修复
This commit is contained in:
1 parent
4d10c86446
commit
3499ec6dbb
5 files changed
+85
-71
No files matched your search
@@ -33,20 +33,23 @@
|
||||
<vxe-column field="unit" title="单位" :edit-render="{}">
|
||||
<template #edit="{ row }">
|
||||
<el-select v-model="row.unitId">
|
||||
<div v-for="item in smErpUnitEntityList">
|
||||
<div v-for="item in computedSmErpUnitEntityList">
|
||||
<el-option :label="item.unit" :value="item.id" />
|
||||
</div>
|
||||
</el-select>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.unitId">{{ smErpUnitEntityList?.find((item) => item.id === row.unitId)?.unit }}</span>
|
||||
<span v-if="row.unitId">{{ computedSmErpUnitEntityList?.find((item: rowVU) => item.id === row.unitId)?.unit }}</span>
|
||||
<span v-else style="color: #c0c4cf">请选择</span>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="barCode" title="条码">
|
||||
<template #default="{ row }">
|
||||
{{ smErpUnitEntityList?.find((item) => item.id == row.unitId)?.barCode }}
|
||||
<vxe-column field="barCode" title="辅助条码" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||
<template #edit="{ row }">
|
||||
<el-input v-model.trim="row.barCode" />
|
||||
</template>
|
||||
<!-- <template #default="{ row }">
|
||||
{{ computedSmErpUnitEntityList?.find((item) => item.id == row.unitId)?.barCode }}
|
||||
</template> -->
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
</div>
|
||||
@@ -55,7 +58,7 @@
|
||||
<script setup lang="ts">
|
||||
import { nanoid } from "nanoid"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { rowVU } from "./packageUnit.vue"
|
||||
import { type rowVU } from "./packageUnit.vue"
|
||||
|
||||
export interface rowVC {
|
||||
id: string
|
||||
@@ -109,6 +112,19 @@ const pushEvent = () => {
|
||||
})
|
||||
}
|
||||
|
||||
// 包装单位行删除时清除辅助条码中选择该包装单位的行
|
||||
watch(
|
||||
() => props.smErpUnitEntityList?.length,
|
||||
() => {
|
||||
auxiliaryCodeList.value = auxiliaryCodeList.value.filter((codeItem: rowVC) =>
|
||||
props.smErpUnitEntityList?.some((item: rowVU) => codeItem.unitId === item.id),
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
// 计算辅助条码中可选择的包装单位下拉菜单
|
||||
const computedSmErpUnitEntityList = computed(() => props.smErpUnitEntityList?.filter((item: rowVU) => item.unit))
|
||||
|
||||
// 删除选中的行
|
||||
const removeSelectRowEvent = () => {
|
||||
const $table = editableTableRef.value
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button v-if="currentTabPaneIndex != 0" type="primary" @click="currentTabPaneIndex--" :disabled="loading">上一步</el-button>
|
||||
<el-button v-if="currentTabPaneIndex != 3" type="primary" @click="currentTabPaneIndex++">下一步</el-button>
|
||||
<el-button v-if="currentTabPaneIndex == 3" type="primary" @click="onSubmit" :disabled="loading">确 认</el-button>
|
||||
<el-button v-if="currentTabPaneIndex == 3" type="primary" @click="onSubmit" :disabled="loading">提 交</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -34,7 +34,7 @@
|
||||
import baseInfo from "./components/baseInfo.vue"
|
||||
import packageUnit, { type rowVU } from "./components/packageUnit.vue"
|
||||
import productInventory from "./components/productInventory.vue"
|
||||
import auxiliaryCode, { rowVC } from "./components/auxiliaryCode.vue"
|
||||
import auxiliaryCode, { type rowVC } from "./components/auxiliaryCode.vue"
|
||||
import { getObj, addObj, putObj } from "/@/api/supermarketerp/supermarketSpu"
|
||||
import { TabPaneName } from "element-plus"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
@@ -161,10 +161,10 @@ const resetForm = () => {
|
||||
// tab栏切换
|
||||
const handleTabChange = (name: TabPaneName) => (currentTabPaneIndex.value = tabPaneEnum.findIndex((item) => item === name))
|
||||
|
||||
// 整理包装单位列表
|
||||
const usePackageUnitList = () => {
|
||||
// 计算包装单位列表
|
||||
const usePackageUnitList = computed(() => {
|
||||
const curRadioRowUnit = packageUnitRef.value.getRadioEvent()
|
||||
return form.smErpUnitEntityList.map((item: rowVU) => {
|
||||
return [...form.smErpUnitEntityList].map((item: rowVU) => {
|
||||
if (item.id === curRadioRowUnit.id) {
|
||||
item.isBase = true
|
||||
} else {
|
||||
@@ -180,23 +180,23 @@ const usePackageUnitList = () => {
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 整理辅助条码列表
|
||||
const useAuxiliaryCode = () => {
|
||||
// 计算辅助条码列表
|
||||
const useAuxiliaryCode = computed(() => {
|
||||
return form.smErpAuxiliaryCodeEntityList
|
||||
.filter((item: rowVC) => item.unitId)
|
||||
.map((item: rowVC) => {
|
||||
const curAuxiliaryCodeItem = form.smErpUnitEntityList.find((unitItem: any) => unitItem.id === item.unitId)
|
||||
if (curAuxiliaryCodeItem.barCode) item.barCode = curAuxiliaryCodeItem.barCode
|
||||
// const curAuxiliaryCodeItem = form.smErpUnitEntityList.find((unitItem: any) => unitItem.id === item.unitId)
|
||||
// if (curAuxiliaryCodeItem.barCode) item.barCode = curAuxiliaryCodeItem.barCode
|
||||
if (item.isNew) {
|
||||
item.id = ""
|
||||
if (curAuxiliaryCodeItem.isNew) item.unitId = ""
|
||||
// if (curAuxiliaryCodeItem.isNew) item.unitId = ""
|
||||
delete item.isNew
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
@@ -210,23 +210,17 @@ const onSubmit = async () => {
|
||||
// if (!form.smErpAuxiliaryCodeEntityList || form.smErpAuxiliaryCodeEntityList.length <= 0) return useMessage().warning("请添加辅助条码")
|
||||
// if (!(await auxiliaryCodeRef.value.editableTableValidate())) return useMessage().warning("辅助条码必填项未填写完整")
|
||||
|
||||
const handleAuxiliaryCode = useAuxiliaryCode()
|
||||
const handlePackageUnit = usePackageUnitList()
|
||||
console.log("提交的数据", {
|
||||
...form,
|
||||
grossMargin: storePrice(form.grossMargin),
|
||||
smErpUnitEntityList: handlePackageUnit,
|
||||
smErpAuxiliaryCodeEntityList: handleAuxiliaryCode,
|
||||
})
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
const _pa = {
|
||||
...form,
|
||||
grossMargin: storePrice(form.grossMargin),
|
||||
smErpUnitEntityList: handlePackageUnit,
|
||||
smErpAuxiliaryCodeEntityList: handleAuxiliaryCode,
|
||||
smErpUnitEntityList: usePackageUnitList.value,
|
||||
smErpAuxiliaryCodeEntityList: useAuxiliaryCode.value,
|
||||
}
|
||||
|
||||
console.log("提交的数据", _pa)
|
||||
|
||||
const res = form.id ? await putObj(_pa) : await addObj(_pa)
|
||||
if (res.code === 0) {
|
||||
useMessage().success(form.id ? "修改成功" : "添加成功")
|
||||
|
||||
Reference in new issue
Block a user