shish 2 месяцев назад
Родитель
Сommit
6104bbbd0d
1 измененных файлов с 23 добавлено и 0 удалено
  1. 23 0
      hdPad/src/pages/home/components/selectPrice.vue

+ 23 - 0
hdPad/src/pages/home/components/selectPrice.vue

@@ -415,6 +415,10 @@ export default {
                 priceSnapshot: r.priceSnapshot,
                 orderOnly: !!r.orderOnly,
                 source: r.source === 'stash' ? 'stash' : 'submit',
+                discountZhe:
+                    r.discountZhe != null && r.discountZhe !== '' && !isNaN(Number(r.discountZhe))
+                        ? parseFloat(Number(r.discountZhe).toFixed(2))
+                        : undefined,
             }
         },
         persistCalcHistoryToStorage() {
@@ -922,6 +926,7 @@ export default {
                     priceSnapshot: Number(this.price) || 0,
                     orderOnly,
                     source: opts.source === 'stash' ? 'stash' : 'submit',
+                    discountZhe: parseFloat(Number(this.discountZhe).toFixed(2)),
                 },
                 0
             )
@@ -970,10 +975,28 @@ export default {
             this.calcInput = ''
             this.resetActiveDiscountToNone()
         },
+        /** 从历史记录还原折扣(不写全局折扣 storage,避免覆盖用户默认偏好) */
+        restoreHistoryDiscountFromRow(row) {
+            let z = 10
+            const raw = row && row.discountZhe
+            if (raw != null && raw !== '' && !isNaN(Number(raw))) {
+                const n = Number(raw)
+                if (n > 0 && n <= 10) {
+                    z = parseFloat(n.toFixed(2))
+                }
+            }
+            if (z >= 10 - 1e-6) {
+                this.discountZhe = 10
+                return
+            }
+            const ok = this.customDiscountZheList.some((x) => Math.abs(Number(x) - z) < 1e-4)
+            this.discountZhe = ok ? z : 10
+        },
         applyHistoryRow(row) {
             if (!row) {
                 return
             }
+            this.restoreHistoryDiscountFromRow(row)
             const ci = row.calcInput != null ? String(row.calcInput) : ''
             const hasTok = row.tokens && row.tokens.length > 0
             const hasLegacy = row.addends && row.addends.length