diff --git a/index.html b/index.html index 1c1d367..b3e7569 100644 --- a/index.html +++ b/index.html @@ -140,7 +140,7 @@
- +
diff --git a/src/api/product/model/productCategoryModel.ts b/src/api/product/model/productCategoryModel.ts new file mode 100644 index 0000000..62771d6 --- /dev/null +++ b/src/api/product/model/productCategoryModel.ts @@ -0,0 +1,9 @@ +export interface ProductCategoryResp { + id: number | string; + parentId: number | string; + categoryName: string; + categoryLevel: string; + serialNumber: string; + remark: string; + sort: number; +} \ No newline at end of file diff --git a/src/api/product/productCategory.ts b/src/api/product/productCategory.ts new file mode 100644 index 0000000..11514a7 --- /dev/null +++ b/src/api/product/productCategory.ts @@ -0,0 +1,19 @@ +import {defHttp} from '/@/utils/http/axios'; +import { ErrorMessageMode } from '/#/axios'; +import {BaseDataResp} from "@/api/model/baseModel"; +import {ProductCategoryResp} from "@/api/product/model/productCategoryModel"; + +enum Api { + List = '/product/category/list', +} + +export function getCategoryList(mode: ErrorMessageMode = 'notice') { + return defHttp.get>( + { + url: Api.List, + }, + { + errorMessageMode: mode, + }, + ); +} \ No newline at end of file diff --git a/src/components/Table/src/hooks/useDataSource.ts b/src/components/Table/src/hooks/useDataSource.ts index 926e028..d748ac1 100644 --- a/src/components/Table/src/hooks/useDataSource.ts +++ b/src/components/Table/src/hooks/useDataSource.ts @@ -310,11 +310,19 @@ export function useDataSource( const result = await api(params); const res = result.data; if (isTreeTable) { - const tree = array2tree(res.data); - rawDataSourceRef.value = tree; - isArrayResult = Array.isArray(tree); - resultItems = isArrayResult ? tree : get(tree, listField); - resultTotal = isArrayResult ? tree.length : get(tree, totalField); + if(res.data){ + const tree = array2tree(res.data); + rawDataSourceRef.value = tree; + isArrayResult = Array.isArray(tree); + resultItems = isArrayResult ? tree : get(tree, listField); + resultTotal = isArrayResult ? tree.length : get(tree, totalField); + }else { + const tree = array2tree(res); + rawDataSourceRef.value = array2tree(res); + isArrayResult = Array.isArray(tree); + resultItems = isArrayResult ? tree : get(tree, listField); + resultTotal = isArrayResult ? tree.length : get(tree, totalField); + } } else { rawDataSourceRef.value = res; isArrayResult = Array.isArray(res); diff --git a/src/views/product/category/CategoryDrawer.vue b/src/views/product/category/CategoryDrawer.vue new file mode 100644 index 0000000..229e34e --- /dev/null +++ b/src/views/product/category/CategoryDrawer.vue @@ -0,0 +1,53 @@ + + + \ No newline at end of file diff --git a/src/views/product/category/CategoryModal.vue b/src/views/product/category/CategoryModal.vue deleted file mode 100644 index 5ff38f5..0000000 --- a/src/views/product/category/CategoryModal.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - \ No newline at end of file diff --git a/src/views/product/category/category.data.ts b/src/views/product/category/category.data.ts index e69de29..0e7b898 100644 --- a/src/views/product/category/category.data.ts +++ b/src/views/product/category/category.data.ts @@ -0,0 +1,55 @@ +import {FormSchema} from "@/components/Form"; +import {BasicColumn} from "@/components/Table"; +import {getCategoryList} from "@/api/product/productCategory"; +export const columns: BasicColumn[] = [ + { + title: '分类名称', + dataIndex: 'categoryName', + width: 150, + align: 'left', + }, + { + title: '父级分类id', + dataIndex: 'parentId', + }, + { + title: '分类级别', + dataIndex: 'categoryLevel', + }, + { + title: '序列号', + dataIndex: 'serialNumber', + }, + { + title: '排序', + dataIndex: 'sort', + }, + { + title: '备注', + dataIndex: 'remark', + }, +] +export const CategorySchema: FormSchema[] = [ + { + field: 'id', + label: '分类id', + component: 'Input', + show: false, + }, + { + field: 'categoryName', + label: '分类名称', + component: 'Input', + }, + { + field: 'parentId', + label: '上级分类', + component: 'ApiTreeSelect', + componentProps: { + api: getCategoryList, + resultField: 'data', + labelField: 'categoryName', + valueField: 'id', + }, + }, +] \ No newline at end of file diff --git a/src/views/product/category/index.vue b/src/views/product/category/index.vue index a8d5a6a..ecdd593 100644 --- a/src/views/product/category/index.vue +++ b/src/views/product/category/index.vue @@ -1,165 +1,115 @@ - - \ No newline at end of file + return { + registerDrawer, + registerTable, + handleEdit, + handleDelete, + onFetchSuccess, + handleSuccess, + handleCreate, + handleBatchDelete, + }; + } +}) + \ No newline at end of file