index.vue 12.2 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
<template>
  <div class="send-assistant">
    <div class="menu-sub">
      <div
        class="menu-sub-item"
        :class="[activeIndex == '1' ? 'active' : '']"
        @click="switchMenu(1)"
      >客户群发</div>
      <div
        class="menu-sub-item"
        :class="[activeIndex == '2' ? 'active' : '']"
        @click="switchMenu(2)"
      >客户群群发</div>
    </div>
    <div v-if="activeIndex == 1" class="container">
      <div class="container-header">
        <!-- <el-button
          type="primary"
          :size="size"
          icon="el-icon-plus"
          @click="btnClick('create', 1)"
        >新建群发</el-button>-->
        <GLButton
          type="primary"
          :size="size"
          icon="el-icon-plus"
          fn="新建客户群发"
          @click="btnClick('create', 1)"
        >新建群发</GLButton>
        <div class="text">企业统一选择要发送的客户,由添加客户的成员确认后发送给客户,消息内容仅管理员和负责人可创建。</div>
      </div>
      <!-- 表格区域 开始 -->
      <GLTable
        :key="key"
        ref="customer"
        :getListApi="customerList"
        :tableParams="gueastTableParams"
        :pageConf="gueastPageConf"
      >
        <div slot="entmicro-name" class="entmicro" slot-scope="scope">
          <span v-for="(i, index) in scope.scope.attachmentList" :key="index">
            [共{{scope.scope.attachmentList.length}}条]
            <span v-show="i.attType == 1">{{i.attContent}}</span>
            <span v-show="i.attType == 2 || i.attType == 3">[{{ATT_TYPE[i.attType]}}]</span>
            <span v-show="i.attType == 4 || i.attType == 5">[{{ATT_TYPE[i.attType]}}]</span>
          </span>
        </div>
        <div class="table-btns" slot="optionBtns" slot-scope="scope">
          <span
            v-if="scope.scope.status == -1 || scope.scope.status == 2"
            style="color: #EB4E4E;"
          >创建失败</span>
          <span v-else>
            <el-button
              type="text"
              :disabled="scope.scope.unsendUserNum == 0 || (scope.scope.unsendUserNum != 0 && scope.scope.isRemind == 1) || new Date(scope.scope.sendTime) > new Date()"
              @click="btnClick('remind', 1, scope.scope)"
            >提醒发送</el-button>
            <GLButton type="text" fn="客户群发详情" @click="btnClick('detail', 1, scope.scope)">详情</GLButton>
            <!-- <el-button type="text" @click="btnClick('detail', 1, scope.scope)">详情</el-button> -->
          </span>
        </div>
      </GLTable>
      <!-- 表格区域 end -->
    </div>
    <div v-if="activeIndex == 2" class="container">
      <div class="container-header">
        <!-- <el-button
          type="primary"
          :size="size"
          icon="el-icon-plus"
          @click="btnClick('create', 2)"
        >新建群发</el-button>-->
        <GLButton
          type="primary"
          :size="size"
          fn="新建客户群群发"
          icon="el-icon-plus"
          @click="btnClick('create', 2)"
        >新建群发</GLButton>
        <div class="text">管理员或负责人统一创建内容,群主收到通知后,可选择他管理的客户群并群发。</div>
      </div>
      <!-- 表格区域 开始 -->
      <GLTable
        :key="groupKey"
        ref="customerGroup"
        :getListApi="customerGroupList"
        :tableParams="gueastGroupTableParams"
        :pageConf="gueastPageConf"
      >
        <div slot="entmicro-name" class="entmicro" slot-scope="scope">
          <span v-for="(i, index) in scope.scope.attachmentList" :key="index">
            [共{{scope.scope.attachmentList.length}}条]
            <span v-show="i.attType == 1">{{i.attContent}}</span>
            <span v-show="i.attType == 2 || i.attType == 3">[{{ATT_TYPE[i.attType]}}]</span>
            <span v-show="i.attType == 4 || i.attType == 5">[{{ATT_TYPE[i.attType]}}]</span>
          </span>
        </div>
        <div class="table-btns" slot="optionBtns" slot-scope="scope">
          <span v-if="scope.scope.status == -1" style="color: #EB4E4E;">创建失败</span>
          <span v-else>
            <el-button
              type="text"
              :disabled="scope.scope.unsendUserNum == 0 || (scope.scope.unsendUserNum != 0 && scope.scope.isRemind == 1)"
              @click="btnClick('remind', 2, scope.scope)"
            >提醒发送</el-button>
            <GLButton type="text" fn="客户群群发详情" @click="btnClick('detail', 2, scope.scope)">详情</GLButton>
            <!-- <el-button type="text" @click="btnClick('detail', 2, scope.scope)">详情</el-button> -->
          </span>
        </div>
      </GLTable>
      <!-- 表格区域 end -->
    </div>
  </div>
