zhengjinyi пре 2 година
родитељ
комит
9338cd587c

+ 8 - 1
src/api/member/member.js

@@ -27,7 +27,7 @@ export function svipCoupon(params) {
 export function saveVipCoupon(data) {
   return request({
     url: '/svip/member/saveVipCoupon',
-    method: 'get',
+    method: 'post',
     data: data
   })
 }
@@ -52,6 +52,13 @@ export function fetchDeleteCoupon(id) {
     method: 'post'
   })
 }
+// 删除超级会员具体优惠券
+export function delCoupon(id) {
+  return request({
+    url: '/svip/member/delCoupon/' + id,
+    method: 'post'
+  })
+}
 // 获取供应商列表
 export function fetchFindShop(params) {
   return request({

+ 2 - 2
src/views/member/coupon/components/good-dialog.vue

@@ -134,8 +134,8 @@ export default {
     },
     handleAddProConfirm() {
       // 确认选择商品
-      this.productRadio.pcStatus = 1
-      this.productRadio.appletsStatus = 1
+      this.productRadio.pcStatus = '1'
+      this.productRadio.appletsStatus = '1'
       this.productRadio.sort = 1
       this.$emit('confirm', this.productRadio)
     },

+ 198 - 115
src/views/member/coupon/edit.vue

@@ -22,97 +22,109 @@
     <el-form ref="couponFrom" :model="form" label-width="100px">
       <div v-for="(formItem,index) in form.formList" :key="formItem.key" class="form-cell" :data-key="formItem.key">
         <el-form-item :label="`优惠券${index+1}:`" style="margin-bottom: 10px;">
-          <el-radio-group v-model="formItem.radio">
+          <el-radio-group v-model="formItem.couponType">
             <el-radio :label="0">活动券</el-radio>
             <el-radio :label="1">品类券</el-radio>
             <el-radio :label="3">店铺券</el-radio>
           </el-radio-group>
         </el-form-item>
-        <el-form-item label="供应商" :hidden="formItem.radio === 3 ? false : true" style="margin-bottom: 10px;">
-          <el-button type="primary" :hidden="!hiddenItem" autofocussize="mini" size="mini" icon="el-icon-plus" @click="handleShopDialogVisible(index)">选择供应商</el-button>
-          <el-table :data="formItem.shopData" border :hidden="hiddenItem" width="1000">
-            <el-table-column prop="name" label="供应商名称" align="center" width="300" />
-            <el-table-column prop="sname" label="供应商简称" align="center" width="200" />
-            <el-table-column prop="linkMan" label="联系人" align="center" width="100" />
-            <el-table-column prop="contractMobile" label="手机号" align="center" width="150">
-              <template slot-scope="{ row }">
-                {{ row.contractMobile ? row.contractMobile : '---' }}
-              </template>
-            </el-table-column>
-            <el-table-column label="操作" align="center">
-              <el-button type="text" @click="deleteShop(index)">删除</el-button>
-            </el-table-column>
-          </el-table>
+        <el-form-item label="供应商" :hidden="formItem.couponType === 3 ? false : true" style="margin-bottom: 10px;">
+          <template v-if="formItem.shopData && formItem.shopData.length === 0">
+            <el-button type="primary" autofocussize="mini" size="mini" icon="el-icon-plus" @click="handleShopDialogVisible(index)">选择供应商</el-button>
+          </template>
+          <template v-else>
+            <el-table :data="formItem.shopData" border width="1000">
+              <el-table-column prop="name" label="供应商名称" align="center" width="300" />
+              <el-table-column prop="sname" label="供应商简称" align="center" width="200" />
+              <el-table-column prop="linkMan" label="联系人" align="center" width="100" />
+              <el-table-column prop="contractMobile" label="手机号" align="center" width="150">
+                <template slot-scope="{ row }">
+                  {{ row.contractMobile ? row.contractMobile : '---' }}
+                </template>
+              </el-table-column>
+              <el-table-column label="操作" align="center">
+                <el-button type="text" @click="deleteShop(index)">删除</el-button>
+              </el-table-column>
+            </el-table>
+          </template>
         </el-form-item>
         <el-form-item label="优惠券金额:" :prop="`formList.${index}.couponAmount`" :rules="rules.couponAmount">
           <el-input v-model="formItem.couponAmount" style="width: 150px" size="mini" />
         </el-form-item>
         <el-form-item label="优惠条件:" :prop="`formList.${index}.touchPrice`" :rules="rules.touchPrice">
-          <el-input v-model="formItem.touchPrice" style="width: 200px" size="mini">
+          <el-input v-model="formItem.touchPrice" style="width: 220px" size="mini">
             <template slot="prepend" style="padding: 0 10px;">订单商品总额满:</template>
           </el-input>
         </el-form-item>
-        <el-form-item label="优惠商品:" :hidden="formItem.radio === 0 ? false : true" style="margin-bottom: 10px;">
+        <el-form-item label="优惠商品:" :hidden="formItem.couponType === 0 ? false : true" style="margin-bottom: 10px;">
           <el-radio-group v-model="formItem.productType">
-            <el-radio :label="1">全商城商品</el-radio>
-            <el-radio :label="2">指定商品</el-radio>
+            <el-radio :label="'1'">全商城商品</el-radio>
+            <el-radio :label="'2'">指定商品</el-radio>
           </el-radio-group>
         </el-form-item>
-        <el-form-item :hidden="formItem.productType === 2 && formItem.radio === 0 ? false : true" style="margin-bottom: 10px;">
-          <el-button type="primary" icon="el-icon-sort" size="mini" @click="handleOnInputBlur(formItem,index)">一键排序</el-button>
-          <el-button type="primary" icon="el-icon-plus" size="mini" @click="dialogGoodVisible = true">添加商品</el-button>
-          <el-form-item :hidden="hiddenProduct">
-            <el-table :data="formItem.associateList" border>
-              <el-table-column property="mainImage" label="商品图片" align="center" width="80">
-                <template slot-scope="{ row }">
-                  <el-popover
-                    placement="top-start"
-                    title=""
-                    width="180"
-                    trigger="hover"
-                  >
-                    <img :src="row.mainImage" alt="" style="width:150px;height:150px;">
-                    <img slot="reference" :src="row.mainImage" alt="" style="width:30px;height:30px;">
-                  </el-popover>
-                </template>
-              </el-table-column>
-              <el-table-column property="name" label="商品名称" align="center" />
-              <el-table-column property="shopName" label="供应商" align="center" width="150" />
-              <el-table-column property="sort" label="网站状态" align="center" width="80">
-                <template slot-scope="{row}">
-                  <el-switch v-model="row.pcStatus" :active-value="1" :inactive-value="0" active-color="#1890ff" inactive-color="#DCDFE6" @change="handlePcStatusChange(row)" />
-                </template>
-              </el-table-column>
-              <el-table-column property="pcStatus" label="小程序状态" align="center" width="80">
-                <template slot-scope="{row}">
-                  <el-switch v-model="row.appletsStatus" :active-value="1" :inactive-value="0" active-color="#1890ff" inactive-color="#DCDFE6" @change="handleAppStatusChange(row)" />
-                </template>
-              </el-table-column>
-              <el-table-column property="appletsStatus" label="排序" align="center" width="100">
-                <template slot-scope="{row}">
-                  <el-input v-model="row.sort" maxlength="4" minlength="1" />
-                </template>
-              </el-table-column>
-              <el-table-column property="addTime" label="添加时间" align="center" width="100" />
-              <el-table-column label="操作" align="center">
-                <template>
-                  <el-button type="text">删除</el-button>
-                </template>
-              </el-table-column>
-            </el-table>
-          </el-form-item>
+        <el-form-item :hidden="formItem.productType === '2'&& formItem.couponType === 0 ? false : true" style="margin-bottom: 10px;">
+          <el-button type="primary" icon="el-icon-sort" size="mini" :disabled="disabled3(formItem.associateList)" @click="handleOnInputBlur(formItem,index)">一键排序</el-button>
+          <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleGoodDialogVisible(index)">添加商品</el-button>
+          <el-table v-show="formItem.associateList && formItem.associateList.length>0" :data="formItem.associateList" border>
+            <el-table-column property="mainImage" label="商品图片" align="center" width="80">
+              <template slot-scope="{ row }">
+                <el-popover
+                  placement="top-start"
+                  title=""
+                  width="180"
+                  trigger="hover"
+                >
+                  <img :src="row.mainImage" alt="" style="width:150px;height:150px;">
+                  <img slot="reference" :src="row.mainImage" alt="" style="width:30px;height:30px;">
+                </el-popover>
+              </template>
+            </el-table-column>
+            <el-table-column property="name" label="商品名称" align="center" />
+            <el-table-column property="shopName" label="供应商" align="center" />
+            <el-table-column label="网站状态" align="center" width="80">
+              <template slot-scope="scope">
+                <el-switch
+                  v-model="scope.row.pcStatus"
+                  active-color="#1890ff"
+                  inactive-color="#DCDFE6"
+                  active-value="1"
+                  inactive-value="0"
+                />
+              </template>
+            </el-table-column>
+            <el-table-column label="小程序状态" align="center" width="100">
+              <template slot-scope="scope">
+                <el-switch
+                  v-model="scope.row.appletsStatus"
+                  active-color="#1890ff"
+                  inactive-color="#DCDFE6"
+                  active-value="1"
+                  inactive-value="0"
+                />
+              </template>
+            </el-table-column>
+            <el-table-column label="排序" align="center" width="100">
+              <template slot-scope="{row}">
+                <el-input v-model="row.sort" maxlength="4" minlength="1" />
+              </template>
+            </el-table-column>
+            <el-table-column label="操作" align="center">
+              <template slot-scope="scope">
+                <el-button type="text" @click="handleDeletePros(formItem,scope.$index)">删除</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
         </el-form-item>
-        <el-form-item label="优惠品类:" :hidden="formItem.radio === 1 ? false : true" style="margin-bottom: 10px;">
-          <template>
-            <el-radio v-model="formItem.categoryType" label="1">产品</el-radio>
-            <el-radio v-model="formItem.categoryType" label="2">仪器</el-radio>
-          </template>
+        <el-form-item label="优惠品类:" :hidden="formItem.couponType ===1 ? false : true" style="margin-bottom: 10px;">
+          <el-radio-group v-model="formItem.categoryType">
+            <el-radio :label="'1'">产品</el-radio>
+            <el-radio :label="'2'">仪器</el-radio>
+          </el-radio-group>
         </el-form-item>
         <el-button class="delete_label" :disabled="disabled1" icon="el-icon-delete" size="mini" type="danger" @click="handleDelete(formItem,index)">删除</el-button>
       </div>
     </el-form>
     <div class="el-dialog__footer">
-      <el-button @click="goBack">返回</el-button>
       <el-button type="primary" @click="onSubmit('couponFrom')">保存</el-button>
     </div>
     <!-- 供应商弹框 -->
@@ -124,35 +136,40 @@
 </template>
 
 <script>
-import { svipCoupon, saveVipCoupon } from '@/api/member/member'
+import { svipCoupon, saveVipCoupon, delCoupon } from '@/api/member/member'
 import goodDialog from './components/good-dialog'
 import shopDialog from './components/shop-dialog'
 const defaultForm = () => {
   return {
-    shop: {
-      shopId: 0
-    }, // 供应商信息
+    shopId: 0,
     shopData: [],
-    radio: 0,
+    couponType: 0,
     couponAmount: '',
     touchPrice: '',
-    productType: 1,
-    categoryType: 1,
+    productType: '1',
+    categoryType: '1',
     associateList: []// 指定商品信息
   }
 }
 export default {
-  name: 'Edit',
+  name: 'MemberEdit',
   components: { goodDialog, shopDialog },
   data() {
     return {
       form: {
         formList: []
       },
+      formParams: {
+        id: '',
+        month: '',
+        endMonth: '',
+        status: '',
+        configure: 1, // 专属优惠券配置  1是、0否
+        coupons: []
+      },
       doctorId: '',
       editType: 'add',
       time: '',
-      hiddenItem: true,
       dialogTableVisible: false,
       shopTotal: 0,
       rows: [],
@@ -160,7 +177,6 @@ export default {
       shopTableData: [],
       // 商品列表
       dialogProductVisible: false,
-      hiddenProduct: true,
       productTableData: [],
       productTotal: 0,
       addIndex: 0,
@@ -169,7 +185,8 @@ export default {
       rules: {
         couponAmount: [{ required: true, message: '优惠券金额不能为空', trigger: 'blur' }],
         touchPrice: [{ required: true, message: '优惠条件不能为空', trigger: 'blur' }]
-      }
+      },
+      delFlag: false
     }
   },
   computed: {
@@ -181,72 +198,123 @@ export default {
     }
   },
   created() {
-    this.doctorId = parseInt(this.$route.query.id)
     this.editType = this.$route.query.type || 'edit'
     console.log('editType', this.editType)
     this.initForm(this.editType)
-    console.log(this.editType)
   },
   methods: {
     initForm(type) {
       if (type === 'add') {
-        // for (let i = 0; i < 3; i++) {
-        //   this.form.formList.push(defaultForm())
-        // }
-        this.svipCoupon(1, 0)
+        console.log('add')
+        this.svipCoupon(type, 1, 0)
       } else {
-        this.svipCoupon(0, this.doctorId)
         console.log('edit')
+        this.svipCoupon(type, 0, this.$route.query.id)
       }
     },
-    async svipCoupon(configure, id) {
+    async svipCoupon(type, configure, id) {
       const res = await svipCoupon({ id: id, configure: configure })
-      console.log('RES', res.data)
+      const data = res.data.svipcouponForm
+      this.formParams = { ...this.formParams, ...data }
+      this.form.formList = data.coupons
+      if (type === 'add') {
+        if (data.coupons.length > 0) {
+          this.delFlag = true
+          this.form.formList = data.coupons.map((el) => {
+            el.shopData = []
+            if (el.shop) {
+              el.shopData.push(el.shop)
+            }
+            return el
+          })
+        } else {
+          for (let i = 0; i <= 2; i++) {
+            this.form.formList.push(defaultForm())
+          }
+        }
+      }
     },
     handleShopDialogVisible(index) {
       // 显示选择供应商弹窗
       this.addIndex = index
       this.dialogShopVisible = true
     },
+    handleGoodDialogVisible(index) {
+      // 显示选择商品弹窗
+      this.addIndex = index
+      this.dialogGoodVisible = true
+    },
     // 清除供应商
     deleteShop(index) {
-      this.hiddenItem = true
       this.form.formList[index].shopData = []
     },
     handleShopConfirm(data) {
       // 确认选择供应商
-      console.log('addIndex', this.addIndex)
-      console.log('data', data)
+      this.form.formList[this.addIndex].shopId = data.shopId
       this.form.formList[this.addIndex].shopData.push(data)
-      console.log('shopData', this.form.formList[this.addIndex].shopData)
-      this.hiddenItem = false
+      console.log('formList', this.form.formList[this.addIndex])
       this.handleShopCancel()
     },
     handleGoodConfirm(data) {
       // 确认选择商品
       console.log('data', data)
       console.log('addIndex', this.addIndex)
-      this.form.formList[this.addIndex].associateList.push(data)
-      console.log('addIndex', this.form.formList[this.addIndex])
-      console.log('formList', this.form.formList)
-      this.hiddenProduct = false
+      const from = this.form.formList[this.addIndex]
+      from.associateList.push(data)
+      console.log('from', this.form.formList)
       this.handleGoodCancel()
     },
+    handleDeletePros(formItem, index) {
+      // 删除商品
+      this.$confirm('确定删除吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        formItem.associateList.splice(index, 1)
+      })
+    },
     onSubmit(formName) {
       this.$refs[formName].validate(valid => {
         if (valid) {
+          this.handleFormParams()
           this.$confirm('是否提交数据', '提示', {
             confirmButtonText: '确定',
             cancelButtonText: '取消',
             type: 'warning'
           }).then(() => {
-            this.saveVipCoupon(this.form.formList)
+            console.log('formParams', this.formParams)
+            if (this.editType === 'add') {
+              this.formParams.configure = 1
+            } else {
+              this.formParams.configure = 1
+            }
+            this.saveVipCoupon(this.formParams)
           })
         } else {
           return false
         }
       })
     },
+    handleFormParams() {
+      // 处理参数
+      this.formParams.coupons = this.form.formList.map((el) => {
+        if (el.associateList && el.associateList.length > 0) {
+          el.associateList = el.associateList.map((pro) => {
+            return {
+              sort: pro.sort,
+              pcStatus: pro.pcStatus,
+              appletsStatus: pro.appletsStatus,
+              name: pro.name,
+              shopName: pro.shopName,
+              mainImage: pro.mainImage,
+              productId: pro.productId
+            }
+          })
+        }
+        return el
+      })
+    },
     async saveVipCoupon(params) {
       // 保存超级会员优惠券
       await saveVipCoupon(params)
@@ -271,35 +339,50 @@ export default {
     },
     handleDelete(item, index) {
       // 删除单挑优惠券
-      this.formList.splice(index, 1)
+      if (this.delFlag) {
+        this.delCoupon(item.id, index)
+      } else {
+        this.form.formList.splice(index, 1)
+      }
     },
-    handleOnInputBlur(formItem, row, index) {
+    async delCoupon(id, index) {
+      // 保存超级会员优惠券
+      await delCoupon(id)
+      this.form.formList.splice(index, 1)
+    },
+    handleOnInputBlur(formItem) {
       // 商品排序
-      console.log('formItem', formItem)
-      console.log('row', row)
-      console.log('index', index)
+      formItem.associateList.sort(this.sortByEnent('sort'))
+    },
+    sortByEnent(i) {
+      // 排序
+      return function(a, b) {
+        return a[i] - b[i] //  a[i] - b[i]为正序,倒叙为  b[i] - a[i]
+      }
     },
     handlePcStatusChange(row) {
       // PC状态开启关闭
-      if (row.pcStatus === 0) {
-        row.pcStatus = 1
+      console.log('row', row)
+      if (row.pcStatus === '0') {
+        row.pcStatus = '1'
       } else {
-        row.pcStatus = 0
+        row.pcStatus = '0'
       }
     },
     handleAppStatusChange(row) {
       // 小程序状态开启关闭
-      if (row.appletsStatus === 0) {
-        row.appletsStatus = 1
+      if (row.appletsStatus === '0') {
+        row.appletsStatus = '1'
       } else {
-        row.appletsStatus = 0
+        row.appletsStatus = '0'
       }
     },
-    goBack() {
-      // 调用全局挂载的方法,关闭当前标签页
-      // this.$store.dispatch('tagsView/delView', this.$route)
-      // 返回上一步路由,返回上一个标签页
-      this.$router.go(-1)
+    disabled3(array) {
+      if (array && array.length >= 2) {
+        return false
+      } else {
+        return true
+      }
     }
   }
 }

+ 2 - 43
src/views/member/coupon/list.vue

@@ -88,39 +88,12 @@
       :page.sync="listQuery.pageNum"
       :limit.sync="listQuery.pageSize"
     />
-    <!-- <template v-else>
-        <div class="coupon-content">
-          <div class="coupon-title">
-            <el-button type="primary" @click="handleAdd">新增优惠券</el-button>
-          </div>
-          <div v-for="(copu,index) in couponList" :key="index" class="coupon-list">
-            <span>优惠券{{ index+1 }}</span>
-            <div class="filter-control">
-              <span>优惠券金额:</span>
-              <el-input
-                v-model="copu.money"
-                placeholder="优惠券金额"
-                clearable
-              />
-            </div>
-            <el-button v-if="couponList.length>1 && index!=0" type="danger" @click="handleDelete(index)">删除</el-button>
-          </div>
-          <div slot="footer">
-            <el-button type="primary" @click="handleSubmit">保存</el-button>
-          </div>
-        </div>
-      </template> -->
   </div>
 </template>
 <script>
 import { fetchCouponList, fetchCloseCoupon, fetchOpenCoupon, fetchDeleteCoupon } from '@/api/member/member'
-const defaultCoupon = {
-  type: '',
-  money: '',
-  total: ''
-}
 export default {
-  name: 'MemberCoupon',
+  name: 'MemberCouponList',
   filters: {
     statusFilters(value) {
       console.log('value', value)
@@ -193,20 +166,18 @@ export default {
         status: '',
         startDate: '',
         endDate: '',
-        pageNum: 0,
+        pageNum: 1,
         pageSize: 20
       },
       // 超级会员优惠券
       total: 0,
       time: '',
       tableData: [],
-      couponList: [],
       dialogTableVisible: false,
       msg: ''
     }
   },
   created() {
-    this.couponList.push(defaultCoupon)
     this.getList()
   },
   methods: {
@@ -276,18 +247,6 @@ export default {
     handleEdit(type, id) {
       // 跳转编辑页
       this.$router.push({ path: '/member/coupon/edit', query: { type: type, id: id }})
-    },
-    handleAdd() {
-      // 新增优惠券
-      this.couponList.push(defaultCoupon)
-    },
-    handleDelete(index) {
-      // 删除优惠券
-      this.couponList.splice(index, 1)
-    },
-    handleSubmit() {
-      // 提交保存
-      console.log(this.couponList)
     }
   }
 }

+ 10 - 2
src/views/member/member/list.vue

@@ -180,7 +180,7 @@
           />
         </div>
         <div class="filter-control">
-          <el-button type="primary">搜索</el-button>
+          <el-button type="primary" @click="getclubList">搜索</el-button>
         </div>
       </div>
       <el-table ref="table" :data="clubTableData" height="350px" border @select="handleSelect">
@@ -419,6 +419,8 @@ export default {
         await saveSvip(this.vipForm)
         this.$message.success('操作成功')
         setTimeout(() => {
+          this.activeName = 'first'
+          this.getList()
           this.deleteClub()
           this.vipForm.month = ''
         }, 2000)
@@ -427,7 +429,13 @@ export default {
       }
     },
     handleTagsList(row) {
-      this.$router.push({ path: '/member/member/record-list', query: { clubId: row.clubId, userId: row.userId }})
+      const query = {
+        userId: row.userId,
+        clubName: row.clubName, // 机构名称
+        linkMan: row.linkMan, // 联系人
+        mobile: row.mobile// 手机号
+      }
+      this.$router.push({ path: '/member/member/record-list', query: query })
     }
   }
 }

+ 19 - 15
src/views/member/member/record-list.vue

@@ -7,7 +7,7 @@
           v-model="clubName"
           placeholder="机构名称"
           clearable
-          disabled="true"
+          :disabled="true"
         />
       </div>
       <div class="filter-control">
@@ -16,7 +16,7 @@
           v-model="linkMan"
           placeholder="联系人"
           clearable
-          disabled="true"
+          :disabled="true"
         />
       </div>
       <div class="filter-control">
@@ -25,7 +25,7 @@
           v-model="mobile"
           placeholder="机构名称"
           clearable
-          disabled="true"
+          :disabled="true"
         />
       </div>
     </div>
@@ -151,6 +151,7 @@ export default {
     packageFilters(value) {
       // 套餐
       const map = {
+        0: '系统赠送',
         1: '1个月',
         3: '3个月',
         12: '12个月'
@@ -271,7 +272,6 @@ export default {
       expireTime: '',
       isLoading: true,
       listQuery: {
-        clubId: 0, // 机构Id
         userId: 0, // 用户Id
         packageId: '', // 购买套餐
         status: '', // 会员状态
@@ -282,15 +282,18 @@ export default {
         pageNum: 1,
         pageSize: 20
       },
-      clubName: '', // 机构名称
-      linkMan: '', // 联系人
-      mobile: '', // 手机号
+      clubInfo: {
+        clubName: '', // 机构名称
+        linkMan: '', // 联系人
+        mobile: '' // 手机号
+      },
       tableData: [],
       total: 0
     }
   },
   created() {
-    this.listQuery = { ...this.listQuery, ...this.$route.query }
+    this.clubInfo = { ...this.clubInfo, ...this.$route.query }
+    this.listQuery.userId = this.clubInfo.userId
     this.getList()
   },
   methods: {
@@ -313,13 +316,14 @@ export default {
         this.listQuery.endEndTime = ''
       }
       // 获取数据列表
-      const res = await findHistory(this.listQuery)
-      this.tableData = res.data.results
-      this.total = res.data.totalRecord
-      this.clubName = res.data.results[0].clubName
-      this.linkMan = res.data.results[0].linkMan
-      this.mobile = res.data.results[0].mobile
-      this.isLoading = false
+      try {
+        const res = await findHistory(this.listQuery)
+        this.tableData = res.data.results
+        this.total = res.data.totalRecord
+        this.isLoading = false
+      } catch (error) {
+        console.log('error', error)
+      }
     }
   }
 }