DSDSWeb/src/views/statistics/ShipStatistics.vue

565 lines
15 KiB
Vue
Raw Normal View History

<template>
2025-10-31 16:15:28 +08:00
<div class="statistics">
<div class="banner">
2026-04-03 02:05:29 +08:00
<div class="banner-title-picker">
2026-04-03 11:10:58 +08:00
<el-dropdown class="banner-type-dropdown" trigger="click" @command="handleCommand">
2026-04-03 02:05:29 +08:00
<span class="banner-select-trigger">
<span class="banner-select-text">{{ currentTitle }}</span>
2026-04-03 11:10:58 +08:00
<svg class="banner-select-chevron" viewBox="0 0 24 24" width="40" height="40" aria-hidden="true"
focusable="false">
2026-04-03 02:05:29 +08:00
<path fill="#ffffff" d="M7 10l5 5 5-5H7z" />
</svg>
</span>
<el-dropdown-menu slot="dropdown" class="banner-type-dropdown-popper">
<el-dropdown-item command="全部科考船">全部科考船</el-dropdown-item>
2026-04-03 11:10:58 +08:00
<el-dropdown-item v-for="item in titles" :key="item.tsy_id" :command="item.report_name">
2026-04-03 02:05:29 +08:00
{{ item.report_name }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<p class="banner-title-picker__hint">点击选择</p>
</div>
2025-10-31 16:15:28 +08:00
<div class="numbers">
<div v-for="(item, index) in numbers" :key="index" class="item">
<div class="value">{{ item.value }}<span class="unit">{{ item.unit }}</span></div>
<div class="label">{{ item.label }}</div>
</div>
</div>
</div>
2025-10-31 16:15:28 +08:00
<!-- 地图板块-->
<div class="map-module">
<div class="bezel">
<div class="map-title">参航单位</div>
2026-04-02 14:29:10 +08:00
<div id="workUnitMap_ship" ref="workUnitMap_ship" style="height: 100%;width:100%;" />
</div>
2025-10-31 16:15:28 +08:00
<div class="bezel">
<div class="map-title">航次地图</div>
2026-04-03 02:05:29 +08:00
<div class="map-year-panel">
<span class="map-year-label">年份</span>
2026-04-03 11:10:58 +08:00
<el-date-picker v-model="voyageYear" type="year" size="small" placeholder="全部" class="map-year" clearable
format="yyyy" @change="selectVoyageYear" />
2026-04-03 02:05:29 +08:00
</div>
2026-04-02 14:29:10 +08:00
<div id="voyageMap_ship" ref="voyageMap_ship" style="height: 100%;width:100%;" />
</div>
2025-10-31 16:15:28 +08:00
</div>
<!-- echarts板块-->
<div class="echarts-module">
<div class="bezel">
2026-04-02 14:29:10 +08:00
<BarChart :title="barData1.title" :chart-data="barData1.salesData" :categories="barData1.productCategories"
chart-type="single" />
2025-10-31 16:15:28 +08:00
</div>
2026-04-03 02:05:29 +08:00
<div class="bezel">
2026-04-03 11:10:58 +08:00
<BarChart :title="barDataDays.title" :chart-data="barDataDays.salesData"
:categories="barDataDays.productCategories" chart-type="single" />
2026-04-03 02:05:29 +08:00
</div>
2025-10-31 16:15:28 +08:00
<div class="bezel">
2026-04-03 11:10:58 +08:00
<BarChart :title="barData2.title" :chart-data="barData2.salesData" :categories="barData2.productCategories"
chart-type="stacked" stack-name="新增单位数" />
2025-10-31 16:15:28 +08:00
</div>
<div class="bezel">
2026-04-02 14:29:10 +08:00
<BarChart :title="barData3.title" :chart-data="barData3.salesData" :categories="barData3.productCategories" />
2025-10-31 16:15:28 +08:00
</div>
<div class="bezel">
2026-04-02 14:29:10 +08:00
<BarChart :title="barData4.title" :chart-data="barData4.salesData" :categories="barData4.productCategories" />
2025-10-31 16:15:28 +08:00
</div>
<div class="bezel">
2026-04-02 14:29:10 +08:00
<PieChart :chart-data="pieData" title="参航单位类型" chart-type="ring" />
</div>
</div>
</div>
</template>
<script>
2025-10-31 16:15:28 +08:00
import BarChart from './components/BarChart.vue'
import PieChart from './components/PieChart.vue'
import { reportList, shipTotal, shipUnit, shipUnitYear, shipVoyage } from '../../api/statistics'
import { getYearRange, filterDictItems } from '../../utils/index'
2026-04-03 11:27:58 +08:00
import { initMapbox } from '@/utils/mapbox-utils'
import { loadVectorLayer, loadJsonPointFeature } from '@/utils/vector-layer-utils'
import { ColorGenerator } from '@/utils/color-generator'
2026-04-02 14:29:10 +08:00
export default {
components: {
2025-10-31 16:15:28 +08:00
BarChart,
PieChart
},
data() {
return {
2025-10-31 16:15:28 +08:00
currentTitle: '全部科考船',
titles: [],
numbers: [
{
2025-10-31 16:15:28 +08:00
label: '航次',
value: '',
unit: '次'
},
{
2025-10-31 16:15:28 +08:00
label: '航次天数',
value: '',
unit: '天'
},
{
2025-10-31 16:15:28 +08:00
label: '参航单位',
value: '',
unit: '家'
},
{
2025-10-31 16:15:28 +08:00
label: '数据样品个数',
value: '',
unit: '个'
},
{
2025-10-31 16:15:28 +08:00
label: '累计里程',
value: '',
2026-04-03 02:05:29 +08:00
unit: 'km'
}
],
2025-10-31 16:15:28 +08:00
voyageYear: '',
barData1: {},
2026-04-03 02:05:29 +08:00
/** 年度航次天数(与 barData1 同源接口按年) */
barDataDays: {},
2025-10-31 16:15:28 +08:00
barData2: {},
barData3: {},
barData4: {},
pieData: []
}
},
2025-10-31 16:15:28 +08:00
created() {
this.getTypeList()
this.getShipList()
this.getShipUnit()
this.gitShipVoyage()
this.gitShipUnitYear()
this.getChartBar({ year: '2025' })
},
mounted() {
2026-04-03 11:27:58 +08:00
initMapbox('workUnitMap_ship', {
tileKey: 'gaode',
2026-04-02 14:29:10 +08:00
zoom: 3,
center: [110, 31],
minZoom: 2,
maxZoom: 29
2026-04-03 11:27:58 +08:00
})
initMapbox('voyageMap_ship', {
tileKey: 'GEBCO_basemap_NCEI',
2026-04-03 11:10:58 +08:00
zoom: 3,
2026-04-02 14:29:10 +08:00
center: [113, 15],
minZoom: 2,
maxZoom: 29
2026-04-03 11:17:11 +08:00
})
2025-11-18 15:33:41 +08:00
},
beforeDestroy() {
2026-04-03 12:04:20 +08:00
const unitMap = Vue.config.maps && Vue.config.maps['workUnitMap_ship']
if (unitMap) {
unitMap.remove()
delete Vue.config.maps['workUnitMap_ship']
}
const voyageMap = Vue.config.maps && Vue.config.maps['voyageMap_ship']
if (voyageMap) {
voyageMap.remove()
delete Vue.config.maps['voyageMap_ship']
}
},
methods: {
2025-10-31 16:15:28 +08:00
// 科考船数据
getTypeList() {
reportList().then(res => {
this.titles = filterDictItems(res.array, '科考船')
})
},
// 选择科考船
handleCommand(command) {
this.currentTitle = command
2026-04-03 11:10:58 +08:00
// this.removeSingleLineImg()
2025-10-31 16:15:28 +08:00
if (command === '全部科考船') {
this.getShipList()
this.gitShipVoyage()
this.gitShipUnitYear()
this.getChartBar({ year: '2025' })
} else {
this.getShipList({ ship_name: command })
this.gitShipVoyage({ ship_name: command })
this.gitShipUnitYear({ ship_name: command })
this.getChartBar({ year: '2025', ship_name: command })
}
},
2025-10-31 16:15:28 +08:00
// 汇总统计数据
getShipList(params = {}) {
shipTotal(params).then(res => {
const obj = res.array[0]
this.numbers[0].value = obj.member_total
this.numbers[1].value = obj.days_total
this.numbers[2].value = obj.unit_total
this.numbers[3].value = obj.dataset_total
this.numbers[4].value = obj.mileage_total
})
},
// 参航单位统计
getShipUnit() {
shipUnit().then(res => {
2026-04-03 11:27:58 +08:00
const geojson = {
type: 'FeatureCollection',
2026-04-02 14:29:10 +08:00
features: []
2026-04-03 11:27:58 +08:00
}
2026-04-02 14:29:10 +08:00
res.array.forEach(element => {
geojson.features.push({
2026-04-03 11:27:58 +08:00
type: 'Feature',
2026-04-02 14:29:10 +08:00
geometry: {
2026-04-03 11:27:58 +08:00
type: 'Point',
2026-04-02 14:29:10 +08:00
coordinates: [element.unit_lon, element.unit_lat]
},
properties: {
unit_name: element.unit_name,
unit_type: element.unit_type,
create_time: element.create_time,
tsy_id: element.tsy_id
}
2026-04-03 11:27:58 +08:00
})
})
loadJsonPointFeature('workUnit', 'blue', geojson, 'unit_name', 'workUnitMap_ship')
2025-11-18 15:33:41 +08:00
2025-10-31 16:15:28 +08:00
const typeCount = res.array.reduce((acc, unit) => {
const type = unit.unit_type
acc[type] = (acc[type] || 0) + 1 // 如果类型已存在则计数+1否则初始化为1
return acc
}, {})
this.pieData = Object.entries(typeCount).map(([type, count]) => ({
name: type,
value: count
}))
})
},
2025-11-18 15:33:41 +08:00
2025-10-31 16:15:28 +08:00
// 航次统计
gitShipVoyage(params = {}) {
shipVoyage(params).then(res => {
2026-04-03 11:27:58 +08:00
let i = 0
const colors = ColorGenerator.generateDivergingColors(res.array.length)
2025-10-31 16:15:28 +08:00
// 添加轨迹图层
res.array.forEach(item => {
2026-04-02 14:29:10 +08:00
// 加载轨迹图层
2026-04-03 11:27:58 +08:00
loadVectorLayer(item.voyage_name, ['line', 'symbol'], [colors[i], '#FFFFFF'], 'visible', 'voyageMap_ship', 'dsds')
i++
2025-10-31 16:15:28 +08:00
})
})
},
2026-04-02 14:29:10 +08:00
2025-10-31 16:15:28 +08:00
// 选择航次地图年份
selectVoyageYear(val) {
const shipName = this.currentTitle === '全部科考船' ? '' : this.currentTitle
if (val) {
2026-04-03 11:10:58 +08:00
// this.removeSingleLineImg()
2025-10-31 16:15:28 +08:00
const params = getYearRange(val)
this.gitShipVoyage({ ...params, ship_name: shipName })
} else {
this.gitShipVoyage({ ship_name: shipName })
}
2025-10-31 16:15:28 +08:00
},
// 参航单位年度
gitShipUnitYear(params = {}) {
shipUnitYear(params).then(res => {
const originalData = res.array
const sortedData = originalData.sort((a, b) => a.voyage_year - b.voyage_year)
this.barData2 = {
title: '年度参航单位',
salesData: [
{
name: '参航单位',
data: sortedData.map(item => item.unit_total),
stack: '新增单位数'
},
{
name: '新增单位',
data: sortedData.map(item => item.year_unit_total),
stack: '新增单位数'
}
],
productCategories: sortedData.map(item => item.voyage_year.toString())
}
})
},
// 柱状图数据
getChartBar(params) {
shipTotal(params).then(res => {
const originalData = res.array
const sortedData = originalData.sort((a, b) => a.year - b.year)
this.barData1 = {
title: '年度航次数',
salesData: sortedData.map(item => item.member_total),
productCategories: sortedData.map(item => item.year.toString())
}
2026-04-03 02:05:29 +08:00
this.barDataDays = {
title: '年度航次天数',
salesData: sortedData.map(item => item.days_total),
productCategories: sortedData.map(item => item.year.toString())
}
2025-10-31 16:15:28 +08:00
this.barData3 = {
title: '样品集个数',
salesData: sortedData.map(item => item.dataset_total),
productCategories: sortedData.map(item => item.year.toString())
}
this.barData4 = {
title: '里程数',
salesData: sortedData.map(item => item.mileage_total),
productCategories: sortedData.map(item => item.year.toString())
}
})
}
}
}
</script>
<style scoped lang="scss">
2025-10-31 16:15:28 +08:00
.statistics {
background-color: #ebf1f7;
.banner {
2026-04-03 11:17:11 +08:00
background-color: #012458;
2025-10-31 16:15:28 +08:00
background-image: url(../../../static/images/bannerny1.jpg);
2026-04-03 02:05:29 +08:00
background-repeat: no-repeat;
background-position: center;
2026-04-03 11:17:11 +08:00
background-size: contain;
width: 100%;
2025-10-31 16:15:28 +08:00
height: 480px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
2026-04-03 02:05:29 +08:00
.banner-title-picker {
display: flex;
flex-direction: column;
align-items: center;
2025-10-31 16:15:28 +08:00
margin-bottom: 40px;
2026-04-03 02:05:29 +08:00
padding: 12px 16px 0;
max-width: 100%;
}
.banner-type-dropdown {
display: inline-block;
width: auto;
max-width: 100%;
vertical-align: top;
}
.banner-select-trigger {
display: inline-flex;
align-items: center;
gap: 12px;
padding: 2px 0;
border: none;
border-radius: 0;
background: transparent;
box-shadow: none;
2025-10-31 16:15:28 +08:00
cursor: pointer;
2026-04-03 02:05:29 +08:00
user-select: none;
outline: none;
&:hover .banner-select-text {
opacity: 0.92;
}
&:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.65);
outline-offset: 6px;
}
}
.banner-select-text {
font-size: 52px;
font-weight: bold;
color: #fff;
line-height: 1.15;
max-width: #{"min(90vw, 920px)"};
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.banner-select-chevron {
flex-shrink: 0;
color: #ffffff;
}
.banner-title-picker__hint {
margin: 14px 0 0;
padding: 0;
font-size: 14px;
font-weight: 400;
letter-spacing: 0.12em;
color: rgba(255, 255, 255, 0.78);
line-height: 1.4;
}
2025-10-31 16:15:28 +08:00
.numbers {
display: flex;
2025-10-31 16:15:28 +08:00
justify-content: space-between;
gap: 80px;
.item {
display: flex;
flex-direction: column;
justify-content: center;
2025-10-31 16:15:28 +08:00
align-items: center;
2026-04-02 14:29:10 +08:00
2025-10-31 16:15:28 +08:00
.value {
font-size: 56px;
font-weight: bold;
2026-04-02 14:29:10 +08:00
2025-10-31 16:15:28 +08:00
.unit {
font-size: 26px;
}
}
2026-04-02 14:29:10 +08:00
2025-10-31 16:15:28 +08:00
.label {
font-size: 18px;
}
}
}
}
2026-04-02 14:29:10 +08:00
2025-10-31 16:15:28 +08:00
.map-module {
padding: 50px 50px;
display: flex;
justify-content: space-between;
2025-10-31 16:15:28 +08:00
gap: 50px;
2026-04-02 14:29:10 +08:00
2025-10-31 16:15:28 +08:00
.bezel {
flex: 1;
width: 100%;
height: 520px;
border-radius: 10px;
overflow: hidden;
2025-10-31 16:15:28 +08:00
border: 1px solid #ccc;
position: relative;
.map-title {
position: absolute;
top: 20px;
left: 20px;
2025-10-31 16:15:28 +08:00
color: white;
z-index: 8888;
font-size: 22px;
}
2026-04-03 02:05:29 +08:00
.map-year-panel {
2025-10-31 16:15:28 +08:00
position: absolute;
2026-04-03 02:05:29 +08:00
top: 16px;
right: 16px;
2025-10-31 16:15:28 +08:00
z-index: 8888;
2026-04-03 02:05:29 +08:00
display: flex;
align-items: center;
gap: 10px;
padding: 6px 10px 6px 12px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.68);
border: 1px solid rgba(255, 255, 255, 0.55);
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
transition:
background 0.25s ease,
border-color 0.25s ease,
box-shadow 0.25s ease,
transform 0.25s ease;
&:hover {
background: rgba(255, 255, 255, 0.82);
border-color: rgba(255, 255, 255, 0.92);
transform: translateY(-2px);
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}
}
.map-year-label {
font-size: 13px;
font-weight: 600;
color: rgba(28, 42, 58, 0.78);
letter-spacing: 0.04em;
user-select: none;
}
.map-year {
width: 120px;
::v-deep .el-input__inner {
height: 34px;
line-height: 34px;
padding-left: 30px;
padding-right: 28px;
border-radius: 8px;
border: 1px solid rgba(0, 50, 90, 0.12);
background: rgba(255, 255, 255, 0.55);
font-size: 14px;
font-weight: 500;
color: #1c2d3f;
transition:
background 0.2s ease,
border-color 0.2s ease,
box-shadow 0.2s ease;
}
::v-deep .el-input__inner:hover,
::v-deep .el-input__inner:focus {
border-color: rgba(0, 90, 150, 0.42);
background: rgba(255, 255, 255, 0.78);
box-shadow: 0 2px 8px rgba(0, 50, 100, 0.1);
}
::v-deep .el-input__prefix {
left: 8px;
}
::v-deep .el-input__suffix {
right: 6px;
}
2025-10-31 16:15:28 +08:00
}
}
}
2026-04-02 14:29:10 +08:00
2025-10-31 16:15:28 +08:00
.echarts-module {
padding: 0 50px 50px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 50px;
grid-auto-rows: 300px;
.bezel {
width: 100%;
height: 100%;
border-radius: 10px;
overflow: hidden;
border: 1px solid #ccc;
position: relative;
.map-title {
position: absolute;
top: 20px;
left: 20px;
color: white;
z-index: 8888;
font-size: 22px;
}
}
}
}
2026-04-03 02:05:29 +08:00
</style>
<style lang="scss">
.banner-type-dropdown-popper.el-dropdown-menu {
min-width: 240px;
max-height: #{"min(60vh, 420px)"};
overflow-y: auto;
padding: 6px 0;
border-radius: 8px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
2025-10-31 16:15:28 +08:00
2026-04-03 02:05:29 +08:00
.banner-type-dropdown-popper.el-dropdown-menu .el-dropdown-menu__item {
font-size: 16px;
line-height: 22px;
padding: 14px 22px;
}
</style>