61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { h, ref } from 'vue';
|
|
import { NImage, NTag } from 'naive-ui';
|
|
import { FormSchema } from '@/components/Form';
|
|
import { useDictStore } from '@/store/modules/dict';
|
|
|
|
const dict = useDictStore();
|
|
|
|
export const schemas = ref<FormSchema[]>([
|
|
{
|
|
field: 'name',
|
|
component: 'NInput',
|
|
label: '商品名称',
|
|
componentProps: { clearable: true },
|
|
},
|
|
{
|
|
field: 'priceRange',
|
|
label: '价格范围',
|
|
slot: 'priceRangeSlot',
|
|
},
|
|
]);
|
|
|
|
export const columns = [
|
|
{ title: 'ID', key: 'id', width: 50 },
|
|
{
|
|
title: '图片',
|
|
key: 'coverUrl',
|
|
width: 90,
|
|
render: (row) =>
|
|
h(NImage, {
|
|
src: row.coverUrl,
|
|
width: 80,
|
|
height: 70,
|
|
objectFit: 'cover',
|
|
lazy: true,
|
|
}),
|
|
},
|
|
{ title: '名称', key: 'name', width: 145, ellipsis: { tooltip: true } },
|
|
{ title: '商品价格', key: 'price', width: 90 },
|
|
{ title: '店铺名称', key: 'shopName', width: 100, ellipsis: { tooltip: true } },
|
|
{
|
|
title: '发布状态',
|
|
key: 'publishStatus',
|
|
width: 90,
|
|
render: (row) =>
|
|
h(
|
|
NTag,
|
|
{ type: dict.getType('bizPublishStatus', row.publishStatus), bordered: false },
|
|
{ default: () => dict.getLabel('bizPublishStatus', row.publishStatus) || '-' }
|
|
),
|
|
},
|
|
{ title: '创建时间', key: 'createdAt', width: 125 },
|
|
{
|
|
title: '是否推荐',
|
|
key: 'isRecommended',
|
|
width: 90,
|
|
render: (row) => (row.isRecommended === 1 ? '推荐' : '不推荐'),
|
|
},
|
|
];
|
|
|
|
export const loadOptions = () => dict.loadOptions(['bizPublishStatus']);
|