index.vue 10.7 KB
<template>
  <div class="expert-container">
    <div>
      <div class="btn-area">
        <GLButton id="clientBtn" :size="size" fn="新增配置" type="primary" @click.stop="addConfig(1)">
          新增配置
          <i class="el-icon-arrow-down"></i>
        </GLButton>
        <ul v-if="showClientType" class="client">
          <li @click.stop="selectClientType(1)">升级客户</li>
          <li @click.stop="selectClientType(2)">战败客户</li>
        </ul>
      </div>
      <span class="btnTip">配置轻改专家,形成业务活码,客户通过「精品升级」订单扫码后添加该员工。</span>
    </div>
    <div class="expert-wrap">
      <glsx-combi-form ref="expertRef" labelWidth="72px" defaultWidth="215px" :formObj="batchListSearch" :formData="expertForm">
        <div slot="department">
          <el-cascader popper-class="expert-cascader" ref="cascaderRef1" placeholder="请选择商户/门店" @change="getCurMerchant" :show-all-levels="false" v-model="batchListSearch.departmentId" :props="mypropParam1" :options="shopList" size="small" style="width: 215px" separator=" " filterable>
            <template slot-scope="{ data }">
              <el-tooltip popper-class="myToolTipClass" style="border: none" :disabled="data.label.length > 12 ? false : true" class="item" effect="light" :content="data.label" placement="top-end">
                <div class="limitText" style="width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{ data.label }}</div>
              </el-tooltip>
            </template>
          </el-cascader>
        </div>
        <span slot="footer" class="footer-btns">
          <el-button :size="size" type="primary" @click="handleSearch">查询{{ isNotData }}</el-button>
          <el-button :size="size" class="resetBtn" @click="handleReset">重置</el-button>
        </span>
      </glsx-combi-form>
      <GLTable ref="expertTable" @hook:mounted="setTabelHeight" :hasNum="false" :pageConf="batchPageConf" :searchForm="batchListSearch" :tableParams="batchTableParams" :getListApi="getListApi">
        <span slot="status" slot-scope="scope">
          <el-switch :value="scope.scope.status == 0" active-color="#5850ff" inactive-color="#eee" @change="changStatus(scope.scope.status, scope.scope.id)"></el-switch>
          {{ scope.scope.status == 1 ? '禁用' : '启用' }}
        </span>
        <div class="table-btns" slot="table-btns" slot-scope="scope">
          <GLButton fn="编辑" type="text" @click="addConfig(scope)">编辑</GLButton>
          <GLButton fn="编辑" type="text" @click="addConfig(2)">删除</GLButton>
        </div>
        <!-- <div slot="additionalContent" class="default-box">
          <img class="default-img" :src="imagBaseURL + 'serviceser.png'" alt="" />
          <span class="tip">用于「精品升级」客户线上化,配置轻改专家成员,可通过精品升级的质保卡活码拉新。</span>
          <GLButton :size="size" fn="新增配置" icon="el-icon-plus" type="primary" @click="addConfig(1)">配置门店轻改专家</GLButton>
        </div> -->
      </GLTable>
    </div>
  </div>
</template>

