ソースを参照

新增优惠券

Joe 3 年 前
コミット
7a4244f173
3 ファイル変更454 行追加296 行削除
  1. 12 0
      src/api/coupon.js
  2. 1 0
      src/store/modules/user.js
  3. 441 296
      src/views/coupon/Coupon_CreateCoupon.vue

+ 12 - 0
src/api/coupon.js

@@ -26,6 +26,8 @@ export function addInfo(data) {
   })
 }
 
+
+
 // 修改优惠劵
 export function updateInfo(data) {
   return request({
@@ -59,4 +61,14 @@ export function verificationList(query) {
     method: 'get',
     params: query
   })
+}
+
+
+// 导出优惠劵
+export function changeCouponStatus(data) {
+  return request({
+    url: '/system/dept/updateDeptInfo',
+    method: 'put',
+    data: data
+  })
 }

+ 1 - 0
src/store/modules/user.js

@@ -79,6 +79,7 @@ const user = {
     GetInfo({ commit, state }) {
       return new Promise((resolve, reject) => {
         getInfo(state.token).then(res => {
+          console.log('用户信息',res)
           const user = res.user
           const avatar = user.avatar == "" ? require("@/assets/image/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
           if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组

+ 441 - 296
src/views/coupon/Coupon_CreateCoupon.vue

@@ -6,106 +6,120 @@
   </div>
   <div v-else-if="pageStatus == 3">加载发生错误</div>
   <div v-else-if="pageStatus == 4" class="app-container">
-    <el-form
-      :model="createForm"
-      ref="createForm"
-      :inline="true"
-      label-width="88px"
-    >
-      <el-form-item label="设备类型" prop="deviceType">
-        <el-select
-          v-model="createForm.deviceType"
-          clearable
-          placeholder="请选择"
-        >
-          <el-option label="小票打印机" value="1"></el-option>
-          <el-option label="POS" value="2"></el-option>
-        </el-select>
-      </el-form-item>
-
-      <el-form-item label="密钥" prop="deviceSerialNum">
-        <el-input
-          v-model="createForm.deviceSerialNum"
-          placeholder="请输入设备密钥"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-
-      <el-form-item>
-        <el-button
-          type="cyan"
-          icon="el-icon-search"
-          size="mini"
-          @click="handleQuery"
-          >搜索</el-button
-        >
-        <el-button
-          type="info"
-          icon="el-icon-refresh"
-          size="mini"
-          @click="resetQuery"
-          >重置</el-button
-        >
-        <el-button
-          type="primary"
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          >新增</el-button
-        >
+    <el-form>
+      <el-form-item label="启动优惠劵" label-width="88px">
+        <el-switch
+          v-model="couponEnabledFlag"
+          active-value="1"
+          inactive-value="0"
+          @change="handleFlagChange()"
+        ></el-switch>
       </el-form-item>
+      <hr />
     </el-form>
-
-    <el-table :data="couponList">
-      <!-- <af-table-column label="优惠" align="center" prop="deviceType">
-        <template slot-scope="scope">
-          {{
-            scope.row.deviceType == "1"
-              ? "小票打印机"
-              : scope.row.deviceType == "2"
-              ? "POS"
-              : "不明设备"
-          }}
-        </template>
-      </af-table-column> -->
-      <af-table-column label="优惠券名称" align="center" prop="couponName" />
-      <!-- <af-table-column label="面值" align="center" prop="gunNo" /> -->
-      <!-- <af-table-column label="有效期" align="center" prop="deviceFactory" /> -->
-      <af-table-column
-        label="操作"
-        align="center"
-        class-name="small-padding fixed-width"
-        width="120px"
+    <div v-if="couponEnabledFlag == 1">
+      <el-form
+        :model="createForm"
+        ref="createForm"
+        :inline="true"
+        label-width="88px"
       >
-        <template slot-scope="scope">
+        <el-form-item label="设备类型" prop="deviceType">
+          <el-select
+            v-model="createForm.deviceType"
+            clearable
+            placeholder="请选择"
+          >
+            <el-option label="小票打印机" value="1"></el-option>
+            <el-option label="POS" value="2"></el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="密钥" prop="deviceSerialNum">
+          <el-input
+            v-model="createForm.deviceSerialNum"
+            placeholder="请输入设备密钥"
+            clearable
+            size="small"
+            @keyup.enter.native="handleQuery"
+          />
+        </el-form-item>
+
+        <el-form-item>
           <el-button
+            type="cyan"
+            icon="el-icon-search"
             size="mini"
-            type="text"
-            icon="el-icon-edit"
-            @click="handleUpdate(scope.row)"
-            >修改</el-button
+            @click="handleQuery"
+            >搜索</el-button
           >
           <el-button
+            type="info"
+            icon="el-icon-refresh"
             size="mini"
-            type="text"
-            icon="el-icon-delete"
-            @click="handleDelete(scope.row)"
-            >删除</el-button
+            @click="resetQuery"
+            >重置</el-button
           >
-        </template>
-      </af-table-column>
-    </el-table>
-
-    <pagination
-      :hidden="total > 0 ? false : true"
-      :total="total"
-      :page.sync="queryForm.pageNum"
-      :limit.sync="queryForm.pageSize"
-      @pagination="getCoupon"
-      :autoScroll="true"
-    />
+          <el-button
+            type="primary"
+            icon="el-icon-plus"
+            size="mini"
+            @click="handleAdd"
+            >新增</el-button
+          >
+        </el-form-item>
+      </el-form>
+      <el-table :data="couponList">
+        <af-table-column label="优惠券名称" align="center" prop="couponName" />
+        <af-table-column label="状态" align="center" width="100">
+          <template slot-scope="scope">
+            <el-switch
+              v-model="scope.row.status"
+              active-value="1"
+              inactive-value="0"
+              @change="handleStatusChange(scope.row)"
+            ></el-switch>
+          </template>
+        </af-table-column>
+        <!-- <af-table-column label="面值" align="center" prop="gunNo" /> -->
+        <!-- <af-table-column label="有效期" align="center" prop="deviceFactory" /> -->
+        <af-table-column
+          label="操作"
+          align="center"
+          class-name="small-padding fixed-width"
+          width="120px"
+        >
+          <template slot-scope="scope">
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-edit"
+              @click="handleUpdate(scope.row)"
+              v-if="scope.row.editFlag"
+              >修改</el-button
+            >
+            <!-- <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-delete"
+              @click="handleDelete(scope.row)"
+              >删除</el-button
+            > -->
+          </template>
+        </af-table-column>
+      </el-table>
+      <pagination
+        :hidden="total > 0 ? false : true"
+        :total="total"
+        :page.sync="queryForm.pageNum"
+        :limit.sync="queryForm.pageSize"
+        @pagination="getCoupon"
+        :autoScroll="true"
+      />
+    </div>
+    <div v-else style="text-align:center">
+      亲,您的油站暂未启动优惠券功能,呦~
+    </div>
 
     <!-- 添加或修改油站设备管理对话框 -->
     <el-dialog
@@ -157,9 +171,10 @@
             <el-radio label="3">兑换劵</el-radio>
           </el-radio-group>
         </el-form-item>
-        <el-form-item label="优惠金额"
+        <el-form-item
+          label="优惠金额"
           prop="couponAmt"
-          v-if="createForm.couponType == 1 ||createForm.couponType == 2"
+          v-if="createForm.couponType == 1 || createForm.couponType == 2"
         >
           <div v-if="createForm.couponType == 1">
             固定面值—<input
@@ -180,12 +195,17 @@
             %
           </div>
         </el-form-item>
-        <el-form-item label="优惠券适用油品" prop="oilNameList">
+        <el-form-item
+          label="优惠券适用油品"
+          prop="oilNameList"
+          v-if="createForm.couponType == 1 || createForm.couponType == 2"
+        >
           <el-checkbox-group v-model="createForm.oilNameList">
-            <!-- <el-checkbox label="92#"></el-checkbox>
-            <el-checkbox label="93#"></el-checkbox>
-            <el-checkbox label="94#"></el-checkbox> -->
-            <el-checkbox label="94#" v-for="ele in oilNameList" :key="ele.oilName"></el-checkbox>
+            <el-checkbox
+              :label="ele.oilName"
+              v-for="ele in oilNameList"
+              :key="ele.oilName"
+            ></el-checkbox>
           </el-checkbox-group>
         </el-form-item>
         <el-form-item label="优惠券有效期" prop="effectiveTimeType">
@@ -196,7 +216,7 @@
                 <el-radio label="2">固定天数</el-radio>
               </el-radio-group>
             </div>
-            <div style="margin-top: 10px;">
+            <div style="margin-top: 10px">
               <div v-if="createForm.effectiveTimeType == 1">
                 <el-date-picker
                   style="margin: 0px 10px; width: 300px"
@@ -210,7 +230,10 @@
                 >
                 </el-date-picker>
               </div>
-              <div v-if="createForm.effectiveTimeType == 2" style="margin-left: 20px">
+              <div
+                v-if="createForm.effectiveTimeType == 2"
+                style="margin-left: 20px"
+              >
                 自用户领取后
                 <input
                   type="text"
@@ -235,17 +258,17 @@
         </el-form-item>
         <el-form-item label="单人可持有数量" prop="couponHoldNum">
-          单个用户最多拥有 
+          单个用户最多拥有
           <input
             type="text"
             class="form-control d-inline"
             v-model.number="createForm.couponHoldNum"
             style="width: 100px"
           />
-           张优惠券
+          张优惠券
         </el-form-item>
         <el-form-item label="累计可拥有数量" prop="couponReceiveNum">
-          单个用户累计可以拥有 
+          单个用户累计可以拥有
           <input
             type="text"
             class="form-control d-inline"
@@ -254,87 +277,130 @@
           />
           张优惠券
         </el-form-item>
-        <el-form-item label="优惠券的核销方" prop="couponType" v-if="createForm.couponType == 3">
+
+        <el-form-item
+          label="用券时可用电子卡"
+          prop="isCardFlag"
+          v-if="createForm.couponType == 1 || createForm.couponType == 2"
+        >
+          <el-radio-group v-model="createForm.isCardFlag">
+            <el-radio label="1">可以使用电子卡</el-radio>
+            <el-radio label="0">不可用电子卡</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item
+          label="用券时叠加等级优惠"
+          prop="isGradeFlag"
+          v-if="createForm.couponType == 1 || createForm.couponType == 2"
+        >
+          <el-radio-group v-model="createForm.isGradeFlag">
+            <el-radio label="1">叠加等级优惠</el-radio>
+            <el-radio label="0">不叠加等级优惠</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item
+          label="用劵时叠加优惠方案"
+          prop="isMakertFlag"
+          v-if="createForm.couponType == 1 || createForm.couponType == 2"
+        >
+          <el-radio-group v-model="createForm.isMakertFlag">
+            <el-radio label="1">叠加优惠方案</el-radio>
+            <el-radio label="0">不叠加优惠方案</el-radio>
+          </el-radio-group>
+        </el-form-item>
+
+        <el-form-item
+          label="优惠券的核销方"
+          prop="couponType"
+          v-if="createForm.couponType == 3"
+        >
           (自己的站点也是核销商)
         </el-form-item>
         <div v-if="createForm.couponType == 3">
-            <el-col :span="11">
-              <el-table
-                :data="unselectedCouponList"
-                border
-                size="mini"
-                :resizable="false"
-                highlight-current-row
-                height="500"
-                @selection-change="handleLeftChange"
-                disabled
-                ref="leftTable"
+          <el-col :span="11">
+            <el-table
+              :data="unselectedCouponList"
+              border
+              size="mini"
+              :resizable="false"
+              highlight-current-row
+              height="500"
+              @selection-change="handleLeftChange"
+              disabled
+              ref="leftTable"
+            >
               >
-                >
-                <el-table-column label="可选">
-                  <el-table-column
-                    prop="phone"
-                    label="姓名"
-                    type="selection"
-                  ></el-table-column>
-                  <el-table-column
-                    prop="deptName"
-                    label="机构"
-                  ></el-table-column>
-                  <el-table-column label="添加" width="60px" align="center">
-                    <template slot-scope="scope">
-                      <el-button
-                        type="text"
-                        icon="el-icon-circle-plus-outline"
-                        class="underline btn24"
-                        size="mini"
-                        @click="handleMoveLabel('right', 1, scope.row)"
-                      >添加</el-button>
-                    </template>
-                  </el-table-column>
+              <el-table-column label="可选">
+                <el-table-column
+                  prop="phone"
+                  label="姓名"
+                  type="selection"
+                ></el-table-column>
+                <el-table-column prop="deptName" label="机构"></el-table-column>
+                <el-table-column label="添加" width="60px" align="center">
+                  <template slot-scope="scope">
+                    <el-button
+                      type="text"
+                      icon="el-icon-circle-plus-outline"
+                      class="underline btn24"
+                      size="mini"
+                      @click="handleMoveLabel('right', 1, scope.row)"
+                      >添加</el-button
+                    >
+                  </template>
                 </el-table-column>
-              </el-table>
-              
-            </el-col>
-            <el-col :span="2" style="text-align: center;">
-               <el-button type="primary" size="mini" @click="toggleLabel" style="margin-top:200px;text-align:center;width:30px;padding-right:0;padding-left:0;" :disabled="toggleable">切换</el-button>
-            </el-col>
-            <el-col :span="11">
-              <el-table
-                :data="selectedCouponList"
-                border
-                size="mini"
-                highlight-current-row
-                :resizable="false"
-                height="500"
-                @selection-change="handleRightChange"
-                :loading="true"
-                ref="rightTable"
-              >
-                <el-table-column label="已选" :resizable="false">
-                  <el-table-column
-                    prop="phone"
-                    type="selection"
-                  ></el-table-column>
-                  <el-table-column
-                    prop="deptName"
-                    label="姓名"
-                  ></el-table-column>
-                  <el-table-column label="移除" width="60px" align="center">
-                    <template slot-scope="scope">
-                      <el-button
-                        type="text"
-                        icon="el-icon-remove-outline"
-                        class="underline btn24"
-                        size="mini"
-                        @click="handleMoveLabel('left', 1, scope.row)"
-                        >移除</el-button
-                      >
-                    </template>
-                  </el-table-column>
+              </el-table-column>
+            </el-table>
+          </el-col>
+          <el-col :span="2" style="text-align: center">
+            <el-button
+              type="primary"
+              size="mini"
+              @click="toggleLabel"
+              style="
+                margin-top: 200px;
+                text-align: center;
+                width: 30px;
+                padding-right: 0;
+                padding-left: 0;
+              "
+              :disabled="toggleable"
+              >切换</el-button
+            >
+          </el-col>
+          <el-col :span="11">
+            <el-table
+              :data="selectedCouponList"
+              border
+              size="mini"
+              highlight-current-row
+              :resizable="false"
+              height="500"
+              @selection-change="handleRightChange"
+              :loading="true"
+              ref="rightTable"
+            >
+              <el-table-column label="已选" :resizable="false">
+                <el-table-column
+                  prop="phone"
+                  type="selection"
+                ></el-table-column>
+                <el-table-column prop="deptName" label="姓名"></el-table-column>
+                <el-table-column label="移除" width="60px" align="center">
+                  <template slot-scope="scope">
+                    <el-button
+                      type="text"
+                      icon="el-icon-remove-outline"
+                      class="underline btn24"
+                      size="mini"
+                      @click="handleMoveLabel('left', 1, scope.row)"
+                      >移除</el-button
+                    >
+                  </template>
                 </el-table-column>
-              </el-table>
-            </el-col>
+              </el-table-column>
+            </el-table>
+          </el-col>
         </div>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -358,7 +424,8 @@ import {
 import { listGun } from "@/api/station/gun";
 import { listPrice } from "@/api/station/price";
 
-import { addInfo,verificationList,listInfo } from "@/api/coupon";
+import { addInfo, verificationList, listInfo, updateInfo, changeCouponStatus } from "@/api/coupon";
+import { updateDept } from "@/api/system/dept";
 
 export default {
   name: "Station_Equipment",
@@ -367,48 +434,32 @@ export default {
       callback();
     };
     return {
+      couponEnabledFlag: "1",
       pageStatus: 4,
       // 油站设备管理表格数据
       createForm: {
         couponName: "",
-        couponDetails:'',
+        couponDetails: "",
         couponThresholdAmt: 0,
         couponType: "1",
         couponAmt: 0,
-        oilNameList: ['92#'],
+        oilNameList: [],
         effectiveTimeType: "", //有效时间类型: 1,固定时间;2,领取后x天内有效
-        effectiveTime:[],
-        effectiveDayNum: 3,
-        couponHoldNum: 2,
-        couponReceiveNum: 1,
+        effectiveTime: [],
+        effectiveDayNum: 30,
+        couponHoldNum: 1,
+        couponReceiveNum: 100,
         couponNum: 100,
-        status: 1,
-        verificationList: [2,5,7],
+        status: "1",
+        verificationList: [],
+        isCardFlag: "1",
+        isGradeFlag: "1",
+        isMakertFlag: "1",
       },
-      couponList:[],
-      oilNameList:[],
-      allVerificationList: [{
-        deptId: 1,
-        deptName:'固定1'
-      },{
-        deptId: 2,
-        deptName:'油站2'
-      },{
-        deptId: 3,
-        deptName:'固定3'
-      },{
-        deptId: 4,
-        deptName:'油站4'
-      },{
-        deptId: 5,
-        deptName:'固定5'
-      },{
-        deptId: 6,
-        deptName:'油站6'
-      },{
-        deptId: 7,
-        deptName:'油站7'
-      }],
+      couponList: [],
+      oilNameList: [],
+      allVerificationList: [
+      ],
       equipmentList: [],
       // 油枪复选
       allGunList: [],
@@ -425,21 +476,19 @@ export default {
       open: false,
       // 总条数
       total: 100,
-      leftQuery:{},
-      rightQuery:{},
-      leftData:[],
-      rightData:[],
+      leftQuery: {},
+      rightQuery: {},
+      leftData: [],
+      rightData: [],
       moveRightData: [],
-      moveLeftData:[],
+      moveLeftData: [],
       // 查询参数
       queryForm: {
         pageNum: 1,
         pageSize: 10, // 初始值只能比10大
       },
       // 表单校验
-      rules: {
-
-      },
+      rules: {},
     };
   },
   created() {
@@ -448,92 +497,147 @@ export default {
     this.setPageStatus();
   },
   computed: {
-    toggleable(){
-      if(this.moveRightData.length === 0 && this.moveLeftData.length === 0){
+    toggleable() {
+      if (this.moveRightData.length === 0 && this.moveLeftData.length === 0) {
         return true;
       }
       return false;
     },
-    selectedCouponList(){
-      return this.allVerificationList.filter((ele)=>{
-        return this.createForm.verificationList.includes(ele.deptId)
-      })
+    selectedCouponList() {
+      return this.allVerificationList.filter((ele) => {
+        return this.createForm.verificationList.includes(ele.deptId);
+      });
     },
-    unselectedCouponList(){
-      return this.allVerificationList.filter((ele)=>{
-        return !!!this.createForm.verificationList.includes(ele.deptId)
-      })
+    unselectedCouponList() {
+      return this.allVerificationList.filter((ele) => {
+        return !!!this.createForm.verificationList.includes(ele.deptId);
+      });
     },
-    getTodayDateString(){
-      const today = new Date()
-      return 
+    getTodayDateString() {
+      const today = new Date();
+      return;
     },
   },
   methods: {
-    getOilList(){
-      listPrice().then((res) => {
-        console.log('油品',res)
-        if(res.code == 200){
-          this.oilNameList = res.rows || []
-        }else{
-          throw new Error("")
-        }
-      }).catch((err) => {
-        this.msgError("亲,拉取油品列表失败~")
+    handleFlagChange() {
+      const that = this
+      let text = this.couponEnabledFlag === "1" ? "启用" : "停用";
+      this.$confirm('确认要"' + text + '"优惠券功能吗?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
       })
+        .then(function () {
+          return changeCouponStatus({
+            deptId: that.deptId,
+            couponEnabledFlag: that.couponEnabledFlag,
+          });
+        })
+        .then(() => {
+          that.msgSuccess(text + "成功");
+        })
+        .catch(function () {
+          that.couponEnabledFlag = that.couponEnabledFlag === "0" ? "1" : "0";
+        });
+    },
+    handleStatusChange(row) {
+      let text = row.status === "1" ? "启用" : "停用";
+      this.$confirm(
+        '确认要"' + text + '""' + row.couponName + '"该优惠券吗?',
+        "警告",
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }
+      )
+        .then(function () {
+          return updateInfo({
+            id: row.id,
+            status: row.status,
+          });
+        })
+        .then(() => {
+          this.msgSuccess(text + "成功");
+        })
+        .catch(function () {
+          row.status = row.status === "0" ? "1" : "0";
+        });
+    },
+    getOilList() {
+      listPrice()
+        .then((res) => {
+          if (res.code == 200) {
+            this.oilNameList = res.rows || [];
+          } else {
+            throw new Error("");
+          }
+        })
+        .catch((err) => {
+          this.msgError("亲,拉取油品列表失败~");
+        });
     },
     getCoupon() {
       listInfo({
         pageNum: 1,
         pageSize: 10,
-      }).then((res)=>{
-        if(res.code == 200){
-          console.log(res)
-          if(res.rows == null){
-            this.total = 0
-            this.couponList = [];
-          }else{
-            this.total = res.total;
-            this.couponList = res.rows;
-          }
-        }else{
-          throw new Error('');
-        }
-      }).catch((err)=>{
-        this.msgError("亲,拉取优惠券列表失败~")
       })
+        .then((res) => {
+          if (res.code == 200) {
+            console.log(res);
+            if (res.rows == null) {
+              this.total = 0;
+              this.couponList = [];
+            } else {
+              this.total = res.total;
+              this.couponList = res.rows;
+            }
+          } else {
+            throw new Error("");
+          }
+        })
+        .catch((err) => {
+          this.msgError("亲,拉取优惠券列表失败~");
+        });
     },
-    getVerificationList(){
+    getVerificationList() {
       verificationList({
         pageNum: 1,
-        pageSize: 1000
-      }).then((res)=>{
-        if(res.code == 200){
-          if(res.rows == null){
-            this.allVerificationList = [];
-          }else{
-            this.allVerificationList = res.rows;
-          }
-        }else{
-          throw new Error('');
-        }
-      }).catch((err)=>{
-        this.msgError("亲,拉取核销机构失败~")
+        pageSize: 1000,
       })
-    },
-    toggleLabel(){
-      if(this.moveLeftData.length !== 0){
-        this.createForm.verificationList = this.createForm.verificationList.filter((ele)=>{
-          return ele  != this.moveLeftData
+        .then((res) => {
+          if (res.code == 200) {
+            if (res.rows == null) {
+              this.allVerificationList = [];
+            } else {
+              this.allVerificationList = res.rows;
+            }
+          } else {
+            throw new Error("");
+          }
         })
-        this.createForm = {...this.createForm}
+        .catch((err) => {
+          this.msgError("亲,拉取核销机构失败~");
+        });
+    },
+    toggleLabel() {
+      if (this.moveLeftData.length !== 0) {
+        this.createForm.verificationList =
+          this.createForm.verificationList.filter((ele) => {
+            return ele != this.moveLeftData;
+          });
+        this.createForm = { ...this.createForm };
         return;
       }
-      if(this.moveRightData.length !== 0){
-        this.createForm.verificationList = [...new Set(this.createForm.verificationList.concat(this.moveRightData))].filter((ele)=>{
-          return !!ele
-        })
-        this.createForm = {...this.createForm}
+      if (this.moveRightData.length !== 0) {
+        this.createForm.verificationList = [
+          ...new Set(
+            this.createForm.verificationList.concat(this.moveRightData)
+          ),
+        ].filter((ele) => {
+          return !!ele;
+        });
+        this.createForm = { ...this.createForm };
         return;
       }
       return;
@@ -543,23 +647,23 @@ export default {
       val.map((ele) => {
         changeArr.push(ele.deptId);
       });
-      console.log(changeArr)
-      this.moveLeftData = []
-      this.moveRightData = changeArr
+      console.log(changeArr);
+      this.moveLeftData = [];
+      this.moveRightData = changeArr;
       // console.log(this.moveRightData);
-      this.$refs.rightTable.clearSelection()
+      this.$refs.rightTable.clearSelection();
     },
-    handleRightChange(val){
+    handleRightChange(val) {
       let changeArr = [];
       val.map((ele) => {
         changeArr.push(ele.deptId);
       });
-      this.moveLeftData = changeArr
-      this.moveRightData = []
-      this.$refs.leftTable.clearSelection()
+      this.moveLeftData = changeArr;
+      this.moveRightData = [];
+      this.$refs.leftTable.clearSelection();
     },
     init() {
-      this.getOilList()
+      this.getOilList();
       this.getCoupon();
       this.getVerificationList();
     },
@@ -588,12 +692,31 @@ export default {
     /** 新增按钮操作 */
     handleAdd() {
       this.title = "添加优惠券";
+      this.createForm = {
+        couponName: "",
+        couponDetails: "",
+        couponThresholdAmt: 0,
+        couponType: "1",
+        couponAmt: 0,
+        oilNameList: [],
+        effectiveTimeType: "", 
+        effectiveTime: [],
+        effectiveDayNum: 30,
+        couponHoldNum: 1,
+        couponReceiveNum: 100,
+        couponNum: 100,
+        status: "1",
+        verificationList: [],
+        isCardFlag: "1",
+        isGradeFlag: "1",
+        isMakertFlag: "1",
+      }
       this.open = true;
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
       // // 查找自己已经选中的枪号
-      this.createForm =  JSON.parse(JSON.stringify(row)) 
+      this.createForm = JSON.parse(JSON.stringify(row));
       this.title = "修改油站设备管理";
       this.open = true;
     },
@@ -602,10 +725,32 @@ export default {
     submitForm() {
       this.$refs["dialogForm"].validate((valid) => {
         if (valid) {
-          //this.dialogForm.gunNo = this.dialogForm.checkedGunList.toString();
-          addInfo(this.createForm).then((res) => {
-            console.log(res)
-          })
+          if(!!this.createForm.id){
+            updateInfo(this.createForm).then((res) => {
+              if(res.code == 200){
+                this.msgSuccess("亲,修改成功了~")
+                this.getCoupon()
+                this.open = false
+              }else{
+                throw new Error("");
+              }
+            }).catch((err) => {
+              this.msgError("修改失败了呀~")
+            });
+          }else{
+            addInfo(this.createForm).then((res) => {
+              if(res.code == 200){
+                this.msgSuccess("亲,新增成功了~")
+                this.getCoupon()
+                this.open = false
+              }else{
+                throw new Error("");
+              }
+            }).catch((err)=>{
+              this.msgError("创建优惠劵失败了~")
+            });
+          }
+          
         }
       });
     },