Jelajahi Sumber

领取方式

Joe 3 tahun lalu
induk
melakukan
ebbcf9c31d

+ 2 - 2
.env.development

@@ -2,7 +2,7 @@
 ENV = 'development'
 
 # 智慧易加管理系统/开发环境
-VUE_APP_BASE_API = 'http://test.huijy.net/prod-api'
-
+ VUE_APP_BASE_API = 'http://test.huijy.net/prod-api'
+# VUE_APP_BASE_API = '/dev-api'
 # 路由懒加载
 VUE_CLI_BABEL_TRANSPILE_MODULES = true

+ 26 - 0
src/api/coupon.js

@@ -71,4 +71,30 @@ export function changeCouponStatus(data) {
     method: 'put',
     data: data
   })
+}
+
+// 新增优惠劵发放方式
+export function addIssue(data) {
+  return request({
+    url: '/coupon/issue',
+    method: 'post',
+    data: data
+  })
+}
+// 查询发放方式
+export function listIssue(query) {
+  return request({
+    url: '/coupon/issue/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 新增优惠劵发放方式
+export function upIssueStatus(data) {
+  return request({
+    url: '/coupon/issue/updateCouponIssueStatus',
+    method: 'get',
+    data: data
+  })
 }

+ 47 - 0
src/api/issue.js

@@ -0,0 +1,47 @@
+import request from '@/utils/request'
+
+// 查询优惠劵发放方式列表
+
+
+// 单条 查询优惠劵发放方式详细
+export function getIssue(id) {
+  return request({
+    url: '/coupon/issue/' + id,
+    method: 'get'
+  })
+}
+
+// 新增优惠劵发放方式
+export function addIssue(data) {
+  return request({
+    url: '/coupon/issue',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改优惠劵发放方式
+export function updateIssue(data) {
+  return request({
+    url: '/coupon/issue',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除优惠劵发放方式
+// export function delIssue(id) {
+//   return request({
+//     url: '/coupon/issue/' + id,
+//     method: 'delete'
+//   })
+// }
+
+// 导出优惠劵发放方式
+export function exportIssue(query) {
+  return request({
+    url: '/coupon/issue/export',
+    method: 'get',
+    params: query
+  })
+}

+ 2 - 2
src/views/coupon/Coupon_CreateCoupon.vue

@@ -122,6 +122,7 @@
     </div>
 
     <!-- 添加或修改油站设备管理对话框 -->
+
     <el-dialog
       :title="title"
       :visible.sync="open"
@@ -478,8 +479,7 @@ export default {
         isMarketFlag: "1",
         availableControl:"0",
         appointedDaysList:[], 
-        cycleDaysList:[]
-
+        cycleDaysList:[],
       },
       couponList: [],
       oilNameList: [],

+ 201 - 314
src/views/coupon/Coupon_CreateGetWay.vue → src/views/coupon/Coupon_CreateIssue.vue

@@ -58,8 +58,8 @@
           >
         </el-form-item>
       </el-form>
-      <el-table :data="couponList">
-        <af-table-column label="优惠券名称" align="center" prop="couponName" />
+      <el-table :data="issueList">
+        <af-table-column label="id" align="center" prop="id" />
         <af-table-column label="状态" align="center" width="100">
           <template slot-scope="scope">
             <el-switch
@@ -84,16 +84,8 @@
               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>
@@ -121,188 +113,80 @@
         :rules="rules"
         label-width="180px"
       >
-        <el-form-item label="优惠劵名称(油站备注)" prop="couponName">
-          <input
-            type="text"
-            class="form-control"
-            v-model="createForm.couponName"
-            style="width: 180px"
-          />
-        </el-form-item>
-        <el-form-item label="优惠劵内容(用户展示)" prop="couponDetails">
-          <input
-            type="text"
-            class="form-control"
-            v-model="createForm.couponDetails"
-            style="width: 180px"
-          />
-        </el-form-item>
-        <el-form-item label="优惠劵使用条件" prop="couponThresholdAmt">
-          <div>
-            满
-            <input
-              type="text"
-              class="form-control d-inline"
-              v-model.number="createForm.couponThresholdAmt"
-              style="width: 100px"
-            />
-            元 可用
-          </div>
-        </el-form-item>
-
-        <el-form-item label="优惠券类型" prop="couponType">
-          <el-radio-group v-model="createForm.couponType">
-            <el-radio label="1">现金券</el-radio>
-            <el-radio label="2">折扣劵</el-radio>
-            <el-radio label="3">兑换劵</el-radio>
+        <el-form-item label="发放类型" prop="couponName">
+          <el-radio-group v-model="createForm.issueType">
+            <div>
+              <el-radio label="1">消费发放</el-radio>
+              <el-radio label="2">展示位发放</el-radio>
+            </div>
+            <div>
+              <el-radio label="3">二维码、网页</el-radio>
+              <el-radio label="4" disabled>更多方式后续开放</el-radio>
+            </div>
+            
           </el-radio-group>
         </el-form-item>
-        <el-form-item
-          label="优惠金额"
-          prop="couponAmt"
-          v-if="createForm.couponType == 1 || createForm.couponType == 2"
-        >
-          <div v-if="createForm.couponType == 1">
-            固定面值—<input
-              type="text"
-              class="form-control d-inline"
-              v-model.number="createForm.couponAmt"
-              style="width: 100px"
-            />
-            元
-          </div>
-          <div v-if="createForm.couponType == 2">
-            折扣比例—<input
-              type="text"
-              class="form-control d-inline"
-              v-model.number="createForm.couponAmt"
-              style="width: 100px"
-            />
-            %
-          </div>
-        </el-form-item>
-        <el-form-item
-          label="优惠券适用油品"
-          prop="oilNameList"
-          v-if="createForm.couponType == 1 || createForm.couponType == 2"
-        >
-          <el-checkbox-group v-model="createForm.oilNameList">
-            <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">
-          <div>
+        <el-form-item label="展示位选择" prop="showId" v-if="createForm.issueType==2">
+          <el-checkbox-group v-model="createForm.showId">
             <div>
-              <el-radio-group v-model="createForm.effectiveTimeType">
-                <el-radio label="1">固定时间段</el-radio>
-                <el-radio label="2">固定天数</el-radio>
-              </el-radio-group>
+              <el-checkbox label="1">支付成功后的展示位</el-checkbox>
+              <el-checkbox label="2" disabled>待定</el-checkbox>
             </div>
-            <div style="margin-top: 10px">
-              <div v-if="createForm.effectiveTimeType == 1">
-                <el-date-picker
-                  style="margin: 0px 10px; width: 300px"
-                  v-model="createForm.effectiveTime"
-                  type="datetimerange"
-                  value-format="yyyy-MM-dd HH:mm:ss"
-                  size="mini"
-                  range-separator="至"
-                  start-placeholder="开始日期"
-                  end-placeholder="结束日期"
-                >
-                </el-date-picker>
-              </div>
-              <div
-                v-if="createForm.effectiveTimeType == 2"
-                style="margin-left: 20px"
-              >
-                自用户领取后
-                <input
-                  type="text"
-                  class="form-control d-inline"
-                  v-model.number="createForm.effectiveDayNum"
-                  style="width: 80px"
-                />
-                天内有效
-              </div>
+            <div>
+              <el-checkbox label="3" disabled>更多位置后续开放</el-checkbox>
             </div>
-          </div>
-        </el-form-item>
-
-        <el-form-item label="生成优惠券的数量" prop="couponNum">
-          共生成
-          <input
-            type="text"
-            class="form-control d-inline"
-            v-model.number="createForm.couponNum"
-            style="width: 100px"
-          />
-          张
-        </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-checkbox-group>
         </el-form-item>
-        <el-form-item label="累计可拥有数量" prop="couponReceiveNum">
-          单个用户累计可以拥有
+        <el-form-item label="发放门槛" prop="discountThresholdAmt" v-if="createForm.issueType==1">
+          消费达到
           <input
             type="text"
-            class="form-control d-inline"
-            v-model.number="createForm.couponReceiveNum"
-            style="width: 100px"
-          />
-          张优惠券
+            class="form-control d-inline-block"
+            v-model.number="createForm.discountThresholdAmt"
+            style="width: 80px"
+          />元时,系统自动发放
         </el-form-item>
-
-        <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-form-item label="可领取时间段" prop="availableControl">
+          <el-radio-group
+            v-model="createForm.availableControl"
+            @change="availableControlChange"
+          >
+            <div>
+              <div>
+                <el-radio label="0">一直都可用</el-radio>
+                <el-radio label="1">每周指定日</el-radio>
+              </div>
+              <div>
+                <el-radio label="2">每月指定日</el-radio>
+                <el-radio label="3">固定指定日</el-radio>
+              </div>
+            </div>
           </el-radio-group>
         </el-form-item>
         <el-form-item
-          label="用券时叠加等级优惠"
-          prop="isGradeFlag"
-          v-if="createForm.couponType == 1 || createForm.couponType == 2"
+          label="可用时间选择"
+          prop="isMarketFlag1"
+          v-if="
+            createForm.availableControl == 1 ||
+            createForm.availableControl == 2 ||
+            createForm.availableControl == 3
+          "
         >
-          <el-radio-group v-model="createForm.isGradeFlag">
-            <el-radio label="1">叠加等级优惠</el-radio>
-            <el-radio label="0">不叠加等级优惠</el-radio>
-          </el-radio-group>
+          <div>
+            <select-day
+              :type="createForm.availableControl"
+              :day.sync="createForm.appointedDaysList"
+              :cycle.sync="createForm.cycleDaysList"
+            ></select-day>
+          </div>
         </el-form-item>
         <el-form-item
-          label="用劵时叠加优惠方案"
-          prop="isMarketFlag"
-          v-if="createForm.couponType == 1 || createForm.couponType == 2"
+          label="此领取方式下的优惠券"
+          prop="couponIssueRelationList"
         >
-          <el-radio-group v-model="createForm.isMarketFlag">
-            <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">
+        <div>
           <el-col :span="11">
             <el-table
               :data="unselectedCouponList"
@@ -322,7 +206,10 @@
                   label="姓名"
                   type="selection"
                 ></el-table-column>
-                <el-table-column prop="deptName" label="机构"></el-table-column>
+                <el-table-column
+                  prop="couponName"
+                  label="优惠券"
+                ></el-table-column>
                 <el-table-column label="添加" width="60px" align="center">
                   <template slot-scope="scope">
                     <el-button
@@ -371,7 +258,10 @@
                   prop="phone"
                   type="selection"
                 ></el-table-column>
-                <el-table-column prop="deptName" label="姓名"></el-table-column>
+                <el-table-column
+                  prop="couponName"
+                  label="优惠券"
+                ></el-table-column>
                 <el-table-column label="移除" width="60px" align="center">
                   <template slot-scope="scope">
                     <el-button
@@ -394,8 +284,6 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
-    <div>支付宝</div>
-    <div><select-day :type="2" :day.sync="day" :cycle.sync="cycle"></select-day></div>
   </div>
 </template>
 
@@ -409,33 +297,41 @@ import {
   exportManage,
   changeManageStatus,
 } from "@/api/station/manage";
-import { listGun } from "@/api/station/gun";
 import { listPrice } from "@/api/station/price";
 
-import { addInfo, verificationList, listInfo, updateInfo, changeCouponStatus } from "@/api/coupon";
-import { updateDept } from "@/api/system/dept";
+import {
+  addInfo,
+  listInfo,
+  updateInfo,
+  changeCouponStatus,
+  addIssue,
+  listIssue,
+  upIssueStatus
+} from "@/api/coupon";
 import SelectDay from "@/components/SelectDay";
 
-
 export default {
-  name: "Coupon_CreateGetWay",
+  name: "Coupon_CreateIssue",
   data() {
     let validateGunNo = (rule, value, callback) => {
       callback();
     };
     return {
       couponEnabledFlag: "1",
-      
+
       pageStatus: 4,
       createForm: {
-        issueType:'1',
-        discountThresholdAmt:0,
-        showId:'1'
+        showId: [],
+        availableControl: "0",
+        appointedDaysList: [],
+        cycleDaysList: [],
+        issueType: "2",
+        discountThresholdAmt: "0",
+        couponIssueRelationList: [],
       },
       couponList: [],
       oilNameList: [],
-      allVerificationList: [
-      ],
+      allVerificationList: [],
       equipmentList: [],
       // 油枪复选
       allGunList: [],
@@ -465,17 +361,19 @@ export default {
       },
       // 表单校验
       rules: {},
-      day:[],
-      cycle:[],
+      day: [],
+      cycle: [],
+      issueList:[],
     };
   },
   components: {
-    'SelectDay': SelectDay
+    SelectDay: SelectDay,
   },
   created() {
     // this.init();
-    // this.getCoupon();
+    this.getCoupon();
     // this.setPageStatus();
+    this.getIssueList();
   },
   computed: {
     toggleable() {
@@ -485,19 +383,19 @@ export default {
       return false;
     },
     selectedCouponList() {
-      return this.allVerificationList.filter((ele) => {
-        if(this.createForm.verificationList == null) {
-          this.createForm.verificationList = [];
+      return this.couponList.filter((ele) => {
+        if(this.createForm.couponIssueRelationList == null) {
+          this.createForm.couponIssueRelationList = [];
         }
-        return this.createForm.verificationList.includes(ele.deptId);
+        return this.createForm.couponIssueRelationList.includes(ele.id);
       });
     },
     unselectedCouponList() {
-      return this.allVerificationList.filter((ele) => {
-        if(this.createForm.verificationList == null) {
-          this.createForm.verificationList = [];
+      return this.couponList.filter((ele) => {
+        if(this.createForm.couponIssueRelationList == null) {
+          this.createForm.couponIssueRelationList = [];
         }
-        return !!!this.createForm.verificationList.includes(ele.deptId);
+        return !!!this.createForm.couponIssueRelationList.includes(ele.id);
       });
     },
     getTodayDateString() {
@@ -506,22 +404,64 @@ export default {
     },
   },
   methods: {
+    getIssueList(){
+      listIssue(this.queryForm).then((res) => {
+          if (res.code == 200) {
+            if (res.rows == null) {
+              this.issueList = [];
+            } else {
+              this.issueList = res.rows;
+            }
+          } else {
+            throw new Error("");
+          }
+        })
+        .catch((err) => {
+          this.msgError("亲,拉取领取方式列表失败~");
+        });
+    },
+    getCoupon() {
+      listInfo({
+        pageNum: 1,
+        pageSize: 1000,
+        status:1
+      })
+        .then((res) => {
+          if (res.code == 200) {
+            if (res.rows == null) {
+              this.couponList = [];
+            } else {
+              this.couponList = res.rows;
+            }
+          } else {
+            throw new Error("");
+          }
+        })
+        .catch((err) => {
+          this.msgError("亲,拉取优惠券列表失败~");
+        });
+    },
+    availableControlChange() {
+      this.createForm.appointedDaysList = [];
+      this.createForm.cycleDaysList = [];
+      this.createForm = { ...this.createForm };
+    },
     handleMoveLabel(direction, row){
       console.log(row)
-      if(this.createForm.verificationList == null) {
-        this.createForm.verificationList = [];
+      if(this.createForm.couponIssueRelationList == null) {
+        this.createForm.couponIssueRelationList = [];
       }
 
       if(direction == "right"){
-        this.createForm.verificationList.push(row.deptId)
+        this.createForm.couponIssueRelationList.push(row.id)
       }else{
-        this.createForm.verificationList = this.createForm.verificationList.filter((ele)=>{
-          return ele != row.deptId
+        this.createForm.couponIssueRelationList = this.createForm.couponIssueRelationList.filter((ele)=>{
+          return ele != row.id
         })
       }
     },
     handleFlagChange() {
-      const that = this
+      const that = this;
       let text = this.couponEnabledFlag === "1" ? "启用" : "停用";
       this.$confirm('确认要"' + text + '"优惠券功能吗?', "警告", {
         confirmButtonText: "确定",
@@ -553,7 +493,7 @@ export default {
         }
       )
         .then(function () {
-          return updateInfo({
+          return upIssueStatus({
             id: row.id,
             status: row.status,
           });
@@ -565,75 +505,19 @@ export default {
           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("亲,拉取优惠券列表失败~");
-        });
-    },
-    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("亲,拉取核销机构失败~");
-        });
-    },
     toggleLabel() {
       if (this.moveLeftData.length !== 0) {
-        this.createForm.verificationList =
-          this.createForm.verificationList.filter((ele) => {
+        this.createForm.couponIssueRelationList =
+          this.createForm.couponIssueRelationList.filter((ele) => {
             return ele != this.moveLeftData;
           });
         this.createForm = { ...this.createForm };
         return;
       }
       if (this.moveRightData.length !== 0) {
-        this.createForm.verificationList = [
+        this.createForm.couponIssueRelationList = [
           ...new Set(
-            this.createForm.verificationList.concat(this.moveRightData)
+            this.createForm.couponIssueRelationList.concat(this.moveRightData)
           ),
         ].filter((ele) => {
           return !!ele;
@@ -646,7 +530,7 @@ export default {
     handleLeftChange(val) {
       let changeArr = [];
       val.map((ele) => {
-        changeArr.push(ele.deptId);
+        changeArr.push(ele.id);
       });
       console.log(changeArr);
       this.moveLeftData = [];
@@ -657,7 +541,7 @@ export default {
     handleRightChange(val) {
       let changeArr = [];
       val.map((ele) => {
-        changeArr.push(ele.deptId);
+        changeArr.push(ele.id);
       });
       this.moveLeftData = changeArr;
       this.moveRightData = [];
@@ -693,25 +577,25 @@ 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",
-        isMarketFlag: "1",
-      }
+      // this.createForm = {
+      //   couponName: "",
+      //   couponDetails: "",
+      //   couponThresholdAmt: 0,
+      //   couponType: "1",
+      //   couponAmt: 0,
+      //   oilNameList: [],
+      //   effectiveTimeType: "",
+      //   effectiveTime: [],
+      //   effectiveDayNum: 30,
+      //   couponHoldNum: 1,
+      //   couponReceiveNum: 100,
+      //   couponNum: 100,
+      //   status: "1",
+      //   couponIssueRelationList: [],
+      //   isCardFlag: "1",
+      //   isGradeFlag: "1",
+      //   isMarketFlag: "1",
+      // };
       this.open = true;
     },
     /** 修改按钮操作 */
@@ -726,32 +610,35 @@ export default {
     submitForm() {
       this.$refs["dialogForm"].validate((valid) => {
         if (valid) {
-          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("创建优惠劵失败了~")
-            });
+          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 {
+            addIssue(this.createForm)
+              .then((res) => {
+                if (res.code == 200) {
+                  this.msgSuccess("亲,新增成功了~");
+                  this.getCoupon();
+                  this.open = false;
+                } else {
+                  throw new Error("");
+                }
+              })
+              .catch((err) => {
+                this.msgError("创建优惠劵失败了~");
+              });
           }
-          
         }
       });
     },

+ 2 - 1
vue.config.js

@@ -35,7 +35,8 @@ module.exports = {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://localhost:8080`,
+        // target: `http://localhost:8080`,
+        target: `http://localhost:8081`,
         // target:"http://www.huiyj.com:9002/prod-api",
         //target:"http://demo.huijy.net/prod-api",
         changeOrigin: true,