|
|
@ -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) |
|
|
|
}) |
|
|
|
} |
|
|
|
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.manTuoQty = Math.floor(parseFloat(row.manXiangQty) / parseFloat(row.otherNumber)) |
|
|
|
// 放满的托数量*一托的箱数量*一箱的数量 获取放满的托一共多少数量 |
|
|
|
row.tuoInManNumber = |
|
|
|
parseFloat(row.manTuoQty) * parseFloat(row.otherNumber) * parseFloat(row.packQty) |
|
|
|
// 数量除以托数量获取余数 |
|
|
|
row.lastNumber = parseFloat(row.allXiangQty) % parseFloat(row.otherNumber) |
|
|
|
|
|
|
|
row.packageList = [] |
|
|
|
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) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
@ -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) => { |
|
|
|
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 (isZ) { |
|
|
|
message.warning('有数量为0或空,请重新填写') |
|
|
|
return |
|
|
|
} |
|
|
|
let obj = tableData.value.find((item) => { |
|
|
|
item.allNumber = 0 |
|
|
|
// 判断托信息是否存在 |
|
|
|
item.packageList.forEach((cur) => { |
|
|
|
item.allNumber += parseFloat(cur.qtyOne) || 0 |
|
|
|
}) |
|
|
|
if (item.allNumber == parseFloat(item.qty)) { |
|
|
|
return true |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
return item.allNumber != parseFloat(item.qty) |
|
|
|
}) |
|
|
|
const isBol = arr.some((item) => item == false) |
|
|
|
if (isBol) { |
|
|
|
message.warning('当前添加的数量与总数量不一致') |
|
|
|
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 |
|
|
|
} |
|
|
@ -460,14 +510,14 @@ const blurOne = (oneRow, twoRow) => { |
|
|
|
if (j == twoRow.xNumbery - 1) { |
|
|
|
twoRow.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
// xPoNumber: j + 1, |
|
|
|
qtyTwo: twoRow.xLastNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
twoRow.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
// xPoNumber: j + 1, |
|
|
|
qtyTwo: oneRow.packQty |
|
|
|
}) |
|
|
|
} |
|
|
@ -475,7 +525,7 @@ const blurOne = (oneRow, twoRow) => { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
twoRow.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
// xPoNumber: j + 1, |
|
|
|
qtyTwo: oneRow.packQty |
|
|
|
}) |
|
|
|
} |
|
|
|