diff --git a/README.md b/README.md index 7c997d5fa..b50a3f14d 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ form: { isFormModel:true, // filters中添加筛选的数据--取于formModel required:true, // 前置添加必有,和isFormModel结合使用 message: '请选择客户代码!', // 前置添加没填的提示语 + }, { key: 'itemCode', @@ -44,7 +45,16 @@ form: { value:'TRUE', // 指查询具体值 isMainValue: false // 表示查询条件不是主表的字段的值 } - ] + ], + // 失去焦点校验参数 + verificationParams: [{ + key: 'code', + action: '==', + value: '', + isMainValue: false, + isSearch: 'true', + isFormModel: true + }] } } **tableForm明细列表查询弹窗配置** diff --git a/src/components/BasicForm/src/BasicForm.vue b/src/components/BasicForm/src/BasicForm.vue index e162d86d9..271d790f8 100644 --- a/src/components/BasicForm/src/BasicForm.vue +++ b/src/components/BasicForm/src/BasicForm.vue @@ -841,82 +841,173 @@ const onChange = (field, cur) => { */ const onBlur = async (field, e) => { isExecute.value = false - let formSchemaObj = formSchema.value.find((item) => item.field == field)?.componentProps if (formSchemaObj?.enterSearch) { - if (formSchemaObj.verificationPage) { - let searchCondition1 = formSchema.value.find((item) => item.field == field).componentProps - .searchCondition //获取data.ts参数信息 - let verificationParams = formSchema.value.find((item) => item.field == field).componentProps - .verificationParams //获取失去焦点参数信息 + if (formSchemaObj.searchPage && formSchemaObj.verificationParams) { + //获取data.ts参数信息 + let searchCondition = + formSchema.value.find((item) => item.field == field)?.componentProps?.searchCondition || [] + //获取失去焦点参数信息 + let verificationParams = + formSchema.value.find((item) => item.field == field)?.componentProps?.verificationParams || + [] console.log('走新方法啦') + searchCondition = [...searchCondition, ...verificationParams] if (e && isString(e)) { let setV = {} setV[field] = '' let params = {} // 循环参数设置参数为key:value格式 - if (searchCondition1 && searchCondition1.length > 0) { - for (let i = 0; i < searchCondition1.length; i++) { - if (searchCondition1[i].isMainValue) { - params[searchCondition1[i].key] = formRef.value.formModel[searchCondition1[i].value] - ? formRef.value.formModel[searchCondition1[i].value] + // if (searchCondition1 && searchCondition1.length > 0) { + // for (let i = 0; i < searchCondition1.length; i++) { + // searchCondition1[i].isSearch = true + // if (searchCondition1[i].isMainValue) { + // params[searchCondition1[i].key] = formRef.value.formModel[searchCondition1[i].value] + // ? formRef.value.formModel[searchCondition1[i].value] + // : props.detailData + // ? props.detailData[searchCondition1[i].value] + // : '' + // // 是否含有空参数情况 + // let isNull = false + // if (params[searchCondition1[i].key] == '' || params[searchCondition1[i].key] == undefined) { + // isNull = true + // } + // if (isNull) { + // message.warning( + // searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' + // ) + // return + // } + // } else { + // // 扩展 转换为筛选条件进行查询 + // if (searchCondition1[i].isSearch) { + // if (searchCondition1[i].isFormModel) { + // //用formModel中的值 + // if (searchCondition1[i].required) { + // if ( + // formRef.value.formModel[searchCondition1[i].value] == '' || + // formRef.value.formModel[searchCondition1[i].value] == undefined + // ) { + // message.warning( + // searchCondition1[i].message + // ? searchCondition1[i].message + // : '前置条件未选择!' + // ) + // return + // } + // } + // } + // params[searchCondition1[i].key] = searchCondition1[i].value + // } else { + // params[searchCondition1[i].key] = searchCondition1[i].value + // } + // } + // } + // } + // 判断查询条件中,是否存在指向主表的数据 + const _searchCondition = {} + if (searchCondition && searchCondition.length > 0) { + // 转换筛选条件所需 + let filters: any[] = [] + for (var i = 0; i < searchCondition.length; i++) { + // searchCondition.forEach((item) => { + // 查询条件为主表某字段,需要赋值主表数据,数据来源是详情的,赋值需要从row中获取 + if (searchCondition[i].isMainValue) { + _searchCondition[searchCondition[i].key] = formRef.value.formModel[ + searchCondition[i].value + ] + ? formRef.value.formModel[searchCondition[i].value] : props.detailData - ? props.detailData[searchCondition1[i].value] + ? props.detailData[searchCondition[i].value] + : // : row + // ? row[searchCondition[i].value] + e + ? e.trim() : '' // 是否含有空参数情况 let isNull = false - if (params[searchCondition1[i].key] == '' || params[searchCondition1[i].key] == undefined) { + if ( + _searchCondition[searchCondition[i].key] == '' || + _searchCondition[searchCondition[i].key] == undefined + ) { isNull = true } if (isNull) { message.warning( - searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' + searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' ) return } - } else { + } + // else if (searchCondition[i].isTableRowValue) { + // if (searchCondition[i].required) { + // if (row[searchCondition[i].value] == '' || row[searchCondition[i].value] == undefined) { + // message.warning( + // searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' + // ) + // return + // } + // } + // row[searchCondition[i].value] + // //查询当前table表数据的值 + // _searchCondition[searchCondition[i].key] = row[searchCondition[i].value] + // } + else { // 扩展 转换为筛选条件进行查询 - if (searchCondition1[i].isSearch) { - if (searchCondition1[i].isFormModel) { + if (searchCondition[i].isSearch) { + if (searchCondition[i].isFormModel) { //用formModel中的值 - if (searchCondition1[i].required) { + if (searchCondition[i].required) { if ( - formRef.value.formModel[searchCondition1[i].value] == '' || - formRef.value.formModel[searchCondition1[i].value] == undefined + formRef.value.formModel[searchCondition[i].value] == '' || + formRef.value.formModel[searchCondition[i].value] == undefined ) { message.warning( - searchCondition1[i].message - ? searchCondition1[i].message - : '前置条件未选择!' + searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' ) return } } + filters.push({ + action: searchCondition[i].action, + column: searchCondition[i].key, + value: formRef.value.formModel[searchCondition[i].value] + ? formRef.value.formModel[searchCondition[i].value] + : e.trim() + }) + } else { + filters.push({ + action: searchCondition[i].action, + column: searchCondition[i].key, + value: searchCondition[i].value + }) } - params[searchCondition1[i].key] = searchCondition1[i].value } else { - params[searchCondition1[i].key] = searchCondition1[i].value + _searchCondition[searchCondition[i].key] = searchCondition[i].value } } } - } - // 循环参数设置参数为key:value格式 - if (verificationParams && verificationParams.length > 0) { - for (let i = 0; i < verificationParams.length; i++) { - params[verificationParams[i].key] = e?.trim() + if (filters.length > 0) { + _searchCondition.isSearch = true + _searchCondition.filters = filters } } - console.log(333,params) + let obj = { + by: 'ASC', + pageNo: 1, + pageSize: 20 + } + params = { ..._searchCondition, ...obj } + // console.log(333,params) if (!formSchemaObj?.multiple && e.indexOf(',') > -1) { message.alert('该输入框只能输入一条数据') formRef.value.setValues(setV) return } - await formSchemaObj.verificationPage(params).then((res) => { + await formSchemaObj.searchPage(params).then((res) => { let arr1 = e.split(',') let list = ref([]) - list.value = res - console.log(222, list.value) + list.value = res.list if (list.value?.length == 0) { message.alert('暂无数据') formRef.value.setValues(setV) @@ -932,19 +1023,7 @@ const onBlur = async (field, e) => { formRef.value.setValues(setV) return } - // emit('searchTableSuccess', formField, searchField, list.value, formRef.value, 'form') - // callback(list.value) }) - // emit( - // 'onBlur', - // field, - // e, - // formSchemaObj.componentProps.searchField, - // formSchemaObj, - // formRef.value, - // 'form', - // obj - // ) } } else { if ( diff --git a/src/views/wms/basicDataManage/itemManage/bom/bom.data.ts b/src/views/wms/basicDataManage/itemManage/bom/bom.data.ts index e8729c17f..31f22135a 100644 --- a/src/views/wms/basicDataManage/itemManage/bom/bom.data.ts +++ b/src/views/wms/basicDataManage/itemManage/bom/bom.data.ts @@ -32,10 +32,13 @@ export const Bom = useCrudSchemas(reactive([ searchTitle: '物料基础信息', // 查询弹窗标题 searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 searchPage: ItembasicApi.selectItembasicPageToFgAndSemibasicPage, // 查询弹窗所需分页方法 - verificationPage: ItembasicApi.getItemListByCodes, // 失去焦点校验输入框的数据内容存在 verificationParams: [{ - key: 'codes', + key: 'code', + action: '==', value: '', + isMainValue: false, + isSearch: 'true', + isFormModel: true }], // 失去焦点校验参数 } } @@ -58,10 +61,13 @@ export const Bom = useCrudSchemas(reactive([ searchTitle: '物料基础信息', // 查询弹窗标题 searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 searchPage: ItembasicApi.selectTypeToItembasic, // 查询弹窗所需分页方法 - verificationPage: ItembasicApi.getItemListByCodes, // 失去焦点校验输入框的数据内容存在 verificationParams: [{ - key: 'codes', + key: 'code', + action: '==', value: '', + isMainValue: false, + isSearch: 'true', + isFormModel: true }], // 失去焦点校验参数 } } @@ -114,12 +120,16 @@ export const Bom = useCrudSchemas(reactive([ searchCondition: [{ key: 'available', value: 'TRUE', - isMainValue: false + isMainValue: false, }], verificationPage: ProcessApi.getProcessByCodes, // 失去焦点校验输入框的数据内容存在 verificationParams: [{ - key: 'codes', + key: 'code', + action: '==', value: '', + isMainValue: false, + isSearch: 'true', + isFormModel:true }], // 失去焦点校验参数 } } diff --git a/src/views/wms/basicDataManage/itemManage/itempackage/itempackage.data.ts b/src/views/wms/basicDataManage/itemManage/itempackage/itempackage.data.ts index fba8c3a25..bc2db8a9f 100644 --- a/src/views/wms/basicDataManage/itemManage/itempackage/itempackage.data.ts +++ b/src/views/wms/basicDataManage/itemManage/itempackage/itempackage.data.ts @@ -34,7 +34,15 @@ export const Itempackaging = useCrudSchemas(reactive([ key: 'available', value: 'TRUE', isMainValue: false - }] + }], + verificationParams: [{ + key: 'code', + action: '==', + value: '', + isMainValue: false, + isSearch: 'true', + isFormModel: true + }], // 失去焦点校验参数 } } }, @@ -78,7 +86,15 @@ export const Itempackaging = useCrudSchemas(reactive([ action: '==', isSearch: true, isMainValue: false - }] + }], + verificationParams: [{ + key: 'code', + action: '==', + value: '', + isMainValue: false, + isSearch: 'true', + isFormModel: true + }], // 失去焦点校验参数 } } }, diff --git a/src/views/wms/basicDataManage/itemManage/packageunit/index.vue b/src/views/wms/basicDataManage/itemManage/packageunit/index.vue index 1e2341a23..a648c1948 100644 --- a/src/views/wms/basicDataManage/itemManage/packageunit/index.vue +++ b/src/views/wms/basicDataManage/itemManage/packageunit/index.vue @@ -80,11 +80,10 @@ const tableColumns = ref(Packageunit.allSchemas.tableColumns) // 查询页面返回 const searchTableSuccess = (formField, searchField, val, formRef) => { nextTick(() => { - // if(val[0].parentCode){ - // message.error('该规格为子包装,请重新选择') - // return - // } const setV = {} + if(formField == 'parentCode'){ + setV['type'] = val[0]['type'] + } setV[formField] = val[0][searchField] formRef.setValues(setV) }) @@ -178,6 +177,9 @@ const openForm = (type: string, row?: any) => { if (item.field == 'manageBalance') { item.componentProps.disabled = true } + if (item.field == 'type') { + item.componentProps.disabled = false + } }) }else { Packageunit.allSchemas.formSchema.forEach((item) => { @@ -190,6 +192,9 @@ const openForm = (type: string, row?: any) => { if (item.field == 'manageBalance') { item.componentProps.disabled = false } + if (item.field == 'type') { + item.componentProps.disabled = true + } }) } basicFormRef.value.open(type, row) diff --git a/src/views/wms/basicDataManage/itemManage/stdcostprice/stdcostprice.data.ts b/src/views/wms/basicDataManage/itemManage/stdcostprice/stdcostprice.data.ts index 6dca2f1d6..2ea5edca4 100644 --- a/src/views/wms/basicDataManage/itemManage/stdcostprice/stdcostprice.data.ts +++ b/src/views/wms/basicDataManage/itemManage/stdcostprice/stdcostprice.data.ts @@ -70,7 +70,15 @@ export const Stdcostprice = useCrudSchemas(reactive([ key: 'available', value: 'TRUE', isMainValue: false - }] + }], + verificationParams: [{ + key: 'code', + action: '==', + value: '', + isMainValue: false, + isSearch: 'true', + isFormModel: true + }], // 失去焦点校验参数 } } }, diff --git a/src/views/wms/deliversettlementManage/deliver/deliverRecordMain/deliverRecordMain.data.ts b/src/views/wms/deliversettlementManage/deliver/deliverRecordMain/deliverRecordMain.data.ts index 2192b55f1..c5249f5e5 100644 --- a/src/views/wms/deliversettlementManage/deliver/deliverRecordMain/deliverRecordMain.data.ts +++ b/src/views/wms/deliversettlementManage/deliver/deliverRecordMain/deliverRecordMain.data.ts @@ -530,6 +530,10 @@ export const DeliverRecordDetail = useCrudSchemas(reactive([ { label: '包装规格', field: 'packUnit', + isSearch: false, + isTable: false, + isForm:false, + isDetail:false, sort: 'custom', table: { width: 150 diff --git a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue index 85b694f7a..86eff1d93 100644 --- a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue +++ b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/index.vue @@ -154,7 +154,6 @@ :footButttondata="footButttondata" @footButtonClick="footButtonClick" @formSelectChange="formSelectChangeLabel" - @visibleChange='visibleChange' /> { } genLabelId.value = row.masterId // await getDetailList() - await getGenerateLabelList(row) + await getGenerateLabelList(row) formLabelRef.value.open('create', row, null, 'createLabel') //创建标签页面 createLabel 标题 } }) @@ -628,27 +627,33 @@ const footButttondata = ref([ defaultButtons.formCloseBtn(null) // BOM关闭 ]) // 获取箱规格 -const getGenerateLabelList=async(row)=>{ +const getGenerateLabelList = async (row) => { const params1 = { - masterId: row.masterId, - pageSize: '500', - pageNo: '1', - sort: '', - by: 'ASC' - } - await SupplierdeliverRequestDetailApi.getGenerateLabelList(params1).then((res) => { - detatableData1.value = res - detatableData1.value.forEach((item) => { - item.packUnitInitOptions = item.boxPackaging - let obj = item?.boxPackaging[0] - if (obj) { - item.packUnit= obj.packUnit - item.packQty = obj.packQty - } - item.secondPackUnit= '' - item.secondPackQty = '' - }) + masterId: row.masterId, + pageSize: '500', + pageNo: '1', + sort: '', + by: 'ASC' + } + await SupplierdeliverRequestDetailApi.getGenerateLabelList(params1).then((res) => { + detatableData1.value = res + detatableData1.value.forEach((item) => { + item.packUnitInitOptions = item.boxPackaging + item.secondPackUnitInitOptions = item.palletPackaging || [] + let obj = item?.boxPackaging[0] + if (obj) { + item.packUnit = obj.packUnit + item.packQty = obj.packQty + } + // 有托规格显示托规格,没有显示第一条规格 + item.secondPackUnit = obj.parentPackUnit + ? obj.parentPackUnit + : item?.secondPackUnitInitOptions[0]?.packUnit + item.secondPackQty = obj.parentPackUnit + ? obj.parentPackQty + : item?.secondPackUnitInitOptions[0]?.packQty }) + }) } // 下一步 const labelFormRef = ref() @@ -658,12 +663,19 @@ const footButtonClick = async (val) => { if (!validateForm) { return } - let isNext = detatableData1.value.some((item)=>{ - return !item.packUnit || !item.packQty + let isNext = detatableData1.value.some((item) => { + return !item.packUnit || !item.packQty }) - if(isNext){ + if (isNext) { message.warning('有数据没有选择箱规格') - return; + return + } + let isNext1 = detatableData1.value.some((item) => { + return item.secondPackQty && item.packQty && parseFloat(item.packQty) > parseFloat(item.secondPackQty) + }) + if (isNext1) { + message.warning('托的包装数量要大于箱的包装数量,请修改') + return } const data = JSON.parse(JSON.stringify(detatableData1.value)) labelFormRef.value.openLabel(data) @@ -677,12 +689,25 @@ const formSelectChangeLabel = (field, val, row) => { let obj = row.boxPackaging.find((item) => item.packUnit == val) if (obj) { row.packQty = obj.packQty + // 获取托规格 + const params1 = { + itemCode: row.itemCode, + packUnit: row.packUnit + } + SupplierdeliverRequestDetailApi.getGenerateLabelParentList(params1).then((res) => { + if (res?.length > 0) { + row.secondPackUnit = res[0].packUnit + row.secondPackQty = res[0].packQty + } else { + row.secondPackUnit = row?.secondPackUnitInitOptions[0]?.packUnit + row.secondPackQty = row?.secondPackUnitInitOptions[0]?.packQty + } + }) } else { row.packQty = '' + row.secondPackUnit = '' + row.secondPackQty = '' } - row.secondPackUnit = '' - row.secondPackQty = '' - } // 设置托 if (field == 'secondPackUnit') { @@ -694,23 +719,7 @@ const formSelectChangeLabel = (field, val, row) => { } } } -// tableForm下拉框弹出隐藏 -const visibleChange=(field, val, row, index)=>{ - row.secondPackUnitInitOptions=[] - if(field=='secondPackUnit'){ - if(val){ - // 获取托规格 - const params1 = { - itemCode: row.itemCode, - packUnit: row.packUnit - } - SupplierdeliverRequestDetailApi.getGenerateLabelParentList(params1).then((res) => { - row.secondPackUnitInitOptions = res - }) - } - } -} // 获取部门 用于详情 部门回显 const { wsCache } = useCache() @@ -1000,10 +1009,9 @@ const { getList: getDetailList } = detatableMethods // 生成标签按钮操作 const submitFormLabel = async (list) => { try { - - let data = { - subList:list - } + let data = { + subList: list + } await message.confirm(t('ts.是否为此数据生成标签?')) labelFormRef.value.isLoading = true await SupplierdeliverRequestMainApi.genLabel(data) @@ -1016,7 +1024,6 @@ const submitFormLabel = async (list) => { labelFormRef.value.formLoading = false labelFormRef.value.dialogTableVisible = false labelFormRef.value.isLoading = false - } } const clearInput = async (field, row, index) => { diff --git a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue index 65dbdc44a..ee81020ce 100644 --- a/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue +++ b/src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverRequestMain/labelForm.vue @@ -438,24 +438,24 @@ const blurOne = (oneRow, twoRow) => { // 托信息修改的時候箱数据自动排列 // 判断箱信息是否存在 if (oneRow.packUnit && oneRow.packQty) { - oneRow.packageList.forEach((cur, key) => { - cur.children = [] + // oneRow.packageList.forEach((cur, key) => { + twoRow.children = [] // 数量除以托数量获取余数 - cur.xLastNumber = parseFloat(cur.xNumber) % parseFloat(oneRow.packQty) - for (let j = 0; j < cur.xNumber; j++) { + twoRow.xLastNumber = parseFloat(twoRow.xNumber) % parseFloat(oneRow.packQty) + for (let j = 0; j < twoRow.xNumber; j++) { twoId.value++ // 如果有余数 - if (cur.xLastNumber) { + if (twoRow.xLastNumber) { // 最后一条信息直接展示余数的信息 - if (j == cur.xNumbery - 1) { - cur.children.push({ + if (j == twoRow.xNumbery - 1) { + twoRow.children.push({ id: twoId.value, xPoNumber: j + 1, - qtyTwo: cur.xLastNumber + qtyTwo: twoRow.xLastNumber }) } else { // 其他数据展示一托的全部箱数和全部数量 - cur.children.push({ + twoRow.children.push({ id: twoId.value, xPoNumber: j + 1, qtyTwo: oneRow.packQty @@ -463,23 +463,23 @@ const blurOne = (oneRow, twoRow) => { } } else { // 如果沒有余数,直接展示一托的全部箱数和全部数量 - cur.children.push({ + twoRow.children.push({ id: twoId.value, xPoNumber: j + 1, qtyTwo: oneRow.packQty }) } } - }) + // }) } } //在托下方的箱数量失去焦点 const blurTwo = (oneRow, twoRow, threeRow) => { - if (parseFloat(threeRow.qtyTwo) > parseFloat(oneRow.packQty)) { - message.warning('数量最多为' + oneRow.packQty) - threeRow.qtyTwo = oneRow.packQty - return - } + // if (parseFloat(threeRow.qtyTwo) > parseFloat(oneRow.packQty)) { + // message.warning('数量最多为' + oneRow.packQty) + // threeRow.qtyTwo = oneRow.packQty + // return + // } let num = 0 twoRow.children.forEach((item) => { num += parseFloat(item.qtyTwo) || 0 @@ -488,10 +488,10 @@ const blurTwo = (oneRow, twoRow, threeRow) => { } // 箱数量失去焦点 const blurThree = (oneRow, twoRow, thereeRow) => { - if (parseFloat(thereeRow.qtyTwo) > parseFloat(oneRow.packQty)) { - message.warning('每箱个数最多' + oneRow.packQty) - thereeRow.qtyTwo = oneRow.packQty - } + // if (parseFloat(thereeRow.qtyTwo) > parseFloat(oneRow.packQty)) { + // message.warning('每箱个数最多' + oneRow.packQty) + // thereeRow.qtyTwo = oneRow.packQty + // } let num = 0 twoRow.children.forEach((item) => { num += parseFloat(item.qtyTwo) || 0