Files
dvcp_v2_webapp/components/AiDvRender.vue

263 lines
7.5 KiB
Vue
Raw Normal View History

2022-06-28 09:14:39 +08:00
<template>
<div class="AiDvRender" style="width: 100%; height: 100%;">
<ai-dv-display v-if="data.type === 'display'" :title="data.title" :list="values"></ai-dv-display>
<ai-dv-panel
2023-01-09 13:53:19 +08:00
style="height: 100%; width: 100%;"
v-if="data.type !== 'display'"
:title="data.title"
:border="data.border || ''">
2022-06-28 09:14:39 +08:00
<AiDvSummary v-if="data.type === 'summary'" :summaryTitle="data.summaryTitle" :key="`summary${index}`" :type="data.display" :data="values"/>
<AiSwiper v-else-if="data.type === 'swiper'" :heigth="'100%'" :data="values"/>
<dv-scroll-board
2023-01-09 13:53:19 +08:00
v-if="data.type === 'table'"
:class="'dvScrollBoard' + theme"
:config="formatTable(values, data.isShowIndex, data.rowNum)"
:key="data.height"
:theme="theme"
:style="{height: data.height + 'px', width: '100%'}"/>
2023-03-09 18:01:14 +08:00
<ai-echart-v2 v-else-if="/Chart/.test(data.type)"
2023-01-09 13:53:19 +08:00
style="height: 100%; width: 100%;"
:ref="'chart' + index"
:key="`chart${index}`"
:theme="theme"
:data="values"
:ops="chartList[data.config]"/>
<!-- <ai-q-map
v-else-if="data.type=='map'"
:area-id="data.areaId"
:markers="markers"
:is3d="data.is3D === '1'"
:limitArea="data.limitArea === '1'"
:is3dAround="data.is3dAround === '1'">
</ai-q-map> -->
2023-03-08 17:03:00 +08:00
<AiDvTable
v-else-if="data.type === 'AiDvTable'"
:heigth="'100%'"
2023-03-08 17:32:42 +08:00
:stripe="data.stripe"
2023-03-08 17:03:00 +08:00
:isShowIndex="data.isShowIndex"
:data="values">
</AiDvTable>
2023-03-09 10:40:04 +08:00
<AiRanking
v-else-if="data.type === 'AiRanking'"
:heigth="'100%'"
:data="values">
</AiRanking>
2022-11-18 09:35:49 +08:00
<ai-map v-else-if="data.type=='map'" :mask="data.mask === '1'" :areaId="data.areaId" :is3d="data.is3d==1" :is3dAround="data.is3dAround === '1'"
:map-style="`amap://styles/${data.mapStyle}`" :pulseLines="data.pulseLines==1" :map.sync="map" :lib.sync="lib" :onlyShowArea="data.limitArea==1"/>
2022-06-28 09:14:39 +08:00
<ai-monitor :src="data.src" v-else-if="data.type === 'monitor'" :type="data.monitorType"/>
<video style="width: 100%; height: 100%; object-fit: fill;" loop :src="data.src" autoplay v-else-if="data.type === 'video'"/>
<AiDvPartyOrg style="width: 100%; height: 100%;" v-else-if="data.type === 'partyOrg'" :instance="instance"/>
2022-08-02 17:46:57 +08:00
<!-- <ai-sprite v-else-if="/building/.test(data.type)" v-bind="data" is3D @init="mods[data.type]"/> -->
2022-06-28 09:14:39 +08:00
</ai-dv-panel>
</div>
</template>
<script>
2023-01-09 13:53:19 +08:00
import Vue from "vue"
2022-06-28 09:14:39 +08:00
import {mapState} from 'vuex'
import AiSwiper from './AiSwiper.vue'
2022-06-28 18:18:37 +08:00
import chartList from './AiEchart/echartTpls'
2022-06-28 09:14:39 +08:00
import AiMonitor from "./AiMonitor/AiMonitor";
2022-08-12 11:50:04 +08:00
import AiDvPanel from "./layout/AiDvPanel/AiDvPanel";
import AiDvDisplay from "./layout/AiDvDisplay/AiDvDisplay";
import AiDvSummary from "./layout/AiDvSummary/AiDvSummary";
2022-06-28 18:18:37 +08:00
import AiSprite from "./AiSprite";
2023-01-09 13:53:19 +08:00
import {scrollBoard} from '@jiaminghi/data-view'
2022-06-28 09:14:39 +08:00
2023-01-09 13:53:19 +08:00
Vue.use(scrollBoard)
2022-06-28 09:14:39 +08:00
export default {
name: 'AiDvRender',
props: ['data', 'index', 'theme', 'instance'],
components: {
2022-08-02 17:46:57 +08:00
// AiSprite,
2022-06-28 09:14:39 +08:00
AiDvSummary,
AiDvDisplay,
AiDvPanel,
AiMonitor,
AiSwiper
},
data() {
return {
2022-08-02 17:46:57 +08:00
// mods,
2022-06-28 18:18:37 +08:00
chartList,
2022-06-28 09:14:39 +08:00
map: null,
lib: null,
timer: null
2022-06-28 09:14:39 +08:00
}
},
computed: {
...mapState(['user']),
values() {
if (!this.data) {
return []
}
return this.data.type === 'map' ? this.data[this.data.dataType].map(e => {
2022-11-09 16:29:44 +08:00
return {lng: e['经度'], lat: e['纬度'], label: e['地区名称'], ...e}
2022-06-28 09:14:39 +08:00
}) : this.data[this.data.dataType]
2022-06-28 18:18:37 +08:00
},
2022-11-09 16:29:44 +08:00
currentType: v => v.data.type
},
watch: {
2022-11-09 17:00:49 +08:00
data: {
2022-11-09 16:29:44 +08:00
immediate: true,
deep: true, handler() {
if (this.currentType == 'map') {
2022-11-18 08:50:55 +08:00
// this.renderMap()
2022-11-09 16:29:44 +08:00
}
}
}
2022-06-28 09:14:39 +08:00
},
methods: {
formatTable(data, isShowIndex, rowNum) {
if (!data.length) {
return {
header: [],
data: []
}
}
let rows = []
const header = data.map(v => {
return v[Object.keys(v)[0]]
})
Object.keys(data[0]).forEach((item, index) => {
if (index !== 0) {
rows.push(item)
}
})
return {
header: header,
data: rows.map(item => {
return data.map(v => {
return v[item]
})
}),
headerBGC: 'transparent',
evenRowBGC: 'transparent',
oddRowBGC: 'rgba(0, 133, 255, 0.2)',
headerHeight: 42,
rowNum: rowNum || 7,
index: isShowIndex === '1',
waitTime: 8000,
carousel: 'page',
indexHeader: '排名',
align: ['center', 'center', 'center', 'center', 'center']
}
},
2022-11-09 16:29:44 +08:00
renderMap(count = 0) {
2022-06-28 09:14:39 +08:00
let {lib: AMap, map} = this
this.timer && clearInterval(this.timer)
2022-06-28 09:14:39 +08:00
if (AMap) {
let infoWin = new AMap.InfoWindow({content: ""})
map.clearMap()
this.values.filter(e => e.lng).map(e => {
2022-06-28 09:14:39 +08:00
return new AMap.Marker({
map,
content: e.content || `<div class="marker ${this.data.alwaysShow ? 'showLabel' : ''}">
2022-11-09 16:29:44 +08:00
<img src="${e.icon}"/>
<span>${e.label}</span>
</div>`,
2022-06-28 09:14:39 +08:00
position: [e.lng, e.lat]
2022-11-09 16:29:44 +08:00
}).on('click', () => {
if (!!e.openWin || e.infoWindowHtml) {
map.clearInfoWindow()
infoWin.setContent(e.infoWindowHtml ||
[`<div class="infoWin">`,
`<b>${e.label}</b>`,
'</div>'
].join('')
)
infoWin.open(map, [e.lng, e.lat])
}
2022-06-28 09:14:39 +08:00
})
})
this.data.is3d && map.setPitch(65)
if (this.data.is3dAround == 1) {
this.timer = setInterval(() => map?.setRotation(360, false, 16000))
}
2022-06-28 09:14:39 +08:00
} else if (count < 10) {
console.log("正在加载...%s", count)
2022-11-09 16:29:44 +08:00
setTimeout(() => this.renderMap(++count), 1000)
2022-06-28 09:14:39 +08:00
}
}
},
mounted() {
if (this.data.type == 'map') {
2022-11-09 16:29:44 +08:00
this.renderMap()
} else if (this.data.type == 'table') {
2022-08-29 09:12:16 +08:00
this.$injectLib("https://cdn.cunwuyun.cn/datav.map.vue.js")
}
2022-06-28 09:14:39 +08:00
}
}
</script>
<style lang="scss" scoped>
.AiDvRender {
2023-01-09 13:53:19 +08:00
:deep( .dvScrollBoard1 ) {
2022-06-28 09:14:39 +08:00
.header {
background: rgba(0, 0, 0, 0.1) !important;
.header-item {
color: #FFBB73 !important;
font-size: 16px !important;
font-weight: 600;
}
}
.rows {
font-size: 16px;
font-weight: 600;
color: #FFFFFF;
line-height: 21px;
text-shadow: 0px 2px 4px rgba(117, 9, 9, 0.5);
background: linear-gradient(180deg, #FFF6C7 0%, #FF9A02 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
& > div:nth-of-type(2n - 1) {
background-color: transparent !important;
}
& > div:nth-of-type(2n) {
background-color: rgba(0, 0, 0, 0.1) !important;
}
.index {
color: #fff;
text-shadow: none;
background: #BD4921 !important;
-webkit-background-clip: inherit;
-webkit-text-fill-color: #fff;
}
}
}
2023-01-09 13:53:19 +08:00
:deep( .marker ) {
2022-11-09 16:29:44 +08:00
position: relative;
2022-06-28 09:14:39 +08:00
2022-11-09 16:29:44 +08:00
& > img {
width: 50px;
height: 50px;
2022-06-28 09:14:39 +08:00
}
2022-11-09 16:29:44 +08:00
& > span {
display: none;
}
2022-06-28 09:14:39 +08:00
&:hover > span, &.showLabel > span {
2022-11-09 16:29:44 +08:00
position: absolute;
left: 50%;
bottom: 0;
transform: translate(-50%, 100%);
display: block;
color: #fff;
font-size: 14px;
white-space: nowrap;
2022-06-28 09:14:39 +08:00
}
}
}
</style>