index.vue 15.5 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 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
<!-- 转化订单推送 -->
<template>
  <div class="activity">
    <!-- 表格区域 开始 -->
    <div class="container">
      <div class="flex-between title">
        <div class="title-text">专员列表</div>
        <el-button :size="size" type="primary" class="battle-set-btn" @click="battleSetHandle">批量配置专员</el-button>
      </div>
      <GLTable ref="battleRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun" @selectionTable="selectionTable">
        <div slot="activityTime" slot-scope="scope">{{ dateFormatFun(scope.scope.startTime) }}-{{ dateFormatFun(scope.scope.endTime) }}</div>
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <el-button type="text" v-if="!scope.scope.staffId" @click="handlebattleOn(scope.scope)">配置</el-button>
          <el-button type="text" v-else @click="handlebattleOn(scope.scope, 'edit')">编辑</el-button>
        </div>
      </GLTable>
    </div>
    <GLDialog :mode="mode" class="battle-dialog" title="配置专员" @onOk="handlebattleConfirm" @onCancel="handlebattleClose" :visible.sync="battleVisible">
      <div class="gl-form-page gl-form-min">
        <el-form :model="wechat" ref="form" label-width="154px" :rules="rules">
          <el-form-item label="所属企业:">
            <el-radio-group v-model="config.merchantId" @change="changeRadio">
              <template v-for="(item, index) in merchantList">
                <el-radio :key="index" :label="item.merchantId">{{ item.merchantName }}</el-radio>
              </template>
            </el-radio-group>
          </el-form-item>
          <!-- 战报自动发送 -->
          <el-form-item class="select-wrap" label="战报自动发送:" prop="staffId">
            <div class="common el-form-item__content">
              <div class="el-input" ref="automaticRef">
                <div class="el-input__inner" @click="openAutomatic">
                  <span v-if="wechat.automaticName == ''" class="placeholder">选择成员</span>
                  {{ wechat.automaticName }}
                </div>
                <span class="el-input__suffix" @click="openAutomatic">
                  <span class="el-input__suffix-inner"><i :class="['el-select__caret', 'el-input__icon', 'el-icon-arrow-up', isAutomatic ? 'is-reverse' : '']"></i></span>
                </span>
              </div>
            </div>
            <transition name="el-zoom-in-top" v-if="!isAutomatic">
              <gl-select-menu :domEl="automaticEl" @changeStatu="hideSelect">
                <el-form-item class="search-groomname">
                  <el-input placeholder="请输入搜索关键词" v-model="filterText"></el-input>
                </el-form-item>
                <div class="el-select-dropdown__wrap el-scrollbar__wrap">
                  <template v-if="automaticData.length > 0">
                    <el-tree class="filter-tree" :data="automaticData" node-key="id" :default-expanded-keys="expandedKeys" :props="defaultProps" default-expand-all :filter-node-method="filterNode" ref="tree" @node-click="handleNodeClick"></el-tree>
                  </template>
                  <div class="empty" v-else>暂无数据</div>
                </div>
              </gl-select-menu>
            </transition>
          </el-form-item>
          <!-- 关联群 -->
          <el-form-item class="select-wrap" label="关联群:" prop="groupId">
            <div class="common el-form-item__content">
              <div class="el-input" ref="groupRef">
                <div class="el-input__inner" @click="openGroup">
                  <span class="placeholder" v-if="wechat.roomName == ''">选择选择群</span>
                  {{ wechat.roomName }}
                </div>
                <span class="el-input__suffix" @click="openGroup">
                  <span class="el-input__suffix-inner"><i :class="['el-select__caret', 'el-input__icon', 'el-icon-arrow-up', isgroup ? 'is-reverse' : '']"></i></span>
                </span>
              </div>
            </div>
            <transition name="el-zoom-in-top" v-if="!isgroup">
              <gl-select-menu :domEl="domEl" @changeStatu="hideSelect">
                <el-form-item class="search-groomname">
                  <el-input placeholder="请输入搜索关键词" prefix-icon="el-icon-search" v-model="roomName"></el-input>
                </el-form-item>
                <div class="el-select-dropdown__wrap el-scrollbar__wrap">
                  <ul class="el-scrollbar__view el-select-dropdown__list">
                    <template v-if="groupList.length > 0">
                      <li v-for="i in roomName == '' ? groupList : stageList" class="el-select-dropdown__item" :key="i" @click="selectGroup(i)">
                        <span>{{ i.roomName }}</span>
                      </li>
                    </template>
                    <div class="empty" v-else>暂无数据</div>
                  </ul>
                </div>
              </gl-select-menu>
            </transition>
          </el-form-item>
        </el-form>
      </div>
    </GLDialog>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
