Browse Source

校验失去焦点添加的数据是否正确

hella_online_20240829
zhang_li 5 months ago
parent
commit
65e5b0a8c1
  1. 5
      src/api/wms/process/index.ts
  2. 4
      src/api/wms/warehouse/index.ts
  3. 141
      src/components/BasicForm/src/BasicForm.vue
  4. 5
      src/views/wms/basicDataManage/factoryModeling/areabasic/index.vue
  5. 7
      src/views/wms/basicDataManage/itemManage/bom/index.vue
  6. 2
      src/views/wms/basicDataManage/itemManage/itemwarehouse/index.vue

5
src/api/wms/process/index.ts

@ -63,3 +63,8 @@ export const importTemplate = () => {
export const getProcessNoPage = async (params) => { export const getProcessNoPage = async (params) => {
return await request.get({ url: `/wms/process/noPage`, 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 })
}

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

@ -70,3 +70,7 @@ export const pageBusinessTypeToWarehouse = async (params) => {
return await request.get({ url: `/wms/warehouse/pageBusinessTypeToWarehouse`, params }) return await request.get({ url: `/wms/warehouse/pageBusinessTypeToWarehouse`, params })
} }
} }
// 根据code获取数据列表
export const getWarehouseByCodes = async (params) => {
return await request.get({ url: `/wms/warehouse/listByCodes`, params })
}

141
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 TableFormCountPlan from '@/components/TableFormCountPlan/src/TableFormCountPlan.vue'
import {DICT_TYPE, getStrDictOptions} from '@/utils/dict' import {DICT_TYPE, getStrDictOptions} from '@/utils/dict'
import { tableFormBlurVer,FormBlur,getListByBottonInput } from '@/api/wms/business/business' import { tableFormBlurVer,FormBlur,getListByBottonInput } from '@/api/wms/business/business'
import { isString } from 'min-dash'
const props = defineProps({ const props = defineProps({
// //
basicFormWidth: { basicFormWidth: {
@ -324,7 +325,17 @@ const props = defineProps({
type: Array, type: Array,
required: false, required: false,
default: [] default: []
} },
byCodespageApi: {
type: Function,
required: true,
default: null
}, //
byCodesParams: {
type: Object,
required: true,
default: null
} //
}) })
const { t } = useI18n() // const { t } = useI18n() //
@ -783,15 +794,135 @@ const onChange = (field, cur) => {
* @param field 当前操作字段 * @param field 当前操作字段
* @param e * @param e
*/ */
const onBlur = async (field, e) => { const onBlur = async (field, e) => {
isExecute.value = false isExecute.value = false
await FormBlur(field, e,routeName.value,formRef.value,props.detailData,formSchema.value,(searchField, list)=>{ if (
emit('searchTableSuccess', field, searchField, list, formRef.value, 'form') 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)
// keyvalue
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 isExecute.value = true
emit('onBlur', field, e) emit('onBlur', field, e)
} }
// //
const batchAdd = async (val) => { const batchAdd = async (val) => {
const row = {} const row = {}

5
src/views/wms/basicDataManage/factoryModeling/areabasic/index.vue

@ -48,6 +48,7 @@
:apiCreate="AreaApi.createArea" :apiCreate="AreaApi.createArea"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" :isBusiness="false"
@onBlur="onBlur"
/> />
<!-- 详情 --> <!-- 详情 -->
@ -267,6 +268,10 @@ const searchFormClick = (searchData) => {
} }
getList() // getList() //
} }
//
const onBlur = (field, e)=>{
}
/** 初始化 **/ /** 初始化 **/
onMounted(async() => { onMounted(async() => {

7
src/views/wms/basicDataManage/itemManage/bom/index.vue

@ -48,6 +48,7 @@
:apiCreate="BomApi.createBom" :apiCreate="BomApi.createBom"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" :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 TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue' import Detail from '@/components/Detail/src/Detail.vue'
import * as ProcessApi from "@/api/wms/process";
// bom // bom
defineOptions({ name: 'Bom' }) defineOptions({ name: 'Bom' })
@ -277,7 +279,10 @@ const searchFormClick = (searchData) => {
} }
getList() // getList() //
} }
//
// const onBlur = (field, e)=>{
// ProcessApi.getProcessByCodes().then()
// }
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
getList() getList()

2
src/views/wms/basicDataManage/itemManage/itemwarehouse/index.vue

@ -48,6 +48,7 @@
:apiCreate="ItemwarehouseApi.createItemwarehouse" :apiCreate="ItemwarehouseApi.createItemwarehouse"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" :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 TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue' import Detail from '@/components/Detail/src/Detail.vue'
import * as WarehouseApi from "@/api/wms/warehouse";
defineOptions({ name: 'Itemwarehouse' }) defineOptions({ name: 'Itemwarehouse' })

Loading…
Cancel
Save