Browse Source

失去焦点校验

hella_online_20240829
zhang_li 5 months ago
parent
commit
5d4292c6a0
  1. 170
      src/components/BasicForm/src/BasicForm.vue
  2. 22
      src/views/wms/basicDataManage/itemManage/bom/bom.data.ts

170
src/components/BasicForm/src/BasicForm.vue

@ -844,79 +844,171 @@ const onBlur = async (field, e) => {
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) {
//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 = {}
// keyvalue
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
}
}
}
}
// keyvalue
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 +1024,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 (

22
src/views/wms/basicDataManage/itemManage/bom/bom.data.ts

@ -32,10 +32,13 @@ export const Bom = useCrudSchemas(reactive<CrudSchema[]>([
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<CrudSchema[]>([
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<CrudSchema[]>([
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
}], // 失去焦点校验参数
}
}

Loading…
Cancel
Save