zhitan-cloud
2025-01-13 9a34cc100384b0db98166e1a7e4f35dee44fb8ae
zhitan-vue/src/views/costmanage/deviation/deviation.vue
@@ -4,15 +4,37 @@
            <el-form :model="form" ref="formRef" :inline="true">
                <el-form-item label="期间" prop="timeType">
                    <el-select v-model="form.timeType" placeholder="期间" style="width: 100%" @change="handleTimeType">
                        <el-option v-for="dict in period" :key="dict.value" :label="dict.label" :value="dict.value"
                            v-show="dict.value != 'DAY'" />
            <el-option
              v-for="dict in period"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
              v-show="dict.value != 'DAY'"
            />
                    </el-select>
                </el-form-item>
                <el-form-item label="时间">
                    <el-date-picker v-model="form.date" type="year" v-if="form.timeType == 'YEAR'" range-separator="到"
                        format="YYYY" value-format="YYYY" placeholder="时间" style="width: 100%" :clearable="false" />
                    <el-date-picker v-model="form.date" type="month" v-else format="YYYY-MM" value-format="YYYY-MM"
                        placeholder="时间" style="width: 100%" :clearable="false" />
          <el-date-picker
            v-model="form.date"
            type="year"
            v-if="form.timeType == 'YEAR'"
            range-separator="到"
            format="YYYY"
            value-format="YYYY"
            placeholder="时间"
            style="width: 100%"
            :clearable="false"
          />
          <el-date-picker
            v-model="form.date"
            type="month"
            v-else
            format="YYYY-MM"
            value-format="YYYY-MM"
            placeholder="时间"
            style="width: 100%"
            :clearable="false"
          />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
@@ -30,7 +52,7 @@
                    <div class="item-bottom" v-for="(node, nodeIndex) in item.data" :key="nodeIndex">
                        <div class="bottom-left">{{ node.label }}</div>
                        <div class="bottom-right" :style="{ color: item.color }">
                            {{ form.timeType == 'YEAR' && nodeIndex == 1 ? '--' : node.value }}
              {{ form.timeType == "YEAR" && nodeIndex == 1 ? "--" : node.value }}
                        </div>
                    </div>
                </div>
@@ -46,7 +68,7 @@
                    <div class="item-bottom" v-for="(node, nodeIndex) in item.data" :key="nodeIndex">
                        <div class="bottom-left">{{ node.label }}</div>
                        <div class="bottom-right" :style="{ color: item.color }">
                            {{ form.timeType == 'YEAR' && nodeIndex == 1 ? '--' : node.value }}
              {{ form.timeType == "YEAR" && nodeIndex == 1 ? "--" : node.value }}
                        </div>
                    </div>
                </div>
@@ -54,10 +76,19 @@
        </BaseCard>
        <BaseCard title="耗电明细">
            <div class="table-box">
                <el-table :data="tableData" v-loading="loading"
                    style="width: 100%; max-height: 500px; margin-bottom: 20px" row-key="id">
                    <el-table-column prop="nodeId" label="用能单位" align="center" show-overflow-tooltip
                        :formatter="(row, column) => findLabelById(treeNode, row.nodeId)" />
        <el-table
          :data="tableData"
          v-loading="loading"
          style="width: 100%; max-height: 500px; margin-bottom: 20px"
          row-key="id"
        >
          <el-table-column
            prop="nodeId"
            label="用能单位"
            align="center"
            show-overflow-tooltip
            :formatter="(row, column) => findLabelById(treeNode, row.nodeId)"
          />
                    <el-table-column prop="electricityNum" label="总耗电量(千瓦时)" align="center" show-overflow-tooltip />
                    <el-table-column prop="sharpElectricity" label="尖(千瓦时)" align="center" show-overflow-tooltip />
                    <el-table-column prop="peakElectricity" label="峰(千瓦时)" align="center" show-overflow-tooltip />
