index.vue 7.46 KB
<template>
  <div>
    <div class="scrm-sub-client-container">
      <!-- <p class="pageTitle">客户群管理</p> -->
      <div class="pageContent">
        <search-form class="searchTop border-shadow" :isHasSyncBtn="true" :formModel="searchForm" :formList="clientGroupFormList" @setTableHeightEvent="setTableHeightEvent" @resetTable="resetTable" @searchTable="searchTable" @syncClick="syncClick">
          <span class="inline-b" slot="form-slot">
            <el-button plain @click="resetTable">重置</el-button>
            <el-button type="primary" @click="searchTable">查询</el-button>
            <el-button type="primary" @click="syncClick" :loading="sloading">同步数据</el-button>
          </span>
        </search-form>
        <!-- <basic-table ref="clientGroupTable" :tableParams="tableParams" :getListApi="getListApi" :searchForm="searchForm" :hasNum="true">
        <span slot="table-button" slot-scope="scope">
          <el-button v-for="(j, idx) in tableParams.tableOption.btnList" :key="idx" :type="j.type || 'text'" :size="btn_size" @click="btnClick(j.pType, scope.scope)">{{ j.name }}</el-button>
        </span>
      </basic-table> -->
        <GLTable ref="clientGroupManage" :hasNum="true" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn" :noDataImg="url" :pageConf="pageConf" :searchForm="searchFormTable" :tableParams="tableParams" :headerStyle="{ height: '54px', background: '#F4F6FC', color: '#333333', fontSize: '14px' }">
          <span slot="status" slot-scope="scope">
            <!-- <span class="dot" :class="scope.scope.enableStatus ? DICTSTATUS[scope.scope.enableStatus].split(',')[1] : ''"></span> -->
            <span class="statusText" :class="scope.scope.status ? CLIENTSTATUS[scope.scope.status].split(',')[1] : ''">{{ scope.scope.status ? CLIENTSTATUS[scope.scope.status].split(',')[0] : '--' }}</span>
          </span>
          <template slot="auth-button" slot-scope="scope" :data="scope.scope">
            <!-- <auth-button :data="scope.scope"></auth-button> -->
            <span @click="goDetail(scope.scope.id, scope.scope.custGroupName)" class="blue-text">详情</span>
          </template>
        </GLTable>
      </div>
    </div>
  </div>
</template>

<script>
import { getTableList, syncCustomerBase } from '@/api/modules/clientGroupManage'
import url from '@/assets/clientDataOverview/nodata.png'
export default {
  name: 'clientManage',
  data() {
    return {
      url: url,

      sloading: false,
      titles: [
        { name: '客户群总数', num: 100, rate: '+10%', isUp: true, tips: '群提示消息1' },
        { name: '新增客户群数', num: 100, rate: '+10%', isUp: true, tips: '群提示消息2' }
      ],
      searchForm: {},
      searchFormTable: {},
      clientGroupFormList: [
        {
          type: 'daterange',
          prop: 'daterange',
          label: '创建时间',
          pickerOptions: {
            disabledDate(time) {
              return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
            }
          }
        },

        {
          type: 'input',
          inputType: 'text',
          prop: 'custGroupName',
          label: '客户群名称',
          placeholder: '请输入客户群名称'
        },
        {
          type: 'input',
          inputType: 'text',
          prop: 'groupHostName',
          label: '群主',
          placeholder: '请输入群主'
        },
        {
          type: 'input',
          inputType: 'text',
          prop: 'groupAdminName',
          label: '管理员',
          placeholder: '请输入管理员'
        }
      ],
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'data',
        tableColumns: [
          {
            label: '客户群名称',
            prop: 'custGroupName'
          },
          {
            label: '当前客户数',
            prop: 'totalCount'
          },
          {
            label: '新增入群客户数',
            prop: 'newCustomerCount'
          },
          {
            label: '新增退群客户数',
            prop: 'delCustomerCount'
          },
          {
            label: '群主',
            prop: 'groupHostName'
          },
          {
            label: '管理员',
            prop: 'groupAdminName'
          },
          {
            label: '创建时间',
            prop: 'addTime',
            width: 188
          }
        ],
        tableOption: {
          width: 170,
          btnList: [
            // {
            //   name: "编辑",
            //   pType: "edit",
            // },
            // {
            //   name: "删除",
            //   pType: "delete",
            // },
            {
              name: '详情',
              pType: 'detail'
            }
          ]
        }
      },
      getListApi: getTableList,
      setHeight: ''
    }
  },

  methods: {
    syncClick() {
      let _this = this
      _this.sloading = true
      syncCustomerBase({})
        .then(res => {
          if (!res) {
            return
          }
          _this.sloading = false
          this.$message.success('已同步客户群')
          this.$refs.clientGroupManage.refreshTable()
        })
        .catch(err => {
          _this.sloading = false
        })
    },
    setTableHeightEvent() {
      this.$refs.clientGroupManage.setTableHeightFun()
    },
    searchTable() {
      this.$refs.clientGroupManage.refreshTable()
    },
    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        this.searchFormTable = JSON.parse(JSON.stringify(this.searchForm))
        if (this.searchFormTable.daterange) {
          this.searchFormTable.beginTime = this.searchForm.daterange[0]
          this.searchFormTable.endTime = this.searchForm.daterange[1]
        } else {
          if (this.searchFormTable.beginTime) delete this.searchFormTable.beginTime && delete this.searchFormTable.endTime
        }
        delete this.searchFormTable.daterange
        resolve()
      })
    },

    resetTable() {
      this.searchForm = {}
      this.$refs.clientGroupManage.refreshTable()
    },
    btnClick(ptype, scope) {},
    goDetail(id, name) {
      this.$router.push({
        path: '/clientGroupManage/clientGroupDetail',
        query: {
          id: id,
          groupName: name
        }
      })
      // this.$history.push({
      //   path: '/clientGroupManage/clientGroupDetail',
      //   params: {
      //     id: id,
      //     groupName: name
      //   }
      // })
    }
  }
}
</script>
<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/resetelement.scss';
.scrm-sub-client-container {
  .pageTitle {
    position: relative;
    margin-bottom: 20px;
    height: 20px;
    font-size: 20px;
    font-weight: 700;
    color: #333333;
    line-height: 20px;
    letter-spacing: 1px;
  }
  .pageContent {
    padding: 6px 20px 30px;
    // min-width: 1300px;
    background-color: #fff;
    .el-button + .el-button {
      margin-left: 20px;
    }
    // .el-button {
    //   font-size: 14px;
    //   font-weight: 400;
    //   padding: 9px 21px;
    //   background: $btnBlue;
    //   border-radius: 4px;
    //   border: none;
    // }
    // .el-button:first-child {
    //   background: #ffffff;
    //   border-radius: 4px;
    //   border: 1px solid #999999;
    //   font-weight: 400;
    //   color: #666666;
    // }
    // .glsx-table {
    //   margin-top: 20px;
    // }
  }
}
</style>