入参更改

qianlishi 1 year ago committed by qianming
parent 3f789c4541
commit 0abd256c44

@ -95,13 +95,55 @@ export default {
}, },
// 查询echarts 数据 // 查询echarts 数据
queryEchartsData(params) { queryEchartsData(params) {
const queryParams = this.toEchartsDataQueryParams(params)
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
const { code, data } = await getData(params); const { code, data } = await getData(queryParams);
if (code != 200) return if (code != 200) return
const analysisData = this.analysisChartsData(params, data); const analysisData = this.analysisChartsData(params, data);
resolve(analysisData) 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) { analysisChartsData(params, data) {
// widget-barchart 柱线图、widget-linechart 折线图、 widget-barlinechart 柱线图 // widget-barchart 柱线图、widget-linechart 折线图、 widget-barlinechart 柱线图

@ -43,7 +43,7 @@ export default {
methods: { methods: {
async handleOpen() { async handleOpen() {
const url = window.location.href; 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); const { code, data } = await reportShareDetailByCode(shareCode);
if (code != "200") return; if (code != "200") return;
this.reportCode = data.reportCode; this.reportCode = data.reportCode;
@ -66,13 +66,20 @@ export default {
}, },
pushAj() { pushAj() {
setShareToken(this.shareToken); setShareToken(this.shareToken);
const url = window.location.href;
const urlParamsObj = this.toUrlParamsMap(url.split('?')[1])
const queryParams = { ...urlParamsObj, reportCode: this.reportCode }
this.$router.push({ this.$router.push({
path: "/bigscreen/viewer", path: "/bigscreen/viewer",
query: { query: queryParams
reportCode: this.reportCode
}
}); });
}, },
toUrlParamsMap(params) {
if(!params) return {}
const urlObj = {}
params.split("&").map(item => urlObj[item.split("=")[0]] = item.split("=")[1])
return urlObj
},
handleClose(done) { handleClose(done) {
this.$confirm("确认关闭?") this.$confirm("确认关闭?")
.then(_ => { .then(_ => {

Loading…
Cancel
Save