zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<template>
  <a-row :gutter="10">
    <a-col :md="8" :sm="24">
      <a-card :bordered="false" style="min-height: 800px" v-loading="loading">
        <div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
          <a-input-search @search="onSearch" style="width:100%;margin-top: 10px" placeholder="请输入文件名称" />
          <!-- 树-->
          <!-- <br></br>
          <a>根目录</a> -->
          <template v-if="docTree.length > 0">
 
            <!--组织机构-->
            <a-tree showLine :selectedKeys="selectedKeys" :checkStrictly="true" @select="onSelect"
              :dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }" :treeData="docTree"
              :autoExpandParent="autoExpandParent" :expandedKeys="iExpandedKeys" @expand="onExpand" />
 
          </template>
          <div style="margin-top: 24px;" v-else-if="docTree.length == 0">
            <h3><span>暂无文件信息</span></h3>
          </div>
          <!-- <div style="margin-top: 24px;" v-else><h3>普通员工暂无此权限</h3></div> -->
        </div>
      </a-card>
    </a-col>
    <a-col :md="16" :sm="24">
      <a-card :bordered="false" title="权限配置" style="min-height: 800px" v-loading="rightLoading">
        <a-table :columns="columns" :data-source="data" :pagination="false" :expanded-row-keys.sync="expandedRowKeys">
          <span slot="visit" slot-scope="text, record">
            <a-switch size="small" :checked="record.visit + '' == '1' ? true : false"
              @change="visitChange($event, record)"></a-switch>
          </span>
          <span slot="download" slot-scope="text, record">
            <a-switch size="small" :checked="record.download + '' == '1' ? true : false"
              @change="downloadChange($event, record)"></a-switch>
          </span>
          <span slot="manage" slot-scope="text, record">
            <a-switch size="small" :checked="record.manage + '' == '1' ? true : false"
              @change="manageChange($event, record)"></a-switch>
          </span>
        </a-table>
 
      </a-card>
    </a-col>
  </a-row>
</template>
<script>
import { getAction, postAction } from '@/api/manage';
import { JeecgListMixin } from '@/mixins/JeecgListMixin';
 
