|
|
@ -229,138 +229,160 @@ export const tableFormBlurVer = async (headerItem, val, row, index,routeName,for |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
export const FormBlur = async (formField, val,routeName,formRef,detailData,formSchema,callback) => { |
|
|
|
let pageApi = ref() |
|
|
|
let params = ref() |
|
|
|
let setV = {} |
|
|
|
setV[formField] = '' |
|
|
|
if (val && isString(val)) { |
|
|
|
if ( |
|
|
|
formField == 'supplierCode' || |
|
|
|
formField == 'itemCode' || |
|
|
|
formField == 'productItemCode' || |
|
|
|
formField == 'componentItemCode' || |
|
|
|
formField == 'packUnit' || |
|
|
|
formField == 'inPackUnit' || |
|
|
|
formField == 'fromPackingNumber' |
|
|
|
) { |
|
|
|
let searchField = 'code' |
|
|
|
if (formField == 'supplierCode') { |
|
|
|
params.value = val?.trim() |
|
|
|
pageApi.value = getSupplierListByCodes |
|
|
|
} else if ( |
|
|
|
formField == 'itemCode' || |
|
|
|
formField == 'productItemCode' || |
|
|
|
formField == 'componentItemCode' |
|
|
|
) { |
|
|
|
// 销售价格单
|
|
|
|
if (routeName == 'Saleprice') { |
|
|
|
params.value = { |
|
|
|
customerCode: formRef.formModel.customerCode, |
|
|
|
itemCodes: val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getCustomerItemListByCodes |
|
|
|
searchField = 'itemCode' |
|
|
|
}else if (routeName == 'ProductscrapRequestMain') { |
|
|
|
// 制品报废申请
|
|
|
|
params.value = { |
|
|
|
productionLineCode: |
|
|
|
detailData.productionLine || detailData.productionLineCode, |
|
|
|
itemCodes: val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getProductionLineCodelistByCodes |
|
|
|
searchField = 'itemCode' |
|
|
|
}else { |
|
|
|
// params.value = val.trim()
|
|
|
|
searchField = 'code' |
|
|
|
|
|
|
|
params.value={ |
|
|
|
codes:val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getItemListByCodes |
|
|
|
} |
|
|
|
} else if (formField == 'packUnit') { |
|
|
|
if(routeName == 'Itemwarehouse'||routeName == 'Callmaterials'){//物料仓库默认配置,叫料标签
|
|
|
|
searchField = 'packUnit' |
|
|
|
params.value = { |
|
|
|
itemCode: formRef.formModel.itemCode, |
|
|
|
packUnit: val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getItemPackageunitListByCodes |
|
|
|
}else{ |
|
|
|
params.value = val?.trim() |
|
|
|
pageApi.value = getPackageunitListByCodes |
|
|
|
} |
|
|
|
} else if (formField == 'inPackUnit') { |
|
|
|
params.value = { |
|
|
|
itemCode: formRef.formModel.itemCode, |
|
|
|
packUnit: val.trim() |
|
|
|
} |
|
|
|
pageApi.value = getItemPackageunitListByCodes |
|
|
|
} |
|
|
|
// else if (formField == 'fromPackingNumber') {
|
|
|
|
// params.value = {
|
|
|
|
// packingNumber: val?.trim()
|
|
|
|
// }
|
|
|
|
// pageApi.value = getBalanceItemListByCodes
|
|
|
|
// }
|
|
|
|
let obj = {} |
|
|
|
let searchCondition1 = formSchema.find((item) => item.field == formField).componentProps |
|
|
|
.searchCondition //获取data.ts参数信息
|
|
|
|
// 循环参数设置参数为key:value格式
|
|
|
|
if (searchCondition1 && searchCondition1.length > 0) { |
|
|
|
for (let i = 0; i < searchCondition1.length; i++) { |
|
|
|
if (searchCondition1[i].isMainValue) { |
|
|
|
obj[searchCondition1[i].key] = formRef.formModel[searchCondition1[i].value] |
|
|
|
? formRef.formModel[searchCondition1[i].value] |
|
|
|
export const FormBlur = async (field, val, routeName, formRef, detailData, formSchema, callback) => { |
|
|
|
if (formSchema.searchPage && formSchema.verificationParams) { |
|
|
|
//获取data.ts参数信息
|
|
|
|
let searchCondition = formSchema?.searchCondition || [] |
|
|
|
//获取失去焦点参数信息
|
|
|
|
let verificationParams = formSchema?.verificationParams || |
|
|
|
[] |
|
|
|
console.log('走新方法啦') |
|
|
|
// searchCondition = [...searchCondition, ...verificationParams]
|
|
|
|
|
|
|
|
if (val && isString(val)) { |
|
|
|
let setV = {} |
|
|
|
setV[field] = '' |
|
|
|
let params = {} |
|
|
|
const _searchCondition = {} |
|
|
|
let filters: any[] = [] |
|
|
|
if (searchCondition && searchCondition.length > 0) { |
|
|
|
// 转换筛选条件所需
|
|
|
|
for (let i = 0; i < searchCondition.length; i++) { |
|
|
|
// searchCondition.forEach((item) => {
|
|
|
|
// 查询条件为主表某字段,需要赋值主表数据,数据来源是详情的,赋值需要从row中获取
|
|
|
|
if (searchCondition[i].isMainValue) { |
|
|
|
_searchCondition[searchCondition[i].key] = formRef.formModel[ |
|
|
|
searchCondition[i].value |
|
|
|
] |
|
|
|
? formRef.formModel[searchCondition[i].value] |
|
|
|
: detailData |
|
|
|
? detailData[searchCondition1[i].value] |
|
|
|
: '' |
|
|
|
? detailData[searchCondition[i].value] |
|
|
|
: // : row
|
|
|
|
// ? row[searchCondition[i].value]
|
|
|
|
'' |
|
|
|
// 是否含有空参数情况
|
|
|
|
let isNull = false |
|
|
|
if (obj[searchCondition1[i].key] == '' || obj[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 { |
|
|
|
filters.push({ |
|
|
|
action: searchCondition[i].action || '==', |
|
|
|
column: searchCondition[i].key, |
|
|
|
value: formRef.formModel[searchCondition[i].value] |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// 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.formModel[searchCondition1[i].value] == '' || |
|
|
|
formRef.formModel[searchCondition1[i].value] == undefined |
|
|
|
formRef.formModel[searchCondition[i].value] == '' || |
|
|
|
formRef.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.formModel[searchCondition[i].value] |
|
|
|
}) |
|
|
|
} else { |
|
|
|
filters.push({ |
|
|
|
action: searchCondition[i].action || '==', |
|
|
|
column: searchCondition[i].key, |
|
|
|
value: searchCondition[i].value |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
obj[searchCondition1[i].key] = searchCondition1[i].value |
|
|
|
filters.push({ |
|
|
|
action: searchCondition[i].action || '==', |
|
|
|
column: searchCondition[i].key, |
|
|
|
value: searchCondition[i].value |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let obj1 = formSchema.find((item) => item.field == formField) |
|
|
|
if (!obj1.componentProps.multiple && val.indexOf(',') > -1) { |
|
|
|
if (verificationParams && verificationParams.length > 0) { |
|
|
|
// 转换筛选条件所需
|
|
|
|
for (let i = 0; i < verificationParams.length; i++) { |
|
|
|
// 扩展 转换为筛选条件进行查询
|
|
|
|
if (verificationParams[i].isSearch) { |
|
|
|
if (verificationParams[i].isFormModel) { |
|
|
|
filters.push({ |
|
|
|
action: verificationParams[i].action, |
|
|
|
column: verificationParams[i].key, |
|
|
|
value: formRef.formModel[verificationParams[i].value] |
|
|
|
? formRef.formModel[verificationParams[i].value] |
|
|
|
: val.trim() |
|
|
|
}) |
|
|
|
} else { |
|
|
|
filters.push({ |
|
|
|
action: verificationParams[i].action, |
|
|
|
column: verificationParams[i].key, |
|
|
|
value: verificationParams[i].value |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
_searchCondition[verificationParams[i].key] = verificationParams[i].value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (filters.length > 0) { |
|
|
|
_searchCondition.isSearch = true |
|
|
|
_searchCondition.filters = filters |
|
|
|
} |
|
|
|
console.log(4545, _searchCondition) |
|
|
|
let obj = { |
|
|
|
by: 'ASC', |
|
|
|
pageNo: 1, |
|
|
|
pageSize: 20 |
|
|
|
} |
|
|
|
console.log(888, _searchCondition) |
|
|
|
params = { |
|
|
|
isSearch: _searchCondition.isSearch, |
|
|
|
filters: _searchCondition.filters, |
|
|
|
...obj |
|
|
|
} |
|
|
|
// console.log(333,params)
|
|
|
|
if (!formSchema?.multiple && val.indexOf(',') > -1) { |
|
|
|
message.alert('该输入框只能输入一条数据') |
|
|
|
formRef.setValues(setV) |
|
|
|
return |
|
|
|
} |
|
|
|
await pageApi.value(params.value).then((res) => { |
|
|
|
await formSchema.searchPage(params).then((res) => { |
|
|
|
let arr1 = val.split(',') |
|
|
|
let list = ref([]) |
|
|
|
list.value = res |
|
|
|
list.value = res?.list?.length > 0 ? res.list.slice(0, 1) : [] |
|
|
|
if (list.value?.length == 0) { |
|
|
|
message.alert('暂无数据') |
|
|
|
formRef.setValues(setV) |
|
|
@ -376,11 +398,161 @@ export const FormBlur = async (formField, val,routeName,formRef,detailData,formS |
|
|
|
formRef.setValues(setV) |
|
|
|
return |
|
|
|
} |
|
|
|
// emit('searchTableSuccess', formField, searchField, list.value, formRef.value, 'form')
|
|
|
|
callback(searchField,list.value) |
|
|
|
callback(list.value) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
let pageApi = ref() |
|
|
|
let params = ref() |
|
|
|
let setV = {} |
|
|
|
setV[field] = '' |
|
|
|
if (val && isString(val)) { |
|
|
|
if ( |
|
|
|
field == 'supplierCode' || |
|
|
|
field == 'itemCode' || |
|
|
|
field == 'productItemCode' || |
|
|
|
field == 'componentItemCode' || |
|
|
|
field == 'packUnit' || |
|
|
|
field == 'inPackUnit' || |
|
|
|
field == 'fromPackingNumber' |
|
|
|
) { |
|
|
|
let searchField = 'code' |
|
|
|
if (field == 'supplierCode') { |
|
|
|
params.value = val?.trim() |
|
|
|
pageApi.value = getSupplierListByCodes |
|
|
|
} else if ( |
|
|
|
field == 'itemCode' || |
|
|
|
field == 'productItemCode' || |
|
|
|
field == 'componentItemCode' |
|
|
|
) { |
|
|
|
// 销售价格单
|
|
|
|
if (routeName == 'Saleprice') { |
|
|
|
params.value = { |
|
|
|
customerCode: formRef.formModel.customerCode, |
|
|
|
itemCodes: val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getCustomerItemListByCodes |
|
|
|
searchField = 'itemCode' |
|
|
|
} else if (routeName == 'ProductscrapRequestMain') { |
|
|
|
// 制品报废申请
|
|
|
|
params.value = { |
|
|
|
productionLineCode: |
|
|
|
detailData.productionLine || detailData.productionLineCode, |
|
|
|
itemCodes: val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getProductionLineCodelistByCodes |
|
|
|
searchField = 'itemCode' |
|
|
|
} else { |
|
|
|
// params.value = val.trim()
|
|
|
|
searchField = 'code' |
|
|
|
|
|
|
|
params.value = { |
|
|
|
codes: val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getItemListByCodes |
|
|
|
} |
|
|
|
} else if (field == 'packUnit') { |
|
|
|
if (routeName == 'Itemwarehouse' || routeName == 'Callmaterials') {//物料仓库默认配置,叫料标签
|
|
|
|
searchField = 'packUnit' |
|
|
|
params.value = { |
|
|
|
itemCode: formRef.formModel.itemCode, |
|
|
|
packUnit: val?.trim() |
|
|
|
} |
|
|
|
pageApi.value = getItemPackageunitListByCodes |
|
|
|
} else { |
|
|
|
params.value = val?.trim() |
|
|
|
pageApi.value = getPackageunitListByCodes |
|
|
|
} |
|
|
|
} else if (field == 'inPackUnit') { |
|
|
|
params.value = { |
|
|
|
itemCode: formRef.formModel.itemCode, |
|
|
|
packUnit: val.trim() |
|
|
|
} |
|
|
|
pageApi.value = getItemPackageunitListByCodes |
|
|
|
} |
|
|
|
// else if (formField == 'fromPackingNumber') {
|
|
|
|
// params.value = {
|
|
|
|
// packingNumber: val?.trim()
|
|
|
|
// }
|
|
|
|
// pageApi.value = getBalanceItemListByCodes
|
|
|
|
// }
|
|
|
|
let obj = {} |
|
|
|
let searchCondition1 = formSchema.searchCondition //获取data.ts参数信息
|
|
|
|
// 循环参数设置参数为key:value格式
|
|
|
|
if (searchCondition1 && searchCondition1.length > 0) { |
|
|
|
for (let i = 0; i < searchCondition1.length; i++) { |
|
|
|
if (searchCondition1[i].isMainValue) { |
|
|
|
obj[searchCondition1[i].key] = formRef.formModel[searchCondition1[i].value] |
|
|
|
? formRef.formModel[searchCondition1[i].value] |
|
|
|
: detailData |
|
|
|
? detailData[searchCondition1[i].value] |
|
|
|
: '' |
|
|
|
// 是否含有空参数情况
|
|
|
|
let isNull = false |
|
|
|
if (obj[searchCondition1[i].key] == '' || obj[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.formModel[searchCondition1[i].value] == '' || |
|
|
|
formRef.formModel[searchCondition1[i].value] == undefined |
|
|
|
) { |
|
|
|
message.warning( |
|
|
|
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' |
|
|
|
) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
obj[searchCondition1[i].key] = searchCondition1[i].value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!formSchema.multiple && val.indexOf(',') > -1) { |
|
|
|
message.alert('该输入框只能输入一条数据') |
|
|
|
formRef.setValues(setV) |
|
|
|
return |
|
|
|
} |
|
|
|
await pageApi.value(params.value).then((res) => { |
|
|
|
let arr1 = val.split(',') |
|
|
|
let list = ref([]) |
|
|
|
list.value = res |
|
|
|
if (list.value?.length == 0) { |
|
|
|
message.alert('暂无数据') |
|
|
|
formRef.setValues(setV) |
|
|
|
return |
|
|
|
} |
|
|
|
if (arr1.length != list.value.length) { |
|
|
|
let arr2 = list.value.map((item) => item.code) |
|
|
|
let str = [ |
|
|
|
...arr1.filter((item) => !arr2.includes(item)), |
|
|
|
...arr2.filter((item) => !arr1.includes(item)) |
|
|
|
].join(',') |
|
|
|
message.alert('代码' + str + '没有找到对应数据') |
|
|
|
formRef.setValues(setV) |
|
|
|
return |
|
|
|
} |
|
|
|
// emit('searchTableSuccess', formField, searchField, list.value, formRef.value, 'form')
|
|
|
|
callback(searchField, list.value) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 根据下方输入框失去焦点校验信息
|
|
|
|