setmeal.vue 10.3 KB
<template>
  <div class="live-room">
    <tip-panel panelWidth="616px" panelMinHeight="40px" :panelContent="panelContent" v-if="isFirstShow" @closePanel="closePanel"></tip-panel>
    <div class="live-room container">
      <div class="btnWrap">
        <!-- <el-button :size="size" type="primary" @click="handleCreate" icon="el-icon-plus">创建套餐</el-button> -->
       <GLButton type="primary" @click="handleCreate" size="small" icon="el-icon-plus" fn="创建套餐" mode="el-button">创建套餐</GLButton>
          <el-button :size="size" @click="showViewer=true">查看示例效果</el-button>
          <el-image-viewer v-if="showViewer"  :on-close="()=>{showViewer=false}" :url-list="srcList"  style="padding:4%;"/>
      </div>
      <GLTable ref="memberSetMealRef" :noDataImg="url" @setTableFinishFun="setTableFinishFun" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
        <span slot="list" slot-scope="scope">
          <div v-for="(item, index) in scope.scope.list" :key="index">{{ item.couponName }}×{{ item.serviceQuantity }}</div>
        </span>
        <span class="table-btns" slot="optionsFun" slot-scope="scope" :data="scope.scope">
          <template v-if="scope.scope.state === 0">
            <!-- <el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button>
            <el-button type="text" @click="handleUpOption(scope.scope)">上架</el-button>
            <el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
            <GLButton type="text" @click="handleEdit(scope.scope)" fn="编辑套餐">编辑</GLButton>
            <GLButton type="text" @click="handleUpOption(scope.scope)" fn="上架">上架</GLButton>
            <GLButton type="text" @click="handleDelete(scope.scope)" fn="删除">删除</GLButton>
          </template>
          <template v-else-if="scope.scope.state === 1">
            <!-- <el-button type="text" @click="handleDownOption(scope.scope)">下架</el-button>
            <el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button> -->
            <GLButton type="text" @click="handleDownOption(scope.scope)" fn="下架">下架</GLButton>
            <GLButton type="text" @click="handleEdit(scope.scope)" fn="编辑套餐">编辑</GLButton>
          </template>
          <template v-else>
            <!-- <el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button>
            <el-button type="text" @click="handleUpOption(scope.scope)">上架</el-button>
            <el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
            <GLButton type="text" @click="handleEdit(scope.scope)" fn="编辑套餐">编辑</GLButton>
            <GLButton type="text" @click="handleUpOption(scope.scope)" fn="上架">上架</GLButton>
            <GLButton type="text" @click="handleDelete(scope.scope)" fn="删除">删除</GLButton>
          </template>
        </span>
      </GLTable>
    </div>
    <!-- btnCancelLabel="关闭" -->
    <glsx-dialog title="示例效果" width="1142px" :hasScroll="false" :noBtnOk="true" :noCancel="true" :noClose="false" typeName="primary" btnSize="small" :isVisible="isDialogVisible" :showClose="false" @closeDialog="handleClose" @confirmDialog="handleClose">
      <div class="content-body">
        <div class="content-item col1">
          <div class="subTitle">1、管理后台先创建套餐</div>
          <div class="imageWrap">
            <img src="@/assets/table.png" alt="" />
          </div>
        </div>
        <div class="content-item col2">
          <div class="subTitle">2、小程序端进行展示</div>
          <div class="twoImageWrap">
            <img src="@/assets/card1.png" alt="" />
            <img src="@/assets/card2.png" alt="" />
          </div>
        </div>
      </div>
    </glsx-dialog>
  </div>
</template>

<script>
import glsxDialog from '@/components/glsx-dialog'
import url from '@/assets/empty.png'
import { getSetMealListApi, deleteSetMeal, upDownPackage } from '@/api/modules/setmeal'
import { getLoginCount } from '@/api/modules/service'

