ali
2024-09-03 0ae83a895e80a4b9777a27f613d721a7e5e2ac18
energy_management_ui/src/views/basicsetting/energyIndex/energyIndex.vue
@@ -1,13 +1,22 @@
<template>
  <div class="app-container" style="padding:0">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="0"
             class="query-form">
  <div class="app-container" style="padding:0 0 30px 0">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="0"
      class="query-form"
    >
      <el-row :gutter="24">
        <el-col :span="5">
          <el-form-item>
            <el-select v-model="queryParams.indexCategory" placeholder="请选择指标分类" clearable
            <el-select
              v-model="queryParams.indexCategory"
              placeholder="请选择指标分类"
              clearable
                       size="small"
                       @change="handleQuery">
              @change="handleQuery"
            >
              <el-option
                  v-for="dict in indexCategoryOptions"
                  :key="dict.dictValue"
@@ -64,10 +73,12 @@
                @click="handleImport"
            >导入
            </el-button>
            <el-button type="text"
            <el-button
              type="text"
                       icon="el-icon-setting"
                       @click="collectIndexSetting"
                       v-if="!statisticIndex">
              v-if="!statisticIndex"
            >
              配置采集点
            </el-button>
          </el-form-item>
@@ -75,15 +86,33 @@
      </el-row>
    </el-form>
    <el-table v-loading="loading" :data="energyindexList" border
              @selection-change="handleSelectionChange">
    <el-table
      v-loading="loading"
      :data="energyindexList"
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="指标编码" align="center" prop="code"/>
      <el-table-column label="指标名称" align="center" prop="name"/>
      <el-table-column label="系统指标分类" align="center" prop="indexCategory"
                       :formatter="indexCategoryFormat"/>
      <el-table-column label="单位" align="center" prop="unitId" :formatter="unitIdFormat"/>
      <el-table-column label="操作" width="200" align="center" class-name="small-padding fixed-width">
      <el-table-column
        label="系统指标分类"
        align="center"
        prop="indexCategory"
        :formatter="indexCategoryFormat"
      />
      <el-table-column
        label="单位"
        align="center"
        prop="unitId"
        :formatter="unitIdFormat"
      />
      <el-table-column
        label="操作"
        width="200"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
              size="mini"
@@ -123,7 +152,12 @@
    />
    <!-- 添加或修改指标信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" :close-on-click-modal="false">
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="500px"
      :close-on-click-modal="false"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="指标名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入指标名称"/>
@@ -132,7 +166,11 @@
          <el-input v-model="form.code" placeholder="请输入指标编码"/>
        </el-form-item>
        <el-form-item label="指标分类">
          <el-select v-model="form.indexCategory" placeholder="请选择指标分类" prop="indexCategory">
          <el-select
            v-model="form.indexCategory"
            placeholder="请选择指标分类"
            prop="indexCategory"
          >
            <el-option
                v-for="dict in indexCategoryOptions"
                :key="dict.dictValue"
@@ -152,7 +190,11 @@
          </el-select>
        </el-form-item>
        <el-form-item label="顺序号">
          <el-input-number v-model="form.orderNum" controls-position="right" :min="0"/>
          <el-input-number
            v-model="form.orderNum"
            controls-position="right"
            :min="0"
          />
        </el-form-item>
        <el-form-item label="设备">
          <el-select v-model="form.equipment" placeholder="请选择设备">
@@ -181,24 +223,40 @@
      </div>
    </el-dialog>
    <el-drawer title="配置指标存储" :visible.sync="indexStorageShow" direction="rtl"
    <el-drawer
      title="配置指标存储"
      :visible.sync="indexStorageShow"
      direction="rtl"
               @open="showIndexStorageDialog"
               size="45%"
               :wrapperClosable="false">
      <IndexStorage ref="indexStorage"
                    :nodeId="currentNode===undefined?'':currentNode.id"></IndexStorage>
      :wrapperClosable="false"
    >
      <IndexStorage
        ref="indexStorage"
        :nodeId="currentNode === undefined ? '' : currentNode.id"
      ></IndexStorage>
    </el-drawer>
    <!--选择采集指标-->
    <el-drawer title="选择采集指标" :visible.sync="collectIndexDialog" direction="rtl"
    <el-drawer
      title="选择采集指标"
      :visible.sync="collectIndexDialog"
      direction="rtl"
               @open="showCollectIndexDialog"
               size="45%">
      <CollectIndexSetting ref="collectIndexSetting"
                           @collectIndexConfirmSelect="collectIndexConfirmSelect"></CollectIndexSetting>
      size="45%"
    >
      <CollectIndexSetting
        ref="collectIndexSetting"
        @collectIndexConfirmSelect="collectIndexConfirmSelect"
      ></CollectIndexSetting>
    </el-drawer>
    <!-- 导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" :destroy-on-close="true"
               width="400px">
    <el-dialog
      :title="upload.title"
      :visible.sync="upload.open"
      :destroy-on-close="true"
      width="400px"
    >
      <el-upload
          ref="upload"
          :limit="1"
