grouping.vue 11 KB
<template>
  <div>
    <div class="header-button"><el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd()">新建分群</el-button></div>

    <div class="scrm-sub-client-container">
      <div class="pageContent">
        <GLCombiForm :formObj="searchForm" :formData="clientGroupFormList" @handleOk="searchTable" @handleRest="resetTable"></GLCombiForm>
        <GLTable @setTableFinishFun="setTableFinishFun" v-if="isReload" ref="clientGroupManage" :hasNum="true" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn" :noDataImg="url" :pageConf="pageConf" :searchForm="searchFormTable" :tableParams="tableParams">
          <div slot="groupInfo" slot-scope="scope" v-if="scope.scope.crowdUnitList && scope.scope.crowdUnitList.length">
            <div class="table-tr">
              <div class="tabel-th">人群名称</div>
              <div class="tabel-th">人群总人数</div>
              <div class="tabel-th">已加企微人数</div>
              <div class="tabel-th">未加企微人数</div>
            </div>
            <div class="table-tr" v-for="item in scope.scope.crowdUnitList" :key="item">
              <div class="tabel-td">{{ item.crowdName }}</div>
              <div class="tabel-td">{{ item.total }}</div>
              <div class="tabel-td">{{ item.wechatTotal }}</div>
              <div class="tabel-td">{{ item.notWechatTotal }}</div>
            </div>
          </div>
          <template slot="auth-button" slot-scope="scope" :data="scope.scope">
            <!-- <auth-button :data="scope.scope"></auth-button> -->
            <el-button type="text" @click="goDetail(scope.scope.crowdGroupId)" class="blue-text">
              查看客户
            </el-button>
            <el-button type="text" @click="handleAdd(scope.scope)" class="blue-text">
              编辑
            </el-button>
            <el-button type="text" @click="handleDelete(scope.scope)" class="blue-text">
              删除
            </el-button>
            <!-- <GLButton  @click="goDetail(scope.scope.id, scope.scope.custGroupName)" fn="客户群详情" type="text">详情</GLButton>   -->
          </template>
        </GLTable>
      </div>
    </div>
    <add-or-edit ref="addOrEditForm"></add-or-edit>
  </div>
</template>

