From 15c5f3c00fe0c694eab0e412cb0e5a346351ae70 Mon Sep 17 00:00:00 2001 From: zhang_li <2235006734@qqq.com> Date: Mon, 18 Nov 2024 16:18:07 +0800 Subject: [PATCH] =?UTF-8?q?YT-875=E8=A6=81=E8=B4=A7=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=97=B6=EF=BC=8C=E7=84=A6=E7=82=B9=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=9C=89=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/wms/business/inputBlur.ts | 2 + src/components/BasicForm/src/BasicForm.vue | 56 +++++++++++-------- src/components/Form/src/Form.vue | 3 +- .../purchasePlanMain/purchasePlanMain.data.ts | 1 + 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/api/wms/business/inputBlur.ts b/src/api/wms/business/inputBlur.ts index 3a107026d..6979ee147 100644 --- a/src/api/wms/business/inputBlur.ts +++ b/src/api/wms/business/inputBlur.ts @@ -416,6 +416,7 @@ export const FormBlur = async (field, val, routeName, formRef, detailData, formS if (list.value?.length == 0) { message.alert('暂无数据') formRef.setValues(setV) + callback([]) return } if (arr1.length != list.value.length) { @@ -425,6 +426,7 @@ export const FormBlur = async (field, val, routeName, formRef, detailData, formS ...arr2.filter((item) => !arr1.includes(item)) ].join(',') message.alert('代码' + str + '没有找到对应数据') + callback([]) formRef.setValues(setV) return } diff --git a/src/components/BasicForm/src/BasicForm.vue b/src/components/BasicForm/src/BasicForm.vue index 33aae303d..b6f833d52 100644 --- a/src/components/BasicForm/src/BasicForm.vue +++ b/src/components/BasicForm/src/BasicForm.vue @@ -1008,33 +1008,37 @@ const onChange = (field, cur) => { * @param field 当前操作字段 * @param e */ - +const isOnBlur = ref(true) const onBlur = async (field, e) => { - let formSchemaObj = formSchema.value.find((item) => item.field == field)?.componentProps - if (formSchemaObj?.enterSearch) { - await FormBlur( - field, - e, - routeName.value, - formRef.value, - props.detailData, - formSchemaObj, - (list) => { - emit('searchTableSuccess', field, formSchemaObj.searchField, list, formRef.value, 'form') - } - ) + // isOnBlur是false的时候证明先走了回车事件,可以不走失去焦点方法,true的时候直接走失去焦点事件 + if (isOnBlur.value) {//同时走失去焦点方法bug + let formSchemaObj = formSchema.value.find((item) => item.field == field)?.componentProps + if (formSchemaObj?.enterSearch) { + await FormBlur( + field, + e, + routeName.value, + formRef.value, + props.detailData, + formSchemaObj, + (list) => { + emit('searchTableSuccess', field, formSchemaObj.searchField, list, formRef.value, 'form') + } + ) - if (props.isShowFooterButtton && !props.footButttondata) { - Butttondata = [ - defaultButtons.formSaveBtn(null), // 保存 - defaultButtons.formCloseBtn(null) // 关闭 - ] - count.value++ + if (props.isShowFooterButtton && !props.footButttondata) { + Butttondata = [ + defaultButtons.formSaveBtn(null), // 保存 + defaultButtons.formCloseBtn(null) // 关闭 + ] + count.value++ + } + sureDisabled.value= false + } else { + emit('onBlur', field, e) } - sureDisabled.value= false - } else { - emit('onBlur', field, e) } + } // 批量增加 @@ -1138,6 +1142,7 @@ const inputStringFcous= (headerItem) => { const onEnter = async (field, value, e) => { let formSchemaObj = formSchema.value.find((item) => item.field == field)?.componentProps if (formSchemaObj?.enterSearch && formSchemaObj?.isEnter) { + isOnBlur.value = false//解决回车事件和失去焦点同时调用bug await FormBlur( field, value, @@ -1146,7 +1151,10 @@ const onEnter = async (field, value, e) => { props.detailData, formSchemaObj, (list) => { - emit('onEnter', field, value, e) + isOnBlur.value = true + if (list.length != 0) { + emit('onEnter', field, value, e) + } } ) } else { diff --git a/src/components/Form/src/Form.vue b/src/components/Form/src/Form.vue index 33db690db..105da516f 100644 --- a/src/components/Form/src/Form.vue +++ b/src/components/Form/src/Form.vue @@ -325,10 +325,11 @@ export default defineComponent({ formItemSlotsSearchList[item.field] = () => { return ( <> - { + { if(event.keyCode === 13){ //回车 emit('onEnter',item.field,formModel.value[item.field],event) + event.target.blur();//回车之后自动失去焦点 } }} diff --git a/src/views/wms/purchasereceiptManage/supplierdeliver/purchasePlanMain/purchasePlanMain.data.ts b/src/views/wms/purchasereceiptManage/supplierdeliver/purchasePlanMain/purchasePlanMain.data.ts index 8a52c7f37..ffef55e62 100644 --- a/src/views/wms/purchasereceiptManage/supplierdeliver/purchasePlanMain/purchasePlanMain.data.ts +++ b/src/views/wms/purchasereceiptManage/supplierdeliver/purchasePlanMain/purchasePlanMain.data.ts @@ -68,6 +68,7 @@ export const PurchasePlanMain = useCrudSchemas( form: { labelMessage: '影响明细中物料代码,需在供应商物料中维护', componentProps: { + isEnter: true, enterSearch: true, isSearchList: true, // 开启查询弹窗 searchListPlaceholder: '请选择供应商代码', // 输入框占位文本