sendRepairList.vue 19.6 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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
<template>
  <div>
    <div class="scrm-sub-client-container">
      <div class="pageContent">
        <GLCombiForm :rowNumber="2" :searchSelectObj="searchSelectObj" :formObj="searchForm" :formData="searchFormList" @handleOk="searchTable" @handleRest="resetTable"></GLCombiForm>
        <!-- 线索分配 -->
        <div class="leadList">
          <div>
            <span>线索列表</span>
          </div>
          <div>
            <el-button fn="线索分配" type="primary" plain size="small" @click="openNoticeDialog">推送设置</el-button>
            <el-button fn="线索分配" size="small" @click="handleExport">Excel导出</el-button>
          </div>
        </div>
        <GLTable ref="repairTableRef" :beforeSearchFn="beforeSearchFn" :getListApi="getListApi" :noDataImg="url" :searchForm="realSearchForm" :pageConf="pageConf" :tableParams="tableParams">
                <div slot="imageSlot" class="table-image" slot-scope="scope">
                    <el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
                        <img class="table-popover-img" :src="scope.scope.goodsImage" />
                        <img class="img-36 pointer" slot="reference" :src="scope.scope.goodsImage" />
                    </el-popover>
                </div>
                <div slot="statusSlot" slot-scope="scope">
                    <span :class="['status', scope.scope.goodsStatus==1 ? 'success-status': 'error-status']"></span>
                    <span>{{scope.scope.goodsStatus==1 ? '上架' : '下架' }}</span>
                </div>
                <div slot="merchantPriceSlot" slot-scope="scope">
                  <template v-if="scope.scope.saleMerchantList && scope.scope.saleMerchantList.length > 1">
                    <span>{{ filterData(scope.scope).slice(0, 1).join('、') }}</span>
                    <el-popover
                      placement="top"
                      width="fit-content"
                      trigger="hover">
                      <div v-for="(item,index) in filterData(scope.scope)" :key="index">
                        {{item}}
                      </div>
                      <span class="more-info" slot="reference">...({{ scope.scope.saleMerchantList.length }})</span>
                    </el-popover>
                  </template>
                  <template v-else>
                    <span v-if="!scope.scope.saleMerchantList || !scope.scope.saleMerchantList.length">--</span>
                    <span v-else>{{ filterData(scope.scope).join('、') }}</span>
                  </template>
                </div>
              <div
                  slot="linkText"
                  slot-scope="scope"
              >
                <template v-if="scope.scope.incrementFlag == 'Y' || hideStatus">
                  {{ scope.scope[scope.prop] || 0 }}
                </template>
                <template v-else>
                  <p
                      class="cursor-pointer"
                      @click="handleDetail(scope)"
                  >{{ scope.scope[scope.prop] || 0 }}</p>
                </template>
              </div>
                <div class="table-btns" slot="operateSlot" slot-scope="scope">
                    <el-Button class="blue-text" type="text" fn="线索详情" @click="reVisitFn(scope.scope)">回访</el-Button>
                </div>
            </GLTable>
      </div>
    </div>
    <GLDialog mode="mid" title="推送设置" :visible.sync="noticeVisible" :before-close="handleCancel" @onOk="handleOk" @onCancel="handleCancel">
        <glsx-combi-form class="form" ref="sendNoticeRef" :formRules="basicRule" labelWidth="154px" defaultWidth="432px" :formObj="basicForm" :formData="basicFormData">
            <div slot="timeSlot">
                    <el-time-picker
                        v-model="basicForm.sendTime"
                        :is-range="true"
                        format="HH:mm"
                        value-format="HH:mm"
                        ></el-time-picker>
            </div>
            <div slot="phoneSlot">
                <div v-for="(item, index) in basicForm.pushPhonesList" :key="index" class="phone-item">
                    <el-input v-model.trim="basicForm.pushPhonesList[index]" maxlength="11" type="text" placeholder="请输入"></el-input>
                    <i v-if="basicForm.pushPhonesList.length>1" @click="delPhoneFn(index)" class="el-icon-delete del"></i>
                </div>
                <div v-if="basicForm.pushPhonesList.length<5" class="add-btn" @click="addPhoneInputFn">
                    <img src="@/assets/add.png" />新增手机号
                </div>
            </div>
        </glsx-combi-form>
    </GLDialog>
    <collision v-if="collVisible" @closeDialogFn="closeDialogFn" :curCollId="curCollId"></collision>
  </div>
</template>

