ZZJ
2022-02-21 c6935cb2e9e6f4e59552d929fd7860d00f4c39ec
src/pages/syslog/views/pollingLog.vue
@@ -1,5 +1,9 @@
<template>
  <div class="polling-log" v-loading="loading" :element-loading-text="loadingText">
  <div
    class="polling-log"
    v-loading="loading"
    :element-loading-text="loadingText"
  >
    <div class="top">
      <div class="first">
        <div class="time-option">
@@ -17,10 +21,19 @@
            class="input-with-select"
            @keyup.enter.native="getScheduleLog(1)"
          >
            <span class="icon iconfont icon_clear" @click="clearSearch" slot="append" v-if="fuzzySearch">
            <span
              class="icon iconfont icon_clear"
              @click="clearSearch"
              slot="append"
              v-if="fuzzySearch"
            >
              &#xe785;
            </span>
            <span class="icon iconfont icon_search" @click="getScheduleLog(1)" slot="append">
            <span
              class="icon iconfont icon_search"
              @click="getScheduleLog(1)"
              slot="append"
            >
              &#xe714;
            </span>
@@ -63,7 +76,8 @@
        <template slot="empty">
          <img :src="png" class="empty_img" alt="" />
        </template>
        <el-table-column :align="'center'" label="序号" type="index" width="50"> </el-table-column>
        <el-table-column :align="'center'" label="序号" type="index" width="50">
        </el-table-column>
        <el-table-column
          :align="'center'"
          sortable
@@ -78,8 +92,17 @@
          prop="schedule_end_time"
          label="轮询结束时间"
        ></el-table-column>
        <el-table-column :align="'center'" sortable prop="info" label="摄像机"></el-table-column>
        <el-table-column :align="'center'" prop="minute" label="轮询时长(分)"></el-table-column>
        <el-table-column
          :align="'center'"
          sortable
          prop="info"
          label="摄像机"
        ></el-table-column>
        <el-table-column
          :align="'center'"
          prop="minute"
          label="轮询时长(分)"
        ></el-table-column>
      </el-table>
    </div>
@@ -94,7 +117,12 @@
    >
    </el-pagination>
    <el-dialog title="选择摄像机" :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
    <el-dialog
      title="选择摄像机"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose"
    >
      <el-tree
        ref="cameraTree"
        :data="cameraTree"
@@ -109,16 +137,18 @@
        <el-button size="small" @click="pickAllNot">取消全选</el-button>
        <el-button @click="pickAllCam" size="small">全选</el-button>
        <el-button size="small" @click="cancelShow">取消</el-button>
        <el-button size="small" type="primary" @click="confirmCamera">确定</el-button>
        <el-button size="small" type="primary" @click="confirmCamera"
          >确定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { pad0 } from "@/api/utils"