<script>
import { getTableList, syncCustomerBase, clientGroupExportApi } from '@/api/modules/clientGroupManage'
import addOrEdit from './addOrEdit.vue'
import url from '@/assets/clientDataOverview/nodata.png'
export default {
  name: 'grouping',
  components: {
    addOrEdit
  },
  data() {
    return {
      isReload: true,
      url: url,
      sloading: false,
      searchForm: {
        keyword: ''
      },
      searchFormTable: {},
      groupParams: {
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '人群名称',
            prop: 'couponName'
          },
          {
            label: '人群总数',
            prop: 'couponName'
          },
          {
            label: '已加企微人数',
            prop: 'couponName'
          },
          {
            label: '未加企微人数',
            prop: 'couponName'
          }
        ]
      },
      clientGroupFormList: [
        {
          type: 'input',
          inputType: 'text',
          name: 'keyword',
          label: '分群名称',
          placeholder: '请输入分群关键字'
        }
      ],
      pageConf: { pageSize: 'req.pageSize', pageNum: 'req.pageNum', totalCount: 'data.total' },
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'data.crowdGroupUnitList',
        tableColumns: [
          {
            label: '',
            prop: '',
            columnattrs: {
              type: 'expand'
            },
            addHtml: 'groupInfo'
          },
          {
            label: '分群名称',
            prop: 'crowdGroupName',
            line: 1
          },
          {
            label: '分群总人数',
            prop: 'total'
          },
          {
            label: '已加企微数',
            prop: 'wechatTotal'
          },
          {
            label: '未加企微数',
            prop: 'notWechatTotal'
          },
          {
            label: '概览是否展示',
            prop: 'isDisplay',
            formatter: cellValue => {
              return cellValue.isDisplay == 1 ? '展示' : '不展示'
            }
          },
          {
            label: '展示位',
            prop: 'displayLoc',
            formatter: cellValue => {
              return cellValue.displayLoc ? cellValue.displayLoc + '号展示位' : '--'
            }
          },
          {
            label: '操作',
            width: 180,
            prop: 'auth-button',
            addHtml: 'auth-button'
          }
        ]
        // tableOption: {
        //   width: 240
        //   // btnList: [
        //   //   {
        //   //     name: '详情',
        //   //     // pType: 'detail'
        //   //   }
        //   // ]
        // }
      },
      getListApi: this.$apis.crowdManage.queryCrowdGroupTree,

      merchantModel: 1,
      accountLevel: 0, //1,2,3,4工厂,省代,市代,门店
      flushTime: false
    }
  },
  filters: {
    filterTable(list) {
      return [{ couponName: 9 }]
    }
  },
  methods: {
    handleAdd(row) {
      this.$refs.addOrEditForm.init(row)
    },
    //删除
    handleDelete(scope) {
      this.$confirm('是否确认将此分群删除?', '删除', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'warning'
      })
        .then(async () => {
          const activityPage = await this.$apis.crowdManage.activityPage({ pageSize: 1, pageNum: 1, custGroupId: scope.crowdGroupId })
          if (activityPage.data.length) {
            this.againConfirm()
          } else {
            this.$apis.crowdManage
              .deleteCrowdGroup({
                'req.crowdGroupId': scope.crowdGroupId
              })
              .then(res => {
                if (res) {
                  this.$message({
                    type: 'success',
                    message: '删除成功!'
                  })
                }
                this.searchTable()
              })
          }
        })
        .catch(() => {})
    },
    againConfirm() {
      this.$confirm('此分群已被招揽活动任务调用,不支持删除', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error'
      })
        .then(() => {})
        .catch(() => {})
    },
    setTableHeightEvent() {
      this.$refs.clientGroupManage.setTableHeightFun()
    },
    setTableFinishFun(content) {
      console.log(content, this.$refs.clientGroupManage.data.length, '获取数据')
      // if (!this.flushTime) {
      //   this.flushTime = true
      //   this.searchTable()
      // }

      //接收到的数据为空
      // if (!this.$refs.clientGroupManage.data.length) {
      //   this.$refs.clientGroupManage.setTableHeightFun()
      // }
      this.$refs.clientGroupManage.data.length ? (this.$refs.clientGroupManage.tableHeightValues = '') : this.$refs.clientGroupManage.setTableHeightFun()
    },
    //导出
    handleExport() {
      var params = this.getParams()
      clientGroupExportApi(params).then(res => {
        this.$Utils.exportFn(res)
      })
    },
    searchTable() {
      this.$refs.clientGroupManage.refreshTable()
    },
    getParams() {
      var params = {
        req: {
          merchantId: this.$globalState.session.merchantId,
          keyword: this.searchForm.keyword
        }
      }
      console.log('params', params)
      delete params.daterange
      return params
    },
    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]
      //     delete this.searchFormTable.daterange
      //   } else {
      //     if (this.searchFormTable.beginTime) delete this.searchFormTable.beginTime && delete this.searchFormTable.endTime
      //   }
      //   resolve()
      // })
      return new Promise((resolve, reject) => {
        this.searchFormTable = this.getParams()
        resolve()
      })
    },

    resetTable() {
      this.isReload = false
      this.searchForm = {}
      this.$nextTick(() => {
        this.isReload = true
      })
    },
    goDetail(id) {
      this.$router.push(`/clientDataOverview/marketingPeople?crowdId=${id}`)
    }
  }
}
</script>
<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/resetelement.scss';
.header-button {
  margin-bottom: 10px;
}
.table-tr {
  width: 100%;
  display: flex;
  border-top: 1px solid #e8e8ea;
  &:first-child {
    background: #f4f6fc;
  }
  div {
    height: 40px;
    line-height: 40px;
    padding-left: 10px;
    width: 25%;
  }
}
.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 {
    /deep/ {
      .expanded {
        & + tr:hover td {
          background: none !important;
        }
      }
      .el-table__expand-icon {
        width: 14px;
        height: 14px;
        background: rgba(88, 80, 255, 0.3);
        border-radius: 2px;
        position: relative;
        &.el-table__expand-icon--expanded {
          transform: rotate(0deg);
        }
        &::after {
          top: 0px;
          left: 0px;
          content: '+';
          color: #5850ff;
          width: 14px;
          height: 14px;
          font-size: 14px;
        }
        i {
          display: none;
        }
        &.el-table__expand-icon--expanded {
          &::after {
            top: 0px;
            left: 0px;
            content: '-';
            color: #5850ff;
            width: 14px;
            height: 14px;
            font-size: 14px;
          }
        }
      }
    }
    .leadList {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      div {
        text-align: center;
        span:nth-child(1) {
          font-weight: 600;
          font-size: 16px;
        }
      }
      /deep/ .el-button {
        color: #5850ff;
        border: 1px solid #5850ff;
      }
    }
    .glsx-table {
      /deep/ .el-table__fixed,
      /deep/ .el-table__fixed-right {
        height: 100% !important; //设置高优先,以覆盖内联样式
      }
    }
    padding: 20px 20px 30px;
    box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
    // min-width: 1300px;
    background-color: #fff;
    .el-button + .el-button {
      margin-left: 10px;
    }
  }
  .el-message--info {
    height: 40px;
    background: #e6e9ff;
    border: 1px solid $btnBlue;
    border-radius: 4px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.65);
  }
  .el-message .el-icon-info {
    color: $btnBlue;
    font-size: 16px;
  }
}
</style>