6 天以前 533353dbeb19b3fa45817e9f65874db4e2ce6f9e
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
<template>
  <section class="app-panel welcome">
    <div class="welcome__left">
      <h2 class="welcome__title">{{ greeting }},{{ userName }}</h2>
      <p class="welcome__meta">
        <span>{{ dateText }}</span>
        <span class="welcome__sep">|</span>
        <span>{{ roleName || '系统用户' }}</span>
        <template v-if="deptName">
          <span class="welcome__sep">|</span>
          <span>{{ deptName }}</span>
        </template>
      </p>
    </div>
    <div class="welcome__chips">
      <div class="welcome__chip">
        <span class="welcome__chip-label">待办任务</span>
        <span class="welcome__chip-value app-num">{{ todoCount }}</span>
      </div>
      <div class="welcome__chip">
        <span class="welcome__chip-label">待生产订单</span>
        <span class="welcome__chip-value app-num">{{ pendingOrders }}</span>
      </div>
      <div class="welcome__chip">
        <span class="welcome__chip-label">今日入库</span>
        <span class="welcome__chip-value app-num">{{ todayInbound }}</span>
      </div>
      <div class="welcome__chip">
        <span class="welcome__chip-label">今日完成检验</span>
        <span class="welcome__chip-value app-num">{{ todayChecked }}</span>
      </div>
    </div>
  </section>
</template>
 
<script setup>
import { ref, computed, onMounted } from 'vue'
import dayjs from 'dayjs'
import { qualityInspectionCount, orderCount } from '@/api/viewIndex'
 
const props = defineProps({
  userName: { type: String, default: '' },
  roleName: { type: String, default: '' },
  deptName: { type: String, default: '' },
  todoCount: { type: Number, default: 0 },
  todayInbound: { type: [Number, String], default: 0 }
})
 
const todayChecked = ref(0)
const pendingOrders = ref(0)
 
const greeting = computed(() => {
  const h = dayjs().hour()
  if (h < 6) return '夜深了'
  if (h < 12) return '早上好'
  if (h < 14) return '中午好'
  if (h < 18) return '下午好'
  return '晚上好'
})
 
const weekMap = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
const dateText = computed(() => {
  const d = dayjs()
  return `${d.format('YYYY年MM月DD日')} ${weekMap[d.day()]}`
})
 
onMounted(() => {
  qualityInspectionCount().then((res) => {
    todayChecked.value = (res.data || {}).todayCompletedCount || 0
  }).catch(() => {})
  orderCount().then((res) => {
    const item = (res.data || []).find((i) => i.name === '待生产订单数')
    pendingOrders.value = item ? Number(item.value) || 0 : 0
  }).catch(() => {})
})
</script>
 
<style scoped>
.welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 24px;
}
 
.welcome__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--app-text);
}
 
.welcome__meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--app-text-tertiary);
}
 
.welcome__sep {
  margin: 0 10px;
  color: var(--app-border);
}
 
.welcome__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
 
.welcome__chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 96px;
  padding: 10px 16px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface-hover);
}
 
.welcome__chip-label {
  font-size: 12px;
  color: var(--app-text-tertiary);
}
 
.welcome__chip-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--app-text);
}
</style>