Sfoglia il codice sorgente

1. 用户管理表格字段显示优化;2. 日志管理支持日期查询

Bella 2 anni fa
parent
commit
0722eb8bf9

+ 11 - 0
package-lock.json

@@ -10,6 +10,7 @@
       "dependencies": {
         "axios": "^1.3.4",
         "core-js": "^3.8.3",
+        "dayjs": "^1.11.7",
         "element-ui": "^2.15.13",
         "js-cookie": "^3.0.1",
         "vue": "^2.7.14",
@@ -4608,6 +4609,11 @@
       "resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.1.1.tgz",
       "integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
     },
+    "node_modules/dayjs": {
+      "version": "1.11.7",
+      "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.7.tgz",
+      "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
+    },
     "node_modules/de-indent": {
       "version": "1.0.2",
       "resolved": "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz",
@@ -15557,6 +15563,11 @@
       "resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.1.1.tgz",
       "integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
     },
+    "dayjs": {
+      "version": "1.11.7",
+      "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.7.tgz",
+      "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
+    },
     "de-indent": {
       "version": "1.0.2",
       "resolved": "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz",

+ 2 - 2
package.json

@@ -9,6 +9,7 @@
   "dependencies": {
     "axios": "^1.3.4",
     "core-js": "^3.8.3",
+    "dayjs": "^1.11.7",
     "element-ui": "^2.15.13",
     "js-cookie": "^3.0.1",
     "vue": "^2.7.14",
@@ -21,10 +22,9 @@
     "@vue/cli-plugin-vuex": "~5.0.0",
     "@vue/cli-service": "~5.0.0",
     "babel-plugin-component": "^1.1.1",
-
+    "less-loader": "^11.1.0",
     "sass": "^1.32.7",
     "sass-loader": "^12.0.0",
-    "less-loader": "^11.1.0",
     "svg-sprite-loader": "^6.0.11",
     "vue-template-compiler": "^2.6.14"
   }

+ 16 - 16
src/api/security/logMonitor.js

@@ -2,27 +2,27 @@ import { get, post } from "@/utils/requestMethod";
 
 /**
  * 获取日志列表
- * @param {*} page 
- * @param {*} page_size 
- * @param {*} name 
- * @param {*} module 
- * @param {*} operation_type 
- * @param {*} operation_status 
- * @returns 
+ * @param {*} page
+ * @param {*} page_size
+ * @param {*} name
+ * @param {*} module
+ * @param {*} operation_type
+ * @param {*} operation_status
+ * @returns
  */
 const getLogList = (
   page,
-  page_size=10,
-  name="",
-  module_name="",
-  operation_type="",
-  operation_status=""
+  page_size = 10,
+  name = "",
+  module_name = "",
+  operation_type = "",
+  operation_status = "",
+  start_time = "",
+  end_time = ""
 ) => {
   return get(
-    `/log/log_list?page=${page}&page_size=${page_size}&name=${name}&module=${module_name}&operation_type=${operation_type}&operation_status=${operation_status}`
+    `/log/log_list?page=${page}&page_size=${page_size}&name=${name}&module=${module_name}&operation_type=${operation_type}&operation_status=${operation_status}&start_time=${start_time}&end_time=${end_time}`
   );
 };
 
-export{
-    getLogList 
-}
+export { getLogList };

+ 4 - 2
src/api/user/user.js

@@ -2,18 +2,20 @@ import { get, post, put, del } from "@/utils/requestMethod";
 
 /**
  * 获取用户列表
- * @param {*} status
+ * @param {*} status 账户状态0为正常,1为禁用
  * @param {*} page
  * @param {*} page_size
+ * @name 对user_name进行模糊查询
  * @returns
  */
 const getUserList = (
     status,
     page,
     page_size = 20,
+    name=""
 ) => {
     return get(
-        `/users/user_list?status=${status}&page=${page}&page_size=${page_size}`
+        `/users/user_list?status=${status}&page=${page}&page_size=${page_size}&name=${name}`
     );
 }
 //添加用户

+ 3 - 0
src/main.js

@@ -9,6 +9,8 @@ Vue.config.productionTip = false;
 import ElementUI from "element-ui";
 import "element-ui/lib/theme-chalk/index.css";
 import locale from "element-ui/lib/locale/lang/zh-CN";
+// 引入dayjs库
+import dayjs from "dayjs";
 Vue.use(ElementUI, { locale });
 
 //拖拽注册
@@ -16,6 +18,7 @@ import "./utils/directive";
 
 Vue.use(ElementUI, { locale });
 Vue.prototype.axios = axios;
+Vue.prototype.$dayjs=dayjs
 
 new Vue({
   router,

+ 14 - 2
src/views/securityManagement/logMonitor.vue

@@ -51,7 +51,8 @@
               type="datetimerange"
               start-placeholder="开始日期"
               end-placeholder="结束日期"
-              :default-time="['12:00:00']"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              :default-time="['00:00:00']"
             >
             </el-date-picker>
           </el-form-item>
@@ -245,13 +246,24 @@ export default {
     },
     getTableData(page) {
       this.tableData = [];
+      let startTime =""
+      let endTime = ""
+      if(this.form.timeVal===""){
+        startTime=""
+        endTime=""
+      }else if(this.form.timeVal.length>0){
+        startTime = this.form.timeVal[0]
+        endTime=this.form.timeVal[1]
+      }
       getLogList(
         page,
         this.currentPageSize,
         this.form.nameInput,
         this.form.moduleName,
         this.form.operationType,
-        this.form.operationStatus
+        this.form.operationStatus,
+        startTime,
+        endTime
       ).then((res) => {
         if (res.data.code === 0 && res.data.data.length > 0) {
           this.paginationData.total = res.data.total

+ 260 - 244
src/views/userManagement/personManagement/tables/activeUser.vue

@@ -1,278 +1,294 @@
 <template>
-    <div>
-        <div class="batch_button">
-            <el-button class="export" @click="exportData">导出数据</el-button>
-            <el-button class="activate" @click="batchActivate">批量激活</el-button>
-            <el-button class="delete" @click="batchDelete">批量删除</el-button>
-        </div>
-        <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" :header-cell-style="{ textAlign: 'center' }"
-            :cell-style="{ textAlign: 'center' }" height="405" style="width: 100%" @selection-change="handleSelectionChange">
-            <el-table-column type="selection" width="50">
-            </el-table-column>
-            <el-table-column prop="username" label="用户名">
-            </el-table-column>
-            <el-table-column prop="phone_num" label="手机号">
-            </el-table-column>
-            <el-table-column prop="email" label="邮箱">
-            </el-table-column>
-            <el-table-column prop="role" label="角色">
-            </el-table-column>
-            <el-table-column prop="permission" label="权限">
-            </el-table-column>
-            <el-table-column prop="working_address" label="单位">
-            </el-table-column>
-            <el-table-column prop="register_time" label="注册时间">
-            </el-table-column>
-            <el-table-column prop="status" label="状态">
-                <template slot-scope="scope">
-                    <el-tag :color="scope.row.status == true ? '#06f77e' : '#757776'"></el-tag>
-                </template>
-            </el-table-column>
-            <el-table-column prop="operation" label="操作">
-                <template slot-scope="scope">
-                    <el-button size="mini" type="text" style="color: #2ea8e6" @click="userDetail(scope.row)">查看</el-button>
-                    <el-button size="mini" type="text" style="color: #2ea8e6"
-                        @click="userInfoEdit(scope.row)">编辑</el-button>
-                    <el-button size="mini" type="text" style="color: #2ea8e6" @click="deleteUser(scope.row)">删除</el-button>
-                </template>
-            </el-table-column>
-        </el-table>
-        <div class="bottom">
-            <page class="page" :paginationData="paginationData"></page>
-        </div>
-        <!--弹窗-->
-        <user-detail ref="userDetail"></user-detail>
-        <userInfoEdit ref="userInfoEdit"></userInfoEdit>
+  <div>
+    <div class="batch_button">
+      <el-button class="export" @click="exportData">导出数据</el-button>
+      <el-button class="activate" @click="batchActivate">批量激活</el-button>
+      <el-button class="delete" @click="batchDelete">批量删除</el-button>
     </div>
+    <el-table
+      ref="multipleTable"
+      :data="tableData"
+      tooltip-effect="dark"
+      :header-cell-style="{ textAlign: 'center' }"
+      :cell-style="{ textAlign: 'center' }"
+      height="405"
+      style="width: 100%"
+      @selection-change="handleSelectionChange"
+    >
+      <el-table-column type="selection" width="50"> </el-table-column>
+      <el-table-column prop="username" label="用户名"> </el-table-column>
+      <el-table-column prop="phone" label="手机号"> </el-table-column>
+      <el-table-column prop="email" label="邮箱"> </el-table-column>
+      <el-table-column prop="role" label="角色"> </el-table-column>
+      <el-table-column prop="permission" label="权限"> </el-table-column>
+      <el-table-column prop="working_address" label="单位"> </el-table-column>
+      <el-table-column prop="register_time" label="注册时间"> </el-table-column>
+      <el-table-column prop="status" label="状态">
+        <template slot-scope="scope">
+          <el-tag
+            :color="scope.row.status == true ? '#06f77e' : '#757776'"
+          ></el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column prop="operation" label="操作">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            style="color: #2ea8e6"
+            @click="userDetail(scope.row)"
+            >查看</el-button
+          >
+          <el-button
+            size="mini"
+            type="text"
+            style="color: #2ea8e6"
+            @click="userInfoEdit(scope.row)"
+            >编辑</el-button
+          >
+          <el-button
+            size="mini"
+            type="text"
+            style="color: #2ea8e6"
+            @click="deleteUser(scope.row)"
+            >删除</el-button
+          >
+        </template>
+      </el-table-column>
+    </el-table>
+    <div class="bottom">
+      <page class="page" :paginationData="paginationData"></page>
+    </div>
+    <!--弹窗-->
+    <user-detail ref="userDetail"></user-detail>
+    <userInfoEdit ref="userInfoEdit"></userInfoEdit>
+  </div>
 </template>
 
 <script>
-import page from '@/components/pagination/index';
-import { getUserList, deleteSingleUser, updateUserDetail } from '@/api/user/user';
-import UserDetail from '../messageDialog/userInfoDetail';
-import userInfoEdit from '../messageDialog/userInfoEdit';
+import page from "@/components/pagination/index";
+import {
+  getUserList,
+  deleteSingleUser,
+  updateUserDetail,
+} from "@/api/user/user";
+import UserDetail from "../messageDialog/userInfoDetail";
+import userInfoEdit from "../messageDialog/userInfoEdit";
 export default {
-    components: { page, UserDetail, userInfoEdit },
-    data() {
-        return {
-            tableData: [],
-            multipleSelection: [],
-            currentPageSize: 10,
-            currentPage: 1,
-            paginationData: {
-                pageSize: 10,
-                pagerCount: 5,
-                currentPage: 1,
-                pageSizes: [5, 10, 20, 30],
-                total: 30,
-                currentChange: (val) => {
-                    this.getTableData(val);
-                },
-                handleSizeChange: (val) => {
-                    this.handleSizeChange(val);
-                },
-            },
-        }
-    },
-    mounted() {
-        this.initData();
-    },
-    methods: {
-        initData() {
-            this.getTableData(1);
-        },
-        handleSelectionChange(val) {
-            this.multipleSelection = val;
-        },
-        handleClick() {
-            //
-        },
-        getTableData(page) {
-            this.tableData = [];
-            getUserList(
-                0,
-                page,
-                this.currentPageSize
-            ).then((res) => {
-                if (res.data.code === 0 && res.data.data.length > 0) {
-                    this.paginationData.total = res.data.total;
-                    this.tableData = res.data.data.map((e) => {
-                        return {
-                            username: e.name,
-                            phone: e.phone,
-                            email: e.email,
-                            role: e.role,
-                            permission: e.permission,
-                            working_address: e.company,
-                            register_time: e.register_time,
-                            status: e.on_job_status
-                        }
-                    })
-                }
-            })
+  components: { page, UserDetail, userInfoEdit },
+  data() {
+    return {
+      tableData: [],
+      multipleSelection: [],
+      currentPageSize: 10,
+      currentPage: 1,
+      paginationData: {
+        pageSize: 10,
+        pagerCount: 5,
+        currentPage: 1,
+        pageSizes: [5, 10, 20, 30],
+        total: 30,
+        currentChange: (val) => {
+          this.getTableData(val);
         },
-        handleSizeChange(val) {
-            this.currentPageSize = val;
-            this.getTableData(this.currentPage);
-        },
-        userDetail() {
-            this.$refs.userDetail.dialogVisible = true;
-        },
-        userInfoEdit() {
-            this.$refs.userInfoEdit.dialogVisible = true;
-        },
-        deleteUser(data) {
-            let options = {
-                id: data.id,
-                username: data.username,
-                password: data.password
-            };
-            deleteSingleUser(options).then((res) => {
-                if (res.data.code === 0) {
-                    this.$message.success('删除成功');
-                    this.getTableData(1);
-                }
-            })
-        },
-        userDetail(data) {
-
+        handleSizeChange: (val) => {
+          this.handleSizeChange(val);
         },
-        userInfoEdit(data) {
-            let options = {
-                id: data.id,
-
+      },
+    };
+  },
+  mounted() {
+    this.initData();
+  },
+  methods: {
+    initData() {
+      this.getTableData(1);
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val;
+    },
+    handleClick() {
+      //
+    },
+    getTableData(page) {
+      this.tableData = [];
+      getUserList(0, page, this.currentPageSize).then((res) => {
+        if (res.data.code === 0 && res.data.data.length > 0) {
+          this.paginationData.total = res.data.total;
+          this.tableData = res.data.data.map((e) => {
+            return {
+              username: e.name,
+              phone: e.phone == "undefined" || !e.phone ? "--" : e.phone,
+              email: e.email == "undefined" || !e.email ? "--" : e.email,
+              role: e.role == "undefined" || !e.role ? "--" : e.role,
+              permission:
+                e.permission == "undefined" || !e.permission
+                  ? e.permission
+                  : "--",
+              working_address:
+                e.company == "undefined" || !e.company ? "--" : e.company,
+              register_time: this.$dayjs(e.register_time).format(
+                "YYYY-MM-DD HH:mm:ss"
+              ),
+              status:
+                e.on_job_status == "undefined" || !e.on_job_status
+                  ? "--"
+                  : e.on_job_status,
             };
-            updateUserDetail(options).then((res) => {
-
-            })
-        },
-        batchActivate() {
-
-        },
-        batchDelete() {
-
-        },
-        exportData() {
-
+          });
         }
-    }
-}
+      });
+    },
+    handleSizeChange(val) {
+      this.currentPageSize = val;
+      this.getTableData(this.currentPage);
+    },
+    userDetail() {
+      this.$refs.userDetail.dialogVisible = true;
+    },
+    userInfoEdit() {
+      this.$refs.userInfoEdit.dialogVisible = true;
+    },
+    deleteUser(data) {
+      let options = {
+        id: data.id,
+        username: data.username,
+        password: data.password,
+      };
+      deleteSingleUser(options).then((res) => {
+        if (res.data.code === 0) {
+          this.$message.success("删除成功");
+          this.getTableData(1);
+        }
+      });
+    },
+    userDetail(data) {},
+    userInfoEdit(data) {
+      let options = {
+        id: data.id,
+      };
+      updateUserDetail(options).then((res) => {});
+    },
+    batchActivate() {},
+    batchDelete() {},
+    exportData() {},
+  },
+};
 </script>
 <style lang="less" scoped>
 .el-tag {
-    width: 12px;
-    height: 12px;
-    border-radius: 100px;
-    padding: 0;
+  width: 12px;
+  height: 12px;
+  border-radius: 100px;
+  padding: 0;
 }
 
 .el-table {
-    position: relative;
-    top: 50px;
-    left: 0;
-    border: 1px solid #f0f2f2;
-    font-size: 0.95rem;
-    font-family: PingFang SC;
-    font-weight: 500;
-    color: #b2b2b2;
-    background: rgba(255, 255, 255, 0.8);
+  position: relative;
+  top: 50px;
+  left: 0;
+  border: 1px solid #f0f2f2;
+  font-size: 0.95rem;
+  font-family: PingFang SC;
+  font-weight: 500;
+  color: #b2b2b2;
+  background: rgba(255, 255, 255, 0.8);
 
-    /deep/th {
-        background: #f7fbff;
-    }
+  /deep/th {
+    background: #f7fbff;
+  }
 
-    /deep/.el-checkbox {
-        color: #b2b2b2;
+  /deep/.el-checkbox {
+    color: #b2b2b2;
 
-        .el-checkbox__input.is-checked+.el-checkbox__label {
-            color: #2ea8e6;
-        }
+    .el-checkbox__input.is-checked + .el-checkbox__label {
+      color: #2ea8e6;
+    }
 
-        .el-checkbox__input.is-checked .el-checkbox__inner::after {
-            width: 70%;
-            height: 70%;
-            background: #2ea8e6;
-            border-radius: 0;
-            transform: rotate(0deg) scaleY(1);
-            position: static;
-            // border: 1px solid #8DD9FF;
-        }
+    .el-checkbox__input.is-checked .el-checkbox__inner::after {
+      width: 70%;
+      height: 70%;
+      background: #2ea8e6;
+      border-radius: 0;
+      transform: rotate(0deg) scaleY(1);
+      position: static;
+      // border: 1px solid #8DD9FF;
+    }
 
-        .el-checkbox__inner {
-            border: 1px solid #8dd9ff;
-            background: rgba(0, 170, 255, 0);
-            display: flex;
-            align-items: center;
-            justify-content: center;
-            position: static;
+    .el-checkbox__inner {
+      border: 1px solid #8dd9ff;
+      background: rgba(0, 170, 255, 0);
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      position: static;
 
-            &::after {
-                transition: 0ms;
-            }
-        }
+      &::after {
+        transition: 0ms;
+      }
+    }
 
-        .el-checkbox__label {
-            padding-left: 0;
-            font-size: 15px;
-            position: absolute;
-            top: 1px;
-            left: 25px;
-        }
+    .el-checkbox__label {
+      padding-left: 0;
+      font-size: 15px;
+      position: absolute;
+      top: 1px;
+      left: 25px;
     }
+  }
 }
 
 .batch_button {
-    position: relative;
-    top: 50px;
-    float: left;
-    left: 280px;
-
-    .export {
-        padding: 3px;
-        width: 80px;
-        height: 30px;
-        bottom: 15px;
-        position: absolute;
-        color: #fff;
-        border-radius: 4px;
-        right: 190px;
-        background-color: #2ea8e6;
-    }
+  position: relative;
+  top: 50px;
+  float: left;
+  left: 280px;
 
-    .activate {
-        padding: 3px;
-        width: 80px;
-        height: 30px;
-        bottom: 15px;
-        position: absolute;
-        color: #fff;
-        border-radius: 4px;
-        right: 100px;
-        background-color: #2ea8e6;
-    }
+  .export {
+    padding: 3px;
+    width: 80px;
+    height: 30px;
+    bottom: 15px;
+    position: absolute;
+    color: #fff;
+    border-radius: 4px;
+    right: 190px;
+    background-color: #2ea8e6;
+  }
 
-    .delete {
-        padding: 3px;
-        width: 80px;
-        height: 30px;
-        bottom: 15px;
-        position: absolute;
-        color: #fff;
-        border-radius: 4px;
-        right: 10px;
-        background-color: #b3b3b3;
-    }
+  .activate {
+    padding: 3px;
+    width: 80px;
+    height: 30px;
+    bottom: 15px;
+    position: absolute;
+    color: #fff;
+    border-radius: 4px;
+    right: 100px;
+    background-color: #2ea8e6;
+  }
 
+  .delete {
+    padding: 3px;
+    width: 80px;
+    height: 30px;
+    bottom: 15px;
+    position: absolute;
+    color: #fff;
+    border-radius: 4px;
+    right: 10px;
+    background-color: #b3b3b3;
+  }
 }
 
 .bottom {
-    position: absolute;
-    left: 20px;
-    right: 16px;
-    bottom: 20px;
-    height: 50px;
-    line-height: 20px;
-    background-color: #ffffff;
-    text-align: center;
+  position: absolute;
+  left: 20px;
+  right: 16px;
+  bottom: 20px;
+  height: 50px;
+  line-height: 20px;
+  background-color: #ffffff;
+  text-align: center;
 }
-</style>
+</style>