|
|
@@ -1,25 +1,18 @@
|
|
|
<script lang="ts" setup>
|
|
|
-import { useAccess } from '@vben/access';
|
|
|
+import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter';
|
|
|
+
|
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
|
|
|
|
-import { Button, message, Modal } from 'ant-design-vue';
|
|
|
+import { Button, message } from 'ant-design-vue';
|
|
|
|
|
|
-import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
+import { useTableGridOptions, useVbenVxeGrid } from '#/adapter';
|
|
|
import { TableApi } from '#/api';
|
|
|
-import { TableAction } from '#/components/table-action';
|
|
|
import FormDesign from '#/views/form/design/form-modal.vue';
|
|
|
import FormMenuEdit from '#/views/system/menu/components/editMenu.vue';
|
|
|
|
|
|
import FormEdit from './components/edit.vue';
|
|
|
import FormPreview from './components/preview.vue';
|
|
|
-import { gridOptions, searchFormOptions } from './data.config';
|
|
|
-
|
|
|
-const { hasAccessByCodes } = useAccess();
|
|
|
-
|
|
|
-const [Grid, { reload }] = useVbenVxeGrid({
|
|
|
- formOptions: searchFormOptions,
|
|
|
- gridOptions,
|
|
|
-});
|
|
|
+import { useColumns, useSearchSchema } from './data.config';
|
|
|
|
|
|
const [FormEditModal, formEditApi] = useVbenModal({
|
|
|
connectedComponent: FormEdit,
|
|
|
@@ -37,18 +30,10 @@ const [FormDesignModal, formDesignApi] = useVbenModal({
|
|
|
connectedComponent: FormDesign,
|
|
|
});
|
|
|
|
|
|
-const handleDelete = (id: number) => {
|
|
|
- Modal.confirm({
|
|
|
- iconType: 'info',
|
|
|
- title: '删除提示',
|
|
|
- content: `确定要删除选择的记录吗?`,
|
|
|
- cancelText: `关闭`,
|
|
|
- onOk: async () => {
|
|
|
- await TableApi.deleteDetail(id);
|
|
|
- message.success('数据删除成功');
|
|
|
- reload();
|
|
|
- },
|
|
|
- });
|
|
|
+const handleDelete = async (id: number) => {
|
|
|
+ await TableApi.deleteDetail(id);
|
|
|
+ message.success('数据删除成功');
|
|
|
+ reload();
|
|
|
};
|
|
|
|
|
|
const handleEdit = (record: any, isUpdate: boolean) => {
|
|
|
@@ -73,26 +58,78 @@ const handelSuccess = () => {
|
|
|
};
|
|
|
|
|
|
const handleCreateMenu = (record: any) => {
|
|
|
- formMenuEditApi.setData({
|
|
|
- isUpdate: record.menuId > 0,
|
|
|
- baseData: {
|
|
|
- id: record.menuId,
|
|
|
- component: `/system/design/template/index`,
|
|
|
- meta: { query: { code: record.code } },
|
|
|
- },
|
|
|
- });
|
|
|
- formMenuEditApi.open();
|
|
|
+ formMenuEditApi
|
|
|
+ .setData({
|
|
|
+ isUpdate: record.menuId > 0,
|
|
|
+ baseData: {
|
|
|
+ id: record.menuId,
|
|
|
+ component: `/system/design/template/index`,
|
|
|
+ meta: { query: { code: record.code } },
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .open();
|
|
|
};
|
|
|
|
|
|
const handleDesign = (id: number) => {
|
|
|
- formDesignApi.setData({
|
|
|
- isUpdate: false,
|
|
|
- baseData: {
|
|
|
- id,
|
|
|
- },
|
|
|
- });
|
|
|
- formDesignApi.open();
|
|
|
+ formDesignApi
|
|
|
+ .setData({
|
|
|
+ isUpdate: false,
|
|
|
+ baseData: {
|
|
|
+ id,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .open();
|
|
|
+};
|
|
|
+
|
|
|
+const handleActionClick = async ({
|
|
|
+ code,
|
|
|
+ row,
|
|
|
+}: OnActionClickParams<TableApi.RecordItem>) => {
|
|
|
+ switch (code) {
|
|
|
+ case 'delete': {
|
|
|
+ await handleDelete(row.id);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'design': {
|
|
|
+ handleDesign(row.id);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'edit': {
|
|
|
+ handleEdit(row, true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'editMenu': {
|
|
|
+ handleCreateMenu(row);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'view': {
|
|
|
+ handlePreview(row);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
+
|
|
|
+const [Grid, { reload }] = useVbenVxeGrid(
|
|
|
+ useTableGridOptions({
|
|
|
+ formOptions: {
|
|
|
+ schema: useSearchSchema(),
|
|
|
+ },
|
|
|
+ gridOptions: {
|
|
|
+ columns: useColumns(handleActionClick),
|
|
|
+ proxyConfig: {
|
|
|
+ ajax: {
|
|
|
+ query: async ({ page }, formValues) => {
|
|
|
+ return await TableApi.getPage({
|
|
|
+ pageIndex: page.currentPage,
|
|
|
+ pageSize: page.pageSize,
|
|
|
+ ...formValues,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ } as VxeTableGridOptions,
|
|
|
+ }),
|
|
|
+);
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -112,45 +149,6 @@ const handleDesign = (id: number) => {
|
|
|
新增页面
|
|
|
</Button>
|
|
|
</template>
|
|
|
- <template #action="{ row }">
|
|
|
- <TableAction
|
|
|
- :actions="[
|
|
|
- {
|
|
|
- label: '编辑',
|
|
|
- type: 'text',
|
|
|
- disabled: !hasAccessByCodes(['page:edit']),
|
|
|
- onClick: handleEdit.bind(null, row, true),
|
|
|
- },
|
|
|
- {
|
|
|
- label: '预览',
|
|
|
- type: 'text',
|
|
|
- disabled: !hasAccessByCodes(['page:view']),
|
|
|
- onClick: handlePreview.bind(null, row),
|
|
|
- },
|
|
|
- ]"
|
|
|
- :drop-down-actions="[
|
|
|
- {
|
|
|
- label: row.menuId > 0 ? '修改菜单' : '配置菜单',
|
|
|
- type: 'text',
|
|
|
- disabled:
|
|
|
- row.tableType !== 'page_list'
|
|
|
- ? true
|
|
|
- : !hasAccessByCodes(['page:edit']),
|
|
|
- onClick: handleCreateMenu.bind(null, row),
|
|
|
- },
|
|
|
- {
|
|
|
- label: '表单设计',
|
|
|
- onClick: handleDesign.bind(null, row.id),
|
|
|
- },
|
|
|
- {
|
|
|
- label: '删除',
|
|
|
- type: 'link',
|
|
|
- disabled: !hasAccessByCodes(['page:delete']),
|
|
|
- onClick: handleDelete.bind(null, row.id),
|
|
|
- },
|
|
|
- ]"
|
|
|
- />
|
|
|
- </template>
|
|
|
</Grid>
|
|
|
</Page>
|
|
|
</template>
|