合同小程序后台管理系统前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
5.2 KiB

  1. <template>
  2. <div>
  3. <!--引用表格-->
  4. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  5. <!--插槽:table标题-->
  6. <template #tableTitle>
  7. <a-button type="primary" v-auth="'store:app_store:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
  8. <a-button type="primary" v-auth="'store:app_store:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
  9. <j-upload-button type="primary" v-auth="'store:app_store:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls"
  10. >导入</j-upload-button
  11. >
  12. <a-dropdown v-if="selectedRowKeys.length > 0">
  13. <template #overlay>
  14. <a-menu>
  15. <a-menu-item key="1" @click="batchHandleDelete">
  16. <Icon icon="ant-design:delete-outlined" />
  17. 删除
  18. </a-menu-item>
  19. </a-menu>
  20. </template>
  21. <a-button v-auth="'store:app_store:deleteBatch'"
  22. >批量操作
  23. <Icon icon="mdi:chevron-down" />
  24. </a-button>
  25. </a-dropdown>
  26. <!-- 高级查询 -->
  27. <super-query :config="superQueryConfig" @search="handleSuperQuery" />
  28. </template>
  29. <!--操作栏-->
  30. <template #action="{ record }">
  31. <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
  32. </template>
  33. <!--字段回显插槽-->
  34. <template #bodyCell="{ column, record, index, text }"> </template>
  35. </BasicTable>
  36. <!-- 表单区域 -->
  37. <AppStoreModal @register="registerModal" @success="handleSuccess" />
  38. </div>
  39. </template>
  40. <script lang="ts" name="store-appStore" setup>
  41. import { ref, reactive, computed, unref } from 'vue';
  42. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  43. import { useModal } from '/@/components/Modal';
  44. import { useListPage } from '/@/hooks/system/useListPage';
  45. import AppStoreModal from './components/AppStoreModal.vue';
  46. import { columns, searchFormSchema, superQuerySchema } from './AppStore.data';
  47. import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AppStore.api';
  48. import { downloadFile } from '/@/utils/common/renderUtils';
  49. import { useUserStore } from '/@/store/modules/user';
  50. const queryParam = reactive<any>({});
  51. const checkedKeys = ref<Array<string | number>>([]);
  52. const userStore = useUserStore();
  53. //注册model
  54. const [registerModal, { openModal }] = useModal();
  55. //注册table数据
  56. const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
  57. tableProps: {
  58. title: '门店管理',
  59. api: list,
  60. columns,
  61. canResize: false,
  62. formConfig: {
  63. //labelWidth: 120,
  64. schemas: searchFormSchema,
  65. autoSubmitOnEnter: true,
  66. showAdvancedButton: true,
  67. fieldMapToNumber: [],
  68. fieldMapToTime: [],
  69. },
  70. actionColumn: {
  71. width: 120,
  72. fixed: 'right',
  73. },
  74. beforeFetch: (params) => {
  75. return Object.assign(params, queryParam);
  76. },
  77. },
  78. exportConfig: {
  79. name: '门店管理',
  80. url: getExportUrl,
  81. params: queryParam,
  82. },
  83. importConfig: {
  84. url: getImportUrl,
  85. success: handleSuccess,
  86. },
  87. });
  88. const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
  89. // 高级查询配置
  90. const superQueryConfig = reactive(superQuerySchema);
  91. /**
  92. * 高级查询事件
  93. */
  94. function handleSuperQuery(params) {
  95. Object.keys(params).map((k) => {
  96. queryParam[k] = params[k];
  97. });
  98. reload();
  99. }
  100. /**
  101. * 新增事件
  102. */
  103. function handleAdd() {
  104. openModal(true, {
  105. isUpdate: false,
  106. showFooter: true,
  107. });
  108. }
  109. /**
  110. * 编辑事件
  111. */
  112. function handleEdit(record: Recordable) {
  113. openModal(true, {
  114. record,
  115. isUpdate: true,
  116. showFooter: true,
  117. });
  118. }
  119. /**
  120. * 详情
  121. */
  122. function handleDetail(record: Recordable) {
  123. openModal(true, {
  124. record,
  125. isUpdate: true,
  126. showFooter: false,
  127. });
  128. }
  129. /**
  130. * 删除事件
  131. */
  132. async function handleDelete(record) {
  133. await deleteOne({ id: record.id }, handleSuccess);
  134. }
  135. /**
  136. * 批量删除事件
  137. */
  138. async function batchHandleDelete() {
  139. await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
  140. }
  141. /**
  142. * 成功回调
  143. */
  144. function handleSuccess() {
  145. (selectedRowKeys.value = []) && reload();
  146. }
  147. /**
  148. * 操作栏
  149. */
  150. function getTableAction(record) {
  151. return [
  152. {
  153. label: '编辑',
  154. onClick: handleEdit.bind(null, record),
  155. auth: 'store:app_store:edit',
  156. },
  157. ];
  158. }
  159. /**
  160. * 下拉操作栏
  161. */
  162. function getDropDownAction(record) {
  163. return [
  164. {
  165. label: '详情',
  166. onClick: handleDetail.bind(null, record),
  167. },
  168. {
  169. label: '删除',
  170. popConfirm: {
  171. title: '是否确认删除',
  172. confirm: handleDelete.bind(null, record),
  173. placement: 'topLeft',
  174. },
  175. auth: 'store:app_store:delete',
  176. },
  177. ];
  178. }
  179. </script>
  180. <style lang="less" scoped>
  181. :deep(.ant-picker),
  182. :deep(.ant-input-number) {
  183. width: 100%;
  184. }
  185. </style>