263 lines
4.6 KiB
TypeScript
Raw Normal View History

2023-06-22 17:31:36 +08:00
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
2023-06-24 18:53:57 +08:00
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
2023-06-22 17:31:36 +08:00
import { getListAllSimple } from '@/api/mall/promotion/seckill/seckillConfig'
// 表单校验
export const rules = reactive({
spuId: [required],
name: [required],
startTime: [required],
endTime: [required],
sort: [required],
configIds: [required],
totalLimitCount: [required],
singleLimitCount: [required],
totalStock: [required]
})
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
{
label: '秒杀活动名称',
field: 'name',
isSearch: true,
form: {
colProps: {
span: 24
}
},
table: {
width: 120
}
},
{
label: '活动开始时间',
field: 'startTime',
2023-06-24 18:53:57 +08:00
formatter: dateFormatter2,
2023-06-22 17:31:36 +08:00
isSearch: true,
search: {
component: 'DatePicker',
componentProps: {
2023-06-24 18:53:57 +08:00
valueFormat: 'YYYY-MM-DD',
type: 'daterange'
2023-06-22 17:31:36 +08:00
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'date',
valueFormat: 'x'
}
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '活动结束时间',
field: 'endTime',
2023-06-24 18:53:57 +08:00
formatter: dateFormatter2,
2023-06-22 17:31:36 +08:00
isSearch: true,
search: {
component: 'DatePicker',
componentProps: {
2023-06-24 18:53:57 +08:00
valueFormat: 'YYYY-MM-DD',
type: 'daterange'
2023-06-22 17:31:36 +08:00
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'date',
valueFormat: 'x'
}
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '秒杀时段',
2023-06-22 17:31:36 +08:00
field: 'configIds',
form: {
component: 'Select',
componentProps: {
multiple: true,
optionsAlias: {
labelField: 'name',
valueField: 'id'
}
},
api: getListAllSimple
},
table: {
width: 300
}
},
{
label: '新增订单数',
field: 'orderCount',
isForm: false,
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '付款人数',
field: 'userCount',
isForm: false,
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '订单实付金额',
field: 'totalPrice',
isForm: false,
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '总限购数量',
field: 'totalLimitCount',
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '单次限够数量',
field: 'singleLimitCount',
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '秒杀库存',
field: 'stock',
isForm: false,
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '秒杀总库存',
field: 'totalStock',
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
2023-06-25 17:16:26 +08:00
label: '秒杀活动商品',
field: 'spuIds',
2023-06-25 17:16:26 +08:00
isTable: false,
isSearch: false,
2023-06-22 17:31:36 +08:00
form: {
colProps: {
span: 24
}
},
table: {
width: 200
}
},
{
label: '创建时间',
field: 'createTime',
formatter: dateFormatter,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false,
table: {
width: 120
2023-06-22 17:31:36 +08:00
}
},
{
label: '排序',
field: 'sort',
form: {
component: 'InputNumber',
value: 0
},
table: {
width: 80
2023-06-22 17:31:36 +08:00
}
},
{
label: '状态',
2023-06-25 17:16:26 +08:00
field: 'status', // TODO @puhui999状态在 table 格式化不对;建表插入的数据状态值不对,改为 0 或 1 就好了
2023-06-22 17:31:36 +08:00
dictType: DICT_TYPE.COMMON_STATUS,
dictClass: 'number',
isForm: false,
isSearch: true,
form: {
component: 'Radio'
},
table: {
width: 80
}
},
{
label: '备注',
field: 'remark',
2023-06-25 17:16:26 +08:00
isSearch: false,
2023-06-22 17:31:36 +08:00
form: {
component: 'Input',
componentProps: {
type: 'textarea',
rows: 4
},
colProps: {
span: 24
}
},
table: {
width: 300
}
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 120,
fixed: 'right'
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)