import { getLocalCameraTree } from "@/api/area"
import { getOperations, getModules, queryScheduleLog } from "@/api/log"
import { pad0 } from "@/api/utils";
import { getLocalCameraTree } from "@/api/area";
import { getOperations, getModules, queryScheduleLog } from "@/api/log";
export default {
  data() {
@@ -132,7 +162,7 @@
      dateRange: [],
      cameraTree: [],
      props: {
        label: "name"
        label: "name",
      },
      value: "",
      page: 1,
@@ -153,91 +183,91 @@
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit("pick", [start, end])
            }
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit("pick", [start, end])
            }
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
              picker.$emit("pick", [start, end])
            }
          }
        ]
      }
    }
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    };
  },
  mounted() {
    this.getTimeRange(24 * 60 * 60 * 1000 * 30)
    this.getScheduleLog()
    this.getOptions()
    this.getTimeRange(24 * 60 * 60 * 1000 * 30);
    this.getScheduleLog();
    this.getOptions();
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val
      this.getScheduleLog()
      this.pageSize = val;
      this.getScheduleLog();
    },
    handleCurrentChange(val) {
      this.page = val
      this.getScheduleLog()
      this.page = val;
      this.getScheduleLog();
    },
    cancelShow() {
      this.dialogVisible = false
      this.pickAllNot()
      this.dialogVisible = false;
      this.pickAllNot();
    },
    pickAllCam() {
      this.$refs.cameraTree.setCheckedNodes(this.cameraTree)
      this.$refs.cameraTree.setCheckedNodes(this.cameraTree);
    },
    pickAllNot() {
      this.$refs.cameraTree.setCheckedKeys([])
      this.$refs.cameraTree.setCheckedKeys([]);
    },
    confirmCamera() {
      const selectedIDs = this.$refs.cameraTree.getCheckedKeys()
      this.pickNum = selectedIDs.length
      this.procID = selectedIDs.join(",")
      this.getScheduleLog()
      this.dialogVisible = false
      const selectedIDs = this.$refs.cameraTree.getCheckedKeys();
      this.pickNum = selectedIDs.length;
      this.procID = selectedIDs.join(",");
      this.getScheduleLog();
      this.dialogVisible = false;
    },
    openDialog() {
      this.dialogVisible = true
      this.dialogVisible = true;
      getLocalCameraTree({
        cameraName: "",
        searchType: 0
        searchType: 0,
      }).then((res) => {
        this.cameraTree = res.data
      })
        this.cameraTree = res.data;
      });
    },
    moduleChange(val) {
      this.getScheduleLog()
      this.gongneng = ""
      this.getScheduleLog();
      this.gongneng = "";
      getOperations({
        module: this.curModule
        module: this.curModule,
      }).then((res) => {
        this.gongnengOptions = res.data
      })
        this.gongnengOptions = res.data;
      });
    },
    getOptions() {
      getModules().then((res) => {
        this.moduleOptions = res.data
      })
        this.moduleOptions = res.data;
      });
    },
    getScheduleLog(typ) {
      if (typ == 1) {
        this.page = 1
        this.page = 1;
      }
      const data = {
@@ -247,40 +277,40 @@
        pageSize: this.pageSize,
        fuzzySearch: this.fuzzySearch,
        procID: this.procID,
        procName: this.procName
      }
        procName: this.procName,
      };
      queryScheduleLog(data).then((res) => {
        this.tableData = res.data.logs
        this.total = res.data.total
      })
        this.tableData = res.data.logs;
        this.total = res.data.total;
      });
    },
    dateChange(val) {
      ;[this.timeStart, this.timeEnd] = val
      this.getScheduleLog()
      [this.timeStart, this.timeEnd] = val;
      this.getScheduleLog();
    },
    getTimeStr(date) {
      var month = pad0(date.getMonth() + 1) //月
      var day = pad0(date.getDate()) //日
      var hour = pad0(date.getHours()) //时
      var minute = pad0(date.getMinutes()) //分
      var second = pad0(date.getSeconds()) //秒
      return `${date.getFullYear()}-${month}-${day} ${hour}:${minute}:${second}`
      var month = pad0(date.getMonth() + 1); //月
      var day = pad0(date.getDate()); //日
      var hour = pad0(date.getHours()); //时
      var minute = pad0(date.getMinutes()); //分
      var second = pad0(date.getSeconds()); //秒
      return `${date.getFullYear()}-${month}-${day} ${hour}:${minute}:${second}`;
    },
    getTimeRange(gap) {
      var date = new Date() //当前时间
      var preDay = new Date(new Date().getTime() - gap)
      this.timeStart = this.getTimeStr(preDay)
      this.timeEnd = this.getTimeStr(date)
      this.dateRange = [this.timeStart, this.timeEnd]
      var date = new Date(); //当前时间
      var preDay = new Date(new Date().getTime() - gap);
      this.timeStart = this.getTimeStr(preDay);
      this.timeEnd = this.getTimeStr(date);
      this.dateRange = [this.timeStart, this.timeEnd];
    },
    handleSelectionChange() {},
    handleClose() {},
    clearSearch() {
      this.fuzzySearch = ""
      this.getScheduleLog(1)
    }
  }
}
      this.fuzzySearch = "";
      this.getScheduleLog(1);
    },
  },
};
</script>
<style lang="scss">
.polling-log {