index.vue 11.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
<template>
  <div class="scrm-sub-client-container">
    <div class="btn-header">
      <!-- <el-button class="addBtn" @click="btnClick('create')">新建群组</el-button> -->
      <GLButton class="addBtn" @click="btnClick('create')" fn="新建群组">新建群组</GLButton>
      <span class="toptips">
        <span>配置群聊不会自动拉群,邀请客户入群后群聊才会正式生效,一个客户默认拉一个群聊。</span>
      </span>
    </div>

    <div class="container">
      <search-form class="searchTop border-shadow" :formModel="searchForm" :formList="searchFormData" labelWidth="85px">
        <span class="inline-b" style="float: right" slot="form-slot">
          <el-button type="primary" @click="searchTable">查询</el-button>
        </span>
      </search-form>
      <!-- 表格区域 开始 -->
      <GLTable ref="gueastGroup" @setTableFinishFun="setTableFinishFun" :noDataImg="url" :getListApi="getListApi" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf">
        <div slot="entmicro-name" class="entmicro" slot-scope="scope">
          <div class="entmicro-tag" v-for="(tag, idx) in scope.scope.userList" :key="idx">
            <el-tag type="info" v-if="idx < 3" :disable-transitions="false">
              <!-- <i class="el-icon-user-solid"></i> -->
              <img class="headPortrait" src="@/assets/headPortrait.png" />
              {{ tag.staffName }}{{ tag.departmentName ? `(${tag.departmentName})` : '' }}
            </el-tag>
            <el-tag type="info" v-if="scope.scope.userList.length > 3 && idx == 3">
              <el-popover placement="top" width="600" trigger="hover" content="这是一段内容,这是一段内容,这是一段内容,这是一段内容。">
                <span slot="reference">...({{ scope.scope.userList.length }})</span>
                <div class="entmicro-hover">
                  <el-tag class="toptip" type="info" v-for="(i, index) in scope.scope.userList" :key="index" :disable-transitions="false">
                    <!-- <i class="el-icon-user-solid"></i> -->
                    <img class="headPortrait" src="@/assets/headPortrait.png" />
                    {{ i.staffName }}{{ i.departmentName ? `(${i.departmentName})` : '' }}
                  </el-tag>
                </div>
              </el-popover>
            </el-tag>
          </div>
        </div>
        <span slot="status" slot-scope="scope">
          <span :class="{ circleStatusGray: scope.scope.status === 2, circleStatusGreen: scope.scope.status === 1 }"></span>
          <span>{{ scope.scope.status == '1' ? '启用' : '停用' }}</span>
        </span>
        <div class="table-btns" slot="optionBtns" slot-scope="scope">
          <!-- <el-button type="text" @click="btnClick('edit', scope.scope)">修改</el-button>
          <el-button type="text" @click="btnClick('detail', scope.scope)">查看详情</el-button>-->
          <GLButton type="text" @click="btnClick('edit', scope.scope)" fn="修改群组">修改</GLButton>
          <GLButton type="text" @click="btnClick('status', scope.scope)" fn="启用禁用">{{ scope.scope.status == 1 ? '停用' : '启用' }}</GLButton>
          <GLButton type="text" @click="btnClick('detail', scope.scope)" fn="客户群详情">查看详情</GLButton>
          <!-- <el-button
            type="text"
            @click="btnClick('status', scope.scope)"
          >{{ scope.scope.status == 1 ? '停用' : '启用' }}</el-button>-->
        </div>
      </GLTable>
      <!-- 表格区域 end -->
    </div>
  </div>
</template>

