浏览代码

物料基础档案-医疗行业部分字典数据偶尔出现无法加载需要重新刷新问题

002390 1 年之前
父节点
当前提交
22ecafa380
共有 1 个文件被更改,包括 46 次插入32 次删除
  1. 46 32
      src/views/material/basicFile/details.vue

+ 46 - 32
src/views/material/basicFile/details.vue

@@ -728,7 +728,6 @@
               <div slot="empty"></div>
             </el-select>
 
-
             <!-- 其他类型 -->
             <el-input
               v-else
@@ -1731,41 +1730,57 @@ export default {
     },
     // 获取物料列表表头
     async getTagList(templateCode, cb) {
-      let _this = this;
-      await materialApi.tagList({ templateCode }).then(async (res) => {
-        console.log(res, `获取${templateCode}表头`);
-        let dictIdList = [];
-        if (res.code == 200) {
-          res.data.map(async (item) => {
-            // 查字典
-            if (item.dictId && item.dictId != "") {
-              // 通过接口获取有dict的对应的数据
-              await getDicts(item.dictId).then((dict) => {
-                if (dict.data) {
-                  item["dictValue"] = dict.data;
-                }
-              });
-            }
+      let dictIdList = [];
+      try {
+        let { code, data } = await materialApi.tagList({ templateCode });
+        if (code == 200) {
+          dictIdList = _.cloneDeep(data);
+          let promiseArray = data.map((item, index) => {
+            return new Promise((resolve, reject) => {
+              if (item.dictId && item.dictId != "") {
+                getDicts(item.dictId).then((dict) => {
+                  if (dict.data) {
+                    dictIdList[index]["dictValue"] = dict.data;
+                    resolve();
+                  }
+                });
+              } else {
+                resolve();
+              }
+            });
           });
+          Promise.all(promiseArray)
+            .then(async () => {
+              return cb(dictIdList);
+            })
+            .catch(() => {
+              console.log("promise.all执行失败");
+            });
+        }
+      } catch (error) {
+      } finally {
+      }
 
-          return cb(res.data);
+      // await materialApi.tagList({ templateCode }).then(async (res) => {
+      //   console.log(res, `获取${templateCode}表头`);
+      //   let dictIdList = [];
+      //   if (res.code == 200) {
 
-          // 动态更改dict
-          // res.data.forEach(item => {
-          //   if (item.dictId) {
-          //     // 请求接口
-          //     dictIdList.push(item.dictId);
-          //   }
-          // })
-          // console.log(dictIdList, 'dictIdList');
-          // _this.dict = [..._this.dict, ...dictIdList];
-          // _this.dict = Array.from(new Set([..._this.dict, ...dictIdList]));
+      //     res.data.map(async (item) => {
+      //       // 查字典
+      //       if (item.dictId && item.dictId != "") {
+      //         // 通过接口获取有dict的对应的数据
+      //         await getDicts(item.dictId).then((dict) => {
+      //           if (dict.data) {
+      //             item["dictValue"] = dict.data;
+      //           }
+      //         });
+      //       }
+      //     });
 
-          // console.log(_this.dict, 'dicts');
+      //     return cb(res.data);
 
-          // return cb(res.data);
-        }
-      });
+     
     },
     // 根据物料id获取物料类别维护列表
     getMedcineitemList(materialId) {
@@ -2041,7 +2056,6 @@ export default {
           this.maintainNewVersion = false;
           this.handleRefresh();
         });
-      
     },
     // 物料类别列表选中
     handleSelectionType(list) {