</template>
<script>
import * as dayjs from 'dayjs'
export default {
  name: 'SendAssistant',
  data() {
    const ATT_TYPE = {
      2: '图文消息',
      3: '图文消息',
      4: '链接',
      5: '链接'
    }
    return {
      ATT_TYPE,
      activeIndex: 1,
      gueastTableParams: {
        listName: 'data',
        tableOption: false,
        tableColumns: [
          {
            label: '群发类型',
            prop: 'sendType',
            formatter: cellValue => {
              return {
                1: '立即发送',
                2: '定时发送'
              }[cellValue.sendType]
            }
          },
          {
            label: '群发内容',
            prop: 'massName',
            line: 2,
            minWidth: '100px',
            addHtml: 'entmicro-name'
          },
          {
            label: '发送时间',
            prop: 'sendTime',
            width: 170,
            line: 2
            // formatter: cellValue => {
            //   if (cellValue.sendTime) {
            //     return dayjs(cellValue.sendTime).format('YYYY-MM-DD HH:mm:ss')
            //   } else {
            //     return ''
            //   }
            // }
          },
          {
            label: '已发送员工',
            prop: 'sendUserNum',
            line: 2
          },
          {
            label: '已送达客户',
            prop: 'sendCustomerNum',
            line: 2
          },
          {
            label: '未发送员工',
            prop: 'unsendUserNum',
            line: 2
          },
          {
            label: '未送达客户',
            prop: 'unsendCustomerNum',
            line: 2
          },
          {
            label: '操作',
            prop: 'optionBtns',
            width: '140px',
            addHtml: 'optionBtns'
          }
        ]
      },
      gueastPageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      customerList: this.$apis.customerTransform.customerList,
      customerGroupList: this.$apis.customerTransform.customerGroupList,
      gueastGroupTableParams: {
        listName: 'data',
        tableOption: false,
        tableColumns: [
          {
            label: '群发名称',
            prop: 'massName'
          },
          {
            label: '群发内容',
            prop: 'massName',
            line: 2,
            minWidth: '100px',
            addHtml: 'entmicro-name'
          },
          {
            label: '发送时间',
            prop: 'sendTime',
            width: 150,
            line: 2
            // formatter: cellValue => {
            //   if (cellValue.sendTime) {
            //     return dayjs(cellValue.sendTime).format('YYYY-MM-DD HH:mm:ss')
            //   } else {
            //     return ''
            //   }
            // }
          },
          {
            label: '已发送群主',
            prop: 'sendUserNum',
            line: 2
          },
          {
            label: '送达群聊',
            prop: 'sendCustomerNum',
            line: 2
          },
          {
            label: '未发送群主',
            prop: 'unsendUserNum',
            line: 2
          },
          {
            label: '未送达群聊',
            prop: 'unsendCustomerNum',
            line: 2
          },
          {
            label: '操作',
            prop: 'optionBtns',
            width: '140px',
            addHtml: 'optionBtns'
          }
        ]
      },
      key: new Date(),
      groupKey: new Date()
    }
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      const path = from.path
      const pathArr = path.split('/')
      if (pathArr[2] == 'addCustomerGroup' || pathArr[2] == 'detaiCustomeGroup') vm.activeIndex = 2
    })
  },
  mounted() {
    this.wxTips()
  },
  beforeDestroy() {
    this.$message.closeAll()
  },
  methods: {
    switchMenu(val) {
      this.$nextTick(() => {
        this.activeIndex = val
        if (val == 1) {
          this.key = new Date()
          if (this.$refs.customer) this.$refs.customer.refreshTable()
        } else {
          this.groupKey = new Date()
          if (this.$refs.customerGroup) this.$refs.customerGroup.refreshTable()
        }
      })
    },
    /**
     * name: 按钮名称
     * type: 1 客户 2 客户群
     * rowData: 行数据
     */
    btnClick(name, type, rowData) {
      switch (name) {
        case 'create':
          if (type == 1) {
            this.$router.push('/customerTransform/addCustomer')
          } else {
            this.$router.push('/customerTransform/addCustomerGroup')
          }
          break
        case 'detail':
          if (type == 1) {
            this.$router.push('/customerTransform/detailCustomer/' + rowData.id)
          } else {
            this.$router.push('/customerTransform/detaiCustomeGroup/' + rowData.id)
          }
          break
        case 'remind':
          var params = {
            id: rowData.id,
            type
          }
          // if (type == 1) {
          this.$apis.customerTransform.listRemindOperate(params).then(res => {
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
            if (type == 1) {
              this.$refs.customer.refreshTable()
            } else {
              this.$refs.customerGroup.refreshTable()
            }
          })
          // } else {
          // }
          break
        default:
          console.log(11)
      }
    },
    jumpWx() {
      // this.$history.push('/settings/enterpriseWechat/index')
      this.$history.push('/home/enterpriseWechat/index')
    },
    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.customerTransform.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' }, '')])])
                })
              }
            })
          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scope>
.send-assistant {
  // margin-top: 26px;
  .menu-sub {
    margin-bottom: 15px;
    .menu-sub-item {
      display: inline-block;
      text-align: center;
      color: #303133;
      font-size: 14px;
      // width: 180px;
      // padding: 0 20px;
      margin-right: 40px;
      height: 32px;
      line-height: 32px;
      cursor: pointer;
      // &:first-child {
      //   padding-left: 0;
      // }
      &.active {
        // background-color: #fff;
        color: #5850ff;
        border-bottom: 2px solid #5850ff;
      }
    }
  }
  .container {
    margin-bottom: 20px;
    background: #ffffff;
    box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
    padding: 20px;
    margin-top: 2px;
    &-header {
      display: flex;
      // justify-content: space-between;
      align-items: center;
      padding-bottom: 20px;
      .text {
        font-size: 14px;
        color: #999;
        margin-left: 20px;
      }
    }
  }
}
.entmicro {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
</style>