import { dateFormat } from '../../utils/index'
import GlSelectMenu from '../battle/components/select-dropdown.vue'
export default {
  components: {
    GlSelectMenu
  },
  data() {
    return {
      isgroup: true,
      isAutomatic: true,
      merchantId: '',
      merchantName: '',
      size: 'small',
      mode: 'mid',
      battleVisible: false,
      battlestaffVisible: false,
      url: url,
      setectList: [],
      merchantList: [],
      groupList: [],
      tableSearchForm: {},
      // 表格
      // userList: [],
      selectArray: [],
      getListApi: this.$apis.saasOrder.getYqReportlist,
      tableParams: {
        listName: 'list',
        tableOption: true,
        // // 行数据的key
        mutiSelectUniqueKey: 'activityId',
        // 多选ref的名称
        mutiSelectName: 'activity',
        tableColumns: [
          {
            label: '园区店',
            prop: 'yqMerchantName'
          },

          {
            label: '商户号',
            prop: 'yqMerchantId'
          },
          {
            label: '负责人',
            prop: 'staffName',
            line: 1,
            width: 300
          }
        ]
      },
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      expandedKeys: [],
      filterText: '',
      automaticData: [],
      stageList: [],
      roomName: '',
      config: {
        merchantId: ''
      },
      rules: {
        staffId: { required: true, message: '请选择战报自动发送', trigger: 'change' },
        groupId: { required: true, message: '请选择关联群', trigger: 'change' }
      },
      wechat: {
        staffId: '',
        automaticName: '',
        roomName: ''
      }
    }
  },

  mounted() {
    this.merchantList = this.$saasOrder?.merchantList || []
    this.config.merchantId = this.merchantList[0]?.merchantId
    this.config.merchantName = this.merchantList[0]?.merchantName
  },
  computed: {
    domEl() {
      return this.$refs.groupRef
    },
    automaticEl() {
      return this.$refs.automaticRef
    }
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val)
    },
    roomName(val) {
      this.filterRoomName(val)
    }
  },
  methods: {
    clearData() {
      this.setectList = []
      this.config.merchantId = this.merchantList[0]?.merchantId
      this.wechat = {
        automaticName: '',
        roomName: ''
      }
      this.hideSelect()
    },
    filterNode(value, data) {
      if (!value) return true
      return data.name.indexOf(value) !== -1
    },
    filterRoomName(value) {
      this.stageList = this.groupList.filter(item => {
        if (item.roomName.indexOf(value) !== -1) {
          return item
        }
      })
    },
    handleNodeClick(data) {
      this.hideSelect()
      this.wechat.automaticName = data.name
      this.wechat.staffId = data.staffId
      this.wechat.roomName = ''
      this.getGroupList(this.wechat.staffId)
    },
    hideSelect() {
      this.isgroup = true
      this.isAutomatic = true
    },
    selectGroup(data) {
      this.hideSelect()
      this.wechat.roomName = data.roomName
      this.wechat.groupId = data.roomChatId
    },
    openGroup(e) {
      this.isAutomatic = true
      this.isgroup = !this.isgroup
    },
    openAutomatic() {
      this.isgroup = true
      this.isAutomatic = !this.isAutomatic
    },
    //所属企业
    changeRadio(val) {
      this.getDepartmentTree()
      this.merchantList.forEach(item => {
        item.merchantId == val ? (this.merchantName = item.merchantName) : ''
      })
    },
    battleSetHandle() {
      if (this.setectList.length == 0) {
        this.$message({
          message: '请选择活动',
          type: 'error'
        })
        return
      }
      this.battleVisible = true
    },
    dateFormatFun(date) {
      return dateFormat(date)
    },
    selectionTable(val) {
      this.setectList = val
    },
    handlestaffbattleConfirm() {
      this.battlestaffVisible = false
    },
    handlestaffbattleClose() {
      this.battlestaffVisible = false
    },
    handlebattleConfirm() {
      if (!this.wechat.staffId) {
        this.$message({
          message: '请选择战报自动发送',
          type: 'error',
          customClass: 'message-Z-zinde'
        })
        return true
      }
      if (this.wechat.automaticName !== '' && this.wechat.roomName == '') {
        this.$message({
          message: '请选择关联群',
          type: 'error',
          customClass: 'message-Z-zinde'
        })
        return true
      }
      var params = {
        enterpriseMerchantId: this.config.merchantId,
        enterpriseMerchantName: this.config.merchantName,
        staffId: this.wechat.staffId,
        staffName: this.wechat.automaticName,
        groupId: this.wechat.groupId,
        groupName: this.wechat.roomName,
        groupMerchantId: this.config.merchantId,
        updatedBy: this.$globalState.session.accountName,
        yqMerchantIdList: []
      }

      this.setectList.forEach(item => {
        params.yqMerchantIdList.push(item.yqMerchantId)
      })
      // console.log(params, 'params---')

      this.$apis.saasOrder.updateYqConfig(params).then(res => {
        this.$message({
          message: res.code == '0' ? '配置成功' : res.message,
          type: res.code == '0' ? 'success' : 'error'
        })
        if (res.data) {
          this.battleVisible = false
          this.handleSearch()
          this.clearData()
        }
      })
    },
    handlebattleClose() {
      this.clearData()
      this.battleVisible = false
    },
    handleDetails() { },
    handlebattleOn(data, sign) {
      this.setectList = []
      this.setectList.push(data)
      this.battleVisible = true
      // 编辑
      if (sign) {
        this.wechat.staffId = data.staffId
        this.wechat.automaticName = data.staffName
        this.wechat.groupId = data.groupId
        this.wechat.roomName = data.groupName
        this.getGroupList(this.wechat.staffId)
      }
      this.getDepartmentTree()
    },
    getGroupList(id) {
      this.$apis.saasOrder.getGroupList({ msgStaffIdList: id }).then(res => {
        if (res.code == 0) this.groupList = res.data
      })
    },
    handleSetting() {
      this.drawer = true
    },
    handleClick() {
      this.handleSearch()
    },

    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.battleRef.data.length ? (this.$refs.battleRef.tableHeightValues = '') : this.$refs.battleRef.setTableHeightFun()
    },

    handleSearch() {
      this.$refs.battleRef.refreshTable()
    },
    async getDepartmentTree() {
      let params = { addChildrensFlag: true, queryMerchantId: this.config.merchantId, loginStatus: 1 }
      // let params = { addChildrensFlag: true, queryMerchantId: 44209846, loginStatus: 1 }
      let data = await this.$apis.saasOrder.getlistDepartmentTree(params)
      this.ids = []
      this.automaticData = data
      await this.initData(this.automaticData)
      this.expandedKeys = [this.automaticData[0].id]
    },
    initData(data) {
      data.forEach((item, index) => {
        this.$set(item, 'name', item.staffName ? item.staffName : item.departmentName)
        let entmicroStaffResponses = this.$common.utils.deepClone(item.entmicroStaffResponses) || []
        entmicroStaffResponses = entmicroStaffResponses.filter((staff, idx) => {
          if (staff.staffName) {
            this.$set(staff, 'name', staff.staffName)
          } else {
            this.$set(staff, 'name', staff.departmentName)
          }
          if (staff.staffId && !this.ids.includes(staff.staffId)) {
            this.ids.push(staff.staffId)
            return true
          } else if (staff.staffId && this.ids.includes(staff.staffId)) {
            return false
          }
        })
        let child = this.$common.utils.deepClone(item.children) || []
        child = child.filter((staff, idx) => {
          if (staff.staffName) {
            this.$set(staff, 'name', staff.staffName)
          } else {
            this.$set(staff, 'name', staff.departmentName)
          }
          if (staff.staffId && !this.ids.includes(staff.staffId)) {
            this.ids.push(staff.staffId)
            return true
          } else if (staff.staffId && this.ids.includes(staff.staffId)) {
            return false
          } else if (staff.entmicroStaffResponses) {
            staff.staffId = staff.id
            return true
          }
        })
        const children = [...child, ...entmicroStaffResponses]
        item.children = children
        //清除没有员工的部门
        if (!item.staffName && item.entmicroStaffResponses === null) {
          // data.splice(index, 1)
        }
        children.length && this.initData(children)
      })
    }
  }
}
</script>

