Files
dvcp_v2_webapp/components/AiDvRender.vue

362 lines
11 KiB
Vue
Raw Normal View History

2022-06-28 09:14:39 +08:00
<template>
<div class="AiDvRender" style="width: 100%; height: 100%;">
2023-10-07 11:30:13 +08:00
<ai-dv-display v-if="currentType === 'display'" :title="data.title" :list="values"/>
2022-06-28 09:14:39 +08:00
<ai-dv-panel
2023-04-11 14:33:36 +08:00
style="height: 100%; width: 100%;"
2023-10-07 11:30:13 +08:00
v-if="currentType !== 'display'"
2023-04-11 14:33:36 +08:00
:title="data.title"
:theme="theme"
:border="data.border || ''">
2023-10-07 11:30:13 +08:00
<AiDvSummary v-if="currentType === 'summary'" :theme="theme" :summaryTitle="data.summaryTitle"
2023-09-20 15:06:57 +08:00
:key="`summary${index}`" :type="data.display"
2023-04-11 14:33:36 +08:00
:data="values"/>
2023-10-07 11:30:13 +08:00
<AiSwiper v-else-if="currentType === 'swiper'" :heigth="'100%'" :data="values" :dotIndicator="data.dotIndicator"/>
2022-06-28 09:14:39 +08:00
<dv-scroll-board
2023-10-07 11:30:13 +08:00
v-if="currentType === 'table'"
2023-04-11 14:33:36 +08:00
:class="'dvScrollBoard' + theme"
:config="formatTable(values, data.isShowIndex, data.rowNum)"
:key="data.height"
:theme="theme"
:style="{height: data.height + 'px', width: '100%'}"/>
2023-10-07 11:30:13 +08:00
<ai-echart-v2 v-else-if="/Chart/.test(currentType)"
2023-04-11 14:33:36 +08:00
style="height: 100%; width: 100%;"
:ref="'chart' + index"
:key="`chart-${index}`"
:theme="theme"
:data="values"
2023-10-08 18:16:51 +08:00
:ops="$echartTpls[data.config]"/>
2023-03-08 17:03:00 +08:00
<AiDvTable
2023-10-07 11:30:13 +08:00
v-else-if="currentType === 'AiDvTable'"
2023-04-11 14:33:36 +08:00
:heigth="'100%'"
:stripe="data.stripe"
:theme="theme"
:isShowIndex="data.isShowIndex"
:config="dvTableConfig"
:data="values">
2023-03-08 17:03:00 +08:00
</AiDvTable>
2023-03-09 10:40:04 +08:00
<AiRanking
2023-10-07 11:30:13 +08:00
v-else-if="currentType === 'AiRanking'"
2023-04-11 14:33:36 +08:00
:theme="theme"
:heigth="'100%'"
:subType="data.subType"
:data="values">
2023-03-09 10:40:04 +08:00
</AiRanking>
2023-10-07 11:30:13 +08:00
<AiDvMap v-else-if="currentType === 'AiDvMap'" style="width: 100%; height: 100%" :ref="'chart' + index"
2023-09-20 15:06:57 +08:00
:key="`AiDvMap${index}`" :theme="theme"></AiDvMap>
2023-10-07 11:30:13 +08:00
<ai-map v-else-if="currentType=='map'" :mask="data.mask === '1'" :areaId="data.areaId" :is3d="data.is3d==1"
2023-09-20 15:06:57 +08:00
:is3dAround="data.is3dAround === '1'"
:map-style="`amap://styles/${data.mapStyle}`" :pulseLines="data.pulseLines==1" :map.sync="map"
:lib.sync="lib"
:onlyShowArea="data.limitArea==1" :satellite="data.layers=='satellite'">
<div class="mapInfoWin" v-show="mapDialog">
<div class="corn" v-for="i in 4" :key="i"/>
<div ref="mapInfoWin"/>
</div>
2023-10-18 15:22:17 +08:00
<div v-if="data.showPingchangMapLegend" class="pingchangMapLegend"/>
2023-09-20 15:06:57 +08:00
</ai-map>
2023-10-07 11:30:13 +08:00
<ai-monitor :src="data.src" v-else-if="currentType === 'monitor'" :type="data.monitorType"/>
2023-09-20 15:06:57 +08:00
<video style="width: 100%; height: 100%; object-fit: fill;" loop :src="data.src" autoplay
2023-10-07 11:30:13 +08:00
v-else-if="currentType === 'video'"/>
<AiDvPartyOrg style="width: 100%; height: 100%;" v-else-if="currentType === 'partyOrg'" :instance="instance"/>
<!-- <ai-sprite v-else-if="/building/.test(currentType)" v-bind="data" is3D @init="mods[currentType]"/> -->
2023-10-08 18:16:51 +08:00
<ai-dv-plot v-else-if="currentType=='plot'" :options="data.charts" :instance="instance"/>
2022-06-28 09:14:39 +08:00
</ai-dv-panel>
</div>
</template>
<script>
import {scrollBoard} from '@jiaminghi/data-view'
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 AiDvMap from "./AiDvMap";
2022-06-28 09:14:39 +08:00
import AiMonitor from "./AiMonitor/AiMonitor";
import AiSwiper from './AiSwiper.vue'
2022-08-12 11:50:04 +08:00
import AiDvDisplay from "./layout/AiDvDisplay/AiDvDisplay";
import AiDvPanel from "./layout/AiDvPanel/AiDvPanel";
2022-08-12 11:50:04 +08:00
import AiDvSummary from "./layout/AiDvSummary/AiDvSummary";
2023-10-07 18:04:34 +08:00
import AiDvPlot from "./layout/AiDvPlot/AiDvPlot.vue";
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: {
2023-10-07 18:04:34 +08:00
AiDvPlot,
2022-08-02 17:46:57 +08:00
// AiSprite,
2022-06-28 09:14:39 +08:00
AiDvSummary,
AiDvDisplay,
AiDvPanel,
AiMonitor,
2023-03-27 18:02:05 +08:00
AiSwiper,
AiDvMap
2022-06-28 09:14:39 +08:00
},
data() {
return {
2022-08-02 17:46:57 +08:00
// mods,
2022-06-28 09:14:39 +08:00
map: null,
lib: null,
2023-03-15 15:18:19 +08:00
timer: null,
2023-09-20 15:06:57 +08:00
dvTableConfig: [],
mapDialog: false
2022-06-28 09:14:39 +08:00
}
},
computed: {
...mapState(['user']),
2023-10-07 11:30:13 +08:00
values: v => v.data?.[v.data?.dataType] || [],
2022-11-09 16:29:44 +08:00
currentType: v => v.data.type
},
watch: {
2023-03-15 15:18:19 +08:00
values: {
2022-11-09 16:29:44 +08:00
immediate: true,
deep: true, handler() {
2023-04-14 09:15:16 +08:00
if (this.currentType == 'map') {
this.renderMap()
2023-10-07 18:04:34 +08:00
} else if (this.currentType === 'AiDvTable') {
2023-03-15 15:18:19 +08:00
this.dvTableConfig = this.data[this.data.dataType].map((v, i) => {
return {
color: this.data.config[i] ? (this.data.config[i].color || '') : '',
width: this.data.config[i] ? (this.data.config[i].width || '') : '',
align: this.data.config[i] ? (this.data.config[i].align || '') : ''
}
})
this.data.config = this.dvTableConfig
}
2022-11-09 16:29:44 +08:00
}
}
2022-06-28 09:14:39 +08:00
},
methods: {
formatTable(data, isShowIndex, rowNum) {
2023-10-09 19:11:01 +08:00
const tableStyle = {
headerBGC: 'transparent',
evenRowBGC: 'transparent',
oddRowBGC: 'rgba(0, 133, 255, 0.2)',
headerHeight: 42,
align: 'center'
}
2022-06-28 09:14:39 +08:00
if (!data.length) {
return {
header: [],
data: []
}
}
2023-10-09 19:11:01 +08:00
if (this.data.tableConfig) {
const {x, y} = this.data.tableConfig, dataMap = {}
const header = [...new Set(Object.entries(data.find(e => e.row == x) || null)?.filter(e => e[0] != 'row').map(e => e[1]) || [])],
rows = [...new Set(Object.entries(data.find(e => e.row == y) || null)?.filter(e => e[0] != 'row').map(e => e[1]) || [])]
data.map(e => Object.keys(e).map(k => k != 'row' && (dataMap[k] = (dataMap[k] || "") + "#" + e[k])))
const tableData = Object.values(dataMap).map(e => e.split("#"))
return {
...tableStyle,
header: ["", ...header],
data: rows.map(y => [y, ...header.map(x => {
return tableData.find(m => m.includes(x) && m.includes(y)).at(-1)
})])
}
}
2022-06-28 09:14:39 +08:00
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]
})
}),
2023-10-09 19:11:01 +08:00
...tableStyle,
2022-06-28 09:14:39 +08:00
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)
if (AMap && map) {
2022-06-28 09:14:39 +08:00
map.clearMap()
2023-10-07 11:30:13 +08:00
const markers = Array.isArray(this.values) ? this.values : this.values.markers
const polylines = Array.isArray(this.values) ? [] : this.values.polylines || []
markers.map(e => ({lng: e['经度'], lat: e['纬度'], label: e['地区名称'], ...e})).filter(e => e.lng).map((e) => {
2023-04-13 15:59:28 +08:00
const {icon = "https://cdn.cunwuyun.cn/dvcp/h5/Location2.png"} = e
2022-06-28 09:14:39 +08:00
return new AMap.Marker({
map,
content: e.content || `<div class="marker ${this.data.alwaysShow ? 'showLabel' : ''}">
2023-04-13 15:59:28 +08:00
<img src="${icon}"/>
2022-11-09 16:29:44 +08:00
<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', () => {
2023-09-20 15:06:57 +08:00
this.mapDialog = true
this.$nextTick(() => {
this.$refs.mapInfoWin.innerHTML = e.infoWindowHtml || [`<div class="infoWin">`, `<b>${e.label}</b>`, '</div>'].join('')
map.setZoomAndCenter(16, [e.lng, e.lat])
2023-09-20 15:06:57 +08:00
map.setPitch(60)
})
2022-06-28 09:14:39 +08:00
})
})
2023-10-07 11:30:13 +08:00
polylines.filter(e => e.path?.length > 0)?.map(e => new AMap.Polyline({
map, strokeColor: "#00FFAE", ...e, path: e.path.map(p => new AMap.LngLat(p[1], p[0]))
}))
map.setFitView()
const center = map.getCenter()
const zoom = map.getZoom()
map.on('click', () => {
map.setZoomAndCenter(zoom, center)
map.setPitch(0)
this.mapDialog = false
})
2023-09-20 15:06:57 +08:00
this.data.is3d > 0 && 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
}
}
}
}
</script>
<style lang="scss" scoped>
.AiDvRender {
2023-09-20 15:06:57 +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-09-20 15:06:57 +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 {
2023-07-25 15:26:40 +08:00
width: 30px;
height: 30px;
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
}
}
2023-04-13 15:59:28 +08:00
:deep(.mapInfoWin) {
2023-09-20 15:06:57 +08:00
$borderColor: #245D8E;
$borderCorn: url("https://cdn.cunwuyun.cn/dvcp/dv/mapDialogCorn.png");
position: absolute;
left: 50%;
top: 40%;
transform: translate(-50%, -50%);
2023-09-20 16:18:47 +08:00
padding: 16px 20px;
2023-04-13 15:59:28 +08:00
max-width: 800px;
2023-09-20 15:06:57 +08:00
background-color: rgba(#0A1B3E, 0.8);
2023-04-13 15:59:28 +08:00
backdrop-filter: blur(6px);
2023-09-20 15:06:57 +08:00
border: 1px solid $borderColor;
box-shadow: 10px 10px 10px inset rgba($borderColor, .8), -10px -10px 10px inset rgba($borderColor, .8);
2023-04-13 15:59:28 +08:00
border-radius: 4px;
2023-09-20 15:06:57 +08:00
color: white;
.corn {
$offset: -2px;
background-image: $borderCorn;
background-repeat: no-repeat;
position: absolute;
width: 14px;
height: 14px;
background-size: 100% 100%;
&:nth-of-type(1) {
left: $offset;
top: $offset;
transform: rotate(-90deg);
}
&:nth-of-type(2) {
right: $offset;
top: $offset;
transform: none;
}
&:nth-of-type(3) {
right: $offset;
bottom: $offset;
transform: rotate(90deg);
}
&:nth-of-type(4) {
left: $offset;
bottom: $offset;
transform: rotate(180deg);
}
}
2023-04-13 15:59:28 +08:00
}
2023-10-18 15:22:17 +08:00
.pingchangMapLegend {
width: 429px;
height: 45px;
background: url("https://cdn.cunwuyun.cn/pingchang/pingchangMapLegend.png");
position: absolute;
bottom: 32px;
left: 50%;
transform: translateX(-50%);
backdrop-filter: blur(10px);
}
2022-06-28 09:14:39 +08:00
}
</style>