diff --git a/src/api/wms/process/index.ts b/src/api/wms/process/index.ts index c9e5d1d5f..dda9c6de1 100644 --- a/src/api/wms/process/index.ts +++ b/src/api/wms/process/index.ts @@ -62,4 +62,9 @@ export const importTemplate = () => { // 查询工序列表 export const getProcessNoPage = async (params) => { return await request.get({ url: `/wms/process/noPage`, params }) +} + +// 根据code获取数据列表 +export const getProcessByCodes = async (params) => { + return await request.get({ url: `/wms/process/listByCodes`, params }) } \ No newline at end of file diff --git a/src/api/wms/warehouse/index.ts b/src/api/wms/warehouse/index.ts index 96e64a813..6c0e25b15 100644 --- a/src/api/wms/warehouse/index.ts +++ b/src/api/wms/warehouse/index.ts @@ -69,4 +69,8 @@ export const pageBusinessTypeToWarehouse = async (params) => { } else { return await request.get({ url: `/wms/warehouse/pageBusinessTypeToWarehouse`, params }) } +} +// 根据code获取数据列表 +export const getWarehouseByCodes = async (params) => { + return await request.get({ url: `/wms/warehouse/listByCodes`, params }) } \ No newline at end of file diff --git a/src/components/BasicForm/src/BasicForm.vue b/src/components/BasicForm/src/BasicForm.vue index c9d62bbca..b9313b4c6 100644 --- a/src/components/BasicForm/src/BasicForm.vue +++ b/src/components/BasicForm/src/BasicForm.vue @@ -142,6 +142,7 @@ import TableForm from '@/components/TableForm/src/TableForm.vue' import TableFormCountPlan from '@/components/TableFormCountPlan/src/TableFormCountPlan.vue' import {DICT_TYPE, getStrDictOptions} from '@/utils/dict' import { tableFormBlurVer,FormBlur,getListByBottonInput } from '@/api/wms/business/business' +import { isString } from 'min-dash' const props = defineProps({ // 显示窗口宽度设置 basicFormWidth: { @@ -324,7 +325,17 @@ const props = defineProps({ type: Array, required: false, default: [] - } + }, + byCodespageApi: { + type: Function, + required: true, + default: null + }, //输入框校验是否正确的方法 + byCodesParams: { + type: Object, + required: true, + default: null + } //输入框校验是否正确的参数 }) const { t } = useI18n() // 国际化 @@ -783,15 +794,135 @@ const onChange = (field, cur) => { * @param field 当前操作字段 * @param e */ - const onBlur = async (field, e) => { +const onBlur = async (field, e) => { isExecute.value = false - await FormBlur(field, e,routeName.value,formRef.value,props.detailData,formSchema.value,(searchField, list)=>{ - emit('searchTableSuccess', field, searchField, list, formRef.value, 'form') - }) + 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') + } + ) + } else { + let formSchemaObj = formSchema.value.find((item) => item.field == field) + let searchCondition1 = formSchema.value.find((item) => item.field == field).componentProps + .searchCondition //获取data.ts参数信息 + if (formSchemaObj?.componentProps?.enterSearch) { + if (e && isString(e)) { + let setV = {} + setV[field] = '' + let obj = {} +console.log(233,searchCondition1) + // 循环参数设置参数为key:value格式 + if (searchCondition1 && searchCondition1.length > 0) { + for (let i = 0; i < searchCondition1.length; i++) { + if (searchCondition1[i].isMainValue) { + obj[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 (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.value.formModel[searchCondition1[i].value] == '' || + formRef.value.formModel[searchCondition1[i].value] == undefined + ) { + message.warning( + searchCondition1[i].message + ? searchCondition1[i].message + : '前置条件未选择!' + ) + return + } + } + } + obj[searchCondition1[i].key] = searchCondition1[i].value + } else { + obj[searchCondition1[i].key] = searchCondition1[i].value + } + } + } + } + if (!formSchemaObj?.componentProps.multiple && e.indexOf(',') > -1) { + message.alert('该输入框只能输入一条数据') + formRef.value.setValues(setV) + return + } + if (props.byCodespageApi) { + let params = {} + if (props.byCodesParams) { + params = { ...props.byCodesParams, ...obj, codes: e } + } else { + params = { ...obj, codes: e } + } + await props.byCodespageApi(params).then((res) => { + let arr1 = e.split(',') + let list = ref([]) + list.value = res + 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 + } + emit( + 'searchTableSuccess', + field, + searchCondition1.searchField, + list, + formRef.value, + 'form' + ) + }) + } + } + } else { + emit('onBlur', field, e) + } + } isExecute.value = true emit('onBlur', field, e) } + // 批量增加 const batchAdd = async (val) => { const row = {} diff --git a/src/views/wms/basicDataManage/factoryModeling/areabasic/index.vue b/src/views/wms/basicDataManage/factoryModeling/areabasic/index.vue index c9ad73d84..15046fcca 100644 --- a/src/views/wms/basicDataManage/factoryModeling/areabasic/index.vue +++ b/src/views/wms/basicDataManage/factoryModeling/areabasic/index.vue @@ -48,6 +48,7 @@ :apiCreate="AreaApi.createArea" @searchTableSuccess="searchTableSuccess" :isBusiness="false" + @onBlur="onBlur" /> @@ -267,6 +268,10 @@ const searchFormClick = (searchData) => { } getList() // 刷新当前列表 } +// 失去焦点 +const onBlur = (field, e)=>{ + +} /** 初始化 **/ onMounted(async() => { diff --git a/src/views/wms/basicDataManage/itemManage/bom/index.vue b/src/views/wms/basicDataManage/itemManage/bom/index.vue index f15170e8b..e6becb72c 100644 --- a/src/views/wms/basicDataManage/itemManage/bom/index.vue +++ b/src/views/wms/basicDataManage/itemManage/bom/index.vue @@ -48,6 +48,7 @@ :apiCreate="BomApi.createBom" @searchTableSuccess="searchTableSuccess" :isBusiness="false" + :byCodespageApi="ProcessApi.getProcessByCodes" /> @@ -66,6 +67,7 @@ import * as defaultButtons from '@/utils/disposition/defaultButtons' import TableHead from '@/components/TableHead/src/TableHead.vue' import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import Detail from '@/components/Detail/src/Detail.vue' +import * as ProcessApi from "@/api/wms/process"; // 物料清单bom defineOptions({ name: 'Bom' }) @@ -277,7 +279,10 @@ const searchFormClick = (searchData) => { } getList() // 刷新当前列表 } - +// 失去焦点 +// const onBlur = (field, e)=>{ +// ProcessApi.getProcessByCodes().then() +// } /** 初始化 **/ onMounted(async () => { getList() diff --git a/src/views/wms/basicDataManage/itemManage/itemwarehouse/index.vue b/src/views/wms/basicDataManage/itemManage/itemwarehouse/index.vue index 6ec0e6347..c2c403729 100644 --- a/src/views/wms/basicDataManage/itemManage/itemwarehouse/index.vue +++ b/src/views/wms/basicDataManage/itemManage/itemwarehouse/index.vue @@ -48,6 +48,7 @@ :apiCreate="ItemwarehouseApi.createItemwarehouse" @searchTableSuccess="searchTableSuccess" :isBusiness="false" + :byCodespageApi="WarehouseApi.getWarehouseByCodes" /> @@ -65,6 +66,7 @@ import * as defaultButtons from '@/utils/disposition/defaultButtons' import TableHead from '@/components/TableHead/src/TableHead.vue' import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import Detail from '@/components/Detail/src/Detail.vue' +import * as WarehouseApi from "@/api/wms/warehouse"; defineOptions({ name: 'Itemwarehouse' })