Kaynağa Gözat

账单推送增加校验及金额格式化。

zhengqiang 5 yıl önce
ebeveyn
işleme
1d839bbfcb
1 değiştirilmiş dosya ile 55 ekleme ve 49 silme
  1. 55 49
      src/views/business/billPush-detail.vue

+ 55 - 49
src/views/business/billPush-detail.vue

@@ -102,7 +102,7 @@
                 <template slot-scope="scope">
                     <el-form-item
                     :prop="'billPushGoodsList.' + scope.$index + '.numStr'"
-                    :rules="ruleValidate['numStr']"
+                    :rules="ruleValidate['numStr3']"
                     >
                         <template v-if="scope.row.goodTypeId=='7'">
                             <el-input style="width:85px" placeholder="起码" v-model.number="scope.row.numStr" @change="handStartChange(scope)" size="mini"></el-input>
@@ -132,7 +132,7 @@
                     :prop="'billPushGoodsList.' + scope.$index + '.totalFee'"
                     :rules="ruleValidate['totalFee']"
                     >
-                    <el-input placeholder="合计金额" :value="fmtMoney(scope.row.totalFee)" readonly="readonly" size="mini"></el-input>
+                    <el-input placeholder="合计金额" :value="scope.row.totalFee" readonly="readonly" size="mini"></el-input>
                     </el-form-item>
                 </template>
             </el-table-column>
@@ -181,6 +181,8 @@ export default {
                 companyId: [{ required: true, message: "缴费单位不能为空", trigger: "blur" }],
                 payService: [{ required: true, message: "收费项目不能为空", trigger: "blur" }],
                 // personId: [{ required: true, message: "推送用户不能为空", trigger: "blur" }]
+                beginEndTime:[{ required: true, message: "起止时间不能为空", trigger: "blur" }],
+                numStr3:[{ required: true, message: "数量不能为空", trigger: "blur" }]
             },
             formModel: {
                 name:"",
@@ -253,56 +255,56 @@ export default {
         handleSubmit() {
             var self = this;
 
-            //增加转型,避免直接修改formModel
-            var requestData = JSON.parse(JSON.stringify(self.formModel));
+            this.$refs["form"].validate(valid => {
+                if (valid) {
+                    //增加转型,避免直接修改formModel
+                    var requestData = JSON.parse(JSON.stringify(self.formModel));
 
-            var billPushGoodsList = requestData.billPushGoodsList;
+                    var billPushGoodsList = requestData.billPushGoodsList;
 
-            for(var i=0;i<billPushGoodsList.length;i++){
-                billPushGoodsList[i].sortNo = i+1;
-                billPushGoodsList[i].beginDate = billPushGoodsList[i].beginEndTime[0];
-                billPushGoodsList[i].endDate = billPushGoodsList[i].beginEndTime[1]
-                billPushGoodsList[i].beginEndTime=null;
-            }
-
-            var removeBillPushGoodsList = requestData.removeBillPushGoodsList;
+                    for(var i=0;i<billPushGoodsList.length;i++){
+                        billPushGoodsList[i].sortNo = i+1;
+                        billPushGoodsList[i].beginDate = billPushGoodsList[i].beginEndTime[0];
+                        billPushGoodsList[i].endDate = billPushGoodsList[i].beginEndTime[1]
+                        billPushGoodsList[i].beginEndTime=null;
+                    }
 
-            for(var j=0;j<removeBillPushGoodsList.length;j++){
-                removeBillPushGoodsList[j].sortNo = j+1;
-                removeBillPushGoodsList[j].beginDate = removeBillPushGoodsList[j].beginEndTime[0];
-                removeBillPushGoodsList[j].endDate = removeBillPushGoodsList[j].beginEndTime[1]
-                removeBillPushGoodsList[j].beginEndTime=null;
-            }
+                    var removeBillPushGoodsList = requestData.removeBillPushGoodsList;
 
-            this.$refs["form"].validate(valid => {
-                if (valid) {
-                (function() {
-                    var id = requestData.id;
-                    
-                    if (id == null || id.length == 0) {
-                    return billPushApi.add(requestData);
-                    } else {
-                    return billPushApi.update(requestData);
+                    for(var j=0;j<removeBillPushGoodsList.length;j++){
+                        removeBillPushGoodsList[j].sortNo = j+1;
+                        removeBillPushGoodsList[j].beginDate = removeBillPushGoodsList[j].beginEndTime[0];
+                        removeBillPushGoodsList[j].endDate = removeBillPushGoodsList[j].beginEndTime[1]
+                        removeBillPushGoodsList[j].beginEndTime=null;
                     }
-                })().then(function(response) {
-                    var jsonData = response.data;
-
-                    if (jsonData.result) {
-                        self.$message({
-                            message: "保存成功!",
-                            type: "success"
-                        });
-
-                        self.$emit("close", true);
-                    } else {
-                        self.$message({
-                            message: jsonData.message + "",
-                            type: "warning"
-                        });
-
-                        self.$emit("close", false);
-                    }
-                });
+
+                    (function() {
+                        var id = requestData.id;
+                        
+                        if (id == null || id.length == 0) {
+                        return billPushApi.add(requestData);
+                        } else {
+                        return billPushApi.update(requestData);
+                        }
+                    })().then(function(response) {
+                        var jsonData = response.data;
+
+                        if (jsonData.result) {
+                            self.$message({
+                                message: "保存成功!",
+                                type: "success"
+                            });
+
+                            self.$emit("close", true);
+                        } else {
+                            self.$message({
+                                message: jsonData.message + "",
+                                type: "warning"
+                            });
+
+                            self.$emit("close", false);
+                        }
+                    });
                 }
             });
         },
@@ -416,7 +418,9 @@ export default {
 
             var totalFee = num*1*unit*1;
 
-            this.formModel.billPushGoodsList[scope.$index].totalFee = totalFee;
+            if(totalFee!=null){
+                this.formModel.billPushGoodsList[scope.$index].totalFee = totalFee.toFixed(2);
+            }
         },
         handStartChange(scope){
             var row = scope.row;
@@ -434,7 +438,9 @@ export default {
 
                     var totalFee = num3*1*unit*1;
 
-                    this.formModel.billPushGoodsList[scope.$index].totalFee = totalFee;
+                    if(totalFee!=null){
+                        this.formModel.billPushGoodsList[scope.$index].totalFee = totalFee.toFixed(2);
+                    }
                 }
             },100);
         }