@@ -219,9 +277,13 @@
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport"/>
          是否更新已经存在的用户数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
          <el-link type="info" style="font-size:12px" @click="importTemplate"
            >下载模板</el-link
          >
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
        <div class="el-upload__tip" style="color:red" slot="tip">
          提示:仅允许导入“xls”或“xlsx”格式文件!
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
@@ -242,13 +304,13 @@
  updateEnergyindex
} from "../../../api/basicsetting/energyindex";
import {getToken} from "@/utils/auth";
import {setNodeToIndex} from '@/api/basicsetting/modelNode'
import { setNodeToIndex } from "@/api/basicsetting/modelNode";
import IndexStorage from "./indexStorage";
import CollectIndexSetting from "../nodeSetting/collectIndexSetting";
import {getPointFacility} from "@/api/comprehensiveStatistics/comprehensive";
export default {
  name: 'EnergyIndex',
  name: "EnergyIndex",
  components: {CollectIndexSetting, IndexStorage},
  props: ["indexType"],
  data() {
@@ -298,12 +360,22 @@
      rules: {
        name: [
          {required: true, message: "指标名称不能为空", trigger: "blur"},
          {min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur'}
        ], code: [
          { min: 2, max: 20, message: "长度在 2 到 20 个字符", trigger: "blur" }
        ],
        code: [
          {required: true, message: "指标编码不能为空", trigger: "blur"},
          {min: 2, max: 20, message: '长度在 2 到 30 个字符', trigger: 'blur'},
          {pattern: /^[a-zA-Z][A-Za-z0-9#_-]+$/, message: '必须为数字、字母、#、- 或_ ,且首字符只能为字母'}
        ], indexCategory: [
          {
            min: 2,
            max: 20,
            message: "长度在 2 到 30 个字符",
            trigger: "blur"
          },
          {
            pattern: /^[a-zA-Z][A-Za-z0-9#_-]+$/,
            message: "必须为数字、字母、#、- 或_ ,且首字符只能为字母"
          }
        ],
        indexCategory: [
          {required: true, message: "请选择指标分类", trigger: "blur"}
        ]
      },
@@ -324,20 +396,23 @@
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/basicsetting/energyindex/importData"
      },
        url:
          process.env.VUE_APP_BASE_API + "/basicsetting/energyindex/importData"
      }
    };
  },
  created() {
    this.getDicts("sys_index_category").then(response => {
      this.indexCategoryOptions = response.data;
      this.indexCategoryDefaultVal = this.indexCategoryOptions.find(f => f.isDefault === 'Y');
      this.indexCategoryDefaultVal = this.indexCategoryOptions.find(
        f => f.isDefault === "Y"
      );
    });
    this.getDicts("sys_unit").then(response => {
      this.unitIdOptions = response.data;
      this.unitDefaultVal = this.unitIdOptions.find(f => f.isDefault === 'Y');
      this.unitDefaultVal = this.unitIdOptions.find(f => f.isDefault === "Y");
    });
    this.statisticIndex = this.$props.indexType === 'STATISTIC';
    this.statisticIndex = this.$props.indexType === "STATISTIC";
    this.getDicts("energy_type").then(response => {
      this.energyIdList = response.data;
    });
@@ -399,7 +474,7 @@
      this.ids = selection.map(item => item.indexId);
      this.names = selection.map(item => item.name);
      this.single = selection.length !== 1;
      this.multiple = !selection.length
      this.multiple = !selection.length;
    },
    getFacilityArchivesList() {
      getPointFacility().then(response => {
@@ -465,55 +540,64 @@
    handleDelete(row) {
      const indexIds = row.indexId || this.ids;
      const indexNames = row.name || this.names;
      this.$confirm('是否确认删除指标名为"' + indexNames + '"的数据项?', "警告", {
      this.$confirm(
        '是否确认删除指标名为"' + indexNames + '"的数据项?',
        "警告",
        {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        }
      )
        .then(() => {
        return delEnergyindex(this.currentNode.id, indexIds);
      }).then(() => {
        })
        .then(() => {
        this.getList(this.currentNode);
        this.msgSuccess("删除成功");
      }).catch(function () {
      });
        })
        .catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有指标信息数据项?', "警告", {
      this.$confirm("是否确认导出所有指标信息数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
      })
        .then(function() {
        return exportEnergyindex(queryParams);
      }).then(response => {
        })
        .then(response => {
        this.download(response.msg);
      }).catch(function () {
      });
        })
        .catch(function() {});
    },
    dataStorage(row) {
      this.indexStorageShow = true;
      this.$nextTick(() => {
        this.$refs.indexStorage.getIndexStorage(row.indexId);
      })
      });
    },
    showIndexStorageDialog() {
    },
    showIndexStorageDialog() {},
    collectIndexSetting() {
      this.collectIndexDialog = true;
    },
    showCollectIndexDialog() {
      this.$nextTick(() => {
        this.$refs.collectIndexSetting.init(this.currentNode);
      })
      });
    },
    collectIndexConfirmSelect(selectedIndex) {
      let indexIds = selectedIndex.map(item => item.indexId);
      setNodeToIndex(this.currentNode.id, indexIds, "COLLECT").then((response) => {
      setNodeToIndex(this.currentNode.id, indexIds, "COLLECT")
        .then(response => {
        if (response.code !== 200) {
          this.$message.error(response.msg);
        }
      }).then(() => {
        })
        .then(() => {
        this.getList(this.currentNode);
      });
    },