diff --git a/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue b/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue
index 942dc21..1c0a007 100644
--- a/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue
+++ b/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue
@@ -107,9 +107,9 @@
{{ row.erpSpuId && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId)?.productName }}
-
+
-
+
@@ -117,7 +117,7 @@
- {{ row.unitId?.unit ?? "请选择" }}
+ {{ row.unitObj?.unit ?? "请选择" }}
{{ row.unit }}
@@ -128,22 +128,22 @@
- {{ row.erpUnitVos ? displayPrice(row.unitId?.purchasePrice || 0) : displayPrice(row.purchasePrice) }}
+ {{ row.erpUnitVos ? displayPrice(row.unitObj?.purchasePrice || 0) : displayPrice(row.purchasePrice) }}
- {{ row.erpUnitVos && row.unitId ? row.unitId?.realPrice || 0 : row.realPrice }}
+ {{ row.erpUnitVos && row.unitObj ? row.unitObj?.realPrice || 0 : row.realPrice }}
-
+
-
- {{ Number(row.quantity * parseFloat(row.unitId.realPrice || 0)).toFixed(2) }}
+
+ {{ Number(row.quantity * parseFloat(row.unitObj.realPrice || 0)).toFixed(2) }}
{{ Number(Number(row.quantity) * row.realPrice).toFixed(2) }}
@@ -268,9 +268,8 @@ const dataRules = ref({
// 可编辑表格校验规则
const validRules = ref>({
- unitId: [{ required: true, message: "必须选择" }],
+ unitObj: [{ required: true, message: "必须选择" }],
quantity: [{ required: true, type: "number", min: 1, message: "必需大于等于0" }],
- realPrice: [{ required: true, type: "number", min: 0, message: "必填" }],
})
// 初始化数据
@@ -287,8 +286,20 @@ const getInitData = async () => {
if (cgPlanData && cgPlanData.code === 0) {
Object.assign(baseDataForm, cgPlanData.data)
- state.editableTableData = cgPlanData.data.items
- state.erpSpuItemsMemo = cgPlanData.data.items
+ state.editableTableData = cgPlanData.data.items.map((item: any) => {
+ const unitObj = item.erpUnitVos.find((unit: any) => unit.id === item.unitId)
+ return {
+ ...item,
+ unitObj: { ...unitObj, realPrice: item?.realPrice || 0 },
+ }
+ })
+ state.erpSpuItemsMemo = cgPlanData.data.items.map((item: any) => {
+ const unitObj = item.erpUnitVos.find((unit: any) => unit.id === item.unitId)
+ return {
+ ...item,
+ unitObj: { ...unitObj, realPrice: item?.realPrice || 0 },
+ }
+ })
}
} else {
loading.value = true
@@ -315,8 +326,16 @@ const getSelectedLinkCode = (selectionRows: any) => {
console.log("被选择的关联数据", selectionRows)
baseDataForm.linkCode = selectionRows.code
- state.editableTableData = selectionRows.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.purchasePrice, "") }))
- state.erpSpuItemsMemo = selectionRows.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.purchasePrice, "") }))
+ state.editableTableData = selectionRows.items.map((item: any) => ({
+ ...item,
+ unitObj: {},
+ realPrice: displayPrice(item.purchasePrice, ""),
+ }))
+ state.erpSpuItemsMemo = selectionRows.items.map((item: any) => ({
+ ...item,
+ unitObj: {},
+ realPrice: displayPrice(item.purchasePrice, ""),
+ }))
state.linkCgPlanDialogVisible = false
}
@@ -386,7 +405,7 @@ const getSelectedSpuRows = (selectionRows: any) => {
const cgPlanSpuItems = computed(() => {
return state.editableTableData.map((item: any) => {
if (item.erpUnitVos) {
- const unitObj = item.unitId
+ const unitObj = item.unitObj
return {
id: item.isNew ? undefined : item.id,
erpSpuId: item.erpSpuId,
@@ -395,7 +414,7 @@ const cgPlanSpuItems = computed(() => {
realPrice: unitObj.realPrice ? storePrice(unitObj?.realPrice) : 0,
totalAmount: storePrice(Number(unitObj?.realPrice || 0) * item.quantity),
remark: item.remark,
- unitId: unitObj.unitId,
+ unitId: unitObj.id,
}
} else {
return {