Browse Source

运费V1.0.4

zhengjinyi 1 year ago
parent
commit
69120c8c3a

+ 1 - 0
src/main/resources/static/js/supplier-center/shop/freight.js

@@ -19,6 +19,7 @@ var myGoods = new Vue({
         productRadio:[],
         handlePros:{},
         groundMallType:0,
+        pageType:'list'
     },
     filters: {
         newvalidFlagFilters(value) {

+ 20 - 4
src/main/resources/static/js/supplier-center/shop/mixins/freightMixins.js

@@ -1,8 +1,8 @@
 // 发布商品
 const freightDefault = () =>{
     return {
-        id:'', // 运费模板Id
-        freightId:'', // 运费规则的Id
+        id:'', // 运费规则的Id
+        freightId:'', // 运费模板Id
         areaTax:'', // 运费规则地区名
         ruleTax:'', // 运费规则文案
         freightAreaList:[], // 运费规则地区id集合
@@ -78,7 +78,14 @@ const freightMixins = function () {
             },
             // 新增运费规则
             handleAddRole(){
-                this.freightRuleList.push(freightDefault())
+                this.rulesChecked = false
+                if(this.templateType === 'edit'){
+                    let roul = {freightId:this.freightTemp.id}
+                    let freight = { ...freightDefault(), ...roul  }
+                    this.freightRuleList.push(freight)
+                }else{
+                    this.freightRuleList.push(freightDefault())
+                }
             },
             // 删除运费规则
             handleDelRole(index){
@@ -150,6 +157,9 @@ const freightMixins = function () {
                 this.freightAreasType = type
                 this.areaRulesForm = freight
                 this.areaRulesIndex = index+1
+                if(this.templateType === 'edit'){
+                    this.getFreightArea(freight.freightId,freight.id)
+                }
                 this.areasFormVisible = true
             },
             // 取消选择省市
@@ -370,8 +380,10 @@ const freightMixins = function () {
                 SupplierApi.saveFreightTemplate(params,function(response){
                     if(response.code === 0){
                         _this.$message({ message: '保存运费模板成功',type: 'success'});
-                        _this.getList()
                         _this.handleCanleFreights()
+                        if(_this.pageType === 'list'){
+                            _this.getList()
+                        }
                     }else{
                         _this.$message({ message: `${response.msg}`,type: 'warning'});
                     }
@@ -410,6 +422,10 @@ const freightMixins = function () {
                         })
                     })
                 })
+            },
+            handleInput(e) {
+                // 通过正则过滤小数点后两位
+                e.target.value = (e.target.value.match(/^\d*(\.?\d{0,1})/g)[0]) || null
             }
         }
     }

+ 3 - 3
src/main/resources/templates/supplier-center/components/freight-dialog.html

@@ -145,7 +145,7 @@
       <span style="font-weight: bold;">运费金额:</span>
     </el-row>
     <el-form-item prop="freightAmount" :rules="rules.freightAmount" style="margin-left: 0;">
-      <el-input v-model="freightRulesForm.freightAmount">
+      <el-input v-model="freightRulesForm.freightAmount" @keydown.native="handleInput">
         <template slot="append">元</template>
       </el-input>
     </el-form-item>
@@ -162,14 +162,14 @@
       </el-row>
       <el-row :gutter="24" class="box-row" style="margin-bottom: 10px;margin-left: 0;margin-right: 0;" v-if="freightRulesForm.freeCondition === 0">
-        <el-input v-model="freightRulesForm.productNum" style="width: 180px">
+        <el-input v-model="freightRulesForm.productNum" @input ="freightRulesForm.productNum = freightRulesForm.productNum.replace(/[^\d]/g,'')" style="width: 180px">
           <template slot="append">件</template>
         </el-input>
         可包邮
       </el-row>
       <el-row :gutter="24" class="box-row" style="margin-bottom: 10px;margin-left: 0;margin-right: 0;"  v-if="freightRulesForm.freeCondition === 1">
-        <el-input v-model="freightRulesForm.allAmount" style="width: 180px">
+        <el-input v-model="freightRulesForm.allAmount" @input ="freightRulesForm.allAmount = freightRulesForm.allAmount.replace(/[^\d]/g,'')" style="width: 180px">
           <template slot="append">元</template>
         </el-input>
         可包邮