Kaynağa Gözat

减少获取企业结构和业务构成其他数据的遍历次数

liusungtsun 1 yıl önce
ebeveyn
işleme
efa5135ba3
1 değiştirilmiş dosya ile 10 ekleme ve 6 silme
  1. 10 6
      src/views/GARDENBASEDATA/index.vue

+ 10 - 6
src/views/GARDENBASEDATA/index.vue

@@ -870,12 +870,16 @@ export default {
       this.$refs["form"].validate((valid) => {
 
         if (valid) {
-          // 获取企业结构 业务构成 label数据
-          this.form.enterpriseStructure = this.dict.type.enterprise_structure.find(({value}) => value == this.form.enterpriseStructureValue).label
-          this.form.businessEvents = this.dict.type.business_events.find(({value}) => value == this.form.businessEventsValue).label
-          // 获取企业结构 业务构成 sort 排序数据
-          this.form.enterpriseStructureSort = this.dict.type.enterprise_structure.find(({value}) => value == this.form.enterpriseStructureValue).raw.dictSort
-          this.form.businessEventsSort = this.dict.type.business_events.find(({value}) => value == this.form.businessEventsValue).raw.dictSort
+          // 获取选中的企业结构 获取 label数据和 sort排序数据
+          let currentEnterpriseStructure = this.dict.type.enterprise_structure?.find(({value}) => value == this.form.enterpriseStructureValue)
+          this.form.enterpriseStructure = currentEnterpriseStructure?.label
+          this.form.enterpriseStructureSort = currentEnterpriseStructure?.raw?.dictSort
+
+          // 获取选中的业务结构
+          let currentBusinessEvents = this.dict.type.business_events?.find(({value}) => value == this.form.businessEventsValue)
+          this.form.businessEvents = currentBusinessEvents?.label
+          this.form.businessEventsSort = currentBusinessEvents?.raw?.dictSort
+
           if (this.form.id != null) {
             updateGARDENBASEDATA(this.form).then((response) => {
               this.$modal.msgSuccess("修改成功");