@@ -65,14 +96,17 @@
                    <el-table-column prop="valleyElectricity" label="谷(千瓦时)" align="center" show-overflow-tooltip />
                    <el-table-column prop="electricityFee" label="总电费(元)" align="center" show-overflow-tooltip />
                    <el-table-column prop="electricityNumYoy" label="同比" align="center" show-overflow-tooltip />
                    <el-table-column prop="electricityNumQoq" label="环比" v-if="form.timeType != 'YEAR'" align="center"
                        show-overflow-tooltip />
          <el-table-column
            prop="electricityNumQoq"
            label="环比"
            v-if="form.timeType != 'YEAR'"
            align="center"
            show-overflow-tooltip
          />
                    <el-table-column prop="electricityNumRadio" label="占比" align="center" show-overflow-tooltip />
                    <el-table-column label="操作" width="80" align="center">
                        <template #default="scope">
                            <el-button link type="primary" icon="Document" @click="handleInfo(scope.row)">
                                详情
                            </el-button>
              <el-button link type="primary" icon="Document" @click="handleInfo(scope.row)"> 详情 </el-button>
                        </template>
                    </el-table-column>
                </el-table>
@@ -82,24 +116,23 @@
    </div>
</template>
<script setup>
import { deviationCardList, deviationTableList } from '@/api/costManage/costManage.js'
import InfoModal from './components/InfoModal.vue'
import { useRoute } from "vue-router";
const { proxy } = getCurrentInstance();
const { period } = proxy.useDict("period");
import { treeList } from "@/api/modelConfiguration/indexWarehouse";
import { deviationCardList, deviationTableList } from "@/api/costManage/costManage.js"
import InfoModal from "./components/InfoModal.vue"
import { useRoute } from "vue-router"
const { proxy } = getCurrentInstance()
const { period } = proxy.useDict("period")
import { treeList } from "@/api/modelConfiguration/indexWarehouse"
let loading = ref(false)
let form = ref({
    timeType: '',
  timeType: "",
    date: null,
    ...useRoute().query
  ...useRoute().query,
})
import icon1 from "@/assets/images/period/icon1.png";
import icon2 from "@/assets/images/period/icon2.png";
import icon3 from "@/assets/images/period/icon3.png";
import icon4 from "@/assets/images/period/icon4.png";
import icon5 from "@/assets/images/period/icon5.png";
import icon1 from "@/assets/images/period/icon1.png"
import icon2 from "@/assets/images/period/icon2.png"
import icon3 from "@/assets/images/period/icon3.png"
import icon4 from "@/assets/images/period/icon4.png"
import icon5 from "@/assets/images/period/icon5.png"
const periodList = ref([
    {
@@ -110,11 +143,11 @@
        data: [
            {
                label: "同比",
                value: '0',
        value: "0",
            },
            {
                label: "环比",
                value: '0',
        value: "0",
            },
        ],
    },
@@ -126,11 +159,11 @@
        data: [
            {
                label: "同比",
                value: '0',
        value: "0",
            },
            {
                label: "环比",
                value: '0',
        value: "0",
            },
        ],
    },
@@ -142,11 +175,11 @@
        data: [
            {
                label: "同比",
                value: '0',
        value: "0",
            },
            {
                label: "环比",
                value: '0',
        value: "0",
            },
        ],
    },
@@ -173,11 +206,10 @@
            },
        ],
    },
]);
])
const periodList1 = ref(
    [{
const periodList1 = ref([
  {
        icon: icon1,
        color: "#3371eb",
        title: "总电量(千瓦时)",
@@ -185,15 +217,15 @@
        data: [
            {
                label: "同比",
                value: '0',
        value: "0",
            },
            {
                label: "环比",
                value: '0',
        value: "0",
            },
            {
                label: "对比差值(千瓦时)",
                value: '0',
        value: "0",
            },
        ],
    },
@@ -205,15 +237,15 @@
        data: [
            {
                label: "同比",
                value: '0',
        value: "0",
            },
            {
                label: "环比",
                value: '0',
        value: "0",
            },
            {
                label: "对比差值(千瓦时)",
                value: '0',
        value: "0",
            },
        ],
    },
@@ -225,15 +257,15 @@
        data: [
            {
                label: "同比",
                value: '0',
        value: "0",
            },
            {
                label: "环比",
                value: '0',
        value: "0",
            },
            {
                label: "对比差值(千瓦时)",
                value: '0',
        value: "0",
            },
        ],
    },
@@ -283,11 +315,11 @@
            },
        ],
    },
    ]);
