Browse Source

生成标签

master_hella_20240701
zhang_li 4 months ago
parent
commit
984d6a47d9
  1. 1
      src/components/TableForm/src/TableForm.vue
  2. 93
      src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue
  3. 206
      src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue

1
src/components/TableForm/src/TableForm.vue

@ -92,6 +92,7 @@
:disabled="disabledInput(headerItem, row)"
style="flex: 1"
@blur="inputStringBlur(headerItem, row[headerItem.field], row, index)"
@clear='clearInput(headerItem.field, row, index)'
/>
<Icon
icon="ep:circle-close"

93
src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue

@ -149,7 +149,6 @@
:isBusiness="true"
:isShowButton="false"
@searchTableSuccess="searchTableSuccessLabel"
@submitForm="submitFormLabel"
:isShowReduceButton="false"
@clearInput="clearInput"
:footButttondata="footButttondata"
@ -181,7 +180,11 @@
<el-button type="primary" @click="printAllClick">打印全部</el-button>
</template> -->
</SearchTable>
<labelForm ref="labelFormRef" :tableAllSchemas="SupplierdeliverRequestDetailLabel.allSchemas" />
<labelForm
ref="labelFormRef"
:tableAllSchemas="SupplierdeliverRequestDetailLabel.allSchemas"
@submitForm="submitFormLabel"
/>
</template>
<script setup lang="ts">
@ -341,7 +344,6 @@ const getSearchTableData = async (number, formField, searchField) => {
tableData.value.push(newRow)
itemCodes.push(row['itemCode'])
})
//
ItembasicApi.getItembasicPage({
code: itemCodes.join(',')
@ -367,7 +369,6 @@ const searchTableSuccessDetail = (formField, searchField, val, formRef) => {
formRef.setValues(setV)
})
}
//
const searchTableSuccessLabel = (formField, searchField, val, formRef, type, row) => {
nextTick(() => {
@ -648,9 +649,9 @@ const footButtonClick = async (val) => {
if (val == 'nextStep') {
const validateForm = await formLabelRef.value.tableFormRef.validateForm()
if (!validateForm) {
return
}
const data = JSON.parse(JSON.stringify(detatableData1.value))
return
}
const data = JSON.parse(JSON.stringify(detatableData1.value))
labelFormRef.value.openLabel(data)
} else if (val == 'close') {
formLabelRef.value.dialogVisible = false
@ -661,8 +662,13 @@ let tuoList = []
const formSelectChangeLabel = (field, val, row) => {
if (field == 'packUnit') {
let obj = row.boxPackaging.find((item) => item.packUnit == val)
row.packQty = obj.packQty
row.parentCode = ''
if (obj) {
row.packQty = obj.packQty
} else {
row.packQty = ''
}
row.secondPackUnit = ''
row.secondPackQty = ''
//
const params1 = {
itemCode: row.itemCode,
@ -678,7 +684,11 @@ const formSelectChangeLabel = (field, val, row) => {
//
if (field == 'secondPackUnit') {
let obj = tuoList.find((item) => item.packUnit == val)
row.secondPackQty = obj.packQty
if (obj) {
row.secondPackQty = obj.packQty
} else {
row.secondPackQty = ''
}
}
}
@ -968,43 +978,42 @@ detatableData.pageSize = 500
const { getList: getDetailList } = detatableMethods
//
const submitFormLabel = async (formType, submitData) => {
let data = { ...submitData }
if (data.masterId) {
data.id = data.masterId
}
const submitFormLabel = async (data) => {
try {
console.log('formType==', formType)
console.log('data==', data)
data.subList = detatableData.tableList
if (detatableData.tableList.find((item) => item.secondPackUnit == item.packUnit)) {
message.warning(t('ts.包装规格1和包装规格2不能相同'))
return
// console.log('formType==', formType)
// console.log('data==', data)
// data.subList = detatableData.tableList
// if (detatableData.tableList.find((item) => item.secondPackUnit == item.packUnit)) {
// message.warning(t('ts.12'))
// return
// }
const data1 = {
subList: [...data]
}
//
let flag = false
await SupplierdeliverRequestMainApi.checkPackQty(data).then(async (res) => {
if (res) {
await message
.confirm(t('ts.是否修改物料包装标包数量') + '?')
.then(() => {
flag = true //
})
.catch(() => {
flag = false
})
data1.subList.forEach((row) => {
if (row.secondPackUnit && row.secondPackQty) {
} else {
flag = true //
row.children = []
let obj = {}
row.packageList.forEach((item) => {
obj = {
xPoNumber: item.xPoNumber,
qtyTwo: item.qtyOne
}
row.children.push(obj)
})
row.packageList = []
row.packageList.push({
isTuo: 0,
children: row.children
})
}
})
console.log('返回结果', flag)
if (flag) {
console.log('detatableData', detatableData)
await message.confirm(t('ts.是否为此数据生成标签?'))
await SupplierdeliverRequestMainApi.genLabel(data)
isCreateLabel.value = true
message.success(t('ts.创建标签成功'))
}
console.log('detatableData', detatableData)
await message.confirm(t('ts.是否为此数据生成标签?'))
await SupplierdeliverRequestMainApi.genLabel(data1)
isCreateLabel.value = true
message.success(t('ts.创建标签成功'))
getList()
} finally {
formLabelRef.value.formLoading = false

206
src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue

@ -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>

Loading…
Cancel
Save