Skip to content

Commit

Permalink
🎈 perf<前端>: 备忘录添加置顶列
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanjunjie committed Jul 24, 2024
1 parent 727cf19 commit ed8bd39
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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[] = [
Expand All @@ -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',
Expand Down Expand Up @@ -43,10 +79,10 @@ export const searchFormSchema: FormSchema[] = [
component: 'RangePicker',
componentProps: {
placeholder: ['开始时间', '结束时间'],
showTime: true
showTime: true,
},
colProps: { span: 6 },
isAdvanced: true
isAdvanced: true,
},
];

Expand All @@ -57,23 +93,23 @@ export const basicFormSchema: FormSchema[] = [
component: 'Input',
required: true,
colProps: {
span: 6
span: 6,
},
componentProps: {
showCount: true,
}
},
},
{
field: 'category',
label: '分类',
component: 'Input',
required: true,
colProps: {
span: 6
span: 6,
},
componentProps: {
showCount: true,
}
},
},
{
field: 'markdown',
Expand All @@ -82,7 +118,7 @@ export const basicFormSchema: FormSchema[] = [
defaultValue: '',
required: true,
colProps: {
span: 24
span: 24,
},
render: ({ model, field }) => {
return h(MarkDown, {
Expand All @@ -95,4 +131,3 @@ export const basicFormSchema: FormSchema[] = [
},
},
];

0 comments on commit ed8bd39

Please sign in to comment.