diff --git a/src/store/modules/program.ts b/src/store/modules/program.ts index 035239e..d8b465d 100644 --- a/src/store/modules/program.ts +++ b/src/store/modules/program.ts @@ -4,12 +4,14 @@ interface ProgramState { programID: string; personProgramTemp: any; totalArr: any; + details: any; } const useProgram = defineStore('program', { state: (): ProgramState => ({ programID: '', personProgramTemp: [], - totalArr: [] + totalArr: [], + details: null }), actions: { @@ -22,6 +24,9 @@ const useProgram = defineStore('program', { }, updateTotalArr(arr: any) { this.totalArr = arr; + }, + updateDetails(a: any) { + this.details = a; } } }); diff --git a/src/views/business/inverter/index.vue b/src/views/business/inverter/index.vue index 5b30f75..ff82096 100644 --- a/src/views/business/inverter/index.vue +++ b/src/views/business/inverter/index.vue @@ -1803,11 +1803,10 @@ const handleCheckDetail = async (row?: InverterVO) => { chart6Value: chart6Value.value, chart6Index: chart6Index.value }; + localStorage.setItem('detail', JSON.stringify(detail)); + programState.updateDetails(detail); router.push({ - path: '/historyDetail', - query: { - detail: JSON.stringify(detail) - } + path: '/historyDetail' }); // await nextTick(() => { // initChart(chart1Value.value, chart1Index.value, myChart1.value, '直流电流参数', 25, 'A'); diff --git a/src/views/historyDetail/historyDetail.vue b/src/views/historyDetail/historyDetail.vue index 13b94bc..d3ae2d2 100644 --- a/src/views/historyDetail/historyDetail.vue +++ b/src/views/historyDetail/historyDetail.vue @@ -2,9 +2,11 @@ import moment from 'moment'; import * as echarts from 'echarts'; import { ref } from 'vue'; +import { useProgram } from '@/store/modules/program'; const route = useRoute(); const router = useRouter(); +const useStore = useProgram(); const detail = ref(); const activeName = ref(); const myChart1 = ref(null); @@ -15,7 +17,6 @@ const myChart5 = ref(null); const myChart6 = ref(null); function dealData() { - console.info(detail.value); detail.value = { ...detail.value, dataTimestamp: moment(Number(detail.value.dataTimestamp)).format('YYYY-MM-DD HH:mm:ss'), @@ -163,8 +164,11 @@ watch( ); onBeforeMount(() => { - localStorage.setItem('detail', route.query.detail); - detail.value = JSON.parse(localStorage.getItem('detail')); + if (!JSON.parse(localStorage.getItem('detail'))) { + detail.value = useStore.details; + } else { + detail.value = JSON.parse(localStorage.getItem('detail')); + } dealData(); activeName.value = 'first'; });