From 84760ba32c36cdc6d947ac60d849b5d433ab0793 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Wed, 11 Dec 2024 16:05:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A3=85=E5=A4=87=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/user/contract-manage/index.vue | 12 ++- src/views/user/goodsManagement/index.vue | 132 ++++++++++++++--------- 2 files changed, 90 insertions(+), 54 deletions(-) diff --git a/src/views/user/contract-manage/index.vue b/src/views/user/contract-manage/index.vue index d345fce..f48a21f 100644 --- a/src/views/user/contract-manage/index.vue +++ b/src/views/user/contract-manage/index.vue @@ -124,6 +124,16 @@ > + + + @@ -157,7 +167,7 @@ :total="total" /> --> - + { - propertyNames.value.push({'propertyName':item,'propertyValue':null}) - options.value.push({'label':item,'value':item}) + propertyNames.value = deviceTypeList[0].data.maTypeProperties; + deviceTypeList[0].data.maTypeProperties.forEach((item:any) =>{ + options.value.push({'label':item.propertyName,'value':item.propertyName}) }) console.log(propertyNames.value) } @@ -539,6 +536,44 @@ const equipRules = ref({ // ], }) +const maTypeRules = ref({ + propertyName: [ + { + required: true, + message: '请输入属性描述', + trigger: 'blur', + }, + ], + propertyValue: [ + { + required: true, + message: '请输入属性值', + trigger: 'blur', + }, + ], + +}) + +const getProertyNameRules = (item:any)=>{ + if(item.mustHave ==1){ + return [ + {required: true, message: '请输入属性描述',trigger: 'blur',} + ] + }else{ + return [] + } +} + +const getProertyValueRules = (item:any)=>{ + if(item.mustHave ==1){ + return [ + {required: true, message: '请输入属性值',trigger: 'blur',} + ] + }else{ + return [] + } +} + const descriptionRules = ref({ insurancePdfs: [{ required: true, message: '请上传合格证', trigger: 'change' }], examinationPdfs: [{ required: true, message: '请上传检测证明', trigger: 'change' }], @@ -611,7 +646,7 @@ const submitFun = (type: any) => { ...addAndEditForm.detailsFileList, ...addAndEditForm.detailsFileTempList, ] - + addAndEditForm.devInfoProperties = propertyNames.value; addAndEditFormRef.value.validate(async (valid: any) => { if (valid) { let isDescription = false @@ -639,11 +674,29 @@ const submitFun = (type: any) => { } catch (error) {} } + // for(let index = 0;index < propertyNames.value.length;index++){ + // try { + // const result = await new Promise((resolve,reject) => { + // addAndEditFormRef.value.validateField(`propertyNames[${index}].propertyValue`,(error) => { + // if(error){ + // reject(error); + // }else{ + // resolve(true); + // } + // }) + // }) + + // if (!result) { + // isDescription = true + // throw new Error('表单校验失败') + // } + // } catch (error) {} + // } if (isDescription) return addAndEditForm.typeId = addAndEditForm.deviceTypeList[addAndEditForm.deviceTypeList.length - 1] - addAndEditForm.devInfoProperties = propertyNamesTwo.value; + let SEND_FUN_API: any = null if (type == 1) { SEND_FUN_API = equipmentAddApi @@ -1021,16 +1074,6 @@ const options = ref([ // } ]) - //新增属性 - const addPartItem = () => { - propertyNamesTwo.value.push({'propertyName':null,'propertyValue':null}); - } - - const removePartItem = (index:any)=> { - if (propertyNamesTwo.value.length > 1) { - propertyNamesTwo.value.splice(index, 1); - } - }