Browse Source

生成标签bug

hella_online_20240829
zhang_li 5 months ago
parent
commit
cd891b1fe8
  1. 222
      src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue

222
src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue

@ -12,7 +12,7 @@
<template #default="scope">
<div
style="margin-left: 400px; margin-top: -8px; margin-bottom: -8px"
v-if="scope.row.secondPackUnit && scope.row.secondPackQty"
v-if="scope.row.packUnit && scope.row.packQty && scope.row.secondPackUnit && scope.row.secondPackQty"
>
<el-table
:data="scope.row.packageList"
@ -25,7 +25,11 @@
<template #default="scope1">
<div style="margin-left: 150px; margin-top: -8px; margin-bottom: -8px">
<el-table :data="scope1.row.children" border style="width: 300px" row-key="id">
<el-table-column label="箱行号" width="100" prop="xPoNumber" align="center" />
<el-table-column label="箱行号" width="100" prop="xPoNumber" align="center">
<template #default="scope2">
{{ scope2.$index + 1 }}
</template>
</el-table-column>
<el-table-column label="数量" width="100" prop="qtyTwo" align="center">
<template #default="scope2">
<el-input
@ -66,10 +70,18 @@
</div>
</template>
</el-table-column>
<el-table-column label="托行号" width="100" prop="tPoNumber" align="center" />
<el-table-column label="托行号" width="100" prop="tPoNumber" align="center">
<template #default="scope">
{{ scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column label="箱个数" width="100" prop="xNumber" align="center">
<template #default="scope1">
<el-input v-model="scope1.row.xNumber" @blur="blurOne(scope.row, scope1.row)" onkeyup="value=value.replace(/\D/g,'')" />
<el-input
v-model="scope1.row.xNumber"
@blur="blurOne(scope.row, scope1.row)"
onkeyup="value=value.replace(/\D/g,'')"
/>
</template>
</el-table-column>
<el-table-column label="数量" width="100" prop="qtyOne" align="center" />
@ -90,10 +102,13 @@
</el-table-column>
</el-table>
</div>
<div style="margin-left: 550px; margin-top: -8px; margin-bottom: -8px" v-else>
<div style="margin-left: 550px; margin-top: -8px; margin-bottom: -8px" v-if="scope.row.packUnit && scope.row.packQty && !scope.row.secondPackUnit">
<div v-for="(item, index) in scope.row.packageList" :key="index">
<el-table :data="item.children" border style="width: 300px" row-key="id">
<el-table-column label="箱行号" width="100" prop="xPoNumber" align="center" />
<el-table-column label="箱行号" width="100" prop="xPoNumber" align="center" > <template #default="scope1">
{{ scope1.$index + 1 }}
</template>
</el-table-column>
<el-table-column label="数量" width="100" prop="qtyOne" align="center">
<template #default="scope1">
<el-input
@ -171,7 +186,7 @@ const tableData = ref([])
const isLoading = ref(false)
const oneId = ref(0) //id
const twoId = ref(0) //id
const openLabel =async (tableList) => {
const openLabel = async (tableList) => {
dialogTableVisible.value = true
tableData.value = tableList
defaultExpandAll.value = false
@ -188,51 +203,47 @@ const showTableData = () => {
} else {
return tableData.value
}
}
const intData =async () => {
const intData = async () => {
tableData.value.forEach((row) => {
if (row.secondPackUnit && row.secondPackQty) {
// %
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.secondPackQty))
} else {
// %
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty))
}
expandChange(row)
expandChange(row)
})
}
const expandChange = (row: any, expandedRows: any[]) => {
//
if (row.secondPackUnit && row.secondPackQty) {
// // /
// row.otherNumber =Math.floor(parseFloat(row.secondPackQty) / parseFloat(row.packQty))
// //
// row.lastNumber = parseFloat(row.qty) % parseFloat(row.secondPackQty)
// // %
// row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.secondPackQty))
//
if (row.secondPackUnit && row.secondPackQty&&row.packUnit && row.packQty) {
//
row.allXiangQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty))
//
row.manXiangQty = Math.floor(parseFloat(row.qty) / parseFloat(row.packQty))
// /
row.otherNumber =Math.floor(parseFloat(row.secondPackQty) / parseFloat(row.packQty))
// %
row.otherNumber = Math.floor(parseFloat(row.secondPackQty) / parseFloat(row.packQty))
// %
row.allTuoQty = Math.ceil(parseFloat(row.allXiangQty) / parseFloat(row.otherNumber))
//
row.lastNumber = parseFloat(row.allXiangQty) % parseFloat(row.otherNumber)
row.packageList = []
//
row.manTuoQty = Math.floor(parseFloat(row.manXiangQty) / parseFloat(row.otherNumber))
// **
row.tuoInManNumber =
parseFloat(row.manTuoQty) * parseFloat(row.otherNumber) * parseFloat(row.packQty)
//
row.lastNumber =
parseFloat(row.qty) > parseFloat(row.tuoInManNumber)
? parseFloat(row.qty) - parseFloat(row.tuoInManNumber)
: parseFloat(row.qty)
//
row.packageList =[]
for (let i = 0; i < row.allTuoQty; i++) {
oneId.value++
//
row.packageList[i] = {
id: oneId.value,
tPoNumber: i + 1,
// tPoNumber: i + 1,
xNumber: '',
qtyOne: '',
isTuo: 1 //
}
//
if (row.lastNumber) {
//
@ -242,7 +253,7 @@ const expandChange = (row: any, expandedRows: any[]) => {
} else {
//
row.packageList[i].xNumber = row.otherNumber
row.packageList[i].qtyOne = parseFloat(row.otherNumber) * parseFloat(row.packQty)
row.packageList[i].qtyOne = parseFloat(row.otherNumber) * parseFloat(row.packQty)
}
} else {
// ,
@ -261,7 +272,7 @@ const expandChange = (row: any, expandedRows: any[]) => {
twoId.value++
cur.children[j] = {
id: twoId.value,
xPoNumber: j + 1
// xPoNumber: j + 1
}
//
if (cur.xLastNumber) {
@ -279,18 +290,21 @@ const expandChange = (row: any, expandedRows: any[]) => {
}
})
}
} else {
}
//
if(!row.secondPackUnit && row.packUnit && row.packQty){
// %
row.allXiangQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty))
row.packageList = []
row.allTuoQty = 1
row.allTuoQty = ''
row.allTuoQty1 = 1
//
for (let i = 0; i < row.allTuoQty; i++) {
for (let i = 0; i < row.allTuoQty1; i++) {
oneId.value++
//
row.packageList[i] = {
id: oneId.value,
xPoNumber: i + 1,
// xPoNumber: i + 1,
qtyOne: row.qty,
isTuo: 0 //
}
@ -301,7 +315,7 @@ const expandChange = (row: any, expandedRows: any[]) => {
twoId.value++
cur.children[j] = {
id: twoId.value,
xPoNumber: j + 1
// xPoNumber: j + 1
}
//
cur.lastNumber = parseFloat(row.qty) % parseFloat(row.packQty)
@ -343,33 +357,59 @@ const buttonBaseClick = (val) => {
}
//
const submitForm = () => {
let arr = tableData.value.map((item) => {
item.allNumber = 0
//
item.packageList.forEach((cur) => {
item.allNumber += parseFloat(cur.qtyOne) || 0
let isZ = false
console.log(tableData.value)
setTimeout(() => {
tableData.value.forEach((item) => {
item.packageList.forEach((cur, key) => {
cur.tPoNumber = key + 1
if (cur.qtyOne == '' || cur.qtyOne == 0) {
isZ = true
}
cur?.children?.forEach((ele,i) => {
ele.xPoNumber = i+1
if (ele.qtyTwo == '' || ele.qtyTwo == 0) {
isZ = true
}
})
})
})
if (item.allNumber == parseFloat(item.qty)) {
return true
} else {
return false
if (isZ) {
message.warning('有数量为0或空,请重新填写')
return
}
})
const isBol = arr.some((item) => item == false)
if (isBol) {
message.warning('当前添加的数量与总数量不一致')
return
}
emit('submitForm', tableData.value)
let obj = tableData.value.find((item) => {
item.allNumber = 0
item.packageList.forEach((cur) => {
item.allNumber += parseFloat(cur.qtyOne) || 0
})
return item.allNumber != parseFloat(item.qty)
})
console.log(222, obj)
// return
// const isBol = arr.some((item) => item == false)
if (obj) {
message.warning(
`物料[${obj.itemCode}],批次[${obj.batch}],${obj.packageList.length}的总和数量${obj.allNumber}不等于发货总数量${obj.qty}`
)
return
}
emit('submitForm', tableData.value)
}, 300)
}
//
const addT = (oneRow) => {
oneId.value++
oneRow.packageList.push({
id: oneId.value,
tPoNumber: oneRow?.packageList?.length>0?oneRow.packageList[oneRow.packageList.length - 1]?.tPoNumber + 1 :1, //1
// tPoNumber:oneRow.packageList.length+1 || 1,
// tPoNumber:
// oneRow?.packageList?.length > 0
// ? oneRow.packageList[oneRow.packageList.length - 1]?.tPoNumber + 1
// : 1, //1
xNumber: '',
qtyOne: ''
qtyOne: '',
isTuo: 1 //
})
oneRow.allTuoQty = oneRow.packageList.length
}
@ -386,16 +426,26 @@ const addX = (oneRow, oneIndex, twoRow, twoIndex, type) => {
//
twoRow.children.push({
id: twoId.value,
xPoNumber: twoRow?.children?.length>0? twoRow?.children[twoRow.children.length - 1]?.xPoNumber + 1 :1,
qtyOne: ''
// xPoNumber:
// twoRow?.children?.length > 0
// ? twoRow?.children[twoRow.children.length - 1]?.xPoNumber + 1
// : 1,
qtyTwo: oneRow.packQty
})
twoRow.xNumber = twoRow.children.length
let num = 0
twoRow.children.forEach((item) => {
num += parseFloat(item.qtyTwo) || 0
})
twoRow.qtyOne = num
} else {
//
oneRow.isTuo= 1 //
twoRow.children.push({
id: twoId.value,
xPoNumber:twoRow.children.length>0? twoRow.children[twoRow.children.length - 1].xPoNumber + 1:1,
qtyTwo: ''
// xPoNumber:
// twoRow.children.length > 0 ? twoRow.children[twoRow.children.length - 1].xPoNumber + 1 : 1,
// qtyTwo: oneRow.packQty
})
oneRow.allTuoQty = twoRow.children.length
}
@ -449,37 +499,37 @@ const blurOne = (oneRow, twoRow) => {
//
if (oneRow.packUnit && oneRow.packQty) {
// oneRow.packageList.forEach((cur, key) => {
twoRow.children = []
//
twoRow.xLastNumber = parseFloat(twoRow.xNumber) % parseFloat(oneRow.packQty)
for (let j = 0; j < twoRow.xNumber; j++) {
twoId.value++
//
if (twoRow.xLastNumber) {
//
if (j == twoRow.xNumbery - 1) {
twoRow.children.push({
id: twoId.value,
xPoNumber: j + 1,
qtyTwo: twoRow.xLastNumber
})
} else {
//
twoRow.children.push({
id: twoId.value,
xPoNumber: j + 1,
qtyTwo: oneRow.packQty
})
}
twoRow.children = []
//
twoRow.xLastNumber = parseFloat(twoRow.xNumber) % parseFloat(oneRow.packQty)
for (let j = 0; j < twoRow.xNumber; j++) {
twoId.value++
//
if (twoRow.xLastNumber) {
//
if (j == twoRow.xNumbery - 1) {
twoRow.children.push({
id: twoId.value,
// xPoNumber: j + 1,
qtyTwo: twoRow.xLastNumber
})
} else {
// ,
//
twoRow.children.push({
id: twoId.value,
xPoNumber: j + 1,
// xPoNumber: j + 1,
qtyTwo: oneRow.packQty
})
}
} else {
// ,
twoRow.children.push({
id: twoId.value,
// xPoNumber: j + 1,
qtyTwo: oneRow.packQty
})
}
}
// })
}
}

Loading…
Cancel
Save