Przeglądaj źródła

feat:可扫码展开问题修复

钱新宇 1 dzień temu
rodzic
commit
90adcaf0a8

+ 54 - 24
traceCodePackages/traceabilityCodeQuery/pages/scanRange/index.vue

@@ -4,19 +4,45 @@
     <view class="loading-page" v-if="getLoading()">
       <image class="loading-icon" src="../../../static/images/loading.png" />
     </view>
-    <scroll-view v-else class="content" scroll-y="true" @scrolltolower="onScrollToLower">
-      <view class="item" v-for="(item, i) in companyList" :key="i" @click="toggle(i)">
+    <scroll-view
+      v-else
+      class="content"
+      scroll-y="true"
+      @scrolltolower="onScrollToLower"
+    >
+      <view
+        class="item"
+        v-for="(item, i) in companyList"
+        :key="i"
+        @click="toggle(i)"
+      >
         <view class="item-header">
-          <text class="item-title">{{ i + 1 }}.&nbsp;{{ item.entName || "" }}</text>
-          <uni-icons type="down" size="22" color="#999" :style="{
-            transform: expanded[i] ? 'rotate(180deg)' : 'rotate(0deg)',
-            transition: 'transform 0.3s ease-in-out',
-          }"></uni-icons>
+          <text class="item-title"
+            >{{ i + 1 }}.&nbsp;{{ item.entName || "" }}</text
+          >
+          <uni-icons
+            type="down"
+            size="22"
+            color="#999"
+            :style="{
+              transform: expanded[i] ? 'rotate(180deg)' : 'rotate(0deg)',
+              transition: 'transform 0.3s ease-in-out',
+            }"
+          ></uni-icons>
         </view>
-        <scroll-view class="item-collapse" scroll-y="true" :style="{
-          height: getCollapseHeight(i),
-        }" @scrolltolower="getDrugInfoNameList(i)">
-          <view class="cv-item" v-for="(d, di) in products[i]" :key="'drug-' + di">
+        <scroll-view
+          class="item-collapse"
+          scroll-y="true"
+          :style="{
+            height: getCollapseHeight(i),
+          }"
+          @scrolltolower="getDrugInfoNameList(i)"
+        >
+          <view
+            class="cv-item"
+            v-for="(d, di) in products[i]"
+            :key="'drug-' + di"
+          >
             <text class="cv-index">{{ di + 1 }}</text>
             <text class="cv-label">药品名称:</text>
             <text class="cv-value">{{ d.physicName || "" }}</text>
@@ -25,7 +51,10 @@
       </view>
       <view class="loading-row" v-if="companyHasMore">
         <view class="loading-wrapper">
-          <image class="loading-icon" src="../../../static/images/loading.png" />
+          <image
+            class="loading-icon"
+            src="../../../static/images/loading.png"
+          />
         </view>
       </view>
     </scroll-view>
@@ -33,8 +62,8 @@
 </template>
 
 <script>
-import request from '../../../request/index.js'
-import { getPaginatedList } from '../../../utils/utils.js'
+import request from "../../../request/index.js";
+import { getPaginatedList } from "../../../utils/utils.js";
 import Water from "@/components/water/water.vue";
 export default {
   components: {
@@ -78,18 +107,19 @@ export default {
       //   ...(this.companyList[i].drugInfoNameList?.slice(start, end) || []),
       // ];
       // this.productPages[i] = page;
-      const {page: nextPage, data: nextData} = getPaginatedList({
+      const res = getPaginatedList({
         page: this.productPages[i] || 0,
-        initData: this.companyList[i].drugInfoNameList || [],
+        initData: this.companyList[i]?.drugInfoNameList || [],
         data: this.products[i] || [],
-      })
-      this.productPages[i] = nextPage;
-      this.products[i] = nextData;
+      });
+      if (!res || !Array.isArray(res.data)) return;
+      this.$set(this.productPages, i, res.page || this.productPages[i] || 0);
+      this.$set(this.products, i, res.data);
     },
     getCollapseHeight(i) {
       return this.expanded[i]
         ? Math.min(7.3 * 70, this.companyList[i].drugInfoNameList.length * 70) +
-        "rpx"
+            "rpx"
         : "0";
     },
     getLoading() {
@@ -114,11 +144,11 @@ export default {
       // }
       // this.companyLoading = false;
       // this.loading = false;
-      request('/customer/info/getEnterpriseData', {
+      request("/customer/info/getEnterpriseData", {
         pageNum: this.companyPageNum,
         pageSize: this.companyPageSize,
-        path: '/traceabilityCodeQuery/pages/scanRange/index.vue',
-      }).then(res => {
+        path: "/traceabilityCodeQuery/pages/scanRange/index.vue",
+      }).then((res) => {
         if (res.code == 200) {
           const { total, list } = res.data || {};
           this.companyTotalCount = total || 0;
@@ -137,7 +167,7 @@ export default {
         }
         this.companyLoading = false;
         this.loading = false;
-      })
+      });
     },
     onScrollToLower() {
       this.fetchCustomers();