|
@ -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) { |
|
|
|
|
|
// 数量%托数量 获取总共几托 |
|
|
|
|
|
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[]) => { |
|
|
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.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.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.lastNumber = |
|
|
|
|
|
parseFloat(row.qty) > parseFloat(row.tuoInManNumber) |
|
|
row.packageList = [] |
|
|
? 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) { |
|
|
// 最后一条信息直接展示余数的信息 |
|
|
// 最后一条信息直接展示余数的信息 |
|
@ -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 |
|
|
|
|
|
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.allNumber = 0 |
|
|
// 判断托信息是否存在 |
|
|
|
|
|
item.packageList.forEach((cur) => { |
|
|
item.packageList.forEach((cur) => { |
|
|
item.allNumber += parseFloat(cur.qtyOne) || 0 |
|
|
item.allNumber += parseFloat(cur.qtyOne) || 0 |
|
|
}) |
|
|
}) |
|
|
if (item.allNumber == parseFloat(item.qty)) { |
|
|
return item.allNumber != parseFloat(item.qty) |
|
|
return true |
|
|
|
|
|
} else { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
const isBol = arr.some((item) => item == false) |
|
|
console.log(222, obj) |
|
|
if (isBol) { |
|
|
// return |
|
|
message.warning('当前添加的数量与总数量不一致') |
|
|
// const isBol = arr.some((item) => item == false) |
|
|
|
|
|
if (obj) { |
|
|
|
|
|
message.warning( |
|
|
|
|
|
`物料[${obj.itemCode}],批次[${obj.batch}],${obj.packageList.length}的总和数量${obj.allNumber}不等于发货总数量${obj.qty}` |
|
|
|
|
|
) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
emit('submitForm', tableData.value) |
|
|
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 |
|
|
} |
|
|
} |
|
@ -460,14 +510,14 @@ const blurOne = (oneRow, twoRow) => { |
|
|
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 { |
|
|
} 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 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
@ -475,7 +525,7 @@ const blurOne = (oneRow, twoRow) => { |
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
twoRow.children.push({ |
|
|
twoRow.children.push({ |
|
|
id: twoId.value, |
|
|
id: twoId.value, |
|
|
xPoNumber: j + 1, |
|
|
// xPoNumber: j + 1, |
|
|
qtyTwo: oneRow.packQty |
|
|
qtyTwo: oneRow.packQty |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|