shish 2 месяцев назад
Родитель
Сommit
796a8c038e

+ 27 - 1
hdApp/src/pagesPurchase/components/gatheringList.vue

@@ -12,10 +12,20 @@
         <view class="mark">{{ info.addTime.substr(5,11) }}</view>
       </view>
       <view class="item-row">
-        <view class="price">¥{{ parseFloat(info.remainDebtPrice) }}</view>
+        <view class="price-block">
+          <view v-if="info.showPartialClear" class="price price--partial">
+            <text class="price-del">¥{{ parseFloat(info.debtPrice) }}</text>
+          </view>
+          <view v-else class="price">¥{{ parseFloat(info.remainDebtPrice || info.debtPrice) }}</view>
+        </view>
         <view class="price" style="border:1upx solid #67a0f7;border-radius:10upx;font-weight:normal;color:#3385FF;font-size:32upx;width:180upx;height:80upx;justify-content:center;"
          @click.stop="goToDetai(info)">查看明细</view>
       </view>
+      <view v-if="info.showPartialClear" class="item-row">
+        <view class="price price--clear-detail">
+          已清 ¥{{ info.hasPayDebt }},剩余待结 ¥{{ parseFloat(info.remainDebtPrice) }}
+        </view>
+      </view>
     </view>
   </view>
 </template>
@@ -96,6 +106,11 @@ export default {
       font-weight: 400;
       color: #666666;
     }
+    .price-block {
+      display: flex;
+      flex-direction: column;
+      align-items: flex-start;
+    }
     .price {
       z-index:auto;
       display: flex;
@@ -108,6 +123,17 @@ export default {
         color: #999999;
       }
     }
+    .price-del {
+      text-decoration: line-through;
+      color: #999;
+      font-weight: 400;
+    }
+    .price--clear-detail {
+      font-size: 26upx;
+      font-weight: 600;
+      color: #f50e24;
+      line-height: 36upx;
+    }
   }
 }
 </style>

+ 106 - 8
hdApp/src/pagesPurchase/gathering.vue

@@ -9,6 +9,13 @@
         </view>
         <DateSelect class="bar" top="0" @selectDateFn="selectDateFn" defaultShowName='时间' />
       </view>
+      <view v-if="hasDebtList" class="debt-summary flex-row">
+        <text class="debt-summary__label">已清</text>
+        <text class="debt-summary__amount debt-summary__amount--cleared">¥{{ debtSummary.clearedText }}</text>
+        <text class="debt-summary__split">|</text>
+        <text class="debt-summary__label">剩余待结</text>
+        <text class="debt-summary__amount debt-summary__amount--remain">¥{{ debtSummary.remainText }}</text>
+      </view>
     </view>
     <view scroll-y class="shop-list">
       <block v-if="!$util.isEmpty(detailsList)">
@@ -63,6 +70,13 @@ export default {
 			startTime:'',
 			endTime:'',
       ghsId:0,
+      summaryCleared: null,
+      summaryRemain: null,
+    }
+  },
+  onShow () {
+    if (this.ghsId) {
+      this.initData()
     }
   },
   onPullDownRefresh() {
@@ -93,6 +107,36 @@ export default {
       }
       return amount.toFixed(2);
     },
+    hasDebtList () {
+      return this.detailsList && this.detailsList.length > 0
+    },
+    debtSummary () {
+      if (this.summaryCleared !== null && this.summaryRemain !== null) {
+        return {
+          clearedText: this.formatMoney(this.summaryCleared),
+          remainText: this.formatMoney(this.summaryRemain)
+        }
+      }
+      let cleared = 0
+      let remain = 0
+      if (this.detailsList && this.detailsList.length) {
+        this.detailsList.forEach((item) => {
+          const debtPrice = Number(item.debtPrice) || 0
+          const remainDebtPrice = Number(item.remainDebtPrice) || 0
+          remain += remainDebtPrice
+          const paid = Number(item.hasPayDebt)
+          if (!isNaN(paid) && paid > 0) {
+            cleared += paid
+          } else if (debtPrice > remainDebtPrice) {
+            cleared += debtPrice - remainDebtPrice
+          }
+        })
+      }
+      return {
+        clearedText: this.formatMoney(cleared),
+        remainText: this.formatMoney(remain)
+      }
+    }
   },
   watch: {
     selectList () {
@@ -104,6 +148,24 @@ export default {
     }
   },
   methods: {
+    formatMoney (val) {
+      const n = parseFloat(val)
+      return isNaN(n) ? '0' : String(n)
+    },
+    mapDebtItem (ele) {
+      const debtPrice = Number(ele.debtPrice) || 0
+      const remainDebtPrice = Number(ele.remainDebtPrice) || 0
+      let hasPayDebt = Number(ele.hasPayDebt)
+      if (isNaN(hasPayDebt)) {
+        hasPayDebt = debtPrice > remainDebtPrice ? debtPrice - remainDebtPrice : 0
+      }
+      return {
+        ...ele,
+        checked: false,
+        hasPayDebt: this.formatMoney(hasPayDebt),
+        showPartialClear: hasPayDebt > 0
+      }
+    },
 		selectDateFn(val){
 			this.searchTime = val.searchTime
 			this.startTime = val.startTime
@@ -142,12 +204,15 @@ export default {
       this.ghsId = id
       this.getGhsInfo(id)
       return purchaseDebtList({id:id,searchTime:this.searchTime,startTime:this.startTime,endTime:this.endTime}).then(res => {
-        this.detailsList = res.data.list.map(ele => {
-          return {
-            ...ele,
-            checked: false
-          };
-        });
+        const list = res.data.list || []
+        this.detailsList = list.map((ele) => this.mapDebtItem(ele))
+        if (res.data && res.data.clearedAmount !== undefined) {
+          this.summaryCleared = res.data.clearedAmount
+          this.summaryRemain = res.data.remainDebtAmount
+        } else {
+          this.summaryCleared = null
+          this.summaryRemain = null
+        }
       }).catch(err => { 
 
       })
@@ -221,9 +286,10 @@ export default {
   flex-direction: column;
   background-color: #f9fbfc;
   .top-view {
-    padding: 30upx;
+    padding: 24upx 24upx 20upx;
 		position:fixed;
 		width:100%;
+    box-sizing: border-box;
     background-color: #fff;
     .top-row {
       display: flex;
@@ -259,8 +325,40 @@ export default {
       }
     }
   }
+  .debt-summary {
+    margin-top: 16upx;
+    padding: 14upx 18upx;
+    border-radius: 10upx;
+    background: #fff7f7;
+    align-items: center;
+    flex-wrap: wrap;
+    box-sizing: border-box;
+  }
+  .debt-summary__label {
+    font-size: 24upx;
+    color: #666;
+    line-height: 32upx;
+  }
+  .debt-summary__amount {
+    margin-left: 6upx;
+    font-size: 28upx;
+    font-weight: 700;
+    line-height: 36upx;
+  }
+  .debt-summary__amount--cleared {
+    color: #07a84c;
+  }
+  .debt-summary__amount--remain {
+    color: #f50e24;
+  }
+  .debt-summary__split {
+    margin: 0 16upx;
+    font-size: 24upx;
+    color: #ddd;
+    line-height: 32upx;
+  }
   .shop-list {
-		margin-top:98upx;
+		margin-top: 168upx;
     padding: 20upx 0;
     flex: 1;
     padding-bottom: 100upx;