|
|
@ -15,7 +15,7 @@ |
|
|
|
v-if="scope.row.secondPackUnit && scope.row.secondPackQty" |
|
|
|
> |
|
|
|
<el-table |
|
|
|
:data="scope.row.children" |
|
|
|
:data="scope.row.packageList" |
|
|
|
border |
|
|
|
style="width: 550px" |
|
|
|
row-key="id" |
|
|
@ -91,7 +91,7 @@ |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
<div style="margin-left: 550px; margin-top: -8px; margin-bottom: -8px" v-else> |
|
|
|
<el-table :data="scope.row.children" border style="width: 300px" row-key="id"> |
|
|
|
<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"> |
|
|
@ -152,24 +152,28 @@ const defaultExpandAll = ref(false) |
|
|
|
|
|
|
|
const tableData = ref([]) |
|
|
|
const openLabel = (tableList) => { |
|
|
|
console.log(tableList) |
|
|
|
dialogTableVisible.value = true |
|
|
|
tableData.value = tableList |
|
|
|
defaultExpandAll.value = false |
|
|
|
// intData() |
|
|
|
intData1() |
|
|
|
intData() |
|
|
|
} |
|
|
|
const oneId = ref(0) //每托的id |
|
|
|
const twoId = ref(0) //每箱的id |
|
|
|
const intData1 = () => { |
|
|
|
const intData = () => { |
|
|
|
tableData.value.forEach((row) => { |
|
|
|
// 数量%托数量 获取总共几托 |
|
|
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.secondPackQty)) |
|
|
|
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)) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
const expandChange = (row: any, expandedRows: any[]) => { |
|
|
|
console.log(row) |
|
|
|
console.log(expandedRows) |
|
|
|
// 判断托信息是否存在 |
|
|
|
if (row.secondPackUnit && row.secondPackQty) { |
|
|
|
// 数量除以托数量获取余数 |
|
|
@ -178,38 +182,38 @@ const expandChange = (row: any, expandedRows: any[]) => { |
|
|
|
row.otherNumber = parseFloat(row.secondPackQty) / parseFloat(row.packQty) |
|
|
|
// 数量%托数量 获取总共几托 |
|
|
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.secondPackQty)) |
|
|
|
row.children = [] |
|
|
|
row.isTuo = 1//有托 |
|
|
|
row.packageList = [] |
|
|
|
// 循环托 |
|
|
|
for (let i = 0; i < row.allTuoQty; i++) { |
|
|
|
oneId.value++ |
|
|
|
// 先给所有托一个默认对象值 |
|
|
|
row.children[i] = { |
|
|
|
row.packageList[i] = { |
|
|
|
id: oneId.value, |
|
|
|
tPoNumber: i + 1, |
|
|
|
xNumber: '', |
|
|
|
qtyOne: '' |
|
|
|
qtyOne: '', |
|
|
|
isTuo : 1 //有托 |
|
|
|
} |
|
|
|
// 如果有余数 |
|
|
|
if (row.lastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (i == row.allTuoQty - 1) { |
|
|
|
row.children[i].xNumber = Math.ceil(row.lastNumber / parseFloat(row.packQty)) |
|
|
|
row.children[i].qtyOne = row.lastNumber |
|
|
|
row.packageList[i].xNumber = Math.ceil(row.lastNumber / parseFloat(row.packQty)) |
|
|
|
row.packageList[i].qtyOne = row.lastNumber |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
row.children[i].xNumber = row.otherNumber |
|
|
|
row.children[i].qtyOne = row.secondPackQty |
|
|
|
row.packageList[i].xNumber = row.otherNumber |
|
|
|
row.packageList[i].qtyOne = row.secondPackQty |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
row.children[i].xNumber = row.otherNumber |
|
|
|
row.children[i].qtyOne = row.secondPackQty |
|
|
|
row.packageList[i].xNumber = row.otherNumber |
|
|
|
row.packageList[i].qtyOne = row.secondPackQty |
|
|
|
} |
|
|
|
} |
|
|
|
// 判断箱信息是否存在 |
|
|
|
if (row.packUnit && row.packQty) { |
|
|
|
row.children.forEach((cur, key) => { |
|
|
|
row.packageList.forEach((cur, key) => { |
|
|
|
cur.children = [] |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
cur.xLastNumber = parseFloat(cur.qtyOne) % parseFloat(row.packQty) |
|
|
@ -237,17 +241,17 @@ const expandChange = (row: any, expandedRows: any[]) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
row.isTuo = 0 //有托 |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
row.lastNumber = parseFloat(row.qty) % parseFloat(row.packQty) |
|
|
|
// 数量%每箱数量 获取总共几箱 |
|
|
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty)) |
|
|
|
row.isTuo = 0//无托 |
|
|
|
row.children = [] |
|
|
|
row.packageList = [] |
|
|
|
// 循环箱 |
|
|
|
for (let i = 0; i < row.allTuoQty; i++) { |
|
|
|
oneId.value++ |
|
|
|
// 先给所有托一个默认对象值 |
|
|
|
row.children[i] = { |
|
|
|
row.packageList[i] = { |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qtyOne: '' |
|
|
@ -256,135 +260,19 @@ const expandChange = (row: any, expandedRows: any[]) => { |
|
|
|
if (row.lastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (i == row.allTuoQty - 1) { |
|
|
|
row.children[i].qtyOne = row.lastNumber |
|
|
|
row.packageList[i].qtyOne = row.lastNumber |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
row.children[i].qtyOne = row.packQty |
|
|
|
row.packageList[i].qtyOne = row.packQty |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
row.children[i].qtyOne = row.packQty |
|
|
|
row.packageList[i].qtyOne = row.packQty |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const intData = () => { |
|
|
|
// 目前托信息等于包装规格1 |
|
|
|
tableData.value.forEach((item) => { |
|
|
|
item.packQty1 = 11 |
|
|
|
|
|
|
|
// 判断托信息是否存在 |
|
|
|
if (item.packUnit && item.packQty) { |
|
|
|
// 数量除以托数量获取余数 |
|
|
|
item.lastNumber = parseFloat(item.qty) % parseFloat(item.packQty) |
|
|
|
// 托数量/箱数量 一托可以放几箱 |
|
|
|
item.otherNumber = parseFloat(item.packQty) / parseFloat(item.secondPackQty) |
|
|
|
// 数量%每箱数量 获取总共几箱 |
|
|
|
item.allPackQty = Math.ceil(parseFloat(item.qty) / parseFloat(item.secondPackQty)) |
|
|
|
// 数量%托数量 获取总共几托 |
|
|
|
item.allTuoQty = Math.ceil(parseFloat(item.qty) / parseFloat(item.packQty)) |
|
|
|
item.children = [] |
|
|
|
// 循环托 |
|
|
|
for (let i = 0; i < item.packQty1; i++) { |
|
|
|
oneId.value++ |
|
|
|
// 先给所有托一个默认对象值 |
|
|
|
item.children[i] = { |
|
|
|
id: oneId.value, |
|
|
|
tPoNumber: i + 1, |
|
|
|
xNumber: '', |
|
|
|
qtyOne: '', |
|
|
|
children: [] |
|
|
|
} |
|
|
|
// 循环当前数量所需要的托数量 |
|
|
|
// for (let j = 0; j < item.allTuoQty; j++) { |
|
|
|
// if (i == j) { |
|
|
|
// // 如果有余数 |
|
|
|
// if (item.lastNumber) { |
|
|
|
// // 最后一条信息直接展示余数的信息 |
|
|
|
// if (j == item.allTuoQty - 1) { |
|
|
|
// item.children[j].xNumber = Math.ceil(item.lastNumber / parseFloat(item.secondPackQty)) |
|
|
|
// item.children[j].qtyOne = item.lastNumber |
|
|
|
// }else{ |
|
|
|
// // 其他数据展示一托的全部箱数和全部数量 |
|
|
|
// item.children[j].xNumber = item.otherNumber |
|
|
|
// item.children[j].qtyOne = item.packQty |
|
|
|
// } |
|
|
|
// }else{ |
|
|
|
// // 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
// item.children[j].xNumber = item.otherNumber |
|
|
|
// item.children[j].qtyOne = item.packQty |
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
// } |
|
|
|
} |
|
|
|
// 判断箱信息是否存在 |
|
|
|
if (item.secondPackUnit && item.secondPackQty) { |
|
|
|
item.children.forEach((cur, key) => { |
|
|
|
cur.children = [] |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
cur.xLastNumber = parseFloat(cur.qtyOne) % parseFloat(item.secondPackQty) |
|
|
|
// cur.xiangNumber = Math.ceil(parseFloat(cur.qtyOne) / parseFloat(item.secondPackQty)) |
|
|
|
for (let i = 0; i < cur.xNumber; i++) { |
|
|
|
twoId.value++ |
|
|
|
cur.children[i] = { |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: i + 1 |
|
|
|
} |
|
|
|
// 如果有余数 |
|
|
|
if (cur.xLastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (i == cur.xNumber - 1) { |
|
|
|
cur.children[i].qtyTwo = cur.xLastNumber |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
cur.children[i].qtyTwo = item.secondPackQty |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
cur.children[i].qtyTwo = item.secondPackQty |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
item.lastNumber = parseFloat(item.qty) % parseFloat(item.secondPackQty) |
|
|
|
// 数量%每箱数量 获取总共几箱 |
|
|
|
item.allPackQty = Math.ceil(parseFloat(item.qty) / parseFloat(item.secondPackQty)) |
|
|
|
item.children = [] |
|
|
|
console.log(333, item.lastNumber) |
|
|
|
// 循环箱 |
|
|
|
for (let i = 0; i < item.packQty1; i++) { |
|
|
|
oneId.value++ |
|
|
|
// 先给所有托一个默认对象值 |
|
|
|
item.children[i] = { |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qtyOne: '' |
|
|
|
} |
|
|
|
// 循环当前数量所需要的箱数量 |
|
|
|
for (let j = 0; j < item.allPackQty; j++) { |
|
|
|
if (i == j) { |
|
|
|
// 如果有余数 |
|
|
|
if (item.lastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (j == item.allPackQty - 1) { |
|
|
|
item.children[j].qtyOne = item.lastNumber |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
item.children[j].qtyOne = item.secondPackQty |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
item.children[j].qtyOne = item.secondPackQty |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
/** 弹窗按钮 */ |
|
|
|
let Butttondata: any = [] |
|
|
|
Butttondata = [ |
|
|
@ -408,37 +296,41 @@ const submitForm = () => { |
|
|
|
let arr = tableData.value.map((item) => { |
|
|
|
item.allNumber = 0 |
|
|
|
// 判断托信息是否存在 |
|
|
|
item.children.forEach((cur) => { |
|
|
|
console.log(item.packageList) |
|
|
|
item.packageList.forEach((cur) => { |
|
|
|
item.allNumber += parseFloat(cur.qtyOne) || 0 |
|
|
|
}) |
|
|
|
|
|
|
|
if (item.allNumber == parseFloat(item.qty)) { |
|
|
|
return true |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(3434, arr) |
|
|
|
const isBol = arr.some((item) => item == false) |
|
|
|
if (isBol) { |
|
|
|
message.warning('当前添加的数量与总数量不一致') |
|
|
|
return |
|
|
|
} |
|
|
|
console.log(343546568678) |
|
|
|
|
|
|
|
emit('submitForm', tableData.value) |
|
|
|
} |
|
|
|
// 添加托 |
|
|
|
const addT = (oneRow) => { |
|
|
|
oneId.value++ |
|
|
|
oneRow.children.push({ |
|
|
|
oneRow.packageList.push({ |
|
|
|
id: oneId.value, |
|
|
|
tPoNumber: (oneRow.children[oneRow.children.length - 1]?.tPoNumber || 0) + 1, //行号是上一行的行号加1 |
|
|
|
tPoNumber: (oneRow.packageList[oneRow.packageList.length - 1]?.tPoNumber || 0) + 1, //行号是上一行的行号加1 |
|
|
|
xNumber: '', |
|
|
|
qtyOne: '' |
|
|
|
}) |
|
|
|
oneRow.allTuoQty = oneRow.children.length |
|
|
|
oneRow.allTuoQty = oneRow.packageList.length |
|
|
|
} |
|
|
|
// 移出托 |
|
|
|
const removeT = (oneRow, oneIndex, twoRow, twoIndex) => { |
|
|
|
oneRow.children.splice(twoIndex, 1) |
|
|
|
oneRow.allTuoQty = oneRow.children.length |
|
|
|
oneRow.packageList.splice(twoIndex, 1) |
|
|
|
oneRow.allTuoQty = oneRow.packageList.length |
|
|
|
} |
|
|
|
// 添加箱 |
|
|
|
const addX = (oneRow, oneIndex, twoRow, twoIndex, type) => { |
|
|
@ -456,12 +348,12 @@ const addX = (oneRow, oneIndex, twoRow, twoIndex, type) => { |
|
|
|
twoRow.xNumber = twoRow.children.length |
|
|
|
} else { |
|
|
|
// 直接添加箱 |
|
|
|
oneRow.children.push({ |
|
|
|
oneRow.packageList.push({ |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: oneRow.children[oneRow.children.length - 1].xPoNumber + 1, |
|
|
|
xPoNumber: oneRow.packageList[oneRow.packageList.length - 1].xPoNumber + 1, |
|
|
|
qtyOne: '' |
|
|
|
}) |
|
|
|
oneRow.allTuoQty = oneRow.children.length |
|
|
|
oneRow.allTuoQty = oneRow.packageList.length |
|
|
|
} |
|
|
|
} |
|
|
|
// 移除箱 |
|
|
@ -477,8 +369,8 @@ const removeX = (oneRow, oneIndex, twoRow, twoIndex, threeRow, threeIndex, type) |
|
|
|
twoRow.qtyOne = num |
|
|
|
twoRow.xNumber = twoRow.children.length |
|
|
|
} else { |
|
|
|
oneRow.children.splice(twoIndex, 1) |
|
|
|
oneRow.allTuoQty = oneRow.children.length |
|
|
|
oneRow.packageList.splice(twoIndex, 1) |
|
|
|
oneRow.allTuoQty = oneRow.packageList.length |
|
|
|
} |
|
|
|
} |
|
|
|
// 是否显示展开图标 |
|
|
@ -500,7 +392,7 @@ const blurOne = (oneRow, twoRow) => { |
|
|
|
} |
|
|
|
twoRow.qtyOne = parseFloat(twoRow.xNumber) * parseFloat(oneRow.packQty) |
|
|
|
let num = 0 |
|
|
|
oneRow.children.forEach((item) => { |
|
|
|
oneRow.packageList.forEach((item) => { |
|
|
|
num += parseFloat(item.xNumber) || 0 |
|
|
|
}) |
|
|
|
if (num > oneRow.allPackQty) { |
|
|
@ -512,7 +404,7 @@ const blurOne = (oneRow, twoRow) => { |
|
|
|
// 托信息修改的時候箱数据自动排列 |
|
|
|
// 判断箱信息是否存在 |
|
|
|
if (oneRow.packUnit && oneRow.packQty) { |
|
|
|
oneRow.children.forEach((cur, key) => { |
|
|
|
oneRow.packageList.forEach((cur, key) => { |
|
|
|
cur.children = [] |
|
|
|
// 数量除以托数量获取余数 |
|
|
|
cur.xLastNumber = parseFloat(cur.xNumber) % parseFloat(oneRow.packQty) |
|
|
@ -569,6 +461,8 @@ const blurThree = (oneRow, twoRow) => { |
|
|
|
twoRow.qtyOne = oneRow.packQty |
|
|
|
} |
|
|
|
} |
|
|
|
// 传递给父类 |
|
|
|
const emit = defineEmits(['submitForm']) |
|
|
|
defineExpose({ openLabel }) // 提供 open 方法,用于打开弹窗 |
|
|
|
</script> |
|
|
|
<style lang="scss" scoped> |
|
|
|