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