index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div>
  3. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  4. <template #tableTitle>
  5. <a-button preIcon="ant-design:plus-outlined" type="primary" @click="handleAdd" style="margin-right: 5px">新增</a-button>
  6. <a-dropdown v-if="selectedRowKeys.length > 0">
  7. <template #overlay>
  8. <a-menu>
  9. <a-menu-item key="1" @click="batchHandleDelete">
  10. <Icon icon="ant-design:delete-outlined" />
  11. 删除
  12. </a-menu-item>
  13. </a-menu>
  14. </template>
  15. <a-button
  16. >批量操作
  17. <Icon icon="mdi:chevron-down" />
  18. </a-button>
  19. </a-dropdown>
  20. <a-button
  21. preIcon="ant-design:user-add-outlined"
  22. type="primary"
  23. @click="handleInvitation"
  24. style="margin-right: 5px"
  25. :disabled="selectedRowKeys.length === 0"
  26. >邀请用户加入</a-button
  27. >
  28. <a-button
  29. preIcon="ant-design:plus-outlined"
  30. type="primary"
  31. @click="handlePack"
  32. style="margin-right: 5px"
  33. :disabled="selectedRowKeys.length === 0"
  34. >套餐</a-button
  35. >
  36. <a-button type="primary" @click="recycleBinClick" preIcon="ant-design:hdd-outlined">回收站</a-button>
  37. </template>
  38. <template #action="{ record }">
  39. <TableAction :actions="getActions(record)" />
  40. </template>
  41. </BasicTable>
  42. <TenantModal @register="registerModal" @success="reload" />
  43. <!-- <TenantInviteUserModal @register="registerSelUserModal" @inviteOk="handleInviteUserOk"/> -->
  44. <!-- <TenantUserModal @register="registerTenUserModal" /> -->
  45. <!-- 产品包 -->
  46. <!-- <TenantPackList @register="registerPackModal" /> -->
  47. <!-- 租户回收站 -->
  48. <!-- <TenantRecycleBinModal @register="registerRecycleBinModal" @success="reload" /> -->
  49. </div>
  50. </template>
  51. <script lang="ts" name="system-tenant" setup>
  52. import { ref, unref } from 'vue';
  53. import { BasicTable, TableAction } from '/@/components/Table';
  54. import { useModal } from '/@/components/Modal';
  55. import { getTenantList, deleteTenant, batchDeleteTenant, invitationUserJoin } from './tenant.api';
  56. import { columns, searchFormSchema } from './tenant.data';
  57. // import TenantModal from './components/TenantModal.vue';
  58. import { useMessage } from '/@/hooks/web/useMessage';
  59. import { useListPage } from '/@/hooks/system/useListPage';
  60. // import TenantInviteUserModal from './components/TenantInviteUserModal.vue';
  61. // // import TenantUserModal from './components/TenantUserList.vue';
  62. // import TenantPackList from './pack/TenantPackList.vue';
  63. // import TenantRecycleBinModal from './components/TenantRecycleBinModal.vue';
  64. const { createMessage } = useMessage();
  65. const [registerModal, { openModal }] = useModal();
  66. // const [registerSelUserModal, { openModal: userOpenModal }] = useModal();
  67. // const [registerTenUserModal, { openModal: tenUserOpenModal }] = useModal();
  68. // const [registerPackModal, { openModal: packModal }] = useModal();
  69. // const [registerRecycleBinModal, { openModal: recycleBinModal }] = useModal();
  70. // 列表页面公共参数、方法
  71. const { prefixCls, tableContext } = useListPage({
  72. designScope: 'tenant-template',
  73. tableProps: {
  74. title: '租户列表',
  75. api: getTenantList,
  76. columns: columns,
  77. formConfig: {
  78. schemas: searchFormSchema,
  79. fieldMapToTime: [['fieldTime', ['beginDate', 'endDate'], 'YYYY-MM-DD HH:mm:ss']],
  80. },
  81. actionColumn: {
  82. width: 150,
  83. fixed: 'right',
  84. },
  85. },
  86. });
  87. const [registerTable, { reload }, { rowSelection, selectedRowKeys, selectedRows }] = tableContext;
  88. /**
  89. * 操作列定义
  90. * @param record
  91. */
  92. function getActions(record) {
  93. return [
  94. {
  95. label: '编辑',
  96. onClick: handleEdit.bind(null, record),
  97. },
  98. {
  99. label: '删除',
  100. popConfirm: {
  101. title: '是否确认删除',
  102. placement: 'left',
  103. confirm: handleDelete.bind(null, record),
  104. },
  105. },
  106. {
  107. label: '用户',
  108. onClick: handleSeeUser.bind(null, record.id),
  109. },
  110. ];
  111. }
  112. /**
  113. * 新增事件
  114. */
  115. function handleAdd() {
  116. openModal(true, {
  117. isUpdate: false,
  118. });
  119. }
  120. /**
  121. * 编辑事件
  122. */
  123. function handleEdit(record) {
  124. openModal(true, {
  125. record,
  126. isUpdate: true,
  127. });
  128. }
  129. /**
  130. * 删除事件
  131. */
  132. async function handleDelete(record) {
  133. await deleteTenant({ id: record.id }, handleSuccess);
  134. }
  135. /**
  136. * 批量删除事件
  137. */
  138. async function batchHandleDelete() {
  139. await batchDeleteTenant({ ids: selectedRowKeys.value }, handleSuccess);
  140. }
  141. /**
  142. * 邀请用户加入租户
  143. */
  144. function handleInvitation() {
  145. userOpenModal(true, {});
  146. }
  147. /**
  148. * 用户选择回调事件
  149. * @param options
  150. * @param value
  151. */
  152. async function handleInviteUserOk(value) {
  153. //update-begin---author:wangshuai ---date:20230314 for:【QQYUN-4605】后台的邀请谁加入租户,没办法选不是租户下的用户------------
  154. if (value) {
  155. await invitationUserJoin({ ids: selectedRowKeys.value.join(','), phone: value });
  156. }
  157. //update-end---author:wangshuai ---date:20230314 for:【QQYUN-4605】后台的邀请谁加入租户,没办法选不是租户下的用户------------
  158. }
  159. /**
  160. * 查看用户
  161. * @param id
  162. */
  163. function handleSeeUser(id) {
  164. tenUserOpenModal(true, {
  165. id: id,
  166. });
  167. }
  168. /**
  169. * 新增产品包
  170. */
  171. function handlePack() {
  172. if (unref(selectedRowKeys).length > 1) {
  173. createMessage.warn('请选择一个');
  174. return;
  175. }
  176. packModal(true, {
  177. tenantId: unref(selectedRowKeys.value.join(',')),
  178. //我的租户显示新增和编辑产品包
  179. showPackAddAndEdit: true,
  180. });
  181. }
  182. /**
  183. * 回收站
  184. */
  185. function recycleBinClick() {
  186. recycleBinModal(true, {});
  187. }
  188. /**
  189. * 删除成功之后回调事件
  190. */
  191. function handleSuccess() {
  192. (selectedRowKeys.value = []) && reload();
  193. }
  194. </script>