handleTimeType('YEAR')
])
handleTimeType("YEAR")
function handleTimeType(e) {
    form.value.timeType = e;
    form.value.date = proxy.dayjs(new Date()).format(e == "YEAR" ? "YYYY" : "YYYY-MM");
  form.value.timeType = e
  form.value.date = proxy.dayjs(new Date()).format(e == "YEAR" ? "YYYY" : "YYYY-MM")
    getList()
    getTableList()
}
@@ -295,7 +327,7 @@
let tableData = ref([])
//获取列表
function getList() {
    deviationCardList(form.value).then(res => {
  deviationCardList(form.value).then((res) => {
        if (res.code == 200) {
            let { CostElectricityData, CostStatisticsData } = res.data
            periodList.value = [
@@ -307,11 +339,11 @@
                    data: [
                        {
                            label: "同比",
                            value: CostElectricityData.electricityNumYoy ? CostElectricityData.electricityNumYoy + '%' : 0,
              value: CostElectricityData.electricityNumYoy ? CostElectricityData.electricityNumYoy + "%" : 0,
                        },
                        {
                            label: "环比",
                            value: CostElectricityData.electricityNumQoq ? CostElectricityData.electricityNumQoq + '%' : 0,
              value: CostElectricityData.electricityNumQoq ? CostElectricityData.electricityNumQoq + "%" : 0,
                        },
                    ],
                },
@@ -323,11 +355,11 @@
                    data: [
                        {
                            label: "同比",
                            value: CostElectricityData.electricityFeeYoy ? CostElectricityData.electricityFeeYoy + '%' : 0,
              value: CostElectricityData.electricityFeeYoy ? CostElectricityData.electricityFeeYoy + "%" : 0,
                        },
                        {
                            label: "环比",
                            value: CostElectricityData.electricityFeeQoq ? CostElectricityData.electricityFeeQoq + '%' : 0,
              value: CostElectricityData.electricityFeeQoq ? CostElectricityData.electricityFeeQoq + "%" : 0,
                        },
                    ],
                },
@@ -339,11 +371,11 @@
                    data: [
                        {
                            label: "同比",
                            value: CostElectricityData.powerFactorYoy ? CostElectricityData.powerFactorYoy + '%' : 0,
              value: CostElectricityData.powerFactorYoy ? CostElectricityData.powerFactorYoy + "%" : 0,
                        },
                        {
                            label: "环比",
                            value: CostElectricityData.powerFactorQoq ? CostElectricityData.powerFactorQoq + '%' : 0,
              value: CostElectricityData.powerFactorQoq ? CostElectricityData.powerFactorQoq + "%" : 0,
                        },
                    ],
                },
@@ -372,7 +404,8 @@
                },
            ]
            periodList1.value = [{
      periodList1.value = [
        {
                icon: icon1,
                color: "#3371eb",
                title: "总电量(千瓦时)",
@@ -380,15 +413,18 @@
                data: [
                    {
                        label: "同比",
                        value: CostStatisticsData && CostStatisticsData.electricityNumYoy ? CostStatisticsData.electricityNumYoy : 0,
              value:
                CostStatisticsData && CostStatisticsData.electricityNumYoy ? CostStatisticsData.electricityNumYoy : 0,
                    },
                    {
                        label: "环比",
                        value: CostStatisticsData && CostStatisticsData.electricityNumQoq ? CostStatisticsData.electricityNumQoq : 0,
              value:
                CostStatisticsData && CostStatisticsData.electricityNumQoq ? CostStatisticsData.electricityNumQoq : 0,
                    },
                    {
                        label: "对比差值(千瓦时)",
                        value: CostStatisticsData && CostStatisticsData.electricityNumDiff ? CostStatisticsData.electricityNumDiff : 0,
              value:
                CostStatisticsData && CostStatisticsData.electricityNumDiff ? CostStatisticsData.electricityNumDiff : 0,
                    },
                ],
            },
@@ -400,15 +436,18 @@
                data: [
                    {
                        label: "同比",
                        value: CostStatisticsData && CostStatisticsData.electricityFeeYoy ? CostStatisticsData.electricityFeeYoy : 0,
              value:
                CostStatisticsData && CostStatisticsData.electricityFeeYoy ? CostStatisticsData.electricityFeeYoy : 0,
                    },
                    {
                        label: "环比",
                        value: CostStatisticsData && CostStatisticsData.electricityNumQoq ? CostStatisticsData.electricityNumQoq : 0,
              value:
                CostStatisticsData && CostStatisticsData.electricityNumQoq ? CostStatisticsData.electricityNumQoq : 0,
                    },
                    {
                        label: "对比差值(千瓦时)",
                        value: CostStatisticsData && CostStatisticsData.electricityNumDiff ? CostStatisticsData.electricityNumDiff : 0,
              value:
                CostStatisticsData && CostStatisticsData.electricityNumDiff ? CostStatisticsData.electricityNumDiff : 0,
                    },
                ],
            },
@@ -439,7 +478,8 @@
                data: [
                    {
                        label: "尖",
                        value: CostStatisticsData && CostStatisticsData.sharpElectricity ? CostStatisticsData.sharpElectricity : 0,
              value:
                CostStatisticsData && CostStatisticsData.sharpElectricity ? CostStatisticsData.sharpElectricity : 0,
                    },
                    {
                        label: "峰",
@@ -451,7 +491,8 @@
                    },
                    {
                        label: "谷",
                        value: CostStatisticsData && CostStatisticsData.valleyElectricity ? CostStatisticsData.valleyElectricity : 0,
              value:
                CostStatisticsData && CostStatisticsData.valleyElectricity ? CostStatisticsData.valleyElectricity : 0,
                    },
                ],
            },
@@ -462,31 +503,42 @@
                data: [
                    {
                        label: "尖",
                        value: CostStatisticsData && CostStatisticsData.sharpElectricityDiff ? CostStatisticsData.sharpElectricityDiff : 0,
              value:
                CostStatisticsData && CostStatisticsData.sharpElectricityDiff
                  ? CostStatisticsData.sharpElectricityDiff
                  : 0,
                    },
                    {
                        label: "峰",
                        value: CostStatisticsData && CostStatisticsData.peakElectricityDiff ? CostStatisticsData.peakElectricityDiff : 0,
              value:
                CostStatisticsData && CostStatisticsData.peakElectricityDiff
                  ? CostStatisticsData.peakElectricityDiff
                  : 0,
                    },
                    {
                        label: "平",
                        value: CostStatisticsData && CostStatisticsData.flatElectricityDiff ? CostStatisticsData.flatElectricityDiff : 0,
              value:
                CostStatisticsData && CostStatisticsData.flatElectricityDiff
                  ? CostStatisticsData.flatElectricityDiff
                  : 0,
                    },
                    {
                        label: "谷",
                        value: CostStatisticsData && CostStatisticsData.valleyElectricityDiff ? CostStatisticsData.valleyElectricityDiff : 0,
              value:
                CostStatisticsData && CostStatisticsData.valleyElectricityDiff
                  ? CostStatisticsData.valleyElectricityDiff
                  : 0,
                    },
                ],
            },
            ]
        }
    })
}
function getTableList() {
    loading.value = true
    deviationTableList(form.value).then(res => {
  deviationTableList(form.value).then((res) => {
        tableData.value = []
        if (res.code == 200) {
            tableData.value.push(res.data)
@@ -509,12 +561,11 @@
    if (InfoModalRef.value) {
        InfoModalRef.value.handleOpen(row, form.value)
    }
}
let treeNode = ref([])
function handleNodeTree() {
    treeList(useRoute().query).then((response) => {
        treeNode.value = response.data;
    treeNode.value = response.data
    })
}
handleNodeTree()
@@ -523,18 +574,17 @@
function findLabelById(tree, targetId) {
    for (const node of tree) {
        if (node.id === targetId) {
            return node.label;
      return node.label
        }
        if (node.children && node.children.length > 0) {
            const result = findLabelById(node.children, targetId);
      const result = findLabelById(node.children, targetId)
            if (result) {
                return result;
        return result
            }
        }
    }
    return null;
  return null
}
</script>
<style lang="scss" scoped>
@@ -543,7 +593,6 @@
:deep(.el-table__expand-icon>.el-icon) {
    color: #cac9c9 !important;
}
.themeDark {
    .tree-title-box {
@@ -580,7 +629,7 @@
                .name {
                    font-family: OPPOSans, OPPOSans;
                    font-weight: bold;
                    font-size: 20px;
          font-size: 18px;
                    color: #fffdfd;
                    margin-left: 7px;
                }
@@ -647,7 +696,7 @@
                .name {
                    font-family: OPPOSans, OPPOSans;
                    font-weight: bold;
                    font-size: 20px;
          font-size: 18px;
                    color: #000;
                    margin-left: 7px;
                }