From da0cb822554fbcddf32c9e080ce5765828a2eb4d Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Thu, 7 Aug 2025 17:18:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=8A=BD=E7=A6=BB?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=85=A8=E5=B1=80=E5=AD=97=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加产品分类相关 API接口 - 实现产品分类列表和 drawers 组件 - 移除冗余的字典定义,统一字典管理 - 优化网络、协议等模块的代码结构 --- .../src/api/device/productCategory/index.ts | 57 +++++++ .../src/api/device/productCategory/model.d.ts | 147 ++++++++++++++++ apps/web-antd/src/constants/dicts/index.ts | 8 + .../src/views/device/productCategory/data.ts | 105 ++++++++++++ .../views/device/productCategory/index.vue | 157 ++++++++++++++++++ .../productCategory-drawer.vue | 125 ++++++++++++++ .../src/views/operations/gateway/data.ts | 4 +- .../src/views/operations/network/data.ts | 11 +- .../src/views/operations/protocol/data.ts | 14 +- 9 files changed, 606 insertions(+), 22 deletions(-) create mode 100644 apps/web-antd/src/api/device/productCategory/index.ts create mode 100644 apps/web-antd/src/api/device/productCategory/model.d.ts create mode 100644 apps/web-antd/src/constants/dicts/index.ts create mode 100644 apps/web-antd/src/views/device/productCategory/data.ts create mode 100644 apps/web-antd/src/views/device/productCategory/index.vue create mode 100644 apps/web-antd/src/views/device/productCategory/productCategory-drawer.vue diff --git a/apps/web-antd/src/api/device/productCategory/index.ts b/apps/web-antd/src/api/device/productCategory/index.ts new file mode 100644 index 0000000..11e1319 --- /dev/null +++ b/apps/web-antd/src/api/device/productCategory/index.ts @@ -0,0 +1,57 @@ +import type { + ProductCategoryForm, + ProductCategoryQuery, + ProductCategoryVO, +} from './model'; + +import type { ID, IDS } from '#/api/common'; + +import { requestClient } from '#/api/request'; + +/** + * 查询产品分类列表 + * @param params + * @returns 产品分类列表 + */ +export function productCategoryList(params?: ProductCategoryQuery) { + return requestClient.get( + `/device/productCategory/list`, + { params }, + ); +} + +/** + * 查询产品分类详情 + * @param id id + * @returns 产品分类详情 + */ +export function productCategoryInfo(id: ID) { + return requestClient.get(`/device/productCategory/${id}`); +} + +/** + * 新增产品分类 + * @param data + * @returns void + */ +export function productCategoryAdd(data: ProductCategoryForm) { + return requestClient.postWithMsg('/device/productCategory', data); +} + +/** + * 更新产品分类 + * @param data + * @returns void + */ +export function productCategoryUpdate(data: ProductCategoryForm) { + return requestClient.putWithMsg('/device/productCategory', data); +} + +/** + * 删除产品分类 + * @param id id + * @returns void + */ +export function productCategoryRemove(id: ID | IDS) { + return requestClient.deleteWithMsg(`/device/productCategory/${id}`); +} diff --git a/apps/web-antd/src/api/device/productCategory/model.d.ts b/apps/web-antd/src/api/device/productCategory/model.d.ts new file mode 100644 index 0000000..3141f63 --- /dev/null +++ b/apps/web-antd/src/api/device/productCategory/model.d.ts @@ -0,0 +1,147 @@ +import type { BaseEntity } from '#/api/common'; + +export interface ProductCategoryVO { + /** + * 编号 + */ + id: number | string; + + /** + * 分类名称 + */ + categoryName: string; + + /** + * 分类key + */ + categoryKey: string; + + /** + * 启用状态 0 禁用 + */ + enabled: string; + + /** + * 分类参数 + */ + categoryParam: string; + + /** + * 描述 + */ + description: string; + + /** + * 物模型 + */ + metadata: string; + + /** + * 排序号 + */ + sortNo: number; + + /** + * 父级分类id + */ + parentId: number | string; + + /** + * 子对象 + */ + children: ProductCategoryVO[]; +} + +export interface ProductCategoryForm extends BaseEntity { + /** + * 编号 + */ + id?: number | string; + + /** + * 分类名称 + */ + categoryName?: string; + + /** + * 分类key + */ + categoryKey?: string; + + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 分类参数 + */ + categoryParam?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 物模型 + */ + metadata?: string; + + /** + * 排序号 + */ + sortNo?: number; + + /** + * 父级分类id + */ + parentId?: number | string; +} + +export interface ProductCategoryQuery { + /** + * 分类名称 + */ + categoryName?: string; + + /** + * 分类key + */ + categoryKey?: string; + + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 分类参数 + */ + categoryParam?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 物模型 + */ + metadata?: string; + + /** + * 排序号 + */ + sortNo?: number; + + /** + * 父级分类id + */ + parentId?: number | string; + + /** + * 日期范围参数 + */ + params?: any; +} diff --git a/apps/web-antd/src/constants/dicts/index.ts b/apps/web-antd/src/constants/dicts/index.ts new file mode 100644 index 0000000..4a20a4d --- /dev/null +++ b/apps/web-antd/src/constants/dicts/index.ts @@ -0,0 +1,8 @@ +/* 本地字典 */ +export * from './operations'; + +// 启用状态 +export const enabledOptions = [ + { label: '启用', value: '1' }, + { label: '禁用', value: '0' }, +]; diff --git a/apps/web-antd/src/views/device/productCategory/data.ts b/apps/web-antd/src/views/device/productCategory/data.ts new file mode 100644 index 0000000..9abf13f --- /dev/null +++ b/apps/web-antd/src/views/device/productCategory/data.ts @@ -0,0 +1,105 @@ +import type { FormSchemaGetter } from '#/adapter/form'; +import type { VxeGridProps } from '#/adapter/vxe-table'; + +export const querySchema: FormSchemaGetter = () => [ + // { + // component: 'Input', + // fieldName: 'categoryKey', + // label: '分类key', + // }, + { + component: 'Input', + fieldName: 'categoryName', + label: '分类名称', + }, +]; + +// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新 +// export const columns: () => VxeGridProps['columns'] = () => [ +export const columns: VxeGridProps['columns'] = [ + // { + // title: '编号', + // field: 'id', + // treeNode: true, + // }, + { + title: '分类名称', + field: 'categoryName', + treeNode: true, + }, + // { + // title: '分类key', + // field: 'categoryKey', + // }, + { + title: '描述', + field: 'description', + }, + { + title: '排序号', + field: 'sortNo', + }, + { + field: 'action', + fixed: 'right', + slots: { default: 'action' }, + title: '操作', + width: 180, + }, +]; + +export const drawerSchema: FormSchemaGetter = () => [ + { + label: '编号', + fieldName: 'id', + component: 'Input', + dependencies: { + show: () => false, + triggerFields: [''], + }, + }, + { + label: '上级分类', + fieldName: 'parentId', + component: 'TreeSelect', + }, + { + label: '分类名称', + fieldName: 'categoryName', + component: 'Input', + rules: 'required', + }, + // { + // label: '分类key', + // fieldName: 'categoryKey', + // component: 'Input', + // rules: 'required', + // }, + { + label: '启用状态', + fieldName: 'enabled', + component: 'Input', + rules: 'required', + defaultValue: '1', + dependencies: { + show: () => false, + triggerFields: [''], + }, + }, + { + label: '排序号', + fieldName: 'sortNo', + component: 'InputNumber', + rules: 'required', + defaultValue: 10, + }, + { + label: '描述', + fieldName: 'description', + component: 'Textarea', + componentProps: { + placeholder: '请输入描述', + rows: 3, + }, + }, +]; diff --git a/apps/web-antd/src/views/device/productCategory/index.vue b/apps/web-antd/src/views/device/productCategory/index.vue new file mode 100644 index 0000000..8813bd9 --- /dev/null +++ b/apps/web-antd/src/views/device/productCategory/index.vue @@ -0,0 +1,157 @@ + + + diff --git a/apps/web-antd/src/views/device/productCategory/productCategory-drawer.vue b/apps/web-antd/src/views/device/productCategory/productCategory-drawer.vue new file mode 100644 index 0000000..14878de --- /dev/null +++ b/apps/web-antd/src/views/device/productCategory/productCategory-drawer.vue @@ -0,0 +1,125 @@ + + + diff --git a/apps/web-antd/src/views/operations/gateway/data.ts b/apps/web-antd/src/views/operations/gateway/data.ts index a40e9bf..2586e38 100644 --- a/apps/web-antd/src/views/operations/gateway/data.ts +++ b/apps/web-antd/src/views/operations/gateway/data.ts @@ -5,8 +5,7 @@ import { h } from 'vue'; import { networkList } from '#/api/operations/network'; import { protocolList } from '#/api/operations/protocol'; - -import { enabledOptions, networkTypeOptions } from '../user.data'; +import { enabledOptions, networkTypeOptions } from '#/constants/dicts'; export const providerOptions = [ ...networkTypeOptions, @@ -189,7 +188,6 @@ export const drawerSchema: FormSchemaGetter = () => [ showSearch: true, class: 'w-full', onChange: async (value: string) => { - console.log('抽屉表单接入方式变化:', value); if (networkOptionsUpdateCallback) { await networkOptionsUpdateCallback(value); } diff --git a/apps/web-antd/src/views/operations/network/data.ts b/apps/web-antd/src/views/operations/network/data.ts index 005b053..58db0cf 100644 --- a/apps/web-antd/src/views/operations/network/data.ts +++ b/apps/web-antd/src/views/operations/network/data.ts @@ -1,16 +1,7 @@ import type { FormSchemaGetter } from '#/adapter/form'; import type { VxeGridProps } from '#/adapter/vxe-table'; -import { networkTypeOptions,enabledOptions } from '../user.data'; -// const networkTypeOptions = [ -// { label: 'MQTT客户端', value: 'MQTT_CLIENT' }, -// { label: 'HTTP服务', value: 'HTTP_SERVER' }, -// ]; - -// const enabledOptions = [ -// { label: '启用', value: '1' }, -// { label: '禁用', value: '0' }, -// ]; +import { enabledOptions, networkTypeOptions } from '#/constants/dicts'; // HTTP服务配置字段 const httpServerFields = [ diff --git a/apps/web-antd/src/views/operations/protocol/data.ts b/apps/web-antd/src/views/operations/protocol/data.ts index 9d7f066..5b84f6c 100644 --- a/apps/web-antd/src/views/operations/protocol/data.ts +++ b/apps/web-antd/src/views/operations/protocol/data.ts @@ -1,10 +1,7 @@ import type { FormSchemaGetter } from '#/adapter/form'; import type { VxeGridProps } from '#/adapter/vxe-table'; -const enabledOptions = [ - { label: '启用', value: '1' }, - { label: '禁用', value: '0' }, -]; +import { enabledOptions } from '#/constants/dicts'; const protocolTypeOptions = [ { label: 'local', value: 'local' }, @@ -120,14 +117,13 @@ export const drawerSchema: FormSchemaGetter = () => [ { label: '启用状态', fieldName: 'enabled', - component: 'Select', + component: 'RadioGroup', componentProps: { - allowClear: true, - filterOption: true, + buttonStyle: 'solid', options: enabledOptions, - placeholder: '请选择', - showSearch: true, + optionType: 'button', }, + defaultValue: '1', rules: 'required', }, {