Browse Source

优惠方案增加修改

Joe 3 years ago
parent
commit
0f7c9b2456
3 changed files with 120 additions and 51 deletions
  1. 1 0
      package.json
  2. 83 39
      src/views/coupon/Coupon_CreateIssue.vue
  3. 36 12
      src/views/market/Market_Discount.vue

+ 1 - 0
package.json

@@ -59,6 +59,7 @@
     "screenfull": "4.2.0",
     "sortablejs": "1.8.4",
     "vue": "2.6.10",
+    "vue-clipboard2": "^0.3.1",
     "vue-count-to": "1.0.13",
     "vue-cropper": "0.4.9",
     "vue-qr": "^2.5.0",

+ 83 - 39
src/views/coupon/Coupon_CreateIssue.vue

@@ -61,17 +61,18 @@
           >
         </el-form-item>
       </el-form>
-      <el-table :data="issueList" >
+      <el-table :data="issueList">
         <af-table-column type="expand">
           <template slot-scope="props">
-            <el-table :data="props.row.couponList"
+            <el-table
+              :data="props.row.couponList"
               :show-header="false"
               :highlight-current-row="false"
-               style="width: 90vw"
+              style="width: 90vw"
             >
               <af-table-column label="名城" align="left">
-                 <template slot-scope="scope">
-                 {{ '优惠券:' }}<b>{{scope.row.couponRemark}}</b>
+                <template slot-scope="scope">
+                  {{ "优惠券:" }}<b>{{ scope.row.couponRemark }}</b>
                 </template>
               </af-table-column>
               <af-table-column label="卡片类型" align="left">
@@ -95,12 +96,12 @@
               </af-table-column>
               <af-table-column label="状态" align="left">
                 <template slot-scope="scope">
-                {{ scope.row.status == '0'? '启用状态': ''}}
-                {{ scope.row.status == '1'? '停用状态': ''}}
+                  {{ scope.row.status == "1" ? "启用状态" : "" }}
+                  {{ scope.row.status == "0" ? "停用状态" : "" }}
                 </template>
               </af-table-column>
             </el-table>
-              
+
             <!--
             <el-table :data="props.row.couponIssueRelations">
               <af-table-column
@@ -265,13 +266,17 @@
         </af-table-column>
         <af-table-column label="操作" align="left">
           <template slot-scope="scope">
-            {{ scope.row.issueType == "1"||scope.row.issueType == "3" ? "-------" : "" }}
+            {{
+              scope.row.issueType == "1" || scope.row.issueType == "3"
+                ? "-------"
+                : ""
+            }}
             <el-button
               size="mini"
               type="text"
               icon="el-icon-download"
               @click="handleExport(scope.row)"
-              v-if="scope.row.issueType=='2'"
+              v-if="scope.row.issueType == '2'"
               >导出二维码、网址</el-button
             >
           </template>
@@ -594,21 +599,49 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
-    
-      <el-dialog
+
+    <el-dialog
       :visible.sync="exportQrDialog"
       width="600px"
       append-to-body
       title="导出标签"
     >
       <div>
-        <qr :text="currentExport.text" @downloadImg="downloadImg" :name="currentExport.name + '活动二维码'">
+        <qr
+          :text="currentExport.text"
+          @downloadImg="downloadImg"
+          :name="currentExport.name + '活动二维码'"
+        >
           <div>{{ currentExport.name }} 活动二维码<b></b></div>
         </qr>