export default {
  name: 'PathRoleUserList',
  mixins: [JeecgListMixin],
 
  data() {
    return {
      columns: [
        { title: '角色', dataIndex: 'roleName', key: 'roleName' },
        { title: '用户', dataIndex: 'userName', key: 'userName' },
        { title: '访问权限', dataIndex: 'visit', key: 'visit', scopedSlots: { customRender: 'visit' } },
        { title: '下载权限', dataIndex: 'download', key: 'download', scopedSlots: { customRender: 'download' } },
        { title: '管理权限', dataIndex: 'manage', key: 'manage', scopedSlots: { customRender: 'manage' } },
      ],
      data: [],
 
      expandedRowKeys: [],
      currentDeptId: '',
      iExpandedKeys: [0],
      loading: false,
      rightLoading: false,
      autoExpandParent: true,
      currFlowId: '',
      currFlowName: '',
      disable: true,
      treeData: [],
      visible: false,
      docTree: [],
      rightClickSelectedKey: '',
      hiding: true,
      model: {},
      dropTrigger: '',
      depart: {},
      disableSubmit: false,
      checkedKeys: [],
      selectedKeys: [],
      autoIncr: 1,
      currSelected: {},
      form: this.$form.createForm(this),
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      graphDatasource: {
        nodes: [],
        edges: []
      },
      userIdentity: "",
    }
  },
  methods: {
    callback(key) {
      //console.log(key)
    },
    loadData() {
      this.refresh();
    },
    clearSelectedDepartKeys() {
      this.checkedKeys = [];
      this.selectedKeys = [];
    },
    loadTree() {
      this.loading = true
      var that = this
      that.treeData = []
      that.docTree = []
 
 
      getAction("/document/queryAsyncTreeList", null).then(res => {
        if (res.success && res.result) {
          console.log("获取树列表::", res);
 
          var root = { isLeaf: false, key: 0, path: '/', pathId: '1', title: '根目录' }
          root.children = res.result.treeList;
          console.log("获取树列表::", [root]);
          that.treeData = [root]
          that.docTree = [root]
 
 
          this.loadPathPrem(1)
 
          this.loading = false
        }
      })
 
    },
    setThisExpandedKeys(node) {
      //只展开一级目录
      if (node.children && node.children.length > 0) {
        this.iExpandedKeys.push(node.key)
        //下方代码放开注释则默认展开所有节点
        /**
        for (let a = 0; a < node.children.length; a++) {
          this.setThisExpandedKeys(node.children[a])
        }
        */
      }
    },
    refresh() {
      this.loading = true
      this.loadTree()
    },
 
    onExpand(expandedKeys, treeNode) {
      // console.log('onExpand', expandedKeys)
      // if not set autoExpandParent to false, if children expanded, parent can not collapse.
      // or, you can remove all expanded children keys.
      this.iExpandedKeys = expandedKeys
      this.autoExpandParent = false
      if (!treeNode.expanded) return
      return new Promise(resolve => {
        console.log("异步加载的treeNode:", treeNode);
        if (treeNode.node.dataRef.children.length > 0) {
          resolve()
          return
        }
        this.loading = true
        getAction("/document/queryAsyncTreeList", treeNode.node.dataRef).then(res => {
          console.log("异步加载内容::", res)
          treeNode.node.dataRef.children = res.result.treeList
          this.treeData = [...this.treeData]
          treeNode.expanded = false
          resolve()
        }).finally(() => {
          this.loading = false
        })
      })
 
 
    },
 
    onSearch(value) {
      let that = this
      if (value) {
        getAction("/document/queryAsyncTreeList", { fileName: value }).then((res) => {
          if (res.success) {
            that.docTree = res.result.treeList
 
          } else {
            that.$message.warning(res.message)
          }
        })
      } else {
        that.loadTree()
      }
 
    },
    onCheck(checkedKeys, e) {
      let record = e.node.dataRef;
      console.log('onCheck', checkedKeys, e);
      this.checkedKeys = [];
 
      this.hiding = false;
    },
    onSelect(selectedKeys, e) {
      console.log('onSelect', selectedKeys, e);
      if (this.selectedKeys[0] !== selectedKeys[0]) {
        this.selectedKeys = [selectedKeys[0]];
      }
      let record = e.node.dataRef;
      this.loadPathPrem(record.pathId)
 
    },
    loadPathPrem(pathId) {
      this.rightLoading = true
      getAction("/pathPermission/queryAll", { 'pathId': pathId }).then(res => {
        console.log("获取权限分配情况res:::", res);
        this.data = res.result;
        this.rightLoading = false
      })
    },
    visitChange(event, record) {
      console.log("访问权限更改EVENT:::", event, "RECORD:::", record);
      record.visit = (event ? 1 : 0)
      this.saveChange(record, 1)
    },
    downloadChange(event, record) {
      console.log("下载权限更改EVENT:::", event, "RECORD:::", record);
      record.download = (event ? 1 : 0)
      this.saveChange(record, 2)
    },
    manageChange(event, record) {
      console.log("管理权限更改EVENT:::", event, "RECORD:::", record);
      record.manage = (event ? 1 : 0)
      this.saveChange(record, 3)
    },
 
    saveChange(record, type) {
      console.log("开始保存权限 Record:", record);
      postAction("/pathPermission/save", record).then(res => {
        console.log("保存文件权限RES::", res);
        if (res.success) {
 
        } else {
          this.$message.error(res.msg)
          if (type === 1) {
            record.visit = !record.visit
          } else if (type === 2) {
            record.download = !record.download
          } else if (type === 3) {
            record.manage = !record.manage
          }
        }
        this.loadPathPrem(record.pathId)
      })
    }
  },
  created() {
    this.currFlowId = this.$route.params.id
    this.currFlowName = this.$route.params.name
    // this.loadTree()
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>