Browse Source

失去焦点

hella_online_20240829
zhang_li 4 months ago
parent
commit
5a144e5fdf
  1. 293
      src/api/wms/business/business.ts
  2. 4
      src/api/wms/location/index.ts
  3. 6
      src/components/TableForm/src/TableForm.vue
  4. 52
      src/views/wms/basicDataManage/itemManage/itemarea/itemarea.data.ts

293
src/api/wms/business/business.ts

@ -384,141 +384,190 @@ 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) => {
let pageApi = ref() let tableFormSchemaObj = headerItem?.tableForm
let params = ref({}) console.log(333,tableFormSchemaObj)
let list = ref([]) if (tableFormSchemaObj.searchPage && tableFormSchemaObj.verificationParams) {
let field = 'itemCode' let params = ref({})
// scp采购订单 let list = ref([])
if(!val)return; console.log(3344)
if (routeName == 'PurchaseMain') { let searchCondition1 = headerItem.tableForm.searchCondition //获取data.ts参数信息
pageApi.value = getSupplierItemListByCodes let verificationParams = headerItem.tableForm.verificationParams //获取data.ts参数信息
params.value = { // 循环参数设置参数为key:value格式
supplierCode: formRef.formModel.supplierCode, if (searchCondition1 && searchCondition1.length > 0) {
itemCodes: val?.trim(), for (let i = 0; i < searchCondition1.length; i++) {
available: true if (searchCondition1[i].isMainValue) {
} params.value[searchCondition1[i].key] = formRef.formModel[
} else if (routeName == 'ProductionMain') { searchCondition1[i].value
pageApi.value = getProductionLineCodelistByCodes ]
params.value = { ? formRef.formModel[searchCondition1[i].value]
productionLineCode: formRef.formModel.productionLine, : detailData
itemCodes: val?.trim() ? detailData[searchCondition1[i].value]
} : ''
} else if ( // 是否含有空参数情况
routeName == 'ZZBJDeliverPlanMain' || let isNull = false
routeName == 'DeliverPlanMain' || if (
routeName == 'DeliverRequestMain' || params.value[searchCondition1[i].key] == '' ||
routeName == 'ZZBJDeliverRequestMain' params.value[searchCondition1[i].key] == undefined
) { ) {
// 自制备件发货计划,发货计划,成品发货申请,自制备件发货申请 isNull = true
pageApi.value = getCustomerItemListByCodes }
params.value = { if (isNull) {
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
}
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]
: ''
// 是否含有空参数情况
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 : '前置条件未选择!'
)
return
}
} else if (searchCondition1[i].isTableRowValue) {
if (searchCondition1[i].required) {
if (row[searchCondition1[i].value] == '' || row[searchCondition1[i].value] == undefined) {
message.warning( message.warning(
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!'
) )
return return
} }
} } else if (searchCondition1[i].isTableRowValue) {
row[searchCondition1[i].value] if (searchCondition1[i].required) {
//查询当前table表数据的值 if (row[searchCondition1[i].value] == '' || row[searchCondition1[i].value] == undefined) {
params.value[searchCondition1[i].key] = row[searchCondition1[i].value] message.warning(
} else { searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!'
// 扩展 转换为筛选条件进行查询 )
if (searchCondition1[i].isSearch) { return
if (searchCondition1[i].isFormModel) { }
//用formModel中的值 }
if (searchCondition1[i].required) { row[searchCondition1[i].value]
if ( //查询当前table表数据的值
formRef.formModel[searchCondition1[i].value] == '' || params.value[searchCondition1[i].key] = row[searchCondition1[i].value]
formRef.formModel[searchCondition1[i].value] == undefined } else {
) { // 扩展 转换为筛选条件进行查询
message.warning( if (searchCondition1[i].isSearch) {
searchCondition1[i].message ? searchCondition1[i].message : '前置条件未选择!' if (searchCondition1[i].isFormModel) {
) //用formModel中的值
return 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 {
params.value[searchCondition1[i].key] = searchCondition1[i].value
} }
}else { } else {
params.value[searchCondition1[i].key] = searchCondition1[i].value params.value[searchCondition1[i].key] = searchCondition1[i].value
} }
} else {
params.value[searchCondition1[i].key] = searchCondition1[i].value
} }
} }
} }
} console.log(999, verificationParams)
await pageApi.value(params.value).then(async (res) => { if (verificationParams && verificationParams.length > 0) {
list.value = res ? res : [] for (let i = 0; i < verificationParams.length; i++) {
let arr1 = val.split(',').map(item=>item.trim()) params.value[verificationParams[i].key] = val
if (arr1.length != res.length) { }
let arr2 = res.map((item) => item[field]) }
let str = [ await tableFormSchemaObj.verificationPage(params.value).then(async (res) => {
...arr1.filter((item) => !arr2.includes(item)), list.value = res ? res : []
...arr2.filter((item) => !arr1.includes(item)) let arr1 = val.split(',').map(item => item.trim())
].join(',') if (arr1.length != res.length) {
message.alert('代码' + str + '没有找到对应数据') let arr2 = res.map((item) => item[field])
return let str = [
} else { ...arr1.filter((item) => !arr2.includes(item)),
let repeatCode = [] ...arr2.filter((item) => !arr1.includes(item))
if(tableData.length > 0){ ].join(',')
tableData.forEach((item) => { message.alert('代码' + str + '没有找到对应数据')
const findIndex = arr1.findIndex(valItem=>valItem==item[field]) return
if(findIndex > -1){ } else {
arr1.splice(findIndex,1) let repeatCode = []
repeatCode.push(item.itemCode) 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)
}
})
return
} else {
let pageApi = ref()
let params = ref({})
let list = ref([])
let field = 'itemCode'
// scp采购订单
if (!val) return;
if (routeName == 'PurchaseMain') {
pageApi.value = getSupplierItemListByCodes
params.value = {
supplierCode: formRef.formModel.supplierCode,
itemCodes: val?.trim(),
available: true
} }
if(repeatCode.length>0){ } else if (routeName == 'ProductionMain') {
message.warning(`${t('ts.代码')}${repeatCode.join(',')}${t('ts.已经存在')}`); pageApi.value = getProductionLineCodelistByCodes
return; 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()
} }
callback(list.value)
} }
}) // 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 : []
let arr1 = val.split(',').map(item => item.trim())
if (arr1.length != res.length) {
let arr2 = res.map((item) => item[field])
let str = [
...arr1.filter((item) => !arr2.includes(item)),
...arr2.filter((item) => !arr1.includes(item))
].join(',')
message.alert('代码' + str + '没有找到对应数据')
return
} else {
let 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)
}
})
}
} }

4
src/api/wms/location/index.ts

@ -136,3 +136,7 @@ export const selectConfigToLocation = async (params) => {
return request.get({ url: `/wms/location/pageConfigToLocation`, params }) return request.get({ url: `/wms/location/pageConfigToLocation`, params })
} }
} }
// 根据code获取数据列表
export const getLocationByCodes = async (params) => {
return await request.get({ url: `/wms/location/listByCodes`, params })
}

6
src/components/TableForm/src/TableForm.vue

@ -402,6 +402,8 @@
<div <div
class="p-12px" class="p-12px"
v-if=" v-if="
isShowTableFormSearch||
routeName == 'PurchaseMain' ||
routeName == 'PurchaseMain' || routeName == 'PurchaseMain' ||
routeName == 'ProductionMain' || routeName == 'ProductionMain' ||
routeName == 'ZZBJDeliverPlanMain' || routeName == 'ZZBJDeliverPlanMain' ||
@ -501,6 +503,10 @@ const props = defineProps({
default: '' default: ''
} }
}) })
const isShowTableFormSearch = ref(false)
console.log(33333,props.tableFields)
isShowTableFormSearch.value =props.tableFields.some(item=>item.isShowTableFormSearch)
// //
const emit = defineEmits([ const emit = defineEmits([
'tableSelectionChange', 'tableSelectionChange',

52
src/views/wms/basicDataManage/itemManage/itemarea/itemarea.data.ts

@ -155,12 +155,12 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
searchCondition: [{ searchCondition: [{
key: 'available', key: 'available',
value: 'TRUE', value: 'TRUE',
},{ }, {
key: 'itemCode', key: 'itemCode',
value: 'itemCode', value: 'itemCode',
message: "请选择物料代码", message: "请选择物料代码",
isMainValue: true isMainValue: true
}], }],
verificationParams: [{ verificationParams: [{
key: 'packUnit', key: 'packUnit',
action: '==', action: '==',
@ -195,12 +195,12 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
searchCondition: [{ searchCondition: [{
key: 'available', key: 'available',
value: 'TRUE', value: 'TRUE',
},{ }, {
key: 'itemCode', key: 'itemCode',
value: 'itemCode', value: 'itemCode',
message: "请选择物料代码", message: "请选择物料代码",
isMainValue: true isMainValue: true
}], }],
verificationParams: [{ verificationParams: [{
key: 'packUnit', key: 'packUnit',
action: '==', action: '==',
@ -210,7 +210,7 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
isFormModel: true, isFormModel: true,
required: true, required: true,
message: '请选择物料代码', message: '请选择物料代码',
isBlurParams:true,//是否是失去焦点的方法的参数 isBlurParams: true,//是否是失去焦点的方法的参数
}], // 失去焦点校验参数 }], // 失去焦点校验参数
} }
} }
@ -304,7 +304,7 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
form: { form: {
// labelMessage: '信息提示说明!!!', // labelMessage: '信息提示说明!!!',
componentProps: { componentProps: {
enterSearch:true, enterSearch: true,
isSearchList: true, // 开启查询弹窗 isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择库区代码', // 输入框占位文本 searchListPlaceholder: '请选择库区代码', // 输入框占位文本
searchField: 'code', // 查询弹窗赋值字段 searchField: 'code', // 查询弹窗赋值字段
@ -440,7 +440,7 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
activeValue: 'TRUE' activeValue: 'TRUE'
} }
}, },
isTable:false isTable: false
}, },
{ {
label: '超过高储是否允许叫料', label: '超过高储是否允许叫料',
@ -456,7 +456,7 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
activeValue: 'TRUE' activeValue: 'TRUE'
} }
}, },
isTable:false isTable: false
}, },
{ {
label: '优先空库位', label: '优先空库位',
@ -623,7 +623,7 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
}, },
table: { table: {
width: 150 width: 150
} , },
form: { form: {
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
@ -642,7 +642,7 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
}, },
table: { table: {
width: 150 width: 150
} , },
form: { form: {
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
@ -704,7 +704,7 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom', sort: 'custom',
table: { table: {
width: 120 width: 120
} , },
}, },
{ {
label: '操作', label: '操作',
@ -744,8 +744,8 @@ export const ItemareaDetail = useCrudSchemas(reactive<CrudSchema[]>([
label: '库位代码', label: '库位代码',
field: 'locationCode', field: 'locationCode',
sort: 'custom', sort: 'custom',
tableForm:{ tableForm: {
multiple:true,//多选 multiple: true,//多选
isInpuFocusShow: true, // 开启查询弹窗 isInpuFocusShow: true, // 开启查询弹窗
searchListPlaceholder: '请选择库位代码', // 输入框占位文本 searchListPlaceholder: '请选择库位代码', // 输入框占位文本
searchField: 'code', // 查询弹窗赋值字段 searchField: 'code', // 查询弹窗赋值字段
@ -756,18 +756,28 @@ export const ItemareaDetail = useCrudSchemas(reactive<CrudSchema[]>([
key: 'available', key: 'available',
value: 'TRUE', value: 'TRUE',
isMainValue: false isMainValue: false
},{ }, {
key: 'areaCode', key: 'areaCode',
value: 'areaCode', value: 'areaCode',
message: '请选择区域代码!', message: '请选择区域代码!',
isMainValue: true isMainValue: true
}] }],
verificationParams: [{
key: 'codes',
action: '==',
value: '',
isMainValue: false,
isSearch: true,
isFormModel: true,
}],
verificationPage: LocationApi.getLocationByCodes, // 校验数去焦点输入是否正确的方法
isShowTableFormSearch: true, //
}, },
form: { form: {
// labelMessage: '信息提示说明!!!', // labelMessage: '信息提示说明!!!',
componentProps: { componentProps: {
isSearchList: true, // 开启查询弹窗 isSearchList: true, // 开启查询弹窗
multiple:true,//多选 multiple: true,//多选
searchListPlaceholder: '请选择库位代码', // 输入框占位文本 searchListPlaceholder: '请选择库位代码', // 输入框占位文本
searchField: 'code', // 查询弹窗赋值字段 searchField: 'code', // 查询弹窗赋值字段
searchTitle: '库位基础信息', // 查询弹窗标题 searchTitle: '库位基础信息', // 查询弹窗标题
@ -777,11 +787,19 @@ export const ItemareaDetail = useCrudSchemas(reactive<CrudSchema[]>([
key: 'available', key: 'available',
value: 'TRUE', value: 'TRUE',
isMainValue: false isMainValue: false
},{ }, {
key: 'areaCode', key: 'areaCode',
value: 'areaCode', value: 'areaCode',
message: '请选择区域代码!', message: '请选择区域代码!',
isMainValue: true isMainValue: true
}],
verificationParams: [{
key: 'code',
action: '==',
value: '',
isMainValue: false,
isSearch: true,
isFormModel: true,
}] }]
} }
} }

Loading…
Cancel
Save