|
|
@ -6,7 +6,7 @@ |
|
|
|
row-key="id" |
|
|
|
style="width: 1050px; max-height: 70vh; overflow-y: auto" |
|
|
|
v-if="tableData.length > 0 && dialogTableVisible == true" |
|
|
|
v-loading='isLoading' |
|
|
|
v-loading="isLoading" |
|
|
|
> |
|
|
|
<el-table-column type="expand" width="50"> |
|
|
|
<template #default="scope"> |
|
|
@ -91,29 +91,37 @@ |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
<div style="margin-left: 550px; margin-top: -8px; margin-bottom: -8px" v-else> |
|
|
|
<el-table :data="scope.row.packageList" border style="width: 300px" row-key="id"> |
|
|
|
<el-table-column label="箱行号" width="100" prop="xPoNumber" align="center" /> |
|
|
|
<el-table-column label="数量" width="100" prop="qtyOne" align="center"> |
|
|
|
<template #default="scope1"> |
|
|
|
<el-input v-model="scope1.row.qtyOne" @blur="blurThree(scope.row, scope1.row)" /> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="添加箱" width="100" prop="add" align="center"> |
|
|
|
<template #header> |
|
|
|
<el-button type="primary" link @click="addX(scope.row, scope.$index)" |
|
|
|
>添加箱</el-button |
|
|
|
> |
|
|
|
</template> |
|
|
|
<template #default="scope1"> |
|
|
|
<el-button |
|
|
|
type="warning" |
|
|
|
link |
|
|
|
@click="removeX(scope.row, scope.$index, scope1.row, scope1.$index)" |
|
|
|
>移出</el-button |
|
|
|
> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<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="qtyOne" align="center"> |
|
|
|
<template #default="scope1"> |
|
|
|
<el-input |
|
|
|
v-model="scope1.row.qtyTwo" |
|
|
|
@blur="blurThree(scope.row, item, scope1.row)" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="添加箱" width="100" prop="add" align="center"> |
|
|
|
<template #header> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
link |
|
|
|
@click="addX(scope.row, scope.$index, item, index)" |
|
|
|
>添加箱</el-button |
|
|
|
> |
|
|
|
</template> |
|
|
|
<template #default="scope1"> |
|
|
|
<el-button |
|
|
|
type="warning" |
|
|
|
link |
|
|
|
@click="removeX(scope.row, scope.$index, item, index)" |
|
|
|
>移出</el-button |
|
|
|
> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
@ -164,14 +172,11 @@ const twoId = ref(0) //每箱的id |
|
|
|
const intData = () => { |
|
|
|
tableData.value.forEach((row) => { |
|
|
|
if (row.secondPackUnit && row.secondPackQty) { |
|
|
|
row.isTuo = 1 //有托 |
|
|
|
// 数量%托数量 获取总共几托 |
|
|
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.secondPackQty)) |
|
|
|
} else { |
|
|
|
row.isTuo = 0 //有托 |
|
|
|
// 数量%每箱数量 获取总共几箱 |
|
|
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty)) |
|
|
|
|
|
|
|
} |
|
|
|
expandChange(row) |
|
|
|
}) |
|
|
@ -195,7 +200,7 @@ const expandChange = (row: any, expandedRows: any[]) => { |
|
|
|
tPoNumber: i + 1, |
|
|
|
xNumber: '', |
|
|
|
qtyOne: '', |
|
|
|
isTuo : 1 //有托 |
|
|
|
isTuo: 1 //有托 |
|
|
|
} |
|
|
|
// 如果有余数 |
|
|
|
if (row.lastNumber) { |
|
|
@ -221,35 +226,33 @@ const expandChange = (row: any, expandedRows: any[]) => { |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
cur.xLastNumber = parseFloat(cur.qtyOne) % parseFloat(row.packQty) |
|
|
|
// cur.xiangNumber = Math.ceil(parseFloat(cur.qtyOne) / parseFloat(item.secondPackQty)) |
|
|
|
for (let i = 0; i < cur.xNumber; i++) { |
|
|
|
for (let j = 0; j < cur.xNumber; j++) { |
|
|
|
twoId.value++ |
|
|
|
cur.children[i] = { |
|
|
|
cur.children[j] = { |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: i + 1 |
|
|
|
xPoNumber: j + 1 |
|
|
|
} |
|
|
|
// 如果有余数 |
|
|
|
if (cur.xLastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (i == cur.xNumber - 1) { |
|
|
|
cur.children[i].qtyTwo = cur.xLastNumber |
|
|
|
if (j == cur.xNumber - 1) { |
|
|
|
cur.children[j].qtyTwo = cur.xLastNumber |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
cur.children[i].qtyTwo = row.packQty |
|
|
|
cur.children[j].qtyTwo = row.packQty |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
cur.children[i].qtyTwo = row.packQty |
|
|
|
cur.children[j].qtyTwo = row.packQty |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
row.isTuo = 0 //有托 |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
row.lastNumber = parseFloat(row.qty) % parseFloat(row.packQty) |
|
|
|
// 数量%每箱数量 获取总共几箱 |
|
|
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty)) |
|
|
|
row.allXiangQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty)) |
|
|
|
row.packageList = [] |
|
|
|
row.allTuoQty = 1 |
|
|
|
// 循环箱 |
|
|
|
for (let i = 0; i < row.allTuoQty; i++) { |
|
|
|
oneId.value++ |
|
|
@ -257,22 +260,35 @@ const expandChange = (row: any, expandedRows: any[]) => { |
|
|
|
row.packageList[i] = { |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qtyOne: '' |
|
|
|
qtyOne: row.qty, |
|
|
|
isTuo: 0 //无托 |
|
|
|
} |
|
|
|
// 如果有余数 |
|
|
|
if (row.lastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (i == row.allTuoQty - 1) { |
|
|
|
row.packageList[i].qtyOne = row.lastNumber |
|
|
|
} |
|
|
|
row.packageList.forEach((cur) => { |
|
|
|
cur.children = [] |
|
|
|
for (let j = 0; j < row.allXiangQty; j++) { |
|
|
|
twoId.value++ |
|
|
|
cur.children[j] = { |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1 |
|
|
|
} |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
cur.lastNumber = parseFloat(row.qty) % parseFloat(row.packQty) |
|
|
|
// 如果有余数 |
|
|
|
if (cur.lastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (j == row.allXiangQty - 1) { |
|
|
|
cur.children[j].qtyTwo = cur.lastNumber |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
cur.children[j].qtyTwo = row.packQty |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
row.packageList[i].qtyOne = row.packQty |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
cur.children[j].qtyTwo = row.packQty |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
row.packageList[i].qtyOne = row.packQty |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -347,12 +363,12 @@ const addX = (oneRow, oneIndex, twoRow, twoIndex, type) => { |
|
|
|
twoRow.xNumber = twoRow.children.length |
|
|
|
} else { |
|
|
|
// 直接添加箱 |
|
|
|
oneRow.packageList.push({ |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: oneRow.packageList[oneRow.packageList.length - 1].xPoNumber + 1, |
|
|
|
qtyOne: '' |
|
|
|
twoRow.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: twoRow.children[twoRow.children.length - 1].xPoNumber + 1, |
|
|
|
qtyTwo: '' |
|
|
|
}) |
|
|
|
oneRow.allTuoQty = oneRow.packageList.length |
|
|
|
oneRow.allTuoQty = twoRow.children.length |
|
|
|
} |
|
|
|
} |
|
|
|
// 移除箱 |
|
|
@ -368,8 +384,8 @@ const removeX = (oneRow, oneIndex, twoRow, twoIndex, threeRow, threeIndex, type) |
|
|
|
twoRow.qtyOne = num |
|
|
|
twoRow.xNumber = twoRow.children.length |
|
|
|
} else { |
|
|
|
oneRow.packageList.splice(twoIndex, 1) |
|
|
|
oneRow.allTuoQty = oneRow.packageList.length |
|
|
|
twoRow.children.splice(twoIndex, 1) |
|
|
|
oneRow.allTuoQty = twoRow.children.length |
|
|
|
} |
|
|
|
} |
|
|
|
// 是否显示展开图标 |
|
|
@ -452,15 +468,20 @@ const blurTwo = (oneRow, twoRow, threeRow) => { |
|
|
|
twoRow.qtyOne = num |
|
|
|
} |
|
|
|
// 箱数量失去焦点 |
|
|
|
const blurThree = (oneRow, twoRow) => { |
|
|
|
if (parseFloat(twoRow.qtyOne) > parseFloat(oneRow.packQty)) { |
|
|
|
const blurThree = (oneRow, twoRow, thereeRow) => { |
|
|
|
if (parseFloat(thereeRow.qtyTwo) > parseFloat(oneRow.packQty)) { |
|
|
|
message.warning('每箱个数最多' + oneRow.packQty) |
|
|
|
twoRow.qtyOne = oneRow.packQty |
|
|
|
thereeRow.qtyTwo = oneRow.packQty |
|
|
|
} |
|
|
|
let num = 0 |
|
|
|
twoRow.children.forEach((item) => { |
|
|
|
num += parseFloat(item.qtyTwo) || 0 |
|
|
|
}) |
|
|
|
twoRow.qtyOne = num |
|
|
|
} |
|
|
|
// 传递给父类 |
|
|
|
const emit = defineEmits(['submitForm']) |
|
|
|
defineExpose({ openLabel,dialogTableVisible,isLoading }) // 提供 open 方法,用于打开弹窗 |
|
|
|
defineExpose({ openLabel, dialogTableVisible, isLoading }) // 提供 open 方法,用于打开弹窗 |
|
|
|
</script> |
|
|
|
<style lang="scss" scoped> |
|
|
|
::v-deep .row-expand-cover td .el-table__expand-icon { |
|
|
|