Переглянути джерело

批发端-运费附加费重收设置

ouyang 13 годин тому
батько
коміт
24f9fc2f88
1 змінених файлів з 134 додано та 1 видалено
  1. 134 1
      ghsApp/src/pagesOrder/shMethod.vue

+ 134 - 1
ghsApp/src/pagesOrder/shMethod.vue

@@ -127,6 +127,48 @@
             <view class="tui-title">{{ form.unMeet == 1 ? '包装费' : '运费' }}</view>
             <view class="tui-title">{{ form.unMeet == 1 ? '包装费' : '运费' }}</view>
             <input type="digit" v-model="form.unMeetFee" @focus="form.unMeetFee = ''" class="tui-input" placeholder="请填写金额" />
             <input type="digit" v-model="form.unMeetFee" @focus="form.unMeetFee = ''" class="tui-input" placeholder="请填写金额" />
           </tui-list-cell>
           </tui-list-cell>
+          <!-- 附加费重收:按自然日 或 按小时间隔(页面只展示小时) -->
+          <tui-list-cell class="line-cell" :hover="false" v-if="form.unMeet != 2">
+            <view class="tui-title">附加费重收</view>
+            <view class="btn-group">
+              <button
+                class="admin-button-com middle"
+                :class="[form.unMeetLockType == 0 ? 'blue' : 'default']"
+                @click="form.unMeetLockType = 0"
+              >
+                按自然日
+              </button>
+              <button
+                class="admin-button-com middle"
+                :class="[form.unMeetLockType == 1 ? 'blue' : 'default']"
+                @click="form.unMeetLockType = 1"
+                style="margin-left: 10upx;"
+              >
+                按时间间隔
+              </button>
+            </view>
+          </tui-list-cell>
+          <tui-list-cell class="line-cell" :hover="false" v-if="form.unMeet != 2 && form.unMeetLockType == 1">
+            <view class="tui-title">间隔时长</view>
+            <view class="input-row">
+              <input
+                type="digit"
+                v-model="form.unMeetLockHours"
+                @focus="form.unMeetLockHours = ''"
+                class="tui-input-sm"
+                placeholder="0.5"
+              />
+              <text class="unit-text">小时后再收</text>
+            </view>
+          </tui-list-cell>
+          <view
+            class="section-tip"
+            v-if="form.unMeet != 2"
+            style="padding: 0 30upx 20upx;"
+          >
+            <text v-if="form.unMeetLockType == 0">按自然日:同一客户当天收过该附加费后,当日不再收取。</text>
+            <text v-else>按时间间隔:收过附加费后,需间隔填写的小时数才会再次收取(支持小数,如 0.5)</text>
+          </view>
         </block>
         </block>
 
 
         <!-- 跑腿 特有字段 -->
         <!-- 跑腿 特有字段 -->
@@ -286,6 +328,10 @@
 </template>
 </template>
 
 
 <script>
 <script>
+/**
+ * 供货商配送方式设置(xhShMethod)
+ * 送货/快递:附加费重收(按自然日 / 按小时间隔),页面用小时录入
+ */
 import TuiListCell from "@/components/plugin/list-cell";
 import TuiListCell from "@/components/plugin/list-cell";
 import { getShMethodConfig, saveShMethodConfig, getShMethodSorts } from "@/api/sh-method";
 import { getShMethodConfig, saveShMethodConfig, getShMethodSorts } from "@/api/sh-method";
 
 
