add.vue 4.4 KB

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