diff --git a/src/components/charge/AssociationIdCode.vue b/src/components/charge/AssociationIdCode.vue new file mode 100644 index 0000000..0d5ef18 --- /dev/null +++ b/src/components/charge/AssociationIdCode.vue @@ -0,0 +1,218 @@ + + + \ No newline at end of file diff --git a/src/components/charge/CheckoutDetail.vue b/src/components/charge/CheckoutDetail.vue index 11c24c5..67ba9aa 100644 --- a/src/components/charge/CheckoutDetail.vue +++ b/src/components/charge/CheckoutDetail.vue @@ -28,11 +28,11 @@ {{ item.name }} - +
未关联
- {{ item.retailNumber }}{{ item.selectedUnit }} - {{ item.gatherNumber }}/{{ item.retailNumber }} + {{ item.selectedNum }}{{ item.selectedUnit }} + {{ item.traceAbilityCodeList ? item.traceAbilityCodeList.length : 0 }}/{{ item.shouldNumber }} @@ -57,10 +57,11 @@ import Mask from "@/components/Mask.vue"; import CloseBtn from "@/components/CloseBtn.vue"; import {nextTick, ref} from "vue"; -import IdCodeListShow from "@/components/retail/IdCodeListShow.vue"; -import AssociationIdCode from "@/components/retail/AssociationIdCode.vue"; -import TraceabilityCodeAdd from "@/components/retail/TraceabilityCodeAdd.vue"; +import IdCodeListShow from "@/components/charge/IdCodeListShow.vue"; +import AssociationIdCode from "@/components/charge/AssociationIdCode.vue"; +import TraceabilityCodeAdd from "@/components/charge/TraceabilityCodeAdd.vue"; import {ElMessage, ElMessageBox} from "element-plus"; +import {Monitor} from '@element-plus/icons-vue' import {post} from "@/utils/request.ts"; @@ -97,7 +98,7 @@ const saveRetail = () => { const checkTraceCode = () => { for (let i = 0; i < list.value.length; i++) { const item = list.value[i]; - if (item.gatherNumber !== item.retailNumber) { + if (!item.traceAbilityCodeList || item.shouldNumber !== item.traceAbilityCodeList.length) { return false; } } @@ -117,6 +118,7 @@ const addTraceAbilityCode = () => { for (let i = 0; i < list.value.length; i++) { let item = list.value[i]; let idCode = inputIdCode.value.slice(0, 7); + if (!item.idCode) break if (item.idCode.includes(idCode)) { addTraceabilityCodeDo(item); return true @@ -130,7 +132,9 @@ const addTraceabilityCodeDo = (item: any) => { if (!item.traceAbilityCodeList) { item.traceAbilityCodeList = [] } - if (item.retailNumber == item.gatherNumber) { + let traceAbilityCodeListList = item.traceAbilityCodeList.length + + if (traceAbilityCodeListList == item.shouldNumber) { ElMessage({ message: '采集数量已满', type: 'warning', @@ -138,61 +142,19 @@ const addTraceabilityCodeDo = (item: any) => { return } const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === inputIdCode.value); - if (index == -1 && item.selectedUnit == item.packagingUnit) { - item.traceAbilityCodeList.push({ - code: inputIdCode.value, - number: 1 - }) - cleanInputIdCode() - getGatherNumber(item) - return; - } - if (index == -1 && item.selectedUnit == item.minPackagingUnit) { - - let needCodeCount = item.retailNumber - item.gatherNumber; - let number = 1; - if (needCodeCount >= item.minPackagingNumber) { - number = item.minPackagingNumber; - } - if (needCodeCount < item.minPackagingNumber) { - number = needCodeCount; - } - item.traceAbilityCodeList.push({ - code: inputIdCode.value, - number: number - }) - cleanInputIdCode() - getGatherNumber(item) - return; - } - if (item.selectedUnit == item.packagingUnit) { - //没拆零 追溯码只能用一次 + if (index != -1) { ElMessage({ - message: '该追溯码已达到最大使用限制', + message: '该追溯码已采集', type: 'warning', }) - return; - } else { - //拆零每一个追溯码最多使用minPackagingNumber次 - if (item.traceAbilityCodeList[index].number == item.minPackagingNumber) { - ElMessage({ - message: '该追溯码已达到最大使用限制', - type: 'warning', - }) - return; - } - item.traceAbilityCodeList[index].number += 1; + return } + item.traceAbilityCodeList.push(inputIdCode.value) cleanInputIdCode() getGatherNumber(item) - console.log("item", item) } const getGatherNumber = (item: any) => { - let gatherNumber = 0; - for (let subItem of item.traceAbilityCodeList) { - gatherNumber += subItem.number; - } - item.gatherNumber = gatherNumber; + item.shouldNumber = item.traceAbilityCodeList?item.traceAbilityCodeList.length:0; } const cleanInputIdCode = () => { diff --git a/src/components/charge/IdCodeListShow.vue b/src/components/charge/IdCodeListShow.vue new file mode 100644 index 0000000..051d33a --- /dev/null +++ b/src/components/charge/IdCodeListShow.vue @@ -0,0 +1,47 @@ + + + + + \ No newline at end of file diff --git a/src/components/charge/TotalPrice.vue b/src/components/charge/TotalPrice.vue index a3eafa7..bae6619 100644 --- a/src/components/charge/TotalPrice.vue +++ b/src/components/charge/TotalPrice.vue @@ -21,7 +21,7 @@ const totalAmount = defineModel() diff --git a/src/components/charge/TraceabilityCodeAdd.vue b/src/components/charge/TraceabilityCodeAdd.vue new file mode 100644 index 0000000..bca698b --- /dev/null +++ b/src/components/charge/TraceabilityCodeAdd.vue @@ -0,0 +1,174 @@ + + + \ No newline at end of file diff --git a/src/components/common/goods/GoodsDetail.vue b/src/components/common/goods/GoodsDetail.vue index b42fc40..5e2cd6d 100644 --- a/src/components/common/goods/GoodsDetail.vue +++ b/src/components/common/goods/GoodsDetail.vue @@ -48,7 +48,7 @@