|
@ -22,7 +22,159 @@ const { t } = useI18n() // 国际化 |
|
|
* tableFormBlur 表格表单失去焦点时候获取焦点 |
|
|
* tableFormBlur 表格表单失去焦点时候获取焦点 |
|
|
* FormBlur 表格失去焦点时候获取焦点 |
|
|
* FormBlur 表格失去焦点时候获取焦点 |
|
|
*/ |
|
|
*/ |
|
|
export const tableFormBlurVer = async (headerItem, val, row, index,routeName,formRef,detailData,tableData,callback) => { |
|
|
export const tableFormBlurVer = async (headerItem, val, row, index, routeName, formRef, detailData, tableData, callback) => { |
|
|
|
|
|
if (headerItem.tableForm.searchPage && headerItem.tableForm.verificationParams) { |
|
|
|
|
|
if (val && isString(val)) { |
|
|
|
|
|
if (val.indexOf(',') > -1) { |
|
|
|
|
|
message.alert('该输入框只能输入一条数据') |
|
|
|
|
|
row[headerItem.field] = '' |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
// 校验
|
|
|
|
|
|
const params = ref({}) |
|
|
|
|
|
const filters: any[] = [] |
|
|
|
|
|
const searchCondition = headerItem.tableForm.searchCondition //获取data.ts参数信息
|
|
|
|
|
|
const verificationParams = headerItem.tableForm.verificationParams //获取data.ts参数信息
|
|
|
|
|
|
// 循环参数设置参数为key:value格式
|
|
|
|
|
|
if (searchCondition && searchCondition.length > 0) { |
|
|
|
|
|
for (let i = 0; i < searchCondition.length; i++) { |
|
|
|
|
|
if (searchCondition[i].isMainValue) { |
|
|
|
|
|
params.value[searchCondition[i].key] = formRef.formModel[ |
|
|
|
|
|
searchCondition[i].value |
|
|
|
|
|
] |
|
|
|
|
|
? formRef.formModel[searchCondition[i].value] |
|
|
|
|
|
: detailData |
|
|
|
|
|
? detailData[searchCondition[i].value] |
|
|
|
|
|
: row |
|
|
|
|
|
? row[searchCondition[i].value] |
|
|
|
|
|
: '' |
|
|
|
|
|
// 是否含有空参数情况
|
|
|
|
|
|
let isNull = false |
|
|
|
|
|
if ( |
|
|
|
|
|
params.value[searchCondition[i].key] == '' || |
|
|
|
|
|
params.value[searchCondition[i].key] == undefined |
|
|
|
|
|
) { |
|
|
|
|
|
isNull = true |
|
|
|
|
|
} |
|
|
|
|
|
if (isNull) { |
|
|
|
|
|
message.warning( |
|
|
|
|
|
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|
|
|
|
|
) |
|
|
|
|
|
row[headerItem.field] = '' |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
filters.push({ |
|
|
|
|
|
action: searchCondition[i].action || '==', |
|
|
|
|
|
column: searchCondition[i].key, |
|
|
|
|
|
value: formRef.formModel[searchCondition[i].value] |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 扩展 转换为筛选条件进行查询
|
|
|
|
|
|
if (searchCondition[i].isSearch) { |
|
|
|
|
|
if (searchCondition[i].isFormModel) { |
|
|
|
|
|
//用formModel中的值
|
|
|
|
|
|
if (searchCondition[i].required) { |
|
|
|
|
|
if ( |
|
|
|
|
|
formRef.formModel[searchCondition[i].value] == '' || |
|
|
|
|
|
formRef.formModel[searchCondition[i].value] == undefined |
|
|
|
|
|
) { |
|
|
|
|
|
message.warning( |
|
|
|
|
|
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|
|
|
|
|
) |
|
|
|
|
|
row[headerItem.field] = '' |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
filters.push({ |
|
|
|
|
|
action: searchCondition[i].action || '==', |
|
|
|
|
|
column: searchCondition[i].key, |
|
|
|
|
|
value: formRef.formModel[searchCondition[i].value] |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
params.value[searchCondition[i].key] = searchCondition[i].value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
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() |
|
|
|
|
|
}) |
|
|
|
|
|
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 { |
|
|
|
|
|
params[verificationParams[i].key] = verificationParams[i].value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 判断改包装号是否已经添加
|
|
|
|
|
|
const seen = new Set() |
|
|
|
|
|
const repeatCode = new Set() |
|
|
|
|
|
const arr = tableData.map((item) => item[headerItem.field]?.trim()) |
|
|
|
|
|
arr.forEach((item) => { |
|
|
|
|
|
if (item) { |
|
|
|
|
|
if (seen.has(item)) { |
|
|
|
|
|
repeatCode.add(item) |
|
|
|
|
|
} else { |
|
|
|
|
|
seen.add(item) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
const arr1 = Array.from(repeatCode) |
|
|
|
|
|
if (arr1.length > 0) { |
|
|
|
|
|
message.warning(`${arr1.join(',')}${t('ts.已经存在')}`) |
|
|
|
|
|
row[headerItem.field] = '' |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (filters.length > 0) { |
|
|
|
|
|
params.value.isSearch = true |
|
|
|
|
|
params.value.filters = filters |
|
|
|
|
|
} |
|
|
|
|
|
const obj = { |
|
|
|
|
|
by: 'ASC', |
|
|
|
|
|
pageNo: 1, |
|
|
|
|
|
pageSize: 20 |
|
|
|
|
|
} |
|
|
|
|
|
params.value = { |
|
|
|
|
|
isSearch: params.value.isSearch, |
|
|
|
|
|
filters: params.value.filters, |
|
|
|
|
|
...obj |
|
|
|
|
|
} |
|
|
|
|
|
const list = ref() |
|
|
|
|
|
// 调取包装接口
|
|
|
|
|
|
await headerItem.tableForm.searchPage(params.value).then(async (res) => { |
|
|
|
|
|
|
|
|
|
|
|
list.value = res?.list?.length > 0 ? res.list.slice(0, 1) : [] |
|
|
|
|
|
// 只查一条数据,多条数据查询默认显示不存在
|
|
|
|
|
|
if (list.value?.length == 0) { |
|
|
|
|
|
message.alert('代码' + row[headerItem.field] + '没有找到对应数据') |
|
|
|
|
|
row[headerItem.field] = '' |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
callback(list.value) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
if ( |
|
|
if ( |
|
|
headerItem.field == 'fromPackingNumber' || |
|
|
headerItem.field == 'fromPackingNumber' || |
|
|
headerItem.field == 'packingNumber' || |
|
|
headerItem.field == 'packingNumber' || |
|
@ -219,7 +371,7 @@ export const tableFormBlurVer = async (headerItem, val, row, index,routeName,for |
|
|
list.value = res ? res : [] |
|
|
list.value = res ? res : [] |
|
|
// 只查一条数据,多条数据查询默认显示不存在
|
|
|
// 只查一条数据,多条数据查询默认显示不存在
|
|
|
if (res.length == 1) { |
|
|
if (res.length == 1) { |
|
|
callback(searchField,list.value) |
|
|
callback(list.value) |
|
|
} else { |
|
|
} else { |
|
|
message.alert('代码' + row[headerItem.field] + '没有找到对应数据') |
|
|
message.alert('代码' + row[headerItem.field] + '没有找到对应数据') |
|
|
row[headerItem.field] = '' |
|
|
row[headerItem.field] = '' |
|
@ -228,23 +380,24 @@ export const tableFormBlurVer = async (headerItem, val, row, index,routeName,for |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
export const FormBlur = async (field, val, routeName, formRef, detailData, formSchema, callback) => { |
|
|
export const FormBlur = async (field, val, routeName, formRef, detailData, formSchema, callback) => { |
|
|
if (formSchema.searchPage && formSchema.verificationParams) { |
|
|
if (formSchema.searchPage && formSchema.verificationParams) { |
|
|
//获取data.ts参数信息
|
|
|
//获取data.ts参数信息
|
|
|
let searchCondition = formSchema?.searchCondition || [] |
|
|
const searchCondition = formSchema?.searchCondition || [] |
|
|
//获取失去焦点参数信息
|
|
|
//获取失去焦点参数信息
|
|
|
let verificationParams = formSchema?.verificationParams || |
|
|
const verificationParams = formSchema?.verificationParams || |
|
|
[] |
|
|
[] |
|
|
console.log('走新方法啦') |
|
|
console.log('走新方法啦') |
|
|
// searchCondition = [...searchCondition, ...verificationParams]
|
|
|
// searchCondition = [...searchCondition, ...verificationParams]
|
|
|
|
|
|
|
|
|
if (val && isString(val)) { |
|
|
if (val && isString(val)) { |
|
|
let setV = {} |
|
|
const setV = {} |
|
|
setV[field] = '' |
|
|
setV[field] = '' |
|
|
let params = {} |
|
|
let params = {} |
|
|
const _searchCondition = {} |
|
|
const _searchCondition = {} |
|
|
let filters: any[] = [] |
|
|
const filters: any[] = [] |
|
|
if (searchCondition && searchCondition.length > 0) { |
|
|
if (searchCondition && searchCondition.length > 0) { |
|
|
// 转换筛选条件所需
|
|
|
// 转换筛选条件所需
|
|
|
for (let i = 0; i < searchCondition.length; i++) { |
|
|
for (let i = 0; i < searchCondition.length; i++) { |
|
@ -359,12 +512,13 @@ export const FormBlur = async (field, val, routeName, formRef, detailData, formS |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
console.log(filters) |
|
|
if (filters.length > 0) { |
|
|
if (filters.length > 0) { |
|
|
_searchCondition.isSearch = true |
|
|
_searchCondition.isSearch = true |
|
|
_searchCondition.filters = filters |
|
|
_searchCondition.filters = filters |
|
|
} |
|
|
} |
|
|
console.log(4545, _searchCondition) |
|
|
console.log(4545, _searchCondition) |
|
|
let obj = { |
|
|
const obj = { |
|
|
by: 'ASC', |
|
|
by: 'ASC', |
|
|
pageNo: 1, |
|
|
pageNo: 1, |
|
|
pageSize: 20 |
|
|
pageSize: 20 |
|
@ -382,8 +536,8 @@ export const FormBlur = async (field, val, routeName, formRef, detailData, formS |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
await formSchema.searchPage(params).then((res) => { |
|
|
await formSchema.searchPage(params).then((res) => { |
|
|
let arr1 = val.split(',') |
|
|
const arr1 = val.split(',') |
|
|
let list = ref([]) |
|
|
const list = ref([]) |
|
|
list.value = res?.list?.length > 0 ? res.list.slice(0, 1) : [] |
|
|
list.value = res?.list?.length > 0 ? res.list.slice(0, 1) : [] |
|
|
if (list.value?.length == 0) { |
|
|
if (list.value?.length == 0) { |
|
|
message.alert('暂无数据') |
|
|
message.alert('暂无数据') |
|
@ -391,8 +545,8 @@ export const FormBlur = async (field, val, routeName, formRef, detailData, formS |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if (arr1.length != list.value.length) { |
|
|
if (arr1.length != list.value.length) { |
|
|
let arr2 = list.value.map((item) => item.code) |
|
|
const arr2 = list.value.map((item) => item.code) |
|
|
let str = [ |
|
|
const str = [ |
|
|
...arr1.filter((item) => !arr2.includes(item)), |
|
|
...arr1.filter((item) => !arr2.includes(item)), |
|
|
...arr2.filter((item) => !arr1.includes(item)) |
|
|
...arr2.filter((item) => !arr1.includes(item)) |
|
|
].join(',') |
|
|
].join(',') |
|
|