diff --git a/apps/web-antd/src/views/mall/product/spu/data.ts b/apps/web-antd/src/views/mall/product/spu/data.ts new file mode 100644 index 000000000..fa55151dd --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/data.ts @@ -0,0 +1,122 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MallSpuApi } from '#/api/mall/product/spu'; + +import { getCategoryList } from '#/api/mall/product/category'; +import { getRangePickerDefaultProps } from '#/utils'; + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '商品名称', + component: 'Input', + }, + { + fieldName: 'categoryId', + label: '商品分类', + component: 'ApiTreeSelect', + componentProps: { + api: () => getCategoryList({}), + fieldNames: { label: 'name', value: 'id', children: 'children' }, + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onStatusChange?: ( + newStatus: number, + row: T, + ) => PromiseLike, +): VxeTableGridOptions['columns'] { + return [ + { + type: 'expand', + width: 80, + slots: { content: 'expand_content' }, + fixed: 'left', + }, + { + field: 'id', + title: '商品编号', + fixed: 'left', + }, + { + field: 'name', + title: '商品名称', + fixed: 'left', + minWidth: 200, + }, + { + field: 'picUrl', + title: '商品图片', + cellRender: { + name: 'CellImage', + }, + }, + { + field: 'price', + title: '价格', + formatter: 'formatFraction', + }, + { + field: 'marketPrice', + title: '市场价', + formatter: 'formatFraction', + }, + { + field: 'costPrice', + title: '成本价', + formatter: 'formatFraction', + }, + { + field: 'salesCount', + title: '销量', + }, + { + field: 'stock', + title: '库存', + }, + { + field: 'sort', + title: '排序', + }, + { + field: 'status', + title: '销售状态', + cellRender: { + attrs: { beforeChange: onStatusChange }, + name: 'CellSwitch', + props: { + checkedValue: 1, + checkedChildren: '上架', + unCheckedValue: 0, + unCheckedChildren: '下架', + }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 300, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mall/product/spu/index.vue b/apps/web-antd/src/views/mall/product/spu/index.vue index 761da1334..393320652 100644 --- a/apps/web-antd/src/views/mall/product/spu/index.vue +++ b/apps/web-antd/src/views/mall/product/spu/index.vue @@ -1,34 +1,312 @@ diff --git a/apps/web-antd/src/views/mall/product/spu/modules/detail.vue b/apps/web-antd/src/views/mall/product/spu/modules/detail.vue new file mode 100644 index 000000000..c28ebc684 --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/modules/detail.vue @@ -0,0 +1,3 @@ + + + diff --git a/apps/web-antd/src/views/mall/product/spu/modules/form.vue b/apps/web-antd/src/views/mall/product/spu/modules/form.vue new file mode 100644 index 000000000..5b6413575 --- /dev/null +++ b/apps/web-antd/src/views/mall/product/spu/modules/form.vue @@ -0,0 +1,3 @@ + + +