diff --git a/src/api/dashboard/index.ts b/src/api/dashboard/index.ts index a7125b41..adc744c3 100644 --- a/src/api/dashboard/index.ts +++ b/src/api/dashboard/index.ts @@ -30,6 +30,18 @@ getPlan: async () => { getDevice: async () => { return await request.get({ url: `/mes/dashboard/getDevice` }) }, + getMold: async () => { + return await request.get({ url: `/mes/dashboard/getMold` }) + }, + getTodoList: async () => { + return await request.get({ url: `/mes/dashboard/getTodoList` }) + }, + getDeviceOperationalStatus: async () => { + return await request.get({ url: `/iot/device/getDeviceOperationalStatus` }) + }, + getDeviceRepairLineOptions: async () => { + return await request.get({ url: `/mes/dashboard/getDeviceRepairLineOptions` }) + }, } diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 88a4eda2..b03ffd40 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -453,7 +453,7 @@ export default { basedata: { product: { category:{ -name:'分类名称', + name:'分类名称', } }, diff --git a/src/views/Home/Index.vue b/src/views/Home/Index.vue index d53b0433..737a8f15 100644 --- a/src/views/Home/Index.vue +++ b/src/views/Home/Index.vue @@ -119,10 +119,10 @@ v-model="productionOverviewRange" type="daterange" unlink-panels value-format="Y
{{ item.name }}
-
任务编号:{{ item.id }}
-
任务类型:{{ item.type }}|优先级:{{ item.priority }}
-
计划时间:{{ item.planTime }}
-
责任部门:{{ item.owner }}
+
任务编号:{{ item.code }}
+
任务类型:{{ item.type }}
+
目标:{{ item.deviceName }}
+
创建时间:{{ formatDate(item.createTime) }}
@@ -155,7 +155,7 @@ v-model="productionOverviewRange" type="daterange" unlink-panels value-format="Y
模具
- +
{{ item.label }}
{{ item.value }}
@@ -174,30 +174,60 @@ v-model="deviceOverviewRange" type="daterange" unlink-panels value-format="YYYY- start-placeholder="开始日期" end-placeholder="结束日期" size="small" />
--> - - + +
-
{{ item.label }}
-
{{ item.value }}
+
总设备数
+
{{ formData?.totalDevices }}
- +
-
{{ item.label }}
-
{{ item.value }}
+
运行
+
{{ formData?.runningCount }}
+
+
+ +
+
待机中
+
{{ formData?.standbyCount }}
+
+
+ +
+
故障中
+
{{ formData?.faultCount }}
+
+
+ +
+
报警中
+
{{ formData?.warningCount }}
+
+
+ +
+
利用率
+
{{ formData?.utilizationRate }}
+
+
+ +
+
故障率
+
{{ formData?.faultRate }}
- + - + @@ -298,23 +328,16 @@ import type { Shortcut, ProductionOverview, ProductionProgressItem, - DeviceStatusSummary, - AlarmStatusSummary, DeviceOverview, - TodoTask + TodoTask, + DeviceOperationStatus } from './types' import { pieOptions, barOptions, - deviceRepairLineOptions, deviceCategoryPieOptions, deviceDistributionBarOptions, - productionOverviewMock, - productionProgressMock, - deviceStatusMock, - alarmStatusMock, deviceOverviewMock, - todoTasksMock } from './echarts-data' import { HomeApi } from '@/api/home/info' import { WeatherVO } from '@/api/home/info' @@ -330,28 +353,21 @@ const loading = ref(true) const avatar = userStore.getUser.avatar const username = userStore.getUser.nickname const pieOptionsData = reactive(pieOptions) as EChartsOption -const deviceRepairLineOptionsData = reactive( - deviceRepairLineOptions -) as EChartsOption + + + + const deviceCategoryPieOptionsData = reactive( deviceCategoryPieOptions ) as EChartsOption const deviceDistributionBarOptionsData = reactive( deviceDistributionBarOptions ) as EChartsOption -const productionOverview = ref(productionOverviewMock) + const productionOverviewRange = ref([]) const deviceOverview = ref(deviceOverviewMock) -const deviceOverviewRange = ref([]) -const productionProgressTab = ref('all') -const productionProgressList = ref() - -const todoTaskList = ref(todoTasksMock) -const deviceStatus = ref(deviceStatusMock) -const alarmStatus = ref(alarmStatusMock) -const filteredProductionProgressList = computed(() => { - return productionProgressList.value -}) + + const formatPercent = (value: number | undefined | null) => { if (value === null || value === undefined) return '0%' if (Number.isNaN(value)) return '0%' @@ -364,6 +380,8 @@ const productionOverviewCenter = ref([]) const plan = ref([]) +const todo = ref([]) + // const productionOverviewRight = computed(() => [ // { // key: 'attendanceCount', @@ -437,46 +455,7 @@ const deviceOverviewBottom = computed(() => [ value: 0 } ]) -// const deviceStatusCards = computed(() => [ -// { -// key: 'inactive', -// label: '非活动', -// value: deviceStatus.value.inactive, -// level: 'mini-danger' -// }, -// { -// key: 'active', -// label: '活动', -// value: deviceStatus.value.active, -// level: 'mini-normal' -// }, -// { -// key: 'total', -// label: '总数', -// value: deviceStatus.value.total, -// level: 'mini-total' -// } -// ]) -const alarmStatusCards = computed(() => [ - { - key: 'serious', - label: '严重', - value: alarmStatus.value.serious, - level: 'mini-danger' - }, - { - key: 'assignedToMe', - label: '分配给我', - value: alarmStatus.value.assignedToMe, - level: 'mini-normal' - }, - { - key: 'total', - label: '总数', - value: alarmStatus.value.total, - level: 'mini-total' - } -]) + const groupBySize = (list: T[], size: number) => { const result: T[][] = [] for (let i = 0; i < list.length; i += size) { @@ -485,7 +464,7 @@ const groupBySize = (list: T[], size: number) => { return result } -const todoTaskGroups = computed(() => groupBySize(todoTaskList.value, 4)) + // 获取统计数 let totalSate = reactive({ project: 0, @@ -499,7 +478,42 @@ const todayWeather = ref({} as WeatherVO) let weatherCity = "" const production = ref({} as DashboardProductVO) const productionProgressGroups = computed(() => groupBySize(plan.value, 3)) +const todoTaskGroups = computed(() => groupBySize(todo.value, 4)) const deviceStatusCards = ref([]) +const moldStatusCards = ref([]) +const formData = ref() +const deviceRepairLineOptions = ref({ + title: { + text: '设备维修数量统计', + left: 'center' + }, + tooltip: { + trigger: 'axis' + }, + grid: { + left: 40, + right: 20, + bottom: 30, + top: 60, + containLabel: true + }, + xAxis: { + type: 'category', + boundaryGap: false, + data: ['一月', '二月', '三月', '四月', '五月', '六月'] + }, + yAxis: { + type: 'value' + }, + series: [ + { + name: '维修数量', + type: 'line', + smooth: true, + data: [3, 5, 4, 6, 8, 7] + } + ] +}) /** 初始化 **/ onMounted(async () => { // 加载 @@ -513,6 +527,12 @@ onMounted(async () => { production.value = await DashboardApi.getProduction(productionOverviewRange) plan.value = await DashboardApi.getPlan() deviceStatusCards.value = await DashboardApi.getDevice() + moldStatusCards.value = await DashboardApi.getMold() + todo.value = await DashboardApi.getTodoList() + formData.value = await DashboardApi.getDeviceOperationalStatus() + const Options = await DashboardApi.getDeviceRepairLineOptions() + deviceRepairLineOptions.value.xAxis.data = Options.xaxis + deviceRepairLineOptions.value.series[0].data = Options.series productionOverviewLeft.value = production.value.taskItems productionOverviewCenter.value = production.value.planItems @@ -521,8 +541,10 @@ onMounted(async () => { const getPlanStatusLabel = (value: any) => { const v = value === '' || value === null || value === undefined ? undefined : String(value) if (v == '1') return '已排产' - if (v == '2') return '试产' - if (v == '3') return '量产' + if (v == '6') return '试产' + if (v == '2') return '量产' + if (v == '3') return '暂停' + if (v == '4') return '待入库' return '-' } const getPlanStatusTagType = (value: any) => { diff --git a/src/views/Home/types.ts b/src/views/Home/types.ts index f60b354c..375b8cc3 100644 --- a/src/views/Home/types.ts +++ b/src/views/Home/types.ts @@ -106,8 +106,19 @@ export type DeviceOverview = { export type TodoTask = { id: string name: string + code: string type: string - priority: string - planTime: string - owner: string + deviceName: string + createTime: Date +} + +export type DeviceOperationStatus = { + totalDevices: number + runningCount: number + standbyCount: number + faultCount: number + warningCount: number + utilizationRate: number + faultRate: number } +