-        <div style="text-align: center;margin-top: 10px;">活动网址:{{currentExport.text}}</div>
+        <!--
+        <div
+          style="text-align: center; margin-top: 15px"
+          v-clipboard:copy="currentExport.text"
+          v-clipboard:error="onCopyError"
+          v-clipboard:success="onCopySuccess"
+        >
+          👇点击复制网址👇
+        </div>
+        -->
+        <div
+          style="text-align: center; margin-top: 15px"
+          v-clipboard:copy="currentExport.text"
+          v-clipboard:error="onCopyError"
+          v-clipboard:success="onCopySuccess"
+        >
+          活动网址:{{ currentExport.text }}
+        </div>
+        <div
+          style="text-align: center"
+          v-clipboard:copy="currentExport.text"
+          v-clipboard:error="onCopyError"
+          v-clipboard:success="onCopySuccess"
+        >
+          👆点击复制网址👆
+        </div>
       </div>
     </el-dialog>
-
   </div>
 </template>
 
@@ -623,9 +656,14 @@ import {
   changeManageStatus,
 } from "@/api/station/manage";
 import { listPrice } from "@/api/station/price";
-import qr from "@/components/QrCode";
+
+import Vue from "vue";
+import VueClipboard from "vue-clipboard2";
+
+import Qr from "@/components/QrCode";
 import Base64 from "@/utils/base64";
 
