Browse Source

失去焦点校验

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

168
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 let formSchemaObj = formSchema.value.find((item) => item.field == field)?.componentProps
if (formSchemaObj?.enterSearch) { if (formSchemaObj?.enterSearch) {
if (formSchemaObj.verificationPage) { if (formSchemaObj.searchPage) {
let searchCondition1 = formSchema.value.find((item) => item.field == field).componentProps //data.ts
.searchCondition //data.ts let searchCondition =
let verificationParams = formSchema.value.find((item) => item.field == field).componentProps formSchema.value.find((item) => item.field == field)?.componentProps?.searchCondition || []
.verificationParams // //
let verificationParams =
formSchema.value.find((item) => item.field == field)?.componentProps?.verificationParams ||
[]
console.log('走新方法啦') console.log('走新方法啦')
searchCondition = [...searchCondition, ...verificationParams]
if (e && isString(e)) { if (e && isString(e)) {
let setV = {} let setV = {}
setV[field] = '' setV[field] = ''
let params = {} let params = {}
// keyvalue // keyvalue
if (searchCondition1 && searchCondition1.length > 0) { // if (searchCondition1 && searchCondition1.length > 0) {
for (let i = 0; i < searchCondition1.length; i++) { // for (let i = 0; i < searchCondition1.length; i++) {
if (searchCondition1[i].isMainValue) { // searchCondition1[i].isSearch = true
params[searchCondition1[i].key] = formRef.value.formModel[searchCondition1[i].value] // if (searchCondition1[i].isMainValue) {
? formRef.value.formModel[searchCondition1[i].value] // 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
? props.detailData[searchCondition1[i].value] ? props.detailData[searchCondition[i].value]
: // : row
// ? row[searchCondition[i].value]
e
? e.trim()
: '' : ''
// //
let isNull = false 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 isNull = true
} }
if (isNull) { if (isNull) {
message.warning( message.warning(
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!'
) )
return 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 (searchCondition[i].isSearch) {
if (searchCondition1[i].isFormModel) { if (searchCondition[i].isFormModel) {
//formModel //formModel
if (searchCondition1[i].required) { if (searchCondition[i].required) {
if ( if (
formRef.value.formModel[searchCondition1[i].value] == '' || formRef.value.formModel[searchCondition[i].value] == '' ||
formRef.value.formModel[searchCondition1[i].value] == undefined formRef.value.formModel[searchCondition[i].value] == undefined
) { ) {
message.warning( message.warning(
searchCondition1[i].message searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!'
? searchCondition1[i].message
: '前置条件未选择!'
) )
return 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 { } else {
params[searchCondition1[i].key] = searchCondition1[i].value _searchCondition[searchCondition[i].key] = searchCondition[i].value
} }
} }
} }
if (filters.length > 0) {
_searchCondition.isSearch = true
_searchCondition.filters = filters
} }
// keyvalue
if (verificationParams && verificationParams.length > 0) {
for (let i = 0; i < verificationParams.length; i++) {
params[verificationParams[i].key] = e?.trim()
} }
let obj = {
by: 'ASC',
pageNo: 1,
pageSize: 20
} }
console.log(333,params) params = { ..._searchCondition, ...obj }
// console.log(333,params)
if (!formSchemaObj?.multiple && e.indexOf(',') > -1) { if (!formSchemaObj?.multiple && e.indexOf(',') > -1) {
message.alert('该输入框只能输入一条数据') message.alert('该输入框只能输入一条数据')
formRef.value.setValues(setV) formRef.value.setValues(setV)
return return
} }
await formSchemaObj.verificationPage(params).then((res) => { await formSchemaObj.searchPage(params).then((res) => {
let arr1 = e.split(',') let arr1 = e.split(',')
let list = ref([]) let list = ref([])
list.value = res list.value = res.list
console.log(222, list.value)
if (list.value?.length == 0) { if (list.value?.length == 0) {
message.alert('暂无数据') message.alert('暂无数据')
formRef.value.setValues(setV) formRef.value.setValues(setV)
@ -932,19 +1024,7 @@ const onBlur = async (field, e) => {
formRef.value.setValues(setV) formRef.value.setValues(setV)
return 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 { } else {
if ( if (

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

@ -32,10 +32,13 @@ export const Bom = useCrudSchemas(reactive<CrudSchema[]>([
searchTitle: '物料基础信息', // 查询弹窗标题 searchTitle: '物料基础信息', // 查询弹窗标题
searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类
searchPage: ItembasicApi.selectItembasicPageToFgAndSemibasicPage, // 查询弹窗所需分页方法 searchPage: ItembasicApi.selectItembasicPageToFgAndSemibasicPage, // 查询弹窗所需分页方法
verificationPage: ItembasicApi.getItemListByCodes, // 失去焦点校验输入框的数据内容存在
verificationParams: [{ verificationParams: [{
key: 'codes', key: 'code',
action: '==',
value: '', value: '',
isMainValue: false,
isSearch: 'true',
isFormModel: true
}], // 失去焦点校验参数 }], // 失去焦点校验参数
} }
} }
@ -58,10 +61,13 @@ export const Bom = useCrudSchemas(reactive<CrudSchema[]>([
searchTitle: '物料基础信息', // 查询弹窗标题 searchTitle: '物料基础信息', // 查询弹窗标题
searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类
searchPage: ItembasicApi.selectTypeToItembasic, // 查询弹窗所需分页方法 searchPage: ItembasicApi.selectTypeToItembasic, // 查询弹窗所需分页方法
verificationPage: ItembasicApi.getItemListByCodes, // 失去焦点校验输入框的数据内容存在
verificationParams: [{ verificationParams: [{
key: 'codes', key: 'code',
action: '==',
value: '', value: '',
isMainValue: false,
isSearch: 'true',
isFormModel: true
}], // 失去焦点校验参数 }], // 失去焦点校验参数
} }
} }
@ -114,12 +120,16 @@ export const Bom = useCrudSchemas(reactive<CrudSchema[]>([
searchCondition: [{ searchCondition: [{
key: 'available', key: 'available',
value: 'TRUE', value: 'TRUE',
isMainValue: false isMainValue: false,
}], }],
verificationPage: ProcessApi.getProcessByCodes, // 失去焦点校验输入框的数据内容存在 verificationPage: ProcessApi.getProcessByCodes, // 失去焦点校验输入框的数据内容存在
verificationParams: [{ verificationParams: [{
key: 'codes', key: 'code',
action: '==',
value: '', value: '',
isMainValue: false,
isSearch: 'true',
isFormModel:true
}], // 失去焦点校验参数 }], // 失去焦点校验参数
} }
} }

Loading…
Cancel
Save