user-select.vue 5.4 KB

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