userList.vue 4.6 KB

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