Compare commits

...

2 Commits

Author SHA1 Message Date
LiJianZhao 77b913e017 Merge branch 'main' of ssh://git.jizhiweb.cn:2222/clinic-v2/web 2025-05-12 16:57:19 +08:00
LiJianZhao 7df8b4dbbe dev 2025-05-12 16:57:07 +08:00
5 changed files with 42 additions and 241 deletions

View File

@ -82,7 +82,6 @@ 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()
@ -105,78 +104,13 @@ const addIdCode = ()=>{
if(!selectedItem){ if(!selectedItem){
return return
} }
addTraceabilityCode(selectedItem) addTraceabilityCodeDo(selectedItem)
} }
const getGatherNumber=(item:any)=>{
let gatherNumber = 0; const emit = defineEmits(["addIdCode","addTraceabilityCode"])
for (let subItem of item.traceAbilityCodeList){ const addTraceabilityCodeDo = (item: any) => {
gatherNumber+=subItem.number; emit("addTraceabilityCode",item,traceabilityCode.value)
}
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,13 +28,14 @@
<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"/> <TraceabilityCodeAdd :item="item" @addTraceabilityCode="addTraceAbilityCodeHandler"/>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -50,7 +51,10 @@
</div> </div>
</template> </template>
</el-card> </el-card>
<AssociationIdCode ref="associationIdCodeRef" @addIdCode="cleanInputIdCode"></AssociationIdCode> <AssociationIdCode
ref="associationIdCodeRef"
@addIdCode="cleanInputIdCode"
@addTraceabilityCode="addTraceAbilityCodeHandler"></AssociationIdCode>
</Mask> </Mask>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -90,7 +94,6 @@ const saveRetail = () => {
}).then(() => { }).then(() => {
emit('confirm') emit('confirm')
}) })
return return
} }
emit('confirm') emit('confirm')
@ -120,7 +123,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); addTraceabilityCodeDo(item, inputIdCode.value);
return true return true
} }
} }
@ -128,7 +131,7 @@ const addTraceAbilityCode = () => {
} }
const addTraceabilityCodeDo = (item: any) => { const addTraceabilityCodeDo = (item: any, inputStr: any) => {
if (!item.traceAbilityCodeList) { if (!item.traceAbilityCodeList) {
item.traceAbilityCodeList = [] item.traceAbilityCodeList = []
} }
@ -141,7 +144,7 @@ const addTraceabilityCodeDo = (item: any) => {
}) })
return 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) { if (index != -1) {
ElMessage({ ElMessage({
message: '该追溯码已采集', message: '该追溯码已采集',
@ -149,18 +152,18 @@ const addTraceabilityCodeDo = (item: any) => {
}) })
return return
} }
item.traceAbilityCodeList.push(inputIdCode.value) item.traceAbilityCodeList.push(inputStr)
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.code }}</div> <div class="code"> {{ subItem }}</div>
<div class="remove" @click="removeTraceAbility(item)"> <div class="remove" @click="removeTraceAbility(subItem)">
<el-icon> <el-icon>
<CloseBold/> <CloseBold/>
</el-icon> </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 inputTraceabilityCode = ref("");
const emit = defineEmits(["addTraceabilityCode"]);
const addTraceabilityCodeDo = (item: any) => { const addTraceabilityCodeDo = (item: any) => {
if (!item.traceAbilityCodeList) { emit("addTraceabilityCode",item,inputTraceabilityCode.value)
item.traceAbilityCodeList = [] inputTraceabilityCode.value = ""
} }
let traceAbilityCodeListList = item.traceAbilityCodeList.length
if (traceAbilityCodeListList == item.shouldNumber) { const removeTraceAbility = (code: any) => {
ElMessage({ const index = props.item.traceAbilityCodeList.findIndex(
message: '采集数量已满', (codeObj: any) => codeObj === code
type: 'warning', );
})
return 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> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.list { .list {

View File

@ -108,75 +108,10 @@ const addIdCode = ()=>{
addTraceabilityCode(selectedItem) addTraceabilityCode(selectedItem)
} }
const getGatherNumber=(item:any)=>{
let gatherNumber = 0; const emit = defineEmits(["addIdCode","addTraceabilityCode"])
for (let subItem of item.traceAbilityCodeList){
gatherNumber+=subItem.number;
}
item.gatherNumber = gatherNumber;
}
const emit = defineEmits(["addIdCode"])
const addTraceabilityCode = (item: any) => { const addTraceabilityCode = (item: any) => {
if (!item.traceAbilityCodeList) { emit("addTraceabilityCode",traceabilityCode)
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"></CheckoutDetail> <CheckoutDetail ref="checkoutDetailRef" @confirm ="saveAndCharge"></CheckoutDetail>
<Settlement <Settlement
ref="settlementRef" ref="settlementRef"
v-model="socialCard" v-model="socialCard"
@ -128,16 +128,15 @@ 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[]) => {
@ -293,10 +292,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 * item.selectedNum totalPrice += (item.selectedPrice*100 * item.selectedNum*100)/10000
}) })
formData.value.goodsDetail.forEach((item: any) => { 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.preTotalPrice = totalPrice
formData.value.totalPrice = totalPrice formData.value.totalPrice = totalPrice