Browse Source

失去焦点逻辑调整

hella_online_20240829
zhang_li 4 months ago
parent
commit
9144c089f3
  1. 437
      src/api/wms/business/inputBlur.ts

437
src/api/wms/business/inputBlur.ts

@ -203,212 +203,6 @@ export const tableFormBlurVer = async (headerItem, val, row, index, routeName, f
callback(list.value)
})
}
} else {
if (
headerItem.field == 'fromPackingNumber' ||
headerItem.field == 'packingNumber' ||
headerItem.field == 'itemCode' ||
headerItem.field == 'packUnit' ||
headerItem.field == 'secondPackUnit' ||
headerItem.field == 'fromPackUnit' ||
headerItem.field == 'toPackUnit' ||
headerItem.field == 'toPackUnit' ||
headerItem.field == 'supplierItemCode'
) {
let searchField = headerItem.field
let pageApi = ref()
let params = ref()
if (val && isString(val)) {
// const obj = props.tableAllSchemas.tableFormColumns.find((item) => item.field == headerItem.field)
if (val.indexOf(',') > -1) {
message.alert('该输入框只能输入一条数据')
row[headerItem.field] = ''
return
}
// 校验
let params = ref({})
let searchCondition1 = headerItem.tableForm.searchCondition //获取data.ts参数信息
// 循环参数设置参数为key:value格式
if (searchCondition1 && searchCondition1.length > 0) {
for (let i = 0; i < searchCondition1.length; i++) {
if (searchCondition1[i].isMainValue) {
params.value[searchCondition1[i].key] = formRef.formModel[
searchCondition1[i].value
]
? formRef.formModel[searchCondition1[i].value]
: detailData
? detailData[searchCondition1[i].value]
: row
? row[searchCondition1[i].value]
: ''
// 是否含有空参数情况
let isNull = false
if (
params.value[searchCondition1[i].key] == '' ||
params.value[searchCondition1[i].key] == undefined
) {
isNull = true
}
if (isNull) {
message.warning(
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!'
)
row[headerItem.field] = ''
return
}
} else {
// 扩展 转换为筛选条件进行查询
if (searchCondition1[i].isSearch) {
if (searchCondition1[i].isFormModel) {
//用formModel中的值
if (searchCondition1[i].required) {
if (
formRef.formModel[searchCondition1[i].value] == '' ||
formRef.formModel[searchCondition1[i].value] == undefined
) {
message.warning(
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!'
)
row[headerItem.field] = ''
return
}
}
}
} else {
params.value[searchCondition1[i].key] = searchCondition1[i].value
}
}
}
}
params.value[headerItem.field] = val?.trim()
// 判断改包装号是否已经添加
const seen = new Set()
const repeatCode = new Set()
let arr = tableData.map((item) => item[headerItem.field]?.trim())
arr.forEach((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 (
headerItem.field == 'fromPackingNumber' ||
headerItem.field == 'packingNumber' ||
headerItem.field == 'itemCode'
) {
// 业务
// 采购退货申请,制品拆解,调拨出库,报废出库申请,合格转隔离,隔离转合格,隔离转报废,合格转报废,报废转隔离,库存移动申请,库存修改申请
if (
routeName == 'PurchasereturnRequestMain' ||
routeName == 'ProductdismantleRequestMain' ||
routeName == 'TransferissueRequestMain' ||
routeName == 'ScrapRequestMain' ||
routeName == 'OktoholdRequestMain' ||
routeName == 'HoldtookRequestMain' ||
routeName == 'HoldtoscrapRequestMain' ||
routeName == 'OktoscrapRequestMain' ||
routeName == 'ScraptoholdRequestMain' ||
routeName == 'InventorymoveRequestMain' ||
routeName == 'InventorychangeRequestMain'
) {
// //合格转隔离,隔离转合格,隔离转报废,合格转报废,报废转隔离,库存移动申请参数稍有不同
// if (
// routeName == 'OktoholdRequestMain' ||
// routeName == 'HoldtookRequestMain' ||
// routeName == 'HoldtoscrapRequestMain' ||
// routeName == 'OktoscrapRequestMain' ||
// routeName == 'ScraptoholdRequestMain' ||
// routeName == 'InventorymoveRequestMain' ||
// routeName == 'InventorychangeRequestMain'
// ) {
// searchField = 'packingNumber'
// params.value.packingNumber = val?.trim()
// }
// pageApi.value = getBalanceItemListByCodes
} else if (
routeName == 'RepleinshRequestMain' ||
routeName == 'IssueRequestMain' ||
routeName == 'InventoryinitRequestMain'
) {
// 补料申请业务
pageApi.value = getItemListByCodes
searchField = 'code'
params.value.codes = val?.trim()
} else if (
routeName == 'ProductionMainAssemble' ||
routeName == 'ProductionMainASparePart' ||
routeName == 'ProductionMainPredictSparePart' ||
routeName == 'ProductreceiptRequestMain' ||
routeName == 'ProductreceiptRequestMainA' ||
routeName == 'ProductreceiptscrapRequestMain' ||
routeName == 'ProductscrapRequestMain'
) {
// 装配计划,裝配备件计划,预备产件计划,预生产收货申请,装配收货申请,报修收货申请,制品报废申请
pageApi.value = getProductionLineCodelistByCodes
params.value.productionLineCode =
formRef.formModel.productionLine || formRef.formModel.productionLineCode || row.productionLine || row.productionLineCode,
params.value.itemCodes = val?.trim()
}
} else if (
headerItem.field == 'packUnit' ||
headerItem.field == 'secondPackUnit' ||
headerItem.field == 'fromPackUnit' ||
headerItem.field == 'toPackUnit'
) {
searchField = 'packUnit'
//包装规格
// 预生产收货申请,装配收货申请,报修收货申请,客户退货申请,计划外入库,计划外出库,翻包申请
if (
routeName == 'ProductreceiptRequestMain' ||
routeName == 'ProductreceiptRequestMainA' ||
routeName == 'ProductreceiptscrapRequestMain' ||
routeName == 'CustomerreturnRequestMain' ||
routeName == 'UnplannedreceiptRequestMain' ||
routeName == 'UnplannedissueJobMain' ||
routeName == 'PackageoverRequestMain'
) {
params.value.itemCode = row.itemCode
params.value.packUnit = val?.trim()
pageApi.value = getItemPackageunitListByCodes
}
} else if (
headerItem.field == 'supplierItemCode'
) {
// 生产退料申请,隔离退料申请
if (
routeName == 'ProductionreturnRequestMain' ||
routeName == 'ProductionreturnRequestMainNo'
) {
searchField = 'supplierCode'
params.value.itemCodes = row.itemCode
params.value.supplierCode = val?.trim()
pageApi.value = getSupplierItemListByCodes
}
}
const list = ref()
// 调取包装接口
await pageApi.value(params.value).then(async (res) => {
list.value = res ? res : []
// 只查一条数据,多条数据查询默认显示不存在
if (res.length == 1) {
callback(list.value)
} else {
message.alert('代码' + row[headerItem.field] + '没有找到对应数据')
row[headerItem.field] = ''
return
}
})
}
}
}
}
export const FormBlur = async (field, val, routeName, formRef, detailData, formSchema, callback) => {
@ -587,164 +381,14 @@ export const FormBlur = async (field, val, routeName, formRef, detailData, formS
})
}
}
else {
let pageApi = ref()
let params = ref()
let setV = {}
setV[field] = ''
if (val && isString(val)) {
if (
field == 'supplierCode' ||
field == 'itemCode' ||
field == 'productItemCode' ||
field == 'componentItemCode' ||
field == 'packUnit' ||
field == 'inPackUnit' ||
field == 'fromPackingNumber'
) {
let searchField = 'code'
if (field == 'supplierCode') {
params.value = val?.trim()
pageApi.value = getSupplierListByCodes
} else if (
field == 'itemCode' ||
field == 'productItemCode' ||
field == 'componentItemCode'
) {
// 销售价格单
if (routeName == 'Saleprice') {
params.value = {
customerCode: formRef.formModel.customerCode,
itemCodes: val?.trim()
}
pageApi.value = getCustomerItemListByCodes
searchField = 'itemCode'
} else if (routeName == 'ProductscrapRequestMain') {
// 制品报废申请
params.value = {
productionLineCode:
detailData.productionLine || detailData.productionLineCode,
itemCodes: val?.trim()
}
pageApi.value = getProductionLineCodelistByCodes
searchField = 'itemCode'
} else {
// params.value = val.trim()
searchField = 'code'
params.value = {
codes: val?.trim()
}
pageApi.value = getItemListByCodes
}
} else if (field == 'packUnit') {
if (routeName == 'Itemwarehouse' || routeName == 'Callmaterials') {//物料仓库默认配置,叫料标签
searchField = 'packUnit'
params.value = {
itemCode: formRef.formModel.itemCode,
packUnit: val?.trim()
}
pageApi.value = getItemPackageunitListByCodes
} else {
params.value = val?.trim()
pageApi.value = getPackageunitListByCodes
}
} else if (field == 'inPackUnit') {
params.value = {
itemCode: formRef.formModel.itemCode,
packUnit: val.trim()
}
pageApi.value = getItemPackageunitListByCodes
}
// else if (formField == 'fromPackingNumber') {
// params.value = {
// packingNumber: val?.trim()
// }
// pageApi.value = getBalanceItemListByCodes
// }
let obj = {}
let searchCondition1 = formSchema.searchCondition //获取data.ts参数信息
// 循环参数设置参数为key:value格式
if (searchCondition1 && searchCondition1.length > 0) {
for (let i = 0; i < searchCondition1.length; i++) {
if (searchCondition1[i].isMainValue) {
obj[searchCondition1[i].key] = formRef.formModel[searchCondition1[i].value]
? formRef.formModel[searchCondition1[i].value]
: detailData
? detailData[searchCondition1[i].value]
: ''
// 是否含有空参数情况
let isNull = false
if (obj[searchCondition1[i].key] == '' || obj[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.formModel[searchCondition1[i].value] == '' ||
formRef.formModel[searchCondition1[i].value] == undefined
) {
message.warning(
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!'
)
return
}
}
}
} else {
obj[searchCondition1[i].key] = searchCondition1[i].value
}
}
}
}
if (!formSchema.multiple && val.indexOf(',') > -1) {
message.alert('该输入框只能输入一条数据')
formRef.setValues(setV)
return
}
await pageApi.value(params.value).then((res) => {
let arr1 = val.split(',')
let list = ref([])
list.value = res
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
}
// emit('searchTableSuccess', formField, searchField, list.value, formRef.value, 'form')
callback(list.value)
})
}
}
}
}
// 根据下方输入框失去焦点校验信息
export const getListByBottonInput = async (headerItem, val, row, routeName, formRef, detailData, tableData, callback) => {
const tableFormSchemaObj = headerItem?.tableForm
console.log(333, tableFormSchemaObj)
if (tableFormSchemaObj.searchPage && tableFormSchemaObj.verificationParams) {
if (tableFormSchemaObj.verificationPage && tableFormSchemaObj.verificationParams) {
if (!val) return;
const params = ref({})
const list = ref([])
@ -856,83 +500,6 @@ export const getListByBottonInput = async (headerItem, val, row, routeName, form
callback(list.value)
})
return
} else {
const pageApi = ref()
const params = ref({})
const list = ref([])
const field = 'itemCode'
// scp采购订单
if (!val) return;
if (routeName == 'PurchaseMain') {
pageApi.value = getSupplierItemListByCodes
params.value = {
supplierCode: formRef.formModel.supplierCode,
itemCodes: val?.trim(),
available: true
}
} else if (routeName == 'ProductionMain') {
pageApi.value = getProductionLineCodelistByCodes
params.value = {
productionLineCode: formRef.formModel.productionLine,
itemCodes: val?.trim()
}
} else if (
routeName == 'ZZBJDeliverPlanMain' ||
routeName == 'DeliverPlanMain' ||
routeName == 'DeliverRequestMain' ||
routeName == 'ZZBJDeliverRequestMain'
) {
// 自制备件发货计划,发货计划,成品发货申请,自制备件发货申请
pageApi.value = getCustomerItemListByCodes
params.value = {
customerCode: formRef.formModel.customerCode,
itemCodes: val?.trim()
}
}
// else if (routeName == 'UnplannedissueRequestMain') {
// // 计划外出库
// pageApi.value = getBalanceItemListByCodes
// params.value = {
// packingNumber: val?.trim()
// }
// field = 'packingNumber'
// }
else {
params.value.codes = val?.trim()
pageApi.value = getItemListByCodes
}
await pageApi.value(params.value).then(async (res) => {
list.value = res ? res : []
const arr1 = val.split(',').map(item => item.trim())
if (arr1.length != res.length) {
const arr2 = res.map((item) => item[field])
const str = [
...arr1.filter((item) => !arr2.includes(item)),
...arr2.filter((item) => !arr1.includes(item))
].join(',')
message.alert('代码' + str + '没有找到对应数据')
return
} else {
const repeatCode = []
if (tableData.length > 0) {
tableData.forEach((item) => {
const findIndex = arr1.findIndex(valItem => valItem == item[field])
if (findIndex > -1) {
arr1.splice(findIndex, 1)
repeatCode.push(item.itemCode)
}
})
}
if (repeatCode.length > 0) {
message.warning(`${t('ts.代码')}${repeatCode.join(',')}${t('ts.已经存在')}`);
return;
}
callback(list.value)
}
})
}
}

Loading…
Cancel
Save