Browse Source

生成标签bug

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

Loading…
Cancel
Save