import { stateList } from '@/common/constant'
import tipPanel from '@/components/tipPanel/index.vue'
export default {
  components: {
    tipPanel,
    glsxDialog,
    'el-image-viewer':()=>import('element-ui/packages/image/src/image-viewer')
  },
  data() {
    return {
      showViewer:false,
      url: url,
      surl: 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/memberCase.png',
      srcList: ['https://img01.glsx.com.cn/weapp/resource/saas/scrm/memberCase.png'],
      isFirstShow: false,
      panelContent: '会员套餐:将已经创建好的会员服务打包成一个套餐售卖给客户。',
      size: 'small',
      getListApi: getSetMealListApi,
      searchForm: {
        merchantId: 44184606
        // merchantName
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // 表格参数
      tableParams: {
        listName: 'list',
        // tableOption: true,
        tableColumns: [
          {
            label: '套餐名称',
            prop: 'packageName',
            width: '180'
          },
          {
            label: '套餐售价',
            prop: 'packagePrice',
            line: 1
          },
          {
            label: '套餐总价',
            prop: 'referencePrice'
          },
          {
            label: '套餐内容',
            prop: 'list',
            addHtml: 'list'
          },
          {
            label: '说明',
            prop: 'notes',
            width:160,
            line: 4
          },
          {
            label: '状态',
            prop: 'state',
            width: '80',
            formatter: cellValue => {
              return this.baseDataList.stateList.find(item => item.confId == cellValue.state).confName
            }
          },
          {
            label: '操作',
            prop: 'optionsFun',
            addHtml: 'optionsFun',
            width: 160
          }
        ]
      },
      baseDataList: {
        stateList: stateList
      },
      //查看示例  --弹窗
      isDialogVisible: false
    }
  },
  created() {
    this.getLoginCountFun()
  },
  mounted() {},
  methods: {
    previewPic() {
      this.$refs.previewImg.showViewer = true
    },
    getLoginCountFun() {
      //loginType:5是查会员套餐浏览次数
      getLoginCount({ loginType: 5 }).then(res => {
        //获取是否第一次点击该页面
        this.isFirstShow = res
      })
    },
    closePanel() {
      this.isFirstShow = false
    },
    handleReset() {
      this.searchForm = {
        merchantId: 44184606
      }
      this.handleSearch()
    },
    handleSearch() {
      this.$refs.memberSetMealRef.refreshTable()
    },
    setTableFinishFun() {
      //接收到的数据为空
      if (!this.$refs.memberSetMealRef.data.length) {
        this.$refs.memberSetMealRef.setTableHeightFun()
      }
    },
    //创建套餐
    handleCreate() {
      this.$router.push({
        path: '/memberCenter/setmealAddUpdate',
        query: {
          $title: encodeURI('创建套餐')
        }
      })
    },
    handleClose() {
      this.isDialogVisible = !this.isDialogVisible
    },
    //上架
    handleUpOption(row) {
      var params = {}
      params.id = row.id
      params.state = 1
      upDownPackage(params).then(res => {
        this.$message({
          message: res.code == '0' ? '上架成功' : res.message,
          type: res.code == '0' ? 'success' : 'error'
        })
        if (res.code == '0') {
          this.handleSearch()
        }
      })
    },
    handleDownOption(row) {
      var params = {}
      params.id = row.id
      params.state = 2
      this.$messageBox.confirm('下架后将隐藏且客户不能购买该套餐,已经购买的客户仍继续享有该套餐的服务?', '下架', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        // type: 'error',
        callback: action => {
          if (action == 'confirm') {
            upDownPackage(params).then(res => {
              this.$message({
                message: res.code == '0' ? '下架成功' : res.message,
                type: res.code == '0' ? 'success' : 'error'
              })
              if (res.code == '0') {
                this.handleSearch()
              }
            })
          }
        }
      })
    },
    handleEdit(row) {
      this.$router.push({ path: '/memberCenter/setmealAddUpdate', query: { id: row.id, $title: encodeURI('编辑套餐') } })
    },
    //   查看示例效果
    handleLook(row) {},
    handleDelete(row) {
      this.$messageBox.confirm('是否删除该套餐?', '删除', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        // type: 'error',
        callback: action => {
          if (action == 'confirm') {
            deleteSetMeal({ id: row.id }).then(res => {
              this.$message({
                message: res.code == '0' ? '操作成功' : res.message,
                type: res.code == '0' ? 'success' : 'error'
              })
              if (res.code == '0') {
                this.handleSearch()
              }
            })
          }
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.btnWrap {
  margin-bottom: 20px;
}

/deep/ .el-dialog__header {
  .main-title {
    font-size: 16px;

    font-weight: 700;
    color: #000000;
  }
}
/deep/ .el-dialog__body {
  border-top: 1px solid #e6e6e6;
  border-bottom: 1px solid #e6e6e6;
  padding: 20px 25px;
  .content-body {
    display: flex;

    .col2 {
      margin-left: 40px;
    }
    .content-item {
      .subTitle {
        margin-bottom: 20px;
        font-size: 18px;

        font-weight: 700;
        color: #000000;
      }
      .imageWrap,
      .twoImageWrap {
        margin-left: 25px;
        img {
          border: 1.5px solid rgba(0, 0, 0, 0.03);
          box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.03);
        }
        img + img {
          margin-left: 22px;
        }
      }
    }
  }
}
/deep/ .el-dialog__footer {
  text-align: center;
  padding: 20px;
}
/* 大图预览的关闭图标 改为大一点的白色 */
/deep/.el-image-viewer__btn.el-image-viewer__close {
    color: #5850ff;
    opacity: unset;
    top: 50px;
    right: 50px;
    width: 40px;
    height: 40px;
    font-size: 40px;
}
</style>