From 2572824d1adbf2cb02ad79e7790bb08a5b837bc6 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 3 Oct 2025 11:37:34 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd=E3=80=91=E3=80=90erp?= =?UTF-8?q?=20=E7=B3=BB=E7=BB=9F=E3=80=91warehouse=20=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/erp/stock/warehouse/data.ts | 48 ++++++++----------- .../src/views/erp/stock/warehouse/index.vue | 42 ++++++++-------- .../erp/stock/warehouse/modules/form.vue | 43 +++++++---------- 3 files changed, 57 insertions(+), 76 deletions(-) diff --git a/apps/web-antd/src/views/erp/stock/warehouse/data.ts b/apps/web-antd/src/views/erp/stock/warehouse/data.ts index 308f2583b..fead0d5ab 100644 --- a/apps/web-antd/src/views/erp/stock/warehouse/data.ts +++ b/apps/web-antd/src/views/erp/stock/warehouse/data.ts @@ -2,9 +2,11 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { ErpWarehouseApi } from '#/api/erp/stock/warehouse'; -import { DICT_TYPE } from '@vben/constants'; +import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; +import { z } from '#/adapter/form'; + /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { return [ @@ -39,9 +41,10 @@ export function useFormSchema(): VbenFormSchema[] { component: 'RadioGroup', componentProps: { options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', }, - rules: 'required', - defaultValue: 0, + rules: z.number().default(CommonStatusEnum.ENABLE), }, { fieldName: 'warehousePrice', @@ -51,7 +54,6 @@ export function useFormSchema(): VbenFormSchema[] { placeholder: '请输入仓储费,单位:元/天/KG', min: 0, precision: 2, - class: 'w-full', }, }, { @@ -62,7 +64,6 @@ export function useFormSchema(): VbenFormSchema[] { placeholder: '请输入搬运费,单位:元', min: 0, precision: 2, - class: 'w-full', }, }, { @@ -80,10 +81,8 @@ export function useFormSchema(): VbenFormSchema[] { componentProps: { placeholder: '请输入排序', precision: 0, - class: 'w-full', }, rules: 'required', - defaultValue: 0, }, { fieldName: 'remark', @@ -91,9 +90,7 @@ export function useFormSchema(): VbenFormSchema[] { component: 'Textarea', componentProps: { placeholder: '请输入备注', - rows: 3, }, - formItemClass: 'col-span-2', }, ]; } @@ -144,34 +141,30 @@ export function useGridColumns( }, { field: 'warehousePrice', - title: '仓储费(元)', - width: 120, - cellRender: { - name: 'CellMoney', - }, + title: '仓储费', + minWidth: 120, + formatter: 'formatAmount2', }, { field: 'truckagePrice', - title: '搬运费(元)', - width: 120, - cellRender: { - name: 'CellMoney', - }, + title: '搬运费', + minWidth: 120, + formatter: 'formatAmount2', }, { field: 'principal', title: '负责人', - width: 100, + minWidth: 100, }, { field: 'sort', title: '排序', - width: 80, + minWidth: 80, }, { field: 'status', title: '状态', - width: 100, + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.COMMON_STATUS }, @@ -180,7 +173,7 @@ export function useGridColumns( { field: 'defaultStatus', title: '是否默认', - width: 100, + minWidth: 100, cellRender: { attrs: { beforeChange: onDefaultStatusChange }, name: 'CellSwitch', @@ -199,15 +192,12 @@ export function useGridColumns( { field: 'createTime', title: '创建时间', - width: 180, - cellRender: { - name: 'CellDateTime', - }, + minWidth: 180, + formatter: 'formatDateTime', }, { - field: 'actions', title: '操作', - width: 160, + width: 130, fixed: 'right', slots: { default: 'actions' }, }, diff --git a/apps/web-antd/src/views/erp/stock/warehouse/index.vue b/apps/web-antd/src/views/erp/stock/warehouse/index.vue index 74c2decf5..3da5da47e 100644 --- a/apps/web-antd/src/views/erp/stock/warehouse/index.vue +++ b/apps/web-antd/src/views/erp/stock/warehouse/index.vue @@ -3,7 +3,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { ErpWarehouseApi } from '#/api/erp/stock/warehouse'; import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui'; -import { downloadFileFromBlobPart } from '@vben/utils'; +import { downloadFileFromBlobPart, isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -23,18 +23,24 @@ import WarehouseForm from './modules/form.vue'; defineOptions({ name: 'ErpWarehouse' }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } -/** 添加仓库 */ +/** 导出仓库 */ +async function handleExport() { + const data = await exportWarehouse(await gridApi.formApi.getValues()); + downloadFileFromBlobPart({ fileName: '仓库.xls', source: data }); +} + +/** 创建仓库 */ function handleCreate() { - formModalApi.setData({ type: 'create' }).open(); + formModalApi.setData(null).open(); } /** 编辑仓库 */ function handleEdit(row: ErpWarehouseApi.Warehouse) { - formModalApi.setData({ type: 'update', id: row.id }).open(); + formModalApi.setData(row).open(); } /** 删除仓库 */ @@ -45,11 +51,9 @@ async function handleDelete(row: ErpWarehouseApi.Warehouse) { }); try { await deleteWarehouse(row.id!); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.name]), - }); - onRefresh(); - } catch { + message.success($t('ui.actionMessage.deleteSuccess', [row.name])); + handleRefresh(); + } finally { hideLoading(); } } @@ -60,15 +64,14 @@ async function handleDefaultStatusChange( row: ErpWarehouseApi.Warehouse, ): Promise { return new Promise((resolve, reject) => { - const text = newStatus ? '开启' : '取消'; - + const text = newStatus ? '设置' : '取消'; confirm({ content: `确认要${text}"${row.name}"默认吗?`, }) .then(async () => { // 更新默认状态 await updateWarehouseDefaultStatus(row.id!, newStatus); - message.success(`${text}默认状态成功`); + message.success(`${text}默认成功`); resolve(true); }) .catch(() => { @@ -77,12 +80,6 @@ async function handleDefaultStatusChange( }); } -/** 导出仓库 */ -async function handleExport() { - const data = await exportWarehouse(await gridApi.formApi.getValues()); - downloadFileFromBlobPart({ fileName: '仓库.xls', source: data }); -} - const [FormModal, formModalApi] = useVbenModal({ connectedComponent: WarehouseForm, destroyOnClose: true, @@ -109,6 +106,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, @@ -127,7 +125,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ /> - +