Blame view

example/table.html 2.43 KB
3a3ecabe   Imshann   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  <!DOCTYPE html>
  <html>
  
  <head>
      <meta charset="UTF-8" />
      <title></title>
  </head>
  
  <body>
      <div ng-app="esNgAntd" ng-controller="mainCtrl">
          <div class="container" style="padding: 50px">
                  <es-table columns="columns" d-source="dataSource" row-selection="rowSelection" loading="{{loading}}"/>
          </div>
      </div>
      <script src="https://cdn.staticfile.org/angular.js/1.2.28/angular.min.js"></script>
      <script src="../dist/ng-antd.js"></script>
      <script>
          angular
              .module("esNgAntd")
              .controller("mainCtrl", function ($scope, $timeout) {
                  $scope.loading = false;
  
                  $scope.columns = [
                      {
                          title: "批次",
                          key: "name",
                          width: "100px",
                      },
                      {
                          title: "航线",
                          key: "age",
                      },
                      {
                          title: "状态",
                          key: "status",
                      },
                      {
                          title: "操作",
                          key: "action",
                          render: (value, record, index) => {
                              return `<a ng-click="handleClick(${index})">Delete</a>`;
                          }
                      },
                  ];
  
                  $scope.dataSource = [
                      {
                          id: 1,
                          name: "AAA",
                          age: 32,
                          status: 1,
                      },
                      {
                          id: 2,
                          name: "BBB",
                          age: 42,
                          status: 0,
                      },
                  ];
  
                  $scope.rowSelection = {
                      onChange: (selectedRowKeys, selectedRows) => {
                          // console.log(selectedRowKeys, selectedRows);
                      },
                      getCheckboxProps: (record) => ({
                          disabled: record.age === 42,
                      }),
                  };
  
                  $scope.handleClick = (key) => {
                      $scope.dataSource[key].status = $scope.dataSource[key].status ? 0 : 1;
                      $scope.dataSource.splice(key, 1);
                      console.log($scope.dataSource);
                  };
              });
      </script>
  </body>
  
  </html>