瀏覽代碼

优化益寿缘医生端增加常用药品\常用诊断页面

cgp 1 周之前
父節點
當前提交
1cf71f3f44
共有 1 個文件被更改,包括 9 次插入11 次删除
  1. 9 11
      src/views/components/collection/collectionDetail.vue

+ 9 - 11
src/views/components/collection/collectionDetail.vue

@@ -8,7 +8,6 @@
           </span>
         </div>
         <div style="margin-left: 31px;">
-          <!-- 只显示 value 在 answer.value 中的选项 -->
           <el-checkbox-group
             v-model="form.answers[index].value"
             size="mini"
@@ -32,8 +31,8 @@
 </template>
 
 <script>
-//根据 userId 获取采集信息的接口
 import { getCollectionByUserId } from "@/api/collection";
+
 export default {
   name: "CollectionDetail",
   props: {
@@ -51,10 +50,7 @@ export default {
       form: {
         answers: []
       },
-      loading: false,
-      questionOptions: [],
-      privatePackageOptions: [],
-      codeImage: null
+      loading: false
     };
   },
   watch: {
@@ -73,25 +69,27 @@ export default {
       if (!Array.isArray(answer.value) || !Array.isArray(answer.options)) {
         return [];
       }
-      const selectedValues = new Set(answer.value); // 提升性能,避免多次遍历
+      const selectedValues = new Set(answer.value);
       return answer.options.filter(option => selectedValues.has(option.value));
     },
+
     fetchCollectionInfo(userId) {
       this.loading = true;
-      console.log("传入的用户信息:", userId)
+      console.log("传入的用户信息:", userId);
       getCollectionByUserId(userId)
         .then(res => {
           const data = res.data;
+          //只更新 answers,不替换整个 form
           if (data && Array.isArray(data.answers)) {
-            this.form = data;
+            this.form.answers = data.answers;
           } else {
-            this.form = { answers: [] };
+            this.form.answers = [];
           }
         })
         .catch(err => {
           console.error("获取采集信息失败:", err);
           this.$message.warning("暂无采集信息");
-          this.form = { answers: [] };
+          this.form.answers = [];
         })
         .finally(() => {
           this.loading = false;