diff --git a/src/modules/system/views/category/CategoryListView.api.ts b/src/modules/system/views/category/CategoryListView.api.ts new file mode 100644 index 000000000..71c3a308d --- /dev/null +++ b/src/modules/system/views/category/CategoryListView.api.ts @@ -0,0 +1,54 @@ +import { ApiServiceEnum, defHttp } from '@/utils/http/axios'; + +enum Api { + list = '/sys/category/list', + saveUpdate = '/sys/category/saveUpdate', + batchDeleteById = '/sys/category/batchDeleteById', + getById = '/sys/category/getById', +} + +export const listApi = (params: Recordable = {}, parentId = 0) => { + if (params) { + params = { + ...params, + parameter: { + ...params.parameter, + 'parentId@=': parentId, + }, + }; + } + return defHttp.post({ + service: ApiServiceEnum.SMART_SYSTEM, + url: Api.list, + data: { + sortName: 'seq', + ...params, + }, + }); +}; + +export const saveUpdateApi = (data) => { + return defHttp.post({ + service: ApiServiceEnum.SMART_SYSTEM, + url: Api.saveUpdate, + data, + }); +}; + +export const getByIdApi = async (id: number) => { + const result = await defHttp.post({ + service: ApiServiceEnum.SMART_SYSTEM, + url: Api.getById, + data: id, + }); + result.parentName = result.parent?.categoryName || '根目录'; + return result; +}; + +export const deleteApi = (idList: number[]) => { + return defHttp.post({ + service: ApiServiceEnum.SMART_SYSTEM, + url: Api.batchDeleteById, + data: idList, + }); +}; diff --git a/src/modules/system/views/category/CategoryListView.config.ts b/src/modules/system/views/category/CategoryListView.config.ts new file mode 100644 index 000000000..374d8397e --- /dev/null +++ b/src/modules/system/views/category/CategoryListView.config.ts @@ -0,0 +1,134 @@ +import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable'; +import type { FormSchema } from '@/components/Form'; + +export const getTableColumns = (): SmartColumn[] => { + return [ + { + type: 'checkbox', + width: 60, + align: 'center', + fixed: 'left', + }, + { + field: 'categoryCode', + title: '{system.views.category.title.categoryCode}', + minWidth: 240, + fixed: 'left', + treeNode: true, + }, + { + field: 'categoryName', + title: '{system.views.category.title.categoryName}', + width: 200, + }, + { + field: 'seq', + title: '{common.table.seq}', + width: 120, + sortable: true, + }, + { + field: 'remark', + title: '{common.table.remark}', + width: 200, + }, + { + field: 'createTime', + title: '{common.table.createTime}', + width: 170, + }, + { + field: 'createBy', + title: '{common.table.createUser}', + width: 120, + }, + { + field: 'updateTime', + title: '{common.table.updateTime}', + width: 170, + }, + { + field: 'updateBy', + title: '{common.table.updateUser}', + width: 120, + }, + { + field: 'id', + title: '{common.table.operation}', + fixed: 'right', + width: 200, + slots: { + default: 'table-option', + }, + }, + ]; +}; + +export const getFormSchemas = (t: Function): FormSchema[] => { + return [ + { + field: 'id', + label: '', + component: 'Input', + show: false, + }, + { + field: 'parentId', + label: '', + component: 'Input', + show: false, + }, + { + field: 'parentName', + label: t('system.views.category.title.parentName'), + component: 'Input', + componentProps: { + disabled: true, + }, + }, + { + field: 'categoryCode', + label: t('system.views.category.title.categoryCode'), + component: 'Input', + required: true, + }, + { + field: 'categoryName', + label: t('system.views.category.title.categoryName'), + component: 'Input', + required: true, + }, + { + field: 'seq', + label: t('common.table.seq'), + component: 'InputNumber', + componentProps: { + style: 'width: 100%', + }, + required: true, + defaultValue: 1, + }, + { + field: 'remark', + label: t('common.table.remark'), + component: 'Input', + }, + ]; +}; + +export const getSearchFormSchemas = (t: Function): SmartSearchFormSchema[] => { + return [ + { + field: 'categoryCode', + label: t('system.views.category.title.categoryCode'), + component: 'Input', + searchSymbol: 'like', + }, + { + field: 'categoryCode', + label: t('system.views.category.title.categoryName'), + component: 'Input', + searchSymbol: 'like', + }, + ]; +}; diff --git a/src/modules/system/views/category/CategoryListView.vue b/src/modules/system/views/category/CategoryListView.vue new file mode 100644 index 000000000..e8da3eb24 --- /dev/null +++ b/src/modules/system/views/category/CategoryListView.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/modules/system/views/category/lang/en_US.ts b/src/modules/system/views/category/lang/en_US.ts new file mode 100644 index 000000000..0d9f76127 --- /dev/null +++ b/src/modules/system/views/category/lang/en_US.ts @@ -0,0 +1,28 @@ +/** + * 分类字段 国际化信息 + */ +export default { + trans: true, + key: 'system.views.category', + data: { + title: { + categoryCode: 'Category code', + categoryName: 'Category name', + createBy: 'Create user', + updateBy: 'Update user', + parentName: 'Parent name', + }, + validate: { + categoryCode: 'Please enter category code', + categoryName: 'Please enter category name', + }, + rules: {}, + search: { + categoryCode: 'Please enter category code', + categoryName: 'Please enter category name', + }, + button: { + addChild: 'Add Child', + }, + }, +}; diff --git a/src/modules/system/views/category/lang/zh_CN.ts b/src/modules/system/views/category/lang/zh_CN.ts new file mode 100644 index 000000000..44187d5f7 --- /dev/null +++ b/src/modules/system/views/category/lang/zh_CN.ts @@ -0,0 +1,30 @@ +/** + * 分类字段 国际化信息 + */ +export default { + trans: true, + key: 'system.views.category', + data: { + title: { + categoryCode: '分类编码', + categoryName: '分类名称', + createBy: 'createBy', + updateBy: 'updateBy', + parentName: '上级', + }, + validate: { + id: '请输入', + parentId: '请输入', + categoryCode: '请输入分类编码', + categoryName: '请输入分类名称', + }, + rules: {}, + search: { + categoryCode: '请输入分类编码', + categoryName: '请输入分类名称', + }, + button: { + addChild: '添加下级', + }, + }, +};