feat(@vben/web-antd): erp-优化采购订单功能
- 移除采购订单明细项表单配置 - 调整采购订单表格列定义 - 优化采购订单删除操作,增加加载提示和错误处理 - 添加采购订单详情页面 - 重新计算采购订单项的价格字段 - 调整采购订单状态更新和删除的交互方式,增加二次确认
This commit is contained in:
@@ -58,16 +58,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
gridEvents: {
|
||||
// editClosed: ({ row }) => {
|
||||
// // 当单元格编辑完成时,同步更新tableData
|
||||
// const index = tableData.value.findIndex((item) => item.id === row.id);
|
||||
// if (index !== -1) {
|
||||
// tableData.value[index] = { ...row };
|
||||
// emit('update:items', [...tableData.value]);
|
||||
// }
|
||||
// },
|
||||
},
|
||||
});
|
||||
|
||||
/** 监听外部传入的列数据 */
|
||||
@@ -118,7 +108,6 @@ onMounted(async () => {
|
||||
|
||||
function handleAdd() {
|
||||
const newRow = {
|
||||
id: tableData.value.length + 1,
|
||||
productId: null,
|
||||
productName: '',
|
||||
productUnitId: null,
|
||||
@@ -180,7 +169,6 @@ function handlePriceChange(row: any) {
|
||||
function handleUpdateValue(row: any) {
|
||||
const index = tableData.value.findIndex((item) => item.id === row.id);
|
||||
if (index === -1) {
|
||||
row.id = tableData.value.length + 1;
|
||||
tableData.value.push(row);
|
||||
} else {
|
||||
tableData.value[index] = row;
|
||||
@@ -240,7 +228,23 @@ const getData = (): ErpPurchaseOrderApi.PurchaseOrderItem[] => tableData.value;
|
||||
const init = (
|
||||
items: ErpPurchaseOrderApi.PurchaseOrderItem[] | undefined,
|
||||
): void => {
|
||||
tableData.value = items ? [...items] : [];
|
||||
tableData.value =
|
||||
items && items.length > 0
|
||||
? items.map((item) => {
|
||||
const newItem = { ...item };
|
||||
if (newItem.productPrice && newItem.count) {
|
||||
newItem.totalProductPrice =
|
||||
erpPriceMultiply(newItem.productPrice, newItem.count) ?? 0;
|
||||
newItem.taxPrice =
|
||||
erpPriceMultiply(
|
||||
newItem.totalProductPrice,
|
||||
(newItem.taxPercent || 0) / 100,
|
||||
) ?? 0;
|
||||
newItem.totalPrice = newItem.totalProductPrice + newItem.taxPrice;
|
||||
}
|
||||
return newItem;
|
||||
})
|
||||
: [];
|
||||
nextTick(() => {
|
||||
gridApi.grid.reloadData(tableData.value);
|
||||
});
|
||||
|
||||
@@ -80,10 +80,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// 验证子表单
|
||||
await nextTick(); // 确保组件已经挂载
|
||||
await nextTick();
|
||||
|
||||
// 获取组件实例 - itemFormRef.value 是数组,需要访问第一个元素
|
||||
const itemFormInstance = Array.isArray(itemFormRef.value)
|
||||
? itemFormRef.value[0]
|
||||
: itemFormRef.value;
|
||||
@@ -114,12 +112,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const data =
|
||||
(await formApi.getValues()) as ErpPurchaseOrderApi.PurchaseOrder;
|
||||
data.items = formData.value?.items;
|
||||
if (data.items) {
|
||||
data.items = data.items.map((item) => {
|
||||
const { ...itemWithoutId } = item;
|
||||
return itemWithoutId;
|
||||
});
|
||||
}
|
||||
// 将文件数组转换为字符串
|
||||
if (data.fileUrl && Array.isArray(data.fileUrl)) {
|
||||
data.fileUrl = data.fileUrl.length > 0 ? data.fileUrl[0] : '';
|
||||
@@ -199,6 +191,7 @@ defineExpose({ modalApi });
|
||||
class="w-1/2"
|
||||
:closable="true"
|
||||
:mask-closable="true"
|
||||
:show-confirm-button="formType !== 'detail'"
|
||||
>
|
||||
<Form class="mx-3">
|
||||
<template #product="slotProps">
|
||||
|
||||
Reference in New Issue
Block a user