Compare commits

..

No commits in common. "77b913e0177cd39e405c63b723757c12cfceae56" and "4638683b012bea8cc5fca15c96101398f76deb38" have entirely different histories.

5 changed files with 242 additions and 43 deletions

View File

@ -82,6 +82,7 @@ const tableData = ref<TableItem[]>([]);
const init = (newIdCode: any, newTableDate: any) => { const init = (newIdCode: any, newTableDate: any) => {
traceabilityCode.value = newIdCode; traceabilityCode.value = newIdCode;
tableData.value = newTableDate; tableData.value = newTableDate;
console.log(tableData)
show.value = true; show.value = true;
} }
const selected = ref() const selected = ref()
@ -104,13 +105,78 @@ const addIdCode = ()=>{
if(!selectedItem){ if(!selectedItem){
return return
} }
addTraceabilityCodeDo(selectedItem) addTraceabilityCode(selectedItem)
} }
const getGatherNumber=(item:any)=>{
const emit = defineEmits(["addIdCode","addTraceabilityCode"]) let gatherNumber = 0;
const addTraceabilityCodeDo = (item: any) => { for (let subItem of item.traceAbilityCodeList){
emit("addTraceabilityCode",item,traceabilityCode.value) 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")
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -28,14 +28,13 @@
<tr v-for="(item,index) in list" :key="index"> <tr v-for="(item,index) in list" :key="index">
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<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> <div v-else>未关联</div>
</td> </td>
<td>{{ item.selectedNum }}{{ item.selectedUnit }}</td> <td>{{ item.selectedNum }}{{ item.selectedUnit }}</td>
<td>{{ item.traceAbilityCodeList ? item.traceAbilityCodeList.length : 0 }}/{{ item.shouldNumber }}</td> <td>{{ item.traceAbilityCodeList ? item.traceAbilityCodeList.length : 0 }}/{{ item.shouldNumber }}</td>
<td> <td>
<TraceabilityCodeAdd :item="item" @addTraceabilityCode="addTraceAbilityCodeHandler"/> <TraceabilityCodeAdd :item="item"/>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -51,10 +50,7 @@
</div> </div>
</template> </template>
</el-card> </el-card>
<AssociationIdCode <AssociationIdCode ref="associationIdCodeRef" @addIdCode="cleanInputIdCode"></AssociationIdCode>
ref="associationIdCodeRef"
@addIdCode="cleanInputIdCode"
@addTraceabilityCode="addTraceAbilityCodeHandler"></AssociationIdCode>
</Mask> </Mask>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -94,6 +90,7 @@ const saveRetail = () => {
}).then(() => { }).then(() => {
emit('confirm') emit('confirm')
}) })
return return
} }
emit('confirm') emit('confirm')
@ -123,7 +120,7 @@ const addTraceAbilityCode = () => {
let idCode = inputIdCode.value.slice(0, 7); let idCode = inputIdCode.value.slice(0, 7);
if (!item.idCode) break if (!item.idCode) break
if (item.idCode.includes(idCode)) { if (item.idCode.includes(idCode)) {
addTraceabilityCodeDo(item, inputIdCode.value); addTraceabilityCodeDo(item);
return true return true
} }
} }
@ -131,7 +128,7 @@ const addTraceAbilityCode = () => {
} }
const addTraceabilityCodeDo = (item: any, inputStr: any) => { const addTraceabilityCodeDo = (item: any) => {
if (!item.traceAbilityCodeList) { if (!item.traceAbilityCodeList) {
item.traceAbilityCodeList = [] item.traceAbilityCodeList = []
} }
@ -144,7 +141,7 @@ const addTraceabilityCodeDo = (item: any, inputStr: any) => {
}) })
return return
} }
const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === inputStr); const index = item.traceAbilityCodeList.findIndex((codeObj: any) => codeObj.code === inputIdCode.value);
if (index != -1) { if (index != -1) {
ElMessage({ ElMessage({
message: '该追溯码已采集', message: '该追溯码已采集',
@ -152,18 +149,18 @@ const addTraceabilityCodeDo = (item: any, inputStr: any) => {
}) })
return return
} }
item.traceAbilityCodeList.push(inputStr) item.traceAbilityCodeList.push(inputIdCode.value)
cleanInputIdCode() cleanInputIdCode()
getGatherNumber(item)
}
const getGatherNumber = (item: any) => {
item.shouldNumber = item.traceAbilityCodeList?item.traceAbilityCodeList.length:0;
} }
const cleanInputIdCode = () => { const cleanInputIdCode = () => {
inputIdCode.value = '' inputIdCode.value = ''
} }
const addTraceAbilityCodeHandler = (item: any, code: any) => {
addTraceabilityCodeDo(item, code)
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -16,8 +16,8 @@
</template> </template>
<template #default> <template #default>
<div v-for="(subItem,index) in item.traceAbilityCodeList" class="list"> <div v-for="(subItem,index) in item.traceAbilityCodeList" class="list">
<div class="code"> {{ subItem }}</div> <div class="code"> {{ subItem.code }}</div>
<div class="remove" @click="removeTraceAbility(subItem)"> <div class="remove" @click="removeTraceAbility(item)">
<el-icon> <el-icon>
<CloseBold/> <CloseBold/>
</el-icon> </el-icon>
@ -61,23 +61,93 @@ const props = defineProps({
}), }),
}, },
}) })
const getGatherNumber = (item: any) => {
item.shouldNumber = item.traceAbilityCodeList?item.traceAbilityCodeList.length:0;
}
const inputTraceabilityCode = ref(""); const inputTraceabilityCode = ref("");
const emit = defineEmits(["addTraceabilityCode"]);
const addTraceabilityCodeDo = (item: any) => { const addTraceabilityCodeDo = (item: any) => {
emit("addTraceabilityCode",item,inputTraceabilityCode.value) if (!item.traceAbilityCodeList) {
inputTraceabilityCode.value = "" item.traceAbilityCodeList = []
}
const removeTraceAbility = (code: any) => {
const index = props.item.traceAbilityCodeList.findIndex(
(codeObj: any) => codeObj === code
);
if (index !== -1) {
props.item.traceAbilityCodeList.splice(index, 1); //
} }
} let traceAbilityCodeListList = item.traceAbilityCodeList.length
if (traceAbilityCodeListList == item.shouldNumber) {
ElMessage({
message: '采集数量已满',
type: 'warning',
})
return
}
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> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.list { .list {

View File

@ -108,10 +108,75 @@ const addIdCode = ()=>{
addTraceabilityCode(selectedItem) addTraceabilityCode(selectedItem)
} }
const getGatherNumber=(item:any)=>{
const emit = defineEmits(["addIdCode","addTraceabilityCode"]) let gatherNumber = 0;
for (let subItem of item.traceAbilityCodeList){
gatherNumber+=subItem.number;
}
item.gatherNumber = gatherNumber;
}
const emit = defineEmits(["addIdCode"])
const addTraceabilityCode = (item: any) => { const addTraceabilityCode = (item: any) => {
emit("addTraceabilityCode",traceabilityCode) 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")
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -67,7 +67,7 @@
</div> </div>
</div> </div>
</div> </div>
<CheckoutDetail ref="checkoutDetailRef" @confirm ="saveAndCharge"></CheckoutDetail> <CheckoutDetail ref="checkoutDetailRef"></CheckoutDetail>
<Settlement <Settlement
ref="settlementRef" ref="settlementRef"
v-model="socialCard" v-model="socialCard"
@ -128,15 +128,16 @@ const checkTraceCode = (goodsList: any[]) => {
for (let i = 0; i < goodsList.length; i++) { for (let i = 0; i < goodsList.length; i++) {
const item = goodsList[i]; const item = goodsList[i];
if (!item.traceAbilityCodeList || item.shouldNumber != item.traceAbilityCodeList.length) { if (!item.traceAbilityCodeList || item.shouldNumber != item.traceAbilityCodeList.length) {
return false;
}else {
ElMessage({ ElMessage({
message: `${item.name}的追溯码采集未完成`, message: `${item.name}的追溯码采集未完成`,
type: 'warning', type: 'warning',
}) })
return false;
} }
} }
return true; return true;
} }
const checkoutDetailRef = ref() const checkoutDetailRef = ref()
const openCheckoutDetail = (goodsList: any[]) => { const openCheckoutDetail = (goodsList: any[]) => {
@ -292,10 +293,10 @@ const orderCanceled = () => {
const getOrderTotalPrice = () => { const getOrderTotalPrice = () => {
let totalPrice = 0 let totalPrice = 0
formData.value.itemDetail?.forEach((item: any) => { formData.value.itemDetail?.forEach((item: any) => {
totalPrice += (item.selectedPrice*100 * item.selectedNum*100)/10000 totalPrice += item.selectedPrice * item.selectedNum
}) })
formData.value.goodsDetail.forEach((item: any) => { formData.value.goodsDetail.forEach((item: any) => {
totalPrice += (item.selectedPrice*100 * item.selectedNum*100)/10000 totalPrice += item.selectedPrice * item.selectedNum
}) })
formData.value.preTotalPrice = totalPrice formData.value.preTotalPrice = totalPrice
formData.value.totalPrice = totalPrice formData.value.totalPrice = totalPrice