BoardBox.vue 5.97 KB
<template>
  <div class="board-box">
    <div class="board-search-box">
      <el-form
        inline
        size="small"
        label-width="97px"
      >
        <el-form-item label="归属业务:">
          <el-select
            class="select"
            v-model="businessType"
            @change="changeBusinessType"
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in bussinessTypeList"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <search-box
        class="search-box"
        @search="setTimeData"
        @update="getBoardData"
      />
    </div>
    <div class="board-content">
      <div class="left-board flex-box">
        <template v-for="(item,index) in currentBoardList">
          <board-item
            :key="index"
            class="board-item"
            :item="item"
            :data="boardData"
          />
        </template>
      </div>
      <div class="right-board flex-box">
        <template v-for="(item,index) in boardList">
          <board-item
            :key="index"
            class="board-item"
            :item="item"
            :data="boardData"
            @click="openWindow(item)"
          />
        </template>
      </div>
    </div>
    <div
      class="board-more"
      @click="openWindow({
        componentName:'data-more',
        tabTitle:'更多看板',
        pageId:'data-more'
       })"
    >
      更多看板
      <span class="el-icon-d-arrow-right"></span>
    </div>
  </div>
</template>

<script type='text/ecmascript-6'>
import SearchBox from '../SearchBox'
import BoardItem from './BoardItem'
import { getShopGuardIndexBoard } from '@api/earlyWarningManager'
import NP from 'number-precision'
export default {
  name: '',
  components: {
    SearchBox,
    BoardItem
  },
  data () {
    return {
      businessType: 4,
      bussinessTypeList: [
        { value: 2, name: '轻改' },
        { value: 3, name: '权益' },
        { value: 4, name: '延保' },
      ],
      boardData: {},
      currentBoardList: [
        {
          name: '当前产值完成度',
          value: 'outputCompletionProgress',
          valueUnit: '%',
          percent: 'outputCompletionProgressRatio',
          tips: '预算',
          tipsValue: 'budget'
        },
        {
          name: '当月毛利情况',
          value: 'profitSituation',
          percent: 'profitSituationRatio',
          tips: '毛利率',
          tipsValue: 'grossProfitMargin',
          tipsUnit:'%'
        }
      ],
      boardList: [
        {
          name: '产值',
          value: 'output',
          percent: 'outputRatio',
          unit: '(元)',
          code: 'A014'
        },
        {
          name: '展业门店数',
          value: 'storeNum',
          percent: 'storeNumRatio',
          code: 'A045'
        },
        {
          name: '客单价',
          value: 'customerUnitPrice',
          percent: 'customerUnitPriceRatio',
          unit: '(元)',
          code: 'A020'
        },
        {
          name: '店均产值',
          value: 'storeAverageOutput',
          percent: 'storeAverageOutputRatio',
          unit: '(元)',
          code: 'A044'
        },
        {
          name: '交车数',
          value: 'deliveryNum',
          percent: 'deliveryNumRatio',
          code: 'A001'
        },
        {
          name: '触客数',
          value: 'touchNum',
          percent: 'touchNumRatio',
          code: 'A004'
        },
      ],
      timeObject: {}
    }
  },
  mounted () {
    this.boardList.map(e => {
      e.componentName = 'boardDetail'
      e.pageId = `board-${e.code}`
      e.tabTitle = `${e.name}详情`
    })
  },
  methods: {
    setTimeData (params) {
      this.timeObject = params
      this.getBoardData()
    },
    async getBoardData () {
      let { timeObject, businessType } = this
      let params = {
        businessType,
        ...timeObject
      }
      const res = await getShopGuardIndexBoard(params)
      Object.keys(res).map(key => {
        if (res[key] != null) {
          if (key == 'outputCompletionProgress') res[key] = NP.times(res[key], 0.01)
          if (key == 'budget') res[key] = '¥' + res[key].toLocaleString()
          if(key == 'grossProfitMargin') res[key] += '%'
        } 
      // else res[key] = '-'
      })
      this.boardData = res
    },
    changeBusinessType () {
      this.getBoardData()
      this.$emit('changeBusinessType', this.businessType)
    },
    openWindow (e) {
      let { businessType } = this
      this.$emit('openWindow', {
        ...e,
        businessType
      })
    }
  }
}
</script>

<style scoped lang='scss'>
.board-box {
  background: #fff;
  border-radius: 0 4px 4px 4px;
  .board-search-box {
    display: flex;
    align-items: center;
    ::v-deep.el-form-item__content {
      height: 32px;
    }
    .el-form-item--small.el-form-item {
      margin: 0 !important;
      ::v-deep.el-input {
        height: 32px !important;
      }
    }
  }
  .search-box {
    flex: 1;
  }
  .board-content {
    padding: 0 20px;
    display: flex;
    .flex-box {
      display: flex;
      gap: 16px;
    }
    .board-item {
      width: 100%;
      height: 139px;
      border-radius: 4px;
      background: #f8faff;
    }
    .left-board {
      flex-direction: column;
      padding-right: 16px;
      border-right: 1px solid #e8e8ea;
      flex: 1;
    }
    .right-board {
      flex: 3;
      flex-wrap: wrap;
      padding-left: 16px;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      .board-item {
        cursor: pointer;
      }
    }
  }
  .board-more {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 8px 0 16px;
    color: #202020;
    font-size: 14px;
    cursor: pointer;
    width: fit-content;
    margin: 0 auto;
    span {
      color: #333333;
      margin-left: 4px;
    }
  }
}
</style>