file.vue 2.64 KB
<!--
 * @Description: 售后档案客户
 * @Author: huyue
 * @Date: 2022-06-23 15:05:21
 * @LastEditors: huyue
 * @LastEditTime: 2022-06-23 17:21:39
-->
<template>
  <div>
    <div class="title">售后档案客户</div>
    <div v-if="isEmpty" class="empty">
      <img src="../../assets/images/empty.png" alt="" />
    </div>
    <div v-else>
      <div v-if="dataList.map(item => item.num).every(item => item.num == 0)" class="empty">
        <img src="../../assets/images/empty.png" alt="" />
      </div>
      <LineChart v-else :dataList="dataList"></LineChart>
    </div>
  </div>
</template>

<script>
import { changeMixin } from '@/mixins'
export default {
  name: 'File',
  mixins: [changeMixin],
  props: {
    height: {
      type: String,
      default: '19.8vh'
    }
  },
  data() {
    return {
      isEmpty: true,
      dataList: []
    }
  },
  mounted() {
    // this.dealList()
  },
  methods: {
    init(val) {
      // console.log(val)
      var params = {
        req: {
          corporateGroupName: '广汇',
          queryItem: 'file',
          querystartTime: +val.reportType === 1 ? this.getNDate(-30) : this.getNMonth(-12),
          queryendTime: +val.reportType === 1 ? this.getNDate(-1) : this.getNMonth(-1),
          queryType: val.reportType || 0
        }
      }
      this.api.afterSales.getAfterSale(params).then(res => {
        var { code, data } = res
        switch (+code) {
          case 0:
            this.dataList = []
            console.log(data.dataList.map(item => item.num).every(item => item.num !== 0))
            if (data.dataList.map(item => item.num).every(item => item.num !== 0)) {
              this.isEmpty = false
              this.dealList(data.dataList)
            }
            break
          // default:
          // alert(message)
        }
      })
    },
    dealList(list) {
      var topList = []
      var lastList = []
      list.forEach(item => {
        const topTempList = JSON.parse(item.topList)
        const lastTempList = JSON.parse(item.lastList)
        topList = []
        lastList = []
        Object.keys(topTempList).forEach(item => {
          topList.push({
            label: item,
            value: this.numAddSymbol(topTempList[item])
          })
        })
        Object.keys(lastTempList).forEach(item => {
          lastList.push({
            label: item,
            value: this.numAddSymbol(lastTempList[item])
          })
        })
        this.dataList.push({
          num: item.num || 0,
          hrate: item.hrate || 0,
          trate: item.trate || 0,
          statDate: item.statDate,
          topList: topList,
          lastList: lastList
        })
      })
    }
  }
}
</script>