<style scoped lang="scss">
.message-Z-zinde {
  z-index: 9999 !important;
}
.activity {
  .container {
    margin-top: 16px;
    .title {
      height: 32px;
      line-height: 32px;
      margin-bottom: 10px;
      .title-text {
        font-weight: 600;
        font-size: 16px;
        color: #333333;
        margin-left: 4px;
      }
    }
  }

  .input-tag-wrapper {
    position: relative;
    font-size: 14px;
    background-color: #fff;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #dcdfe6;
    box-sizing: border-box;
    color: #666;
    display: inline-block;
    outline: none;
    padding: 5px;
    max-height: 68px;
    overflow: auto;
    flex-wrap: wrap;
    transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    width: 450px;
    display: flex;
    align-items: center;
    margin-top: 6px;
    font-size: 14px;
    i {
      color: #75acff;
      margin-right: 3px;
      font-size: 14px;
    }
    /deep/ .el-tag {
      background-color: #fff !important;
      margin-bottom: 4px;
    }
  }
  .select-wrap {
    .common {
      margin: 4px 0;
      height: 40px !important;
      overflow: hidden;
      /deep/ .el-input {
        height: 40px !important;
        line-height: 40px !important;
      }
      /deep/ .el-input__suffix {
        height: 40px !important;
        margin-top: -4px;
        .is-reverse {
          transform: rotate(180deg);
        }
      }
    }
  }
}
.search-groomname {
  width: 252px;
  margin: 12px 16px 0;
  /deep/.el-input {
    width: 252px;
  }
}
.filter-tree {
  padding: 0 16px;
}
.empty {
  padding: 10px 0;
  margin: 0;
  text-align: center;
  color: #999;
  font-size: 13px;
}
.placeholder {
  font-size: 14px;
  color: #c0c6ce;
  line-height: 20px;
}
</style>