Browse Source

Merge branch '11/24SAAS' of http://git.dayaedu.com/yonge/dy-admin-manager into 11/24SAAS

lex-xin 3 years ago
parent
commit
3e909fbfdc
2 changed files with 62 additions and 21 deletions
  1. 14 1
      src/views/couponManager/api.js
  2. 48 20
      src/views/couponManager/couponRecord.vue

+ 14 - 1
src/views/couponManager/api.js

@@ -40,7 +40,7 @@ export const getSysCouponCode = data => request2({
   params: data,
   method: 'get',
 })
-
+// 新
 // 手动发放优惠券
 export const getIssueCoupon = data => request2({
   url: '/api-web/sysCouponIssue/issueCoupon',
@@ -62,3 +62,16 @@ export const getIssueRecordDetail = data => request2({
   method: 'post',
 })
 
+// 查询发放优惠券使用情况
+export const checkRevoke = data => request2({
+  url: '/api-web/sysCouponIssue/checkRevoke',
+ data,
+  method: 'post',
+})
+
+// 撤销发放
+export const revokeCoupon = data => request2({
+  url: '/api-web/sysCouponIssue/revokeCoupon',
+ data,
+  method: 'post',
+})

+ 48 - 20
src/views/couponManager/couponRecord.vue

@@ -39,16 +39,12 @@
             prop="num"
             label="数量"
           ></el-table-column>
-          <el-table-column
-            align="center"
-            prop="phone"
-            label="操作"
-          >
-          <template slot-scope="scope">
-            <div>
-              {{scope.row.ops?'撤回':'发放'}}
-            </div>
-          </template>
+          <el-table-column align="center" prop="phone" label="操作">
+            <template slot-scope="scope">
+              <div>
+                {{ scope.row.ops ? "撤回" : "发放" }}
+              </div>
+            </template>
           </el-table-column>
           <el-table-column
             align="center"
@@ -81,7 +77,13 @@
         />
       </div>
 
-      <el-dialog title="发放名单" :visible.sync="couponDetailVisible" width="1000px" append-to-body v-if="couponDetailVisible">
+      <el-dialog
+        title="发放名单"
+        :visible.sync="couponDetailVisible"
+        width="1000px"
+        append-to-body
+        v-if="couponDetailVisible"
+      >
         <couponGiveChiose :activeRow="activeRows" />
         <span slot="footer" class="dialog-footer">
           <el-button @click="couponDetailVisible = false">取 消</el-button>
@@ -97,11 +99,11 @@
 <script>
 import pagination from "@/components/Pagination/index";
 import { getStudentList } from "@/api/vipSeting";
-import {getIssueRecord} from './api'
-import couponGiveChiose from'./couponGiveChiose'
+import { getIssueRecord, checkRevoke,revokeCoupon } from "./api";
+import couponGiveChiose from "./couponGiveChiose";
 export default {
-  props:['activeRow'],
-  components: { pagination,couponGiveChiose },
+  props: ["activeRow"],
+  components: { pagination, couponGiveChiose },
   data() {
     return {
       searchForm: {
@@ -118,8 +120,8 @@ export default {
         total: 0, // 总条数
         page_size: [10, 20, 40, 50], // 选择限制显示条数
       },
-      couponDetailVisible:false,
-      activeRows:null
+      couponDetailVisible: false,
+      activeRows: null,
     };
   },
   //生命周期 - 创建完成(可以访问当前this实例)
@@ -145,7 +147,7 @@ export default {
           ...rest,
           page: this.rules.page,
           rows: this.rules.limit,
-          couponId:this.activeRow.id
+          couponId: this.activeRow.id,
         };
         const res = await getIssueRecord(params);
         this.tableList = res.data.rows;
@@ -154,10 +156,36 @@ export default {
         console.log(e);
       }
     },
-    revokeCoupon(row) {},
+    async revokeCoupon(row) {
+      let num = 0;
+      try {
+        const res = await checkRevoke({ issueId: row.id });
+        num = res.data;
+      } catch (e) {
+        console.log(e);
+      }
+      let str = "";
+      if (num > 0) {
+        str = `当前已有${num}学员优惠券已使用,仅可对未使用学员撤回.是否确认继续撤销?`;
+      } else {
+        str = "是否确认继续撤销?";
+      }
+      this.$confirm(str, "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+      }).then(async some=>{
+        try{
+          const res = await revokeCoupon({issueId: row.id})
+          this.$message.success('撤销成功')
+          this.getList()
+        }catch(e){
+
+        }
+      })
+    },
     couponDetail(row) {
       this.activeRows = row;
-      this.couponDetailVisible = true
+      this.couponDetailVisible = true;
     },
   },
 };