Browse Source

营销管理

Joe 4 years ago
parent
commit
045d614ed0
1 changed files with 42 additions and 19 deletions
  1. 42 19
      src/views/market/Market_Discount.vue

+ 42 - 19
src/views/market/Market_Discount.vue

@@ -34,10 +34,10 @@
 
     <hr />
     <el-dialog
-      :title="title"
       :visible.sync="openDialog"
       width="600px"
       append-to-body
+      :title="['', '满减方案', '立减方案', '直降方案'][discountSetting]"
     >
       <el-form
         ref="updateForm"
@@ -56,7 +56,7 @@
             size="small"
           >
             <el-option
-              v-for="dict in oilNameOptions"
+              v-for="dict in filterOilNameOptions"
               :key="dict.oilName"
               :label="dict.oilName"
               :value="dict.oilName"
@@ -64,23 +64,30 @@
           </el-select>
         </el-form-item>
         <el-form-item label="优惠条件" prop="gasoilDiscountAmt" required>
-          <el-radio-group v-model="updateForm.discountTerm">
+          <el-radio-group
+            v-model="updateForm.discountTerm"
+            v-if="discountSetting == 3"
+          >
             <el-radio :label="0">按加油金额优惠</el-radio>
             <el-radio :label="1">按加油升数优惠</el-radio>
           </el-radio-group>
           <div
             v-show="
-              updateForm.discountTerm == 0 || updateForm.discountTerm == 1
+              updateForm.discountTerm == 0 ||
+              updateForm.discountTerm == 1 ||
+              discountSetting == 1 ||
+              discountSetting == 2
             "
           >
-            满
+            {{ ["", "每", "满", "满"][discountSetting] }}
             <el-input-number
               v-model="updateForm.discountAmt"
               size="mini"
               :min="0"
             />
+
             <span>{{ updateForm.discountTerm == 0 ? "元" : "L" }}</span>
-            ,每升优惠
+            ,{{ ["", "减", "减", "每升优惠"][discountSetting] }}
             <el-input-number
               v-model="updateForm.gasoilDiscountAmt"
               size="mini"
@@ -159,17 +166,18 @@
       <af-table-column
         label="优惠条件"
         align="center"
-        v-if="discountSetting==3"
+        v-if="discountSetting == 3"
       >
         <template slot-scope="scope">
-          满 {{ scope.row.discountAmt }} {{scope.row.discountTerm == 0 ? "元": "L"}},每升优惠
+          满 {{ scope.row.discountAmt }}
+          {{ scope.row.discountTerm == 0 ? "元" : "L" }},每升优惠
           {{ scope.row.gasoilDiscountAmt }} 元
         </template>
       </af-table-column>
       <af-table-column
         label="优惠条件"
         align="center"
-        v-if="discountSetting==1"
+        v-if="discountSetting == 1"
       >
         <template slot-scope="scope">
           每满 {{ scope.row.discountAmt }} 元,减
@@ -259,12 +267,14 @@ export default {
   data() {
     const validatorGasoilDiscountAmt = (rule, value, callback) => {
       console.log(this.updateForm.discountTerm);
-      if (
-        this.updateForm.discountTerm === undefined ||
-        this.updateForm.discountTerm === ""
-      ) {
-        callback(new Error("请选择优惠方式"));
-        return;
+      if (this.discountSetting == 3) {
+        if (
+          this.updateForm.discountTerm === undefined ||
+          this.updateForm.discountTerm === ""
+        ) {
+          callback(new Error("请选择优惠方式"));
+          return;
+        }
       }
       const start = +this.updateForm.discountAmt;
       const end = +this.updateForm.gasoilDiscountAmt;
@@ -299,9 +309,9 @@ export default {
         date: null,
         deductionGrowthValue: null,
       },
-
-      ruleForm: {
-      },
+      updateFormDynamic1: ["", "满", "每满", "满"],
+      updateFormDynamic2: ["", "减", "减", "每升优惠"],
+      ruleForm: {},
       // 表单校验
       rules: {
         grade: [{ required: true, message: "请输入方案名称", trigger: "blur" }],
@@ -344,15 +354,27 @@ export default {
         ? "直降"
         : "无";
     },
+    filterOilNameOptions(){
+      return this.oilNameOptions.filter((ele)=>{
+        let flag = true;
+        this.discountList.forEach(item=>{
+          if(ele.oilName == item.oilName){
+            flag = false;
+          }
+        })
+        return flag
+      })
+    }
   },
   created() {
-    this.init();
     this.setPageStatus();
+    this.init();
   },
   methods: {
     init() {
       listPrice().then((response) => {
         this.oilNameOptions = response.rows;
+        console.log(this.oilNameOptions)
       });
       this.getPay().then(() => {
         this.getList();
@@ -421,6 +443,7 @@ export default {
       };
       listPlan(query).then((response) => {
         this.discountList = response.rows;
+        console.log(this.discountList);
         this.total = response.total;
       });
     },