#79 导出卡密

Yhdistetty
lsx yhdistetty 1 committia lähteestä mangpiao/dev kohteeseen mangpiao/test 1 vuosi sitten
2 muutettua tiedostoa jossa 24 lisäystä ja 3 poistoa
  1. 8 1
      src/api/business/goods.js
  2. 16 2
      src/components/Camilo/index.vue

+ 8 - 1
src/api/business/goods.js

@@ -96,6 +96,14 @@ export function cradCamiloList(urlParams, data) {
     urlParams
   })
 }
+// 导出卡密列表
+export function exportCradCamiloList(data) {
+  return request({
+    url: '/api/v1/mp/admin/goods/export/card/list',
+    method: 'post',
+    data, 
+  })
+}
 
 // 查看关联商品
 export function associationList(urlParams, data) {
@@ -106,4 +114,3 @@ export function associationList(urlParams, data) {
     urlParams
   })
 }
-

+ 16 - 2
src/components/Camilo/index.vue

@@ -1,6 +1,7 @@
 <template>
   <div>
     <el-dialog title="查看卡密" :visible.sync="camiloShow" :before-close="close">
+      <el-button type="primary" style="margin-bottom: 10px;" size="mini" :loading="exportLoading" @click="exportData">导出</el-button>
       <el-table :data="camiloData">
         <el-table-column property="cardNo" label="卡号" min-width="250" align="center">
           <template slot-scope="{row}">
@@ -16,7 +17,7 @@
 </template>
 
 <script>
-import {cradCamiloList} from "../../api/business/goods";
+import {cradCamiloList,exportCradCamiloList} from "../../api/business/goods";
 
 export default {
   name: "camilo",
@@ -37,6 +38,7 @@ export default {
         pageSize: 10
       },
       loading: false,
+      exportLoading:false,
       camiloData: [],
       total: 0,
     };
@@ -48,13 +50,25 @@ export default {
     close() {
       this.$emit('cancel')
     },
+    exportData(){
+      this.exportLoading = true;
+      exportCradCamiloList( {goodsId: this.camiloGoodsId}).then(res => {
+        this.exportLoading = false 
+        if (res.code === 0) {
+          this.download(res.msg);
+        }
+      }).catch(() => {
+        this.exportLoading = false
+      })
+    },
     getList() {
       if (this.loading) {
         return
       }
       this.loading = true
       cradCamiloList('pageNum=' + this.pageParams.pageNum + '&pageSize=' + this.pageParams.pageSize + '&', {goodsId: this.camiloGoodsId}).then(res => {
-        this.loading = false
+        this.loading = false;
+
         if (res.code === 0) {
           this.camiloData = res.rows
           this.total = res.total