DepartUserList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <a-row :gutter="10">
  3. <a-col :md="8" :sm="24">
  4. <a-card :bordered="false">
  5. <div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
  6. <a-input-search @search="onSearch" style="width:100%;margin-top: 10px" placeholder="请输入部门名称"/>
  7. <!-- 树-->
  8. <template v-if="userIdentity === '2' && departTree.length>0">
  9. <!--组织机构-->
  10. <a-tree
  11. showLine
  12. :selectedKeys="selectedKeys"
  13. :checkStrictly="true"
  14. @select="onSelect"
  15. :dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
  16. :treeData="departTree"
  17. :autoExpandParent="autoExpandParent"
  18. />
  19. </template>
  20. <div style="margin-top: 24px;" v-else-if="userIdentity === '2' && departTree.length==0">
  21. <h3><span>您的部门下暂无有效部门信息</span></h3>
  22. </div>
  23. <div style="margin-top: 24px;" v-else><h3>普通员工暂此权限</h3></div>
  24. </div>
  25. </a-card>
  26. </a-col>
  27. <a-col :md="16" :sm="24">
  28. <a-card :bordered="false">
  29. <a-tabs defaultActiveKey="2" @change="callback">
  30. <a-tab-pane tab="基本信息" key="1" forceRender>
  31. <Dept-Base-Info ref="DeptBaseInfo"></Dept-Base-Info>
  32. </a-tab-pane>
  33. <a-tab-pane tab="用户信息" key="2">
  34. <Dept-User-Info ref="DeptUserInfo" @clearSelectedDepartKeys="clearSelectedDepartKeys"></Dept-User-Info>
  35. </a-tab-pane>
  36. <a-tab-pane tab="部门角色" key="3" forceRender>
  37. <dept-role-info ref="DeptRoleInfo" @clearSelectedDepartKeys="clearSelectedDepartKeys"/>
  38. </a-tab-pane>
  39. </a-tabs>
  40. </a-card>
  41. </a-col>
  42. </a-row>
  43. </template>
  44. <script>
  45. import DeptBaseInfo from './modules/DeptBaseInfo'
  46. import DeptUserInfo from './modules/DeptUserInfo'
  47. import {queryMyDepartTreeList, searchByKeywords} from '@/api/api'
  48. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  49. import DeptRoleInfo from './modules/DeptRoleInfo'
  50. export default {
  51. name: 'DepartUserList',
  52. mixins: [JeecgListMixin],
  53. components: {
  54. DeptRoleInfo,
  55. DeptBaseInfo,
  56. DeptUserInfo,
  57. },
  58. data() {
  59. return {
  60. currentDeptId: '',
  61. iExpandedKeys: [],
  62. loading: false,
  63. autoExpandParent: true,
  64. currFlowId: '',
  65. currFlowName: '',
  66. disable: true,
  67. treeData: [],
  68. visible: false,
  69. departTree: [],
  70. rightClickSelectedKey: '',
  71. hiding: true,
  72. model: {},
  73. dropTrigger: '',
  74. depart: {},
  75. disableSubmit: false,
  76. checkedKeys: [],
  77. selectedKeys: [],
  78. autoIncr: 1,
  79. currSelected: {},
  80. form: this.$form.createForm(this),
  81. labelCol: {
  82. xs: {span: 24},
  83. sm: {span: 5}
  84. },
  85. wrapperCol: {
  86. xs: {span: 24},
  87. sm: {span: 16}
  88. },
  89. graphDatasource: {
  90. nodes: [],
  91. edges: []
  92. },
  93. userIdentity:"",
  94. }
  95. },
  96. methods: {
  97. callback(key) {
  98. console.log(key)
  99. },
  100. loadData() {
  101. this.refresh();
  102. },
  103. clearSelectedDepartKeys() {
  104. this.checkedKeys = [];
  105. this.selectedKeys = [];
  106. this.currentDeptId = '';
  107. this.$refs.DeptUserInfo.currentDeptId='';
  108. this.$refs.DeptRoleInfo.currentDeptId='';
  109. },
  110. loadTree() {
  111. var that = this
  112. that.treeData = []
  113. that.departTree = []
  114. queryMyDepartTreeList().then((res) => {
  115. if (res.success && res.result ) {
  116. for (let i = 0; i < res.result.length; i++) {
  117. let temp = res.result[i]
  118. that.treeData.push(temp)
  119. that.departTree.push(temp)
  120. that.setThisExpandedKeys(temp)
  121. // console.log(temp.id)
  122. }
  123. this.loading = false
  124. }
  125. that.userIdentity = res.message
  126. })
  127. },
  128. setThisExpandedKeys(node) {
  129. if (node.children && node.children.length > 0) {
  130. this.iExpandedKeys.push(node.key)
  131. for (let a = 0; a < node.children.length; a++) {
  132. this.setThisExpandedKeys(node.children[a])
  133. }
  134. }
  135. },
  136. refresh() {
  137. this.loading = true
  138. this.loadTree()
  139. },
  140. onExpand(expandedKeys) {
  141. // console.log('onExpand', expandedKeys)
  142. // if not set autoExpandParent to false, if children expanded, parent can not collapse.
  143. // or, you can remove all expanded children keys.
  144. this.iExpandedKeys = expandedKeys
  145. this.autoExpandParent = false
  146. },
  147. onSearch(value) {
  148. let that = this
  149. if (value) {
  150. searchByKeywords({keyWord: value}).then((res) => {
  151. if (res.success) {
  152. that.departTree = []
  153. for (let i = 0; i < res.result.length; i++) {
  154. let temp = res.result[i]
  155. that.departTree.push(temp)
  156. }
  157. } else {
  158. that.$message.warning(res.message)
  159. }
  160. })
  161. } else {
  162. that.loadTree()
  163. }
  164. },
  165. onCheck(checkedKeys, e) {
  166. let record = e.node.dataRef;
  167. // console.log('onCheck', checkedKeys, e);
  168. this.checkedKeys = [];
  169. // if (e.checked === true) {
  170. this.currentDeptId = record.id;
  171. this.checkedKeys.push(record.id);
  172. this.$refs.DeptBaseInfo.open(record);
  173. this.$refs.DeptUserInfo.open(record);
  174. this.$refs.DeptRoleInfo.open(record);
  175. // }
  176. // else {
  177. // this.checkedKeys = [];
  178. // this.$refs.DeptBaseInfo.clearForm();
  179. // this.$refs.DeptUserInfo.clearList();
  180. // }
  181. this.hiding = false;
  182. // this.checkedKeys = checkedKeys.checked
  183. },
  184. onSelect(selectedKeys, e) {
  185. if (this.selectedKeys[0] !== selectedKeys[0]) {
  186. this.selectedKeys = [selectedKeys[0]];
  187. }
  188. let record = e.node.dataRef;
  189. this.checkedKeys.push(record.id);
  190. this.$refs.DeptBaseInfo.open(record);
  191. this.$refs.DeptUserInfo.onClearSelected();
  192. this.$refs.DeptUserInfo.open(record);
  193. this.$refs.DeptRoleInfo.onClearSelected();
  194. this.$refs.DeptRoleInfo.open(record);
  195. },
  196. },
  197. created() {
  198. this.currFlowId = this.$route.params.id
  199. this.currFlowName = this.$route.params.name
  200. // this.loadTree()
  201. },
  202. }
  203. </script>
  204. <style scoped>
  205. @import '~@assets/less/common.less'
  206. </style>