Quellcode durchsuchen

Merge remote-tracking branch 'origin/dev' into dev

DELL vor 3 Jahren
Ursprung
Commit
d2db9ce208

+ 33 - 10
src/api/business/couponPkg.js

@@ -1,6 +1,6 @@
 import request from '@/utils/request'
 
-//查询列表
+// 查询列表
 export function getCouponList(urlParams, data) {
   return request({
     url: '/api/v1/mp/admin/coupon/pkg/list',
@@ -10,22 +10,45 @@ export function getCouponList(urlParams, data) {
   })
 }
 
-//删除券包
-export function delCoupon(couponId) {
+// 删除券包
+export function delCoupon(id) {
   return request({
-    url: `/api/v1/mp/admin/coupon/pkg/delete/${couponId}`,
+    url: `/api/v1/mp/admin/coupon/pkg/delete/${id}`,
+    method: 'post'
+  })
+}
+
+// 上架下架
+export function setCouponPkgStatus(data) {
+  return request({
+    url: '/api/v1/mp/admin/coupon/pkg/status',
     method: 'post',
-    headers: {
-      'Content-Type': 'application/x-www-form-urlencoded'
-    },
+    data
   })
 }
 
-//上架下架
-export function setCouponStatus(data) {
+// 创建券包
+export function couponPkgCreate(data) {
   return request({
-    url: '/api/v1/mp/admin/coupon/status',
+    url: '/api/v1/mp/admin/coupon/pkg/create',
     method: 'post',
     data
   })
 }
+
+// 修改券包
+export function couponPkgUpdate(data) {
+  return request({
+    url: '/api/v1/mp/admin/coupon/pkg/update',
+    method: 'post',
+    data
+  })
+}
+
+// 券包详情
+export function couponPkgDetail(orderId) {
+  return request({
+    url: `/api/v1/mp/admin/coupon/pkg/detail/${ orderId }`,
+    method: 'post',
+  })
+}

+ 2 - 2
src/router/index.js

@@ -214,11 +214,11 @@ export const constantRoutes = [
         path: 'pkg/add',
         component: (resolve) => require(['@/views/business/couponPkg/create'], resolve),
         name: 'CouponPkgAdd',
-        meta: { title: '添加券包', activeMenu: '/coupon/listCouponPkg', noCache: true }
+        meta: { title: '生成券包', activeMenu: '/coupon/listCouponPkg', noCache: true }
       },
       {
         path: 'pkg/query',
-        component: (resolve) => require(['@/views/business/couponPkg/detail'], resolve),
+        component: (resolve) => require(['@/views/business/couponPkg/create'], resolve),
         name: 'CouponPkgQuery',
         meta: { title: '查看券包', activeMenu: '/coupon/listCouponPkg', noCache: true }
       },

+ 186 - 0
src/views/business/couponPkg/components/CouponAdd.vue

@@ -0,0 +1,186 @@
+<template>
+  <div>
+    <el-dialog
+      title="添加券"
+      width="1000px"
+      :visible.sync="dialogVisible"
+      :before-close="close"
+    >
+      <div class="dialog-search">
+        <div>券名称:</div>
+        <el-input
+          v-model="couponTitle"
+          placeholder="请输入券名称"
+          clearable
+          size="small"
+          style="width: 240px"
+          @keyup.enter.native="getCouponList"
+        />
+        <div class="ge"></div>
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="getCouponList"
+          >查询</el-button
+        >
+      </div>
+      <el-table
+        v-loading="loading"
+        :data="couponList"
+        @selection-change="handleSelectionCoupon"
+        class="el-table"
+      >
+        <el-table-column
+          type="selection"
+          width="55"
+          align="center"
+          fixed="left"
+        />
+        <!--  -->
+        <el-table-column label="券ID" prop="couponId" />
+        <el-table-column label="券图片">
+          <template slot-scope="scope">
+            <div>
+              <el-image
+                style="width: 100px; height: 100px"
+                :src="scope.row.picUrl"
+                :preview-src-list="[scope.row.picUrl]"
+              >
+              </el-image>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column label="券名称" prop="title" min-width="85" />
+        <el-table-column label="使用场景" min-width="85">
+          <template slot-scope="scope">
+            <div>{{ scope.row.type.desc }}</div>
+          </template>
+        </el-table-column>
+        <el-table-column label="券价格" min-width="85">
+          <template slot-scope="scope">
+            <div>¥{{ $numberFormat(scope.row.discount) }}</div>
+          </template>
+        </el-table-column>
+        <el-table-column label="有效期限" min-width="85">
+          <template slot-scope="scope">
+            <div>领取后{{ scope.row.dueDays }}天有效</div>
+          </template>
+        </el-table-column>
+      </el-table>
+      <pagination
+        v-show="couponTotal > 0"
+        :total="couponTotal"
+        :page.sync="pageParams.pageNum"
+        :limit.sync="pageParams.pageSize"
+        @pagination="getCouponList"
+      />
+      <div class="dialog-btn">
+        <el-button size="small" @click="close"> 取 消 </el-button>
+        <div class="ge"></div>
+        <el-button type="primary" size="small" @click="confirmCoupon">
+          确 认
+        </el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+<script>
+import { publicFileGetUrl } from "@/api/common";
+import { getCouponList } from "@/api/business/coupon";
+export default {
+  name: "CouponAdd",
+  props: {
+    dialogVisible: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  data() {
+    return {
+      loading: false,
+      couponTitle: "", // 券名称
+      couponList: [], // 卡券列表
+      couponTotal: 0, // 卡券总数
+      selectCouponList: [], // 选中卡券
+      pageParams: {
+        pageNum: 1,
+        pageSize: 10,
+      },
+    };
+  },
+  created() {
+    this.getCouponList();
+  },
+  methods: {
+    // 卡券列表
+    getCouponList() {
+      this.loading = true;
+      getCouponList(
+        "pageNum=" +
+          this.pageParams.pageNum +
+          "&pageSize=" +
+          this.pageParams.pageSize +
+          "&",
+        { title: this.couponTitle, status: "on" }
+      ).then((res) => {
+        this.couponList = res.rows.map((item) => {
+          return {
+            ...item,
+            type: JSON.parse(item.type),
+            useArea: JSON.parse(item.useArea),
+            picUrl: publicFileGetUrl + item.picUrl,
+          };
+        });
+        this.couponTotal = res.total;
+        this.loading = false;
+      });
+    },
+
+    // 选中卡券
+    handleSelectionCoupon(e) {
+      this.selectCouponList = e.map((item) => {
+        return {
+          couponNum: 1,
+          couponId: item.couponId,
+          title: item.title,
+          createdTime: item.createdTime,
+          updatedTime: item.updatedTime,
+          type: item.type,
+          discount: item.discount,
+          dueDays: item.dueDays
+        };
+      });
+    },
+
+    // 确认选中卡券
+    confirmCoupon() {
+      this.$emit("confirmCoupon", this.selectCouponList);
+      this.close()
+    },
+
+    close() {
+      this.$emit("close");
+    },
+  },
+};
+</script>
+<style lang="scss" scoped>
+.dialog-search {
+  display: flex;
+  line-height: 32px;
+  margin-bottom: 20px;
+  .ge {
+    width: 40px;
+  }
+}
+.dialog-btn {
+  display: flex;
+  align-content: center;
+  justify-content: flex-end;
+  padding: 40px 0 0;
+  .ge {
+    width: 40px;
+  }
+}
+</style>

+ 0 - 108
src/views/business/couponPkg/components/selectTicket.vue

@@ -1,108 +0,0 @@
-<template>
-  <el-dialog title="添加券" :visible.sync="selectShow" width="800px" :close-on-click-modal="false" :destroy-on-close="true">
-    <el-form :model="queryParams" ref="queryForm" label-width="80px" size="small">
-      <el-row :gutter="10">
-        <el-col :span="7">
-          <el-form-item label="券名称">
-            <el-input
-              v-model="queryParams.title"
-              placeholder="请输入券名称"
-              clearable
-              @keyup.enter.native="queryParams.pageNum = 1;getList()"
-            />
-          </el-form-item>
-        </el-col>
-        <el-col :span="3">
-          <el-form-item label-width="0">
-            <el-button type="primary" icon="el-icon-search" @click="queryParams.pageNum = 1;getList()">搜索</el-button>
-          </el-form-item>
-        </el-col>
-      </el-row>
-    </el-form>
-    <el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" />
-      <el-table-column label="券编号" prop="boxId" width="80" />
-      <el-table-column label="图片" prop="picUrl" align="center" width="80">
-        <template slot-scope="{row}">
-          <a target="_black" v-if="row.picUrl && row.picUrl.split(',').length > 0" :href="`${IMG_URL + row.picUrl}`"><img :src="`${IMG_URL + row.picUrl.split(',')[0]}`" style="max-height: 37px;max-width: 54px"></a>
-          <span v-else>-</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="名称" prop="title" />
-      <el-table-column label="使用场景" prop="type">
-        <template slot-scope="{row}">
-          {{ JSON.parse(row.type).desc }}
-        </template>
-      </el-table-column>
-      <el-table-column label="金额" prop="facePrice" />
-      <el-table-column label="有效期限" prop="status">
-        <template slot-scope="{row}">
-          <el-tag :type="JSON.parse(row.status).value === 'on' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
-        </template>
-      </el-table-column>
-    </el-table>
-    <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList()" />
-    <span slot="footer">
-      <el-button type="info" plain @click="selectShow = false">取消</el-button>
-      <el-button type="primary" @click="update">确定</el-button>
-    </span>
-  </el-dialog>
-</template>
-<script>
-import { getTicketList, setListData } from "@/api/business/ticketPkg"
-import { publicFileGetUrl } from "@/api/common"
-export default {
-  name: "SelectTicket",
-  props: {
-    value: {
-      type: Array,
-      default: []
-    }
-  },
-  data() {
-    return {
-      IMG_URL: publicFileGetUrl,
-      loading: false,
-      selectShow: false,
-      tableData: [],
-      queryParams: {},
-      total: 0,
-      selection: []
-    }
-  },
-  methods: {
-    show() {
-      this.getList(true)
-      this.selectShow = true
-      this.selection = this.value
-      // this.$refs.table.toggleRowSelection(this.selection)
-    },
-    getList(reset) {
-      if (this.loading) {
-        return
-      }
-      this.loading = true
-      if (reset) {
-        this.queryParams = { pageNum: 1, pageSize: 20 }
-      }
-      getTicketList('pageNum='+this.queryParams.pageNum + '&pageSize='+this.queryParams.pageSize+'&', this.queryParams).then(res => {
-        this.loading = false
-        if (res.code === 0) {
-          this.tableData = res.rows
-
-          this.total = res.total
-        }
-      }).catch(() => {
-        this.loading = false
-      })
-    },
-    handleSelectionChange(val) {
-      this.selection = val
-    },
-    update() {
-      this.$emit('input', this.selection)
-      this.selectShow = false
-    }
-  }
-}
-</script>

+ 105 - 32
src/views/business/couponPkg/create.vue

@@ -8,29 +8,45 @@
         </el-form>
     </el-row>
     <br>
-    <el-button v-if="!readonly" type="primary" size="small" plain @click="$refs.select.show()">添加优惠券</el-button>
+    <el-button v-if="!readonly" type="primary" size="small" plain @click="couponTableVisible = true">添加优惠券</el-button>
     <br>
     <br>
-    <span style="font-size: 14px; line-height: 40px">面值总额:¥{{ addData.ticketBoxList.length }}</span>
-    <span style="margin-left: 80px;font-size: 14px; line-height: 40px">优惠券数量:{{ addData.ticketBoxList.length }}</span>
-    <el-table v-if="addData.useArea === 5" :data="addData.ticketBoxList">
-      <el-table-column label="券编号" prop="" align="center" />
+    <span style="font-size: 14px; line-height: 40px">面值总额:¥{{ $numberFormat(totalPrice) }}</span>
+    <span style="margin-left: 80px;font-size: 14px; line-height: 40px">优惠券数量:{{ couponPkgItemList.length }}</span>
+    <el-table :data="couponPkgItemList">
+      <el-table-column label="券编号" prop="couponId" align="center" />
       <el-table-column label="券名称" prop="title" />
-      <el-table-column label="券金额" prop="facePrice" />
+       <el-table-column label="券金额" min-width="85">
+          <template slot-scope="{ row }">
+            <div>¥{{ $numberFormat(row.discount) }}</div>
+          </template>
+        </el-table-column>
       <el-table-column label="使用场景" prop="type">
-        <template slot-scope="{row}">
-          {{ JSON.parse(row.type).desc }}
+        <template slot-scope="{ row }">
+          <div>{{ row.type.desc }}</div>
         </template>
       </el-table-column>
-      <el-table-column label="数量" prop="title" />
-      <el-table-column label="有效期限" prop="status">
-        <template slot-scope="{row}">
-          <el-tag :type="JSON.parse(row.status).value === 'on' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
+      <el-table-column label="数量" align="center">
+        <template slot-scope="{ row }">
+          <div>
+            <el-input-number
+              :disabled="readonly"
+              v-model="row.couponNum"
+              controls-position="right"
+              :min="1"
+              size="small"
+            ></el-input-number>
+          </div>
         </template>
       </el-table-column>
-      <el-table-column v-if="!readonly" prop="date" label="操作">
+      <el-table-column label="有效期限" min-width="85" align="center">
+          <template slot-scope="{ row }">
+            <div>领取后{{ row.dueDays }}天有效</div>
+          </template>
+        </el-table-column>
+      <el-table-column v-if="!readonly" prop="date" label="操作" align="center">
         <template slot-scope="{ $index }">
-          <el-button type="text" class="del" @click="addData.ticketBoxList.splice($index, 1)">删除</el-button>
+          <el-button type="text" class="del" @click="couponPkgItemList.splice($index, 1);getPrice()">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -41,40 +57,97 @@
         <el-button :loading="addIng" type="primary" @click="update()">保存</el-button>
       </el-col>
     </el-row>
-    <!-- 弹出层 -->
-    <SelectTicket ref="select" v-model="addData.ticketBoxList" />
+    
+    <!-- 添加券 -->
+    <coupon-add :dialog-visible="couponTableVisible" @close="couponTableVisible = false" @confirmCoupon="confirmCoupon" v-if="couponTableVisible" />
   </div>
 </template>
 <script>
-import Upload from '@/components/ImageUpload'
-import SelectTicket from '../couponPkg/components/selectTicket'
-import { publicFileGetUrl } from '@/api/common'
-import { getCouponDetail, addCoupon } from '@/api/business/coupon'
-import { accDiv, accMul } from '@/utils/util'
-import {addData} from "../../../api/system/dict/data";
+import { couponPkgCreate, couponPkgDetail, couponPkgUpdate } from "@/api/business/couponPkg";
+import CouponAdd from "./components/CouponAdd"
 export default {
   components: {
-    Upload,
-    SelectTicket
+    CouponAdd
   },
   data() {
     return {
-      IMG_URL: publicFileGetUrl,
       id: this.$route.query.id,
       readonly: this.$route.name === 'CouponPkgQuery',
-      addData: {
-        ticketBoxList:[],
-        useArea: 5,
-        type: 2,
-      },
+      addData: {},
+      couponTableVisible: false,
+      couponPkgItemList: [],
+      totalPrice: 0,
       addIng: false,
       rules: {
         title: [{ required: true, message: '请输入券包名称', trigger: 'blur' }]
       }
-
     };
   },
-  methods: {},
+  created() {
+    if(this.id) {
+      couponPkgDetail(this.id).then(res => {
+        const { couponPkgItemVOList, facePrice, title } = res.data
+        this.addData = { title }
+        this.totalPrice = facePrice
+        this.couponPkgItemList = couponPkgItemVOList.map(item => {
+          return {
+            ... item, 
+            type: item.type && JSON.parse(item.type)
+          }
+        })
+      })
+    }
+  },
+  methods: {
+    confirmCoupon(arr) {
+      this.couponPkgItemList = this.couponPkgItemList.concat(arr)
+      this.getPrice()
+    },
+
+    getPrice() {
+      let num = 0
+      this.couponPkgItemList.forEach(item => {
+        num = item.discount + num
+      })
+      this.totalPrice = num
+    },
+
+    update() {
+      const subForm = this.$refs["addItem"];
+      subForm.validate((valid) => {
+        if (valid) {
+          if(!this.couponPkgItemList.length) {
+            this.$message.error('请添加优惠券');
+            return
+          }
+          this.addIng = true
+          let data = {
+            title: this.addData.title,
+            couponPkgItemList: this.couponPkgItemList,
+            facePrice: this.totalPrice,
+            couponNum: this.couponPkgItemList.length
+          }
+          if(this.id){
+            data.id = this.id
+          }
+          let request = this.id ? couponPkgUpdate : couponPkgCreate
+          request(data).then(res => {
+            this.addIng = false
+            if (res.code === 0) {
+              this.$message({
+                message: this.id ? '修改成功!' : '添加成功!',
+                type: 'success'
+              })
+              this.$store.dispatch('tagsView/delView', this.$route)
+              this.$router.go(-1)
+            }
+          }).catch(() => {
+            this.addIng = false
+          })
+          }
+      });
+    }
+  },
 };
 </script>
 <style>

+ 0 - 15
src/views/business/couponPkg/detail.vue

@@ -1,15 +0,0 @@
-<template>
-  <div>
-    查看
-  </div>
-</template>
-<script>
-export default {
-  data() {
-    return {};
-  },
-  methods: {},
-};
-</script>
-<style>
-</style>

+ 169 - 74
src/views/business/couponPkg/index.vue

@@ -1,17 +1,33 @@
 <template>
-  <div class="app-container coupon-list">
-    <el-form v-show="showSearch" :model="queryParams" ref="queryForm" :inline="true" size="small">
-      <el-form-item label="券名称">
-        <el-input
+  <div class="app-container">
+    <el-form
+      v-show="showSearch"
+      :model="queryParams"
+      ref="queryForm"
+      :inline="true"
+      size="small"
+      @submit.native.prevent
+    >
+      <el-form-item label="券包名称" prop="title">
+         <el-input
           v-model="queryParams.title"
-          placeholder="请输入券名称"
+          placeholder="请输入券名称"
           clearable
-          @keyup.enter.native="queryParams.pageNum = 1;getList()"
+          size="small"
+          style="width: 240px"
+          @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-search" @click="queryParams.pageNum = 1;getList()">搜索</el-button>
-        <el-button icon="el-icon-refresh" @click="getList(true)">重置</el-button>
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          @click="handleQuery"
+          >搜索</el-button
+        >
+        <el-button icon="el-icon-refresh" @click="resetQuery"
+          >重置</el-button
+        >
       </el-form-item>
     </el-form>
     <el-row :gutter="10" class="mb8">
@@ -22,108 +38,187 @@
           size="mini"
           @click="$router.push({ name: 'CouponPkgAdd' })"
           v-hasPermi="['business:couponPkg:add']"
-        >生成券包</el-button>
+          >生成券包</el-button
+        >
       </el-col>
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+      <right-toolbar
+        :showSearch.sync="showSearch"
+        @queryTable="getList"
+      ></right-toolbar>
     </el-row>
-    <el-table v-loading="loading" :data="tableData">
-      <el-table-column label="券包编号" prop="id" width="80" />
-      <el-table-column label="券包名称" prop="title" />
+    <el-table v-loading="loading" :data="list">
+      <el-table-column label="券包编号" prop="id" width="80" align="center" />
+      <el-table-column label="券包名称" prop="title" align="center" />
       <el-table-column label="券数量" prop="couponNum" />
-      <el-table-column label="总面值" prop="facePrice">
-        <template slot-scope="{row}">
-          ¥{{$numberFormat(row.discount)}}
+      <el-table-column label="总面值">
+        <template slot-scope="{ row }">
+          ¥{{ $numberFormat(row.facePrice) }}
         </template>
       </el-table-column>
       <el-table-column label="状态" prop="status">
-        <template slot-scope="{row}">
-          <el-tag v-if="row.status == 0">待上架</el-tag>
-          <el-tag v-else-if="row.status == 1">上架</el-tag>
-          <el-tag v-else-if="row.status == 2">下架</el-tag>
+        <template slot-scope="{ row }">
+          <el-tag v-if="row.status == 0" type="info">待上架</el-tag>
+          <el-tag v-else-if="row.status == 1" type="success">上架</el-tag>
+          <el-tag v-else-if="row.status == 2" type="info">下架</el-tag>
         </template>
       </el-table-column>
-      <el-table-column fixed="right" align="right" label="操作" width="150">
-        <template slot-scope="{row}">
-          <el-button v-hasPermi="['business:couponPkg:query']" type="text" @click="$router.push({ name: 'CouponPkgQuery', query: { id: row.couponId } })">查看</el-button>
-          <el-button v-if="row.status === 0" v-hasPermi="['business:couponPkg:edit']" type="text" @click="$router.push({ name: 'CouponPkgEdit', query: { id: row.couponId } })">编辑</el-button>
-          <el-button v-if="JSON.parse(row.status).value === 'off' || JSON.parse(row.status).value === 'init'" v-hasPermi="['business:couponPkg:on']" type="text" @click="setStatus(row, 'on')">上架</el-button>
-          <el-button v-if="JSON.parse(row.status).value === 'on'" v-hasPermi="['business:couponPkg:off']" type="text" @click="setStatus(row, 'off')">下架</el-button>
-          <el-button v-if="JSON.parse(row.status).value === 'init'" v-hasPermi="['business:couponPkg:remove']" class="del" type="text" @click="del(row)">删除</el-button>
+      <el-table-column fixed="right" align="center" label="操作" width="230">
+        <template slot-scope="{ row }">
+          <el-button
+            v-hasPermi="['business:couponPkg:query']"
+            type="text"
+            @click="
+              $router.push({
+                name: 'CouponPkgQuery',
+                query: { id: row.id },
+              })
+            "
+            >查看</el-button
+          >
+          <el-button
+            v-if="row.status === 0"
+            v-hasPermi="['business:couponPkg:edit']"
+            type="text"
+            @click="
+              $router.push({
+                name: 'CouponPkgEdit',
+                query: { id: row.id },
+              })
+            "
+            >编辑</el-button
+          >
+          <el-button
+            v-if="row.status === 0 || row.status === 2"
+            v-hasPermi="['business:couponPkg:on']"
+            type="text"
+            @click="setStatus(row, 1)"
+            >上架</el-button
+          >
+          <el-button
+            v-if="row.status === 1"
+            v-hasPermi="['business:couponPkg:off']"
+            type="text"
+            @click="setStatus(row, 2)"
+            >下架</el-button
+          >
+          <el-button
+            v-if="row.status === 0"
+            v-hasPermi="['business:couponPkg:remove']"
+            class="del"
+            type="text"
+            @click="del(row)"
+            >删除</el-button
+          >
         </template>
       </el-table-column>
     </el-table>
-    <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList()" />
+    <pagination
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList()"
+    />
   </div>
 </template>
 <script>
-import { getCouponList, delCoupon, setCouponStatus } from '@/api/business/couponPkg'
-import { accDiv } from '@/utils/util'
+import {
+  getCouponList,
+  delCoupon,
+  setCouponPkgStatus,
+} from "@/api/business/couponPkg";
 export default {
+  name: 'ListCouponPkg',
   data() {
     return {
       loading: false,
       showSearch: true,
-      queryParams: {},
-      tableData: [],
-      total: 0
+      queryParams: {
+        title: "",
+      },
+      // 分页
+      pageParams: {
+        pageNum: 1,
+        pageSize: 10,
+      },
+      // 总条数
+      total: 0,
+      list: [],
     };
   },
   created() {
-    this.getList(true)
+    this.getList();
   },
   methods: {
-    getList(reset) {
-      if (this.loading) {
-        return
-      }
-      this.loading = true
-      if (reset) {
-        this.queryParams = { pageNum: 1, pageSize: 20 }
-      }
-      getCouponList('pageNum='+this.queryParams.pageNum + '&pageSize='+this.queryParams.pageSize+'&', this.queryParams).then(res => {
-        this.loading = false
-        if (res.code === 0) {
-          console.log(res)
-          this.tableData = res.rows
-          this.total = res.total
-        }
-      }).catch(() => {
-        this.loading = false
-      })
+    getList() {
+      this.loading = true;
+      getCouponList(
+        "pageNum=" +
+          this.pageParams.pageNum +
+          "&pageSize=" +
+          this.pageParams.pageSize +
+          "&",
+        this.queryParams
+      )
+        .then((res) => {
+          this.loading = false;
+          if (res.code === 0) {
+            this.list = res.rows;
+            this.total = res.total;
+          }
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
 
+     //搜索
+    handleQuery() {
+      this.pageParams.pageNum = 1;
+      this.getList();
+    },
+
+    // 重置
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.pageParams.pageNum = 1;
+      this.getList();
     },
 
     setStatus(item, status) {
-      this.$confirm(`确认${status === 'on' ? '上架' : '下架'}券 “${item.title}” 吗?`, `${status === 'on' ? '上架' : '下架'}券`, {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        setCouponStatus({
-          couponId: item.couponId,
-          status
-        }).then(res => {
+      this.$confirm(
+        `确认${status === "on" ? "上架" : "下架"}券包 “${item.title}” 吗?`,
+        `${status === "on" ? "上架" : "下架"}券包`,
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }
+      ).then(() => {
+        setCouponPkgStatus({
+          id: item.id,
+          status,
+        }).then((res) => {
           if (res.code === 0) {
-            this.$message.success('操作已完成!')
-            this.getList()
+            this.$message.success("操作已完成!");
+            this.getList();
           }
-        })
-      })
+        });
+      });
     },
 
     del(item) {
-      this.$confirm(`确认删除券 “${item.title}” 吗?`, '删除券', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
+      this.$confirm(`确认删除券包 “${item.title}” 吗?`, "删除券", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
       }).then(() => {
-        delCoupon(item.couponId).then(res => {
+        delCoupon(item.id).then((res) => {
           if (res.code === 0) {
-            this.$message.success('操作已完成!')
-            this.getList()
+            this.$message.success("操作已完成!");
+            this.getList();
           }
-        })
-      })
+        });
+      });
     },
   },
 };

+ 1 - 0
src/views/business/ticket/components/CouponAdd.vue

@@ -37,6 +37,7 @@
           align="center"
           fixed="left"
         />
+        <!--  -->
         <el-table-column label="券ID" prop="couponId" />
         <el-table-column label="券图片">
           <template slot-scope="scope">

+ 1 - 5
src/views/order/userTicket/index.vue

@@ -169,11 +169,7 @@ export default {
       },
       // 总条数
       total: 0,
-      list: [
-        {
-          orderId: 1,
-        },
-      ],
+      list: [],
       // 下单时间
       tradeTimeArr: [],
       // 订单列表状态