diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHarmfulData.vue b/src/views/dataManage/deviceData/listHarmfulData.vue index 03668c8..b1b0ac0 100644 --- a/src/views/dataManage/deviceData/listHarmfulData.vue +++ b/src/views/dataManage/deviceData/listHarmfulData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHarmfulData, batchExportHarmfulData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHarmfulData', @@ -168,31 +169,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '3' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHarmfulData.vue b/src/views/dataManage/deviceData/listHarmfulData.vue index 03668c8..b1b0ac0 100644 --- a/src/views/dataManage/deviceData/listHarmfulData.vue +++ b/src/views/dataManage/deviceData/listHarmfulData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHarmfulData, batchExportHarmfulData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHarmfulData', @@ -168,31 +169,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '3' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHyetometerData.vue b/src/views/dataManage/deviceData/listHyetometerData.vue index 516a91a..4f07328 100644 --- a/src/views/dataManage/deviceData/listHyetometerData.vue +++ b/src/views/dataManage/deviceData/listHyetometerData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHyetoData, batchExportHyetoData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHyetometerData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '8' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHarmfulData.vue b/src/views/dataManage/deviceData/listHarmfulData.vue index 03668c8..b1b0ac0 100644 --- a/src/views/dataManage/deviceData/listHarmfulData.vue +++ b/src/views/dataManage/deviceData/listHarmfulData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHarmfulData, batchExportHarmfulData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHarmfulData', @@ -168,31 +169,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '3' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHyetometerData.vue b/src/views/dataManage/deviceData/listHyetometerData.vue index 516a91a..4f07328 100644 --- a/src/views/dataManage/deviceData/listHyetometerData.vue +++ b/src/views/dataManage/deviceData/listHyetometerData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHyetoData, batchExportHyetoData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHyetometerData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '8' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listLiquidData.vue b/src/views/dataManage/deviceData/listLiquidData.vue index 9bf5307..88332f1 100644 --- a/src/views/dataManage/deviceData/listLiquidData.vue +++ b/src/views/dataManage/deviceData/listLiquidData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getLiquidData, batchExportLiquidData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListLiquidData', @@ -150,31 +151,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '2' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHarmfulData.vue b/src/views/dataManage/deviceData/listHarmfulData.vue index 03668c8..b1b0ac0 100644 --- a/src/views/dataManage/deviceData/listHarmfulData.vue +++ b/src/views/dataManage/deviceData/listHarmfulData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHarmfulData, batchExportHarmfulData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHarmfulData', @@ -168,31 +169,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '3' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHyetometerData.vue b/src/views/dataManage/deviceData/listHyetometerData.vue index 516a91a..4f07328 100644 --- a/src/views/dataManage/deviceData/listHyetometerData.vue +++ b/src/views/dataManage/deviceData/listHyetometerData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHyetoData, batchExportHyetoData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHyetometerData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '8' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listLiquidData.vue b/src/views/dataManage/deviceData/listLiquidData.vue index 9bf5307..88332f1 100644 --- a/src/views/dataManage/deviceData/listLiquidData.vue +++ b/src/views/dataManage/deviceData/listLiquidData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getLiquidData, batchExportLiquidData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListLiquidData', @@ -150,31 +151,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '2' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listMeterData.vue b/src/views/dataManage/deviceData/listMeterData.vue index 8c0a30a..cce008c 100644 --- a/src/views/dataManage/deviceData/listMeterData.vue +++ b/src/views/dataManage/deviceData/listMeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getMeterData, batchExportMeterData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListMeterData', @@ -184,31 +185,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '10' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHarmfulData.vue b/src/views/dataManage/deviceData/listHarmfulData.vue index 03668c8..b1b0ac0 100644 --- a/src/views/dataManage/deviceData/listHarmfulData.vue +++ b/src/views/dataManage/deviceData/listHarmfulData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHarmfulData, batchExportHarmfulData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHarmfulData', @@ -168,31 +169,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '3' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHyetometerData.vue b/src/views/dataManage/deviceData/listHyetometerData.vue index 516a91a..4f07328 100644 --- a/src/views/dataManage/deviceData/listHyetometerData.vue +++ b/src/views/dataManage/deviceData/listHyetometerData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHyetoData, batchExportHyetoData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHyetometerData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '8' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listLiquidData.vue b/src/views/dataManage/deviceData/listLiquidData.vue index 9bf5307..88332f1 100644 --- a/src/views/dataManage/deviceData/listLiquidData.vue +++ b/src/views/dataManage/deviceData/listLiquidData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getLiquidData, batchExportLiquidData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListLiquidData', @@ -150,31 +151,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '2' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listMeterData.vue b/src/views/dataManage/deviceData/listMeterData.vue index 8c0a30a..cce008c 100644 --- a/src/views/dataManage/deviceData/listMeterData.vue +++ b/src/views/dataManage/deviceData/listMeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getMeterData, batchExportMeterData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListMeterData', @@ -184,31 +185,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '10' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listTempData.vue b/src/views/dataManage/deviceData/listTempData.vue index 1707de6..5c2626c 100644 --- a/src/views/dataManage/deviceData/listTempData.vue +++ b/src/views/dataManage/deviceData/listTempData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getTempData, batchExportTempData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListTempData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '5' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHarmfulData.vue b/src/views/dataManage/deviceData/listHarmfulData.vue index 03668c8..b1b0ac0 100644 --- a/src/views/dataManage/deviceData/listHarmfulData.vue +++ b/src/views/dataManage/deviceData/listHarmfulData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHarmfulData, batchExportHarmfulData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHarmfulData', @@ -168,31 +169,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '3' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHyetometerData.vue b/src/views/dataManage/deviceData/listHyetometerData.vue index 516a91a..4f07328 100644 --- a/src/views/dataManage/deviceData/listHyetometerData.vue +++ b/src/views/dataManage/deviceData/listHyetometerData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHyetoData, batchExportHyetoData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHyetometerData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '8' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listLiquidData.vue b/src/views/dataManage/deviceData/listLiquidData.vue index 9bf5307..88332f1 100644 --- a/src/views/dataManage/deviceData/listLiquidData.vue +++ b/src/views/dataManage/deviceData/listLiquidData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getLiquidData, batchExportLiquidData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListLiquidData', @@ -150,31 +151,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '2' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listMeterData.vue b/src/views/dataManage/deviceData/listMeterData.vue index 8c0a30a..cce008c 100644 --- a/src/views/dataManage/deviceData/listMeterData.vue +++ b/src/views/dataManage/deviceData/listMeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getMeterData, batchExportMeterData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListMeterData', @@ -184,31 +185,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '10' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listTempData.vue b/src/views/dataManage/deviceData/listTempData.vue index 1707de6..5c2626c 100644 --- a/src/views/dataManage/deviceData/listTempData.vue +++ b/src/views/dataManage/deviceData/listTempData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getTempData, batchExportTempData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListTempData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '5' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listWellCoverData.vue b/src/views/dataManage/deviceData/listWellCoverData.vue index 5ef5bdd..af6a4c2 100644 --- a/src/views/dataManage/deviceData/listWellCoverData.vue +++ b/src/views/dataManage/deviceData/listWellCoverData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getWellData, batchExportWellData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListWellCoverData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '1' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '1' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/dataManage.vue b/src/views/dataManage/dataManage.vue index 9887d01..82631dc 100644 --- a/src/views/dataManage/dataManage.vue +++ b/src/views/dataManage/dataManage.vue @@ -46,6 +46,7 @@ import ListHyetometerData from './deviceData/listHyetometerData' import ListFlowmeterData from './deviceData/listFlowmeterData' import ListMeterData from './deviceData/listMeterData' +import { parseUrl } from '@/utils/parseutils' export default { name: 'DataManage', components: { ListMeterData, ListFlowmeterData, ListHyetometerData, ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData }, @@ -54,65 +55,22 @@ activeName: 'wellcover' } }, - mounted() { + created() { + // 如果路径里带参数,自己解析deviceType参数 if (window.location.href) { - var query = window.location.href.split('?') - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'deviceType') { - if (value === '1') { - this.activeName = 'wellcover' - } else if (value === '2') { - this.activeName = 'liquid' - } else if (value === '3') { - this.activeName = 'harmful' - } else if (value === '4') { - this.activeName = 'gas' - } else if (value === '5') { - this.activeName = 'temp' - } else if (value === '6') { - this.activeName = 'dig' - } else if (value === '7') { - this.activeName = 'wellloca' - } else if (value === '8') { - this.activeName = 'hyetometer' - } else if (value === '9') { - this.activeName = 'flowmeter' - } else if (value === '10') { - this.activeName = 'meter' - } - } - } - } - if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') { - if (this.$route.params.deviceTypedeviceType === '1') { - this.activeName = 'wellcover' - } else if (this.$route.params.deviceType === '2') { - this.activeName = 'liquid' - } else if (this.$route.params.deviceType === '3') { - this.activeName = 'harmful' - } else if (this.$route.params.deviceType === '4') { - this.activeName = 'gas' - } else if (this.$route.params.deviceType === '5') { - this.activeName = 'temp' - } else if (this.$route.params.deviceType === '6') { - this.activeName = 'dig' - } else if (this.$route.params.deviceType === '7') { - this.activeName = 'wellloca' - } else if (this.$route.params.deviceType === '8') { - this.activeName = 'hyetometer' - } else if (this.$route.params.deviceType === '9') { - this.activeName = 'flowmeter' - } else if (this.$route.params.deviceType === '10') { - this.activeName = 'meter' + const params = parseUrl(window.location.href) + if (params && params.deviceType) { + this.changeTab(params.deviceType) } } }, + activated() { + if (this.$route.query && this.$route.query.deviceType) { + this.changeTab(this.$route.query.deviceType) + } + }, methods: { + // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'wellcover') { this.$refs.welldatacomp.fetchData() @@ -135,6 +93,29 @@ } else if (tab.name === 'meter') { this.$refs.meterdatacomp.fetchData() } + }, + changeTab(deviceType) { + if (deviceType === '1') { + this.activeName = 'wellcover' + } else if (deviceType === '2') { + this.activeName = 'liquid' + } else if (deviceType === '3') { + this.activeName = 'harmful' + } else if (deviceType === '4') { + this.activeName = 'gas' + } else if (deviceType === '5') { + this.activeName = 'temp' + } else if (deviceType === '6') { + this.activeName = 'dig' + } else if (deviceType === '7') { + this.activeName = 'wellloca' + } else if (deviceType === '8') { + this.activeName = 'hyetometer' + } else if (deviceType === '9') { + this.activeName = 'flowmeter' + } else if (deviceType === '10') { + this.activeName = 'meter' + } } } } diff --git a/src/views/dataManage/deviceData/listDigData.vue b/src/views/dataManage/deviceData/listDigData.vue index 0a2b296..e68911c 100644 --- a/src/views/dataManage/deviceData/listDigData.vue +++ b/src/views/dataManage/deviceData/listDigData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getDigData, batchExportDigData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListDigData', @@ -157,31 +158,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '6' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listFlowmeterData.vue b/src/views/dataManage/deviceData/listFlowmeterData.vue index 30d9395..8a384d0 100644 --- a/src/views/dataManage/deviceData/listFlowmeterData.vue +++ b/src/views/dataManage/deviceData/listFlowmeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getFlowData, batchExportFlowData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListFlowmeterData', @@ -164,31 +165,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '9' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listGasData.vue b/src/views/dataManage/deviceData/listGasData.vue index cd05595..35f7daf 100644 --- a/src/views/dataManage/deviceData/listGasData.vue +++ b/src/views/dataManage/deviceData/listGasData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getGasData, batchExportGasData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListGasData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '4' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHarmfulData.vue b/src/views/dataManage/deviceData/listHarmfulData.vue index 03668c8..b1b0ac0 100644 --- a/src/views/dataManage/deviceData/listHarmfulData.vue +++ b/src/views/dataManage/deviceData/listHarmfulData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHarmfulData, batchExportHarmfulData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHarmfulData', @@ -168,31 +169,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '3' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listHyetometerData.vue b/src/views/dataManage/deviceData/listHyetometerData.vue index 516a91a..4f07328 100644 --- a/src/views/dataManage/deviceData/listHyetometerData.vue +++ b/src/views/dataManage/deviceData/listHyetometerData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getHyetoData, batchExportHyetoData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListHyetometerData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '8' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listLiquidData.vue b/src/views/dataManage/deviceData/listLiquidData.vue index 9bf5307..88332f1 100644 --- a/src/views/dataManage/deviceData/listLiquidData.vue +++ b/src/views/dataManage/deviceData/listLiquidData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getLiquidData, batchExportLiquidData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListLiquidData', @@ -150,31 +151,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '2' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listMeterData.vue b/src/views/dataManage/deviceData/listMeterData.vue index 8c0a30a..cce008c 100644 --- a/src/views/dataManage/deviceData/listMeterData.vue +++ b/src/views/dataManage/deviceData/listMeterData.vue @@ -63,6 +63,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getMeterData, batchExportMeterData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListMeterData', @@ -184,31 +185,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '10' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listTempData.vue b/src/views/dataManage/deviceData/listTempData.vue index 1707de6..5c2626c 100644 --- a/src/views/dataManage/deviceData/listTempData.vue +++ b/src/views/dataManage/deviceData/listTempData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getTempData, batchExportTempData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListTempData', @@ -155,31 +156,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '5' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listWellCoverData.vue b/src/views/dataManage/deviceData/listWellCoverData.vue index 5ef5bdd..af6a4c2 100644 --- a/src/views/dataManage/deviceData/listWellCoverData.vue +++ b/src/views/dataManage/deviceData/listWellCoverData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getWellData, batchExportWellData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListWellCoverData', @@ -144,31 +145,23 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '1' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '1' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { diff --git a/src/views/dataManage/deviceData/listWellLocaData.vue b/src/views/dataManage/deviceData/listWellLocaData.vue index 051f5a4..01fda73 100644 --- a/src/views/dataManage/deviceData/listWellLocaData.vue +++ b/src/views/dataManage/deviceData/listWellLocaData.vue @@ -62,6 +62,7 @@ import selectTree from '@/components/SelectTree/singleSelect' import { getWellLocaData, batchExportWellLocaData } from '@/api/data' import DeptSelect from '../../../components/DeptSelect/index' +import { parseUrl } from '@/utils/parseutils' export default { name: 'ListWellLocaData', @@ -148,37 +149,28 @@ } } }, - mounted() { + created() { + // 如果路径里带参数,解析devcode参数 if (window.location.href) { - var query = window.location.href.split('?') - if (query.length > 1) { - var values = query[1].split('&') - for (var i = 0; i < values.length; i++) { - var pos = values[i].indexOf('=') - if (pos === -1) continue - var paramname = values[i].substring(0, pos) - var value = values[i].substring(pos + 1) - if (paramname === 'devcode') { - this.listQuery.keywords = value - this.fetchData() - } else { - this.fetchData() - } - } - } else { - if (this.$route.params && this.$route.params.deviceType === '2' && this.$route.params.devcode && this.$route.params.devcode !== '') { - this.listQuery.keywords = this.$route.params.devcode - this.fetchData(false)// 获取数据 - } else { - this.fetchData() - } + const params = parseUrl(window.location.href) + if (params && params.deviceType === '7' && params.devcode) { + this.listQuery.keywords = params.devcode } + this.fetchData() + } + }, + activated() { + // 要是路由里有参数 + if (this.$route.query && this.$route.query.devcode) { + this.listQuery.keywords = this.$route.query.devcode + this.fetchData(false)// 获取数据 + } else { + this.fetchData() } }, methods: { // 批量导出 batchExport() { - console.log('批量导出液位配置') // 全屏加载动画 const loading = this.$loading({ lock: true, @@ -188,7 +180,6 @@ }) batchExportWellLocaData(this.listQuery).then(res => { loading.close() // 关闭加载动画 - console.log('download===', res) const blob = new Blob([res.data]) const downloadElement = document.createElement('a') const href = window.URL.createObjectURL(blob) // 创建下载的链接