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