12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181 |
- <template>
- <div class="page-container">
- <el-row :gutter="16" class="summary">
- <!-- 原有的统计卡片部分保持不变 -->
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="device.total || 0"
- icon="fa-solid:project-diagram"
- icon-bg-color="text-blue-500"
- icon-color="bg-blue-100"
- :title="t('stat.deviceCount')"
- />
- </el-col>
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="maintain.total || 0"
- icon="fa-solid:list"
- icon-bg-color="text-pink-500"
- icon-color="bg-blue-100"
- :title="t('stat.maintenanceOrder')"
- />
- </el-col>
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="fill.unfilledCount || 0"
- icon="fa-solid:times-circle"
- icon-bg-color="text-purple-500"
- icon-color="bg-purple-100"
- :title="t('stat.operationNotFilled')"
- />
- </el-col>
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="fill.filledCount || 0"
- icon="fa-solid:award"
- icon-bg-color="text-purple-500"
- icon-color="bg-purple-100"
- :title="t('stat.operationFilled')"
- />
- </el-col>
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="by.todo || 0"
- icon="fa-solid:times-circle"
- icon-bg-color="text-green-500"
- icon-color="bg-green-100"
- :title="t('stat.notMaintained')"
- />
- </el-col>
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="by.finished || 0"
- icon="fa-solid:award"
- icon-bg-color="text-green-500"
- icon-color="bg-green-100"
- :title="t('stat.maintained')"
- />
- </el-col>
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="inspectt.todo || 0"
- icon="fa-solid:times-circle"
- icon-bg-color="text-yellow-500"
- icon-color="bg-yellow-100"
- :title="t('stat.notInspected')"
- />
- </el-col>
- <el-col :sm="3" :xs="12">
- <SummaryCard
- :value="inspectt.finished || 0"
- icon="fa-solid:award"
- icon-bg-color="text-yellow-500"
- icon-color="bg-yellow-100"
- :title="t('stat.inspected')"
- />
- </el-col>
- <!-- 其他统计卡片... -->
- </el-row>
- <!-- 第二行:图表行 -->
- <el-row :gutter="16" class="mb-4 mt-3">
- <el-col :span="6">
- <el-card class="chart-card" shadow="never">
- <template #header>
- <div class="flex items-center">
- <span class="text-base font-medium" style="color: #b6c8da">{{t('stat.deviceStatus')}}</span>
- </div>
- </template>
- <div ref="statusChartRef" class="h-[320px]"></div>
- </el-card>
- </el-col>
- <el-col :span="7">
- <el-card class="chart-card" shadow="never">
- <template #header>
- <div class="flex items-center">
- <span class="text-base font-medium" style="color: #b6c8da">{{t('stat.projectDevice')}}</span>
- </div>
- </template>
- <div ref="topContainer" class="h-[320px]"></div>
- </el-card>
- </el-col>
- <!-- <el-col :span="7">-->
- <!-- <el-card class="chart-card" shadow="never">-->
- <!-- <template #header>-->
- <!-- <div class="flex items-center">-->
- <!-- <span class="text-base font-medium" style="color: #b6c8da">设备类别TOP5数量</span>-->
- <!-- </div>-->
- <!-- </template>-->
- <!-- <div ref="topContainer" class="h-[320px]"></div>-->
- <!-- </el-card>-->
- <!-- </el-col>-->
- <el-col :span="11">
- <el-card class="chart-card" shadow="never">
- <template #header>
- <div class="flex items-center justify-between">
- <span class="text-base font-medium" style="color: #b6c8da">{{t('stat.orderCount')}}</span>
- </div>
- </template>
- <div ref="qxRef" class="h-[320px]"></div>
- </el-card>
- </el-col>
- </el-row>
- <!-- 新增:修井完成情况图表 -->
- <el-row :gutter="16" class="mb-4">
- <el-col :span="8">
- <div class="flex flex-col justify-between">
- <el-card class="safety-days-card chart-card h-[230px]" shadow="never">
- <template #header>
- <div class="flex items-center">
- <span class="text-base font-medium" style="color: #b6c8da">{{t('stat.safeProduction')}}</span>
- </div>
- </template>
- <div class="safety-days-content">
- <div class="days-number">{{ 165 }}</div>
- <div class="days-label">day</div>
- <div class="safety-desc">{{t('stat.daysToDate')}}</div>
- </div>
- </el-card>
- <el-card class="chart-card mt-1" shadow="never">
- <template #header>
- <div class="flex items-center">
- <span class="text-base font-medium" style="color: #b6c8da">{{t('stat.drillingCompletion')}}</span>
- </div>
- </template>
- <div ref="drillingWellChartRef" class="h-[170px]"></div>
- </el-card>
- </div>
- </el-col>
- <el-col :span="8">
- <el-card class="chart-card" shadow="never">
- <template #header>
- <div class="flex items-center">
- <span class="text-base font-medium" style="color: #b6c8da">{{t('stat.drillingWork')}}</span>
- </div>
- </template>
- <div ref="drillingWorkloadChartRef" class="h-[405px]"></div>
- </el-card>
- </el-col>
- <el-col :span="8">
- <el-card class="chart-card" shadow="never">
- <template #header>
- <div class="flex items-center">
- <span class="text-base font-medium" style="color: #b6c8da">{{t('stat.wellWorkoverWorkload')}}</span>
- </div>
- </template>
- <div ref="repairWorkloadChartRef" class="h-[405px]"></div>
- </el-card>
- </el-col>
- </el-row>
- </div>
- </template>
- <script setup lang="ts" name="Index">
- import * as echarts from 'echarts/core'
- import { BarChart, GaugeChart, LineChart, PieChart } from 'echarts/charts' // 显式导入柱状图模块
- import {
- GridComponent,
- LegendComponent,
- TitleComponent,
- ToolboxComponent,
- TooltipComponent
- } from 'echarts/components'
- import { LabelLayout, UniversalTransition } from 'echarts/features'
- import { CanvasRenderer } from 'echarts/renderers'
- import { useElementSize } from '@vueuse/core'
- import { IotStatisticsSummaryRespVO } from '@/api/iot/statistics'
- import { IotStatApi } from '@/api/pms/stat'
- import SummaryCard from '@/components/SummaryCard/index.vue'
- import { onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
- // TODO @super:参考下 /Users/yunai/Java/yudao-ui-admin-vue3/src/views/mall/home/index.vue,拆一拆组件
- /** IoT 首页 */
- defineOptions({ name: 'IotRyStat' })
- // TODO @super:使用下 Echart 组件,参考 yudao-ui-admin-vue3/src/views/mall/home/components/TradeTrendCard.vue 等
- echarts.use([
- TooltipComponent,
- LegendComponent,
- PieChart,
- CanvasRenderer,
- LabelLayout,
- TitleComponent,
- ToolboxComponent,
- GridComponent,
- LineChart,
- UniversalTransition,
- GaugeChart,
- BarChart
- ])
- const { t } = useI18n() // 国际化
- const dateRange = ref<[Date, Date] | null>(null)
- const by = ref({
- todo: undefined,
- finished: undefined
- })
- const fill = ref({
- filledCount: undefined,
- unfilledCount: undefined
- })
- const inspectt = ref({
- finished: 0,
- todo: 0
- })
- const queryParams = reactive({
- startTime: Date.now() - 7 * 24 * 60 * 60 * 1000, // 设置默认开始时间为 7 天前
- endTime: Date.now() // 设置默认结束时间为当前时间
- })
- const backendData = ref([])
- const statusChartRef = ref() // 设备数量统计的图表
- // const materialChartRef = ref() // 设备数量统计的图表
- const drillingWorkloadChartRef = ref()
- const repairWorkloadChartRef = ref()
- // 基础统计数据
- // TODO @super:初始为 -1,然后界面展示先是加载中?试试用 cursor 改哈
- const statsData = ref<IotStatisticsSummaryRespVO>({
- productCategoryCount: 0,
- productCount: 0,
- deviceCount: 0,
- deviceMessageCount: 0,
- productCategoryTodayCount: 0,
- productTodayCount: 0,
- deviceTodayCount: 0,
- deviceMessageTodayCount: 0,
- deviceOnlineCount: 0,
- deviceOfflineCount: 0,
- deviceInactiveCount: 0,
- productCategoryDeviceCounts: {}
- })
- const device = ref({
- total: undefined,
- today: undefined
- })
- const maintain = ref({
- total: undefined,
- today: undefined
- })
- const work = ref({
- total: undefined,
- today: undefined
- })
- const inspect = ref({
- total: undefined,
- today: undefined
- })
- const status = ref({
- finished: 0,
- todo: 0
- })
- const todayStatus = ref({
- finished: 0,
- todo: 0
- })
- const typeData = ref({})
- const materialData = ref({})
- const orderSevenData = ref({})
- const safe = ref()
- // 新增:修井完成情况数据
- const repairWellData = ref({
- xAxis: ['小修10队', '小修8队', '小修9队'],
- series: [
- { name: '日累完成井数', data: [10, 15, 20] },
- { name: '月累完成井数', data: [50, 60, 70] },
- { name: '年累完成井数', data: [200, 220, 250] }
- ]
- })
- // 新增:钻井完成情况数据
- const drillingWellData = ref({
- xAxis: ['50010队', '四川宝石带压作业队'],
- series: [
- // { name: '日累完成井数', data: [5, 8] },
- { name: '月累完成井数', data: [40, 30] },
- { name: '年累完成井数', data: [180, 150] }
- ]
- })
- const drillingWorkloadData = ref({
- xAxis: ['SCP项目部', '伊拉克项目部', '陕西项目部'],
- series: [
- { name: '日累进尺', data: [150, 100, 200] },
- { name: '月累进尺', data: [1000, 1200, 1500] },
- { name: '年累进尺', data: [2000, 5000, 10000] }
- ]
- })
- // 新增:修井工作量情况数据
- const repairWorkloadData = ref({
- xAxis: ['SCP项目部', '伊拉克项目部', '陕西项目部'],
- series: [
- // { name: '日累进尺', data: [120,80, 160] },
- { name: '月完井数', data: [1300, 800, 1000] },
- { name: '年完井数', data: [4000, 5000, 7000] }
- ]
- })
- const repairWellChartRef = ref()
- const drillingWellChartRef = ref()
- /** 获取统计数据 */
- const getStats = () => {
- // 获取基础统计数据
- IotStatApi.getDeviceCount('ry').then((res) => {
- device.value = res
- })
- IotStatApi.getMaintainCount('ry').then((res) => {
- maintain.value = res
- })
- IotStatApi.getMainWorkCount().then((res) => {
- work.value = res
- })
- IotStatApi.getInspectCount().then((res) => {
- inspect.value = res
- })
- IotStatApi.getMaintenanceStatus('ry').then((res) => {
- status.value = res
- // initCharts()
- })
- // IotStatApi.getMaintenanceTodayStatus().then((res) => {
- // todayStatus.value = res
- // })
- IotStatApi.getDeviceStatusCount('ry').then((res) => {
- typeData.value = res
- initDeviceStatusCharts()
- })
- IotStatApi.getSafeCount().then((res) => {
- safe.value = res
- })
- // IotStatApi.getMaterial().then((res) => {
- // materialData.value = res
- // initMaterials()
- // })
- IotStatApi.getOrderSeven('ry').then((res) => {
- orderSevenData.value = res
- initQxChart()
- })
- IotStatApi.getMaintenanceStatus('ry').then((res) => {
- by.value = res
- })
- const fillQueryParams = reactive({
- startTime: Date.now() - 7 * 24 * 60 * 60 * 1000, // 设置默认开始时间为 7 天前
- endTime: Date.now(), // 设置默认结束时间为当前时间
- createTime: [],
- deptId: null, // 选中的部门ID
- status: null // 填写状态
- })
- IotStatApi.getInspectStatuss(fillQueryParams, 'ry').then((res) => {
- inspectt.value = res
- })
- fillQueryParams.deptId = '158'
- IotStatApi.getDeptStatistics(fillQueryParams).then((res) => {
- fill.value = res.totalList[0] || []
- })
- IotStatApi.getProject('ry').then((res) => {
- typeData.value = res;
- initProjectCharts()
- })
- }
- const initDrillingWorkloadChart = () => {
- if (!drillingWorkloadChartRef.value) return
- const chart = echarts.init(drillingWorkloadChartRef.value)
- const option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- legend: {
- data: drillingWorkloadData.value.series.map((item) => item.name),
- textStyle: {
- color: '#B6C8DA'
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: drillingWorkloadData.value.xAxis,
- axisLabel: {
- color: '#B6C8DA'
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- yAxis: {
- type: 'value',
- name: '进尺(米)',
- axisLabel: {
- color: '#B6C8DA'
- },
- splitLine: {
- show: true, // 显示水平网格线(默认显示)
- lineStyle: {
- // 水平网格线颜色(可设置为纯色或带透明度的颜色)
- color: '#457794', // 浅灰色半透明
- // 可选:设置线条类型(实线/虚线/点线)
- type: 'dashed'
- }
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- series: drillingWorkloadData.value.series.map((item) => ({
- name: item.name,
- type: 'bar',
- data: item.data
- }))
- }
- chart.setOption(option)
- }
- // 新增:初始化修井工作量情况图表
- const initRepairWorkloadChart = () => {
- if (!repairWorkloadChartRef.value) return
- const chart = echarts.init(repairWorkloadChartRef.value)
- const option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- legend: {
- data: repairWorkloadData.value.series.map((item) => item.name),
- textStyle: {
- color: '#B6C8DA'
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: repairWorkloadData.value.xAxis,
- axisLabel: {
- color: '#B6C8DA'
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- yAxis: {
- type: 'value',
- name: '进尺(米)',
- axisLabel: {
- color: '#B6C8DA'
- },
- splitLine: {
- show: true, // 显示水平网格线(默认显示)
- lineStyle: {
- // 水平网格线颜色(可设置为纯色或带透明度的颜色)
- color: '#457794', // 浅灰色半透明
- // 可选:设置线条类型(实线/虚线/点线)
- type: 'dashed'
- }
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- series: repairWorkloadData.value.series.map((item) => ({
- name: item.name,
- type: 'bar',
- data: item.data
- }))
- }
- chart.setOption(option)
- }
- /** 初始化图表 */
- const initDeviceStatusCharts = () => {
- // 设备数量统计
- echarts.init(statusChartRef.value).setOption({
- tooltip: {
- trigger: 'item'
- },
- legend: {
- orient: 'horizontal', // 水平排列图例项
- bottom: '0%', // 放置在底部
- icon: 'circle',
- textStyle: {
- color: '#B6C8DA'
- }
- },
- series: [
- {
- name: '',
- type: 'pie',
- radius: ['50%', '80%'],
- avoidLabelOverlap: false,
- center: ['50%', '46%'],
- label: {
- show: false,
- position: 'outside',
- color: 'white'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 15,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: typeData.value
- }
- ]
- })
- }
- // 自适应调整
- const handleResize = () => {
- topInstance?.resize()
- }
- const topContainer = ref(null)
- let topInstance = null
- // 响应式容器尺寸
- const { width, height } = useElementSize(topContainer)
- // 处理数据(排序+限制5条)
- const processedData = () => {
- const data = IotStatApi.getDeviceTypeCount()
- backendData.value = data
- return [...backendData.value].sort((a, b) => a.value - b.value)
- }
- const fetchTop = () => {
- IotStatApi.getDeviceTypeCount().then((res) => {
- backendData.value = res
- })
- }
- watch(
- backendData,
- () => {
- updateTopChart()
- },
- { deep: true }
- )
- // 初始化图表配置
- const getTopOption = () => {
- // backendData.value = data
- const data = backendData.value.sort((a, b) => a.value - b.value)
- return {
- tooltip: {
- trigger: 'axis',
- axisPointer: { type: 'shadow' },
- formatter: (params) => {
- const item = params[0]
- return `${item.name}<br/>${item.marker} ${item.value.toLocaleString()}`
- }
- },
- grid: {
- height: '200px',
- left: '6%',
- right: '6%',
- bottom: '18%',
- containLabel: true
- },
- xAxis: {
- type: 'value',
- axisLabel: {
- color: '#B6C8DA',
- formatter: (value) => {
- if (value >= 10000) return `${(value / 10000).toFixed(1)}万`
- return value.toLocaleString()
- }
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA' // X轴线白色半透明
- }
- },
- splitLine: {
- show: true, // 显示水平网格线(默认显示)
- lineStyle: {
- // 水平网格线颜色(可设置为纯色或带透明度的颜色)
- color: '#457794', // 浅灰色半透明
- // 可选:设置线条类型(实线/虚线/点线)
- type: 'dashed'
- }
- }
- },
- yAxis: {
- type: 'category',
- data: data.map((item) => item.category),
- axisTick: { show: false },
- axisLabel: { color: '#B6C8DA' },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA' // X轴线白色半透明
- }
- }
- },
- series: [
- {
- type: 'bar',
- data: data.map((item) => item.value),
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
- { offset: 0, color: '#83bff6' },
- { offset: 0.7, color: '#188df0' },
- { offset: 1, color: '#188df0' }
- ]),
- borderRadius: [0, 8, 8, 0]
- },
- label: {
- show: true,
- position: 'right',
- formatter: '{@value}',
- color: '#B6C8DA',
- fontWeight: 'bold'
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- }
- }
- // // 初始化图表
- // const initTopChart = async () => {
- // await IotStatApi.getDeviceTypeCount('ry').then((res) => {
- // backendData.value = res
- // })
- // if (!topContainer.value) return
- // topInstance = echarts.init(topContainer.value)
- // updateTopChart()
- // }
- //
- // // 更新图表
- // const updateTopChart = () => {
- // if (!topInstance) return
- // topInstance.setOption(getTopOption())
- // }
- const initProjectCharts = () => {
- const chart = echarts.init(topContainer.value);
- chart.setOption({
- tooltip: {
- trigger: 'item'
- },
- legend: {
- // top: '5%',
- // right: '10%',
- // align: 'center',
- orient: 'horizontal', // 水平排列图例项
- bottom: '0%', // 放置在底部
- icon: 'circle',
- textStyle: {
- color:'#B6C8DA'
- }
- },
- series: [
- {
- name: '',
- type: 'pie',
- radius: ['0%', '70%'],
- avoidLabelOverlap: false,
- center: ['50%', '45%'],
- label: {
- show: false,
- position: 'outside',
- color:'#B6C8DA'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 15,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: true
- },
- data: typeData.value
- }
- ]})
- }
- // 自适应调整
- watch([width, height], () => {
- topInstance?.resize()
- })
- const activeDom = ref(null)
- let activeInstance = null
- const activeData = ref([])
- const initActiveChart = async () => {
- if (!activeDom.value) return
- activeData.value = await IotStatApi.getDeptCount()
- activeInstance = echarts.init(activeDom.value)
- const option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: { type: 'shadow' },
- formatter: (params) => `
- ${params[0].name}<br/>
- ${params[0].marker} 总人数: ${params[0].value}<br/>
- ${params[1].marker} 活跃人数: ${params[1].value}
- `
- },
- legend: {
- data: ['总人数', '活跃人数'],
- top: 30
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: activeData.value.map((item) => item.department),
- axisLabel: {
- interval: 0,
- rotate: 0
- }
- },
- yAxis: {
- type: 'value',
- name: '人数',
- splitLine: {
- show: true,
- lineStyle: { type: 'dashed' }
- }
- },
- series: [
- {
- name: '总人数',
- type: 'bar',
- data: activeData.value.map((item) => item.total),
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: '#5470c6' },
- { offset: 1, color: '#83bff6' }
- ])
- },
- barWidth: 30
- },
- {
- name: '活跃人数',
- type: 'bar',
- data: activeData.value.map((item) => item.active),
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: '#91cc75' },
- { offset: 1, color: '#e6f4d2' }
- ])
- },
- barWidth: 30
- }
- ]
- }
- activeInstance.setOption(option)
- }
- const qxRef = ref(null)
- let qxInstance = null
- // 生成近12个月份 (包含当年和去年)
- const generateMonths = () => {
- const months = []
- const date = new Date()
- date.setMonth(date.getMonth() + 1, 1) // 从下个月开始倒推
- for (let i = 0; i < 12; i++) {
- date.setMonth(date.getMonth() - 1)
- months.push(`${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}`)
- }
- return months.reverse()
- }
- const initQxChart = () => {
- if (!qxRef.value) return
- qxInstance = echarts.init(qxRef.value)
- debugger
- const option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'cross',
- label: {
- backgroundColor: '#6a7985'
- }
- }
- },
- legend: {
- data: orderSevenData.value.series.map((item) => item.name),
- top: 30,
- textStyle: {
- color: '#B6C8DA'
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: orderSevenData.value.xAxis,
- axisLabel: {
- color: '#B6C8DA',
- formatter: (value) => value.split('-').join('/') // 显示为 2023/01
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- yAxis: [
- {
- type: 'value',
- axisLabel: {
- color: '#B6C8DA',
- formatter: '{value}'
- },
- splitLine: {
- show: true, // 显示水平网格线(默认显示)
- lineStyle: {
- // 水平网格线颜色(可设置为纯色或带透明度的颜色)
- color: '#457794', // 浅灰色半透明
- // 可选:设置线条类型(实线/虚线/点线)
- type: 'dashed'
- }
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- },
- position: 'left' // 左侧 Y 轴
- },
- {
- type: 'value',
- axisLabel: {
- formatter: '{value}'
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- },
- position: 'right', // 右侧 Y 轴
- splitLine: {
- show: false // 隐藏右侧 Y 轴的分割线
- }
- }
- ],
- series: orderSevenData.value.series.map((item, index) => {
- // 假设前两条曲线使用左侧 Y 轴,后两条曲线使用右侧 Y 轴
- const yAxisIndex = index < 2 ? 0 : 1
- return {
- name: item.name,
- type: 'line',
- smooth: true,
- symbol: 'circle',
- symbolSize: 8,
- itemStyle: {
- color: ['#5470c6', '#f1d209', '#e14f0f', '#91cc75'][index]
- },
- areaStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: 'rgba(84,112,198,0.4)' },
- { offset: 1, color: 'rgba(84,112,198,0.1)' }
- ])
- },
- data: item.data,
- yAxisIndex: yAxisIndex // 指定使用的 Y 轴
- }
- })
- }
- qxInstance.setOption(option)
- }
- // 响应式调整
- const resizeQxChart = () => qxInstance?.resize()
- // 新增:初始化修井完成情况图表
- const initRepairWellChart = () => {
- if (!repairWellChartRef.value) return
- const option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- legend: {
- data: repairWellData.value.series.map((item) => item.name),
- top: 10,
- textStyle: {
- color: '#B6C8DA'
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: repairWellData.value.xAxis,
- axisLabel: {
- color: '#B6C8DA'
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- yAxis: {
- type: 'value',
- name: '完成井数(口)',
- axisLabel: {
- color: '#B6C8DA',
- formatter: '{value}'
- },
- splitLine: {
- show: true, // 显示水平网格线(默认显示)
- lineStyle: {
- // 水平网格线颜色(可设置为纯色或带透明度的颜色)
- color: '#457794', // 浅灰色半透明
- // 可选:设置线条类型(实线/虚线/点线)
- type: 'dashed'
- }
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- series: repairWellData.value.series.map((item) => ({
- name: item.name,
- type: 'bar',
- data: item.data
- }))
- }
- const chart = echarts.init(repairWellChartRef.value)
- chart.setOption(option)
- window.addEventListener('resize', () => chart.resize())
- }
- // 新增:初始化钻井完成情况图表
- const initDrillingWellChart = () => {
- if (!drillingWellChartRef.value) return
- const option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- legend: {
- data: drillingWellData.value.series.map((item) => item.name),
- top: 10,
- textStyle: {
- color: '#B6C8DA'
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: drillingWellData.value.xAxis,
- axisLabel: {
- color: '#B6C8DA',
- formatter: (value) => value.split('-').join('/') // 显示为 2023/01
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- yAxis: {
- type: 'value',
- name: '完成井数(口)',
- axisLabel: {
- color: '#B6C8DA',
- formatter: '{value}'
- },
- splitLine: {
- show: true, // 显示水平网格线(默认显示)
- lineStyle: {
- // 水平网格线颜色(可设置为纯色或带透明度的颜色)
- color: '#457794', // 浅灰色半透明
- // 可选:设置线条类型(实线/虚线/点线)
- type: 'dashed'
- }
- },
- axisLine: {
- lineStyle: {
- color: '#B6C8DA'
- }
- }
- },
- series: drillingWellData.value.series.map((item) => ({
- name: item.name,
- type: 'bar',
- data: item.data
- }))
- }
- const chart = echarts.init(drillingWellChartRef.value)
- chart.setOption(option)
- window.addEventListener('resize', () => chart.resize())
- }
- /** 初始化 */
- onMounted(() => {
- getStats()
- // initChart()
- // initTopChart()
- // initActiveChart()
- // initQxChart()
- window.addEventListener('resize', resizeQxChart)
- // fetchTop()
- window.addEventListener('resize', () => topInstance?.resize())
- initRepairWellChart()
- initDrillingWellChart()
- initDrillingWorkloadChart()
- initRepairWorkloadChart()
- })
- onBeforeUnmount(() => {
- // chartInstance?.dispose()
- // window.removeEventListener('resize', () => chartInstance?.resize())
- // topInstance?.dispose()
- // window.removeEventListener('resize', handleResize)
- // qxInstance?.dispose()
- // window.removeEventListener('resize', resizeQxChart)
- // repairWellChartRef.dispose()
- // window.removeEventListener('resize', () =>
- // echarts.getInstanceByDom(repairWellChartRef.value)?.resize()
- // )
- // echarts.getInstanceByDom(drillingWellChartRef.value)?.dispose()
- // window.removeEventListener('resize', () =>
- // echarts.getInstanceByDom(drillingWellChartRef.value)?.resize()
- // )
- })
- </script>
- <style lang="scss" scoped>
- .page-container {
- background-color: #3a6fa3;
- min-height: 100vh;
- padding: 20px;
- }
- .summary {
- margin-bottom: 20px;
- }
- ::v-deep .chart-card {
- background-color: rgba(0, 0, 0, 0.3);
- border-radius: 8px;
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
- transition: all 0.3s ease;
- border: none;
- &:hover {
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
- }
- }
- .safety-days-card {
- .safety-days-content {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- height: 150px;
- position: relative;
- .days-number {
- font-size: 58px;
- font-weight: bold;
- color: darkorange;
- line-height: 1;
- transition: all 0.3s ease;
- }
- .days-number:hover {
- transform: scale(1.05);
- }
- .days-label {
- font-size: 20px;
- color: white;
- margin-top: 8px;
- }
- .safety-desc {
- font-size: 14px;
- color: #999;
- position: absolute;
- bottom: 10px;
- text-align: center;
- width: 90%;
- }
- }
- }
- @media (max-width: 768px) {
- .page-container {
- padding: 10px;
- }
- }
- ::v-deep .el-card__header {
- border-bottom: none !important;
- padding-bottom: 0;
- }
- </style>
|