feat:【antd】【erp 系统】product 迁移

This commit is contained in:
YunaiV
2025-10-03 09:55:03 +08:00
parent 325cede2ed
commit eeb1f1ebf9
5 changed files with 42 additions and 12 deletions

View File

@@ -341,13 +341,13 @@ setupVbenVxeTable({
vxeUI.formats.add('formatAmount2', {
tableCellFormatMethod({ cellValue }, digits = 2) {
return `${erpNumberFormatter(cellValue, digits)}`;
return `${erpNumberFormatter(cellValue, digits)}`;
},
});
vxeUI.formats.add('formatFenToYuanAmount', {
tableCellFormatMethod({ cellValue }, digits = 2) {
return `${erpNumberFormatter(fenToYuan(cellValue), digits)}`;
return `${erpNumberFormatter(fenToYuan(cellValue), digits)}`;
},
});
},

View File

@@ -3,7 +3,6 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { handleTree } from '@vben/utils';
import { z } from '#/adapter/form';
import { getProductCategorySimpleList } from '#/api/erp/product/category';
@@ -109,6 +108,9 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber',
componentProps: {
placeholder: '请输入采购价格,单位:元',
precision: 2,
min: 0,
step: 0.01,
},
},
{
@@ -117,6 +119,9 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber',
componentProps: {
placeholder: '请输入销售价格,单位:元',
precision: 2,
min: 0,
step: 0.01,
},
},
{
@@ -125,12 +130,18 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber',
componentProps: {
placeholder: '请输入最低价格,单位:元',
precision: 2,
min: 0,
step: 0.01,
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
},
},
];
}
@@ -142,6 +153,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'name',
label: '名称',
component: 'Input',
componentProps: {
placeholder: '请输入名称',
allowClear: true,
},
},
{
fieldName: 'categoryId',
@@ -169,38 +184,50 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'barCode',
title: '条码',
minWidth: 120,
},
{
field: 'name',
title: '名称',
minWidth: 200,
},
{
field: 'standard',
title: '规格',
minWidth: 100,
},
{
field: 'categoryName',
title: '分类',
minWidth: 120,
},
{
field: 'unitName',
title: '单位',
minWidth: 100,
},
{
field: 'purchasePrice',
title: '采购价格',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'salePrice',
title: '销售价格',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'minPrice',
title: '最低价格',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'status',
title: '状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
@@ -209,6 +236,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{

View File

@@ -24,7 +24,7 @@ const [FormModal, formModalApi] = useVbenModal({
});
/** 刷新表格 */
function onRefresh() {
function handleRefresh() {
gridApi.query();
}
@@ -52,10 +52,8 @@ async function handleDelete(row: ErpProductApi.Product) {
});
try {
await deleteProduct(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
});
onRefresh();
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
handleRefresh();
} finally {
hideLoading();
}
@@ -100,7 +98,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
url="https://doc.iocoder.cn/erp/product/"
/>
</template>
<FormModal @success="onRefresh" />
<FormModal @success="handleRefresh" />
<Grid table-title="产品列表">
<template #toolbar-tools>
<TableAction

View File

@@ -79,7 +79,7 @@ const [Modal, modalApi] = useVbenModal({
</script>
<template>
<Modal class="w-2/5" :title="getTitle">
<Modal :title="getTitle" class="w-1/2">
<Form class="mx-4" />
</Modal>
</template>

View File

@@ -321,19 +321,22 @@ setupVbenVxeTable({
// add by 星语:数量格式化,例如说:金额
vxeUI.formats.add('formatNumber', {
tableCellFormatMethod({ cellValue }) {
if (cellValue === null || cellValue === undefined) {
return '';
}
return erpCountInputFormatter(cellValue);
},
});
vxeUI.formats.add('formatAmount2', {
tableCellFormatMethod({ cellValue }, digits = 2) {
return `${erpNumberFormatter(cellValue, digits)}`;
return `${erpNumberFormatter(cellValue, digits)}`;
},
});
vxeUI.formats.add('formatFenToYuanAmount', {
tableCellFormatMethod({ cellValue }, digits = 2) {
return `${erpNumberFormatter(fenToYuan(cellValue), digits)}`;
return `${erpNumberFormatter(fenToYuan(cellValue), digits)}`;
},
});
},