affdff5db8689d183fe3411fea98c1555c07f71a.svn-base 6.7 KB

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