add.vue 4.5 KB

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