|
|
|
|
@ -155,7 +155,7 @@
|
|
|
|
|
</ContentWrap>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref, onMounted, onUnmounted } from 'vue'
|
|
|
|
|
import { ref, onMounted, onUnmounted, computed } from 'vue'
|
|
|
|
|
import { debounce } from 'lodash-es'
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
import { CameraApi, CameraVO } from '@/api/logistics/camera'
|
|
|
|
|
@ -163,6 +163,9 @@ import { homeApi } from '@/api/logistics/home'
|
|
|
|
|
import Camera from '@/components/camera/camera.vue'
|
|
|
|
|
import { EChartsOption } from 'echarts'
|
|
|
|
|
import { StockApi } from '@/api/logistics/stock'
|
|
|
|
|
import { DICT_TYPE } from '@/utils/dict'
|
|
|
|
|
import { isHexColor } from '@/utils/color'
|
|
|
|
|
import { getAllInfoList } from '@/api/system/dict/dict.data'
|
|
|
|
|
import type { Shortcut } from './types'
|
|
|
|
|
|
|
|
|
|
// ----------------------------- 数据定义 -----------------------------
|
|
|
|
|
@ -196,6 +199,8 @@ let logTimer: NodeJS.Timeout | null = null
|
|
|
|
|
// 获取所有数据
|
|
|
|
|
const getAll = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 先加载 check_status 字典,保证图表渲染时颜色已就绪
|
|
|
|
|
await loadCheckStatusDict()
|
|
|
|
|
// 并行请求所有接口,避免串行等待
|
|
|
|
|
const [stats, laneStats, laneLine, stockStats, pieData] = await Promise.all([
|
|
|
|
|
homeApi.statistics(),
|
|
|
|
|
@ -237,7 +242,8 @@ const getAll = async () => {
|
|
|
|
|
type: series.type,
|
|
|
|
|
stack: series.stack,
|
|
|
|
|
itemStyle: {
|
|
|
|
|
color: series.color
|
|
|
|
|
// 颜色统一取自 check_status 字典,取不到时回退后端给的色
|
|
|
|
|
color: getStatusHex(series.name) || series.color
|
|
|
|
|
},
|
|
|
|
|
data: series.data
|
|
|
|
|
}))
|
|
|
|
|
@ -378,7 +384,43 @@ eventSource.onerror = (error) => {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const colorListHex = {'未盘点':'#ebc26e','盘点异常':'#ed6d6d','盘点正确':'#6cc238','人工核对正确':'#5061c2'};
|
|
|
|
|
/** Element Plus type → 十六进制色(与物流盘点页保持一致) */
|
|
|
|
|
const TYPE_TO_HEX: Record<string, string> = {
|
|
|
|
|
primary: '#409eff',
|
|
|
|
|
success: '#6cc238',
|
|
|
|
|
warning: '#ebc26e',
|
|
|
|
|
danger: '#ed6d6d',
|
|
|
|
|
info: '#909399'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** check_status 字典项(通过 /system/dict-data/typeAllInfo 获取,不依赖全局缓存) */
|
|
|
|
|
const checkStatusDict = ref<Array<{ label: string; colorType: string; cssClass: string }>>([])
|
|
|
|
|
const loadCheckStatusDict = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const list = (await getAllInfoList(DICT_TYPE.CHECK_STATUS)) || []
|
|
|
|
|
checkStatusDict.value = list.map((d: any) => ({
|
|
|
|
|
label: d.label,
|
|
|
|
|
colorType: d.colorType || '',
|
|
|
|
|
cssClass: d.cssClass || ''
|
|
|
|
|
}))
|
|
|
|
|
} catch {
|
|
|
|
|
checkStatusDict.value = []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 状态文案 → 十六进制色,来源为字典 check_status */
|
|
|
|
|
const statusHexMap = computed(() => {
|
|
|
|
|
const map = new Map<string, string>()
|
|
|
|
|
checkStatusDict.value.forEach((d) => {
|
|
|
|
|
const hex = isHexColor(d.cssClass) ? d.cssClass : TYPE_TO_HEX[d.colorType] || ''
|
|
|
|
|
if (hex) {
|
|
|
|
|
map.set(d.label, hex)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return map
|
|
|
|
|
})
|
|
|
|
|
const getStatusHex = (name?: string) => statusHexMap.value.get(name || '') || ''
|
|
|
|
|
|
|
|
|
|
// 盘点饼状图选项
|
|
|
|
|
const stockPieOptions = reactive({
|
|
|
|
|
animationDurationUpdate: 0,
|
|
|
|
|
@ -398,9 +440,8 @@ const stockPieOptions = reactive({
|
|
|
|
|
borderRadius: 10,
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
color: function (params) {
|
|
|
|
|
|
|
|
|
|
// 使用 params.dataIndex 获取当前数据项的索引
|
|
|
|
|
return colorListHex[params.name];
|
|
|
|
|
// 颜色统一取自 check_status 字典
|
|
|
|
|
return getStatusHex(params.name) || '#c8c9cc'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
label: {
|
|
|
|
|
|