Commit e510c83f authored by leon's avatar leon

fix: change detail to details

parent b0f3fecf
...@@ -57,14 +57,16 @@ ...@@ -57,14 +57,16 @@
"onReachBottomDistance": 50 "onReachBottomDistance": 50
} }
}, { },{
"path": "pages/detail/detail", "path" : "pages/details/details",
"style": { "style" :
"navigationBarTitleText": "", {
"enablePullDownRefresh": true "navigationBarTitleText": "",
} "enablePullDownRefresh": true
} }
],
}
],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "uView", "navigationBarTitleText": "uView",
......
<template>
<view
class="canvas"
:style="[styleObject]"
>
<view class="viewport-wrapper" :style="{
width: `${reportInfo.width * scale}px`,
height: `${reportInfo.height * scale}px`
}">
<template v-for="(element, index) in reportData">
<view
class="view-element"
v-if="!element.hide"
:key="element.id"
:style="{
width: `${element.width * scale}px`,
height: `${element.height * scale}px`,
transform: `translate(${element.left * scale}px, ${element.top * scale}px)`,
zIndex: index + 1
}"
>
<!-- 普通柱状图 -->
<NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar>
<!-- 普通折线图 -->
<NormalLine v-if="element.type == 'NormalLine'" :elementInfo="element"></NormalLine>
<!-- 横向柱状图 -->
<HorizontalBar v-if="element.type == 'HorizontalBar'" :elementInfo="element"></HorizontalBar>
<!-- 折柱图 -->
<LineMixBar v-if="element.type == 'LineMixBar'" :elementInfo="element"></LineMixBar>
<!-- 仪表盘 -->
<NormalGauge v-if="element.type == 'NormalGauge'" :elementInfo="element"></NormalGauge>
<!-- 饼图 -->
<NormalPie v-if="element.type == 'NormalPie'" :elementInfo="element"></NormalPie>
<!-- 中国地图 -->
<ChinaMap v-if="element.type == 'ChinaMap'" :elementInfo="element"></ChinaMap>
<!-- 柱状图混合地图 -->
<BarMixMap v-if="element.type == 'BarMixMap'" :elementInfo="element"></BarMixMap>
<!-- 雷达图 -->
<NormalRadar v-if="element.type == 'NormalRadar'" :elementInfo="element"></NormalRadar>
<!-- 普通数字滚动 -->
<CountTo v-if="element.type == 'CountTo'" :elementInfo="element"></CountTo>
<!-- 数字滚动 -->
<NumberScroll v-if="element.type == 'NumberScroll'" :elementInfo="element"></NumberScroll>
<!-- 普通选项卡 -->
<NormalTabs v-if="element.type == 'NormalTabs'" :elementInfo="element"></NormalTabs>
<!-- 文本框 -->
<BasicText v-if="element.type == 'BasicText'" :elementInfo="element"></BasicText>
<!-- 真实时间 -->
<RealTime v-if="element.type == 'RealTime'" :elementInfo="element"></RealTime>
<!-- 普通进度条 -->
<NormalProgress v-if="element.type == 'NormalProgress'" :elementInfo="element"></NormalProgress>
<!-- 普通图片 -->
<NormalImage v-if="element.type == 'NormalImage'" :elementInfo="element"></NormalImage>
<!-- 远程图片 -->
<RemoteImage v-if="element.type == 'RemoteImage'" :elementInfo="element"></RemoteImage>
<!-- 普通表格 -->
<NormalTable v-if="element.type == 'NormalTable'" :elementInfo="element"></NormalTable>
</view>
</template>
</view>
</view>
</template>
<script>
export default {
data() {
return {
reportInfo: {},
reportData: [],
timename: null,
detailId: ""
}
},
computed: {
styleObject() {
let params = {}
const { backgroundColor, backgroundImage } = this.reportInfo
if(backgroundImage) params = { 'background-image': `url(${backgroundImage})` }
return {
'background-color': backgroundColor,
...params
}
},
scale() {
const { windowWidth } = uni.getSystemInfoSync()
const { width, height } = this.reportInfo
return windowWidth / width
}
},
onLoad(option) {
this.detailId = option.id
this.userAuthCheck()
this.getReportCharts()
/**
* 组件交互 - 参数
*/
uni.$on('handleLinkParams', ({index, paramName, value}) => {
this.handleValueChange(index, paramName, value)
})
/**
* 组件交互 - 组件
*/
uni.$on('handleLinkComp', ({ showData, hideData }) => {
this.reportData.map(item => {
if(showData.includes(item.id)) item.hide = false
if(hideData.includes(item.id)) item.hide = true
return item
})
})
},
onUnload() {
// 移除监听事件
uni.$off('handleLinkParams')
clearInterval(this.timename)
},
methods: {
//检查是否登录
userAuthCheck() {
var userId = uni.getStorageSync('userId')
this.getNewestAuthFromServer()
var authorized = uni.getStorageSync('authorized')
if (userId) {
if (authorized) {
} else {
uni.reLaunch({
url:'../login/authorized'
})
}
} else {
uni.reLaunch({
url: '../login/login'
})
}
},
//获取最新的授权信息
getNewestAuthFromServer() {
var param = {
id: uni.getStorageSync('userId')
}
this.$u.api.getAuthorized(param).then(res=>{
const { Status, Result } = res.data
if (Status === 'true') {
uni.setStorageSync('authorized', Result.authorized)
}
})
},
/**
* 获取页面报表配置
*/
async getReportCharts() {
clearInterval(this.timename)
let res = await this.$u.api.getReportCharts({id: this.detailId})
const { Status, Result: { info, list } } = res.data
if (Status === 'true') {
if(info.dataUrl) {
this.getGlobalData(info)
if(info.dataPollingInterval) {
this.timename = setInterval(() => {
this.getGlobalData(info)
}, parseInt(info.dataPollingInterval) * 1000)
}
}
this.reportInfo = info
this.reportData = list
}
},
/**
* 获取全局接口数据
*/
async getGlobalData(info) {
const dataUrl = info.dataUrl.replace(/^(\/dashboardCharts)?|^(\/dashboardAPI)?/, '')
let res = await this.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, info.dataFormatter, {
custom: { loading: false }
})
this.$u.vuex('vuex_globalData', JSON.stringify(res.data))
},
/**
* 组件之间关联
*/
handleValueChange(index, paramName, value) {
if(index.length && paramName && value) {
this.reportData.map(item => {
const flag = index.includes(item.id)
if(flag && item.type === 'BasicText' && item.data.dataType === 'static') {
this.$set(item.data.dataList, 'text', value)
}
if(flag && item.data.dataType === 'dynamic') {
if(!item.data.dataFormatter) item.data.dataFormatter = {}
this.$set(item.data.dataFormatter, paramName, value)
}
if(flag && item.data.dataType === 'dataSet') {
if(!item.data.dataSetInfo.queryFormatter) item.data.dataSetInfo.queryFormatter = {}
this.$set(item.data.dataSetInfo.queryFormatter, paramName, value)
}
return item
})
}
}
},
onReachBottom() {
},
onPullDownRefresh() {
this.getReportCharts()
}
}
</script>
<style lang="scss" scoped>
.canvas {
position: relative;
height: 100%;
user-select: none;
overflow: auto;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
.viewport-wrapper {
position: relative;
}
.view-element {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
will-change: transform;
user-select: none;
cursor: move;
}
</style>
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
// 点击查看 // 点击查看
onClick(item) { onClick(item) {
const url = "/pages/detail/detail?id=" + item.id const url = "/pages/details/details?id=" + item.id
uni.navigateTo({ uni.navigateTo({
url: url url: url
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment