a1140836302 2 سال پیش
والد
کامیت
e66f54c119

+ 17 - 1
src/api/equipment.js

@@ -34,4 +34,20 @@ export function getStoreCode() {
     url: '/device/getStoreCode',
     method: 'get'
   })
-}
+}
+//开始充电
+export function startCharge(data) {
+  return request({
+    url: '/discharge/startCharge',
+    method: 'post',
+    params:data,
+  })
+}
+//断电
+export function stopCharge(data) {
+  return request({
+    url: '/discharge/stopCharge',
+    method: 'post',
+    params:data
+  })
+}

+ 16 - 0
src/api/log.js

@@ -15,4 +15,20 @@ export function robotList(data) {
       method: 'post',
       data
     })
+}
+//充电机日志列表
+export function chargerList(data) {
+  return request({
+    url: '/log/chargerList',
+    method: 'post',
+    data
+  })
+}
+//BMS日志列表
+export function bmsList(data) {
+  return request({
+    url: '/log/bmsList',
+    method: 'post',
+    data
+  })
 }

+ 36 - 10
src/views/equipment-monitoring/components/BatteryCharger.vue

@@ -11,9 +11,10 @@
 </template>
 
 <script>
+    import { startCharge, stopCharge } from '@/api/equipment'
     export default {
         name: "BatteryCharger",
-        props:['chargerCode','comState','chgState'],
+        props:['chargerCode','comState','chgState',"sn","storeState"],
         data(){
             return{
                 loading:false,
@@ -28,9 +29,9 @@
                 }
             },
             buttonState(){
-                if(this.chgState === 0 || this.chgState === 3){
+                if((this.chgState === 0 || this.chgState === 3) && this.storeState === 1){
                     return ['btnState','充电']
-                }else if(this.chgState === 2){
+                }else if(this.chgState === 2  && this.storeState === 1){
                     return ['purple','断电']
                 }else{
                     return 1
@@ -38,7 +39,14 @@
             }
         },
         methods:{
+            //充电、断电操作
             sendCharger(){
+                let params={}
+                if(this.chgState === 0 || this.chgState === 3){
+                    params={chargerId:this.chargerCode*1,sn:this.sn}
+                }else if(this.chgState === 2){
+                    params={chargerId:this.chargerCode*1}
+                }
                 this.loading=true
                 this.$confirm(`请确认是否执行${this.buttonState[1]}操作?`, `${this.buttonState[1]}确认`, {
                     confirmButtonText: '确认',
@@ -46,14 +54,32 @@
                     type: 'warning'
                 })
                 .then(async() => {
-                // const res = await beginSwap()
-                // this.$message({
-                //   type: 'success',
-                //   message: '后端接口数据为空',
-                // })
-                // this.loading=false
+                    //充电操作
+                    if(this.chgState === 0 || this.chgState === 3){
+                        const res = await startCharge(params)
+                        console.log(res)
+                        this.$message({
+                          type: 'success',
+                          message: res.msg,
+                        })
+                    }
+                    //断电操作
+                    else if(this.chgState === 2){
+                        const res = await stopCharge(params)
+                        console.log(res)
+                        this.$message({
+                          type: 'success',
+                          message: res.msg,
+                        })
+                    }
+                    this.loading=false
                 })
-                .catch(err => { console.error(err) })
+                .catch(err => { 
+                    this.$message({
+                        type: 'error',
+                        message: err,
+                    })
+                 })
             }
         }
     }

+ 2 - 0
src/views/equipment-monitoring/components/StorageInfo.vue

@@ -25,6 +25,8 @@
                 :chargerCode="chargerInfoVo.chargerCode"
                 :comState="chargerInfoVo.comState"
                 :chgState="chargerInfoVo.chgState"
+                :sn="sn"
+                :storeState="storeState"
                 v-show="chargerInfoVo.chargerCode"></BatteryCharger>
                 <div class="battery-info" v-show="chargerInfoVo.chargerCode">
                     <BatteryInfo :num="chargerInfoVo.demandCurrent" unit="A" text="需求电流"></BatteryInfo>

+ 339 - 10
src/views/manage-log/battery-charger.vue

@@ -1,13 +1,342 @@
 <template>
+    <div class="charge-box">
+      <div class="charge-tools">
+        <el-form :inline="true" :model="queryParams">
+          <el-form-item label="日志范围:" style="margin-left: 35px">
+            <el-select 
+              multiple
+              v-model="robotValue" 
+              clearable 
+              placeholder="请选择"
+              @change="changeSelect"
+              collapse-tags
+              @remove-tag="removeTag"
+            >
+              <el-option label="全选" value="全选" @click.native="selectAll"></el-option>
+              <el-option
+                v-for="item in logOptions"
+                :key="item.alarmCode"
+                :label="item.alarmName"
+                :value="item.alarmCode"
+              />
+            </el-select>
+          </el-form-item>
   
-</template>
-
-<script>
-export default {
+          <el-form-item label="时间范围:" style="margin-left: 50px">
+            <el-date-picker
+              v-model="dateTime"
+              class="times"
+              type="datetimerange"
+              range-separator="至"
+              start-placeholder="开始时间"
+              end-placeholder="结束时间"
+              format="yyyy-MM-dd HH:mm:ss"
+            />
+          </el-form-item>
+  
+          <el-form-item>
+            <el-button type="primary" class="serch actve" @click="handleQuery">查询</el-button>
+            <el-button type="primary" class="serch" @click="resetForm">重置</el-button>
+          </el-form-item>
+  
+        </el-form>
+      </div>
+  
+      <div class="charge-table">
+        <div class="charge-table-top">
+          <el-button type="primary" class="daochu" @click="chargeExport">导出结果</el-button>
+        </div>
+        <div class="charge-table-bottom">
+          <el-table
+            :data="datalist"
+            :header-cell-style="{
+              background: '#1d283e',
+              borderColor: '#2f3c86',
+              height: '36px',
+              lineHeight: '36px',
+              color:'white',
+              fontSize: '15px',
+            }"
+            stripe
+            fit
+            :height="tableheight"
+            style="width: 100%"
+            :default-sort="{prop: 'chargerId', order: 'descending'}"
+            @selection-change="handleSelectionChange"
+          >
+          <el-table-column
+            type="selection"
+            width="55">
+          </el-table-column>
+          <af-table-column
+            prop="time"
+            label="发生时间"
+            fixed
+            width="160">
+          </af-table-column>
+          <af-table-column
+            prop="plcTag"
+            label="日志编号"
+            fixed
+            width="120">
+          </af-table-column>
+          <af-table-column v-for="log in logheader" :key="log.alarmCode" :label="log.alarmName">
+            <template slot-scope="scope">
+              {{ scope.row[log.alarmId] }}
+            </template>
+          </af-table-column>
+  
+            <!-- <el-table-column label="时段明细" width="100" align="center" fixed="right">
+              <template slot-scope="scope">
+                <el-button type="primary" class="handle" size="small" @click="chargeShow(scope.row.interval)">明细</el-button>
+              </template>
+            </el-table-column> -->
+          </el-table>
+        </div>
+        <div class="pageblock">
+          <el-pagination
+            :current-page="queryParams.page"
+            :page-sizes="[10, 20, 30, 40]"
+            :page-size="queryParams.pageSize"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="total"
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+          />
+        </div>
+      </div>
+  
+      <!--时段明细弹窗-->
+      <div class="rolemanage chargeshow">
+        <el-dialog
+          title="充电明细"
+          :visible.sync="dialogChargeVisible"
+          :destroy-on-close="true"
+        >
+          <div class="charge-table-bottom">
+            <el-table
+              :data="chargeShowList"
+              :header-cell-style="{
+                background: '#1d283e',
+                borderColor: '#2f3c86',
+                height: '36px',
+                lineHeight: '36px',
+                color:'white',
+                fontSize: '16px',
+              }"
+              stripe
+              fit
+              :height="tableheight-80"
+              style="width: 100%"
+            >
+              <el-table-column
+                prop="index"
+                label="序号"
+              />
+              <el-table-column
+                prop="startTime"
+                label="开始时间段"
+              />
+              <el-table-column
+                prop="endTime"
+                label="结束时间段"
+              />
+              <el-table-column
+                prop="chargePower"
+                label="充电量kWh"
+              />
+            </el-table>
+          </div>
+          <div slot="footer" class="dialog-footer" />
+        </el-dialog>
+      </div>
+      <!--时段明细弹窗结束-->
+    </div>
+  </template>
+  
+  <script>
+  import './log.scss'
+  import { chargeExport, getChargeCode } from '@/api/records'
+  import { logModel,chargerList } from '@/api/log'
+  import serverUrl from '../../../vue.config.js'
+  export default {
     name: 'BatteryCharger',
-}
-</script>
-
-<style>
-
-</style>
+    components: {},
+    data() {
+      return {
+        // 查询时间数组
+        dateTime: '',
+        // 充电机ID下拉列表
+        chargerArr: null,
+        // 数据列表
+        datalist: [],
+        // 查询参数
+        queryParams: {
+          page: 1, // 当前页
+          pageSize: 10, // 每页条数
+          deviceNo: undefined, 
+          endTime: undefined, // 电池编号
+          signals: undefined, // 排序字段
+          startTime: undefined,// 排序方式
+          sort:1
+        },
+        total: 0, // 总条数,
+        tableheight: 0, // 表格高度设置
+        dialogChargeVisible: false, // 弹窗显示
+        chargeShowList: [],// 充电机明细弹窗列表
+        checked: false,
+        indeterminate: false,
+        robotValue:'',
+        logOptions: [],
+        logheader:[],
+        multipleSelection:[],
+      }
+    },
+    watch: {
+      tableheight(val) {
+        // 为了避免频繁触发resize函数导致页面卡顿,使用定时器
+        if (!this.heightTimer) {
+          // 一旦监听到的screenWidth值改变,就将其重新赋给data里的screenWidth
+          this.screenHeight = val
+          this.heightTimer = true
+          setTimeout(function() {
+            this.heightTimer = false
+          }, 400)
+        }
+      }
+    },
+    mounted() {
+      this.getChargeCode()
+      this.onLoadHeight()
+      this.changeWindow()
+      this.getLogModel()
+      this.getrobotList()
+    },
+    methods: {
+      /* 设置初始视窗高度*/
+      onLoadHeight() {
+        this.$nextTick(() => {
+          this.tableheight = document.body.clientHeight - 460
+        })
+      },
+      /* 设置窗口变化高度*/
+      changeWindow() {
+        window.onresize = () => {
+          return (() => {
+            this.tableheight = document.body.clientHeight - 460
+          })()
+        }
+      },
+      selectAll() {
+        if (this.robotValue.length < this.logOptions.length) {
+          this.robotValue = [];
+          this.logOptions.map((item) => {
+            this.robotValue.push(item.value);
+          });
+          this.robotValue.unshift("全选");
+        } else {
+          this.robotValue = [];
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      changeSelect(val) {
+        if (!val.includes("全选") && val.length === this.logOptions.length) {
+          this.robotValue.unshift("全选");
+        } else if (val.includes("全选") && val.length - 1 < this.logOptions.length) {
+          this.robotValue = this.robotValue.filter((item) => {
+            return item !== "全选";
+          });
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      removeTag(val) {
+        if (val === "全选") {
+          this.robotValue = [];
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      //列表选择
+      handleSelectionChange(val) {
+        this.multipleSelection = val;
+      },
+      //获取充电机日志列表
+      getrobotList(){
+        chargerList(this.queryParams).then( res =>{
+          console.log(res)
+          this.datalist= res.data.list
+          this.total=res.data.total
+        })
+      },
+      //获取日志数据字典
+      getLogModel(){
+        logModel().then( res =>{
+          this.logOptions= res.data
+          this.logheader=res.data
+          console.log(this.logOptions)
+        })
+      },
+      // 充电明细弹窗显示
+      chargeShow(list) {
+        this.dialogChargeVisible = true
+        this.chargeShowList = list
+      },
+      // 获取充电机ID
+      getChargeCode() {
+        getChargeCode().then(res => {
+          this.chargerArr = res.data
+        })
+      },
+      /** 分页下一页 */
+      handleSizeChange(val) {
+        this.queryParams.pageSize = val
+        this.getrobotList()
+      },
+      /** 分页选择页数 */
+      handleCurrentChange(val) {
+        this.queryParams.page = val
+        this.getrobotList()
+      },
+      // 搜索
+      handleQuery() {
+        if (this.dateTime) {
+          this.queryParams.startTime = this.$moment(this.dateTime[0]).format('YYYY-MM-DD HH:mm:ss')
+          this.queryParams.endTime = this.$moment(this.dateTime[1]).format('YYYY-MM-DD HH:mm:ss')
+        }
+        if(this.robotValue){
+          this.queryParams.signals=this.robotValue
+          // this.logheader.forEach((item)=>{
+          //   if(!this.robotValue.includes(item.alarmCode)){
+          //         this.logheader.splice(item.alarmCode,1)  
+          //   }
+          // })
+          let differenceABSet = Array.from(new Set([...this.logOptions].filter(x => this.robotValue.includes(x.alarmCode))));
+          this.logheader=differenceABSet
+        }
+        this.getrobotList()
+        console.log(this.logheader)
+      },
+      // 搜索重置
+      resetForm() {
+        this.queryParams.startTime = undefined
+        this.queryParams.endTime = undefined
+        this.queryParams.signals = undefined
+        this.getrobotList()
+      },
+      // 导出结果
+      chargeExport() {
+        this.$confirm('确认导出结果?', '导出结果', {
+          confirmButtonText: '确认',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+        .then(async() => {
+            const res = await chargeExport(this.queryParams)
+            const execlUrl=serverUrl.devServer.proxy['/api'].target+'/excel/'+res.data
+            window.open(execlUrl,'_blank')
+          })
+        .catch(err => { console.error(err) })
+      }
+    }
+  }
+  </script>
+  

+ 340 - 11
src/views/manage-log/bms.vue

@@ -1,13 +1,342 @@
 <template>
+    <div class="charge-box">
+      <div class="charge-tools">
+        <el-form :inline="true" :model="queryParams">
+          <el-form-item label="日志范围:" style="margin-left: 35px">
+            <el-select 
+              multiple
+              v-model="robotValue" 
+              clearable 
+              placeholder="请选择"
+              @change="changeSelect"
+              collapse-tags
+              @remove-tag="removeTag"
+            >
+              <el-option label="全选" value="全选" @click.native="selectAll"></el-option>
+              <el-option
+                v-for="item in logOptions"
+                :key="item.alarmCode"
+                :label="item.alarmName"
+                :value="item.alarmCode"
+              />
+            </el-select>
+          </el-form-item>
   
-</template>
-
-<script>
-export default {
-    name: 'BatteryCharger',
-}
-</script>
-
-<style>
-
-</style>
+          <el-form-item label="时间范围:" style="margin-left: 50px">
+            <el-date-picker
+              v-model="dateTime"
+              class="times"
+              type="datetimerange"
+              range-separator="至"
+              start-placeholder="开始时间"
+              end-placeholder="结束时间"
+              format="yyyy-MM-dd HH:mm:ss"
+            />
+          </el-form-item>
+  
+          <el-form-item>
+            <el-button type="primary" class="serch actve" @click="handleQuery">查询</el-button>
+            <el-button type="primary" class="serch" @click="resetForm">重置</el-button>
+          </el-form-item>
+  
+        </el-form>
+      </div>
+  
+      <div class="charge-table">
+        <div class="charge-table-top">
+          <el-button type="primary" class="daochu" @click="chargeExport">导出结果</el-button>
+        </div>
+        <div class="charge-table-bottom">
+          <el-table
+            :data="datalist"
+            :header-cell-style="{
+              background: '#1d283e',
+              borderColor: '#2f3c86',
+              height: '36px',
+              lineHeight: '36px',
+              color:'white',
+              fontSize: '15px',
+            }"
+            stripe
+            fit
+            :height="tableheight"
+            style="width: 100%"
+            :default-sort="{prop: 'chargerId', order: 'descending'}"
+            @selection-change="handleSelectionChange"
+          >
+          <el-table-column
+            type="selection"
+            width="55">
+          </el-table-column>
+          <af-table-column
+            prop="time"
+            label="发生时间"
+            fixed
+            width="140">
+          </af-table-column>
+          <af-table-column
+            prop="plcTag"
+            label="日志编号"
+            fixed
+            width="120">
+          </af-table-column>
+          <af-table-column v-for="log in logheader" :key="log.alarmCode" :label="log.alarmName">
+            <template slot-scope="scope">
+              {{ scope.row[log.alarmId] }}
+            </template>
+          </af-table-column>
+  
+            <!-- <el-table-column label="时段明细" width="100" align="center" fixed="right">
+              <template slot-scope="scope">
+                <el-button type="primary" class="handle" size="small" @click="chargeShow(scope.row.interval)">明细</el-button>
+              </template>
+            </el-table-column> -->
+          </el-table>
+        </div>
+        <div class="pageblock">
+          <el-pagination
+            :current-page="queryParams.page"
+            :page-sizes="[10, 20, 30, 40]"
+            :page-size="queryParams.pageSize"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="total"
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+          />
+        </div>
+      </div>
+  
+      <!--时段明细弹窗-->
+      <div class="rolemanage chargeshow">
+        <el-dialog
+          title="充电明细"
+          :visible.sync="dialogChargeVisible"
+          :destroy-on-close="true"
+        >
+          <div class="charge-table-bottom">
+            <el-table
+              :data="chargeShowList"
+              :header-cell-style="{
+                background: '#1d283e',
+                borderColor: '#2f3c86',
+                height: '36px',
+                lineHeight: '36px',
+                color:'white',
+                fontSize: '16px',
+              }"
+              stripe
+              fit
+              :height="tableheight-80"
+              style="width: 100%"
+            >
+              <el-table-column
+                prop="index"
+                label="序号"
+              />
+              <el-table-column
+                prop="startTime"
+                label="开始时间段"
+              />
+              <el-table-column
+                prop="endTime"
+                label="结束时间段"
+              />
+              <el-table-column
+                prop="chargePower"
+                label="充电量kWh"
+              />
+            </el-table>
+          </div>
+          <div slot="footer" class="dialog-footer" />
+        </el-dialog>
+      </div>
+      <!--时段明细弹窗结束-->
+    </div>
+  </template>
+  
+  <script>
+  import './log.scss'
+  import { chargeExport, getChargeCode } from '@/api/records'
+  import { logModel,robotList } from '@/api/log'
+  import serverUrl from '../../../vue.config.js'
+  export default {
+    name: 'Bms',
+    components: {},
+    data() {
+      return {
+        // 查询时间数组
+        dateTime: '',
+        // 充电机ID下拉列表
+        chargerArr: null,
+        // 数据列表
+        datalist: [],
+        // 查询参数
+        queryParams: {
+          page: 1, // 当前页
+          pageSize: 10, // 每页条数
+          deviceNo: undefined, 
+          endTime: undefined, // 电池编号
+          signals: undefined, // 排序字段
+          startTime: undefined,// 排序方式
+          sort:1
+        },
+        total: 0, // 总条数,
+        tableheight: 0, // 表格高度设置
+        dialogChargeVisible: false, // 弹窗显示
+        chargeShowList: [],// 充电机明细弹窗列表
+        checked: false,
+        indeterminate: false,
+        robotValue:'',
+        logOptions: [],
+        logheader:[],
+        multipleSelection:[],
+      }
+    },
+    watch: {
+      tableheight(val) {
+        // 为了避免频繁触发resize函数导致页面卡顿,使用定时器
+        if (!this.heightTimer) {
+          // 一旦监听到的screenWidth值改变,就将其重新赋给data里的screenWidth
+          this.screenHeight = val
+          this.heightTimer = true
+          setTimeout(function() {
+            this.heightTimer = false
+          }, 400)
+        }
+      }
+    },
+    mounted() {
+      this.getChargeCode()
+      this.onLoadHeight()
+      this.changeWindow()
+      this.getLogModel()
+      this.getrobotList()
+    },
+    methods: {
+      /* 设置初始视窗高度*/
+      onLoadHeight() {
+        this.$nextTick(() => {
+          this.tableheight = document.body.clientHeight - 460
+        })
+      },
+      /* 设置窗口变化高度*/
+      changeWindow() {
+        window.onresize = () => {
+          return (() => {
+            this.tableheight = document.body.clientHeight - 460
+          })()
+        }
+      },
+      selectAll() {
+        if (this.robotValue.length < this.logOptions.length) {
+          this.robotValue = [];
+          this.logOptions.map((item) => {
+            this.robotValue.push(item.value);
+          });
+          this.robotValue.unshift("全选");
+        } else {
+          this.robotValue = [];
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      changeSelect(val) {
+        if (!val.includes("全选") && val.length === this.logOptions.length) {
+          this.robotValue.unshift("全选");
+        } else if (val.includes("全选") && val.length - 1 < this.logOptions.length) {
+          this.robotValue = this.robotValue.filter((item) => {
+            return item !== "全选";
+          });
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      removeTag(val) {
+        if (val === "全选") {
+          this.robotValue = [];
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      //列表选择
+      handleSelectionChange(val) {
+        this.multipleSelection = val;
+      },
+      //获取机器人日志列表
+      getrobotList(){
+        robotList(this.queryParams).then( res =>{
+          console.log(res)
+          this.datalist= res.data.list
+          this.total=res.data.total
+        })
+      },
+      //获取日志数据字典
+      getLogModel(){
+        logModel().then( res =>{
+          this.logOptions= res.data
+          this.logheader=res.data
+          console.log(this.logOptions)
+        })
+      },
+      // 充电明细弹窗显示
+      chargeShow(list) {
+        this.dialogChargeVisible = true
+        this.chargeShowList = list
+      },
+      // 获取充电机ID
+      getChargeCode() {
+        getChargeCode().then(res => {
+          this.chargerArr = res.data
+        })
+      },
+      /** 分页下一页 */
+      handleSizeChange(val) {
+        this.queryParams.pageSize = val
+        this.getrobotList()
+      },
+      /** 分页选择页数 */
+      handleCurrentChange(val) {
+        this.queryParams.page = val
+        this.getrobotList()
+      },
+      // 搜索
+      handleQuery() {
+        if (this.dateTime) {
+          this.queryParams.startTime = this.$moment(this.dateTime[0]).format('YYYY-MM-DD HH:mm:ss')
+          this.queryParams.endTime = this.$moment(this.dateTime[1]).format('YYYY-MM-DD HH:mm:ss')
+        }
+        if(this.robotValue){
+          this.queryParams.signals=this.robotValue
+          // this.logheader.forEach((item)=>{
+          //   if(!this.robotValue.includes(item.alarmCode)){
+          //         this.logheader.splice(item.alarmCode,1)  
+          //   }
+          // })
+          let differenceABSet = Array.from(new Set([...this.logOptions].filter(x => this.robotValue.includes(x.alarmCode))));
+          this.logheader=differenceABSet
+        }
+        this.getrobotList()
+        console.log(this.logheader)
+      },
+      // 搜索重置
+      resetForm() {
+        this.queryParams.startTime = undefined
+        this.queryParams.endTime = undefined
+        this.queryParams.signals = undefined
+        this.getrobotList()
+      },
+      // 导出结果
+      chargeExport() {
+        this.$confirm('确认导出结果?', '导出结果', {
+          confirmButtonText: '确认',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+        .then(async() => {
+            const res = await chargeExport(this.queryParams)
+            const execlUrl=serverUrl.devServer.proxy['/api'].target+'/excel/'+res.data
+            window.open(execlUrl,'_blank')
+          })
+        .catch(err => { console.error(err) })
+      }
+    }
+  }
+  </script>
+  

+ 340 - 11
src/views/manage-log/change-record.vue

@@ -1,13 +1,342 @@
 <template>
+    <div class="charge-box">
+      <div class="charge-tools">
+        <el-form :inline="true" :model="queryParams">
+          <el-form-item label="日志范围:" style="margin-left: 35px">
+            <el-select 
+              multiple
+              v-model="robotValue" 
+              clearable 
+              placeholder="请选择"
+              @change="changeSelect"
+              collapse-tags
+              @remove-tag="removeTag"
+            >
+              <el-option label="全选" value="全选" @click.native="selectAll"></el-option>
+              <el-option
+                v-for="item in logOptions"
+                :key="item.alarmCode"
+                :label="item.alarmName"
+                :value="item.alarmCode"
+              />
+            </el-select>
+          </el-form-item>
   
-</template>
-
-<script>
-export default {
-    name:'ChangeRecord'
-}
-</script>
-
-<style>
-
-</style>
+          <el-form-item label="时间范围:" style="margin-left: 50px">
+            <el-date-picker
+              v-model="dateTime"
+              class="times"
+              type="datetimerange"
+              range-separator="至"
+              start-placeholder="开始时间"
+              end-placeholder="结束时间"
+              format="yyyy-MM-dd HH:mm:ss"
+            />
+          </el-form-item>
+  
+          <el-form-item>
+            <el-button type="primary" class="serch actve" @click="handleQuery">查询</el-button>
+            <el-button type="primary" class="serch" @click="resetForm">重置</el-button>
+          </el-form-item>
+  
+        </el-form>
+      </div>
+  
+      <div class="charge-table">
+        <div class="charge-table-top">
+          <el-button type="primary" class="daochu" @click="chargeExport">导出结果</el-button>
+        </div>
+        <div class="charge-table-bottom">
+          <el-table
+            :data="datalist"
+            :header-cell-style="{
+              background: '#1d283e',
+              borderColor: '#2f3c86',
+              height: '36px',
+              lineHeight: '36px',
+              color:'white',
+              fontSize: '15px',
+            }"
+            stripe
+            fit
+            :height="tableheight"
+            style="width: 100%"
+            :default-sort="{prop: 'chargerId', order: 'descending'}"
+            @selection-change="handleSelectionChange"
+          >
+          <el-table-column
+            type="selection"
+            width="55">
+          </el-table-column>
+          <af-table-column
+            prop="time"
+            label="发生时间"
+            fixed
+            width="140">
+          </af-table-column>
+          <af-table-column
+            prop="plcTag"
+            label="日志编号"
+            fixed
+            width="120">
+          </af-table-column>
+          <af-table-column v-for="log in logheader" :key="log.alarmCode" :label="log.alarmName">
+            <template slot-scope="scope">
+              {{ scope.row[log.alarmId] }}
+            </template>
+          </af-table-column>
+  
+            <!-- <el-table-column label="时段明细" width="100" align="center" fixed="right">
+              <template slot-scope="scope">
+                <el-button type="primary" class="handle" size="small" @click="chargeShow(scope.row.interval)">明细</el-button>
+              </template>
+            </el-table-column> -->
+          </el-table>
+        </div>
+        <div class="pageblock">
+          <el-pagination
+            :current-page="queryParams.page"
+            :page-sizes="[10, 20, 30, 40]"
+            :page-size="queryParams.pageSize"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="total"
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+          />
+        </div>
+      </div>
+  
+      <!--时段明细弹窗-->
+      <div class="rolemanage chargeshow">
+        <el-dialog
+          title="充电明细"
+          :visible.sync="dialogChargeVisible"
+          :destroy-on-close="true"
+        >
+          <div class="charge-table-bottom">
+            <el-table
+              :data="chargeShowList"
+              :header-cell-style="{
+                background: '#1d283e',
+                borderColor: '#2f3c86',
+                height: '36px',
+                lineHeight: '36px',
+                color:'white',
+                fontSize: '16px',
+              }"
+              stripe
+              fit
+              :height="tableheight-80"
+              style="width: 100%"
+            >
+              <el-table-column
+                prop="index"
+                label="序号"
+              />
+              <el-table-column
+                prop="startTime"
+                label="开始时间段"
+              />
+              <el-table-column
+                prop="endTime"
+                label="结束时间段"
+              />
+              <el-table-column
+                prop="chargePower"
+                label="充电量kWh"
+              />
+            </el-table>
+          </div>
+          <div slot="footer" class="dialog-footer" />
+        </el-dialog>
+      </div>
+      <!--时段明细弹窗结束-->
+    </div>
+  </template>
+  
+  <script>
+  import './log.scss'
+  import { chargeExport, getChargeCode } from '@/api/records'
+  import { logModel,robotList } from '@/api/log'
+  import serverUrl from '../../../vue.config.js'
+  export default {
+    name: 'ChangeRecord',
+    components: {},
+    data() {
+      return {
+        // 查询时间数组
+        dateTime: '',
+        // 充电机ID下拉列表
+        chargerArr: null,
+        // 数据列表
+        datalist: [],
+        // 查询参数
+        queryParams: {
+          page: 1, // 当前页
+          pageSize: 10, // 每页条数
+          deviceNo: undefined, 
+          endTime: undefined, // 电池编号
+          signals: undefined, // 排序字段
+          startTime: undefined,// 排序方式
+          sort:1
+        },
+        total: 0, // 总条数,
+        tableheight: 0, // 表格高度设置
+        dialogChargeVisible: false, // 弹窗显示
+        chargeShowList: [],// 充电机明细弹窗列表
+        checked: false,
+        indeterminate: false,
+        robotValue:'',
+        logOptions: [],
+        logheader:[],
+        multipleSelection:[],
+      }
+    },
+    watch: {
+      tableheight(val) {
+        // 为了避免频繁触发resize函数导致页面卡顿,使用定时器
+        if (!this.heightTimer) {
+          // 一旦监听到的screenWidth值改变,就将其重新赋给data里的screenWidth
+          this.screenHeight = val
+          this.heightTimer = true
+          setTimeout(function() {
+            this.heightTimer = false
+          }, 400)
+        }
+      }
+    },
+    mounted() {
+      this.getChargeCode()
+      this.onLoadHeight()
+      this.changeWindow()
+      this.getLogModel()
+      this.getrobotList()
+    },
+    methods: {
+      /* 设置初始视窗高度*/
+      onLoadHeight() {
+        this.$nextTick(() => {
+          this.tableheight = document.body.clientHeight - 460
+        })
+      },
+      /* 设置窗口变化高度*/
+      changeWindow() {
+        window.onresize = () => {
+          return (() => {
+            this.tableheight = document.body.clientHeight - 460
+          })()
+        }
+      },
+      selectAll() {
+        if (this.robotValue.length < this.logOptions.length) {
+          this.robotValue = [];
+          this.logOptions.map((item) => {
+            this.robotValue.push(item.value);
+          });
+          this.robotValue.unshift("全选");
+        } else {
+          this.robotValue = [];
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      changeSelect(val) {
+        if (!val.includes("全选") && val.length === this.logOptions.length) {
+          this.robotValue.unshift("全选");
+        } else if (val.includes("全选") && val.length - 1 < this.logOptions.length) {
+          this.robotValue = this.robotValue.filter((item) => {
+            return item !== "全选";
+          });
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      removeTag(val) {
+        if (val === "全选") {
+          this.robotValue = [];
+        }
+        this.$emit("SelectedData", this.robotValue);
+      },
+      //列表选择
+      handleSelectionChange(val) {
+        this.multipleSelection = val;
+      },
+      //获取机器人日志列表
+      getrobotList(){
+        robotList(this.queryParams).then( res =>{
+          console.log(res)
+          this.datalist= res.data.list
+          this.total=res.data.total
+        })
+      },
+      //获取日志数据字典
+      getLogModel(){
+        logModel().then( res =>{
+          this.logOptions= res.data
+          this.logheader=res.data
+          console.log(this.logOptions)
+        })
+      },
+      // 充电明细弹窗显示
+      chargeShow(list) {
+        this.dialogChargeVisible = true
+        this.chargeShowList = list
+      },
+      // 获取充电机ID
+      getChargeCode() {
+        getChargeCode().then(res => {
+          this.chargerArr = res.data
+        })
+      },
+      /** 分页下一页 */
+      handleSizeChange(val) {
+        this.queryParams.pageSize = val
+        this.getrobotList()
+      },
+      /** 分页选择页数 */
+      handleCurrentChange(val) {
+        this.queryParams.page = val
+        this.getrobotList()
+      },
+      // 搜索
+      handleQuery() {
+        if (this.dateTime) {
+          this.queryParams.startTime = this.$moment(this.dateTime[0]).format('YYYY-MM-DD HH:mm:ss')
+          this.queryParams.endTime = this.$moment(this.dateTime[1]).format('YYYY-MM-DD HH:mm:ss')
+        }
+        if(this.robotValue){
+          this.queryParams.signals=this.robotValue
+          // this.logheader.forEach((item)=>{
+          //   if(!this.robotValue.includes(item.alarmCode)){
+          //         this.logheader.splice(item.alarmCode,1)  
+          //   }
+          // })
+          let differenceABSet = Array.from(new Set([...this.logOptions].filter(x => this.robotValue.includes(x.alarmCode))));
+          this.logheader=differenceABSet
+        }
+        this.getrobotList()
+        console.log(this.logheader)
+      },
+      // 搜索重置
+      resetForm() {
+        this.queryParams.startTime = undefined
+        this.queryParams.endTime = undefined
+        this.queryParams.signals = undefined
+        this.getrobotList()
+      },
+      // 导出结果
+      chargeExport() {
+        this.$confirm('确认导出结果?', '导出结果', {
+          confirmButtonText: '确认',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+        .then(async() => {
+            const res = await chargeExport(this.queryParams)
+            const execlUrl=serverUrl.devServer.proxy['/api'].target+'/excel/'+res.data
+            window.open(execlUrl,'_blank')
+          })
+        .catch(err => { console.error(err) })
+      }
+    }
+  }
+  </script>
+  

+ 28 - 11
src/views/manage-log/robot.vue

@@ -80,9 +80,9 @@
           fixed
           width="120">
         </af-table-column>
-        <af-table-column v-for="log in logOptions" :key="log.alarmCode" :label="log.alarmName">
+        <af-table-column v-for="log in logheader" :key="log.alarmCode" :label="log.alarmName">
           <template slot-scope="scope">
-            {{ scope.row.time }}
+            {{ scope.row[log.alarmId] }}
           </template>
         </af-table-column>
 
@@ -156,7 +156,7 @@
 
 <script>
 import './log.scss'
-import { chargeList, chargeExport, getChargeCode } from '@/api/records'
+import { chargeExport, getChargeCode } from '@/api/records'
 import { logModel,robotList } from '@/api/log'
 import serverUrl from '../../../vue.config.js'
 export default {
@@ -188,7 +188,8 @@ export default {
       indeterminate: false,
       robotValue:'',
       logOptions: [],
-      multipleSelection:[]
+      logheader:[],
+      multipleSelection:[],
     }
   },
   watch: {
@@ -263,12 +264,15 @@ export default {
       robotList(this.queryParams).then( res =>{
         console.log(res)
         this.datalist= res.data.list
+        this.total=res.data.total
       })
     },
     //获取日志数据字典
     getLogModel(){
       logModel().then( res =>{
         this.logOptions= res.data
+        this.logheader=res.data
+        console.log(this.logOptions)
       })
     },
     // 充电明细弹窗显示
@@ -285,25 +289,38 @@ export default {
     /** 分页下一页 */
     handleSizeChange(val) {
       this.queryParams.pageSize = val
+      this.getrobotList()
     },
     /** 分页选择页数 */
     handleCurrentChange(val) {
       this.queryParams.page = val
+      this.getrobotList()
     },
     // 搜索
     handleQuery() {
       if (this.dateTime) {
-        this.queryParams.chgBeginTime = this.$moment(this.dateTime[0]).format('YYYY-MM-DD HH:mm:ss')
-        this.queryParams.chgEndTime = this.$moment(this.dateTime[1]).format('YYYY-MM-DD HH:mm:ss')
+        this.queryParams.startTime = this.$moment(this.dateTime[0]).format('YYYY-MM-DD HH:mm:ss')
+        this.queryParams.endTime = this.$moment(this.dateTime[1]).format('YYYY-MM-DD HH:mm:ss')
       }
-      console.log(this.queryParams)
+      if(this.robotValue){
+        this.queryParams.signals=this.robotValue
+        // this.logheader.forEach((item)=>{
+        //   if(!this.robotValue.includes(item.alarmCode)){
+        //         this.logheader.splice(item.alarmCode,1)  
+        //   }
+        // })
+        let differenceABSet = Array.from(new Set([...this.logOptions].filter(x => this.robotValue.includes(x.alarmCode))));
+        this.logheader=differenceABSet
+      }
+      this.getrobotList()
+      console.log(this.logheader)
     },
     // 搜索重置
     resetForm() {
-      this.queryParams.chgBeginTime = undefined
-      this.queryParams.chgEndTime = undefined
-      this.queryParams.chargerId = undefined
-      this.queryParams.chgSn = undefined
+      this.queryParams.startTime = undefined
+      this.queryParams.endTime = undefined
+      this.queryParams.signals = undefined
+      this.getrobotList()
     },
     // 导出结果
     chargeExport() {