diff --git a/report-ui/src/mixins/queryform.js b/report-ui/src/mixins/queryform.js index 4004384c..271201b2 100644 --- a/report-ui/src/mixins/queryform.js +++ b/report-ui/src/mixins/queryform.js @@ -95,13 +95,55 @@ export default { }, // 查询echarts 数据 queryEchartsData(params) { + const queryParams = this.toEchartsDataQueryParams(params) return new Promise(async (resolve) => { - const { code, data } = await getData(params); + const { code, data } = await getData(queryParams); if (code != 200) return const analysisData = this.analysisChartsData(params, data); resolve(analysisData) }) }, + /** + * 将url参数解析到图表参数中 + * 1. tenantCode=aaa + * 2. [setCode].tenantCode=aaa + * 判断是否有点(.) + * a. 没有 -> 把所有的参数全部给插入contextData + * b. 有 -> 点前缀的值去匹配相同的值再把对应的值插入contextData + * + * **/ + toEchartsDataQueryParams(params) { + const queryParams = this.deepClone(params) + const query = this.$route.query + if(!this.isIncludePoints(query)) { + queryParams.contextData = { ...queryParams.contextData, ...query } + } else { + Object.keys(query).forEach(item => { + if(item.indexOf('.') > -1) { + const obj = {} + const key1 = item.split('.')[0] + const key2 = item.split('.')[1] + obj[key2] = query[item] + if (queryParams.setCode == key1) { + const newObj = { ...queryParams.contextData, ...obj } + queryParams.contextData = newObj + } + } + }) + } + + return queryParams + }, + // 判断对象是否包含点 + isIncludePoints(query) { + let isPoints = false + Object.keys(query).forEach(item => { + if(item.indexOf('.') > -1) { + isPoints = true + } + }) + return isPoints + }, // 解析不同图标的数据 analysisChartsData(params, data) { // widget-barchart 柱线图、widget-linechart 折线图、 widget-barlinechart 柱线图 diff --git a/report-ui/src/views/bigScreenReport/aj/index.vue b/report-ui/src/views/bigScreenReport/aj/index.vue index ee94ff4f..61959d3b 100644 --- a/report-ui/src/views/bigScreenReport/aj/index.vue +++ b/report-ui/src/views/bigScreenReport/aj/index.vue @@ -43,7 +43,7 @@ export default { methods: { async handleOpen() { const url = window.location.href; - const shareCode = url.substring(url.lastIndexOf("/") + 1); + const shareCode = url.split('?')[0].substring(url.lastIndexOf("/") + 1); const { code, data } = await reportShareDetailByCode(shareCode); if (code != "200") return; this.reportCode = data.reportCode; @@ -66,13 +66,20 @@ export default { }, pushAj() { setShareToken(this.shareToken); + const url = window.location.href; + const urlParamsObj = this.toUrlParamsMap(url.split('?')[1]) + const queryParams = { ...urlParamsObj, reportCode: this.reportCode } this.$router.push({ path: "/bigscreen/viewer", - query: { - reportCode: this.reportCode - } + query: queryParams }); }, + toUrlParamsMap(params) { + if(!params) return {} + const urlObj = {} + params.split("&").map(item => urlObj[item.split("=")[0]] = item.split("=")[1]) + return urlObj + }, handleClose(done) { this.$confirm("确认关闭?") .then(_ => {