Merge branch 'master' of http://gitea.zianxin.com/zianxin-tec/biz-pc-cloud
This commit is contained in:
commit
2fd32b34fc
1 file changed
+35
-16
@@ -107,9 +107,9 @@
|
||||
<span v-else>{{ row.erpSpuId && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId)?.productName }}</span>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="unitId" title="包装单位" :edit-render="{}">
|
||||
<vxe-column field="unitObj" title="包装单位" :edit-render="{}">
|
||||
<template #edit="{ row }">
|
||||
<el-select v-if="row.erpUnitVos" v-model="row.unitId" value-key="id" placeholder="请选择包装单位">
|
||||
<el-select v-if="row.erpUnitVos" v-model="row.unitObj" value-key="id" placeholder="请选择包装单位">
|
||||
<el-option v-for="item in row.erpUnitVos" :key="item.id" :label="item.unit" :value="item" />
|
||||
</el-select>
|
||||
<el-select v-else v-model="row.unitId" value-key="id" placeholder="请选择包装单位">
|
||||
@@ -117,7 +117,7 @@
|
||||
</el-select>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.erpUnitVos">{{ row.unitId?.unit ?? "请选择" }}</span>
|
||||
<span v-if="row.erpUnitVos">{{ row.unitObj?.unit ?? "请选择" }}</span>
|
||||
<span v-else>{{ row.unit }}</span>
|
||||
</template>
|
||||
</vxe-column>
|
||||
@@ -128,22 +128,22 @@
|
||||
</vxe-column>
|
||||
<vxe-column field="unitPrice" title="原进价">
|
||||
<template #default="{ row }">
|
||||
{{ row.erpUnitVos ? displayPrice(row.unitId?.purchasePrice || 0) : displayPrice(row.purchasePrice) }}
|
||||
{{ row.erpUnitVos ? displayPrice(row.unitObj?.purchasePrice || 0) : displayPrice(row.purchasePrice) }}
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="realPrice" title="实际进价" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||
<template #default="{ row }">
|
||||
{{ row.erpUnitVos && row.unitId ? row.unitId?.realPrice || 0 : row.realPrice }}
|
||||
{{ row.erpUnitVos && row.unitObj ? row.unitObj?.realPrice || 0 : row.realPrice }}
|
||||
</template>
|
||||
<template #edit="{ row }">
|
||||
<el-input v-if="row.erpUnitVos && row.unitId" v-model="row.unitId.realPrice" />
|
||||
<el-input v-if="row.erpUnitVos && row.unitObj" v-model="row.unitObj.realPrice" />
|
||||
<el-input v-else v-model="row.realPrice" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="totalAmount" title="累计总金额">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.erpUnitVos && row.unitId && row.quantity">
|
||||
{{ Number(row.quantity * parseFloat(row.unitId.realPrice || 0)).toFixed(2) }}
|
||||
<span v-if="row.erpUnitVos && row.unitObj && row.quantity">
|
||||
{{ Number(row.quantity * parseFloat(row.unitObj.realPrice || 0)).toFixed(2) }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ Number(Number(row.quantity) * row.realPrice).toFixed(2) }}
|
||||
@@ -268,9 +268,8 @@ const dataRules = ref({
|
||||
|
||||
// 可编辑表格校验规则
|
||||
const validRules = ref<VxeTablePropTypes.EditRules<any>>({
|
||||
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 {
|
||||
|
||||
Reference in new issue
Block a user