Browse Source

fix: 图表增加默认数据

feature-v1.0.0
ruancuihong 1 month ago
parent
commit
84fc2d17ab
  1. 1
      src/components.d.ts
  2. 7
      src/store/modules/chart.ts
  3. 26
      src/views/Main/DailyPatrolCard/index.vue
  4. 25
      src/views/Main/ProjectCountCard/index.vue
  5. 30
      src/views/Main/RiskInspectionCard/index.vue
  6. 12
      vite.config.ts

1
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']

7
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(() => {})
}
}
});

26
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();
};

25
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;

30
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,

12
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,

Loading…
Cancel
Save