TenantUserSelectModal.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!--套餐中使用的用户选择框-->
  2. <template>
  3. <div>
  4. <BasicModal
  5. v-bind="$attrs"
  6. @register="register"
  7. :title="modalTitle"
  8. width="900px"
  9. wrapClassName="j-user-select-modal"
  10. @ok="handleOk"
  11. destroyOnClose
  12. >
  13. <BasicTable ref="tableRef" @register="registerTable" :rowSelection="rowSelection">
  14. <template #tableTitle></template>
  15. </BasicTable>
  16. </BasicModal>
  17. </div>
  18. </template>
  19. <script lang="ts">
  20. import { defineComponent, ref } from 'vue';
  21. import { BasicModal, useModalInner } from '/@/components/Modal';
  22. import { getTenantUserList } from '../tenant.api';
  23. import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
  24. import { useListPage } from '/@/hooks/system/useListPage';
  25. import { userColumns, userSearchFormSchema } from '../tenant.data';
  26. export default defineComponent({
  27. name: 'TenantUserSelectModal',
  28. components: {
  29. //此处需要异步加载BasicTable
  30. BasicModal,
  31. BasicTable: createAsyncComponent(() => import('/@/components/Table/src/BasicTable.vue'), {
  32. loading: true,
  33. }),
  34. },
  35. props: {
  36. //选择框标题
  37. modalTitle: {
  38. type: String,
  39. default: '选择用户',
  40. },
  41. //查询参数
  42. tenantId: {
  43. type: Number,
  44. default: 0,
  45. },
  46. //排除用户id的集合
  47. excludeUserIdList: {
  48. type: Array,
  49. default: [],
  50. },
  51. },
  52. emits: ['register', 'on-select'],
  53. setup(props, { emit, refs }) {
  54. const tableScroll = ref<any>({ x: false });
  55. const tableRef = ref();
  56. //注册弹框
  57. const [register, { closeModal }] = useModalInner(() => {
  58. if (window.innerWidth < 900) {
  59. tableScroll.value = { x: 900 };
  60. } else {
  61. tableScroll.value = { x: false };
  62. }
  63. setTimeout(() => {
  64. if (tableRef.value) {
  65. tableRef.value.setSelectedRowKeys([]);
  66. }
  67. }, 800);
  68. });
  69. //定义表格列
  70. const columns = [
  71. {
  72. title: '账号',
  73. dataIndex: 'username',
  74. width: 40,
  75. align: 'left',
  76. },
  77. {
  78. title: '姓名',
  79. dataIndex: 'realname',
  80. width: 40,
  81. },
  82. {
  83. title: '性别',
  84. dataIndex: 'sex_dictText',
  85. width: 20,
  86. },
  87. {
  88. title: '手机号码',
  89. dataIndex: 'phone',
  90. width: 30,
  91. },
  92. {
  93. title: '邮箱',
  94. dataIndex: 'email',
  95. width: 40,
  96. },
  97. {
  98. title: '状态',
  99. dataIndex: 'status_dictText',
  100. width: 20,
  101. },
  102. ];
  103. // 列表页面公共参数、方法
  104. const { prefixCls, tableContext } = useListPage({
  105. designScope: 'tenant-template',
  106. tableProps: {
  107. api: getTenantUserList,
  108. columns: userColumns,
  109. scroll: { y: 390 },
  110. rowKey: 'id',
  111. showActionColumn: false,
  112. formConfig: {
  113. schemas: userSearchFormSchema,
  114. labelWidth: 60,
  115. actionColOptions: {
  116. xs: 24,
  117. sm: 8,
  118. md: 8,
  119. lg: 8,
  120. xl: 8,
  121. xxl: 8,
  122. },
  123. },
  124. beforeFetch: (params) => {
  125. return Object.assign(params, { userTenantId: props.tenantId });
  126. },
  127. },
  128. });
  129. const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
  130. /**
  131. * 确定选择
  132. */
  133. function handleOk() {
  134. //返回选中事件
  135. emit('on-select', rowSelection.selectedRows, rowSelection.selectedRowKeys);
  136. }
  137. return {
  138. handleOk,
  139. register,
  140. columns,
  141. rowSelection,
  142. tableScroll,
  143. tableRef,
  144. registerTable,
  145. };
  146. },
  147. });
  148. </script>
  149. <style scoped>
  150. :deep(.ant-input-suffix) {
  151. display: none;
  152. }
  153. </style>