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