feat(property): 1
This commit is contained in:
@@ -22,7 +22,7 @@ onMounted(() => {
|
|||||||
try {
|
try {
|
||||||
// 尝试解析消息内容
|
// 尝试解析消息内容
|
||||||
const parsedMessage = JSON.parse(latestMessage);
|
const parsedMessage = JSON.parse(latestMessage);
|
||||||
if (parsedMessage.type === 'meter') {
|
if (parsedMessage.type === 'meter' && parsedMessage.meterType === 1) {
|
||||||
// 根据消息内容执行相应操作
|
// 根据消息内容执行相应操作
|
||||||
handleSSEMessage(parsedMessage);
|
handleSSEMessage(parsedMessage);
|
||||||
}
|
}
|
||||||
|
@@ -1,53 +1,65 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue';
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue';
|
||||||
import { handleNode } from '@vben/utils'
|
import { handleNode } from '@vben/utils';
|
||||||
import { Empty, Skeleton, Tree } from 'ant-design-vue'
|
import { Empty, Skeleton, Tree } from 'ant-design-vue';
|
||||||
import { communityTree } from "#/api/property/community"
|
import { queryTree } from '#/api/property/energyManagement/meterInfo';
|
||||||
import type { CommunityVO } from "#/api/property/community/model"
|
import type { TreeNode } from '#/api/common';
|
||||||
|
|
||||||
defineOptions({ inheritAttrs: false })
|
defineOptions({ inheritAttrs: false });
|
||||||
|
|
||||||
withDefaults(defineProps<{ showSearch?: boolean }>(), { showSearch: true })
|
const props = defineProps({
|
||||||
|
isMeter: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
/**
|
/**
|
||||||
* 点击刷新按钮的事件
|
* 点击刷新按钮的事件
|
||||||
*/
|
*/
|
||||||
reload: []
|
reload: [];
|
||||||
/**
|
/**
|
||||||
* 点击节点的事件
|
* 点击节点的事件
|
||||||
|
* @param selectedKeys 选中的节点keys
|
||||||
|
* @param info 节点信息对象
|
||||||
*/
|
*/
|
||||||
select: []
|
select: [selectedKeys: string[], info: any];
|
||||||
}>()
|
}>();
|
||||||
|
|
||||||
const selectFloorId = defineModel('selectFloorId', {
|
const selectTreeId = defineModel('selectTreeId', {
|
||||||
type: Array as PropType<string[]>,
|
type: Array as PropType<string[]>,
|
||||||
})
|
});
|
||||||
|
|
||||||
const searchValue = defineModel('searchValue', {
|
const searchValue = defineModel('searchValue', {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
})
|
});
|
||||||
|
|
||||||
type TreeArray = CommunityVO[]
|
const treeArray = ref<TreeNode[]>([]);
|
||||||
const treeArray = ref<TreeArray>([])
|
|
||||||
/** 骨架屏加载 */
|
/** 骨架屏加载 */
|
||||||
const showTreeSkeleton = ref<boolean>(true)
|
const showTreeSkeleton = ref<boolean>(true);
|
||||||
|
|
||||||
async function loadTree() {
|
async function loadTree() {
|
||||||
showTreeSkeleton.value = true
|
showTreeSkeleton.value = true;
|
||||||
searchValue.value = ''
|
searchValue.value = '';
|
||||||
selectFloorId.value = []
|
const ret = await queryTree({ meterType: 2, isMeter: props.isMeter });
|
||||||
const ret = await communityTree(3)
|
handleNode(ret, 3);
|
||||||
const splitStr = '/'
|
treeArray.value = ret;
|
||||||
handleNode(ret, 'label', splitStr, function (node: any) {
|
showTreeSkeleton.value = false;
|
||||||
if (node.level != 3) {
|
}
|
||||||
node.disabled = true
|
|
||||||
|
function handleNode(nodes: any[], level: number) {
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
node.key = node.id;
|
||||||
|
if (node.level < level) {
|
||||||
|
node.disabled = true;
|
||||||
}
|
}
|
||||||
})
|
if (node.children) {
|
||||||
treeArray.value = ret
|
handleNode(node.children, level);
|
||||||
showTreeSkeleton.value = false
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(loadTree);
|
onMounted(loadTree);
|
||||||
@@ -55,23 +67,46 @@ onMounted(loadTree);
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="$attrs.class">
|
<div :class="$attrs.class">
|
||||||
<Skeleton :loading="showTreeSkeleton" :paragraph="{ rows: 8 }" active class="p-[8px] flex-1 min-h-0">
|
<Skeleton
|
||||||
<div class="bg-background flex h-full flex-col overflow-y-auto rounded-lg">
|
:loading="showTreeSkeleton"
|
||||||
|
:paragraph="{ rows: 8 }"
|
||||||
|
active
|
||||||
|
class="min-h-0 flex-1 p-[8px]"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="bg-background flex h-full flex-col overflow-y-auto rounded-lg"
|
||||||
|
>
|
||||||
<div class="h-full overflow-x-hidden px-[8px]">
|
<div class="h-full overflow-x-hidden px-[8px]">
|
||||||
<Tree v-bind="$attrs" v-if="treeArray.length > 0" v-model:selected-keys="selectFloorId"
|
<Tree
|
||||||
:field-names="{ title: 'label', key: 'id' }" :show-line="{ showLeafIcon: false }" :tree-data="treeArray"
|
v-bind="$attrs"
|
||||||
:virtual="false" default-expand-all @select="$emit('select')">
|
v-if="treeArray.length > 0"
|
||||||
|
v-model:selected-keys="selectTreeId"
|
||||||
|
:show-line="{ showLeafIcon: false }"
|
||||||
|
:tree-data="treeArray"
|
||||||
|
:virtual="false"
|
||||||
|
default-expand-all
|
||||||
|
@select="
|
||||||
|
(selectedKeys, info) => $emit('select', selectedKeys, info)
|
||||||
|
"
|
||||||
|
>
|
||||||
<template #title="{ label }">
|
<template #title="{ label }">
|
||||||
<span v-if="label.indexOf(searchValue) > -1">
|
<span v-if="label.indexOf(searchValue) > -1">
|
||||||
{{ label.substring(0, label.indexOf(searchValue)) }}
|
{{ label.substring(0, label.indexOf(searchValue)) }}
|
||||||
<span style="color: #f50">{{ searchValue }}</span>
|
<span style="color: #f50">{{ searchValue }}</span>
|
||||||
{{ label.substring(label.indexOf(searchValue) + searchValue.length) }}
|
{{
|
||||||
|
label.substring(
|
||||||
|
label.indexOf(searchValue) + searchValue.length,
|
||||||
|
)
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
<span v-else>{{ label }}</span>
|
<span v-else>{{ label }}</span>
|
||||||
</template>
|
</template>
|
||||||
</Tree>
|
</Tree>
|
||||||
<div v-else class="mt-5">
|
<div v-else class="mt-5">
|
||||||
<Empty :image="Empty.PRESENTED_IMAGE_SIMPLE" description="暂无数据" />
|
<Empty
|
||||||
|
:image="Empty.PRESENTED_IMAGE_SIMPLE"
|
||||||
|
description="暂无数据"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,377 +1,286 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useNotifyStore } from '#/store';
|
||||||
|
import { useAccessStore } from '@vben/stores';
|
||||||
|
import FloorTree from '../components/floor-tree.vue';
|
||||||
|
import { BackTop, message, Spin } from 'ant-design-vue';
|
||||||
|
import { Page, VbenCountToAnimator } from '@vben/common-ui';
|
||||||
|
import { ref, onMounted, onBeforeUnmount, reactive, watch } from 'vue';
|
||||||
|
import { currentReading } from '#/api/property/energyManagement/meterInfo';
|
||||||
|
|
||||||
|
const notifyStore = useNotifyStore();
|
||||||
|
const readingData = ref<any>({});
|
||||||
|
const readingTime = ref('');
|
||||||
|
const readingLoading = ref(false);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
notifyStore.startListeningMessage();
|
||||||
|
// 监听sseList的变化
|
||||||
|
watch(
|
||||||
|
() => notifyStore.sseList,
|
||||||
|
(val) => {
|
||||||
|
const latestMessage = val[val.length - 1];
|
||||||
|
try {
|
||||||
|
// 尝试解析消息内容
|
||||||
|
const parsedMessage = JSON.parse(latestMessage);
|
||||||
|
if (parsedMessage.type === 'meter' && parsedMessage.meterType === 2) {
|
||||||
|
// 根据消息内容执行相应操作
|
||||||
|
handleSSEMessage(parsedMessage);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('收到非JSON消息:', latestMessage);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleSSEMessage(data: any) {
|
||||||
|
if (data.data.length === 0) {
|
||||||
|
message.warn('当前楼层暂无水表!');
|
||||||
|
}
|
||||||
|
readingData.value = data.data;
|
||||||
|
readingTime.value = data.readingTime;
|
||||||
|
readingLoading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
// 关闭页面,发送请求停止心跳
|
||||||
|
currentReading({ meterType: 0, floorId: 0 });
|
||||||
|
});
|
||||||
|
async function handleSelectFloor(selectedKeys, info) {
|
||||||
|
if (typeof selectedKeys[0] === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
readingLoading.value = true;
|
||||||
|
await currentReading({
|
||||||
|
meterType: 2,
|
||||||
|
floorId: selectedKeys[0],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function targetFn() {
|
||||||
|
return document.getElementById('right-panel');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page :auto-content-height="true">
|
<Page :auto-content-height="true">
|
||||||
<div class="flex h-full gap-[8px]">
|
<div class="flex h-full gap-[8px]">
|
||||||
<FloorTree class="w-[260px]"></FloorTree>
|
<FloorTree
|
||||||
<div class="flex-1 overflow-hidden">
|
:isMeter="false"
|
||||||
<div class="row">
|
class="w-[260px]"
|
||||||
<div class="comparison-section-container">
|
@select="handleSelectFloor"
|
||||||
<div class="section-header">
|
></FloorTree>
|
||||||
<div class="header-title">环比</div>
|
<div class="flex-1" id="right-panel">
|
||||||
|
<Spin :spinning="readingLoading" size="large" style="height: 100px">
|
||||||
|
<div class="cards-container">
|
||||||
|
<div v-for="item in readingData" class="meterInfo-card">
|
||||||
|
<h2>
|
||||||
|
{{ item.meterName }}
|
||||||
|
</h2>
|
||||||
|
<div class="meterInfo-reading">
|
||||||
|
<p>
|
||||||
|
<VbenCountToAnimator
|
||||||
|
:end-val="item.initReading"
|
||||||
|
:decimals="2"
|
||||||
|
prefix=""
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
<div></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="comparison-grid">
|
<div class="meterInfo-list">
|
||||||
<div class="comparison-item">
|
<ul>
|
||||||
<div class="item-value">{{ chainData.currentMonthEnergy }}</div>
|
<li>
|
||||||
<div class="item-title">当月用水(t)</div>
|
<span>采集时间:</span>
|
||||||
|
<span>{{ readingTime }}</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span>设备位置:</span>
|
||||||
|
<span>{{ item.installLocation }}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="comparison-item">
|
<div class="button-get-plan">
|
||||||
<div class="item-value">{{ chainData.lastMonthSamePeriodEnergy }}</div>
|
<a
|
||||||
<div class="item-title">上月同期(t)</div>
|
v-if="item.communicationState !== 0"
|
||||||
</div>
|
style="background: #6bb1e3"
|
||||||
<div class="comparison-item">
|
>
|
||||||
<div class="item-top">
|
<span>在线</span>
|
||||||
<div class="item-percent">{{ chainData.monthTrendPercentage }}</div>
|
</a>
|
||||||
<div>{{ chainData.monthTrendValue }}
|
<a v-else style="background: orange">
|
||||||
<span class="item-title">t</span>
|
<span>离线</span>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
|
||||||
<div class="item-title">趋势</div>
|
|
||||||
</div>
|
|
||||||
<div class="comparison-item">
|
|
||||||
<div class="item-value">{{ chainData.currentYearEnergy }}</div>
|
|
||||||
<div class="item-title">当年用水(t)</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="comparison-item">
|
|
||||||
<div class="item-value">{{ chainData.lastYearSamePeriodEnergy }}</div>
|
|
||||||
<div class="item-title">去年同期(t)</div>
|
|
||||||
</div>
|
|
||||||
<div class="comparison-item">
|
|
||||||
<div class="item-top">
|
|
||||||
<div class="item-percent">{{ chainData.yearTrendPercentage }}</div>
|
|
||||||
<div>{{ chainData.yearTrendValue }}
|
|
||||||
<span class="item-title">t</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="item-title">趋势</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="energy-trend-container">
|
|
||||||
<div class="energy-trend-top">
|
|
||||||
<div class="section-header">
|
|
||||||
<div class="header-title">能耗趋势</div>
|
|
||||||
</div>
|
|
||||||
<RadioGroup v-model:value="energyTrendTime" button-style="solid" size="small"
|
|
||||||
@change="buildingEnergyTrendData(energyTrendTime)">
|
|
||||||
<RadioButton value="2">当月</RadioButton>
|
|
||||||
<RadioButton value="3">当年</RadioButton>
|
|
||||||
</RadioGroup>
|
|
||||||
</div>
|
|
||||||
<div class="energy-chart" ref="energyTrendChart">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="power-curve-container">
|
|
||||||
<div class="section-header">
|
|
||||||
<div class="header-title">当年数据曲线</div>
|
|
||||||
</div>
|
|
||||||
<div class="power-chart" ref="powerCurveChart">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
|
<BackTop class="back-to-top" :target="targetFn"></BackTop>
|
||||||
</div>
|
</div>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { RadioGroup, RadioButton } from 'ant-design-vue'
|
|
||||||
import { Page } from '@vben/common-ui'
|
|
||||||
import { ref, onMounted, onBeforeUnmount, reactive } from 'vue'
|
|
||||||
import * as echarts from 'echarts'
|
|
||||||
import type { ECharts, EChartsOption } from 'echarts'
|
|
||||||
import FloorTree from "../components/floor-tree.vue"
|
|
||||||
|
|
||||||
const chainData = reactive({
|
|
||||||
currentMonthEnergy: '9',
|
|
||||||
lastMonthSamePeriodEnergy: '--',
|
|
||||||
monthTrendPercentage: '--',
|
|
||||||
monthTrendValue: '--',
|
|
||||||
currentYearEnergy: '59',
|
|
||||||
lastYearSamePeriodEnergy: '--',
|
|
||||||
yearTrendPercentage: '--',
|
|
||||||
yearTrendValue: '--',
|
|
||||||
})
|
|
||||||
|
|
||||||
const energyTrendTime = ref('2')
|
|
||||||
|
|
||||||
// 能耗趋势图表容器
|
|
||||||
const energyTrendChart = ref<HTMLElement | null>(null)
|
|
||||||
const energyTrendInstance = ref<ECharts | null>(null)
|
|
||||||
|
|
||||||
const energyTrendOption: EChartsOption = {
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'item',
|
|
||||||
axisPointer: {
|
|
||||||
type: 'shadow'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
type: 'category',
|
|
||||||
data: [],
|
|
||||||
name: '日期',
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
type: 'value',
|
|
||||||
name: 't',
|
|
||||||
},
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
data: [],
|
|
||||||
type: 'bar',
|
|
||||||
markPoint: {
|
|
||||||
data: [
|
|
||||||
{ type: 'max', name: 'Max' },
|
|
||||||
{ type: 'min', name: 'Min' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
const initEnergyTrendChart = () => {
|
|
||||||
if (energyTrendChart.value) {
|
|
||||||
// 销毁旧实例
|
|
||||||
energyTrendInstance.value?.dispose()
|
|
||||||
// 创建新实例
|
|
||||||
energyTrendInstance.value = echarts.init(energyTrendChart.value)
|
|
||||||
// 设置配置项
|
|
||||||
energyTrendInstance.value.setOption(energyTrendOption)
|
|
||||||
buildingEnergyTrendData('2')
|
|
||||||
// 可选:添加窗口大小变化监听
|
|
||||||
const resizeHandler = () => {
|
|
||||||
energyTrendInstance.value?.resize()
|
|
||||||
}
|
|
||||||
window.addEventListener('resize', resizeHandler)
|
|
||||||
|
|
||||||
// 在组件卸载前移除监听
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener('resize', resizeHandler)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildingEnergyTrendData(val: string) {
|
|
||||||
const now = new Date()
|
|
||||||
let timeArr = []
|
|
||||||
let valArr = []
|
|
||||||
let name = '日期'
|
|
||||||
if (val == '2') {
|
|
||||||
const day = now.getDate()
|
|
||||||
for (let i = 1; i < day; i++) {
|
|
||||||
timeArr.push(i)
|
|
||||||
valArr.push(parseFloat((Math.random() * 10).toFixed(2)))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const month = now.getMonth() + 1
|
|
||||||
for (let i = 1; i < month; i++) {
|
|
||||||
timeArr.push(i)
|
|
||||||
valArr.push(parseFloat((Math.random() * 80).toFixed(2)))
|
|
||||||
}
|
|
||||||
name = '月份'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (energyTrendInstance.value) {
|
|
||||||
energyTrendInstance.value.setOption({
|
|
||||||
xAxis: { data: timeArr, name },
|
|
||||||
series: [{ data: valArr }],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//日用电率
|
|
||||||
const powerCurveChart = ref<HTMLElement | null>(null)
|
|
||||||
const powerCurveInstance = ref<ECharts | null>(null)
|
|
||||||
|
|
||||||
|
|
||||||
const powerCurveOption: EChartsOption = {
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'item',
|
|
||||||
axisPointer: {
|
|
||||||
type: 'cross',
|
|
||||||
crossStyle: {
|
|
||||||
color: '#999'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toolbox: {
|
|
||||||
feature: {
|
|
||||||
magicType: { show: true, type: ['line', 'bar'] },
|
|
||||||
restore: { show: true },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
legend: {
|
|
||||||
data: ['今年']
|
|
||||||
},
|
|
||||||
xAxis: [
|
|
||||||
{
|
|
||||||
type: 'category',
|
|
||||||
data: [],
|
|
||||||
axisPointer: {
|
|
||||||
type: 'shadow'
|
|
||||||
},
|
|
||||||
name: '月份'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
yAxis: [
|
|
||||||
{
|
|
||||||
type: 'value',
|
|
||||||
name: 't',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: '今年',
|
|
||||||
type: 'line',
|
|
||||||
smooth: true,
|
|
||||||
data: [],
|
|
||||||
markPoint: {
|
|
||||||
data: [
|
|
||||||
{ type: 'max', },
|
|
||||||
{ type: 'min', }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
const initPowerCurveChart = () => {
|
|
||||||
if (powerCurveChart.value) {
|
|
||||||
// 销毁旧实例
|
|
||||||
powerCurveInstance.value?.dispose()
|
|
||||||
// 创建新实例
|
|
||||||
powerCurveInstance.value = echarts.init(powerCurveChart.value)
|
|
||||||
// 设置配置项
|
|
||||||
powerCurveInstance.value.setOption(powerCurveOption)
|
|
||||||
buildingPowerCurveData()
|
|
||||||
// 可选:添加窗口大小变化监听
|
|
||||||
const resizeHandler = () => {
|
|
||||||
powerCurveInstance.value?.resize()
|
|
||||||
}
|
|
||||||
window.addEventListener('resize', resizeHandler)
|
|
||||||
|
|
||||||
// 在组件卸载前移除监听
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener('resize', resizeHandler)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildingPowerCurveData() {
|
|
||||||
const now = new Date()
|
|
||||||
const month = now.getMonth() + 1
|
|
||||||
let yearData = []
|
|
||||||
let timeDate = []
|
|
||||||
for (let i = 1; i < month; i++) {
|
|
||||||
timeDate.push(i + '月')
|
|
||||||
yearData.push(parseFloat((Math.random() * 60).toFixed(2)))
|
|
||||||
}
|
|
||||||
if (powerCurveInstance.value) {
|
|
||||||
powerCurveInstance.value.setOption({
|
|
||||||
xAxis: { data: timeDate },
|
|
||||||
series: [{ data: yearData }],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 组件挂载后初始化图表
|
|
||||||
onMounted(() => {
|
|
||||||
initEnergyTrendChart()
|
|
||||||
initPowerCurveChart()
|
|
||||||
})
|
|
||||||
|
|
||||||
// 组件卸载前销毁图表实例
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
energyTrendInstance.value?.dispose()
|
|
||||||
powerCurveInstance.value?.dispose()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.row {
|
/* 右侧内容区域样式 */
|
||||||
|
.flex-1 {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto; /* 添加垂直滚动条 */
|
||||||
|
padding: 10px;
|
||||||
|
height: 100%; /* 确保高度占满父容器 */
|
||||||
|
box-sizing: border-box; /* 包括padding在高度计算中 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 卡片容器样式 */
|
||||||
|
.cards-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
flex-wrap: wrap;
|
||||||
width: 100%;
|
justify-content: flex-start;
|
||||||
|
gap: 20px; /* 使用gap替代margin控制间距 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.comparison-section-container {
|
.meterInfo-card {
|
||||||
flex: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.energy-trend-container {
|
|
||||||
flex: 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.power-curve-container {
|
|
||||||
margin-top: 10px;
|
|
||||||
flex: 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.energy-trend-top {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-header {
|
|
||||||
border-left: 4px solid #3671e8;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
padding-left: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-title {
|
|
||||||
font-size: 16px;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comparison-section-container,
|
|
||||||
.energy-trend-container,
|
|
||||||
.power-curve-container {
|
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 5px;
|
width: 15rem;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
padding-left: 2rem;
|
||||||
padding: 1rem;
|
padding-right: 2rem;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border-bottom: 4px solid #87ceeb;
|
||||||
|
box-shadow: 0 6px 30px rgba(173, 216, 230, 0.3);
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
height: 270px;
|
||||||
|
margin: 0 5px 20px 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comparison-grid {
|
.meterInfo-card h2 {
|
||||||
display: grid;
|
margin-bottom: 15px;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
font-size: 27px;
|
||||||
gap: 5px;
|
color: #5faee3;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comparison-item {
|
.meterInfo-card h2 span {
|
||||||
padding: 15px 10px;
|
display: block;
|
||||||
border: 1px solid #e0e0e0;
|
margin-top: -4px;
|
||||||
text-align: center;
|
color: #7eb8da;
|
||||||
}
|
|
||||||
|
|
||||||
.item-value {
|
|
||||||
font-size: 22px;
|
|
||||||
color: #333;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-title {
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #666;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-top {
|
.meterInfo-reading {
|
||||||
font-size: 16px;
|
position: relative;
|
||||||
margin-bottom: 10px;
|
background: #f0f8ff;
|
||||||
|
width: 14.46rem;
|
||||||
|
margin-left: -0.65rem;
|
||||||
|
padding: 0.2rem 1.2rem;
|
||||||
|
border-radius: 5px 0 0 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-percent {
|
.meterInfo-reading p {
|
||||||
color: #7fb926;
|
margin: 0;
|
||||||
margin-bottom: 5px;
|
padding-top: 0.4rem;
|
||||||
border-bottom: 1px solid #666;
|
display: flex;
|
||||||
|
font-size: 1.9rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #4a8cbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.power-chart {
|
.meterInfo-reading p:before {
|
||||||
height: 45vh;
|
content: '';
|
||||||
|
margin-right: 5px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
.energy-chart {
|
.meterInfo-reading p:after {
|
||||||
height: 30vh;
|
content: '/ 立方米';
|
||||||
|
margin-left: 5px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meterInfo-reading div {
|
||||||
|
position: absolute;
|
||||||
|
bottom: -23px;
|
||||||
|
right: 0px;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-top: 13px solid #87ceeb;
|
||||||
|
border-bottom: 10px solid transparent;
|
||||||
|
border-right: 13px solid transparent;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meterInfo-list {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meterInfo-list ul {
|
||||||
|
padding: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meterInfo-list ul li {
|
||||||
|
color: #5a7d9a;
|
||||||
|
list-style: none;
|
||||||
|
margin-bottom: 0.2rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meterInfo-list ul li svg {
|
||||||
|
width: 0.9rem;
|
||||||
|
fill: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meterInfo-list ul li span {
|
||||||
|
font-weight: 300;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-get-plan {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-get-plan a {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
color: #fff;
|
||||||
|
padding: 10px 15px;
|
||||||
|
border-radius: 5px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
letter-spacing: 0.05rem;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-get-plan a:hover {
|
||||||
|
transform: translateY(-3%);
|
||||||
|
box-shadow: 0 3px 10px rgba(123, 180, 220, 0.6); /* 浅蓝色阴影 */
|
||||||
|
background: #5fa0d0; /* 悬停时略深的蓝色 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-get-plan .svg-rocket {
|
||||||
|
margin-right: 10px;
|
||||||
|
width: 0.9rem;
|
||||||
|
fill: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-to-top {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 返回顶部按钮 */
|
||||||
|
.back-to-top:hover {
|
||||||
|
background-color: #6bb1e3;
|
||||||
|
transform: translateY(-5px);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@@ -108,6 +108,12 @@ export const columns: VxeGridProps['columns'] = [
|
|||||||
},
|
},
|
||||||
width: 100,
|
width: 100,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '授权状态',
|
||||||
|
field: 'eeightId',
|
||||||
|
slots: { default: 'eeightId' },
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '备注',
|
title: '备注',
|
||||||
field: 'remark',
|
field: 'remark',
|
||||||
@@ -117,7 +123,7 @@ export const columns: VxeGridProps['columns'] = [
|
|||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 200,
|
width: 250,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@@ -1,31 +1,29 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useAccess } from '@vben/access';
|
||||||
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui'
|
import personModal from './person-modal.vue';
|
||||||
import { getVxePopupContainer } from '@vben/utils'
|
import { columns, querySchema } from './data';
|
||||||
|
import personDetail from './person-detail.vue';
|
||||||
import { Avatar, Modal, Popconfirm, Space } from 'ant-design-vue'
|
import { TableSwitch } from '#/components/table';
|
||||||
|
import { getVxePopupContainer } from '@vben/utils';
|
||||||
|
import faceImportModal from './face-import-modal.vue';
|
||||||
|
import personImportModal from './person-import-modal.vue';
|
||||||
|
import { commonDownloadExcel } from '#/utils/file/download';
|
||||||
|
import { Avatar, Modal, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||||
|
import type { PersonForm } from '#/api/property/resident/person/model';
|
||||||
|
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useVbenVxeGrid,
|
useVbenVxeGrid,
|
||||||
vxeCheckboxChecked,
|
vxeCheckboxChecked,
|
||||||
type VxeGridProps
|
type VxeGridProps,
|
||||||
} from '#/adapter/vxe-table'
|
} from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
personExport,
|
personExport,
|
||||||
personList,
|
personList,
|
||||||
personRemove, personUpdate,
|
personRemove,
|
||||||
} from '#/api/property/resident/person'
|
personUpdate,
|
||||||
import type { PersonForm } from '#/api/property/resident/person/model'
|
} from '#/api/property/resident/person';
|
||||||
import { commonDownloadExcel } from '#/utils/file/download'
|
|
||||||
|
|
||||||
import personModal from './person-modal.vue'
|
|
||||||
import personDetail from './person-detail.vue'
|
|
||||||
import personImportModal from './person-import-modal.vue'
|
|
||||||
import faceImportModal from './face-import-modal.vue'
|
|
||||||
import { columns, querySchema } from './data'
|
|
||||||
import { useAccess } from "@vben/access"
|
|
||||||
import { TableSwitch } from "#/components/table"
|
|
||||||
|
|
||||||
const formOptions: VbenFormProps = {
|
const formOptions: VbenFormProps = {
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
@@ -36,7 +34,7 @@ const formOptions: VbenFormProps = {
|
|||||||
},
|
},
|
||||||
schema: querySchema(),
|
schema: querySchema(),
|
||||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||||
}
|
};
|
||||||
|
|
||||||
const gridOptions: VxeGridProps = {
|
const gridOptions: VxeGridProps = {
|
||||||
checkboxConfig: {
|
checkboxConfig: {
|
||||||
@@ -64,8 +62,6 @@ const gridOptions: VxeGridProps = {
|
|||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
...formValues,
|
...formValues,
|
||||||
});
|
});
|
||||||
console.log(res);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -74,75 +70,80 @@ const gridOptions: VxeGridProps = {
|
|||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
},
|
},
|
||||||
// 表格全局唯一表示 保存列配置需要用到
|
// 表格全局唯一表示 保存列配置需要用到
|
||||||
id: 'property-person-index'
|
id: 'property-person-index',
|
||||||
}
|
};
|
||||||
|
|
||||||
const [BasicTable, tableApi] = useVbenVxeGrid({
|
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||||
formOptions,
|
formOptions,
|
||||||
gridOptions,
|
gridOptions,
|
||||||
})
|
});
|
||||||
|
|
||||||
const [PersonModal, modalApi] = useVbenModal({
|
const [PersonModal, modalApi] = useVbenModal({
|
||||||
connectedComponent: personModal,
|
connectedComponent: personModal,
|
||||||
})
|
});
|
||||||
const [PersonDetail, personDetailApi] = useVbenModal({
|
const [PersonDetail, personDetailApi] = useVbenModal({
|
||||||
connectedComponent: personDetail,
|
connectedComponent: personDetail,
|
||||||
})
|
});
|
||||||
const [PersonImportModal, personImportModalApi] = useVbenModal({
|
const [PersonImportModal, personImportModalApi] = useVbenModal({
|
||||||
connectedComponent: personImportModal,
|
connectedComponent: personImportModal,
|
||||||
})
|
});
|
||||||
const [FaceImportModal, faceImportModalApi] = useVbenModal({
|
const [FaceImportModal, faceImportModalApi] = useVbenModal({
|
||||||
connectedComponent: faceImportModal,
|
connectedComponent: faceImportModal,
|
||||||
})
|
});
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess()
|
const { hasAccessByCodes } = useAccess();
|
||||||
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
modalApi.setData({})
|
modalApi.setData({});
|
||||||
modalApi.open()
|
modalApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleImport() {
|
function handleImport() {
|
||||||
personImportModalApi.open()
|
personImportModalApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFaceImport() {
|
function handleFaceImport() {
|
||||||
faceImportModalApi.open()
|
faceImportModalApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleEdit(row: Required<PersonForm>) {
|
async function handleEdit(row: Required<PersonForm>) {
|
||||||
modalApi.setData({ id: row.id })
|
modalApi.setData({ id: row.id });
|
||||||
modalApi.open()
|
modalApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete(row: Required<PersonForm>) {
|
async function handleDelete(row: Required<PersonForm>) {
|
||||||
await personRemove(row.id)
|
await personRemove(row.id);
|
||||||
await tableApi.query()
|
await tableApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMultiDelete() {
|
function handleMultiDelete() {
|
||||||
const rows = tableApi.grid.getCheckboxRecords()
|
const rows = tableApi.grid.getCheckboxRecords();
|
||||||
const ids = rows.map((row: Required<PersonForm>) => row.id)
|
const ids = rows.map((row: Required<PersonForm>) => row.id);
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
okType: 'danger',
|
okType: 'danger',
|
||||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
await personRemove(ids)
|
await personRemove(ids);
|
||||||
await tableApi.query()
|
await tableApi.query();
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDownloadExcel() {
|
function handleDownloadExcel() {
|
||||||
commonDownloadExcel(personExport, '入驻员工数据', tableApi.formApi.form.values, {
|
commonDownloadExcel(
|
||||||
|
personExport,
|
||||||
|
'入驻员工数据',
|
||||||
|
tableApi.formApi.form.values,
|
||||||
|
{
|
||||||
fieldMappingTime: formOptions.fieldMappingTime,
|
fieldMappingTime: formOptions.fieldMappingTime,
|
||||||
})
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInfo(row: Required<PersonForm>) {
|
function handleInfo(row: Required<PersonForm>) {
|
||||||
personDetailApi.setData({ id: row.id })
|
personDetailApi.setData({ id: row.id });
|
||||||
personDetailApi.open()
|
personDetailApi.open();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -151,20 +152,33 @@ function handleInfo(row: Required<PersonForm>) {
|
|||||||
<BasicTable table-title="入驻员工列表">
|
<BasicTable table-title="入驻员工列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<Space>
|
<Space>
|
||||||
<a-button v-access:code="['property:person:export']" @click="handleDownloadExcel">
|
<a-button
|
||||||
|
v-access:code="['property:person:export']"
|
||||||
|
@click="handleDownloadExcel"
|
||||||
|
>
|
||||||
{{ $t('pages.common.export') }}
|
{{ $t('pages.common.export') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button v-access:code="['system:user:import']" @click="handleImport">
|
<a-button
|
||||||
|
v-access:code="['system:user:import']"
|
||||||
|
@click="handleImport"
|
||||||
|
>
|
||||||
{{ $t('pages.common.import') }}
|
{{ $t('pages.common.import') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button @click="handleFaceImport">
|
<a-button @click="handleFaceImport"> 人脸导入 </a-button>
|
||||||
人脸导入
|
<a-button
|
||||||
</a-button>
|
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||||
<a-button :disabled="!vxeCheckboxChecked(tableApi)" danger type="primary"
|
danger
|
||||||
v-access:code="['property:person:remove']" @click="handleMultiDelete">
|
type="primary"
|
||||||
|
v-access:code="['property:person:remove']"
|
||||||
|
@click="handleMultiDelete"
|
||||||
|
>
|
||||||
{{ $t('pages.common.delete') }}
|
{{ $t('pages.common.delete') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button type="primary" v-access:code="['property:person:add']" @click="handleAdd">
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
v-access:code="['property:person:add']"
|
||||||
|
@click="handleAdd"
|
||||||
|
>
|
||||||
{{ $t('pages.common.add') }}
|
{{ $t('pages.common.add') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</Space>
|
</Space>
|
||||||
@@ -173,17 +187,38 @@ function handleInfo(row: Required<PersonForm>) {
|
|||||||
<Avatar :src="row.img" v-if="row.img" />
|
<Avatar :src="row.img" v-if="row.img" />
|
||||||
<span v-else>无</span>
|
<span v-else>无</span>
|
||||||
</template>
|
</template>
|
||||||
|
<template #eeightId="{ row }">
|
||||||
|
<tag v-if="row.eeightId" color="green">成功</tag>
|
||||||
|
<tag v-else color="orange">未授权</tag>
|
||||||
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<Space>
|
<Space>
|
||||||
<ghost-button @click.stop="handleInfo(row)">
|
<ghost-button @click.stop="handleInfo(row)">
|
||||||
{{ $t('pages.common.info') }}
|
{{ $t('pages.common.info') }}
|
||||||
</ghost-button>
|
</ghost-button>
|
||||||
<ghost-button v-access:code="['property:person:edit']" @click.stop="handleEdit(row)">
|
<ghost-button
|
||||||
|
v-access:code="['property:person:edit']"
|
||||||
|
@click.stop="handleEdit(row)"
|
||||||
|
>
|
||||||
{{ $t('pages.common.edit') }}
|
{{ $t('pages.common.edit') }}
|
||||||
</ghost-button>
|
</ghost-button>
|
||||||
<Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="确认删除?"
|
<ghost-button
|
||||||
@confirm="handleDelete(row)">
|
v-if="!row.eeightId"
|
||||||
<ghost-button danger v-access:code="['property:person:remove']" @click.stop="">
|
style="color: orange; border-color: orange"
|
||||||
|
>
|
||||||
|
授权
|
||||||
|
</ghost-button>
|
||||||
|
<Popconfirm
|
||||||
|
:get-popup-container="getVxePopupContainer"
|
||||||
|
placement="left"
|
||||||
|
title="确认删除?"
|
||||||
|
@confirm="handleDelete(row)"
|
||||||
|
>
|
||||||
|
<ghost-button
|
||||||
|
danger
|
||||||
|
v-access:code="['property:person:remove']"
|
||||||
|
@click.stop=""
|
||||||
|
>
|
||||||
{{ $t('pages.common.delete') }}
|
{{ $t('pages.common.delete') }}
|
||||||
</ghost-button>
|
</ghost-button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
Reference in New Issue
Block a user