From 2e5c8bcbaaca21c2389b3d35dcce70c3c40873cf Mon Sep 17 00:00:00 2001 From: zhang_li <2235006734@qqq.com> Date: Wed, 10 Jul 2024 10:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A0=87=E7=AD=BE=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TableForm/src/TableForm.vue | 21 ++- .../supplierdeliverRequestMain/index.vue | 45 ++---- .../supplierdeliverRequestMain/labelForm.vue | 145 +++++++++-------- .../supplierdeliverRequestMain.data.ts | 148 +++--------------- 4 files changed, 130 insertions(+), 229 deletions(-) diff --git a/src/components/TableForm/src/TableForm.vue b/src/components/TableForm/src/TableForm.vue index 5e952d597..c08408bc6 100644 --- a/src/components/TableForm/src/TableForm.vue +++ b/src/components/TableForm/src/TableForm.vue @@ -168,9 +168,9 @@ > @@ -699,7 +699,20 @@ const disabledInput = (headerItem, row) => { ) } } - +const initLabel=(headerItem,op)=>{ +if(headerItem?.tableForm?.labelField){ + return op[headerItem?.tableForm?.labelField] +}else{ + return op.label +} +} +const initValue=(headerItem,op)=>{ +if(headerItem?.tableForm?.valueField){ + return op[headerItem?.tableForm?.valueField] +}else{ + return op.value +} +} // setup 语法糖 抛出方法 defineExpose({ TableBaseComponents_Ref, diff --git a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue index 1a82e289a..0f05b902d 100644 --- a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue +++ b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue @@ -601,11 +601,7 @@ const buttonTableClick = async (val, row) => { detatableData1.value = res detatableData1.value.forEach((item) => { console.log(item.boxPackaging) - if (item.boxPackaging?.length > 0) { - item.packUnitInitOptions = item.boxPackaging.map((cur) => { - return { label: cur.packName, value: cur.packUnit } - }) - } + item.packUnitInitOptions = item.boxPackaging }) }) formLabelRef.value.open('create', row, null, 'createLabel') //创建标签页面 createLabel 标题 @@ -676,7 +672,6 @@ const footButtonClick = async (val) => { } } // 选择箱规格 拖规格 -let tuoList = [] const formSelectChangeLabel = (field, val, row) => { if (field == 'packUnit') { let obj = row.boxPackaging.find((item) => item.packUnit == val) @@ -693,15 +688,12 @@ const formSelectChangeLabel = (field, val, row) => { packUnit: row.packUnit } SupplierdeliverRequestDetailApi.getGenerateLabelParentList(params1).then((res) => { - tuoList = res - row.secondPackUnitInitOptions = res.map((cur) => { - return { label: cur.packName, value: cur.packUnit } - }) + row.secondPackUnitInitOptions = res }) } // 设置托 if (field == 'secondPackUnit') { - let obj = tuoList.find((item) => item.packUnit == val) + let obj = row.secondPackUnitInitOptions.find((item) => item.packUnit == val) if (obj) { row.secondPackQty = obj.packQty } else { @@ -996,35 +988,16 @@ detatableData.pageSize = 500 const { getList: getDetailList } = detatableMethods // 生成标签按钮操作 -const submitFormLabel = async (data) => { +const submitFormLabel = async (list) => { try { - const data1 = { - subList: JSON.parse(JSON.stringify(data)) - } - data1.subList.forEach((row) => { - if (row.secondPackUnit && row.secondPackQty) { - } else { - 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(data1) + let data = { + subList:list + } + console.log(data) await message.confirm(t('ts.是否为此数据生成标签?')) labelFormRef.value.isLoading = true - await SupplierdeliverRequestMainApi.genLabel(data1) + await SupplierdeliverRequestMainApi.genLabel(data) isCreateLabel.value = true message.success(t('ts.创建标签成功')) getList() diff --git a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue index fc932ffca..337596fe2 100644 --- a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue +++ b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue @@ -6,7 +6,7 @@ row-key="id" style="width: 1050px; max-height: 70vh; overflow-y: auto" v-if="tableData.length > 0 && dialogTableVisible == true" - v-loading='isLoading' + v-loading="isLoading" > @@ -91,29 +91,37 @@ - - - - - - - - - - 添加箱 - - - 移出 - - - + + + + + + + + + + + 添加箱 + + + 移出 + + + + @@ -164,14 +172,11 @@ const twoId = ref(0) //每箱的id const intData = () => { tableData.value.forEach((row) => { 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)) - } expandChange(row) }) @@ -195,7 +200,7 @@ const expandChange = (row: any, expandedRows: any[]) => { tPoNumber: i + 1, xNumber: '', qtyOne: '', - isTuo : 1 //有托 + isTuo: 1 //有托 } // 如果有余数 if (row.lastNumber) { @@ -221,35 +226,33 @@ const expandChange = (row: any, expandedRows: any[]) => { // 数量除以箱数量获取余数 cur.xLastNumber = parseFloat(cur.qtyOne) % parseFloat(row.packQty) // 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++ - cur.children[i] = { + cur.children[j] = { id: twoId.value, - xPoNumber: i + 1 + xPoNumber: j + 1 } // 如果有余数 if (cur.xLastNumber) { // 最后一条信息直接展示余数的信息 - if (i == cur.xNumber - 1) { - cur.children[i].qtyTwo = cur.xLastNumber + if (j == cur.xNumber - 1) { + cur.children[j].qtyTwo = cur.xLastNumber } else { // 其他数据展示一托的全部箱数和全部数量 - cur.children[i].qtyTwo = row.packQty + cur.children[j].qtyTwo = row.packQty } } else { // 如果沒有余数,直接展示一托的全部箱数和全部数量 - cur.children[i].qtyTwo = row.packQty + cur.children[j].qtyTwo = row.packQty } } }) } } 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.allTuoQty = 1 // 循环箱 for (let i = 0; i < row.allTuoQty; i++) { oneId.value++ @@ -257,22 +260,35 @@ const expandChange = (row: any, expandedRows: any[]) => { row.packageList[i] = { id: oneId.value, xPoNumber: i + 1, - qtyOne: '' + qtyOne: row.qty, + isTuo: 0 //无托 } - // 如果有余数 - if (row.lastNumber) { - // 最后一条信息直接展示余数的信息 - if (i == row.allTuoQty - 1) { - row.packageList[i].qtyOne = row.lastNumber + } + row.packageList.forEach((cur) => { + cur.children = [] + for (let j = 0; j < row.allXiangQty; j++) { + 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 { - // 其他数据展示一托的全部箱数和全部数量 - 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 } else { // 直接添加箱 - oneRow.packageList.push({ - id: oneId.value, - xPoNumber: oneRow.packageList[oneRow.packageList.length - 1].xPoNumber + 1, - qtyOne: '' + twoRow.children.push({ + id: twoId.value, + xPoNumber: twoRow.children[twoRow.children.length - 1].xPoNumber + 1, + 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.xNumber = twoRow.children.length } else { - oneRow.packageList.splice(twoIndex, 1) - oneRow.allTuoQty = oneRow.packageList.length + twoRow.children.splice(twoIndex, 1) + oneRow.allTuoQty = twoRow.children.length } } // 是否显示展开图标 @@ -452,15 +468,20 @@ const blurTwo = (oneRow, twoRow, threeRow) => { twoRow.qtyOne = num } // 箱数量失去焦点 -const blurThree = (oneRow, twoRow) => { - if (parseFloat(twoRow.qtyOne) > parseFloat(oneRow.packQty)) { +const blurThree = (oneRow, twoRow, thereeRow) => { + if (parseFloat(thereeRow.qtyTwo) > parseFloat(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']) -defineExpose({ openLabel,dialogTableVisible,isLoading }) // 提供 open 方法,用于打开弹窗 +defineExpose({ openLabel, dialogTableVisible, isLoading }) // 提供 open 方法,用于打开弹窗