|
|
@ -5,7 +5,7 @@ |
|
|
|
border |
|
|
|
row-key="id" |
|
|
|
style="width: 1050px; max-height: 70vh; overflow-y: auto" |
|
|
|
v-if="tableData.length>0" |
|
|
|
v-if="tableData.length > 0" |
|
|
|
> |
|
|
|
<el-table-column type="expand" width="50"> |
|
|
|
<template #default="scope"> |
|
|
@ -23,17 +23,12 @@ |
|
|
|
<el-table-column type="expand" width="50"> |
|
|
|
<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 :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="qty1" align="center"> |
|
|
|
<el-table-column label="数量" width="100" prop="qtyTwo" align="center"> |
|
|
|
<template #default="scope2"> |
|
|
|
<el-input |
|
|
|
v-model="scope2.row.qty1" |
|
|
|
v-model="scope2.row.qtyTwo" |
|
|
|
@blur="blurTwo(scope.row, scope1.row, scope2.row)" |
|
|
|
/> |
|
|
|
</template> |
|
|
@ -43,7 +38,7 @@ |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
link |
|
|
|
@click="addX(scope.row, scope.$index, scope1.row, scope1.$index,1)" |
|
|
|
@click="addX(scope.row, scope.$index, scope1.row, scope1.$index, 1)" |
|
|
|
>添加箱</el-button |
|
|
|
> |
|
|
|
</template> |
|
|
@ -76,7 +71,7 @@ |
|
|
|
<el-input v-model="scope1.row.xNumber" @blur="blurOne(scope.row, scope1.row)" /> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="数量" width="100" prop="qty1" align="center" /> |
|
|
|
<el-table-column label="数量" width="100" prop="qtyOne" align="center" /> |
|
|
|
<el-table-column label="操作" width="100" prop="action" align="center"> |
|
|
|
<template #default="scope1"> |
|
|
|
<el-button |
|
|
@ -95,16 +90,11 @@ |
|
|
|
</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.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="qty1" align="center"> |
|
|
|
<el-table-column label="数量" width="100" prop="qtyOne" align="center"> |
|
|
|
<template #default="scope1"> |
|
|
|
<el-input v-model="scope1.row.qty1" @blur="blurThree(scope.row, scope1.row)" /> |
|
|
|
<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"> |
|
|
@ -114,7 +104,10 @@ |
|
|
|
> |
|
|
|
</template> |
|
|
|
<template #default="scope1"> |
|
|
|
<el-button type="warning" link @click="removeX(scope.row, scope.$index, scope1.row, scope1.$index)" |
|
|
|
<el-button |
|
|
|
type="warning" |
|
|
|
link |
|
|
|
@click="removeX(scope.row, scope.$index, scope1.row, scope1.$index)" |
|
|
|
>移出</el-button |
|
|
|
> |
|
|
|
</template> |
|
|
@ -162,24 +155,21 @@ const openLabel = (tableList) => { |
|
|
|
tableData.value = tableList |
|
|
|
intData() |
|
|
|
} |
|
|
|
const oneId = ref(0) |
|
|
|
const twoId = ref(0) |
|
|
|
const oneId = ref(0)//每托的id |
|
|
|
const twoId = ref(0)//每箱的id |
|
|
|
const intData = () => { |
|
|
|
// 目前托信息等于包装规格1 |
|
|
|
tableData.value.forEach((item) => { |
|
|
|
item.packQty1 = 3 |
|
|
|
|
|
|
|
|
|
|
|
// 判断托信息是否存在 |
|
|
|
console.log(44,item.packUnit); |
|
|
|
console.log(item.packQty); |
|
|
|
|
|
|
|
if (item.packUnit && item.packQty) { |
|
|
|
// 数量除以托数量获取余数 |
|
|
|
item.lastNumber = parseFloat(item.orderQty) % parseFloat(item.packQty) |
|
|
|
// 托数量/箱数量 一托可以放几箱 |
|
|
|
item.otherNumber = parseFloat(item.packQty) / parseFloat(item.secondPackQty) |
|
|
|
// 数量%每箱数量 获取总共几箱 |
|
|
|
item.allPackQty = Math.ceil(parseFloat(item.orderQty) / parseFloat(item.secondPackQty)) |
|
|
|
// 数量除以托数量获取余数 |
|
|
|
item.lastNumber = parseFloat(item.orderQty) % parseFloat(item.packQty) |
|
|
|
// 托数量/箱数量 一托可以放几箱 |
|
|
|
item.otherNumber = parseFloat(item.packQty) / parseFloat(item.secondPackQty) |
|
|
|
// 数量%每箱数量 获取总共几箱 |
|
|
|
item.allPackQty = Math.ceil(parseFloat(item.orderQty) / parseFloat(item.secondPackQty)) |
|
|
|
item.children = [] |
|
|
|
for (let i = 0; i < item.packQty1; i++) { |
|
|
|
oneId.value++ |
|
|
@ -191,7 +181,7 @@ const intData = () => { |
|
|
|
id: oneId.value, |
|
|
|
tPoNumber: i + 1, |
|
|
|
xNumber: Math.ceil(item.lastNumber / parseFloat(item.secondPackQty)), |
|
|
|
qty1: item.lastNumber |
|
|
|
qtyOne: item.lastNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
@ -199,7 +189,7 @@ const intData = () => { |
|
|
|
id: oneId.value, |
|
|
|
tPoNumber: i + 1, |
|
|
|
xNumber: item.otherNumber, |
|
|
|
qty1: item.packQty |
|
|
|
qtyOne: item.packQty |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
@ -208,7 +198,7 @@ const intData = () => { |
|
|
|
id: oneId.value, |
|
|
|
tPoNumber: i + 1, |
|
|
|
xNumber: item.otherNumber, |
|
|
|
qty1: item.packQty |
|
|
|
qtyOne: item.packQty |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -227,14 +217,14 @@ const intData = () => { |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qty1: cur.xLastNumber |
|
|
|
qtyTwo: cur.xLastNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qty1: item.secondPackQty |
|
|
|
qtyTwo: item.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
@ -242,44 +232,44 @@ const intData = () => { |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qty1: item.secondPackQty |
|
|
|
qtyTwo: item.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}else{ |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
item.lastNumber = parseFloat(item.orderQty) % parseFloat(item.secondPackQty) |
|
|
|
item.children=[] |
|
|
|
console.log(item.packQty1) |
|
|
|
for (let i = 0; i < item.packQty1; i++) { |
|
|
|
oneId.value++ |
|
|
|
if (item.lastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (i == item.packQty - 1) { |
|
|
|
item.children.push({ |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber : i + 1, |
|
|
|
qty1: item.lastNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
item.children.push({ |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qty1: item.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 数量除以箱数量获取余数 |
|
|
|
item.lastNumber = parseFloat(item.orderQty) % parseFloat(item.secondPackQty) |
|
|
|
item.children = [] |
|
|
|
console.log(item.packQty1) |
|
|
|
for (let i = 0; i < item.packQty1; i++) { |
|
|
|
oneId.value++ |
|
|
|
if (item.lastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (i == item.packQty - 1) { |
|
|
|
item.children.push({ |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qty1: item.secondPackQty |
|
|
|
}) |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qtyOne: item.lastNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
item.children.push({ |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qtyOne: item.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
item.children.push({ |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: i + 1, |
|
|
|
qtyOne: item.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log(item.children) |
|
|
|
} |
|
|
|
console.log(item.children) |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(tableData.value) |
|
|
@ -302,16 +292,35 @@ const buttonBaseClick = (val) => { |
|
|
|
dialogTableVisible.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 保存 |
|
|
|
const submitForm = () => { |
|
|
|
let arr = tableData.value.map((item) => { |
|
|
|
item.allNumber = 0 |
|
|
|
// 判断托信息是否存在 |
|
|
|
item.children.forEach((cur) => { |
|
|
|
item.allNumber += parseFloat(cur.qtyOne) || 0 |
|
|
|
}) |
|
|
|
|
|
|
|
if (item.allNumber == parseFloat(item.orderQty)) { |
|
|
|
return true |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
}) |
|
|
|
const isBol = arr.some((item) => item == false) |
|
|
|
if (isBol) { |
|
|
|
message.warning('当前添加的数量与总数量不一致') |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
// 添加托 |
|
|
|
const addT = (oneRow) => { |
|
|
|
console.log(oneRow) |
|
|
|
oneId.value++ |
|
|
|
oneRow.children.push({ |
|
|
|
id: oneId.value, |
|
|
|
tPoNumber: oneRow.children[oneRow.children.length - 1].tPoNumber + 1, |
|
|
|
tPoNumber: oneRow.children[oneRow.children.length - 1].tPoNumber + 1, //行号是上一行的行号加1 |
|
|
|
xNumber: '', |
|
|
|
qty1: '' |
|
|
|
qtyOne: '' |
|
|
|
}) |
|
|
|
oneRow.packQty1 = oneRow.children.length |
|
|
|
} |
|
|
@ -320,56 +329,62 @@ const removeT = (oneRow, oneIndex, twoRow, twoIndex) => { |
|
|
|
oneRow.children.splice(twoIndex, 1) |
|
|
|
oneRow.packQty1 = oneRow.children.length |
|
|
|
} |
|
|
|
const addX = (oneRow, oneIndex, twoRow, twoIndex,type) => { |
|
|
|
twoId.value++ |
|
|
|
// 有父集托的时候 |
|
|
|
if(type == 1){ |
|
|
|
console.log(444,twoRow.children) |
|
|
|
// 添加箱 |
|
|
|
const addX = (oneRow, oneIndex, twoRow, twoIndex, type) => { |
|
|
|
twoId.value++ |
|
|
|
// 有父级托的时候 |
|
|
|
if (type == 1) { |
|
|
|
// 在托下添加箱 |
|
|
|
twoRow.children.push({ |
|
|
|
id:twoId.value, |
|
|
|
xPoNumber: twoRow?.children[twoRow.children.length - 1]?.xPoNumber? twoRow?.children[twoRow.children.length - 1]?.xPoNumber:0 + 1, |
|
|
|
qty1: '' |
|
|
|
}) |
|
|
|
twoRow.xNumber = twoRow.children.length |
|
|
|
}else{ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: twoRow?.children[twoRow.children.length - 1]?.xPoNumber |
|
|
|
? twoRow?.children[twoRow.children.length - 1]?.xPoNumber |
|
|
|
: 0 + 1, |
|
|
|
qtyOne: '' |
|
|
|
}) |
|
|
|
twoRow.xNumber = twoRow.children.length |
|
|
|
} else { |
|
|
|
// 直接添加箱 |
|
|
|
oneRow.children.push({ |
|
|
|
id:oneId.value, |
|
|
|
xPoNumber: oneRow.children[oneRow.children.length - 1].xPoNumber + 1, |
|
|
|
qty1: '' |
|
|
|
}) |
|
|
|
oneRow.packQty1 = oneRow.children.length |
|
|
|
id: oneId.value, |
|
|
|
xPoNumber: oneRow.children[oneRow.children.length - 1].xPoNumber + 1, |
|
|
|
qtyOne: '' |
|
|
|
}) |
|
|
|
oneRow.packQty1 = oneRow.children.length |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
const removeX = (oneRow, oneIndex, twoRow, twoIndex, threeRow, threeIndex,type) => { |
|
|
|
// 有父集托的时候 |
|
|
|
if(type == 1){ |
|
|
|
twoRow.children.splice(threeIndex, 1) |
|
|
|
// 移除箱 |
|
|
|
const removeX = (oneRow, oneIndex, twoRow, twoIndex, threeRow, threeIndex, type) => { |
|
|
|
// 有父级托的时候 |
|
|
|
if (type == 1) { |
|
|
|
// 在托下移除箱 |
|
|
|
twoRow.children.splice(threeIndex, 1) |
|
|
|
let num = 0 |
|
|
|
twoRow.children.forEach((item) => { |
|
|
|
num += parseFloat(item.qty1) || 0 |
|
|
|
num += parseFloat(item.qtyTwo) || 0 |
|
|
|
}) |
|
|
|
twoRow.qty1 = num |
|
|
|
twoRow.qtyOne = num |
|
|
|
twoRow.xNumber = twoRow.children.length |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
oneRow.children.splice(twoIndex, 1) |
|
|
|
oneRow.packQty1 = oneRow.children.length |
|
|
|
} |
|
|
|
} |
|
|
|
// 隐藏展开图标 |
|
|
|
// 是否显示展开图标 |
|
|
|
const getRowClass = (row) => { |
|
|
|
if (!row.row.children || row.row.children.length == 0) { |
|
|
|
return 'row-expand-cover' |
|
|
|
} |
|
|
|
} |
|
|
|
// 托失去焦点 |
|
|
|
const blurOne = (oneRow, twoRow) => { |
|
|
|
if (parseFloat(twoRow.xNumber) > parseFloat(oneRow.otherNumber)) { |
|
|
|
message.warning('每托箱个数最多' + oneRow.otherNumber + '箱') |
|
|
|
twoRow.xNumber = oneRow.otherNumber |
|
|
|
twoRow.children = [] |
|
|
|
twoRow.qty1 = parseFloat(twoRow.xNumber) * parseFloat(oneRow.secondPackQty) |
|
|
|
twoRow.qtyOne = parseFloat(twoRow.xNumber) * parseFloat(oneRow.secondPackQty) |
|
|
|
} |
|
|
|
twoRow.qty1 = parseFloat(twoRow.xNumber) * parseFloat(oneRow.secondPackQty) |
|
|
|
twoRow.qtyOne = parseFloat(twoRow.xNumber) * parseFloat(oneRow.secondPackQty) |
|
|
|
let num = 0 |
|
|
|
oneRow.children.forEach((item) => { |
|
|
|
num += parseFloat(item.xNumber) || 0 |
|
|
@ -379,60 +394,64 @@ const blurOne = (oneRow, twoRow) => { |
|
|
|
twoRow.xNumber = '' |
|
|
|
return |
|
|
|
} |
|
|
|
// 托信息修改的時候箱数据自动排列 |
|
|
|
// 判断箱信息是否存在 |
|
|
|
if (oneRow.secondPackUnit && oneRow.secondPackQty) { |
|
|
|
oneRow.children.forEach((cur, key) => { |
|
|
|
cur.children = [] |
|
|
|
// 数量除以托数量获取余数 |
|
|
|
cur.xLastNumber = parseFloat(cur.xNumber) % parseFloat(oneRow.secondPackQty) |
|
|
|
for (let j = 0; j < cur.xNumber; j++) { |
|
|
|
twoId.value++ |
|
|
|
// 如果有余数 |
|
|
|
if (cur.xLastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (j == cur.xNumbery - 1) { |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qty1: cur.xLastNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qty1: oneRow.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qty1: oneRow.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
oneRow.children.forEach((cur, key) => { |
|
|
|
cur.children = [] |
|
|
|
// 数量除以托数量获取余数 |
|
|
|
cur.xLastNumber = parseFloat(cur.xNumber) % parseFloat(oneRow.secondPackQty) |
|
|
|
for (let j = 0; j < cur.xNumber; j++) { |
|
|
|
twoId.value++ |
|
|
|
// 如果有余数 |
|
|
|
if (cur.xLastNumber) { |
|
|
|
// 最后一条信息直接展示余数的信息 |
|
|
|
if (j == cur.xNumbery - 1) { |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qtyTwo: cur.xLastNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 其他数据展示一托的全部箱数和全部数量 |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qtyTwo: oneRow.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
|
|
|
cur.children.push({ |
|
|
|
id: twoId.value, |
|
|
|
xPoNumber: j + 1, |
|
|
|
qtyTwo: oneRow.secondPackQty |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//在托下方的箱数量失去焦点 |
|
|
|
const blurTwo = (oneRow, twoRow, threeRow) => { |
|
|
|
if (parseFloat(threeRow.xNumber) > parseFloat(oneRow.secondPackQty)) { |
|
|
|
message.warning('数量不可以大于箱数量') |
|
|
|
threeRow.qty1 = '' |
|
|
|
console.log(parseFloat(threeRow.qtyTwo)) |
|
|
|
console.log(parseFloat(oneRow.secondPackQty)) |
|
|
|
if (parseFloat(threeRow.qtyTwo) > parseFloat(oneRow.secondPackQty)) { |
|
|
|
message.warning('数量最多为'+oneRow.secondPackQty) |
|
|
|
threeRow.qtyTwo = oneRow.secondPackQty |
|
|
|
return |
|
|
|
} |
|
|
|
let num = 0 |
|
|
|
twoRow.children.forEach((item) => { |
|
|
|
num += parseFloat(item.qty1) || 0 |
|
|
|
num += parseFloat(item.qtyTwo) || 0 |
|
|
|
}) |
|
|
|
twoRow.qty1 = num |
|
|
|
twoRow.qtyOne = num |
|
|
|
} |
|
|
|
const blurThree = (oneRow,twoRow)=>{ |
|
|
|
if(parseFloat(twoRow.qty1)>parseFloat(oneRow.secondPackQty)){ |
|
|
|
message.warning('每箱个数最多' + oneRow.secondPackQty ) |
|
|
|
twoRow.qty1 =oneRow.secondPackQty |
|
|
|
// 箱数量失去焦点 |
|
|
|
const blurThree = (oneRow, twoRow) => { |
|
|
|
if (parseFloat(twoRow.qtyOne) > parseFloat(oneRow.secondPackQty)) { |
|
|
|
message.warning('每箱个数最多' + oneRow.secondPackQty) |
|
|
|
twoRow.qtyOne = oneRow.secondPackQty |
|
|
|
} |
|
|
|
} |
|
|
|
defineExpose({ openLabel }) // 提供 open 方法,用于打开弹窗 |
|
|
|