tech-billing-stat.vue 2.39 KB
<template>
  <workbench-card title="科技部开单业绩" subtitle="科技部当月开单" icon="el-icon-s-promotion" tone="green" :loading="loading">
    <div class="stat">
      <div class="stat__icon"><i class="el-icon-s-promotion" /></div>
      <div class="stat__amount">¥{{ formatMoney(totalAmount) }}</div>
      <div class="stat__sub">本月科技部开单合计</div>
      <div class="stat__hint">{{ rowCount ? `共 ${rowCount} 条记录` : '本月暂无数据' }}</div>
    </div>
  </workbench-card>
</template>

<script>
import { mapGetters } from 'vuex'
import { getTechPerformanceStatisticsList } from '@/api/extend/statistics'
import WorkbenchCard from '../workbench-card.vue'
import { formatMoney, getCurrentMonthYm } from '../utils'

export default {
  name: 'WidgetTechBillingStat',
  components: { WorkbenchCard },
  data() {
    return { loading: false, totalAmount: 0, rowCount: 0 }
  },
  computed: {
    ...mapGetters(['userInfo']),
    teacherName() {
      return (this.userInfo && (this.userInfo.realName || this.userInfo.userName)) || ''
    }
  },
  mounted() {
    this.load()
  },
  methods: {
    formatMoney,
    async load() {
      this.loading = true
      try {
        const res = await getTechPerformanceStatisticsList({
          pageIndex: 1,
          pageSize: 500,
          statisticsMonth: getCurrentMonthYm(),
          teacherName: this.teacherName || undefined
        })
        const list = (res.data && res.data.list) || []
        this.rowCount = list.length
        this.totalAmount = list.reduce((s, r) => s + (Number(r.BillingPerformance || r.TotalPerformance || r.Performance || 0)), 0)
      } catch (e) {
        this.totalAmount = 0
        this.rowCount = 0
      } finally {
        this.loading = false
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.stat {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 0;
}
.stat__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ecfdf5;
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
}
.stat__amount {
  font-size: 26px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: -0.02em;
}
.stat__sub { margin-top: 6px; font-size: 13px; color: #64748b; }
.stat__hint { margin-top: 8px; font-size: 12px; color: #94a3b8; }
</style>