diff --git a/src/views/supermarketerp/supermarketSpu/components/auxiliary-code.vue b/src/views/supermarketerp/supermarketSpu/components/auxiliary-code.vue index 6161243..90bd45e 100644 --- a/src/views/supermarketerp/supermarketSpu/components/auxiliary-code.vue +++ b/src/views/supermarketerp/supermarketSpu/components/auxiliary-code.vue @@ -1,21 +1,19 @@ - - - 新增 - 删除选中 - + + 新增 + - - - - - - - - - - - - - {{ computedSmErpUnitEntityList?.find((item: rowVU) => item.id === row.unitId)?.unit }} - 请选择 - - - - - {{ computedSmErpUnitEntityList?.find((item: rowVU) => item.id === row.unitId)?.taste }} - - - - - - - - - + size="mini" + align="center" + > + + + + + + + + 单位:{{ item.unit }} + 口味:{{ item.taste }} + + + + + + {{ unitSelectOptions?.find((item: rowVU) => item.id === row.unitId)?.unit }} + 请选择 + + + + + {{ unitSelectOptions?.find((item: rowVU) => item.id === row.unitId)?.taste }} + + + + + + + + + + + 删除 + + + + diff --git a/src/views/supermarketerp/supermarketSpu/components/base-info.vue b/src/views/supermarketerp/supermarketSpu/components/base-info.vue index b55608e..289d028 100644 --- a/src/views/supermarketerp/supermarketSpu/components/base-info.vue +++ b/src/views/supermarketerp/supermarketSpu/components/base-info.vue @@ -1,84 +1,112 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + {{ item.label }} - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + 正常 @@ -86,31 +114,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue index ab29d47..a440296 100644 --- a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue +++ b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue @@ -1,33 +1,31 @@ - - - 新增 - 删除选中 - - - - - 注:内装数据必须为该商品的最小售卖的基本单位,否则无法完成库存数量转换,影响erp库存自动扣减操作。 - 例如:一瓶矿泉水内装填'1',为售卖的最小基础单位,如果想按箱卖,在继续添加包装单位为箱,内装为24 - - - - - - + + 新增 + + + + + 注:内装数据必须为该商品的最小售卖的基本单位,否则无法完成库存数量转换,影响erp库存自动扣减操作。 + 例如:一瓶矿泉水内装填'1',为售卖的最小基础单位,如果想按箱卖,在继续添加包装单位为箱,内装为24 + + + + + + - - - - - - - - - - - - - - - - - handleUnitInput(row, value)" /> - - - - - handleTasteInput(row, value)" /> - - - - - - - - - - - 正常 - 停销 - 请选择 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + size="mini" + align="center" + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 正常 + 停销 + 请选择 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 删除 + + + + diff --git a/src/views/supermarketerp/supermarketSpu/components/product-inventory.vue b/src/views/supermarketerp/supermarketSpu/components/product-inventory.vue index 7b0eef0..9299bb8 100644 --- a/src/views/supermarketerp/supermarketSpu/components/product-inventory.vue +++ b/src/views/supermarketerp/supermarketSpu/components/product-inventory.vue @@ -1,18 +1,18 @@ - + - + - + diff --git a/src/views/supermarketerp/supermarketSpu/components/upload-excel.vue b/src/views/supermarketerp/supermarketSpu/components/upload-excel.vue index eb7cb1e..7da9044 100644 --- a/src/views/supermarketerp/supermarketSpu/components/upload-excel.vue +++ b/src/views/supermarketerp/supermarketSpu/components/upload-excel.vue @@ -137,6 +137,7 @@ const handleFileSuccess = (response: any) => { * 提交表单,触发上传 */ const submitFileForm = () => { + state.upload.isUploading = true uploadRef.value.submit() } diff --git a/src/views/supermarketerp/supermarketSpu/form.vue b/src/views/supermarketerp/supermarketSpu/form.vue index 1a95377..2dd4b55 100644 --- a/src/views/supermarketerp/supermarketSpu/form.vue +++ b/src/views/supermarketerp/supermarketSpu/form.vue @@ -1,6 +1,6 @@ - - + + @@ -16,15 +16,15 @@ /> - + - 上一步 - 下一步 - 提 交 + 上一步 + 下一步 + 提 交 取消 @@ -43,15 +43,14 @@ import { nanoid } from "nanoid" const emit = defineEmits(["refresh"]) -const formRef = ref() -const packageUnitRef = ref() const visible = ref(false) const loading = ref(false) -const tabPaneEnum = ["基础信息", "包装单位", "库存", "辅助条码"] -const currentTabPaneIndex = ref(0) -const tabPaneActiveName = computed(() => tabPaneEnum[currentTabPaneIndex.value]) +const formRef = ref() +const packageUnitRef = ref() +const tabPaneName = ["基础信息", "包装单位", "库存", "辅助条码"] +const tabPaneActiveName = ref(tabPaneName[0]) +const tabPaneActiveIndex = ref(0) -// 提交表单数据 const form = reactive({ id: "", merchantId: "", @@ -83,9 +82,8 @@ const form = reactive({ promotionPrice: 0, costPrice: 0, }) - // 基本信息的金额转为单位分 -const formatedBaseFormMoney = computed(() => { +const formatedStorePrice = computed(() => { return { grossMargin: storePrice(form.grossMargin), purchasePrice: storePrice(form.purchasePrice), @@ -95,7 +93,7 @@ const formatedBaseFormMoney = computed(() => { } }) -// 定义校验规则 +// 表单校验规则 const dataRules = { productNature: [{ required: true, message: "请选择商品性质", trigger: "blur" }], merchantId: [{ required: true, message: "商户不能为空", trigger: "blur" }], @@ -122,11 +120,56 @@ const dataRules = { // costPrice: [{ required: true, message: "成本价不能为空", trigger: "blur" }], } +// tab栏切换 +const handleTabChange = (name: TabPaneName) => { + tabPaneActiveIndex.value = tabPaneName.findIndex((item) => item === name) + setDefaultPackageUnit() +} + +// 上一步 +const previousStep = () => { + tabPaneActiveIndex.value-- + tabPaneActiveName.value = tabPaneName[tabPaneActiveIndex.value] + setDefaultPackageUnit() +} + +// 下一步 +const nextStep = () => { + tabPaneActiveIndex.value++ + tabPaneActiveName.value = tabPaneName[tabPaneActiveIndex.value] + setDefaultPackageUnit() +} + +// 默认设置一行基础包装单位 +const setDefaultPackageUnit = () => { + if (!form.id && tabPaneActiveIndex.value == 1) { + const isFlagRowExist = form.smErpUnitEntityList.some((item: rowVU) => item.flag === "defaultPackageUnitRow") + if (isFlagRowExist) return + const row = { + id: "tmp_" + nanoid(5), + barCode: form.barCode, + spec: form.spec, + unit: form.unit, + status: form.unitStatus, + packageNum: form.packageNum, + purchasePrice: form.purchasePrice, + retailPrice: form.retailPrice, + promotionPrice: form.promotionPrice, + costPrice: form.costPrice, + flag: "defaultPackageUnitRow", + } + packageUnitRef.value.pushEvent(row) + packageUnitRef.value.setRadioRow(0) // 自动设置基础包装单位的radio单选行 + } +} + // 打开弹窗 const openDialog = async (id: string) => { - visible.value = true - currentTabPaneIndex.value = 0 + tabPaneActiveIndex.value = 0 + tabPaneActiveName.value = tabPaneName[tabPaneActiveIndex.value] form.id = "" + visible.value = true + // 重置表单数据 resetForm() @@ -144,10 +187,10 @@ const openDialog = async (id: string) => { const getsupermarketSpuData = async (id: string) => { loading.value = true try { - const res = await getObj(id) - if (res.code === 0) { - res.data.smErpUnitEntityList = res.data.smErpUnitEntityList.map((item: rowVU) => { - // 格式化金额数据 + const { code, data } = await getObj(id) + if (code === 0) { + data.smErpUnitEntityList = data.smErpUnitEntityList.map((item: rowVU) => { + // 格式化金额 item.retailPrice = parseFloat(displayPrice(item.retailPrice, "")) item.promotionPrice = parseFloat(displayPrice(item.promotionPrice, "")) item.purchasePrice = parseFloat(displayPrice(item.purchasePrice, "")) @@ -156,12 +199,12 @@ const getsupermarketSpuData = async (id: string) => { }) Object.assign(form, { - ...res.data, - grossMargin: parseFloat(displayPrice(res.data.grossMargin, "")), - retailPrice: parseFloat(displayPrice(res.data.retailPrice, "")), - promotionPrice: parseFloat(displayPrice(res.data.promotionPrice, "")), - purchasePrice: parseFloat(displayPrice(res.data.purchasePrice, "")), - costPrice: parseFloat(displayPrice(res.data.costPrice, "")), + ...data, + grossMargin: parseFloat(displayPrice(data.grossMargin, "")), + retailPrice: parseFloat(displayPrice(data.retailPrice, "")), + promotionPrice: parseFloat(displayPrice(data.promotionPrice, "")), + purchasePrice: parseFloat(displayPrice(data.purchasePrice, "")), + costPrice: parseFloat(displayPrice(data.costPrice, "")), }) } } catch (error: any) { @@ -178,44 +221,6 @@ const resetForm = () => { form.smErpAuxiliaryCodeEntityList = [] } -// tab栏切换 -const handleTabChange = (name: TabPaneName) => { - currentTabPaneIndex.value = tabPaneEnum.findIndex((item) => item === name) - if (form.id) return - setDefaultPackageUnit() -} - -// 下一步 -const nextStep = () => { - currentTabPaneIndex.value++ - if (form.id) return - setDefaultPackageUnit() -} - -// 默认设置一行基础包装单位 -const setDefaultPackageUnit = () => { - if (currentTabPaneIndex.value == 1) { - const isFlagRowExist = form.smErpUnitEntityList.some((item: rowVU) => item.flag === "defaultAddedPackageUnit") - if (isFlagRowExist) return - const row = { - id: nanoid(5), - barCode: form.barCode, - spec: form.spec, - unit: form.unit, - status: form.unitStatus, - packageNum: form.packageNum, - purchasePrice: form.purchasePrice, - retailPrice: form.retailPrice, - promotionPrice: form.promotionPrice, - costPrice: form.costPrice, - isNew: true, - flag: "defaultAddedPackageUnit", - } - packageUnitRef.value.pushEvent(row) - packageUnitRef.value.setRadioRow(0) // 自动设置基础包装单位的radio单选行 - } -} - // 整理包装单位列表 const settlePackageUnitList = () => { const curRadioRowUnit = packageUnitRef.value.getRadioRow() @@ -227,15 +232,12 @@ const settlePackageUnitList = () => { } else { item.isBase = false } + if (item.id.startsWith("tmp_")) item.id = "" // 转换金额单位 item.costPrice = storePrice(item.costPrice) item.promotionPrice = storePrice(item.promotionPrice) item.purchasePrice = storePrice(item.purchasePrice) item.retailPrice = storePrice(item.retailPrice) - if (item.isNew) { - item.id = "" - delete item.isNew - } return item }) } @@ -246,13 +248,8 @@ const settleAuxiliaryCode = () => { return smErpAuxiliaryCodeEntityList .filter((item: rowVC) => item.unitId) .map((item: rowVC) => { - const curPackageUnitItem = form.smErpUnitEntityList.find((unitItem: any) => unitItem.id == item.unitId) - - if (item.isNew) { - item.id = "" - if (curPackageUnitItem?.isNew) item.unitId = "" - delete item.isNew - } + if (item.id.startsWith("tmp_")) item.id = "" + if (item.unitId.startsWith("tmp_")) item.unitId = "" return item }) } @@ -262,27 +259,21 @@ const onSubmit = async () => { const valid = await formRef.value.validate().catch(() => {}) if (!valid) return useMessage().warning("基础信息或库存必填项未填写完整") if (!form.smErpUnitEntityList || form.smErpUnitEntityList.length <= 0) return useMessage().warning("请添加包装单位") - if (!(await packageUnitRef.value.editableTableValidate())) return useMessage().warning("包装单位必填项未填写完整") + if (!(await packageUnitRef.value.tableValidate())) return useMessage().warning("包装单位必填项未填写完整 且 相同包装单位的口味不能相同") if (!packageUnitRef.value.getRadioRow()) return useMessage().warning("请选择基础包装单位") - // if (!form.smErpAuxiliaryCodeEntityList || form.smErpAuxiliaryCodeEntityList.length <= 0) return useMessage().warning("请添加辅助条码") - // if (!(await auxiliaryCodeRef.value.editableTableValidate())) return useMessage().warning("辅助条码必填项未填写完整") - - console.log("未整理-包装单位", form.smErpUnitEntityList) - console.log("未整理-辅助条码", form.smErpAuxiliaryCodeEntityList) - const smErpAuxiliaryCodeEntityList = settleAuxiliaryCode() const smErpUnitEntityList = settlePackageUnitList() try { loading.value = true const _pa = { ...form, - ...formatedBaseFormMoney.value, + ...formatedStorePrice.value, smErpAuxiliaryCodeEntityList, smErpUnitEntityList, } - console.log("提交的数据", _pa) + // console.log("提交的数据", _pa) const res = form.id ? await putObj(_pa) : await addObj(_pa) if (res.code === 0) {
- 注:内装数据必须为该商品的最小售卖的基本单位,否则无法完成库存数量转换,影响erp库存自动扣减操作。 - 例如:一瓶矿泉水内装填'1',为售卖的最小基础单位,如果想按箱卖,在继续添加包装单位为箱,内装为24 -
+ 注:内装数据必须为该商品的最小售卖的基本单位,否则无法完成库存数量转换,影响erp库存自动扣减操作。 + 例如:一瓶矿泉水内装填'1',为售卖的最小基础单位,如果想按箱卖,在继续添加包装单位为箱,内装为24 +