userList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. width="65vw"
  5. :visible.sync="show"
  6. :close-on-click-modal="false"
  7. custom-class="ele-dialog-form"
  8. append-to-body
  9. @close="cancel"
  10. >
  11. <ele-split-layout
  12. width="210px"
  13. allow-collapse
  14. :right-style="{ overflow: 'hidden' }"
  15. >
  16. <div>
  17. <div class="ele-border-lighter sys-organization-list">
  18. <el-tree
  19. ref="tree"
  20. :data="data"
  21. highlight-current
  22. node-key="id"
  23. :props="{ label: 'name' }"
  24. :expand-on-click-node="false"
  25. :default-expand-all="true"
  26. @node-click="onNodeClick"
  27. /> </div
  28. >.
  29. </div>
  30. <template v-slot:content>
  31. <ele-pro-table
  32. ref="table"
  33. :columns="columns"
  34. :datasource="datasource"
  35. :selection.sync="selection"
  36. :current.sync="current"
  37. highlight-current-row
  38. cache-key="systemRoleTable3"
  39. aaaaaa
  40. row-key="id"
  41. >
  42. </ele-pro-table>
  43. </template>
  44. </ele-split-layout>
  45. <template v-slot:footer>
  46. <el-button @click="cancel">取消</el-button>
  47. <el-button type="primary" @click="save"> 确认 </el-button>
  48. </template>
  49. </ele-modal>
  50. </template>
  51. <script>
  52. import { getUserPage } from '@/api/system/organization';
  53. import { listOrganizations } from '@/api/system/organization';
  54. export default {
  55. data() {
  56. return {
  57. data: [],
  58. show: false,
  59. organizationId: '',
  60. // 表格列配置
  61. current: {},
  62. selection: [],
  63. disArr: [],
  64. key: '',
  65. isAll:2 //多选:1 单选:2
  66. };
  67. },
  68. computed: {
  69. columns() {
  70. return [
  71. {
  72. width: 45,
  73. type: 'selection',
  74. columnKey: 'selection',
  75. align: 'center', reserveSelection: true,
  76. show: this.isAll == 1,
  77. selectable: (row, index) => {
  78. return !this.disArr.includes(row.id);
  79. }
  80. },
  81. {
  82. columnKey: 'index',
  83. type: 'index',
  84. label: '序号',
  85. width: 45,
  86. align: 'center',
  87. showOverflowTooltip: true,
  88. fixed: 'left'
  89. },
  90. {
  91. prop: 'name',
  92. label: '姓名',
  93. sortable: 'custom',
  94. showOverflowTooltip: true,
  95. minWidth: 110
  96. },
  97. {
  98. prop: 'jobNumber',
  99. label: '工号',
  100. sortable: 'custom',
  101. showOverflowTooltip: true,
  102. minWidth: 110
  103. },
  104. {
  105. prop: 'loginName',
  106. label: '用户账号',
  107. sortable: 'custom',
  108. showOverflowTooltip: true,
  109. minWidth: 110
  110. },
  111. {
  112. prop: 'sex',
  113. label: '性别',
  114. sortable: 'custom',
  115. showOverflowTooltip: true,
  116. minWidth: 80,
  117. formatter: (_row, _column, cellValue) => {
  118. return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
  119. }
  120. }
  121. ];
  122. }
  123. },
  124. created() {},
  125. methods: {
  126. /* 查询 */
  127. query() {
  128. listOrganizations()
  129. .then((list) => {
  130. let _list = list.filter((i) => i.name != '超级管理员');
  131. this.data = this.$util.toTreeData({
  132. data: _list,
  133. idField: 'id',
  134. parentIdField: 'parentId'
  135. });
  136. this.$nextTick(() => {
  137. this.onNodeClick(this.data[0]);
  138. });
  139. })
  140. .catch((e) => {
  141. // this.$message.error(e.message);
  142. });
  143. },
  144. async open(key) {
  145. this.query();
  146. this.key = key;
  147. this.show = true;
  148. },
  149. /* 表格数据源 */
  150. async datasource({ page, limit, where, order }) {
  151. let data = await getUserPage({
  152. ...where,
  153. ...order,
  154. pageNum: page,
  155. size: limit,
  156. groupId: this.organizationId
  157. });
  158. return data;
  159. },
  160. /* 保存编辑 */
  161. save() {
  162. let data =
  163. this.isAll == 1
  164. ? JSON.parse(JSON.stringify(this.selection))
  165. : JSON.parse(JSON.stringify(this.current));
  166. this.$emit('success', { data, key: this.key });
  167. this.show = false;
  168. },
  169. onNodeClick(val) {
  170. this.organizationId = val.id;
  171. this.reload();
  172. },
  173. /* 刷新表格 */
  174. reload(where) {
  175. this.$refs.table.reload({ pageNum: 1, where: where });
  176. },
  177. cancel() {
  178. this.show = false;
  179. }
  180. }
  181. };
  182. </script>
  183. <style scoped lang="scss">
  184. :deep(.ele-split-panel-wrap) {
  185. height: 50vh;
  186. overflow-y: auto;
  187. }
  188. :deep(.el-checkbox__input.is-disabled .el-checkbox__inner) {
  189. background-color: #f3f3f3;
  190. }
  191. </style>