tech-dept-kpi.vue 3.36 KB
<template>
  <workbench-card title="科技部核心指标" :subtitle="deptName || '科技部当月'" icon="el-icon-cpu" tone="cyan" :loading="loading">
    <template #extra>
      <el-button type="text" size="mini" @click="goMore">更多</el-button>
    </template>
    <div v-if="techDepartmentId" class="wb-kpi-grid kpi-5">
      <div class="wb-kpi-cell wb-kpi-cell--primary">
        <div class="wb-kpi-cell__label">溯源金额</div>
        <div class="wb-kpi-cell__value">¥{{ formatMoney(stats.TraceabilityAmount) }}</div>
      </div>
      <div class="wb-kpi-cell wb-kpi-cell--success">
        <div class="wb-kpi-cell__label">Cell金额</div>
        <div class="wb-kpi-cell__value">¥{{ formatMoney(stats.CellAmount) }}</div>
      </div>
      <div class="wb-kpi-cell wb-kpi-cell--danger">
        <div class="wb-kpi-cell__label">Slim金额</div>
        <div class="wb-kpi-cell__value">¥{{ formatMoney(stats.SlimAmount) }}</div>
      </div>
      <div class="wb-kpi-cell wb-kpi-cell--warning">
        <div class="wb-kpi-cell__label">科美总收入</div>
        <div class="wb-kpi-cell__value">¥{{ formatMoney(stats.TotalKemeiIncome) }}</div>
      </div>
      <div class="wb-kpi-cell wb-kpi-cell--info">
        <div class="wb-kpi-cell__label">活跃门店</div>
        <div class="wb-kpi-cell__value">{{ stats.ActiveStoreCount || 0 }}</div>
      </div>
    </div>
    <div v-else class="wb-empty">
      <div class="wb-empty__circle" style="background:#ecfeff;color:#06b6d4"><i class="el-icon-cpu" /></div>
      <div class="wb-empty__title">暂无科技部</div>
      <div class="wb-empty__desc">未获取到科技部组织,无法展示指标</div>
    </div>
  </workbench-card>
</template>

<script>
import request from '@/utils/request'
import WorkbenchCard from '../workbench-card.vue'
import { formatMoney, getCurrentMonthYm } from '../utils'

export default {
  name: 'WidgetTechDeptKpi',
  components: { WorkbenchCard },
  data() {
    return {
      loading: false,
      techDepartmentId: '',
      deptName: '',
      stats: {}
    }
  },
  mounted() {
    this.load()
  },
  methods: {
    formatMoney,
    async resolveDept() {
      const res = await request({
        url: '/api/Extend/Organize/GetByName',
        method: 'get',
        data: { organizeName: '科技部' }
      })
      const list = res.data || []
      const first = list[0]
      if (!first) return
      this.techDepartmentId = first.Id || first.id || ''
      this.deptName = first.FullName || first.fullName || '科技部'
    },
    async load() {
      this.loading = true
      try {
        await this.resolveDept()
        if (!this.techDepartmentId) return
        const res = await request({
          url: '/api/Extend/LqTechDepartmentDashboard/GetStatistics',
          method: 'post',
          data: {
            statisticsMonth: getCurrentMonthYm(),
            techDepartmentId: this.techDepartmentId,
            storeIds: []
          }
        })
        this.stats = res.data || {}
      } catch (e) {
        this.stats = {}
      } finally {
        this.loading = false
      }
    },
    goMore() {
      this.$router.push('/extend/techDepartmentDashboard').catch(() => {})
    }
  }
}
</script>

<style lang="scss" scoped>
@import '../widget-common.scss';
.kpi-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1200px) {
  .kpi-5 { grid-template-columns: repeat(2, 1fr); }
}
</style>