customerList.vue 13.3 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
<!-- 客户列表 -->
<template>
  <d2-container class="customer-list">
    <div class="header" slot="header">
      <d2-search ref="showSearch" class="show-search" :search-form="searchForm" :form-data="showFormData" />
      <div class="up-btns">
        <el-button size="small" type="primary" @click="handleSearch">
          查询
        </el-button>
        <el-button size="small" @click="handleReset">
          重置
        </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header>
        <span slot="left">客户列表记录{{ count.orderCount }}条。</span>
        <auth-button category="Button" />
      </d2-table-header>
      <el-table :data="tableData">
        <el-table-column label="序号" width="60px" type="index" align="center" />
        <el-table-column label="客户信息">
          <el-table-column label="客户姓名" prop="customerName" align="center" />
          <el-table-column label="性别" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.customerSex === 1 ? '男' : '女' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="品牌车型" align="center" width="150px">
            <template slot-scope="scope">
              <span>{{ scope.row.carBrand || '' }}{{ scope.row.carSeriesName ? ('-' + scope.row.carSeriesName) : '' }}{{
                scope.row.carTypeName ? ('-' + scope.row.carTypeName) : '' }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column label="车架号"
                           align="center"
                           prop="standNo" /> -->
          <el-table-column label="客户状态" align="center">
            <template slot-scope="scope">
              <!-- <span
                class="red"
                v-if="customerStatusObj[1].includes(scope.row.status)"
              >未完成</span>
              <span v-else>已完成</span> -->
              <span :class="{ 'red': scope.row.status === 1 }">{{ baseData.customerStatusList.find(item => item.confId ==
                scope.row.status).confLabel }}</span>
              <!-- <span>{{scope.row.status}}</span> -->
            </template>
          </el-table-column>
          <el-table-column label="服务时间" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.order ? (!scope.row.order.installUpgradeTime ? '' : new
                Date(scope.row.order.installUpgradeTime).toLocaleDateString()) : '' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备注信息" align="center" prop="order.remark">
            <template slot-scope="scope">
              <span>{{ scope.row.order ? (scope.row.order.upgradeFlag === 'N' ? (scope.row.order.customer ?
                (scope.row.order.customer.refusalReason || '无') : '无') : (scope.row.order.remark || '无')) : '无' }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="关联信息">
          <el-table-column label="流量来源" align="center" prop="merchantName" width="170" />
          <el-table-column label="推荐人" align="center" prop="employeeName">
            <template slot-scope="scope">
              <span>{{ scope.row.order ? scope.row.order.employeeName : '' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="园区店" align="center" prop="yqMerchantName" width="170px" />
          <el-table-column label="转化专员" align="center" prop="order.sellerName" />
        </el-table-column>
        <el-table-column label="创建时间" align="center">
          <template slot-scope="scope">
            <span>{{ new Date(scope.row.createdDate).toLocaleDateString() }}</span>
          </template>
        </el-table-column>
        <el-table-column label="创建方式" align="center" prop="source">
          <template slot-scope="scope">
            <span>{{ scope.row.order ? (scope.row.order.source === 3 ? '现场升级' : (scope.row.order.source === 5 ? '核销抵扣' :
              '系统录入')) : (scope.row.source === 3 ? '现场升级' : (scope.row.source === 5 ? '核销抵扣' : '系统录入')) }}</span>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                     :current-page="page.pageNum" :page-sizes="[10, 20, 30, 40]" :page-size="page.pageSize" :total="total"
                     layout="sizes,total,->,prev,pager,next,jumper" />
    </div>
  </d2-container>
</template>

<script>
// exportFile
import { getList, orderCount } from '@api/customerList'
import { getServiceStore, getParkStore } from '@api/editCustomer'
// import { asyncExportExcel } from '@api/sys.base'
import { mapActions, mapState } from 'vuex'
export default {
  name: 'Index',
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      count: {
        orderCount: 0
      },
      showFormData: [{
        label: '客户状态',
        name: 'customerStatus',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confLabel',
        optionsName: 'customerStatusList'
      }, {
        label: '园区店',
        name: 'sellerMerchantId',
        type: 'select',
        optionList: [],
        optionId: 'merchantId',
        optionLabel: 'merchantName',
        optionsName: 'parkServiceList',
        changeAttr: (value, targetItem) => {
          value ? this.getServiceStore(value) : this.baseData.storeIdList = []
          this.searchForm.merchantId = ''
          this.getOptionsList()
        }
      }, {
        label: '流量来源',
        name: 'merchantId',
        type: 'select',
        noDataText: '请先选择园区店',
        optionList: [],
        optionId: 'merchantId',
        optionLabel: 'merchantName',
        optionsName: 'storeIdList'
      }, {
        label: '服务时间',
        name: 'successTime',
        type: 'datePicker',
        isClear: true,
        pickerOptions: 'rangePickerOptions'
      }, {
        label: '创建时间',
        name: 'createTime',
        type: 'datePicker',
        isClear: true,
        pickerOptions: 'rangePickerOptions'
      }, {
        label: '创建方式',
        name: 'source',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confLabel',
        optionsName: 'sourceList'
      }, {
        label: '流量信息',
        name: 'name',
        type: 'input',
        keyFn: this.keyDowmGetList,
        placeholder: '请输入推荐人或转化员姓名',
        isClear: true
      }, {
        label: '客户信息',
        name: 'keyword',
        type: 'input',
        keyFn: this.keyDowmGetList,
        placeholder: '车架号或客户姓名或钥匙号',
        isClear: true
      }],
      searchForm: {
        customerStatus: '',
        sellerMerchantId: '',
        merchantId: '',
        source: ''
      },
      // 表格
      tableData: [],
      // 搜索下拉框
      // 客户状态;1-未完成;2-已完成
      // customerStatusObj: {
      //   1: [1, 3],
      //   2: [2, 4, 6]
      // },
      // 创建方式;1-系统录入;2-现场升级;5-核销抵扣
      sourceStatusObj: {
        1: [1, 2, 6],
        2: [3],
        5: [5]
      },
      baseData: {
        parkServiceList: [],
        storeIdList: [],
        customerStatusList: [{
          confId: 1,
          confLabel: '未完成'
        }, {
          confId: 2,
          confLabel: '已完成'
        }, {
          confId: 3,
          confLabel: '已评价'
        }],
        upgradeList: [{
          confId: 'Y',
          confLabel: '已升级'
        }, {
          confId: 'N',
          confLabel: '战败'
        }, {
          confId: 'R',
          confLabel: '待升级'
        }],
        sourceList: [{
          confId: 1,
          confLabel: '系统录入'
        }, {
          confId: 2,
          confLabel: '现场升级'
        }, {
          confId: 5,
          confLabel: '核销抵扣'
        }]
      },
      total: 0,
      page: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },

  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },

  mounted() {
    // console.log(this.$router)
    getParkStore({}).then(res => {
      res.forEach(item => {
        item.merchantId = item.merchantNo
      })
      this.baseData.parkServiceList = res
      this.getOptionsList()
    })
    // if (this.userInfo.beSuper) {
    //   getParkStore({}).then(res => {
    //     res.forEach(item => {
    //       item.merchantId = item.merchantNo
    //     })
    //     this.baseData.parkServiceList = res
    //     this.getOptionsList()
    //   })
    // } else {
    //   this.showFormData = this.showFormData.filter(item => item.name !== 'sellerMerchantId')
    //   this.getServiceStore(this.userInfo.detail.merchantId)
    // }
    this.getList()
    this.getOrderCount()
  },

  methods: {
    ...mapActions('d2admin/user', ['actionSetDownloadList']),
    getParams() {
      var params = {
        merchantId: this.searchForm.merchantId,
        sellerMerchantId: this.searchForm.sellerMerchantId,
        name: this.searchForm.name,
        keyword: this.searchForm.keyword
        // upgradeFinishFlag: this.searchForm.upgradeFinishFlag
      }
      // this.searchForm.baseGoodsId && (params.baseGoodsCodeList = [this.searchForm.baseGoodsId])
      this.searchForm.customerStatus && (params.statusList = this.searchForm.customerStatus)
      this.searchForm.source && (params.sourceList = this.sourceStatusObj[this.searchForm.source])
      if (this.searchForm.successTime) {
        params.paySuccessStartDate = new Date(this.searchForm.successTime[0]).toLocaleDateString().replace(/\//g, '-')
        params.paySuccessEndDate = new Date(this.searchForm.successTime[1]).toLocaleDateString().replace(/\//g, '-')
      }
      if (this.searchForm.createTime) {
        params.startDate = new Date(this.searchForm.createTime[0]).toLocaleDateString().replace(/\//g, '-')
        params.endDate = new Date(this.searchForm.createTime[1]).toLocaleDateString().replace(/\//g, '-')
      }
      return params
    },
    getOrderCount() {
      orderCount({}).then(res => {
        this.count.orderCount = res.customerCount
      })
    },
    keyDowmGetList() {
      this.getList()
    },
    getList() {
      var params = this.getParams()
      params = {
        ...this.page,
        ...params
      }
      getList(params).then(res => {
        this.tableData = res.list
        this.page.pageNum = res.pageNum
        this.page.pageSize = res.pageSize
        this.total = res.total
      })
    },
    getServiceStore(merchantId) {
      getServiceStore({
        yqMerchantId: merchantId
      }).then(res => {
        this.baseData.storeIdList = res || []
        this.getOptionsList()
      })
    },
    getOptionsList() {
      var formList = ['showFormData']
      formList.forEach(i => {
        this[i].forEach((item, index) => {
          if (item.type === 'select') {
            if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[i][index].optionLabel] !== '全部') {
              const temp = {}
              temp[this[i][index].optionId] = ''
              temp[this[i][index].optionLabel] = '全部'
              this.baseData[item.optionsName].unshift(temp)
            }
            this.$set(this[i][index], 'optionList', this.baseData[item.optionsName])
          }
        })
      })
    },
    handleSearch() {
      this.page.pageNum = 1
      this.getList()
    },

    // 每页条数
    handleSizeChange(value) {
      this.page.pageSize = value
      this.getList()
    },

    // 页码
    handleCurrentChange(value) {
      this.page.pageNum = value
      this.getList()
    },
    handleReset() {
      this.searchForm = {
        customerStatus: '',
        // upgradeFinishFlag: '',
        sellerMerchantId: '',
        merchantId: '',
        // baseGoodsId: '',
        source: ''
      }
      // this.userInfo.beSuper && (this.baseData.storeIdList = [])
      // this.baseData.goodList = []
      this.baseData.storeIdList = []
      this.getOptionsList()
    },
    handleExport() {
      var params = this.getParams()
      params.pageNum = 1
      params.method = 'dj.api.customer.exportExcel.async'
      // exportFile(params).then(res => {
      //   this.$open(res)
      // })
      // asyncExportExcel({ exportParam: JSON.stringify(params) }).then(res => {
      const list = [
        ...this.dowloadList,
        {
          name: '客户列表',
          // uuid: JSON.parse(res).data,
          // ifSuccess: false
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
      // })
    }
  }
}

</script>
<style>
.customer-list {
  position: relative;
}

.search-icon {
  display: inline-block;
  width: 100%;
  height: 10px;
  text-align: center;
  cursor: pointer;
}

.customer-list .custom-input {
  display: inline-block;
  width: 220px;
}

.customer-list .custom-input:first-child {
  margin-right: 20px;
}

.customer-list .red {
  color: red;
}

.customer-list p {
  margin: 0 0;
}
</style>