diff --git a/src/components.d.ts b/src/components.d.ts index d58ef46..2da205c 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -14,7 +14,6 @@ declare module 'vue' { ElOption: typeof import('element-plus/es')['ElOption'] ElPopover: typeof import('element-plus/es')['ElPopover'] ElSelect: typeof import('element-plus/es')['ElSelect'] - ElTag: typeof import('element-plus/es')['ElTag'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTree: typeof import('element-plus/es')['ElTree'] ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect'] diff --git a/src/store/modules/chart.ts b/src/store/modules/chart.ts index ef595c1..e24493b 100644 --- a/src/store/modules/chart.ts +++ b/src/store/modules/chart.ts @@ -28,8 +28,11 @@ export const useChartStore = defineStore('chart', { ...this.chartObject, ...data }; - const res = await getlStatisticChart(pramas); - return res; + getlStatisticChart(pramas).then(res => { + if (res) return res + }).catch(() => { + return false + }).finally(() => {}) } } }); diff --git a/src/views/Main/DailyPatrolCard/index.vue b/src/views/Main/DailyPatrolCard/index.vue index 9be6d69..9a06a5c 100644 --- a/src/views/Main/DailyPatrolCard/index.vue +++ b/src/views/Main/DailyPatrolCard/index.vue @@ -38,7 +38,7 @@ const getChartData = async () => { startTime: '', group: 'K6' }; - const data = await chartStore.initStatisticChart(pramas); + const data: any = await chartStore.initStatisticChart(pramas); if (data?.yaxis?.length) { let newArr = data.yaxis.flatMap((v: any) => v.series); newArr?.forEach((item: any) => { @@ -54,6 +54,30 @@ const getChartData = async () => { // .reduce((acc: any, cur: any) => { // return acc + cur; // }, 0); + } else { + // 默认数据 + dailyData.value = [ + { + name: '一般', + value: 0, + unit: '' + }, + { + name: '较大', + value: 0, + unit: '' + }, + { + name: '重大', + value: 0, + unit: '' + }, + { + name: '紧急', + value: 0, + unit: '' + } + ]; } await initChart(); }; diff --git a/src/views/Main/ProjectCountCard/index.vue b/src/views/Main/ProjectCountCard/index.vue index 49a91af..d304c7d 100644 --- a/src/views/Main/ProjectCountCard/index.vue +++ b/src/views/Main/ProjectCountCard/index.vue @@ -23,14 +23,14 @@ const handleResize = () => { const projectCount = ref(0); const projectData: any = ref([]); const getChartData = async () => { - projectCount.value = 0 + projectCount.value = 0; projectData.value = []; const pramas = { endTime: '', startTime: '', group: 'K1' }; - const data = await chartStore.initStatisticChart(pramas); + const data: any = await chartStore.initStatisticChart(pramas); if (data?.yaxis?.length) { let newArr = data.yaxis.flatMap((v: any) => v.series); newArr?.forEach((item: any) => { @@ -41,8 +41,27 @@ const getChartData = async () => { }); projectCount.value += Number(item.sum || 0); }); + } else { + // 默认数据 + projectData.value = [ + { + name: '水库', + value: 0, + unit: '座' + }, + { + name: '水闸', + value: 0, + unit: '座' + }, + { + name: '堤防', + value: 0, + unit: '段' + } + ]; } - await initChart() + await initChart(); }; const initChart = () => { if (!chartRef.value) return; diff --git a/src/views/Main/RiskInspectionCard/index.vue b/src/views/Main/RiskInspectionCard/index.vue index 1666de2..57a3b28 100644 --- a/src/views/Main/RiskInspectionCard/index.vue +++ b/src/views/Main/RiskInspectionCard/index.vue @@ -49,7 +49,7 @@ const getChartData = async () => { startTime: '', group: 'K5' }; - const data = await chartStore.initStatisticChart(pramas); + const data: any = await chartStore.initStatisticChart(pramas); if (data?.yaxis?.length) { let newArr = data.yaxis.flatMap((v: any) => v.series); newArr?.forEach((item: any) => { @@ -69,6 +69,32 @@ const getChartData = async () => { taskCount.value += Number(item.sum) || 0; } }); + } else { + // 默认数据 + problemData.value = [ + { + name: '问题数', + value: 0, + unit: '' + }, + { + name: '数量', + value: 0, + unit: '' + } + ]; + taskData.value = [ + { + name: '任务数', + value: 0, + unit: '' + }, + { + name: '已完成', + value: 0, + unit: '' + } + ]; } initChart(); }; @@ -238,7 +264,7 @@ const initChart = () => { const taskNum = taskData.value.find((item: any) => item.name === '任务数')?.value; const accomplishNum = taskData.value.find((item: any) => item.name === '已完成')?.value; // 占比率 - const li_qu_count: any = Number(accomplishNum) / Number(taskNum); + const li_qu_count: any = taskNum ? Number(accomplishNum) / Number(taskNum) : 0; const titleStyle = { fontSize: 32, diff --git a/vite.config.ts b/vite.config.ts index efc55d0..f55f5d2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -85,12 +85,12 @@ export default defineConfig(({ mode }) => { changeOrigin: true, rewrite: (path) => path.replace(/^\/api\/iserver/, '/iserver') }, - '/api/run': { - // target: "http://shuili.product.dev.com:30115/", - target: 'http://172.16.34.80:18082', - changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, '/tianhui-admin-web') - }, + // '/api/run': { + // // target: "http://shuili.product.dev.com:30115/", + // target: 'http://172.16.34.80:18082', + // changeOrigin: true, + // rewrite: (path) => path.replace(/^\/api/, '/tianhui-admin-web') + // }, '/api': { target: 'http://shuili.product.dev.com:30115', // 'http://172.16.34.59:18083' changeOrigin: true,