From ed8bd3902850a0c11b06c205a9906cc4e5d6f1fa Mon Sep 17 00:00:00 2001 From: yuanjunjie Date: Wed, 24 Jul 2024 14:28:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf<=E5=89=8D=E7=AB=AF>:=20?= =?UTF-8?q?=E5=A4=87=E5=BF=98=E5=BD=95=E6=B7=BB=E5=8A=A0=E7=BD=AE=E9=A1=B6?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../memorandum-management/category/index.vue | 1 - .../memorandum/memorandum.data.ts | 51 ++++++++++++++++--- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/vue-vben-admin/src/views/website/memorandum-management/category/index.vue b/vue-vben-admin/src/views/website/memorandum-management/category/index.vue index bba9e1b..024d9c3 100644 --- a/vue-vben-admin/src/views/website/memorandum-management/category/index.vue +++ b/vue-vben-admin/src/views/website/memorandum-management/category/index.vue @@ -42,7 +42,6 @@ import CreateOrEditModal from './CreateOrEditModal.vue'; import { columns, searchFormSchema } from './category.data'; import { useMessage } from '@/hooks/web/useMessage'; - import { UserType } from '@/enums/userEnum'; const { createMessage } = useMessage(); diff --git a/vue-vben-admin/src/views/website/memorandum-management/memorandum/memorandum.data.ts b/vue-vben-admin/src/views/website/memorandum-management/memorandum/memorandum.data.ts index 0ca09a3..e4f6ac5 100644 --- a/vue-vben-admin/src/views/website/memorandum-management/memorandum/memorandum.data.ts +++ b/vue-vben-admin/src/views/website/memorandum-management/memorandum/memorandum.data.ts @@ -1,4 +1,6 @@ import { h } from 'vue'; +import { Switch } from 'ant-design-vue'; +import { useMessage } from '@/hooks/web/useMessage'; import { BasicColumn, FormSchema } from '@/components/Table'; import { MarkDown } from '@/components/Markdown'; export const columns: BasicColumn[] = [ @@ -12,6 +14,40 @@ export const columns: BasicColumn[] = [ width: 160, dataIndex: 'category', }, + { + title: '置顶', + width: 160, + dataIndex: 'stickyPost', + helpMessage: ['相同分类只拥有一个置顶', '每一个分类可拥有一个置顶'], + align: 'center', + customRender: ({ record }) => { + if (!Reflect.has(record, 'pendingStatus')) { + record.pendingStatus = false; + } + return h(Switch, { + checked: record.status === true, + checkedChildren: '否', + unCheckedChildren: '是', + loading: record.pendingStatus, + onChange(checked) { + // record.pendingStatus = true; + const newStatus = checked ? true : false; + const { createMessage } = useMessage(); + // setRoleStatus(record.id, newStatus) + // .then(() => { + // record.status = newStatus; + // createMessage.success(`已成功修改角色状态`); + // }) + // .catch(() => { + // createMessage.error('修改角色状态失败'); + // }) + // .finally(() => { + // record.pendingStatus = false; + // }); + }, + }); + } + }, { title: '', dataIndex: 'xxx', @@ -43,10 +79,10 @@ export const searchFormSchema: FormSchema[] = [ component: 'RangePicker', componentProps: { placeholder: ['开始时间', '结束时间'], - showTime: true + showTime: true, }, colProps: { span: 6 }, - isAdvanced: true + isAdvanced: true, }, ]; @@ -57,11 +93,11 @@ export const basicFormSchema: FormSchema[] = [ component: 'Input', required: true, colProps: { - span: 6 + span: 6, }, componentProps: { showCount: true, - } + }, }, { field: 'category', @@ -69,11 +105,11 @@ export const basicFormSchema: FormSchema[] = [ component: 'Input', required: true, colProps: { - span: 6 + span: 6, }, componentProps: { showCount: true, - } + }, }, { field: 'markdown', @@ -82,7 +118,7 @@ export const basicFormSchema: FormSchema[] = [ defaultValue: '', required: true, colProps: { - span: 24 + span: 24, }, render: ({ model, field }) => { return h(MarkDown, { @@ -95,4 +131,3 @@ export const basicFormSchema: FormSchema[] = [ }, }, ]; -