Compare commits
2 Commits
4638683b01
...
77b913e017
| Author | SHA1 | Date |
|---|---|---|
|
|
77b913e017 | |
|
|
7df8b4dbbe |
|
|
@ -82,7 +82,6 @@ const tableData = ref<TableItem[]>([]);
|
|||
const init = (newIdCode: any, newTableDate: any) => {
|
||||
traceabilityCode.value = newIdCode;
|
||||
tableData.value = newTableDate;
|
||||
console.log(tableData)
|
||||
show.value = true;
|
||||
}
|
||||
const selected = ref()
|
||||
|
|
@ -105,78 +104,13 @@ const addIdCode = ()=>{
|
|||
if(!selectedItem){
|
||||
return
|
||||
}
|
||||
addTraceabilityCode(selectedItem)
|
||||
addTraceabilityCodeDo(selectedItem)
|
||||
|
||||
}
|
||||
const getGatherNumber=(item:any)=>{
|
||||
let gatherNumber = 0;
|
||||
for (let subItem of item.traceAbilityCodeList){
|
||||
gatherNumber+=subItem.number;
|
||||
}
|
||||
item.gatherNumber = gatherNumber;
|
||||
}
|
||||
const emit = defineEmits(["addIdCode"])
|
||||
const addTraceabilityCode = (item: any) => {
|
||||
if (!item.traceAbilityCodeList) {
|
||||
item.traceAbilityCodeList = []
|
||||
}
|
||||
if (item.retailNumber == item.gatherNumber) {
|
||||
ElMessage({
|
||||
message: '采集数量已满',
|
||||
type: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === traceabilityCode.value);
|
||||
if (index == -1 && item.selectedUnit == item.packagingUnit){
|
||||
item.traceAbilityCodeList.push({
|
||||
code: traceabilityCode.value,
|
||||
number: 1
|
||||
})
|
||||
traceabilityCode.value = "";
|
||||
getGatherNumber(item)
|
||||
emit("addIdCode")
|
||||
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: traceabilityCode.value,
|
||||
number: number
|
||||
})
|
||||
traceabilityCode.value = "";
|
||||
getGatherNumber(item)
|
||||
emit("addIdCode")
|
||||
return;
|
||||
}
|
||||
if(item.selectedUnit == item.packagingUnit){
|
||||
//没拆零 追溯码只能用一次
|
||||
ElMessage({
|
||||
message: '该追溯码已达到最大使用限制',
|
||||
type: 'warning',
|
||||
})
|
||||
return;
|
||||
}else {
|
||||
//拆零每一个追溯码最多使用minPackagingNumber次
|
||||
if (item.traceAbilityCodeList[index].number == item.minPackagingNumber) {
|
||||
ElMessage({
|
||||
message: '该追溯码已达到最大使用限制',
|
||||
type: 'warning',
|
||||
})
|
||||
return;
|
||||
}
|
||||
item.traceAbilityCodeList[index].number += 1;
|
||||
}
|
||||
traceabilityCode.value = "";
|
||||
getGatherNumber(item)
|
||||
emit("addIdCode")
|
||||
|
||||
const emit = defineEmits(["addIdCode","addTraceabilityCode"])
|
||||
const addTraceabilityCodeDo = (item: any) => {
|
||||
emit("addTraceabilityCode",item,traceabilityCode.value)
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -28,13 +28,14 @@
|
|||
<tr v-for="(item,index) in list" :key="index">
|
||||
<td>{{ item.name }}</td>
|
||||
<td>
|
||||
<IdCodeListShow :idCodeList="item.idCode" v-if="item.idCode&&item.idCode.length>0"/>
|
||||
<IdCodeListShow :idCodeList="item.idCode" v-if="item.idCode&&item.idCode.length>0"
|
||||
@addTraceabilityCode="addTraceAbilityCodeHandler"/>
|
||||
<div v-else>未关联</div>
|
||||
</td>
|
||||
<td>{{ item.selectedNum }}{{ item.selectedUnit }}</td>
|
||||
<td>{{ item.traceAbilityCodeList ? item.traceAbilityCodeList.length : 0 }}/{{ item.shouldNumber }}</td>
|
||||
<td>
|
||||
<TraceabilityCodeAdd :item="item"/>
|
||||
<TraceabilityCodeAdd :item="item" @addTraceabilityCode="addTraceAbilityCodeHandler"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
@ -50,7 +51,10 @@
|
|||
</div>
|
||||
</template>
|
||||
</el-card>
|
||||
<AssociationIdCode ref="associationIdCodeRef" @addIdCode="cleanInputIdCode"></AssociationIdCode>
|
||||
<AssociationIdCode
|
||||
ref="associationIdCodeRef"
|
||||
@addIdCode="cleanInputIdCode"
|
||||
@addTraceabilityCode="addTraceAbilityCodeHandler"></AssociationIdCode>
|
||||
</Mask>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
|
@ -90,7 +94,6 @@ const saveRetail = () => {
|
|||
}).then(() => {
|
||||
emit('confirm')
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
emit('confirm')
|
||||
|
|
@ -120,7 +123,7 @@ const addTraceAbilityCode = () => {
|
|||
let idCode = inputIdCode.value.slice(0, 7);
|
||||
if (!item.idCode) break
|
||||
if (item.idCode.includes(idCode)) {
|
||||
addTraceabilityCodeDo(item);
|
||||
addTraceabilityCodeDo(item, inputIdCode.value);
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -128,7 +131,7 @@ const addTraceAbilityCode = () => {
|
|||
|
||||
}
|
||||
|
||||
const addTraceabilityCodeDo = (item: any) => {
|
||||
const addTraceabilityCodeDo = (item: any, inputStr: any) => {
|
||||
if (!item.traceAbilityCodeList) {
|
||||
item.traceAbilityCodeList = []
|
||||
}
|
||||
|
|
@ -141,7 +144,7 @@ const addTraceabilityCodeDo = (item: any) => {
|
|||
})
|
||||
return
|
||||
}
|
||||
const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === inputIdCode.value);
|
||||
const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === inputStr);
|
||||
if (index != -1) {
|
||||
ElMessage({
|
||||
message: '该追溯码已采集',
|
||||
|
|
@ -149,18 +152,18 @@ const addTraceabilityCodeDo = (item: any) => {
|
|||
})
|
||||
return
|
||||
}
|
||||
item.traceAbilityCodeList.push(inputIdCode.value)
|
||||
item.traceAbilityCodeList.push(inputStr)
|
||||
cleanInputIdCode()
|
||||
getGatherNumber(item)
|
||||
}
|
||||
const getGatherNumber = (item: any) => {
|
||||
item.shouldNumber = item.traceAbilityCodeList?item.traceAbilityCodeList.length:0;
|
||||
}
|
||||
|
||||
|
||||
const cleanInputIdCode = () => {
|
||||
inputIdCode.value = ''
|
||||
}
|
||||
const addTraceAbilityCodeHandler = (item: any, code: any) => {
|
||||
addTraceabilityCodeDo(item, code)
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
</template>
|
||||
<template #default>
|
||||
<div v-for="(subItem,index) in item.traceAbilityCodeList" class="list">
|
||||
<div class="code"> {{ subItem.code }}</div>
|
||||
<div class="remove" @click="removeTraceAbility(item)">
|
||||
<div class="code"> {{ subItem }}</div>
|
||||
<div class="remove" @click="removeTraceAbility(subItem)">
|
||||
<el-icon>
|
||||
<CloseBold/>
|
||||
</el-icon>
|
||||
|
|
@ -61,93 +61,23 @@ const props = defineProps({
|
|||
}),
|
||||
},
|
||||
})
|
||||
const getGatherNumber = (item: any) => {
|
||||
item.shouldNumber = item.traceAbilityCodeList?item.traceAbilityCodeList.length:0;
|
||||
}
|
||||
const inputTraceabilityCode = ref("");
|
||||
const emit = defineEmits(["addTraceabilityCode"]);
|
||||
const addTraceabilityCodeDo = (item: any) => {
|
||||
if (!item.traceAbilityCodeList) {
|
||||
item.traceAbilityCodeList = []
|
||||
}
|
||||
let traceAbilityCodeListList = item.traceAbilityCodeList.length
|
||||
emit("addTraceabilityCode",item,inputTraceabilityCode.value)
|
||||
inputTraceabilityCode.value = ""
|
||||
}
|
||||
|
||||
if (traceAbilityCodeListList == item.shouldNumber) {
|
||||
ElMessage({
|
||||
message: '采集数量已满',
|
||||
type: 'warning',
|
||||
})
|
||||
return
|
||||
const removeTraceAbility = (code: any) => {
|
||||
const index = props.item.traceAbilityCodeList.findIndex(
|
||||
(codeObj: any) => codeObj === code
|
||||
);
|
||||
|
||||
if (index !== -1) {
|
||||
props.item.traceAbilityCodeList.splice(index, 1); // 删除对应项
|
||||
}
|
||||
const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === inputTraceabilityCode.value);
|
||||
if (index != -1) {
|
||||
ElMessage({
|
||||
message: '该追溯码已采集',
|
||||
type: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
item.traceAbilityCodeList.push(inputTraceabilityCode.value)
|
||||
inputTraceabilityCode.value = "";
|
||||
getGatherNumber(item)
|
||||
}
|
||||
const removeTraceAbility = (item: any) => {
|
||||
item.traceAbilityCodeList.splice(item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === inputTraceabilityCode.value), 1)
|
||||
getGatherNumber(item)
|
||||
}
|
||||
const changeNumber=ref(0);
|
||||
const openNumberInput = (subItem: any) => {
|
||||
subItem.showNumberInput = true;
|
||||
changeNumber.value = subItem.number;
|
||||
}
|
||||
const handleNumberChange = (subItem:any)=>{
|
||||
let limit = 1;
|
||||
if (props.item.selectedUnit == props.item.minPackagingUnit){
|
||||
limit = props.item.minPackagingNumber;
|
||||
}
|
||||
if (changeNumber.value>limit) {
|
||||
ElMessage({
|
||||
message: '单个追溯码采集数量超过限制',
|
||||
type: 'warning',
|
||||
})
|
||||
subItem.showNumberInput = false;
|
||||
return
|
||||
}
|
||||
// 可以在这里添加具体的处理逻辑
|
||||
let totalNumber = 0;
|
||||
for (let subItem of props.item.traceAbilityCodeList) {
|
||||
totalNumber += subItem.number;
|
||||
}
|
||||
totalNumber = totalNumber - subItem.number + changeNumber.value;
|
||||
if (totalNumber > props.item.retailNumber) {
|
||||
ElMessage({
|
||||
message: '采集数量超过上限',
|
||||
type: 'warning',
|
||||
})
|
||||
subItem.showNumberInput = false;
|
||||
return;
|
||||
}
|
||||
subItem.number = changeNumber.value;
|
||||
}
|
||||
const addIdCode = (idCode:any)=>{
|
||||
if (idCode==null || idCode.value ==""){
|
||||
return;
|
||||
}
|
||||
if (props.item.idCode.includes(idCode)){
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(
|
||||
`当前标识码未绑定是否确认绑定标识码?`,
|
||||
'Warning',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
post("goods/goods/addIdCode",{goodsId:props.item.id,idCode:idCode}).then((res:any)=>{
|
||||
props.item.idCode.push(idCode);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.list {
|
||||
|
|
|
|||
|
|
@ -108,75 +108,10 @@ const addIdCode = ()=>{
|
|||
addTraceabilityCode(selectedItem)
|
||||
|
||||
}
|
||||
const getGatherNumber=(item:any)=>{
|
||||
let gatherNumber = 0;
|
||||
for (let subItem of item.traceAbilityCodeList){
|
||||
gatherNumber+=subItem.number;
|
||||
}
|
||||
item.gatherNumber = gatherNumber;
|
||||
}
|
||||
const emit = defineEmits(["addIdCode"])
|
||||
|
||||
const emit = defineEmits(["addIdCode","addTraceabilityCode"])
|
||||
const addTraceabilityCode = (item: any) => {
|
||||
if (!item.traceAbilityCodeList) {
|
||||
item.traceAbilityCodeList = []
|
||||
}
|
||||
if (item.retailNumber == item.gatherNumber) {
|
||||
ElMessage({
|
||||
message: '采集数量已满',
|
||||
type: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === traceabilityCode.value);
|
||||
if (index == -1 && item.selectedUnit == item.packagingUnit){
|
||||
item.traceAbilityCodeList.push({
|
||||
code: traceabilityCode.value,
|
||||
number: 1
|
||||
})
|
||||
traceabilityCode.value = "";
|
||||
getGatherNumber(item)
|
||||
emit("addIdCode")
|
||||
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: traceabilityCode.value,
|
||||
number: number
|
||||
})
|
||||
traceabilityCode.value = "";
|
||||
getGatherNumber(item)
|
||||
emit("addIdCode")
|
||||
return;
|
||||
}
|
||||
if(item.selectedUnit == item.packagingUnit){
|
||||
//没拆零 追溯码只能用一次
|
||||
ElMessage({
|
||||
message: '该追溯码已达到最大使用限制',
|
||||
type: 'warning',
|
||||
})
|
||||
return;
|
||||
}else {
|
||||
//拆零每一个追溯码最多使用minPackagingNumber次
|
||||
if (item.traceAbilityCodeList[index].number == item.minPackagingNumber) {
|
||||
ElMessage({
|
||||
message: '该追溯码已达到最大使用限制',
|
||||
type: 'warning',
|
||||
})
|
||||
return;
|
||||
}
|
||||
item.traceAbilityCodeList[index].number += 1;
|
||||
}
|
||||
traceabilityCode.value = "";
|
||||
getGatherNumber(item)
|
||||
emit("addIdCode")
|
||||
emit("addTraceabilityCode",traceabilityCode)
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<CheckoutDetail ref="checkoutDetailRef"></CheckoutDetail>
|
||||
<CheckoutDetail ref="checkoutDetailRef" @confirm ="saveAndCharge"></CheckoutDetail>
|
||||
<Settlement
|
||||
ref="settlementRef"
|
||||
v-model="socialCard"
|
||||
|
|
@ -128,16 +128,15 @@ const checkTraceCode = (goodsList: any[]) => {
|
|||
for (let i = 0; i < goodsList.length; i++) {
|
||||
const item = goodsList[i];
|
||||
if (!item.traceAbilityCodeList || item.shouldNumber != item.traceAbilityCodeList.length) {
|
||||
return false;
|
||||
}else {
|
||||
ElMessage({
|
||||
message: `${item.name}的追溯码采集未完成`,
|
||||
type: 'warning',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
const checkoutDetailRef = ref()
|
||||
const openCheckoutDetail = (goodsList: any[]) => {
|
||||
|
|
@ -293,10 +292,10 @@ const orderCanceled = () => {
|
|||
const getOrderTotalPrice = () => {
|
||||
let totalPrice = 0
|
||||
formData.value.itemDetail?.forEach((item: any) => {
|
||||
totalPrice += item.selectedPrice * item.selectedNum
|
||||
totalPrice += (item.selectedPrice*100 * item.selectedNum*100)/10000
|
||||
})
|
||||
formData.value.goodsDetail.forEach((item: any) => {
|
||||
totalPrice += item.selectedPrice * item.selectedNum
|
||||
totalPrice += (item.selectedPrice*100 * item.selectedNum*100)/10000
|
||||
})
|
||||
formData.value.preTotalPrice = totalPrice
|
||||
formData.value.totalPrice = totalPrice
|
||||
|
|
|
|||
Loading…
Reference in New Issue