Browse Source

失去焦点组件修改

hella_online_20240829
zhang_li 4 months ago
parent
commit
f77172334c
  1. 210
      src/api/wms/business/business.ts
  2. 198
      src/components/BasicForm/src/BasicForm.vue
  3. 22
      src/views/wms/basicDataManage/documentSetting/businesstype/businesstype.data.ts
  4. 2
      src/views/wms/basicDataManage/supplierManage/supplieritem/supplieritem.data.ts

210
src/api/wms/business/business.ts

@ -229,29 +229,202 @@ export const tableFormBlurVer = async (headerItem, val, row, index,routeName,for
} }
} }
} }
export const FormBlur = async (formField, val,routeName,formRef,detailData,formSchema,callback) => { 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[searchCondition[i].value]
: // : row
// ? row[searchCondition[i].value]
''
// 是否含有空参数情况
let isNull = false
if (
_searchCondition[searchCondition[i].key] == '' ||
_searchCondition[searchCondition[i].key] == undefined
) {
isNull = true
}
if (isNull) {
message.warning(
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!'
)
return
}
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 (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 : '前置条件未选择!'
)
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 {
filters.push({
action: searchCondition[i].action || '==',
column: searchCondition[i].key,
value: 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()
})
} 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 formSchema.searchPage(params).then((res) => {
let arr1 = val.split(',')
let list = ref([])
list.value = res?.list?.length > 0 ? res.list.slice(0, 1) : []
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
}
callback(list.value)
})
}
}
else {
let pageApi = ref() let pageApi = ref()
let params = ref() let params = ref()
let setV = {} let setV = {}
setV[formField] = '' setV[field] = ''
if (val && isString(val)) { if (val && isString(val)) {
if ( if (
formField == 'supplierCode' || field == 'supplierCode' ||
formField == 'itemCode' || field == 'itemCode' ||
formField == 'productItemCode' || field == 'productItemCode' ||
formField == 'componentItemCode' || field == 'componentItemCode' ||
formField == 'packUnit' || field == 'packUnit' ||
formField == 'inPackUnit' || field == 'inPackUnit' ||
formField == 'fromPackingNumber' field == 'fromPackingNumber'
) { ) {
let searchField = 'code' let searchField = 'code'
if (formField == 'supplierCode') { if (field == 'supplierCode') {
params.value = val?.trim() params.value = val?.trim()
pageApi.value = getSupplierListByCodes pageApi.value = getSupplierListByCodes
} else if ( } else if (
formField == 'itemCode' || field == 'itemCode' ||
formField == 'productItemCode' || field == 'productItemCode' ||
formField == 'componentItemCode' field == 'componentItemCode'
) { ) {
// 销售价格单 // 销售价格单
if (routeName == 'Saleprice') { if (routeName == 'Saleprice') {
@ -279,7 +452,7 @@ export const FormBlur = async (formField, val,routeName,formRef,detailData,formS
} }
pageApi.value = getItemListByCodes pageApi.value = getItemListByCodes
} }
} else if (formField == 'packUnit') { } else if (field == 'packUnit') {
if (routeName == 'Itemwarehouse' || routeName == 'Callmaterials') {//物料仓库默认配置,叫料标签 if (routeName == 'Itemwarehouse' || routeName == 'Callmaterials') {//物料仓库默认配置,叫料标签
searchField = 'packUnit' searchField = 'packUnit'
params.value = { params.value = {
@ -291,7 +464,7 @@ export const FormBlur = async (formField, val,routeName,formRef,detailData,formS
params.value = val?.trim() params.value = val?.trim()
pageApi.value = getPackageunitListByCodes pageApi.value = getPackageunitListByCodes
} }
} else if (formField == 'inPackUnit') { } else if (field == 'inPackUnit') {
params.value = { params.value = {
itemCode: formRef.formModel.itemCode, itemCode: formRef.formModel.itemCode,
packUnit: val.trim() packUnit: val.trim()
@ -305,8 +478,7 @@ export const FormBlur = async (formField, val,routeName,formRef,detailData,formS
// pageApi.value = getBalanceItemListByCodes // pageApi.value = getBalanceItemListByCodes
// } // }
let obj = {} let obj = {}
let searchCondition1 = formSchema.find((item) => item.field == formField).componentProps let searchCondition1 = formSchema.searchCondition //获取data.ts参数信息
.searchCondition //获取data.ts参数信息
// 循环参数设置参数为key:value格式 // 循环参数设置参数为key:value格式
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++) {
@ -351,8 +523,7 @@ export const FormBlur = async (formField, val,routeName,formRef,detailData,formS
} }
} }
let obj1 = formSchema.find((item) => item.field == formField) if (!formSchema.multiple && val.indexOf(',') > -1) {
if (!obj1.componentProps.multiple && val.indexOf(',') > -1) {
message.alert('该输入框只能输入一条数据') message.alert('该输入框只能输入一条数据')
formRef.setValues(setV) formRef.setValues(setV)
return return
@ -382,6 +553,7 @@ export const FormBlur = async (formField, val,routeName,formRef,detailData,formS
} }
} }
} }
}
// 根据下方输入框失去焦点校验信息 // 根据下方输入框失去焦点校验信息
export const getListByBottonInput = async (headerItem, val, row, routeName, formRef, detailData, tableData, callback) => { export const getListByBottonInput = async (headerItem, val, row, routeName, formRef, detailData, tableData, callback) => {

198
src/components/BasicForm/src/BasicForm.vue

@ -843,203 +843,11 @@ const onChange = (field, cur) => {
const onBlur = async (field, e) => { const onBlur = async (field, e) => {
isExecute.value = false isExecute.value = false
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.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)) { if (formSchemaObj?.enterSearch) {
let setV = {} await FormBlur(field, e, routeName.value, formRef.value, props.detailData, formSchemaObj, (list) => {
setV[field] = '' emit('searchTableSuccess', field, formSchemaObj.searchField, list, formRef.value, 'form')
let params = {}
const _searchCondition = {}
let filters: any[] = []
if (searchCondition && searchCondition.length > 0) {
//
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[searchCondition[i].value]
: // : row
// ? row[searchCondition[i].value]
''
//
let isNull = false
if (
_searchCondition[searchCondition[i].key] == '' ||
_searchCondition[searchCondition[i].key] == undefined
) {
isNull = true
}
if (isNull) {
message.warning(
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!'
)
return
}
filters.push({
action: searchCondition[i].action || '==',
column: searchCondition[i].key,
value: formRef.value.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 (searchCondition[i].isSearch) {
if (searchCondition[i].isFormModel) {
//formModel
if (searchCondition[i].required) {
if (
formRef.value.formModel[searchCondition[i].value] == '' ||
formRef.value.formModel[searchCondition[i].value] == undefined
) {
message.warning(
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!'
)
return
}
}
filters.push({
action: searchCondition[i].action || '==',
column: searchCondition[i].key,
value: formRef.value.formModel[searchCondition[i].value]
})
} else {
filters.push({
action: searchCondition[i].action || '==',
column: searchCondition[i].key,
value: searchCondition[i].value
})
}
} else {
filters.push({
action: searchCondition[i].action || '==',
column: searchCondition[i].key,
value: searchCondition[i].value
})
}
}
}
}
if (verificationParams && verificationParams.length > 0) {
//
for (var 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.value.formModel[verificationParams[i].value]
? formRef.value.formModel[verificationParams[i].value]
: e.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 (!formSchemaObj?.multiple && e.indexOf(',') > -1) {
message.alert('该输入框只能输入一条数据')
formRef.value.setValues(setV)
return
}
await formSchemaObj.searchPage(params).then((res) => {
let arr1 = e.split(',')
let list = ref([])
list.value = res?.list?.length>0 ? res.list.slice(0,1) : []
if (list.value?.length == 0) {
message.alert('暂无数据')
formRef.value.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.value.setValues(setV)
return
}
}) })
}
} else {
if (
field == 'supplierCode' ||
field == 'itemCode' ||
field == 'productItemCode' ||
field == 'componentItemCode' ||
field == 'packUnit' ||
field == 'inPackUnit' ||
field == 'fromPackingNumber'
) {
await FormBlur(
field,
e,
routeName.value,
formRef.value,
props.detailData,
formSchema.value,
(searchField, list) => {
emit('searchTableSuccess', field, searchField, list, formRef.value, 'form')
}
)
return
}
}
} else { } else {
emit('onBlur', field, e) emit('onBlur', field, e)
} }

22
src/views/wms/basicDataManage/documentSetting/businesstype/businesstype.data.ts

@ -112,12 +112,21 @@ export const Businesstype = useCrudSchemas(reactive<CrudSchema[]>([
form: { form: {
// labelMessage: '信息提示说明!!!', // labelMessage: '信息提示说明!!!',
componentProps: { componentProps: {
enterSearch: true,
isSearchList: true, // 开启查询弹窗 isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择库区代码', // 输入框占位文本 searchListPlaceholder: '请选择库区代码', // 输入框占位文本
searchField: 'code', // 查询弹窗赋值字段 searchField: 'code', // 查询弹窗赋值字段
searchTitle: '库区信息', // 查询弹窗标题 searchTitle: '库区信息', // 查询弹窗标题
searchAllSchemas: Area.allSchemas, // 查询弹窗所需类 searchAllSchemas: Area.allSchemas, // 查询弹窗所需类
searchPage: AreaApi.getAreaPage // 查询弹窗所需分页方法 searchPage: AreaApi.getAreaPage, // 查询弹窗所需分页方法
verificationParams: [{
key: 'code',
action: '==',
value: '',
isMainValue: false,
isSearch: true,
isFormModel: true,
}], // 失去焦点校验参数
} }
} }
}, },
@ -131,12 +140,21 @@ export const Businesstype = useCrudSchemas(reactive<CrudSchema[]>([
form: { form: {
// labelMessage: '信息提示说明!!!', // labelMessage: '信息提示说明!!!',
componentProps: { componentProps: {
enterSearch: true,
isSearchList: true, // 开启查询弹窗 isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择库区代码', // 输入框占位文本 searchListPlaceholder: '请选择库区代码', // 输入框占位文本
searchField: 'code', // 查询弹窗赋值字段 searchField: 'code', // 查询弹窗赋值字段
searchTitle: '库区信息', // 查询弹窗标题 searchTitle: '库区信息', // 查询弹窗标题
searchAllSchemas: Area.allSchemas, // 查询弹窗所需类 searchAllSchemas: Area.allSchemas, // 查询弹窗所需类
searchPage: AreaApi.getAreaPage // 查询弹窗所需分页方法 searchPage: AreaApi.getAreaPage, // 查询弹窗所需分页方法
verificationParams: [{
key: 'code',
action: '==',
value: '',
isMainValue: false,
isSearch: true,
isFormModel: true,
}], // 失去焦点校验参数
} }
} }
}, },

2
src/views/wms/basicDataManage/supplierManage/supplieritem/supplieritem.data.ts

@ -80,7 +80,7 @@ export const Supplieritem = useCrudSchemas(reactive<CrudSchema[]>([
isMainValue: false isMainValue: false
}], }],
verificationParams: [{ verificationParams: [{
key: 'itemCode', key: 'code',
action: '==', action: '==',
value: '', value: '',
isMainValue: false, isMainValue: false,

Loading…
Cancel
Save