<script>
import url from '@/assets/clientDataOverview/nodata.png'
export default {
  name: 'guestGroup',
  data() {
    return {
      url: url,
      searchForm: {},
      searchFormData: [
        {
          type: 'input',
          inputType: 'text',
          prop: 'groupName',
          label: '群聊名称:',
          placeholder: '请输入群聊名称搜索',
          clearable: true
        }
      ],
      // 表格
      getListApi: this.$apis.groupGuest.templateList,
      tableParams: {
        listName: 'data',
        tableOption: false,
        otherOptions: {
          label: '启用开关'
        },
        tableColumns: [
          {
            label: '群聊名称',
            prop: 'groupName',
            // minWidth: 90,
            line: 1
          },
          {
            label: '默认成员',
            prop: 'entmicroName',
            minWidth: 320,
            addHtml: 'entmicro-name'
          },
          {
            label: '创建时间',
            prop: 'createdTime',
            line: 1
            // minWidth: 110
          },
          {
            label: '状态',
            prop: 'status',
            // minWidth: 130,
            addHtml: 'status'
          },
          {
            label: '操作',
            prop: 'optionBtns',
            width: '200px',
            addHtml: 'optionBtns',
            fixed: 'right'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      tableData: [
        {
          id: 1,
          orgName: '守候专用服务一组',
          createdTime: '2021-11-05',
          status: '1',
          userList: [
            {
              id: 1,
              name: '1号',
              tips: '售前一组'
            },
            {
              id: 2,
              name: '2号',
              tips: '售前一组'
            },
            {
              id: 3,
              name: '3号',
              tips: '售前一组'
            },
            {
              id: 4,
              name: '4号',
              tips: '售前一组'
            },
            {
              id: 5,
              name: '5号',
              tips: '售前一组'
            },
            {
              id: 6,
              name: '6号',
              tips: '售前一组'
            },
            {
              id: 7,
              name: '7号',
              tips: '售前一组'
            },
            {
              id: 8,
              name: '8号',
              tips: '售前一组'
            },
            {
              id: 9,
              name: '9号',
              tips: '售前一组'
            },
            {
              id: 10,
              name: '10号',
              tips: '售前一组'
            }
          ]
        },
        {
          id: 2,
          orgName: '守候专用服务er组',
          createdTime: '2021-11-05',
          status: '2',
          userList: [
            {
              id: 1,
              name: '1号'
            },
            {
              id: 2,
              name: '2号'
            },
            {
              id: 3,
              name: '3号'
            },
            {
              id: 4,
              name: '4号'
            },
            {
              id: 5,
              name: '5号'
            }
          ]
        }
      ]
    }
  },
  // watch: {
  //   $route(val) {
  //     if (val.path == '/guestGroup/index') this.searchTable()
  //   }
  // },
  beforeDestroy() {
    this.$message.closeAll()
  },
  mounted() {
    this.wxTips()
  },
  methods: {
    wxTips() {
      const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST'])
      menu.forEach(item => {
        if (!item.children) {
          return
        }
        item.children.forEach(itm => {
          if (itm.path == '/enterpriseWechat/index') {
            this.$apis.groupGuest.getStatus({}).then(res => {
              if (res.status != 'SUCCESS') {
                const h = this.$createElement
                this.$message({
                  showClose: true,
                  duration: 0,
                  message: h('p', null, [h('span', null, '此功能需完成【企业微信授权】后方可使用! '), h('span', { on: { click: this.jumpWx }, style: { marginRight: '150px', cursor: 'pointer', color: '#5850ff' } }, ['企业微信授权 ', h('i', { class: 'el-icon-d-arrow-right' }, '')])])
                })
              }
            })
          }
        })
      })
    },
    jumpWx() {
      this.$history.push('/settings/enterpriseWechat/index')
    },
    //搜索表格
    searchTable() {
      this.$refs.gueastGroup.refreshTable()
    },
    btnClick(name, rowData) {
      switch (name) {
        case 'create':
          this.$router.push('/guestGroup/add')
          break
        case 'edit':
          this.$router.push('/guestGroup/add/' + rowData.id)
          break
        case 'detail':
          this.$router.push('/guestGroup/detail/' + rowData.id)
          break
        case 'status':
          this.$confirm(`是否确认${rowData.status == 1 ? '停用' : '启用'}?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            customClass: 'gl-message-box',
            type: 'warning'
          })
            .then(() => {
              const params = {
                id: rowData.id,
                status: rowData.status == 1 ? 2 : 1,
                merchantId: 1
              }
              this.$apis.groupGuest
                .status(params)
                .then(res => {
                  if (res) {
                    this.searchTable()
                    this.$message({
                      type: 'success',
                      message: '操作成功'
                    })
                  }
                })
                .catch(err => {
                  this.$message({
                    type: 'error',
                    message: err.message
                  })
                })
            })
            .catch(() => {
              this.$message({
                type: 'info',
                message: '已取消操作'
              })
            })
          break
        default:
          
      }
    },
    setTableFinishFun() {
      // if (!this.$refs.gueastGroup.data.length) {
      //   this.$refs.gueastGroup.setTableHeightFun()
      // }
      this.$refs.gueastGroup.data.length ? (this.$refs.gueastGroup.tableHeightValues = '') : this.$refs.gueastGroup.setTableHeightFun()
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/resetelement.scss';
.searchTop {
  /deep/ .el-form-item:nth-child(2) {
    position: static !important;
    .el-form-item__content {
      margin-left: 15px !important;
    }
  }
}
/deep/.search-form {
  .itemWidth {
    display: flex;
    .el-form-item {
      display: flex;
    }
  }

  .el-form-item__content {
    width: auto;
    display: inline-block;
    margin-left: 0px !important;
    .el-input {
      width: 415px;
      .el-input__inner {
        width: 415px;
      }
    }
  }
}
.btn-header {
  margin-bottom: 10px;
}
.container {
  margin-bottom: 20px;
  background: #ffffff;
  
  padding: 20px;
}
.addBtn {
  height: 32px;
  background: $btnBlue;
  border-radius: 4px;
  padding: 0 20px;
  color: #fff;
  font-size: 14px;
  &:hover {
    background-color: $lightBtnBlue;
  }
}
.toptips {
  display: inline-block;
  position: relative;
  margin-left: 10px;
  height: 20px;
  font-size: 14px;
  font-weight: 400;
  color: #666666;
  line-height: 20px;
}
.entmicro {
  // overflow: hidden;
  // text-overflow: ellipsis;
  // display: -webkit-box;
  // -webkit-line-clamp: 2;
  // -webkit-box-orient: vertical;
  text-align: left;
  i {
    color: #75acff;
    margin-right: 3px;
    font-size: 14px;
  }

  &-tag {
    display: inline-block;
  }
  &-hover {
    max-height: 214px;
    overflow: auto;
    i {
      color: #75acff;
      margin-right: 3px;
      font-size: 14px;
    }
  }
  // span {
  //   line-height: 20px;
  // }
}
.el-tag {
  margin-right: 10px;
  // margin-bottom: 10px;
  cursor: pointer;
}
.toptip {
  margin-bottom: 10px;
  &:nth-last-of-type(-n + 4) {
    margin-bottom: 0;
  }
}
/deep/ {
  .search-form {
    padding-top: 0;
  }
  .search-form .itemWidth {
    max-width: 100%;
  }
  .search-form .el-form-item:last-child {
    float: right;
  }
}
</style>