From 0d3db253cad1fb49c4fae9b9a537c8c318c7172f Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 29 十一月 2023 10:23:59 +0800
Subject: [PATCH] 优化应用中心卸载

---
 src/pages/syslog/views/systemLog.vue |  697 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 415 insertions(+), 282 deletions(-)

diff --git a/src/pages/syslog/views/systemLog.vue b/src/pages/syslog/views/systemLog.vue
index 6f2d951..fb9c3a5 100644
--- a/src/pages/syslog/views/systemLog.vue
+++ b/src/pages/syslog/views/systemLog.vue
@@ -1,326 +1,459 @@
 <template>
-  <div class="all">
-    <div class="backup-content">
-      <div class="backup-center" ref="left">
-        <div class="menu-item" @click="openRight(0)">
-          <div class="con">
-            <span class="icon iconfont">&#xe646;</span>
-            <span class="menu-text">鑷姩澶囦唤璁剧疆</span>
+  <div class="sys-log" v-loading="loading" :element-loading-text="loadingText">
+    <div class="top">
+      <div class="first">
+        <div class="time-option">
+          <div class="title">鍛ㄦ湡锛�</div>
+
+          <div class="opts">
+            <div
+              :class="activeDateChoise == i ? 'opt-active' : ''"
+              class="opt"
+              v-for="(item, i) in dateArr"
+              :key="i"
+              @click="choseRange(item, i)"
+            >
+              {{ item }}
+            </div>
           </div>
         </div>
-        <div class="menu-item" @click="openRight(1)">
-          <div class="con">
-            <span class="icon iconfont">&#xe646;</span>
-
-            <span class="menu-text">浠庡浠戒腑鎭㈠</span>
-          </div>
+        <div class="search">
+          <el-input
+            placeholder="鎼滅储"
+            v-model="fuzzySearch"
+            size="small"
+            class="input-with-select"
+            @keyup.enter.native="getVaSystemLog(1)"
+          >
+            <span class="icon iconfont icon_clear" @click="clearSearch" slot="append" v-if="fuzzySearch">
+              &#xe785;
+            </span>
+            <span class="icon iconfont icon_search" @click="getVaSystemLog(1)" slot="append">
+              &#xe714;
+            </span>
+          </el-input>
         </div>
       </div>
-      <div class="backup-right">
-        <div class="auto" v-if="activePage == 0">
-          <div class="bar">
-            <div class="name">鑷姩澶囦唤</div>
-            <el-switch
-              v-model="isBackUp"
-              active-color="rgba(61, 104, 225, 1)"
-              @change="switchChange"
-            >
-            </el-switch>
-          </div>
-          <div class="bar">
-            <div class="name">澶囦唤鐩綍</div>
-            <input type="file" id="file_input" webkitdirectory directory />
-          </div>
-          <div class="bar">
-            <div class="name">澶囦唤闂撮殧 / 澶�</div>
-            <el-input
-              v-model="interval"
-              :placeholder="'璇疯緭鍏ュぉ鏁�'"
-              @change="handleChange"
-              size="small"
-            ></el-input>
-            <!-- :controls="false" -->
-          </div>
-          <div class="bar">
-            <div class="name">澶囦唤鏁版嵁淇濆瓨鏃堕棿 / 澶�</div>
-            <el-input
-              v-model="lifeSpan"
-              placeholder="璇疯緭鍏ュぉ鏁�"
-              @change="handleChange"
-              size="small"
-            ></el-input>
-          </div>
-          <div class="bar">
-            <div class="name">鑷姩澶囦唤</div>
-            <el-button type="primary" size="small" @click="backUpNow"
-              >绔嬪嵆澶囦唤</el-button
-            >
-          </div>
+      <div class="second">
+        <div class="bar">
+          <div class="name">绾у埆锛�</div>
+
+          <el-select v-model="level" placeholder="璇烽�夋嫨" size="small" @change="getVaSystemLog">
+            <el-option v-for="(item, index) in levelOptions" :key="index" :label="item.label" :value="item.value">
+            </el-option>
+          </el-select>
         </div>
