From e27d525c43dafa20545a5d09d8b0b6abd94bcd75 Mon Sep 17 00:00:00 2001 From: lq Date: Thu, 15 May 2025 15:15:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8A=A0=E5=B7=A5=E8=B4=B9=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/process/api/index.ts | 58 ++++++ .../views/system/process/components/modal.vue | 62 ++++++ .../src/views/system/process/config/form.ts | 117 +++++++++++ .../src/views/system/process/config/search.ts | 37 ++++ .../src/views/system/process/config/table.ts | 67 +++++++ .../src/views/system/process/index.vue | 187 ++++++++++++++++++ 6 files changed, 528 insertions(+) create mode 100644 apps/web-antd/src/views/system/process/api/index.ts create mode 100644 apps/web-antd/src/views/system/process/components/modal.vue create mode 100644 apps/web-antd/src/views/system/process/config/form.ts create mode 100644 apps/web-antd/src/views/system/process/config/search.ts create mode 100644 apps/web-antd/src/views/system/process/config/table.ts create mode 100644 apps/web-antd/src/views/system/process/index.vue diff --git a/apps/web-antd/src/views/system/process/api/index.ts b/apps/web-antd/src/views/system/process/api/index.ts new file mode 100644 index 00000000..35d0a02b --- /dev/null +++ b/apps/web-antd/src/views/system/process/api/index.ts @@ -0,0 +1,58 @@ +import { requestClient } from '#/api/request'; + +const prefix = 'process/'; +/** + * 分页查询用户列表 + * @param data + */ +export async function getProcessList(data: any) { + return requestClient.get(`${prefix}list`, { params: data }); +} +/** + * 分页查询用户列表 + * @param data + */ +export async function getProcessOption(data: any) { + return requestClient.get(`${prefix}option`, { params: data }); +} +/** + * 分页查询用户列表 + */ +export async function getProcessOptionPidApi() { + return requestClient.get(`${prefix}option`, { params: { + pid: 0, + }, + }); +} + +/** + * 获取加工费详情 + * @param id + */ +export async function getProcessInfo(id: number) { + return requestClient.get(`${prefix}detail`, { params: { id } }); +} + +/** + * 新增加工费 + * @param data + */ +export async function createProcess(data: Record) { + return requestClient.post(`${prefix}create`, data); +} + +/** + * 编辑加工费 + * @param data + */ +export async function updateProcess(data: Record) { + return requestClient.post(`${prefix}update`, data); +} + +/** + * 删除加工费 + * @param data + */ +export async function deleteProcess(data: Record) { + return requestClient.post(`${prefix}delete`, data); +} diff --git a/apps/web-antd/src/views/system/process/components/modal.vue b/apps/web-antd/src/views/system/process/components/modal.vue new file mode 100644 index 00000000..e41d2b81 --- /dev/null +++ b/apps/web-antd/src/views/system/process/components/modal.vue @@ -0,0 +1,62 @@ + + diff --git a/apps/web-antd/src/views/system/process/config/form.ts b/apps/web-antd/src/views/system/process/config/form.ts new file mode 100644 index 00000000..5882408c --- /dev/null +++ b/apps/web-antd/src/views/system/process/config/form.ts @@ -0,0 +1,117 @@ +import type { VbenFormProps } from '#/adapter/form'; +import {getProcessOptionPidApi} from "#/views/system/process/api"; + +export const modalFormProps: VbenFormProps = { + wrapperClass: 'grid-cols-12', // 24栅格, + commonConfig: { + formItemClass: 'col-span-12', + // 所有表单项 + componentProps: { + class: 'w-full', + }, + }, + // handleSubmit: onSubmit, + layout: 'horizontal', + schema: [ + // { + // fieldName: 'baseinfo', + // component: 'Divider', + // label: '基础信息', + // formItemClass: 'col-span-12', + // componentProps: {}, + // hideLabel: true, + // renderComponentContent: () => { + // return { + // default: () => { + // return '基础信息'; + // }, + // }; + // }, + // }, + { + component: 'VbenInput', + fieldName: 'id', + label: 'ID', + formItemClass: 'col-span-6', + dependencies: { + show: false, + triggerFields: ['id'], + }, + }, + { + component: 'VbenInput', + componentProps: { + placeholder: '请输入加工费昵称', + }, + fieldName: 'name', + label: '加工费名称', + rules: 'required', + }, + // calc_method '计算方式 1固定价格 2贴数 3克数', + { + component: 'VbenSelect', + componentProps: { + placeholder: '请选择计算方式', + options: [ + { + label: '固定价格', + value: 1, + }, + { + label: '贴数', + value: 2, + }, + { + label: '克数', + value: 3, + }, + ], + }, + fieldName: 'calc_method', + label: '计算方式', + }, + { + component: 'ApiSelect', + componentProps: { + placeholder: '请选择计算方式', + api: getProcessOptionPidApi, + filterOption: (input: string, option: any) => { + // 自定义过滤逻辑,确保可以根据 name 进行搜索 + return option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0; + }, + showSearch: true, + // 菜单接口转options格式 + afterFetch: (data: { id: number; name: string }[]) => { + // 在开头插入value = 0 的选项 + data.unshift({ + name: '一级分类', + id: 0, + }); + return data.map((item: any) => ({ + label: item.name, + value: item.id, + })); + }, + }, + fieldName: 'pid', + label: '父级', + }, + { + component: 'InputNumber', + componentProps: { + placeholder: '请输入计算价格', + }, + fieldName: 'price', + label: '计算价格', + }, + { + component: 'VbenInput', + componentProps: { + placeholder: '请输入计算单位', + }, + fieldName: 'unit', + label: '计算单位', + }, + ], + showDefaultActions: false, +}; diff --git a/apps/web-antd/src/views/system/process/config/search.ts b/apps/web-antd/src/views/system/process/config/search.ts new file mode 100644 index 00000000..98d583c7 --- /dev/null +++ b/apps/web-antd/src/views/system/process/config/search.ts @@ -0,0 +1,37 @@ +import type { VbenFormProps } from '#/adapter/form'; + +// import dayjs from 'dayjs'; + +export const formOptions: VbenFormProps = { + // 默认展开 + collapsed: false, + schema: [ + { + component: 'VbenInput', + componentProps: { + placeholder: '输入名称', + }, + defaultValue: '', + fieldName: 'name', + label: '加工费名称', + }, + // { + // component: 'RangePicker', + // componentProps: { + // format: 'YYYY-MM-DD', // 确保格式与你需要的一致 + // }, + // // defaultValue: [dayjs().startOf('month'), dayjs()], + // fieldName: 'search_time', + // label: '时间范围', + // }, + ], + // 控制表单是否显示折叠按钮 + showCollapseButton: true, + submitButtonOptions: { + content: '查询', + }, + // 是否在字段值改变时提交表单 + submitOnChange: false, + // 按下回车时是否提交表单 + submitOnEnter: false, +}; diff --git a/apps/web-antd/src/views/system/process/config/table.ts b/apps/web-antd/src/views/system/process/config/table.ts new file mode 100644 index 00000000..1c6d5d37 --- /dev/null +++ b/apps/web-antd/src/views/system/process/config/table.ts @@ -0,0 +1,67 @@ +import type { VxeGridProps } from '#/adapter/vxe-table'; + +import { getProcessList } from '#/views/system/process/api'; + +export const gridOptions: VxeGridProps = { + checkboxConfig: { + highlight: true, + labelField: '', + }, + columnConfig: { + useKey: true, + }, + rowConfig: { + useKey: true, + }, + columns: [ + { type: 'checkbox', width: 60 }, + { width: 60, treeNode: true }, + { field: 'id', align: 'left', title: 'ID', width: 100 }, + { field: 'name', title: '加工费名称' }, + { field: 'calc_method', title: '计算方式' }, + { field: 'price', title: '计算价格' }, + { field: 'unit', title: '计算单位' }, + { field: 'created_at', title: '注册时间' }, + { type: 'html', title: '操作', slots: { default: 'action' } }, + ], + keepSource: true, + pagerConfig: {}, + proxyConfig: { + ajax: { + // 请求后端接口方法 + query: async ({ page }, formValues) => { + return await getProcessList({ + page: page.currentPage, + pageSize: page.pageSize, + ...formValues, + }); + }, + }, + }, + treeConfig: { + parentField: 'pid', + rowField: 'id', + transform: true, + expandAll: false, + }, + height: 'auto', + border: false, + toolbarConfig: { + // 是否显示搜索表单控制按钮 + // @ts-ignore 正式环境时有完整的类型声明 + search: true, + refresh: true, // 刷新 + print: false, // 打印 + export: false, // 导出 + // custom: true, // 自定义列 + zoom: true, // 最大化最小化 + slots: { + buttons: 'toolbar-buttons', + }, + custom: { + // 自定义列-图标 + icon: 'vxe-icon-menu', + }, + }, + showOverflow: false, +}; diff --git a/apps/web-antd/src/views/system/process/index.vue b/apps/web-antd/src/views/system/process/index.vue new file mode 100644 index 00000000..960b4452 --- /dev/null +++ b/apps/web-antd/src/views/system/process/index.vue @@ -0,0 +1,187 @@ + + +