user-select.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="visible"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. top="5vh"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="70%"
  11. >
  12. <el-card shadow="never">
  13. <ele-split-layout width="244px" allow-collapse>
  14. <div class="ele-border-lighter split-layout-right-content">
  15. <DepartmentTree
  16. @handleNodeClick="handleNodeClick"
  17. :isFirstRefreshTable="false"
  18. ref="treeList"
  19. />
  20. </div>
  21. <!-- 表格 -->
  22. <template v-slot:content>
  23. <user-select-search @search="reload"></user-select-search>
  24. <ele-pro-table
  25. class="table1"
  26. ref="table222"
  27. :columns="columns1"
  28. :datasource="datasource"
  29. :selection.sync="selection"
  30. height="calc(100vh - 430px)"
  31. cache-key="systemRoleTable3"
  32. row-key="id"
  33. ></ele-pro-table>
  34. </template>
  35. </ele-split-layout>
  36. </el-card>
  37. <div slot="footer" class="dialog-footer">
  38. <el-button type="primary" size="small" @click="selected">选择</el-button>
  39. <el-button size="small" @click="handleClose">关闭</el-button>
  40. </div>
  41. </el-dialog>
  42. </template>
  43. <script>
  44. import { getUserPage } from '@/api/system/organization';
  45. import DepartmentTree from './departmentTree.vue';
  46. import userSelectSearch from './user-select-search.vue';
  47. export default {
  48. components: {
  49. DepartmentTree,
  50. userSelectSearch
  51. },
  52. props: {},
  53. data() {
  54. return {
  55. visible: false,
  56. currentIndex: 0,
  57. title: '选择',
  58. statusOptions: [
  59. { value: 1, label: '全职' },
  60. { value: 2, label: '兼职' },
  61. { value: 3, label: '实习' },
  62. { value: 4, label: '正式' },
  63. { value: 5, label: '试用' },
  64. { value: 6, label: '离职' }
  65. ],
  66. selection: [],
  67. columns1: [
  68. {
  69. width: 45,
  70. type: 'selection',
  71. columnKey: 'selection',
  72. reserveSelection: true
  73. },
  74. {
  75. columnKey: 'index',
  76. label: '序号',
  77. type: 'index',
  78. width: 55
  79. },
  80. {
  81. prop: 'name',
  82. label: '姓名',
  83. sortable: 'custom',
  84. showOverflowTooltip: true,
  85. minWidth: 110
  86. },
  87. {
  88. prop: 'jobNumber',
  89. label: '工号',
  90. sortable: 'custom',
  91. showOverflowTooltip: true,
  92. minWidth: 110
  93. },
  94. {
  95. prop: 'loginName',
  96. label: '用户账号',
  97. sortable: 'custom',
  98. showOverflowTooltip: true,
  99. minWidth: 110
  100. },
  101. {
  102. prop: 'sex',
  103. label: '性别',
  104. sortable: 'custom',
  105. showOverflowTooltip: true,
  106. minWidth: 80,
  107. formatter: (_row, _column, cellValue) => {
  108. return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
  109. }
  110. },
  111. {
  112. prop: 'status',
  113. label: '状态',
  114. sortable: 'custom',
  115. width: 80,
  116. formatter: (_row, _column, cellValue) => {
  117. const dom = this.statusOptions.find((item) => {
  118. return item.value == cellValue;
  119. });
  120. return dom ? dom.label : '';
  121. }
  122. }
  123. ]
  124. };
  125. },
  126. computed: {},
  127. watch: {},
  128. methods: {
  129. /* 表格数据源 */
  130. datasource({ page, limit, where }) {
  131. return getUserPage({
  132. pageNum: page,
  133. size: limit,
  134. ...where
  135. });
  136. },
  137. /* 刷新表格 */
  138. reload(where) {
  139. this.$refs.table222.reload({ pageNum: 1, where: where });
  140. },
  141. open(row, index) {
  142. this.visible = true;
  143. this.selection = [];
  144. this.currentIndex = index;
  145. this.$refs.table222.clearSelection();
  146. },
  147. handleNodeClick(data, node) {
  148. this.curNodeData = data;
  149. this.reload({ groupId: data.id });
  150. },
  151. handleClose() {
  152. this.visible = false;
  153. },
  154. selected() {
  155. if (!this.selection.length) return this.$message.warning('请选择');
  156. this.$emit('changeParent', this.selection, this.currentIndex);
  157. this.handleClose();
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. ::v-deep .table1 .el-table .el-table__cell .cell {
  164. display: flex;
  165. width: 100%;
  166. justify-content: center;
  167. }
  168. </style>