<script>
const imagBaseURL = 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/'
import glsxCombiForm from '@/components/glsx-combi-form'
import util from '@/util/util'
export default {
  name: 'expert_index',
  data() {
    return {
      imagBaseURL,
      shopName: '',
      shopList: [],
      mypropParam1: {
        value: 'id',
        label: 'label',
        children: 'children',
        checkStrictly: true
      },
      size: 'small',
      getListApi: this.$apis.expert.getExpertList,
      showClientType: false,
      batchPageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      batchListSearch: {
        departmentId: '',
        staffName: '',
        businessType: ''
      },
      expertForm: [
        {
          label: '门店',
          name: 'departmentId',
          addHtml: 'department'
        },
        {
          label: '员工',
          name: 'staffName',
          type: 'input',
          maxlength: 15
        },
        {
          label: '客户类型',
          name: 'businessType',
          type: 'select',
          optionList: [
            {
              memberId: '',
              memberName: '全部'
            },
            {
              memberId: 1,
              memberName: '正式会员'
            },
            {
              memberId: 2,
              memberName: '试用会员'
            }
          ],
          optionId: 'memberId',
          optionLabel: 'memberName',
          optionsName: 'memberType'
        }
      ],
      batchTableParams: {
        listName: 'data',
        tableOption: false,
        tableColumns: [
          {
            label: '编号',
            prop: 'stateId',
            formatter: cellValue => {
              return cellValue.stateId || '-'
            }
          },
          {
            label: '所属门店/部门',
            prop: 'departmentName',
            formatter: cellValue => {
              return cellValue.departmentName || '-'
            }
          },
          {
            label: '成员',
            prop: 'staffName',
            formatter: cellValue => {
              return cellValue.staffName || '-'
            }
          },
          {
            label: '客户类型',
            prop: 'businessType',
            width: 200,
            formatter: cellValue => {
              return cellValue.priceSection == -1 ? '战败客户' : '升级客户'
            }
          },
          {
            label: '欢迎语',
            prop: 'isWelcomeWord',
            width: 200,
            formatter: cellValue => {
              return cellValue.isWelcomeWord == -1 ? '否' : '是'
            }
          },
          {
            label: '状态',
            prop: 'status',
            addHtml: 'status'
          },
          {
            label: '操作',
            prop: '',
            width: '100px',
            fixed: 'right',
            addHtml: 'table-btns'
          }
        ]
      }
    }
  },
  components: {
    glsxCombiForm
  },
  computed: {},
  created() {
    this.getMerchantList()
  },
  mounted() {
    document.getElementById('app').addEventListener('click', this.setClientType)
  },
  beforeDestroy() {
    document.getElementById('app').removeEventListener('click', this.setClientType)
  },
  methods: {
    // 获取当前选择的商户
    getCurMerchant(val) {
      console.log(val, 7897)
      let id = val[val.length - 1]
      this.batchListSearch.departmentId = id
      // let labels = this.$refs.cascaderRef1.getCheckedNodes()[0].pathLabels
      // let curLabel = labels[labels.length - 1]
      // this.curTempMerchant = {
      //   merchantId: id,
      //   merchantName: curLabel
      // }
      // this.$refs.cascaderRef1.dropDownVisible = false
    },
    getMerchantList() {
      this.$apis.expert.getMerchantTree({}).then(res => {
        this.shopList = this.traverse(2, res, 'entmicroName', 'merchantAccountLevel')
      })
    },
    traverse(type, arr, string1, string2, arr1 = []) {
      arr.map(item => {
        // if (item[string1] || (item[string2] != 4 && type == 2)) {
        //   item.disabled = true
        // } else {
        //   item.disabled = false
        // }
        if (item.children && item.children instanceof Array) {
          this.traverse(type, item.children, string1, string2, (arr1 = []))
        }
        return item
      })
      return arr
    },
    setClientType() {
      if (this.showClientType) this.showClientType = false
    },
    changStatus(openFlag, id) {
      let ids = []
      ids.push(id)
      let target = 'openConfigs'
      if (openFlag == 1) {
        target = 'closeConfigs'
      }
      let params = { ids }
      this.$apis.openconfig[target](params).then(({ code, message }) => {
        if (code == 0) {
          this.$message({
            message: '操作成功!',
            type: 'success'
          })
          this.$refs.table.refreshTable()
        } else {
          this.$message.error(message)
        }
      })
    },
    addConfig() {
      this.showClientType = true
    },
    setTabelHeight() {
      this.$refs.expertTable.tableHeightValues = '455'
    },
    goDetail() {
      this.$router.push({ path: '/expert/detail/5' })
    },
    selectClientType(type, id) {
      this.showClientType = false
      let paraFormat = {
        clientType: type
      }
      if (id) {
        paraFormat.expertId = id
      }
      const urlpara = JSON.stringify(paraFormat)
      this.$router.push({ path: '/expert/detail/' + urlpara })
    },
    // beforeSearchFn() {
    //   return new Promise((resolve, reject) => {
    //     this.batchListSearch = { ...this.setParams() }
    //     resolve()
    //   })
    // },
    // setParams() {
    //   const params = {}
    //   params.searchText = 'dasda'
    //   return params
    // },
    handleSearch() {
      this.$refs.expertTable.refreshTable()
    },
    handleReset(type) {
      console.log(this.$refs.expertTable)
      this.batchListSearch = {
        searchText: '',
        activeTime: []
      }
      if (type === 'reset') {
        this.handleSearch()
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.btn-area {
  display: inline-block;
  position: relative;
  .client {
    background-color: #fff;
    list-style: none;
    position: absolute;
    z-index: 1;
    width: 108px;
    padding: 4px 0;
    box-shadow: 0px 6px 20px 0px rgba(122, 122, 122, 0.2);
    border-radius: 4px;
    top: calc(100% + 8px);
    li {
      height: 32px;
      line-height: 32px;
      text-align: center;
      background: #ffffff;
      cursor: pointer;
      font-size: 14px;
      font-weight: 400;
      color: #666666;
      &:hover {
        background-color: #f4f6fc;
        color: #5850ff;
      }
    }
  }
}
.btnTip,
.tip {
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #666666;
}
.btnTip {
  font-size: 14px;
  line-height: 22px;
  margin-left: 16px;
}
.expert-wrap {
  position: relative;
  margin-top: 16px;
  padding: 20px 20px 0;
  background-color: #fff;
  // height: calc(100vh - 148px);
  .select_wrapper {
    display: flex;
    align-items: center;
    .label {
      box-sizing: border-box;
      padding-right: 10px;
      font-size: 14px;
      font-weight: 400;
      color: #333333;
      text-align: right;
      white-space: nowrap;
    }
  }
  .default-box {
    width: 624px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    .default-img {
      width: 400px;
      height: 174px;
    }
    .tip {
      font-size: 16px;
      line-height: 24px;
      white-space: nowrap;
      margin: 24px;
    }
  }
}
</style>