Przeglądaj źródła

数据管理对接

ming 3 lat temu
rodzic
commit
31dccc50cd

+ 2 - 2
src/utils/index.js

@@ -49,7 +49,7 @@ export function parseTime2(time, cFormat) {
     if (arguments.length === 0) {
         return null
     }
-    const format = cFormat || '{y}-{m}-{d}'
+    const format = cFormat || '{y}-{m}'
     let date
     if (typeof time === 'object') {
         date = time
@@ -65,7 +65,7 @@ export function parseTime2(time, cFormat) {
     const formatObj = {
         y: date.getFullYear(),
         m: date.getMonth() + 1,
-        d: date.getDate(),
+
 
     }
     return format.replace(/{([ymdhisa])+}/g, (result, key) => {

+ 1 - 1
src/views/dataManage/chainAnalysis/index.vue

@@ -119,7 +119,7 @@ export default defineComponent({
      const typeSrarch = ref(0)
      const treeCheckedList = ref([])
       const valueCalculation = ref()
-      const dateTime = ref('')
+      const dateTime = ref([new Date(2021, 9, 1, 10, 10), new Date(2021, 9, 30, 10, 10)],)
     const ecahrtsData = ref({})
     const state = reactive({
       value1: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],

+ 35 - 46
src/views/dataManage/demandAnalysis/ehcarts/index.vue

@@ -4,7 +4,7 @@
   </div>
 </template>
 <script>
-import { computed, defineComponent, onMounted, ref } from 'vue'
+import { computed, defineComponent, onMounted, ref ,watch} from 'vue'
 import { useStore } from 'vuex'
 import * as echarts from 'echarts'
 // import { ChartDataType } from "../../data";
@@ -13,8 +13,9 @@ export default defineComponent({
   name: 'CurveCom',
   props: {
     Height: String,
+    echartsData:Object
   },
-  setup() {
+  setup(props) {
     const store = useStore()
 
     // 总数
@@ -25,13 +26,10 @@ export default defineComponent({
     // 读取数据 func
     const loading = ref(true)
     const getData = async () => {
-      // loading.value = true
-      //   await store.dispatch('Home/queryWorksChartData')
+      console.log(props.echartsData.name)
       loading.value = false
     }
-
-    onMounted(() => {
-      getData()
+    function echarts2(){
       let myChart = echarts.init(document.getElementById('worksChartRef'))
       // 绘制图表
       myChart.setOption({
@@ -63,39 +61,7 @@ export default defineComponent({
         xAxis: [
           {
             type: 'category',
-            data: [
-              '5-01',
-              '5-02',
-              '5-03',
-              '5-04',
-              '5-05',
-              '5-06',
-              '5-07',
-              '5-08',
-              '5-09',
-              '5-10',
-              '5-11',
-              '5-12',
-              '5-13',
-              '5-14',
-              '5-15',
-              '5-16',
-              '5-17',
-              '5-18',
-              '5-19',
-              '5-20',
-              '5-21',
-              '5-22',
-              '5-23',
-              '5-24',
-              '5-25',
-              '5-26',
-              '5-27',
-              '5-28',
-              '5-29',
-              '5-30',
-              '5-31',
-            ],
+            data:props.echartsData.listDate,
             boundaryGap: true,
             axisTick: {
               show: false, //去除刻度线
@@ -141,12 +107,7 @@ export default defineComponent({
           {
             name: '(kw)',
             type: 'bar',
-            data: [
-              2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4,
-              3.3, 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0,
-              6.4, 3.3, 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6,
-              20.0,
-            ],
+            data:props.echartsData.list,
             markPoint: {
               data: [
                 { type: 'max', name: 'Max' },
@@ -159,12 +120,40 @@ export default defineComponent({
       window.addEventListener('resize', () => {
         myChart.resize()
       })
+
+    }
+    const writeValue = (val) => {
+      val
+      echarts2()
+      getData()
+    }
+
+    //监听变化
+    watch(
+      () => props.echartsData,
+      (newVal, oldVal, clear) => {
+        // 执行异步任务,并得到关闭异步任务的 id
+
+        // alert(1)
+        console.log(newVal)
+        let id = writeValue(newVal, oldVal)
+        // 如果 watch 监听被重复执行了,则会先清除上次未完成的异步任务
+        clear(() => clearTimeout(id))
+      },
+      { lazy: true }
+    )
+
+    onMounted(() => {
+      getData()
+      echarts2()
+      
     })
 
     return {
       loading,
       total,
       num,
+      echarts2
     }
   },
 })

+ 60 - 224
src/views/dataManage/demandAnalysis/index.vue

@@ -2,7 +2,7 @@
   <div class="demandAnalysis">
     <div class="demContent1">
       <div style="display: flex">
-       <el-select
+        <el-select
           v-model="store.state.siteId"
           @change="siteChange"
           placeholder="选择站点"
@@ -22,12 +22,11 @@
           :data="deviceBoxData"
           show-checkbox
           node-key="id"
-           @node-click="handleNodeClick"
+          @node-click="handleNodeClick"
           accordion
           :check-strictly="true"
           :props="defaultProps"
-          @check="currentChecked"
-          highlight-current="showTree"
+          highlight-current
         />
       </div>
     </div>
@@ -38,26 +37,28 @@
             <span class="demonstration" style="color: black">日期:</span>
             <el-date-picker
               v-model="dateTime"
-              type="day"
+              type="month"
               placeholder="请选择日期"
             ></el-date-picker>
           </div>
         </div>
 
         <el-radio-group
-            v-model="listTabPosition"
-            @change="listTabsChange(listTabPosition)"
-            style="display: flex"
-          >
-            <el-radio-button label="cycleValue">电费结算周期</el-radio-button>
-            <el-radio-button label="monthValue">自然月</el-radio-button>
-          </el-radio-group>
+          v-model="listTabPosition"
+          @change="listTabsChange(listTabPosition)"
+          style="display: flex"
+        >
+          <el-radio-button label="cycleValue">电费结算周期</el-radio-button>
+          <el-radio-button label="monthValue">自然月</el-radio-button>
+        </el-radio-group>
 
-         <div style="margin-left: 10px">
-            <el-button icon="el-icon-search" type="primary"  @click="searchData()">查询</el-button>
-          </div>
+        <div style="margin-left: 10px">
+          <el-button icon="el-icon-search" type="primary" @click="searchData()">
+            查询
+          </el-button>
+        </div>
       </div>
-      <div class="demEcharTable">
+      <div class="demEcharTable" v-if="flag">
         <div class="Echarts">
           <div class="ehcartOne">
             <i
@@ -67,43 +68,20 @@
             <span style="font-size: 15px">{{}}每日最大需量趋势</span>
           </div>
           <div>
-            <echarts :Height="Height"></echarts>
+            <echarts :Height="Height" :echartsData="echartsData"></echarts>
           </div>
         </div>
         <div class="Tables">
           <el-table
-            :data="
-              tableData.slice(
-                0,
-                tableData.length % 2
-                  ? tableData.length / 2 + 1
-                  : tableData.length / 2
-              )
-            "
+            :data="tableData"
             :height="Height"
             style="width: 100%"
             id="tables1"
+             border
+        stripe
           >
-            <el-table-column prop="date" label="日期" width="" />
-            <el-table-column prop="maximum" label="最大需量(kw)" width="110" />
-            <el-table-column prop="time" label="时间" />
-          </el-table>
-          <el-table
-            :data="
-              tableData.slice(
-                tableData.length % 2
-                  ? tableData.length / 2 + 1
-                  : tableData.length / 2,
-                tableData.length
-              )
-            "
-            :height="Height"
-            style="width: 100%"
-            id="tables2"
-          >
-            <el-table-column prop="date" label="日期" width="" />
-            <el-table-column prop="maximum" label="最大需量(kw)" width="110" />
-            <el-table-column prop="time" label="时间" />
+            <el-table-column prop="listDate" label="日期" width=""  align="center"/>
+            <el-table-column prop="list" label="最大需量(kw)" width=""  align="center"/>
           </el-table>
         </div>
       </div>
@@ -112,7 +90,7 @@
 </template>
 <script>
 import { useStore } from 'vuex'
-import { defineComponent, ref, reactive, toRefs,onMounted } from 'vue'
+import { defineComponent, ref, reactive, toRefs, onMounted } from 'vue'
 import echarts from './ehcarts/index.vue'
 import { parseTime2 } from '@/utils'
 
@@ -126,10 +104,10 @@ export default defineComponent({
   props: {},
   setup() {
     const store = useStore()
-
+    const tableData=ref([])
     const deviceBoxData = ref([])
     const deviceChecked = ref([])
-     const dateTime = ref(new Date())
+    const dateTime = ref(new Date())
     const typeSrarch = ref(1)
     const flag = ref(false)
     const echartsData = ref({})
@@ -139,10 +117,7 @@ export default defineComponent({
     }
 
     const listTabsChange = (value) => {
-       value == 'monthValue'
-          ? (typeSrarch.value = 2)
-        
-          : (typeSrarch.value = 1)
+      value == 'monthValue' ? (typeSrarch.value = 2) : (typeSrarch.value = 1)
       console.log(value)
     }
     const handleNodeClick = (data, obj, node) => {
@@ -183,28 +158,42 @@ export default defineComponent({
           }
         })
     }
-     function searchData() {
-      if (deviceChecked.value.length>0) {
+    function searchData() {
+      if (deviceChecked.value.length > 0) {
         // alert(1)
         // store.commit('TimeAll_function', dateTime.value)
         // const time = store.state.Time_Data
 
-         dateTime.value
-        ? (dateTime.value = parseTime2(
-            dateTime.value
-          ))
-        : ''
+        dateTime.value ? (dateTime.value = parseTime2(dateTime.value)) : ''
         api
           .demandAnalysis({
             cycle: typeSrarch.value,
-            monthDate:dateTime.value,
-            deviceCode:deviceChecked.value
-
+            monthDate: dateTime.value,
+            deviceCode: deviceChecked.value,
           })
           .then((requset) => {
             if (requset.status === 'SUCCESS') {
               flag.value = true
-               echartsData.value = requset.data[0]
+              echartsData.value = requset.data[0]
+
+
+              //重组表格数据
+              var list = requset.data[0].list
+              var listDate = requset.data[0].listDate
+              var newArr1 = []
+              var newArr2 = []
+              list.forEach((item) => {
+                newArr1.push({ list: item })
+              })
+              listDate.forEach((item) => {
+                newArr2.push({ listDate: item })
+              })
+              var newObj = newArr1.map((item, index) => {
+                return { ...item, ...newArr2[index] }
+              })
+              tableData.value=newObj
+
+
             } else {
               ElMessage.error(requset.msg)
             }
@@ -232,10 +221,13 @@ export default defineComponent({
       searchData,
       handleNodeClick,
       store,
-       listTabPosition: ref('cycleValue'), //单选按钮
+      listTabPosition: ref('cycleValue'), //单选按钮
       deviceBoxData,
       deviceChecked,
-      dateTime,typeSrarch,flag,echartsData,
+      dateTime,
+      typeSrarch,
+      flag,
+      echartsData,
       data: [
         {
           id: 1,
@@ -275,168 +267,12 @@ export default defineComponent({
         },
       ]),
       defaultProps: {
-       children: 'children',
+        children: 'children',
         label: 'deviceName',
         deviceCode: 'deviceCode',
         id: 'id',
       },
-      tableData: [
-        {
-          date: '05-01',
-          maximum: 'Tom',
-          time: '11:01:08',
-        },
-        {
-          date: '05-02',
-          maximum: 'Tom',
-          time: '09:26:13',
-        },
-        {
-          date: '05-03',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-04',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-05',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-06',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-07',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-08',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-09',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-10',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-11',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-12',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-13',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-14',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-15',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-16',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-17',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-18',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-19',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-20',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-21',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-22',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-23',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-24',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-25',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-26',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-27',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-28',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-29',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-30',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-        {
-          date: '05-31',
-          maximum: 'Tom',
-          time: 'No. 189',
-        },
-      ],
+      tableData
     }
   },
 })
@@ -511,7 +347,7 @@ export default defineComponent({
 }
 </style>
 <style>
-.el-table--scrollable-y .el-table__body-wrapper::-webkit-scrollbar{
+.el-table--scrollable-y .el-table__body-wrapper::-webkit-scrollbar {
   overflow-y: hidden;
 }
 </style>

+ 17 - 43
src/views/dataManage/energyReport/ehcarts/index.vue

@@ -26,36 +26,9 @@ export default defineComponent({
     // 读取数据 func
     const loading = ref(true)
 
-    // const data = ref([
-    //   {
-    //     name: '进线',
-    //     list: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
-    //     listDate: props.echartsData.listDate,
-    //   },
-    // ])
-
-    // const dataAll = ref([
-    //   {
-    //     name: '进线(kWh)',
-    //     type: 'line',
-    //     smooth: false,
-    //     data: props.echartsData.list,
-    //     symbolSize: 6,
-    //     markPoint: {
-    //       data: [
-    //         { type: 'max', name: 'Max' },
-    //         { type: 'min', name: 'Min' },
-    //       ],
-    //     },
-    //   },
-    // ])
-
     const getData = async () => {
-      console.log('子组件中的props.ecahrtsData')
+      console.log('ecahrts子组件中的props.ecahrtsData')
       console.log(props.echartsData)
-
-      // loading.value = true
-      // await store.dispatch('Home/queryWorksChartData')
       loading.value = false
     }
 
@@ -102,7 +75,7 @@ export default defineComponent({
           type: 'category',
           boundaryGap: true,
           data: props.echartsData.listDate.map((val) => {
-            return val.split(':')[0] 
+            return val.split(':')[0]
           }),
           axisTick: {
             show: false, //去除刻度线
@@ -142,20 +115,20 @@ export default defineComponent({
           },
         },
         series: [
-      {
-        name: '电量(kWh)',
-        type: 'line',
-        smooth: false,
-        data: props.echartsData.list,
-        symbolSize: 6,
-        markPoint: {
-          data: [
-            { type: 'max', name: 'Max' },
-            { type: 'min', name: 'Min' },
-          ],
-        },
-      },
-    ],
+          {
+            name: '电量(kWh)',
+            type: 'line',
+            smooth: false,
+            data: props.echartsData.list,
+            symbolSize: 6,
+            markPoint: {
+              data: [
+                { type: 'max', name: 'Max' },
+                { type: 'min', name: 'Min' },
+              ],
+            },
+          },
+        ],
       })
       window.onresize = function () {
         // 自适应大小
@@ -164,6 +137,7 @@ export default defineComponent({
     }
 
     onMounted(() => {
+      // alert(1)
       getData()
       echarts2()
     })

+ 25 - 20
src/views/dataManage/energyReport/index.vue

@@ -34,8 +34,7 @@
           accordion
           :check-strictly="true"
           :props="defaultProps"
-          @check="currentChecked"
-          highlight-current="showTree"
+          highlight-current
         />
       </div>
     </div>
@@ -94,23 +93,21 @@
               @change="listTabsChange(rightTabs)"
               style="display: flex"
             >
-              <el-radio-button label="tables">表格</el-radio-button>
               <el-radio-button label="echarts">图表</el-radio-button>
+              <el-radio-button label="tables">表格</el-radio-button>
             </el-radio-group>
           </div>
         </div>
       </div>
       <div class="energEcharts">
-        <echarts
-          v-if="rightTabsBool && flag"
-          :echartsData="echartsData"
-          :Height="Height"
-        ></echarts>
-        <tables
-          v-if="!rightTabsBool"
-          :tableDatas="echartsData"
-          :Height="Height"
-        ></tables>
+        <template v-if="flag">
+          <echarts
+            v-if="rightTabsBool"
+            :echartsData="echartsData"
+            :Height="Height"
+          ></echarts>
+          <tables v-else :tableDatas="echartsData" :Height="Height"></tables>
+        </template>
       </div>
     </div>
   </div>
@@ -132,15 +129,14 @@ export default defineComponent({
   props: {},
   setup() {
     const store = useStore()
-    const showTree = ref(true)
-
+    // const showTree = ref(true)
+    // const timer=ref('')
     const dateTime = ref([new Date(2021, 10, 1), new Date(2021, 10, 30)])
     const typeSrarch = ref(1)
     const flag = ref(false)
     const echartsData = ref({})
 
     let dateType = ref('date')
-    
 
     const deviceBoxData = ref([])
     const deviceChecked = ref([])
@@ -165,9 +161,17 @@ export default defineComponent({
       } else if (value == 'electriQuan' || value == 'electriFees') {
         console.log()
       } else if (value == 'tables' || value == 'echarts') {
-        value == 'echarts'
-          ? (rightTabsBool.value = true)
-          : (rightTabsBool.value = false)
+        searchData()
+        // timer.value = new Date().getTime()
+        //   console.log('timer.value')
+        //    console.log(timer.value)
+
+        if (value == 'echarts') {
+          rightTabsBool.value = true 
+        } else {
+          rightTabsBool.value = false
+        }
+        console.log(rightTabsBool.value)
       }
 
       console.log(dateType)
@@ -269,7 +273,7 @@ export default defineComponent({
       searchData,
       dateTime,
       deviceBoxList,
-      showTree,
+      // showTree,
       data: [
         {
           id: 1,
@@ -299,6 +303,7 @@ export default defineComponent({
       deviceBoxData,
       deviceChecked,
       echartsData,
+      // timer,
       handleNodeClick,
     }
   },

+ 56 - 79
src/views/dataManage/energyReport/tables/index.vue

@@ -1,44 +1,14 @@
 <template>
   <div>
     <div style="margin: 0 15px">
-      <!-- <el-table
-        :data="tableData"
+      <el-table
+        :data="tableData6"
         border
         stripe
-        :header-cell-style="headClass"
-        :height="Height"
+        style="max-width: 100%"
+        :key="Math.random()"
       >
-        <el-table-column type="index" label="名称" width="50"></el-table-column>
-        <el-table-column
-          prop="numCode"
-          label="变量编码"
-          width=""
-        ></el-table-column>
-        <el-table-column
-          prop="refValue"
-          label="基准值"
-          width=""
-        ></el-table-column>
-        <el-table-column
-          prop="refValue"
-          label="合计"
-          width=""
-        ></el-table-column>
-        <el-table-column
-          prop="refValue"
-          label="单位"
-          width=""
-        ></el-table-column>
-      </el-table> -->
-
-      <el-table :data="tableData6" border style="max-width: 100%">
-          <el-table-column
-          props="name"
-          label="名称"
-          width=""
-        ></el-table-column>
         <template v-for="(item, index) in cols" :key="index">
-          
           <el-table-column :prop="item.prop" :label="item.label" align="center">
             <template #default="scope">
               <span>
@@ -53,64 +23,78 @@
 </template>
 <script>
 // import { useStore } from "vuex";
-import { defineComponent, watch, ref,onMounted } from 'vue'
+import { defineComponent, watch, ref, onMounted } from 'vue'
 
 export default defineComponent({
   name: 'consumConfig',
   components: {},
-  props: {
-    Height: String,
-    tableDatas: Object,
-  },
+  props: ['Height', 'tableDatas'],
+
   setup(props) {
     const Update = (row) => {
       console.log('', row)
     }
-
-    // 表头样式设置
-    const headClass = () => {
-      return 'background:#FAFAFA !important;color: black;'
-    }
+    
+    //处理数据
     const getData = async () => {
-      console.log('子组件中的props.tableDatas')
+      console.log('table子组件中的props.tableDatas')
       console.log(props.tableDatas.listDate)
-
       var aa = props.tableDatas.listDate
       var newArr=[]
       aa.forEach((item, index) => {
-        newArr.push({'label':item,'prop':index})
+        newArr.push({ label: item, prop: index.toString() })
       })
-      
-      
-      // newArr.unshift({'label':'单位','prop':'unit'});
-      // newArr.unshift({'label':'合计','prop':'total'});
-      // newArr.unshift({'label':'名称','prop':'name'});
+
+      newArr.push({ label: '合计', prop: 'total' },{ label: '单位', prop: 'unit' })
+      newArr.unshift({ label: '名称', prop: 'name' })
       console.log(newArr)
-      cols.value=newArr
+      cols.value = newArr
 
-      var bb=props.tableDatas.list;
-      var obj={}
-      bb.forEach((item,index)=>{
-        obj[index]=item
+      var bb = props.tableDatas.list
+      var obj = {}
+      bb.forEach((item, index) => {
+        obj[index] = item
       })
-      obj.name='进线'
-
+      obj.name = props.tableDatas.name
+      obj.unit = 'kWh'
+      obj.total = sum(props.tableDatas.list).toFixed(2)
       console.log(obj)
-tableData6.value[0]=obj
-      
-
-    
+      tableData6.value[0] = obj
     }
     const cols = ref([
-      { label: '名称', prop: 'name' },
-      { label: '合计', prop: 'total' },
-      { label: '单位', prop: 'unit' },
-      { label: '2020-22-20', prop: 1 },
+      // { label: '名称', prop: 'name' },
+      // { label: '合计', prop: 'total' },
+      // { label: '单位', prop: 'unit' },
+      // { label: '2020-22-20', prop: 1 },
     ])
     const tableData6 = ref([
-      {0: 559.2, 1: 616.8, 2: 583.99, 3: 546.39, 4: 498.8, 5: 574.41, 6: 780.4, 7: 794.39, 8: 767.59}
+      // {
+      //   0: 559.2,
+      //   1: 616.8,
+      //   2: 583.99,
+      //   3: 546.39,
+      //   4: 498.8,
+      //   5: 574.41,
+      //   6: 780.4,
+      //   7: 794.39,
+      //   8: 767.59,
+      // },
     ])
 
+    // 表头样式设置
+    const headClass = () => {
+      return 'background:#FAFAFA !important;color: black;'
+    }
+
+    // 求和
+    function sum(arr) {
+      var s = 0
+      for (var i = arr.length - 1; i >= 0; i--) {
+        s += arr[i]
+      }
+      return s
+    }
+
     const writeValue = (val) => {
       val
       getData()
@@ -121,8 +105,7 @@ tableData6.value[0]=obj
       () => props.tableDatas,
       (newVal, oldVal, clear) => {
         // 执行异步任务,并得到关闭异步任务的 id
-
-        alert(1)
+        // alert(1)
         console.log(newVal)
         let id = writeValue(newVal, oldVal)
         // 如果 watch 监听被重复执行了,则会先清除上次未完成的异步任务
@@ -130,23 +113,17 @@ tableData6.value[0]=obj
       },
       { lazy: true }
     )
-     onMounted(() => {
+    onMounted(() => {
       getData()
-  
     })
 
-
     return {
       headClass,
       Update, //修改偏差配置事件
       cols,
       tableData6,
-      tableData: [
-        {
-          numCode: '电量',
-          refValue: 'Tom',
-        },
-      ],
+      // newArr
+     
     }
   },
 })

+ 69 - 76
src/views/dataManage/sameAnalysis/ehcarts/index.vue

@@ -1,5 +1,6 @@
 <template>
   <div shadow="never" class="homeBoxCard" v-loading="loading">
+    <div>{{aa}}</div>
     <div :style="'height:' + Height" ref="sumeChartRef" />
   </div>
 </template>
@@ -9,47 +10,47 @@ import { useStore } from 'vuex'
 import * as echarts from 'echarts'
 // import { ChartDataType } from "../../data";
 
-const dataAll = [
-  {
-    name: 'IA(A)',
-    type: 'line',
-    smooth: false,
-    data: [0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.7, 0, 0],
-    symbolSize: 6,
-    markPoint: {
-      data: [
-        { type: 'max', name: 'Max' },
-        { type: 'min', name: 'Min' },
-      ],
-    },
-  },
-  {
-    name: 'IB(A)',
-    type: 'line',
-    smooth: false,
-    data: [0, 0, 0.2, 0, 0, 0, 0, 0.8, 0, 0, 0, 0],
-    symbolSize: 6,
-    markPoint: {
-      data: [
-        { type: 'max', name: 'Max' },
-        { type: 'min', name: 'Min' },
-      ],
-    },
-  },
-  {
-    name: 'IC(A)',
-    type: 'line',
-    smooth: false,
-    data: [0, 0.1, 0, 0, 0, 0.9, 0, 0, 0, 0, 0, 0],
-    symbolSize: 6,
-    markPoint: {
-      data: [
-        { type: 'max', name: 'Max' },
-        { type: 'min', name: 'Min' },
-      ],
-    },
-  },
-]
+// const dataAll = [
+//   {
+//     name: 'IA(A)',
+//     type: 'line',
+//     smooth: false,
+//     data: [0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.7, 0, 0],
+//     symbolSize: 6,
+//     markPoint: {
+//       data: [
+//         { type: 'max', name: 'Max' },
+//         { type: 'min', name: 'Min' },
+//       ],
+//     },
+//   },
+//   {
+//     name: 'IB(A)',
+//     type: 'line',
+//     smooth: false,
+//     data: [0, 0, 0.2, 0, 0, 0, 0, 0.8, 0, 0, 0, 0],
+//     symbolSize: 6,
+//     markPoint: {
+//       data: [
+//         { type: 'max', name: 'Max' },
+//         { type: 'min', name: 'Min' },
+//       ],
+//     },
+//   },
+//   {
+//     name: 'IC(A)',
+//     type: 'line',
+//     smooth: false,
+//     data: [0, 0.1, 0, 0, 0, 0.9, 0, 0, 0, 0, 0, 0],
+//     symbolSize: 6,
+//     markPoint: {
+//       data: [
+//         { type: 'max', name: 'Max' },
+//         { type: 'min', name: 'Min' },
+//       ],
+//     },
+//   },
+// ]
 
 const yName = 'kV'
 
@@ -57,56 +58,46 @@ export default defineComponent({
   name: 'CurveCom',
   props: {
     ecahrtsData: Object,
-    title: String,
+  
   },
 
   setup(props) {
     props
     const store = useStore()
     const sumeChartRef = ref(null)
+    const newData=ref([])
 
-    const listData = ref([])
+    // const listData = ref([])
 
     // 总数
-    const total = computed(() => store.state.Home.worksChartData.total)
     // num
     const num = computed(() => store.state.Home.worksChartData.num)
     const newDataName = ref('')
+    const aa=ref('')
 
     // 读取数据 func
     const loading = ref(true)
     const getData = async () => {
-      // loading.value = true
-      // await store.dispatch('Home/queryWorksChartData')
       loading.value = false
-      console.log('props.ecahrtsData')
-      console.log(props.ecahrtsData.list)
+      // console.log('props.ecahrtsData')
+      // console.log(props.ecahrtsData)
+      aa.value=props.ecahrtsData[0].name;
+      var jsona = JSON.stringify(props.ecahrtsData)
+      var jsonb = jsona.replace(/"list"/g, '"data"')
+      newData.value = JSON.parse(jsonb)
 
-      listData.value = props.ecahrtsData.list.map((x) => {
-        return x.dataTime
-      }) // 生成数组
-      // var newArrValue=[]
-      props.ecahrtsData.list.map((obj) => {
-        var valueArr = []
-        var nameArr = []
-        for (var i in obj) {
-          if (i != 'dataTime') {
-            nameArr.push(i)
-            valueArr.push(obj[i])
-          }
-         
+      newData.value.forEach((value) => {
+        value.type = 'line'
+        value.smooth = false
+        value.symbolSize = 6
+        value.markPoint = {
+          data: [
+            { type: 'max', name: 'Max' },
+            { type: 'min', name: 'Min' },
+          ],
         }
-         console.log(obj)
-        console.log('obj')
-        // console.log('nameArr')
-        // console.log(nameArr)
-        // console.log('valueArr')
-        // console.log(valueArr)
-
-        // newArrValue.push(valueArr)
       })
-      //  console.log('newArrValue')
-      // console.log(newArrValue)
+      console.log(newData.value)
     }
     function ecahrts() {
       let myChart = echarts.init(sumeChartRef.value)
@@ -145,7 +136,7 @@ export default defineComponent({
         xAxis: {
           type: 'category',
           boundaryGap: true,
-          data: listData.value,
+          data: props.ecahrtsData[0].listDate,
           axisTick: {
             show: false, //去除刻度线
           },
@@ -183,8 +174,8 @@ export default defineComponent({
             },
           },
         },
-        series: dataAll,
-      })
+        series: newData.value,
+      },true)
       window.onresize = function () {
         // 自适应大小
         myChart.resize()
@@ -203,7 +194,7 @@ export default defineComponent({
       (newVal, oldVal, clear) => {
         alert(1)
         // 执行异步任务,并得到关闭异步任务的 id
-        console.log(newVal)
+        // console.log(newVal)
         let id = writeValue(newVal, oldVal)
         // 如果 watch 监听被重复执行了,则会先清除上次未完成的异步任务
         clear(() => clearTimeout(id))
@@ -225,9 +216,11 @@ export default defineComponent({
       Height,
       sumeChartRef,
       loading,
-      total,
+      aa,
       num,
       newDataName,
+      newData,
+      ecahrts
     }
   },
 })

+ 16 - 4
src/views/dataManage/sameAnalysis/index.vue

@@ -79,7 +79,9 @@
         </el-radio-group>
       </div>
       <div class="sameEcharts">
-        <echarts :ecahrtsData="ecahrtsData" :title="123" v-if="flag"></echarts>
+         <echarts :ecahrtsData="ecahrtsData"  v-if="flag"></echarts>
+        <!-- <echarts :ecahrtsData="ecahrtsData"  v-if="flag&&ecahrtsData.length>0"></echarts> -->
+        <!-- <div v-else style="text-align:center;margin:50px">暂无数据</div> -->
       </div>
     </div>
   </div>
@@ -141,7 +143,17 @@ export default defineComponent({
     }
 
     function searchData() {
-      ecahrtsData.value = {}
+  
+
+      if(!dateTime.value){
+        ElNotification({
+          title: '提示',
+          message: '请选择开始和结束时间',
+          type: 'warning',
+        })
+        return
+      }
+
       if (treeCheckedList.value.length > 0) {
         console.log('', store.state.deviceList)
         console.log('treeCheckedList')
@@ -159,7 +171,7 @@ export default defineComponent({
           .then((requset) => {
             if (requset.status === 'SUCCESS') {
               flag.value = true
-              ecahrtsData.value = requset.data[0]
+              ecahrtsData.value = requset.data
             } else {
               ElMessage.error(requset.msg)
             }
@@ -180,7 +192,7 @@ export default defineComponent({
     }
 
     onMounted(() => {
-      // searchData()
+     
     })
 
     return {

+ 7 - 3
src/views/siteManage/index.vue

@@ -82,14 +82,14 @@
     <!-- 树形组件end -->
 
     <!-- 站点主题start -->
-    <div class="grid-content nestingDom" style="width: calc(100% - 300px)">
+    <div class="grid-content nestingDom" style="width: calc(100% - 300px)" v-if="flag2">
       <el-tabs
         v-if="treeLevel == 3 || groupingId == 0"
         v-model="activeName"
         type="card"
       >
         <el-tab-pane label="基本信息" name="first">
-          <basic-info class="basicInfo" :siteId="siteId"></basic-info>
+          <basic-info class="basicInfo" :siteId="siteId" :lalala="siteId"></basic-info>
         </el-tab-pane>
         <el-tab-pane label="监控设备" name="second" :siteId="siteId">
           <watch-dog
@@ -168,13 +168,14 @@ export default defineComponent({
     addSiteCom,
   },
   setup() {
+    const flag2=ref(false)
     const showTree = ref(true)
     const defaultExpand=ref(0)
     const showDialog = ref(false)
     const showDialog2 = ref(false)
     const dialogTitle = ref('')
     const treeLevel = ref(3)
-    const groupingId = ref(0)
+    const groupingId = ref(1)
     const siteId = ref(368)
     const label = ref('')
     const activeName = ref('second')
@@ -248,6 +249,7 @@ export default defineComponent({
     }
     const handleNodeClick = (data, obj, node) => {
       data, node
+      flag2.value=true
       console.log(obj.data)
       treeLevel.value = obj.level
       groupingId.value = obj.data.grouping_id
@@ -277,6 +279,7 @@ export default defineComponent({
       showDialog.value = false
       showDialog2.value = false
       siteTreeList()
+      flag2.value=false
 
       treeLevel.value = 3
     }
@@ -358,6 +361,7 @@ export default defineComponent({
       groupingId,
       siteId,
       label,
+      flag2,
 
       showTree,