+Vue.use(VueClipboard);
 
 import {
   addInfo,
@@ -637,7 +675,7 @@ import {
   upIssueStatus,
 } from "@/api/coupon";
 import SelectDay from "@/components/SelectDay";
-import settings from "@/settings"
+import settings from "@/settings";
 
 export default {
   name: "Coupon_CreateIssue",
@@ -686,11 +724,10 @@ export default {
         giveLimit: 9,
         giveCount: 999999,
       },
-      currentExport:{
-        text:"error",
-        type:"你好",
-        name:"二维码",
-        
+      currentExport: {
+        text: "error",
+        type: "你好",
+        name: "二维码",
       },
       couponList: [],
       oilNameList: [],
@@ -785,11 +822,12 @@ export default {
   },
   components: {
     SelectDay: SelectDay,
-    qr,
+    Qr: Qr,
+    VueClipboard: VueClipboard,
   },
   created() {
-    console.log('哈哈');
-    console.log('settings',settings);
+    console.log("哈哈");
+    console.log("settings", settings);
     // this.init();
     this.getCoupon();
     // this.setPageStatus();
@@ -830,6 +868,12 @@ export default {
     },
   },
   methods: {
+    onCopySuccess() {
+      this.msgSuccess("网址已经拷贝到剪切板");
+    },
+    onCopyError() {
+      this.msgError("网址拷贝失败,请手动复制");
+    },
     // exportUrl(url){
     //   this.currentExport.name = emp.personnelName;
     //   this.currentExport.type = 1;
@@ -840,17 +884,18 @@ export default {
     //   this.currentExport.text = "https://goto.huijy.net/" + this.deptId + "/" + trimEqualStr;
     //   this.exportQrDialog = true;
     // },
-    handleExport(row){
-      this.currentExport.name = row.issueName
-      const base64 =  Base64.getInstance();
-      const encodeStr = "i" + row.id
-      const encodedStr = base64.encode(encodeStr) 
+    handleExport(row) {
+      this.currentExport.name = row.issueName;
+      const base64 = Base64.getInstance();
+      const encodeStr = "i" + row.id;
+      const encodedStr = base64.encode(encodeStr);
       const trimEqualStr = encodedStr.replace(/={1,}$/g, "");
       this.exportQrDialog = true;
-      this.currentExport.text = settings.baseURL + this.deptId + "/" + trimEqualStr 
+      this.currentExport.text =
+        settings.baseURL + this.deptId + "/" + trimEqualStr;
     },
-    downloadImg(){
-      console.log(1221);
+    downloadImg() {
+      console.log('');
     },
     translateTime(row) {
       let timeString = "";
@@ -1068,6 +1113,8 @@ export default {
         giveLimit: 9,
         giveCount: 999999,
       }
+      
+      ;
       this.title = "添加优惠券";
       // this.createForm = {
       //   couponName: "",
@@ -1102,15 +1149,13 @@ export default {
     submitForm() {
       console.log(123);
       this.$refs["dialogForm"].validate((valid) => {
-        console.log(234);
         if (valid) {
-          console.log(567);
           if (!!this.createForm.id) {
             updateIssue(this.createForm)
               .then((res) => {
                 if (res.code == 200) {
                   this.msgSuccess("亲,修改成功了~");
-                  this.getCoupon();
+                  this.getIssueList();
                   this.open = false;
                 } else {
                   throw new Error("");
@@ -1120,19 +1165,18 @@ export default {
                 this.msgError("修改失败了呀~");
               });
           } else {
-            console.log(678);
             addIssue(this.createForm)
               .then((res) => {
                 if (res.code == 200) {
                   this.msgSuccess("亲,新增成功了~");
-                  this.getCoupon();
+                  this.getIssueList();
                   this.open = false;
                 } else {
                   throw new Error("");
                 }
               })
               .catch((err) => {
-                this.msgError("创建优惠劵失败了~");
+                this.msgError("创建失败了~");
               });
           }
         }

+ 36 - 12
src/views/market/Market_Discount.vue

@@ -69,12 +69,12 @@
           />
         </el-form-item>
         <el-form-item label="油品名称" prop="oilName">
-
           <select
             v-model="updateForm.oilName"
             class="form-control form-control-sm w-50"
             :disabled="ladderUp"
           >
+
             <option
               v-for="dict in filterOilNameOptions"
               :key="dict.oilName"
@@ -395,7 +395,7 @@
           icon="el-icon-plus"
           size="mini"
           class="mb-3 mr-4"
-          @click="handleUpdateClick"
+          @click="handleAdd"
           style="float: right"
           type="warning"
         >
@@ -497,6 +497,13 @@
             @click="handleDelete(scope.row)"
             >删除</el-button
           >
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            >修改</el-button
+          >
         </template>
       </af-table-column>
     </el-table>
@@ -964,7 +971,7 @@ export default {
         return "否";
       }
     },
-    handleUpdateClick() {
+    handleAdd() {
       this.openDialog = true;
       this.ladderUp = false;
       this.updateForm = {
@@ -1012,19 +1019,22 @@ export default {
               });
               return ;
           }
-          if (this.updateForm.id != null) {
-            updatePlan(this.updateForm).then((response) => {
+
+          
+          if (!!this.updateForm.id) {
+            addPlan(this.updateForm).then((response) => {
               this.msgSuccess("修改成功");
               this.openDialog = false;
               this.getList();
             });
           } else {
             addPlan(this.updateForm).then((response) => {
-              if(this.ladderUp){
-                this.msgSuccess("修改成功");
-              }else{
-                this.msgSuccess("新增成功");
-              }
+              this.msgSuccess("新增成功");
+              // if(this.ladderUp){
+              //   this.msgSuccess("修改成功2");
+              // }else{
+              //   this.msgSuccess("新增成功3");
+              // }
               this.openDialog = false;
               this.getList();
             });
@@ -1051,9 +1061,23 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(row) {
       const id = row.id;
-      this.title = "修改满减优惠";
-      this.openDialog = true;
+      console.log('--------',row);
+      this.ladderUp = true;
+      row = JSON.parse(JSON.stringify(row));
+       console.log(row);
+      console.log('this.updateForm.discountDate',this.updateForm.discountDate);
+      if(row.discountType == 1||row.discountType == 2){
+        row.collectClickCalendar = row.discountDate.split(',').filter(ele=>ele!=='').map(ele=>+ele)
+        row.collectClickDay = [];
+      }else if(row.discountType == 3){
+        row.collectClickDay = row.discountDate.split(',').filter(ele=>ele!=='')
+        row.collectClickCalendar = [];
+      }
       this.updateForm = row;
+      this.openDialog = true;
+      // this.title = "修改满减优惠";
+      // this.openDialog = true;
+      // this.updateForm = row;
     },
     /** 删除按钮操作 */
     handleDelete(row) {