-        <div class="recover" v-if="activePage == 1">
-          <div class="title">鏄剧ず澶囦唤鐨勬枃浠惰寖鍥达細{{ 5 }}</div>
-
-          <div class="table-head">
-            <span class="line1">鑷姩澶囦唤鏃堕棿</span>
-            <span class="line1">澶囦唤鏂囦欢鍚嶇О</span>
-            <span class="line2">鎿嶄綔</span>
-          </div>
-
-          <div class="bar" v-for="(item, i) in fileList" :key="i">
-            <span class="time">{{ item.time }}</span>
-            <span class="time">{{ item.name }}</span>
-            <span class="operation">鎭㈠</span>
-          </div>
+        <div class="bar">
+          <div class="name">杩涚▼</div>
+          <el-select
+            v-model="procName"
+            placeholder="璇烽�夋嫨"
+            size="small"
+            @change="getVaSystemLog(1)"
+            clearable
+            multiple
+          >
+            <el-option v-for="(item, index) in procOptions" :key="index" :label="item" :value="item"> </el-option>
+          </el-select>
         </div>
       </div>
     </div>
+    <div class="table">
+      <el-table
+        class="tableBox"
+        ref="multipleTable"
+        highlight-current-row
+        :data="tableData"
+        :header-cell-style="{ background: '#f8f8f8', color: '#222222' }"
+        style="width: 100%"
+        border
+        :row-class-name="tableRowClassName"
+      >
+        <template slot="empty">
+          <img :src="png" class="empty_img" alt="" />
+        </template>
+        <el-table-column :align="'center'" label="搴忓彿" type="index" width="100"> </el-table-column>
+        <el-table-column :align="'center'" sortable prop="level" label="绾у埆" width="100px">
+          <template slot-scope="scope">
+            <span>{{ scope.row.level | leverFilter }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column :align="'center'" sortable prop="procName" label="杩涚▼" width="150px"></el-table-column>
+        <el-table-column :align="'center'" sortable prop="procID" label="杩涚▼鍙�" width="150px"></el-table-column>
+        <!-- <el-table-column
+          :align="'center'"
+          prop="hostName"
+          min-width="100px"
+          label="涓绘満鍚�"
+          width="150px"
+        ></el-table-column> -->
+
+        <el-table-column sortable :align="'center'" prop="createDate" label="鏃ユ湡鏃堕棿" width="200px"></el-table-column>
+        <el-table-column prop="info" label="璇︾粏淇℃伅"></el-table-column>
+      </el-table>
+    </div>
+
+    <el-pagination
+      @size-change="handleSizeChange"
+      @current-change="handleCurrentChange"
+      :current-page="page"
+      :page-sizes="[15, 30, 50, 100]"
+      :page-size="15"
+      layout="total, sizes, prev, pager, next, jumper"
+      :total="total"
+    >
+    </el-pagination>
   </div>
 </template>
 
 <script>
+import { queryVaSystemLog, queryProcName } from "@/api/log"
+import { pad0 } from "@/api/utils"
+const levelOptions = [
+  {
+    value: 0,
+    label: "鍏ㄩ儴",
+    style: ""
+  },
+  {
+    value: 1,
+    label: "涓ラ噸",
+    style: "error-row"
+  },
+  {
+    value: 2,
+    label: "閿欒",
+    style: "error-row"
+  },
+  {
+    value: 3,
+    label: "璀﹀憡",
+    style: "warning-row"
+  },
+  {
+    value: 4,
+    label: "淇℃伅",
+    style: ""
+  },
+  {
+    value: 5,
+    label: "璋冭瘯",
+    style: ""
+  }
+]
+
 export default {
-  mounted() {},
   data() {
     return {
-      langList: [
-        { name: "绠�浣撲腑鏂�" },
-        { name: "鑻辨枃" },
-        { name: "绻佷綋涓枃锛堥娓級" },
-      ],
-      fileList: [
-        { time: "2010-10-02 12:30:09", name: "鏂囦欢1" },
-        { time: "2010-10-02 12:30:09", name: "鏂囦欢12121212121" },
-        { time: "2010-10-02", name: "鏂囦欢2211" },
-        { time: "2011", name: "澶囦唤鏂囦欢2" },
-      ],
-      activePage: 0,
-      interval: "",
-      lifeSpan: "",
-      options: [
-        {
-          value: "閫夐」1",
-          label: "鎵嬪姩",
-        },
-        {
-          value: "閫夐」2",
-          label: "鑷姩",
-        },
-      ],
-      isBackUp: true,
-    };
+      png: require("../../../../public/images/syslog/娌℃暟鎹�.png"),
+      loading: false,
+      loadingText: "",
+      tableData: [],
+      dateArr: ["浠婃棩", "杩戜笁澶�", "杩戜竷澶�", "杩戜竴涓湀", "杩戝叚涓湀"],
+
+      procOptions: [],
+      hostNameOptions: [],
+      levelOptions: levelOptions,
+      value: "",
+      page: 1,
+      pageSize: 15,
+      activeDateChoise: 0,
+      procName: [],
+      level: 0,
+      timeStart: "",
+      timeEnd: "",
+      fuzzySearch: "",
+      total: 0
+    }
+  },
+  filters: {
+    leverFilter(val) {
+      for (let i = 0; i < levelOptions.length; i++) {
+        if (levelOptions[i].value === val) {
+          return levelOptions[i].label
+        }
+      }
+    }
+  },
+  mounted() {
+    this.getTimeRange(24 * 60 * 60 * 1000)
+    this.getVaSystemLog()
+    this.getOptions()
   },
   methods: {
-    openRight(typ) {
-      const es = document.getElementsByClassName("menu-item");
-      es[this.activePage].style.backgroundColor = "#f8f8f8";
-      es[this.activePage].style.color = "rgba(54, 54, 54, 1)";
-      es[typ].style.backgroundColor = "rgba(61, 104, 225, 1)";
-      es[typ].style.color = "#fff";
-      this.activePage = typ;
+    tableRowClassName({ row, rowIndex }) {
+      for (let i = 0; i < levelOptions.length; i++) {
+        if (levelOptions[i].value === row.level) {
+          return levelOptions[i].style
+        }
+      }
     },
-    handleChange() {},
-    backUpNow() {
-      this.$confirm("鎮ㄦ槸鍚︾‘璁ょ珛鍗冲浠芥墍鏈夊簲鐢ㄧ殑閰嶇疆鏁版嵁锛�", "绔嬪嵆澶囦唤", {
-        confirmButtonText: "纭畾",
-        cancelButtonText: "鍙栨秷",
-      }).then(() => {
-        this.$message({
-          type: "success",
-          message: "澶囦唤鎴愬姛",
-        });
-      });
-      //  .then((resp) => {
-      //         if (resp.success) {
-      //           this.$message({
-      //             type: "success",
-      //             message: "鍒犻櫎鏁版嵁鎴愬姛",
-      //           });
-      //           this.loading = false;
-      //         }
-      //       })
-      //       .catch((err) => {
-      //         this.$message({
-      //           type: "error",
-      //           message: "鍒犻櫎鏁版嵁澶辫触锛�",
-      //         });
-      //         this.loading = false;
-      //       });
+    handleSizeChange(val) {
+      this.pageSize = val
+      this.getVaSystemLog()
     },
-    switchChange(val) {
-      console.log(val);
+    handleCurrentChange(val) {
+      this.page = val
+      this.getVaSystemLog()
     },
-  },
-};
+    getOptions() {
+      queryProcName().then((res) => {
+        this.procOptions = res.data
+      })
+    },
+    choseRange(item, i) {
+      switch (item) {
+        case "浠婃棩":
+          this.getTimeRange(24 * 60 * 60 * 1000)
+          break
+        case "杩戜笁澶�":
+          this.getTimeRange(24 * 60 * 60 * 1000 * 3)
+          break
+        case "杩戜竷澶�":
+          this.getTimeRange(24 * 60 * 60 * 1000 * 7)
+          break
+        case "杩戜竴涓湀":
+          this.getTimeRange(24 * 60 * 60 * 1000 * 30)
+          break
+        case "杩戝叚涓湀":
+          this.getTimeRange(24 * 60 * 60 * 1000 * 30 * 6)
+          break
+        default:
+          break
+      }
+      this.activeDateChoise = i
+      this.getVaSystemLog()
+    },
+    getVaSystemLog(typ) {
+      if (typ == 1) {
+        this.page = 1
+      }
+      queryVaSystemLog({
+        timeStart: this.timeStart,
+        timeEnd: this.timeEnd,
+        level: this.level,
+        procName: this.procName,
+        fuzzySearch: this.fuzzySearch,
+        page: this.page,
+        pageSize: this.pageSize
+      }).then((res) => {
+        this.tableData = res.data.logs
+        this.total = res.data.total
+      })
+    },
+    getTimeStr(date) {
+      var month = pad0(date.getMonth() + 1) //鏈�
+      var day = pad0(date.getDate()) //鏃�
+      return `${date.getFullYear()}-${month}-${day}`
+    },
+    getTimeRange(gap) {
+      var date = new Date() //褰撳墠鏃堕棿
+      var preDay = new Date(new Date().getTime() - gap + 24 * 60 * 60 * 1000)
+      this.timeStart = this.getTimeStr(preDay) + " 00:00:00"
+      this.timeEnd = this.getTimeStr(date) + " 23:59:59"
+    },
+    clearSearch() {
+      this.fuzzySearch = ""
+      this.getVaSystemLog(1)
+    }
+  }
+}
 </script>
 <style lang="scss">
-.all {
+.sys-log {
+  margin: 0 auto;
+  padding: 0px 8px 10px 5px;
+  border-top: 1px solid #e1e0e6;
+  background-color: rgba(242, 242, 247, 1);
   width: 100%;
-}
-
-.backup-content {
-  height: 100%;
   display: flex;
-  flex-direction: row;
-  flex: 1;
-  flex-basis: auto;
-  box-sizing: border-box;
-  .backup-center {
-    height: 100%;
-    width: 280px;
-    overflow: auto;
-    box-sizing: border-box;
-    flex-shrink: 0;
-    padding: 10px;
-    border-right: 5px solid #f8f8f8;
-    .menu-item {
-      background-color: #f8f8f8;
-      height: 50px;
-      margin-bottom: 10px;
-      border-radius: 8px;
-      line-height: 50px;
-      box-sizing: border-box;
-      font-size: 14px;
-      cursor: pointer;
-      padding: 0 20px;
+  flex-direction: column;
+  overflow: auto;
+  .top {
+    height: 132px;
+    background: #fff;
+    border-radius: 5px;
+    .first {
       display: flex;
       justify-content: space-between;
-      .con {
-        .iconfont {
+      align-items: center;
+      height: 45px;
+      padding: 20px 20px 0 20px;
+      .time-option {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        .title {
           margin-right: 10px;
+          min-width: fit-content;
+          font-weight: bold;
+          font-size: 12px;
         }
-        .menu-text {
-          font-size: 15px;
+        .opts {
+          display: flex;
+          justify-content: space-between;
+          .opt {
+            box-sizing: border-box;
+            border: 2px solid #efeff6;
+            min-width: fit-content;
+            width: 100px;
+            height: 36px;
+            padding: 0 15px;
+            border-radius: 4px;
+            cursor: pointer;
+            margin-right: 2px;
+            line-height: 32px;
+            font-size: 12px;
+            color: #333;
+          }
+          .opt:hover {
+            border-color: #4e94ff;
+          }
+          .opt-active {
+            color: #fff;
+            background-color: #4e94ff;
+            border-color: #4e94ff;
+          }
+        }
+      }
+      .search {
+        width: 280px;
+        height: 36px;
+        display: flex;
+        align-items: center;
+
+        .input-with-select {
+          width: 100%;
+          height: 100%;
+
+          input {
+            height: 100%;
+            border-radius: 18px 0 0 18px;
+            border: 2px solid #f2f2f7;
+            border-right: none;
+
+            &:focus,
+            &:focus + .el-input-group__append {
+              border-color: #409eff;
+            }
+          }
+
+          .el-input-group__append {
+            transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
+            background-color: #fff;
+            border: 2px solid #f2f2f7;
+            border-radius: 0 18px 18px 0;
+            border-left: none;
+          }
+        }
+
+        span {
+          cursor: pointer;
+          color: rgb(47, 45, 61);
+          font-weight: 700;
+          font-size: 19px;
+        }
+      }
+    }
+    .second {
+      display: flex;
+      margin: 15px 0 20px 0;
+      padding: 0 20px;
+      .bar {
+        display: flex;
+        align-items: baseline;
+        width: fit-content;
+        margin-right: 30px;
+        min-width: 120px;
+
+        .el-select {
+          width: 200px;
+          height: 36px;
+
+          .el-input {
+            width: 100%;
+            height: 100%;
+
+            input {
+              width: 100%;
+              height: 100%;
+              border: 2px solid #f2f2f7;
+              border-radius: 20px;
+            }
+          }
+        }
+        .name {
+          margin-right: 15px;
+          min-width: fit-content;
+          font-weight: bold;
+          font-size: 12px;
         }
       }
     }
   }
-  .backup-right {
-    flex: 1;
-    flex-basis: auto;
-    overflow: auto;
-    box-sizing: border-box;
-    position: relative;
-    padding: 20px 40px;
-    .el-form-item.is-required:not(.is-no-asterisk)
-      > .el-form-item__label:before,
-    .el-form-item.is-required:not(.is-no-asterisk)
-      .el-form-item__label-wrap
-      > .el-form-item__label:before {
-      display: none;
+  .table {
+    margin-top: 16px;
+    border-radius: 5px;
+    padding: 12px;
+    background-color: rgb(255, 255, 255);
+    .empty_img {
+      margin: 80px auto;
+      width: 164px;
     }
-    .el-select {
-      width: 100%;
-    }
-    .el-form-item {
-      margin-bottom: 10px;
-      height: 50px;
-      background: #f8f8f8;
-      padding: 4px 20px;
-      -webkit-box-sizing: border-box;
-      box-sizing: border-box;
-      border-radius: 10px;
-      .el-form-item__label {
-        text-align: left;
-        line-height: 42px;
+    .tableBox {
+      border: none;
+      &::before,
+      &::after {
+        display: none;
       }
-    }
-    .el-form-item__content {
-      line-height: 40px;
-      position: relative;
-      font-size: 14px;
-    }
-    .ip-input-container {
-      max-width: none !important;
-    }
-    .auto {
-      .bar {
-        display: flex;
-        align-items: center;
-        height: 50px;
-        padding: 0 25px;
-        background-color: #f8f8f8;
-        justify-content: space-between;
-        border-radius: 12px;
-        margin-bottom: 10px;
-        .name {
-          font-size: 15px;
-          text-align: left;
-          min-width: 180px;
+
+      tr {
+        td:first-child {
+          border-radius: 4px 0 0 4px;
         }
-        .el-input {
-          width: 100%;
-          .el-input {
-            height: auto;
-          }
-          .el-input__inner {
-            border: none;
-            border-radius: 8px;
-            background-color: rgba(240, 240, 240, 1);
-            text-align: left;
-          }
+        td:last-child {
+          border-radius: 0 4px 4px 0;
+        }
+        &.current-row td {
+          background-color: #4e94ff !important;
+          color: #fff;
+        }
+        &:hover td {
+          background-color: rgb(242, 242, 247);
         }
       }
-    }
-    .recover {
-      .title {
-        font-size: 13px;
-        color: #868686;
-        text-align: left;
-        padding: 0 10px;
-        margin-bottom: 10px;
-      }
-      .table-head {
-        height: 30px;
-        line-height: 30px;
-        display: flex;
-        // justify-content: space-between;
-        box-sizing: border-box;
-        font-size: 15px;
-        padding: 0 10px;
-        margin-bottom: 5px;
-        .line1 {
-          flex: 4;
-          text-align: left;
-        }
-        .line2 {
-          flex: 1;
-          text-align: right;
-        }
-      }
-      .bar {
+      th {
+        padding: 0 !important;
         height: 40px;
-        background-color: rgba(248, 248, 248, 1);
-        display: flex;
-        box-sizing: border-box;
-        padding: 0 10px;
-        align-items: center;
-        border-radius: 8px;
-        color: #797979;
-        font-size: 14px;
-        margin-bottom: 10px;
-        .time {
-          width: 45%;
-          text-align: left;
-        }
-        .operation {
-          color: rgba(26, 115, 232, 1);
-          cursor: pointer;
-          width: 10%;
-          text-align: right;
-        }
+        line-height: 40px;
+        border-color: #fff !important;
+        border-right: 2px solid #fff;
+        border-radius: 4px;
+        font-size: 12px;
+        background: #f2f2f7;
+      }
+      td {
+        padding: 0 !important;
+        height: 34px;
+        line-height: 34px;
+        border: none;
+        font-size: 12px;
       }
     }
-    .save-btn {
-      background-color: #3d68e1;
-      width: 240px;
-      height: 40px;
-      margin: 0 auto;
-      border-radius: 10px;
-      color: #fff;
-      line-height: 40px;
-      font-size: 14px;
-      margin-top: 20px;
-    }
+  }
+  .el-pagination {
+    padding: 20px 5px;
+    height: 100%;
+    box-sizing: border-box;
+    background-color: white;
+  }
+
+  .el-table .warning-row {
+    background: oldlace;
+  }
+
+  .el-table .error-row {
+    background: #f7b9b9;
   }
 }
 </style>

--
Gitblit v1.8.0