user-select.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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
  14. width="244px"
  15. allow-collapse
  16. :right-style="{ overflow: 'hidden' }"
  17. >
  18. <div class="ele-border-lighter split-layout-right-content">
  19. <DepartmentTree
  20. @handleNodeClick="handleNodeClick"
  21. :isFirstRefreshTable="false"
  22. ref="treeList"
  23. />
  24. </div>
  25. <!-- 表格 -->
  26. <template v-slot:content>
  27. <user-select-search @search="reload"></user-select-search>
  28. <ele-pro-table
  29. ref="table"
  30. :columns="columns"
  31. :datasource="datasource"
  32. row-key="id"
  33. height="calc(100vh - 430px)"
  34. class="dict-table"
  35. cache-key="systemRoleTable3"
  36. :selection.sync="selection"
  37. >
  38. </ele-pro-table>
  39. </template>
  40. </ele-split-layout>
  41. </el-card>
  42. <div slot="footer" class="dialog-footer">
  43. <el-button type="primary" size="small" @click="selected">选择</el-button>
  44. <el-button size="small" @click="handleClose">关闭</el-button>
  45. </div>
  46. </el-dialog>
  47. </template>
  48. <script>
  49. import { getUserPage } from '@/api/system/organization';
  50. import DepartmentTree from './departmentTree.vue';
  51. import userSelectSearch from './user-select-search.vue';
  52. export default {
  53. components: {
  54. DepartmentTree,
  55. userSelectSearch
  56. },
  57. props: {},
  58. data() {
  59. return {
  60. visible: false,
  61. currentIndex: 0,
  62. title: '选择负责人',
  63. statusOptions: [
  64. { value: 1, label: '全职' },
  65. { value: 2, label: '兼职' },
  66. { value: 3, label: '实习' },
  67. { value: 4, label: '正式' },
  68. { value: 5, label: '试用' },
  69. { value: 6, label: '离职' }
  70. ],
  71. selection: [],
  72. columns: [
  73. {
  74. width: 45,
  75. type: 'selection',
  76. columnKey: 'selection',
  77. align: 'center'
  78. },
  79. {
  80. columnKey: 'index',
  81. label: '序号',
  82. type: 'index',
  83. align: 'center',
  84. showOverflowTooltip: true
  85. },
  86. {
  87. prop: 'name',
  88. label: '姓名',
  89. sortable: 'custom',
  90. align: 'center',
  91. showOverflowTooltip: true,
  92. minWidth: 110
  93. },
  94. {
  95. prop: 'jobNumber',
  96. label: '工号',
  97. sortable: 'custom',
  98. align: 'center',
  99. showOverflowTooltip: true,
  100. minWidth: 110
  101. },
  102. {
  103. prop: 'loginName',
  104. label: '用户账号',
  105. sortable: 'custom',
  106. align: 'center',
  107. showOverflowTooltip: true,
  108. minWidth: 110
  109. },
  110. {
  111. prop: 'sex',
  112. label: '性别',
  113. sortable: 'custom',
  114. align: 'center',
  115. showOverflowTooltip: true,
  116. minWidth: 80,
  117. formatter: (_row, _column, cellValue) => {
  118. return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
  119. }
  120. },
  121. {
  122. prop: 'status',
  123. label: '状态',
  124. align: 'center',
  125. sortable: 'custom',
  126. width: 80,
  127. formatter: (_row, _column, cellValue) => {
  128. const dom = this.statusOptions.find((item) => {
  129. return item.value == cellValue;
  130. });
  131. return dom ? dom.label : '';
  132. }
  133. }
  134. ]
  135. };
  136. },
  137. computed: {},
  138. watch: {},
  139. methods: {
  140. /* 表格数据源 */
  141. datasource({ page, limit, where, order }) {
  142. return getUserPage({
  143. pageNum: page,
  144. size: limit,
  145. ...where
  146. });
  147. },
  148. /* 刷新表格 */
  149. reload(where) {
  150. this.$refs.table.reload({ pageNum: 1, where: where });
  151. },
  152. open(row, index) {
  153. this.visible = true;
  154. this.selection = [];
  155. this.currentIndex = index;
  156. this.$refs.table.toggleRowSelection(row);
  157. },
  158. handleNodeClick(data, node) {
  159. this.curNodeData = data;
  160. this.reload({ groupId: data.id });
  161. },
  162. handleClose() {
  163. this.visible = false;
  164. },
  165. selected() {
  166. // if (this.multiple) {
  167. // } else {
  168. // if (!this.current) {
  169. // return this.$message.warning('请选择');
  170. // }
  171. // this.$emit('changeParent', this.current, this.currentIndex);
  172. // }
  173. if (!this.selection.length) return this.$message.warning('请选择');
  174. this.$emit('changeParent', this.selection, this.currentIndex);
  175. this.handleClose();
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .tree_col {
  182. border: 1px solid #eee;
  183. padding: 10px 0;
  184. box-sizing: border-box;
  185. height: 500px;
  186. overflow: auto;
  187. }
  188. .table_col {
  189. padding-left: 10px;
  190. ::v-deep .el-table th.el-table__cell {
  191. background: #f2f2f2;
  192. }
  193. }
  194. .pagination {
  195. text-align: right;
  196. padding: 10px 0;
  197. }
  198. .btns {
  199. text-align: center;
  200. padding: 10px 0;
  201. }
  202. .topsearch {
  203. margin-bottom: 15px;
  204. }
  205. </style>