@@ -316,6 +362,11 @@ export default {
         minNum: 0,
         minNum: 0,
         unMeet: 0,
         unMeet: 0,
         unMeetFee: 0.00,
         unMeetFee: 0.00,
+        /** 附加费重收:0 按自然日;1 按时间间隔(页面用小时,提交换算秒) */
+        unMeetLockType: 0,
+        unMeetLockSeconds: 1800,
+        /** 仅编辑展示:小时,支持小数如 0.5 */
+        unMeetLockHours: 0.5,
         startKm: 0.00,
         startKm: 0.00,
         startPrice: 0.00,
         startPrice: 0.00,
         perKmPrice: 0.00,
         perKmPrice: 0.00,
@@ -395,6 +446,11 @@ export default {
               minNum: data.minNum != null ? Number(data.minNum) : 0,
               minNum: data.minNum != null ? Number(data.minNum) : 0,
               unMeet: data.unMeet != null ? Number(data.unMeet) : 0,
               unMeet: data.unMeet != null ? Number(data.unMeet) : 0,
               unMeetFee: data.unMeetFee != null ? parseFloat(data.unMeetFee) : 0.00,
               unMeetFee: data.unMeetFee != null ? parseFloat(data.unMeetFee) : 0.00,
+              unMeetLockType: data.unMeetLockType != null ? Number(data.unMeetLockType) : 0,
+              unMeetLockSeconds: data.unMeetLockSeconds != null ? Number(data.unMeetLockSeconds) : 1800,
+              unMeetLockHours: this.secondsToLockHours(
+                data.unMeetLockSeconds != null ? Number(data.unMeetLockSeconds) : 1800
+              ),
               startKm: data.startKm != null ? parseFloat(data.startKm) : 0.00,
               startKm: data.startKm != null ? parseFloat(data.startKm) : 0.00,
               startPrice: data.startPrice != null ? parseFloat(data.startPrice) : 0.00,
               startPrice: data.startPrice != null ? parseFloat(data.startPrice) : 0.00,
               perKmPrice: data.perKmPrice != null ? parseFloat(data.perKmPrice) : 0.00,
               perKmPrice: data.perKmPrice != null ? parseFloat(data.perKmPrice) : 0.00,
@@ -533,6 +589,65 @@ export default {
       this.$util.pageTo({ url: "/admin/shop/wl" });
       this.$util.pageTo({ url: "/admin/shop/wl" });
     },
     },
 
 
+    /**
+     * 冷却秒数 → 配置页小时(保留小数,去掉多余 0)
+     * @param {number} seconds
+     * @returns {number}
+     */
+    secondsToLockHours(seconds) {
+      const s = Number(seconds);
+      if (!(s > 0)) {
+        return 0.5;
+      }
+      return parseFloat((s / 3600).toFixed(4));
+    },
+
+    /**
+     * 配置页小时 → 冷却秒(四舍五入)
+     * @param {number|string} hours
+     * @returns {number}
+     */
+    hoursToLockSeconds(hours) {
+      const h = Number(hours);
+      if (!(h > 0)) {
+        return 0;
+      }
+      return Math.round(h * 3600);
+    },
+
+    /**
+     * 送货/快递附加费重收校验;通过则把小时写入 form.unMeetLockSeconds
+     * ghs:unMeet=2 为不能买,此时不校验重收规则
+     * @returns {string} 错误文案,空表示通过
+     */
+    validateUnMeetLockBeforeSave() {
+      const style = Number(this.form.style);
+      if (style !== 0 && style !== 4) {
+        return "";
+      }
+      // 不能买:不需要重收规则
+      if (Number(this.form.unMeet) === 2) {
+        this.form.unMeetLockType = 0;
+        return "";
+      }
+      const lockType = Number(this.form.unMeetLockType) === 1 ? 1 : 0;
+      this.form.unMeetLockType = lockType;
+      if (lockType !== 1) {
+        if (!(Number(this.form.unMeetLockSeconds) > 0)) {
+          this.form.unMeetLockSeconds = 1800;
+          this.form.unMeetLockHours = 0.5;
+        }
+        return "";
+      }
+      const seconds = this.hoursToLockSeconds(this.form.unMeetLockHours);
+      if (!(seconds > 0)) {
+        return "请填写大于 0 的间隔小时(支持小数,如 0.5)";
+      }
+      this.form.unMeetLockSeconds = seconds;
+      this.form.unMeetLockHours = this.secondsToLockHours(seconds);
+      return "";
+    },
+
     /**
     /**
      * 保存当前配置
      * 保存当前配置
      */
      */
@@ -553,9 +668,20 @@ export default {
           return;
           return;
         }
         }
       }
       }
+
+      const lockErr = this.validateUnMeetLockBeforeSave();
+      if (lockErr) {
+        this.$msg(lockErr);
+        return;
+      }
+
       saveShMethodConfig(this.form).then(res => {
       saveShMethodConfig(this.form).then(res => {
           if (res.code == 1) {
           if (res.code == 1) {
-            this.$msg("保存成功");
+            if (Number(this.form.unMeetLockType) === 1 && (Number(this.form.style) === 0 || Number(this.form.style) === 4)) {
+              this.$msg(`保存成功,间隔 ${this.form.unMeetLockHours} 小时后再收`);
+            } else {
+              this.$msg("保存成功");
+            }
             // 重新加载配置刷新数据
             // 重新加载配置刷新数据
             this.loadConfig(this.form.style);
             this.loadConfig(this.form.style);
             // 重新加载排序和别名信息
             // 重新加载排序和别名信息
@@ -677,6 +803,13 @@ export default {
   margin: 0 10upx;
   margin: 0 10upx;
 }
 }
 
 
+/* 附加费重收说明 */
+.section-tip {
+  font-size: 24upx;
+  color: #999999;
+  line-height: 1.5;
+}
+
 /* 模块标题 */
 /* 模块标题 */
 .section-header {
 .section-header {
   display: flex;
   display: flex;