分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-06-27 77ee85a249a26fcf47c28aebc9cd89b187f9d4dc
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<template>
  <div class="container">
    <el-alert type="success" style=" margin: 20px 20px 0 20px;" show-icon>
      treetable
      <div>
    页面为手动引用的voltable的组件,具体使用见:TreeTable3.vue
      </div>
    </el-alert>
    <!-- 查询配置 -->
    <div style="padding: 0px 20px">
      <VolHeader
        icon="md-apps"
        text="TreeTable"
        style="margin-bottom: 10px; border: 0px; margin-top: 15px"
      >
        <slot>
          <div style="text-align: right">
            <el-button type="primary" size="mini"   @click="search" 
              >查询</el-button
            >
            <el-button type="success" size="mini" style="margin-left: 10px"  @click="getRows">获取选中的行</el-button>
          </div>
        </slot>
      </VolHeader>
      <vol-table
        ref="table"
        :loadKey="true"
        row-key="Role_Id"
        :columns="columns"
        :pagination-hide="false"
        :max-height="450"
        url="/api/Sys_Role/getPageData"
        :index="true"
        :loadTreeChildren="loadTreeChildren"
        @loadBefore="loadTableBefore"
      ></vol-table>
    </div>
  </div>
</template>
<script>
import VolTable from "@/components/basic/VolTable.vue";
import VolHeader from "@/components/basic/VolHeader.vue";
export default {
  components: { VolTable, VolHeader },
  created() {},
  data() {
    return {
      columns: [
        {
          field: "Role_Id",
          title: "角色ID",
          type: "int",
          width: 70,
          readonly: true,
          require: true,
          align: "left",
          sortable: true,
        },
        {
          field: "RoleName",
          title: "角色名称",
          type: "string",
          width: 90,
          require: true,
          align: "left",
        },
        {
          field: "Dept_Id",
          title: "部门ID",
          type: "int",
          width: 90,
          hidden: true,
          align: "left",
        },
        {
          field: "DeptName",
          title: "部门名称",
          type: "string",
          width: 90,
          align: "left",
        },
        {
          field: "Enable",
          title: "是否启用",
          type: "byte",
          bind: { key: "enable", data: [] },
          width: 90,
          align: "left",
        },
        {
          field: "OrderNo",
          title: "排序",
          type: "int",
          width: 90,
          hidden: true,
          align: "left",
        },
        {
          field: "Creator",
          title: "创建人",
          type: "string",
          width: 130,
          readonly: true,
          align: "left",
        },
        {
          field: "CreateDate",
          title: "创建时间",
          type: "datetime",
          width: 90,
          readonly: true,
          align: "left",
          sortable: true,
        },
      ],
    };
  },
  methods: {
    loadTableBefore(params) {
      //Sys_RoleController中始终只加载根节点数据
      params.value = 1;
      return true;
    },
    loadTreeChildren(tree, treeNode, resolve) {
      //加载子节点数据
      let url = `api/role/getTreeTableChildrenData?roleId=${tree.Role_Id}`;
      this.http.post(url, {}).then((result) => {
        resolve(result.rows);
      });
    },
    search() {
      this.$refs.table.load();
    },
    getRows() {
      let rows = this.$refs.table.getSelected();
      if (rows.length == 0) {
        return this.$message.error("请先选中行1");
      }
      let text = "当前选中的行数据:" + JSON.stringify(rows);
      this.$Message.info(text);
    },
  },
};
</script>