index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <ele-modal
  3. width="980px"
  4. height="60%"
  5. :visible="visibleInChild"
  6. :close-on-click-modal="true"
  7. custom-class="ele-dialog-form"
  8. fullscreen
  9. maxable
  10. title="选择用户"
  11. :append-to-body="appendToBody"
  12. @update:visible="updateVisible"
  13. :maxable="true"
  14. >
  15. <div class="el-dialog-body-custom-height">
  16. <el-row :gutter="5">
  17. <el-col :span="18">
  18. <Organization
  19. @changeList="changeList"
  20. :multipleSelect="multipleSelect"
  21. ref="organization"
  22. />
  23. </el-col>
  24. <el-col :span="6">
  25. <div>
  26. <el-card shadow="never">
  27. <clearList @btnRemoveAll="btnRemoveAll" />
  28. <ele-pro-table
  29. ref="table"
  30. :columns="columns"
  31. :datasource="datasource"
  32. :need-page="false"
  33. :toolbar="false"
  34. tool-class="ele-toolbar-form"
  35. cache-key="systemOrgUserTable"
  36. >
  37. <template v-slot:action="row">
  38. <el-popconfirm
  39. class="ele-action"
  40. title="确定要删除此用户吗?"
  41. @confirm="remove(row)"
  42. >
  43. <template v-slot:reference>
  44. <el-link
  45. type="danger"
  46. :underline="false"
  47. icon="el-icon-delete"
  48. >
  49. 删除
  50. </el-link>
  51. </template>
  52. </el-popconfirm>
  53. </template>
  54. <!-- 角色列 -->
  55. <template v-slot:roles="{ row }">
  56. <el-tag
  57. v-for="item in row.roles"
  58. :key="item.roleId"
  59. type="primary"
  60. size="mini"
  61. :disable-transitions="true"
  62. >
  63. {{ item.roleName }}
  64. </el-tag>
  65. </template>
  66. </ele-pro-table>
  67. </el-card>
  68. </div>
  69. </el-col>
  70. </el-row>
  71. </div>
  72. <div slot="footer" class="dialog-footer">
  73. <el-button icon="el-icon-close" @click="updateVisible">取消</el-button>
  74. <el-button icon="el-icon-check" type="primary" @click="confirm"
  75. >确定</el-button
  76. >
  77. </div>
  78. </ele-modal>
  79. </template>
  80. <script>
  81. import Organization from '@/components/select/organization';
  82. import { getAction } from '@/api/flowable/manage';
  83. import { Message } from 'element-ui';
  84. import clearList from './clear-list.vue';
  85. export default {
  86. name: 'SelectUser',
  87. components: { Organization, clearList },
  88. props: {
  89. visible: {
  90. type: Boolean,
  91. default: false
  92. },
  93. //是否多选
  94. multipleSelect: {
  95. type: Boolean,
  96. default: false
  97. },
  98. type: {
  99. type: String,
  100. default: ''
  101. },
  102. //是否为2级弹出框
  103. appendToBody: {
  104. type: Boolean,
  105. default: true
  106. }
  107. },
  108. data() {
  109. return {
  110. filterText: '',
  111. treeData: [],
  112. defaultProps: {
  113. children: 'children',
  114. label: 'label',
  115. isLeaf: 'isLeaf',
  116. data: 'data'
  117. },
  118. records: [],
  119. total: 0,
  120. selectedRecords: [],
  121. listQuery: {
  122. current: 1,
  123. size: 10,
  124. userId: undefined,
  125. userName: undefined,
  126. orgId: undefined
  127. },
  128. currOrgId: '',
  129. columns: [
  130. {
  131. columnKey: 'index',
  132. type: 'index',
  133. width: 45,
  134. align: 'center',
  135. showOverflowTooltip: true,
  136. fixed: 'left'
  137. },
  138. {
  139. prop: 'name',
  140. label: '姓名',
  141. sortable: 'custom',
  142. showOverflowTooltip: true
  143. },
  144. {
  145. prop: 'loginName',
  146. label: '用户账号',
  147. sortable: 'custom',
  148. showOverflowTooltip: true
  149. },
  150. {
  151. label: '操作',
  152. slot: 'action',
  153. showOverflowTooltip: true
  154. }
  155. ]
  156. };
  157. },
  158. watch: {
  159. filterText(val) {
  160. this.$refs._selectOrgTree.filter(val);
  161. }
  162. },
  163. computed: {
  164. visibleInChild: {
  165. get() {
  166. return this.visible;
  167. },
  168. set(val) {
  169. this.$emit('update:visible', val);
  170. }
  171. }
  172. },
  173. methods: {
  174. datasource() {
  175. return {
  176. list: this.selectedRecords
  177. };
  178. },
  179. remove(row) {
  180. this.selectedRecords.splice(row.$index, 1);
  181. this.$refs.table.reload();
  182. this.$refs.organization.$refs.userList.selectedRecords =
  183. this.selectedRecords;
  184. },
  185. changeList(arr) {
  186. this.selectedRecords = arr;
  187. this.$refs.table.reload();
  188. },
  189. /* 更新visible */
  190. updateVisible(value) {
  191. this.selectedRecords = [];
  192. this.$refs.table.reload();
  193. this.$refs.organization.$refs.userList.selectedRecords = [];
  194. this.$emit('update:visible', value);
  195. this.visibleInChild = false;
  196. },
  197. filterNode(value, data) {
  198. if (!value) return true;
  199. return data.label.indexOf(value) !== -1;
  200. },
  201. // getTreeData() {
  202. // getAction('/sys/org/getSelectTreeData', { type: this.type }).then(
  203. // (res) => {
  204. // const { data } = res;
  205. // this.treeData = data;
  206. // }
  207. // );
  208. // },
  209. handleNodeClick(node) {
  210. this.currOrgId = node.id;
  211. this.listSysUsers();
  212. },
  213. listSysUsers() {
  214. this.listQuery.orgId = this.currOrgId;
  215. getAction('/sys/user/listSelectUser', this.listQuery).then((res) => {
  216. const { data } = res;
  217. this.records = data.records;
  218. this.total = data.total;
  219. });
  220. },
  221. btnQuery() {
  222. this.listQuery.current = 1;
  223. this.listSysUsers();
  224. },
  225. btnReset() {
  226. this.currOrgId = '';
  227. this.listQuery = {
  228. current: 1,
  229. size: 10,
  230. userId: undefined,
  231. userName: undefined,
  232. orgId: undefined
  233. };
  234. this.listSysUsers();
  235. },
  236. btnRemoveAll() {
  237. this.selectedRecords = [];
  238. this.$refs.table.reload();
  239. this.$refs.organization.$refs.userList.selectedRecords = [];
  240. },
  241. btnRemove(row) {
  242. let arr = this.selectedRecords;
  243. arr.splice(
  244. arr.findIndex((item) => item.userId === row.userId),
  245. 1
  246. );
  247. },
  248. confirm() {
  249. if (!this.selectedRecords || this.selectedRecords.length == 0) {
  250. Message.error('请先选择用户');
  251. return;
  252. }
  253. if (this.multipleSelect) {
  254. this.$emit('selectUserFinished', this.selectedRecords);
  255. } else {
  256. this.$emit('selectUserFinished', this.selectedRecords[0]);
  257. }
  258. this.selectedRecords = [];
  259. this.$refs.table.reload();
  260. this.$refs.organization.$refs.userList.selectedRecords = [];
  261. this.visibleInChild = false;
  262. }
  263. }
  264. };
  265. </script>