Blame view

ant-design-vue-jeecg/src/views/system/DepartUserList.vue 6.4 KB
肖超群 authored
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
<template>
  <a-row :gutter="10">
    <a-col :md="8" :sm="24">
      <a-card :bordered="false">
        <div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
          <a-input-search @search="onSearch" style="width:100%;margin-top: 10px" placeholder="请输入部门名称"/>
          <!-- 树-->

          <template v-if="userIdentity === '2' && departTree.length>0">

            <!--组织机构-->
            <a-tree
              showLine
              :selectedKeys="selectedKeys"
              :checkStrictly="true"
              @select="onSelect"
              :dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
              :treeData="departTree"
              :autoExpandParent="autoExpandParent"
              :expandedKeys="iExpandedKeys"
              @expand="onExpand"
            />

          </template>
          <div style="margin-top: 24px;" v-else-if="userIdentity === '2' && departTree.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">
        <a-tabs defaultActiveKey="2" @change="callback">
          <a-tab-pane tab="基本信息" key="1" forceRender>
            <Dept-Base-Info ref="DeptBaseInfo"></Dept-Base-Info>
          </a-tab-pane>
          <a-tab-pane tab="用户信息" key="2">
            <Dept-User-Info ref="DeptUserInfo" @clearSelectedDepartKeys="clearSelectedDepartKeys"></Dept-User-Info>
          </a-tab-pane>
          <a-tab-pane tab="部门角色" key="3" forceRender>
            <dept-role-info ref="DeptRoleInfo" @clearSelectedDepartKeys="clearSelectedDepartKeys"/>
          </a-tab-pane>
        </a-tabs>
      </a-card>
    </a-col>
  </a-row>
</template>
<script>
肖超群 authored
50
51
52
53
54
import DeptBaseInfo from './modules/DeptBaseInfo'
import DeptUserInfo from './modules/DeptUserInfo'
import {queryMyDepartTreeList, searchByKeywords} from '@/api/api'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import DeptRoleInfo from './modules/DeptRoleInfo'
肖超群 authored
55
肖超群 authored
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
export default {
  name: 'DepartUserList',
  mixins: [JeecgListMixin],
  components: {
    DeptRoleInfo,
    DeptBaseInfo,
    DeptUserInfo,
  },
  data() {
    return {
      currentDeptId: '',
      iExpandedKeys: [],
      loading: false,
      autoExpandParent: true,
      currFlowId: '',
      currFlowName: '',
      disable: true,
      treeData: [],
      visible: false,
      departTree: [],
      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}
肖超群 authored
90
      },
肖超群 authored
91
92
93
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16}
肖超群 authored
94
      },
肖超群 authored
95
96
97
      graphDatasource: {
        nodes: [],
        edges: []
肖超群 authored
98
      },
肖超群 authored
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
      userIdentity: "",
    }
  },
  methods: {
    callback(key) {
      //console.log(key)
    },
    loadData() {
      this.refresh();
    },
    clearSelectedDepartKeys() {
      this.checkedKeys = [];
      this.selectedKeys = [];
      this.currentDeptId = '';
      this.$refs.DeptUserInfo.currentDeptId = '';
      this.$refs.DeptRoleInfo.currentDeptId = '';
    },
    loadTree() {
      var that = this
      that.treeData = []
      that.departTree = []
      queryMyDepartTreeList().then((res) => {
        if (res.success && res.result) {
          for (let i = 0; i < res.result.length; i++) {
            let temp = res.result[i]
            that.treeData.push(temp)
            that.departTree.push(temp)
            that.setThisExpandedKeys(temp)
            // console.log(temp.id)
肖超群 authored
128
          }
肖超群 authored
129
130
131
132
133
134
135
136
137
138
139
140
          this.loading = false
        }
        that.userIdentity = res.message
      })
    },
    setThisExpandedKeys(node) {
      //只展开一级目录
      if (node.children && node.children.length > 0) {
        this.iExpandedKeys.push(node.key)
        //下方代码放开注释则默认展开所有节点
        /**
         for (let a = 0; a < node.children.length; a++) {
肖超群 authored
141
142
            this.setThisExpandedKeys(node.children[a])
          }
肖超群 authored
143
144
145
146
147
148
149
         */
      }
    },
    refresh() {
      this.loading = true
      this.loadTree()
    },
肖超群 authored
150
肖超群 authored
151
152
153
154
155
156
157
    onExpand(expandedKeys) {
      // 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
    },
肖超群 authored
158
肖超群 authored
159
160
161
162
163
164
165
166
167
    onSearch(value) {
      let that = this
      if (value) {
        searchByKeywords({keyWord: value, myDeptSearch: '1'}).then((res) => {
          if (res.success) {
            that.departTree = []
            for (let i = 0; i < res.result.length; i++) {
              let temp = res.result[i]
              that.departTree.push(temp)
肖超群 authored
168
            }
肖超群 authored
169
170
171
172
173
174
175
          } else {
            that.$message.warning(res.message)
          }
        })
      } else {
        that.loadTree()
      }
肖超群 authored
176
肖超群 authored
177
178
179
180
181
182
183
184
    },
    onCheck(checkedKeys, e) {
      let record = e.node.dataRef;
      // console.log('onCheck', checkedKeys, e);
      this.checkedKeys = [];
      // if (e.checked === true) {
      this.currentDeptId = record.id;
      this.checkedKeys.push(record.id);
肖超群 authored
185
肖超群 authored
186
187
188
189
190
191
192
193
194
      this.$refs.DeptBaseInfo.open(record);
      this.$refs.DeptUserInfo.open(record);
      this.$refs.DeptRoleInfo.open(record);
      // }
      // else {
      //   this.checkedKeys = [];
      //   this.$refs.DeptBaseInfo.clearForm();
      //   this.$refs.DeptUserInfo.clearList();
      // }
肖超群 authored
195
肖超群 authored
196
197
      this.hiding = false;
      // this.checkedKeys = checkedKeys.checked
肖超群 authored
198
    },
肖超群 authored
199
200
201
202
203
204
205
206
207
208
209
    onSelect(selectedKeys, e) {
      if (this.selectedKeys[0] !== selectedKeys[0]) {
        this.selectedKeys = [selectedKeys[0]];
      }
      let record = e.node.dataRef;
      this.checkedKeys.push(record.id);
      this.$refs.DeptBaseInfo.open(record);
      this.$refs.DeptUserInfo.onClearSelected();
      this.$refs.DeptUserInfo.open(record);
      this.$refs.DeptRoleInfo.onClearSelected();
      this.$refs.DeptRoleInfo.open(record);
肖超群 authored
210
    },
肖超群 authored
211
212
213
214
215
216
217
  },
  created() {
    this.currFlowId = this.$route.params.id
    this.currFlowName = this.$route.params.name
    // this.loadTree()
  },
}
肖超群 authored
218
219
</script>
<style scoped>
肖超群 authored
220
@import '~@assets/less/common.less'
肖超群 authored
221
</style>