<script>
import * as dayjs from 'dayjs'
import util from '@/utils/util'
import url from '@/assets/clientDataOverview/nodata.png'
import glsxCombiForm from '@/components/glsx-combi-form'
import collision from './collision.vue'
import  {PHONE_MAX_NUM, FOLLOW_STATUS, FOLLOW_RESULT, SN_TYPE} from './constant'
export default {
  name: 'repairList',
  components: {
    glsxCombiForm,
    collision
  },
  data() {
    return {
      noticeVisible: false,
      collVisible: false,
      url: url,
      basicRule: {
        sendTime: [{ required: true, message: '请选择推送时间', trigger: 'change' }],
        pushPhonesList: [{
            required: true,
            validator: (rule, value, callback) => {
                const list = this.basicForm.pushPhonesList || []
                const emptyValIdx= this.basicForm.pushPhonesList?.findIndex(item => !item)
                const copylist = [...new Set(JSON.parse(JSON.stringify(list)))]
                if (list?.length<1 || emptyValIdx>-1) {
                    callback(new Error('请填写手机号'))
                } else if (list?.length>5) {
                    callback(new Error('手机号最多填写5个'))
                }else if(copylist.length!==list.length){
                    callback(new Error('手机号不能重复'))
                }else{
                    callback()
                }
            },
            trigger: 'change'
          }]
      },
      basicForm: {
        pushFlag: 0,
        sendTime: ['09:00', '20:00'],
        pushPhonesList: ['']
      },
      basicFormData: [
        {
          label: '门店提醒',
          name: 'pushFlag',
          type: 'radio',
          optionLabel: 'label',
          optionId: 'value',
          optionList: [
            {
              label: '开',
              value: 1
            },
            {
              label: '关',
              value: 0
            }
          ],
          isHide: false
        },
        {
          label: '推送时间',
          name: 'sendTime',
          addHtml: 'timeSlot',
          isHide: false,
        },
        {
          label: '顾问手机号',
          name: 'pushPhonesList',
          tipsWidth: 315,
          tipsHtml: `<p style="color: #333333;font-weight: 600;font-size: 12px;">当车主发送碰撞事故时,会往您所填的手机号推送一条碰撞预警的短信,同时也会将您的手机号同步给客户。</p>
          <span style="color: #666666;font-size: 12px;">如:您的客户xxx在广东省深圳市南山区粤海街道科苑北路疑似发生事故,客户手机号为:13XXXXXXXXX,请及时联系客户。</span>`,
          type: 'input',
          addHtml: 'phoneSlot',
          isHide: false,
        }
      ],
      realSearchForm: {},
      searchForm: {
        operate: false,
        sn: '',
        merchantName: '',
        merchantNo: '',
        snType: '',
        followStatus: '',
        followTime: '',
        collisionTime: '',
        followResult: '',
      },
      searchSelectObj: {
        nameOrNoOrVin: {
          attr: 'customerPhone',
          value: ''
        }
      },
      searchFormList: [
        {
          type: 'selectInput',
          selectName: 'nameOrNoOrVin',
          isClear: true,
          inputWidth: '320px',
          selectWidth: '110px',
          selectOption: [
            {
              label: '客户电话',
              name: 'customerPhone'
            },
            {
              label: '客户姓名',
              name: 'customerName'
            },
            {
              label: '车牌号',
              name: 'licensePlate'
            },
            {
              label: '车架号',
              name: 'standNo'
            }
          ],
          handleSelectChange: value => {
            this.searchSelectObj.nameOrNoOrVin.value = ''
          }
        },
        {
          type: 'input',
          name: 'sn',
          label: 'IMEI/SN号'
        },
        {
          type: 'select',
          name: 'snType',
          label: '设备类型',
          optionLabel: 'label',
          optionId: 'value',
          optionList: [
            {
              label: '全部',
              value: ''
            },
            ...SN_TYPE
          ],
          placeholder: '请选择'
        },
        {
          type: 'select',
          name: 'followStatus',
          label: '回访状态',
          optionLabel: 'label',
          optionId: 'value',
          optionList: [
            {
              label: '全部',
              value: ''
            },
            ...FOLLOW_STATUS
          ],
          placeholder: '请选择'
        },
        {
          label: '回访时间',
          name: 'followTime',
          type: 'datePicker',
          isClear: true,
          customPickerOptions: {
            disabledDate(date) {
              const yesterday = new Date(new Date().setDate(new Date().getDate()))
              return date > yesterday
            }
          }
        },
        {
          label: '碰撞时间',
          name: 'collisionTime',
          type: 'datePicker',
          isClear: true,
          customPickerOptions: {
            disabledDate(date) {
              const yesterday = new Date(new Date().setDate(new Date().getDate()))
              return date > yesterday
            }
          }
        },
        {
          type: 'select',
          name: 'followResult',
          label: '回访结果',
          optionLabel: 'label',
          optionId: 'value',
          optionList: [
            {
              label: '全部',
              value: ''
            },
            ...FOLLOW_RESULT
          ],
          placeholder: '请选择'
        }
      ],
      getListApi: this.$apis.sendRepair.getSendRepairListApi,
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      tableParams: {
        listName: 'data',
        tableColumns: [
          {
            label: '商户名称',
            prop: 'merchantName',
            width: 200,
            line: 1
          },
          {
            label: '商户号',
            prop: 'merchantId',
            width: 180
          },
          {
            label: '设备类型',
            prop: 'snType',
            width: 180,
            formatter : cell => {
                const _target = SN_TYPE.find(item => item.value == cell.snType)
                return _target ? _target.label : '--'
            }
          },
          {
            label: 'IMEI/SN',
            prop: 'sn',
            width: 200
          },
          {
            label: '客户电话',
            prop: 'customerPhone',
            width: 200
          },
          {
            label: '客户姓名',
            prop: 'customerName',
            width: 140
          },
          {
            label: '车牌号',
            prop: 'licensePlate',
            width: 140
          },
          {
            label: '车架号',
            prop: 'standNo',
            width: 230
          },
          {
            label: '车型',
            prop: 'vehicleShapeName',
            width: 140
          },
          {
            label: '碰撞地点',
            prop: 'address',
            width: 220,
            line: 1
          },
          {
            label: '碰撞时间',
            prop: 'collisionTime',
            formatter: cell => {
              return cell.collisionTime ? dayjs(cell.collisionTime).format('YYYY-MM-DD HH:mm:ss') : '--'
            },
            minWidth: 180
          },
          {
            label: '回访状态',
            prop: 'userName',
            width: 180,
            formatter : cell => {
                const _target = FOLLOW_STATUS.find(item => item.value == cell.followStatus)
                return _target ? _target.label : '--'
            }
          },
          {
            label: '回访时间',
            prop: 'followTime',
            width: 220,
            formatter: cell => {
              return cell.followTime ? dayjs(cell.followTime).format('YYYY-MM-DD HH:mm:ss') : '--'
            }
          },
          {
            label: '回访结果',
            prop: 'createdDate',
            width: 180,
            formatter : cell => {
                const _target = FOLLOW_RESULT.find(item => item.value == cell.followResult)
                return _target ? _target.label : '--'
            }
          },
          {
            label: '回访备注',
            prop: 'followRemark',
            width: 180
          },
          {
            label: '回访人员',
            prop: 'updatedBy',
            width: 140
          },
          {
            label: '操作',
            fixed: 'right',
            addHtml: 'operateSlot',
            width: 70
          }
        ]
      },
    }
  },
  watch:{
    'basicForm.pushFlag':{
      handler(nVal,oVal){
        this.basicFormData.forEach(item => {
          if(item.name != 'pushFlag'){
            item.isHide = !nVal
          }
        })
        // if(nVal){
        //   this.basicForm.sendTime = ['09:00', '20:00']
        //   this.basicForm.pushPhonesList = ['']
        // }
      },
      deep: true
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    reVisitFn(row){
        this.curCollId = row.id
        this.collVisible = true
    },
    closeDialogFn(){
        this.collVisible = false
        this.searchTable()
    },
    handleOk() {
        this.$refs.sendNoticeRef.$refs.formRef.validate(valid => {
            if(valid){
                console.log(this.basicForm)
                const {pushFlag, pushPhonesList, sendTime} = this.basicForm
                const params = {
                    pushFlag,
                    startTime: sendTime[0],
                    endTime: sendTime[1],
                    configType: 0,
                    pushPhones: pushPhonesList?.join(',') || ''
                }
                this.$apis.sendRepair.setNoticeApi(params).then(res => {
                    console.log(res)
                    if(res){
                        this.$message.success('设置成功')
                        this.resetNoticeData()
                    }
                })
            }
        })
    },
    handleCancel() {
        this.resetNoticeData()
    },
    resetNoticeData(){
        this.noticeVisible = false
        this.basicForm = {
            pushFlag: 0,
            sendTime: ['09:00', '20:00'],
            pushPhonesList: ['']
        }
    },
    addPhoneInputFn(){
        if(this.basicForm.pushPhonesList.length >=PHONE_MAX_NUM) return
        this.basicForm.pushPhonesList.push('')
    },
    delPhoneFn(idx){
        this.basicForm.pushPhonesList.splice(idx, 1)
    },
    setTableFinishFun() {
      this.$refs.repairTableRef.data.length ? (this.$refs.repairTableRef.tableHeightValues = '') : this.$refs.repairTableRef.setTableHeightFun()
    },
    setTableHeightEvent() {
      this.$refs.repairTableRef.setTableHeightFun()
    },
    openNoticeDialog() {
        this.noticeVisible  = true
        this.$apis.sendRepair.getNoticeDetailApi({}).then(res => {
            if(res?.length) {
                const {configType, endTime, startTime, id, pushFlag, pushPhones } = res[0]
                if(configType==0){
                    this.basicForm = {
                        pushFlag,
                        sendTime: [startTime, endTime],
                        pushPhonesList: pushPhones?.split(',') || []
                    }
                }
            }
        })
    },
    // 搜索表格
    searchTable() {
      this.$refs.repairTableRef.refreshTable()
    },
    //重置表格
    resetTable() {
        this.searchForm = {
            operate: false,
            sn: '',
            merchantName: '',
            merchantNo: '',
            snType: '',
            followStatus: '',
            followTime: '',
            collisionTime: '',
            followResult: '',
        },
        this.searchSelectObj = {
            nameOrNoOrVin: {
                attr: 'customerPhone',
                value: ''
            }
        }
        this.$refs.repairTableRef.refreshTable()
    },
    getSelectInputParams() {
      const list = Object.keys(this.searchSelectObj)
      var params = {}
      list.forEach(i => {
        const item = this.searchSelectObj[i]
        item.value && (params[item.attr] = item.value)
      })
      return params
    },
    getParams() {
        var params = JSON.parse(JSON.stringify(this.searchForm))
        if (this.searchForm.followTime.length) {
          params.beginFollowTime = new Date(this.searchForm.followTime[0]).toLocaleDateString().replace(/\//g, '-')+ ' 00:00:00'
          params.endFollowTime = new Date(this.searchForm.followTime[1]).toLocaleDateString().replace(/\//g, '-')+ ' 23:59:59'
        }
        if (this.searchForm.collisionTime.length) {
          params.beginCollisionTime = new Date(this.searchForm.collisionTime[0]).toLocaleDateString().replace(/\//g, '-')+ ' 00:00:00'
          params.endCollisionTime = new Date(this.searchForm.collisionTime[1]).toLocaleDateString().replace(/\//g, '-')+ ' 23:59:59'
        }
        delete params.followTime
        delete params.collisionTime
        return {...params, ...this.getSelectInputParams()}
      },
    beforeSearchFn() {
        return new Promise(resolve => {
          this.realSearchForm = this.getParams()
          resolve()
        })
    },
    handleExport () {
        const params = this.getParams()
        params.pageNum = 1
        params.pageSize = 5000
        this.$apis.sendRepair.exportSendRepairListApi(params).then(res => {
            util.exportFn(res)
        })
    },
  }
}
</script>

<style lang="scss" scoped>
.scrm-sub-client-container {
  /deep/ .el-table .cell {
    text-overflow: clip;
  }
  /deep/ .el-table .cell,
  .el-table th div {
    text-overflow: clip;
  }
  .pageContent {
    padding: 20px 20px 30px;

    // min-width: 1300px;
    background-color: #fff;
    /deep/ .el-icon-user-solid {
      color: #75acff;
      // margin-right: 3px;
      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;
        }
        span:nth-child(2) {
          font-size: 14px;
          margin-left: 8px;
          color: #5850ff;
          border-bottom: 1px solid #5850ff;
          cursor: pointer;
        }
      }
    }
    /deep/ .el-tag {
      height: 26px;
      line-height: 26px;
      padding: 0 8px;
    }
  }
  .blue-text {
    color: #5850ff;
  }
}
.phone-item{
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    /deep/ .el-input__inner{
        width: 284px;
    }
    .del{
        margin-left: 10px;
        color: #C6C6C6;
    }
}

.add-btn{
    height: 20px;
    display: inline-flex;
    align-items: center;
    color: #5850FF;
    font-size: 12px;
    cursor: pointer;
    img{
        height: 20px;
        width: 20px;
        margin-right: 6px;
    }  
}
</style>