Commit 16670525 authored by hubaoshan's avatar hubaoshan

页面的token Bug

parent b074febb
...@@ -53,8 +53,10 @@ function detail(row) { ...@@ -53,8 +53,10 @@ function detail(row) {
detailOpen.value = true detailOpen.value = true
} }
getData() // getData()
if(localStorage.getItem('AIToken')){
getData()
}
function getData() { function getData() {
const item = reactive({ const item = reactive({
page: Page.page, page: Page.page,
...@@ -87,15 +89,7 @@ watch( ...@@ -87,15 +89,7 @@ watch(
getDataNew(params.value) getDataNew(params.value)
} }
) )
watch(
() => props.searchData,
(newData) => {
console.log('ppppppppppp',props.searchData)
if(props.searchData.includes(1)){
getData()
}
},{ immediate: true }
) // TODO 等待后续优化
function getDataNew(item) { function getDataNew(item) {
getListNewData(item).then(res => { getListNewData(item).then(res => {
...@@ -104,6 +98,9 @@ function getDataNew(item) { ...@@ -104,6 +98,9 @@ function getDataNew(item) {
Page.rows = res.pageSize Page.rows = res.pageSize
}) })
} }
defineExpose({
getData
});
</script> </script>
<template> <template>
......
...@@ -17,7 +17,7 @@ import {useRoute} from "vue-router"; ...@@ -17,7 +17,7 @@ import {useRoute} from "vue-router";
const options = ref([]); const options = ref([]);
const enterpriseId = ref(); const enterpriseId = ref();
const props = {multiple: true, emitPath: false} const props = {multiple: true, emitPath: false}
const dynamicComponent = ref(ExtinguisherNewDataPage);
// 初始化选中的标签页 // 初始化选中的标签页
onMounted(() => { onMounted(() => {
...@@ -26,6 +26,13 @@ onMounted(() => { ...@@ -26,6 +26,13 @@ onMounted(() => {
selectedBtn.value = topBtn.value[0].id; selectedBtn.value = topBtn.value[0].id;
getSupplys() getSupplys()
}); });
const childComponentRef = ref(null);
const getData = () => {
if (childComponentRef.value && childComponentRef.value.getData) {
console.log('能不能成功啊')
childComponentRef.value.getData(); // 调用子组件的 getData 方法
}
};
const {proxy} = getCurrentInstance(); const {proxy} = getCurrentInstance();
// 列表 // 列表
const topBtn = ref([ const topBtn = ref([
...@@ -100,11 +107,11 @@ const search = () => { ...@@ -100,11 +107,11 @@ const search = () => {
console.log('查询:', item); console.log('查询:', item);
} }
function getNumber() { function getNumber() {
getAlarmNumData().then(res => { getAlarmNumData().then(res => {
console.log('123123123123-----------', res.data) console.log('123123123123-----------', res.data)
alarmNum.value = res.data alarmNum.value = res.data
iop.value = res.data
}) })
} }
...@@ -230,45 +237,24 @@ function getSupplys() { ...@@ -230,45 +237,24 @@ function getSupplys() {
} }
const route = useRoute() const route = useRoute()
const number = ref(0)
watch( watch(
() => route.path, // 只监听路径变化 () => route.path, // 只监听路径变化
() => { () => {
if(route.path === '/AIStation/Extinguisher') { if(route.path === '/AIStation/Extinguisher') {
// 路由变化,执行相应操作 // 路由变化,执行相应操作
handleGetAIToken(); handleGetAIToken();
number.value = 1 setTimeout(() => {
console.log('11111ppppppppppppp1',number.value) if(localStorage.getItem('AIToken')){
getNumber() getNumber()
getData()
}
}, 500);
console.log('route.path', route.path) console.log('route.path', route.path)
} }
}, },
{ immediate: true } // 只在路径变化时触发 { immediate: true } // 只在路径变化时触发
) )
watch(
() => number.value,
() => {
console.log('0000000000000', number.value);
if (number.value === 1) {
console.log(']]]]]]]]]]]]]]]]]]]]]]');
searchData.value.push(1);
console.log('searchData.value', searchData.value)
}
},
{ immediate: true }
);
function ChildMethod() {
if (dynamicComponent) {
console.log('selectedComponent.value', dynamicComponent.value);
if (typeof dynamicComponent.value.getData === 'function') {
console.log('子组件方法存在,开始调用...');
dynamicComponent.value.getData();
} else {
console.error('子组件方法不存在');
}
}
}
</script> </script>
<template> <template>
<div class="app-content"> <div class="app-content">
...@@ -330,7 +316,7 @@ function ChildMethod() { ...@@ -330,7 +316,7 @@ function ChildMethod() {
> >
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<component :is="selectedComponent" :queryParams='childParams' :search-data="searchData" ></component> <component :is="selectedComponent" ref="childComponentRef" :queryParams='childParams' :search-data="searchData" ></component>
</div> </div>
</div> </div>
......
...@@ -49,11 +49,18 @@ function getDataByParams(){ ...@@ -49,11 +49,18 @@ function getDataByParams(){
} }
//子组件接收父组件传递过来的值 //子组件接收父组件传递过来的值
const props = defineProps({ const props = defineProps({
searchData: {
type: Array,
required: true
},
queryParams: { queryParams: {
type: Object, type: Object,
required: true required: true
} }
}); });
if(localStorage.getItem('AIToken')){
getData()
}
watch( watch(
() => props.queryParams, () => props.queryParams,
(newData) => { (newData) => {
...@@ -63,7 +70,8 @@ watch( ...@@ -63,7 +70,8 @@ watch(
console.log('值ooo',props.queryParams) console.log('值ooo',props.queryParams)
} }
) )
getData()
function getData(){ function getData(){
const item = reactive({ const item = reactive({
page: Page.page, page: Page.page,
...@@ -154,6 +162,9 @@ function getSupplys() { ...@@ -154,6 +162,9 @@ function getSupplys() {
} }
getSupplys() getSupplys()
defineExpose({
getData
});
</script> </script>
<template> <template>
......
<script setup> <script setup>
import {getCurrentInstance, onMounted, reactive, ref} from 'vue' import {getCurrentInstance, onMounted, reactive, ref, watch} from 'vue'
import MoveMonitorNewDataPage from './MoveMonitorNewDataPage.vue' // 导入组件 import MoveMonitorNewDataPage from './MoveMonitorNewDataPage.vue' // 导入组件
import MoveMonitorHistoryPage from './MoveMonitorHistoryPage.vue' // 导入组件 import MoveMonitorHistoryPage from './MoveMonitorHistoryPage.vue' // 导入组件
import MoveMonitorAlarmPage from './MoveMonitorAlarmPage.vue' // 导入组件 import MoveMonitorAlarmPage from './MoveMonitorAlarmPage.vue' // 导入组件
...@@ -11,12 +11,21 @@ import { ...@@ -11,12 +11,21 @@ import {
exportMoveMonitorHistoryData, exportMoveMonitorHistoryData,
exportMoveMonitorAlarmData, exportMoveMonitorAlarmData,
} from "../../../api/AIStation/MoveMonitor.js"; } from "../../../api/AIStation/MoveMonitor.js";
import {useRoute} from "vue-router";
import {handleGetAIToken} from "../AItoken.js";
const options = ref([]); const options = ref([]);
const enterpriseId = ref(); const enterpriseId = ref();
const props = {multiple: true, emitPath: false} const props = {multiple: true, emitPath: false}
const {proxy} = getCurrentInstance(); const {proxy} = getCurrentInstance();
const childComponentRef = ref(null);
const getData = () => {
if (childComponentRef.value && childComponentRef.value.getData) {
console.log('能不能成功啊')
childComponentRef.value.getData(); // 调用子组件的 getData 方法
}
};
// 列表 // 列表
const topBtn = ref([ const topBtn = ref([
{id: 1, name: '最新数据', component: MoveMonitorNewDataPage}, {id: 1, name: '最新数据', component: MoveMonitorNewDataPage},
...@@ -36,7 +45,7 @@ const activeName = ref(MoveMonitorNewDataPage); ...@@ -36,7 +45,7 @@ const activeName = ref(MoveMonitorNewDataPage);
const alarmNum = ref(0); const alarmNum = ref(0);
// 查询结果数据 // 查询结果数据
const searchData = ref({}); const searchData = ref([]);
// 点击标签页切换事件 // 点击标签页切换事件
const handleTabClick = (tab, event) => { const handleTabClick = (tab, event) => {
console.log('id', tab) console.log('id', tab)
...@@ -93,7 +102,6 @@ const search = () => { ...@@ -93,7 +102,6 @@ const search = () => {
} }
console.log('查询:', item); console.log('查询:', item);
}; };
getNumber()
function getNumber() { function getNumber() {
getMoveAlarmNumber().then(res => { getMoveAlarmNumber().then(res => {
...@@ -227,6 +235,25 @@ function getSupplys() { ...@@ -227,6 +235,25 @@ function getSupplys() {
getSupplys(); getSupplys();
const route = useRoute()
const number = ref(0)
watch(
() => route.path, // 只监听路径变化
() => {
if(route.path === '/AIStation/MoveMonitor') {
// 路由变化,执行相应操作
handleGetAIToken();
setTimeout(() => {
if(localStorage.getItem('AIToken')){
getNumber()
getData()
}
}, 500);
console.log('route.path', route.path)
}
},
{ immediate: true } // 只在路径变化时触发
)
</script> </script>
<template> <template>
<div class="app-content"> <div class="app-content">
...@@ -288,7 +315,7 @@ getSupplys(); ...@@ -288,7 +315,7 @@ getSupplys();
> >
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<component :is="selectedComponent" :queryParams='childParams'></component> <component :is="selectedComponent" ref="childComponentRef" :queryParams='childParams' :search-data="searchData"></component>
</div> </div>
</div> </div>
......
...@@ -36,12 +36,18 @@ function detail(row) { ...@@ -36,12 +36,18 @@ function detail(row) {
//子组件接收父组件传递过来的值 //子组件接收父组件传递过来的值
const props = defineProps({ const props = defineProps({
searchData:{
type: Array,
required: true
},
queryParams: { queryParams: {
type: Object, type: Object,
required: true required: true
} }
}); });
if(localStorage.getItem('AIToken')){
getData()
}
watch( watch(
() => props.queryParams, () => props.queryParams,
(newData) => { (newData) => {
...@@ -55,7 +61,6 @@ watch( ...@@ -55,7 +61,6 @@ watch(
} }
) )
getData()
function getData() { function getData() {
const item = reactive({ const item = reactive({
...@@ -160,6 +165,9 @@ function getSupplys() { ...@@ -160,6 +165,9 @@ function getSupplys() {
} }
getSupplys() getSupplys()
defineExpose({
getData
});
</script> </script>
<template> <template>
......
<script setup> <script setup>
import {getCurrentInstance, onMounted, reactive, ref} from 'vue' import {getCurrentInstance, onMounted, reactive, ref, watch} from 'vue'
import PipelineTempNewDataPage from './PipelineTempNewDataPage.vue' // 导入组件 import PipelineTempNewDataPage from './PipelineTempNewDataPage.vue' // 导入组件
import PipelineTempHistoryPage from './PipelineTempHistoryPage.vue' // 导入组件 import PipelineTempHistoryPage from './PipelineTempHistoryPage.vue' // 导入组件
import PipelineTempAlarmPage from './PipelineTempAlarmPage.vue' // 导入组件 import PipelineTempAlarmPage from './PipelineTempAlarmPage.vue' // 导入组件
...@@ -12,6 +12,8 @@ import { ...@@ -12,6 +12,8 @@ import {
exportPipelineTempHistoryData, exportPipelineTempHistoryData,
exportPipelineTempAlarmData exportPipelineTempAlarmData
} from "../../../api/AIStation/PipelineTemp.js"; } from "../../../api/AIStation/PipelineTemp.js";
import {useRoute} from "vue-router";
import {handleGetAIToken} from "../AItoken.js";
const {proxy} = getCurrentInstance(); const {proxy} = getCurrentInstance();
...@@ -22,8 +24,13 @@ const topBtn = ref([ ...@@ -22,8 +24,13 @@ const topBtn = ref([
{id: 3, name: '报警信息', component: PipelineTempAlarmPage} {id: 3, name: '报警信息', component: PipelineTempAlarmPage}
]); ]);
const selectedBtn = ref(null); const selectedBtn = ref(null);
const dateRange = ref([]) const childComponentRef = ref(null);
const optionsList = ref([]) const getData = () => {
if (childComponentRef.value && childComponentRef.value.getData) {
console.log('能不能成功啊')
childComponentRef.value.getData(); // 调用子组件的 getData 方法
}
};
// 默认显示的组件页面 // 默认显示的组件页面
const selectedComponent = ref(PipelineTempNewDataPage); const selectedComponent = ref(PipelineTempNewDataPage);
...@@ -71,7 +78,7 @@ const queryParams = reactive({ ...@@ -71,7 +78,7 @@ const queryParams = reactive({
endTime: '', endTime: '',
}); });
const Page = reactive({total: 0, rows: 20, page: 1}); const Page = reactive({total: 0, rows: 20, page: 1});
const searchData = ref({}); const searchData = ref([]);
const thermalAlarmTypeList = [ const thermalAlarmTypeList = [
{ {
label: '定温报警', label: '定温报警',
...@@ -119,7 +126,6 @@ const search = () => { ...@@ -119,7 +126,6 @@ const search = () => {
} }
console.log('查询:', item); console.log('查询:', item);
}; };
getNumber()
function getNumber() { function getNumber() {
getPipAlarmNumber().then(res => { getPipAlarmNumber().then(res => {
...@@ -254,6 +260,26 @@ function getSupplys() { ...@@ -254,6 +260,26 @@ function getSupplys() {
getSupplys(); getSupplys();
const route = useRoute()
const number = ref(0)
watch(
() => route.path, // 只监听路径变化
() => {
if(route.path === '/AIStation/PipelineTemp') {
// 路由变化,执行相应操作
handleGetAIToken();
setTimeout(() => {
if(localStorage.getItem('AIToken')){
getNumber()
getData()
}
}, 500);
console.log('route.path', route.path)
}
},
{ immediate: true } // 只在路径变化时触发
)
</script> </script>
<template> <template>
<div class="app-content"> <div class="app-content">
...@@ -320,7 +346,7 @@ getSupplys(); ...@@ -320,7 +346,7 @@ getSupplys();
> >
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<component :is="selectedComponent" :queryParams='childParams'></component> <component :is="selectedComponent" ref="childComponentRef" :queryParams='childParams' :search-data="searchData"></component>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -44,12 +44,18 @@ function detail(row) { ...@@ -44,12 +44,18 @@ function detail(row) {
//子组件接收父组件传递过来的值 //子组件接收父组件传递过来的值
const props = defineProps({ const props = defineProps({
searchData:{
type: Array,
required: true
},
queryParams: { queryParams: {
type: Object, type: Object,
required: true required: true
} }
}); });
if(localStorage.getItem('AIToken')){
getData()
}
watch( watch(
() => props.queryParams, () => props.queryParams,
(newData) => { (newData) => {
...@@ -59,7 +65,6 @@ watch( ...@@ -59,7 +65,6 @@ watch(
console.log('值ooo', props.queryParams) console.log('值ooo', props.queryParams)
} }
) )
getData()
function getData() { function getData() {
const item = reactive({ const item = reactive({
...@@ -160,6 +165,9 @@ function getSupplys() { ...@@ -160,6 +165,9 @@ function getSupplys() {
} }
getSupplys() getSupplys()
defineExpose({
getData
});
</script> </script>
<template> <template>
......
<script setup> <script setup>
import {getCurrentInstance, onMounted, reactive, ref} from 'vue' import {getCurrentInstance, onMounted, reactive, ref, watch} from 'vue'
import TransTempNewDataPage from './TransTempNewDataPage.vue' // 导入组件 import TransTempNewDataPage from './TransTempNewDataPage.vue' // 导入组件
import TransTempHistoryPage from './TransTempHistoryPage.vue' // 导入组件 import TransTempHistoryPage from './TransTempHistoryPage.vue' // 导入组件
import TransTempAlarmPage from './TransTempAlarmPage.vue' // 导入组件 import TransTempAlarmPage from './TransTempAlarmPage.vue' // 导入组件
...@@ -21,6 +21,8 @@ import { ...@@ -21,6 +21,8 @@ import {
exportTransTempAlarmData exportTransTempAlarmData
} from "../../../api/AIStation/TransTemp.js"; } from "../../../api/AIStation/TransTemp.js";
import {getPipAlarmNumber} from "../../../api/AIStation/PipelineTemp.js"; import {getPipAlarmNumber} from "../../../api/AIStation/PipelineTemp.js";
import {useRoute} from "vue-router";
import {handleGetAIToken} from "../AItoken.js";
const {proxy} = getCurrentInstance(); const {proxy} = getCurrentInstance();
// 列表 // 列表
...@@ -30,7 +32,13 @@ const topBtn = ref([ ...@@ -30,7 +32,13 @@ const topBtn = ref([
{id: 3, name: '报警信息', component: TransTempAlarmPage} {id: 3, name: '报警信息', component: TransTempAlarmPage}
]); ]);
const selectedBtn = ref(null); const selectedBtn = ref(null);
const optionsList = ref([]) const childComponentRef = ref(null);
const getData = () => {
if (childComponentRef.value && childComponentRef.value.getData) {
console.log('能不能成功啊')
childComponentRef.value.getData(); // 调用子组件的 getData 方法
}
};
const childParams = ref({}) const childParams = ref({})
// 默认显示的组件页面 // 默认显示的组件页面
...@@ -106,7 +114,7 @@ const queryParams = reactive({ ...@@ -106,7 +114,7 @@ const queryParams = reactive({
}); });
const Page = reactive({total: 0, rows: 20, page: 1}); const Page = reactive({total: 0, rows: 20, page: 1});
const searchData = ref({}); const searchData = ref([]);
const search = () => { const search = () => {
const item = { const item = {
page: Page.page, page: Page.page,
...@@ -126,7 +134,6 @@ const search = () => { ...@@ -126,7 +134,6 @@ const search = () => {
} }
console.log('查询:', item); console.log('查询:', item);
}; };
getNumber()
function getNumber() { function getNumber() {
getTransAlarmNumber().then(res => { getTransAlarmNumber().then(res => {
...@@ -261,7 +268,27 @@ function getSupplys() { ...@@ -261,7 +268,27 @@ function getSupplys() {
} }
getSupplys(); getSupplys();
getNumber()
const route = useRoute()
const number = ref(0)
watch(
() => route.path, // 只监听路径变化
() => {
if(route.path === '/AIStation/TransTemp') {
// 路由变化,执行相应操作
handleGetAIToken();
setTimeout(() => {
if(localStorage.getItem('AIToken')){
getNumber()
getData()
}
}, 500);
console.log('route.path', route.path)
}
},
{ immediate: true } // 只在路径变化时触发
)
</script> </script>
<template> <template>
<div class="app-content"> <div class="app-content">
...@@ -328,7 +355,7 @@ getSupplys(); ...@@ -328,7 +355,7 @@ getSupplys();
> >
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<component :is="selectedComponent" :queryParams='childParams'></component> <component :is="selectedComponent" ref="childComponentRef" :queryParams='childParams' :search-data="searchData"></component>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment