diff --git a/apps/web-antd/src/api/crm/product/category/index.ts b/apps/web-antd/src/api/crm/product/category/index.ts index 656de9835..37ed24f58 100644 --- a/apps/web-antd/src/api/crm/product/category/index.ts +++ b/apps/web-antd/src/api/crm/product/category/index.ts @@ -1,5 +1,3 @@ -import type { PageParam } from '@vben/request'; - import { requestClient } from '#/api/request'; export namespace CrmProductCategoryApi { @@ -38,7 +36,7 @@ export function deleteProductCategory(id: number) { } /** 产品分类列表 */ -export function getProductCategoryList(params?: PageParam) { +export function getProductCategoryList(params?: any) { return requestClient.get( '/crm/product-category/list', { params }, diff --git a/apps/web-antd/src/views/crm/product/category/data.ts b/apps/web-antd/src/views/crm/product/category/data.ts new file mode 100644 index 000000000..01d0996ec --- /dev/null +++ b/apps/web-antd/src/views/crm/product/category/data.ts @@ -0,0 +1,91 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { CrmProductCategoryApi } from '#/api/crm/product/category'; + +import { handleTree } from '@vben/utils'; + +import { getProductCategoryList } from '#/api/crm/product/category'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'parentId', + label: '上级分类', + component: 'ApiTreeSelect', + componentProps: { + allowClear: true, + api: async () => { + const data = await getProductCategoryList(); + data.unshift({ + id: 0, + name: '顶级分类', + } as CrmProductCategoryApi.ProductCategory); + return handleTree(data); + }, + fieldNames: { label: 'name', value: 'id', children: 'children' }, + placeholder: '请选择上级分类', + showSearch: true, + treeDefaultExpandAll: true, + }, + rules: 'selectRequired', + }, + { + fieldName: 'name', + label: '分类名称', + component: 'Input', + componentProps: { + placeholder: '请输入分类名称', + }, + rules: 'required', + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '分类名称', + component: 'Input', + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'name', + title: '分类名称', + treeNode: true, + }, + { + field: 'id', + title: '分类编号', + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + field: 'actions', + title: '操作', + width: 200, + fixed: 'right', + slots: { + default: 'actions', + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/crm/product/category/index.vue b/apps/web-antd/src/views/crm/product/category/index.vue index 32f54cc97..f55c1f516 100644 --- a/apps/web-antd/src/views/crm/product/category/index.vue +++ b/apps/web-antd/src/views/crm/product/category/index.vue @@ -1,34 +1,173 @@ diff --git a/apps/web-antd/src/views/crm/product/category/modules/form.vue b/apps/web-antd/src/views/crm/product/category/modules/form.vue new file mode 100644 index 000000000..d9d3b9a99 --- /dev/null +++ b/apps/web-antd/src/views/crm/product/category/modules/form.vue @@ -0,0 +1,92 @@ + + +