shaogen1995 3 gadi atpakaļ
vecāks
revīzija
6090bc295f

+ 29 - 0
src/apis/tab7.js

@@ -0,0 +1,29 @@
+import axios from '../utils/request'
+// 获取用户列表
+export const userList = (data) => {
+  return axios({
+    method: 'post',
+    url: '/sys/user/list',
+    data
+  })
+}
+// 编辑-新增用户
+export const userSave = (data) => {
+  return axios({
+    method: 'post',
+    url: '/sys/user/save',
+    data
+  })
+}
+// 启用、停用账户
+export const userEditStatus = (id, isEnabled) => {
+  return axios({
+    url: `/sys/user/editStatus/${id}/${isEnabled}`
+  })
+}
+// 删除
+export const userRemoves = (id) => {
+  return axios({
+    url: `/sys/user/removes/${id}`
+  })
+}

+ 9 - 0
src/apis/tab8.js

@@ -0,0 +1,9 @@
+import axios from '../utils/request'
+// 获取操作日志列表
+export const logList = (data) => {
+  return axios({
+    method: 'post',
+    url: '/sys/log/list',
+    data
+  })
+}

+ 12 - 0
src/router/index.js

@@ -109,6 +109,18 @@ const routes = [
         name: 'tab7',
         meta: { myInd: 7 },
         component: () => import('../views/tab7/index.vue')
+      },
+      {
+        path: 'tab7Edit',
+        name: 'tab7Edit',
+        meta: { myInd: 7 },
+        component: () => import('../views/tab7/edit.vue')
+      },
+      {
+        path: 'tab8',
+        name: 'tab8',
+        meta: { myInd: 8 },
+        component: () => import('../views/tab8/index.vue')
       }
     ]
   }

+ 1 - 1
src/utils/request.js

@@ -1,7 +1,7 @@
 import axios from 'axios'
 const service = axios.create({
   baseURL: 'http://192.168.0.135:8011/', // 本地调试
-  // baseURL: '', // 线上调试
+  // baseURL: 'http://8.135.106.227:8012/', // 线上调试
   // baseURL: '', // build
   timeout: 5000
 })

+ 2 - 2
src/views/layout/index.vue

@@ -31,8 +31,8 @@
             {{ item.name }}
           </li>
         </ul>
-        <div class="biaoji">系统管理</div>
-        <ul>
+        <div class="biaoji" v-if="userName==='admin'">系统管理</div>
+        <ul v-if="userName==='admin'">
           <li
             v-for="item in tab2"
             :key="item.id"

+ 1 - 1
src/views/tab3/index.vue

@@ -61,7 +61,7 @@
         <el-table-column label="操作" width="200">
           <template #default="{ row }">
             <el-button type="text" @click="editVideo(row.id)">修 改</el-button>
-            <el-button type="text" @click="delVideo(row.id)">删 除</el-button>
+            <el-button type="text" @click="delVideo(row.id)" style="color:#b6242b;">删 除</el-button>
           </template>
         </el-table-column>
       </el-table>

+ 1 - 1
src/views/tab4/index.vue

@@ -43,7 +43,7 @@
         <el-table-column label="操作" width="220">
           <template #default="{ row }">
             <el-button type="text" @click="editVideo(row.id)">修 改</el-button>
-            <el-button type="text" @click="delAlarm(row.id)">删 除</el-button>
+            <el-button type="text" @click="delAlarm(row.id)" style="color:#b6242b;">删 除</el-button>
           </template>
         </el-table-column>
       </el-table>

+ 2 - 2
src/views/tab5/index.vue

@@ -64,7 +64,7 @@
         <el-table-column label="操作" width="200">
           <template #default="{ row }">
             <el-button type="text" @click="editVideo(row.id)">修 改</el-button>
-            <el-button type="text" @click="delTow(row.id)">删 除</el-button>
+            <el-button type="text" @click="delTow(row.id)" style="color:#b6242b;">删 除</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -96,7 +96,7 @@
             <el-button type="text" @click="editVideoThree(row.id)"
               >修 改</el-button
             >
-            <el-button type="text" @click="delThree(row.id)"
+            <el-button type="text" @click="delThree(row.id)" style="color:#b6242b;"
               >删 除</el-button
             >
           </template>

+ 1 - 1
src/views/tab6/index.vue

@@ -53,7 +53,7 @@
         <el-table-column label="操作" width="200">
           <template #default="{ row }">
             <el-button type="text" @click="editVideo(row.id)">修 改</el-button>
-            <el-button type="text" @click="delTow(row.id)">删 除</el-button>
+            <el-button type="text" @click="delTow(row.id)" style="color:#b6242b;">删 除</el-button>
           </template>
         </el-table-column>
       </el-table>

+ 153 - 0
src/views/tab7/edit.vue

@@ -0,0 +1,153 @@
+<template>
+  <div class="tab7Edit">
+    <div class="top">{{ruleForm.id?'编辑用户':'新增用户'}}</div>
+    <div class="con">
+      <el-form
+        :model="ruleForm"
+        :rules="rules"
+        ref="ruleForm"
+        label-width="100px"
+        class="demo-ruleForm"
+      >
+        <el-form-item label="用户账号:" prop="userName">
+          <el-input
+            :disabled='!!ruleForm.id'
+            v-model="ruleForm.userName"
+            placeholder="仅能输入数字、字母"
+            maxlength="10"
+            show-word-limit
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="联系电话:" prop="phone">
+          <el-input
+            v-model="ruleForm.phone"
+            placeholder="请输入电话"
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="性别:">
+          <el-radio v-model="ruleForm.sex" :label="0">男</el-radio>
+          <el-radio v-model="ruleForm.sex" :label="1">女</el-radio>
+        </el-form-item>
+        <el-form-item label="是否启用:">
+          <el-switch
+            v-model="ruleForm.isEnabled"
+            :active-value='1'
+            :inactive-value="0"
+          >
+          </el-switch>
+        </el-form-item>
+        <span class="tip">*默认密码123456</span>
+      </el-form>
+    </div>
+    <!-- 下面的按钮 -->
+    <div class="btn">
+      <el-button @click="$router.push('/layout/tab7')">返 回</el-button>
+      <el-button type="primary" @click="btnOk">提 交</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+import { userSave } from '@/apis/tab7'
+export default {
+  // import引入的组件需要注入到对象中才能使用
+  name: 'tab7Edit',
+  components: {},
+  data () {
+    // 这里存放数据
+    return {
+      ruleForm: {
+        userName: '',
+        phone: '',
+        sex: 0,
+        isEnabled: 1
+      },
+      rules: {
+        userName: [
+          { required: true, message: '不能为空', trigger: 'blur' },
+          {
+            pattern: /^[0-9a-zA-Z_]*$/,
+            message: '仅能输入数字、字母',
+            trigger: 'blur'
+          }
+        ],
+        phone: [
+          { required: true, message: '不能为空', trigger: 'blur' },
+          {
+            pattern: /^1[3-9]\d{9}$/,
+            message: '请输入合法手机号',
+            trigger: 'blur'
+          }
+        ]
+      }
+    }
+  },
+  // 监听属性 类似于data概念
+  computed: {},
+  // 监控data中的数据变化
+  watch: {},
+  // 方法集合
+  methods: {
+    async btnOk () {
+      try {
+        await this.$refs.ruleForm.validate()
+        const res = await userSave(this.ruleForm)
+        if (res.code === 0) {
+          this.$message.success('操作成功')
+          this.$router.push('/layout/tab7')
+        } else this.$message.warning(res.msg)
+      } catch (error) {
+        console.log(error)
+      }
+    }
+  },
+  // 生命周期 - 创建完成(可以访问当前this实例)
+  created () {
+    // 编辑的情况下
+    if (this.$route.query.id) {
+      this.ruleForm = this.$route.query
+      this.ruleForm.sex = Number(this.ruleForm.sex)
+      this.ruleForm.isEnabled = Number(this.ruleForm.isEnabled)
+    }
+  },
+  // 生命周期 - 挂载完成(可以访问DOM元素)
+  mounted () {},
+  beforeCreate () {}, // 生命周期 - 创建之前
+  beforeMount () {}, // 生命周期 - 挂载之前
+  beforeUpdate () {}, // 生命周期 - 更新之前
+  updated () {}, // 生命周期 - 更新之后
+  beforeDestroy () {}, // 生命周期 - 销毁之前
+  destroyed () {}, // 生命周期 - 销毁完成
+  activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
+}
+</script>
+<style lang='less' scoped>
+.tab7Edit {
+  height: 100%;
+  position: relative;
+  .top {
+    height: 40px;
+    line-height: 40px;
+    background-color: #fbfbfb;
+    padding-left: 20px;
+  }
+  .con {
+    margin-top: 40px;
+    width: 600px;
+    .tip{
+      color: #F56C6C;
+      font-size: 14px;
+      margin-left: 12px;
+    }
+  }
+    .btn {
+    display: flex;
+    justify-content: space-between;
+    width: 200px;
+    position: absolute;
+    left: 50%;
+    bottom: 30px;
+    transform: translateX(-50%);
+  }
+}
+</style>

+ 222 - 13
src/views/tab7/index.vue

@@ -1,33 +1,215 @@
 <!--  -->
 <template>
-<div class='tab7'>
-  <div class="top">
-
-  </div>
-</div>
+  <div class="tab7">
+    <div class="top">
+      <el-form
+        :model="ruleForm"
+        ref="ruleForm"
+        label-width="100px"
+        class="demo-ruleForm"
+      >
+        <el-form-item label="注册时间:">
+          <el-date-picker
+            style="width: 300px"
+            v-model="time"
+            type="daterange"
+            range-separator="-"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期"
+          >
+          </el-date-picker>
+          <span class="userName">用户账号:</span>
+          <el-input
+            placeholder="请输入"
+            v-model="ruleForm.searchKey"
+            style="width: 300px; margin-right: 50px"
+          ></el-input>
+          <el-button @click="inquire">查 询</el-button>
+          <el-button @click="reset">重 置</el-button>
+        </el-form-item>
+      </el-form>
+      <div class="addUser">
+        <el-button type="primary" @click="$router.push('/layout/tab7Edit')"
+          >新 增</el-button
+        >
+      </div>
+    </div>
+    <!-- 表格 -->
+    <div class="table">
+      <el-table :data="tableData" style="width: 100%">
+        <el-table-column label="序号" width="80">
+          <template slot-scope="scope">
+            {{ scope.$index + (ruleForm.pageNum - 1) * ruleForm.pageSize + 1 }}
+          </template>
+        </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="sexTxt" label="性别"> </el-table-column>
+        <el-table-column prop="createTime" label="注册时间"> </el-table-column>
+        <el-table-column label="启用状态">
+          <template slot-scope="scope">
+            <el-switch :disabled='scope.row.id===1' @change='change($event,scope.row.id)' v-model="tableData[scope.$index].isEnabled" :active-value='1' :inactive-value="0"></el-switch>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" width="230">
+          <template #default="{ row }">
+            <el-button type="text" @click="edit(row)" v-if="row.id!==1">编 辑</el-button>
+            <el-button type="text" style="color: #b6242b" @click="delUser(row.id)"  v-if="row.id!==1">删 除</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    <!-- 分页 -->
+    <div class="paging">
+      <span class="zong">共 {{ total }} 条</span>
+      <el-pagination
+        layout="sizes,prev,pager,next,jumper"
+        :total="total"
+        :page-sizes="[15, 30, 45, 60]"
+        :current-page="ruleForm.pageNum"
+        @current-change="currentChange"
+        @size-change="sizeChange"
+      >
+      </el-pagination>
+    </div>  </div>
 </template>
 
 <script>
+import { userList, userEditStatus, userRemoves } from '@/apis/tab7'
 export default {
   name: 'tab7',
   components: {},
   data () {
     return {
-
+      total: 0,
+      time: '',
+      ruleForm: {
+        pageNum: 1,
+        pageSize: 15,
+        startTime: '',
+        endTime: '',
+        searchKey: ''
+      },
+      tableData: []
     }
   },
   computed: {},
+  // 监控data中的数据变化
+  watch: {
+    time (val) {
+      this.handleSelect(val)
+    }
+  },
   methods: {
-
+    // 点击编辑
+    edit (val) {
+      this.$router.push({
+        path: '/layout/tab7Edit',
+        query: val
+      })
+    },
+    // 点击删除
+    delUser (id) {
+      this.$confirm('确定删除吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+        .then(async () => {
+          await userRemoves(id)
+          this.$message.success('删除成功!')
+          this.userList(this.ruleForm)
+        })
+        .catch(() => {
+          this.$message.info('已取消删除')
+        })
+    },
+    // 分页器方法
+    currentChange (val) {
+      // console.log('当前页改变了', val)
+      this.ruleForm.pageNum = val
+      this.userList(this.ruleForm)
+    },
+    sizeChange (val) {
+      // console.log('条数改变了', val)
+      this.ruleForm.pageNum = 1
+      this.ruleForm.pageSize = val
+      this.userList(this.ruleForm)
+    },
+    // 点击查询
+    inquire () {
+      this.ruleForm.pageNum = 1
+      this.userList(this.ruleForm)
+    },
+    // 点击重置
+    reset () {
+      this.ruleForm = {
+        pageNum: 1,
+        pageSize: 15,
+        searchKey: ''
+      }
+      this.time = ''
+      this.userList(this.ruleForm)
+    },
+    // 点击启用-停用账户
+    async change (val, id) {
+      const res = await userEditStatus(id, val)
+      if (res.code === 0) {
+        this.$message.success('操作成功')
+        this.userList(this.ruleForm)
+      } else this.$message.warning(res.msg)
+    },
+    // 封装获取列表方法
+    async userList (data) {
+      const res = await userList(data)
+      this.tableData = res.data.records
+      this.total = res.data.total
+      this.tableData.forEach((v) => {
+        if (v.sex === 0) v.sexTxt = '男'
+        else if (v.sex === 1) v.sexTxt = '女'
+      })
+      // console.log(998, res.data.records)
+    },
+    // 时间处理----------------
+    handleSelect (e) {
+      const date = []
+      for (const i in e) {
+        date.push(this.gettime(e[i]))
+      }
+      this.ruleForm.startTime = date[0]
+      if (date[1]) {
+        this.ruleForm.endTime = date[1].replace('00:00:00', '23:59:59')
+      }
+      if (e === null) this.ruleForm.endTime = ''
+    },
+    gettime (data) {
+      const value =
+        data.getFullYear() +
+        '-' +
+        this.checkTime(data.getMonth() + 1) +
+        '-' +
+        this.checkTime(data.getDate()) +
+        ' ' +
+        this.checkTime(data.getHours()) +
+        ':' +
+        this.checkTime(data.getMinutes()) +
+        ':' +
+        this.checkTime(data.getSeconds())
+      return value
+    },
+    checkTime (i) {
+      if (i < 10) {
+        i = '0' + i
+      }
+      return i
+    }
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
   created () {
-
+    this.userList(this.ruleForm)
   },
   // 生命周期 - 挂载完成(可以访问DOM元素)
-  mounted () {
-
-  },
+  mounted () {},
   beforeCreate () {}, // 生命周期 - 创建之前
   beforeMount () {}, // 生命周期 - 挂载之前
   beforeUpdate () {}, // 生命周期 - 更新之前
@@ -38,6 +220,33 @@ export default {
 }
 </script>
 <style lang='less' scoped>
-//@import url(); 引入公共css类
-
+.tab7 {
+  .top {
+    position: relative;
+    border-bottom: 1px solid black;
+    margin-bottom: 20px;
+    .userName {
+      margin-left: 50px;
+    }
+    .addUser {
+      position: absolute;
+      right: 20px;
+      top: 0;
+    }
+  }
+  /deep/.el-table__body-wrapper{
+    max-height: 580px;
+    overflow-y: auto;
+  }
+  .paging {
+    width: auto;
+    display: flex;
+    position: absolute;
+    bottom: 40px;
+    right: 50px;
+    .zong {
+      margin-right: 20px;
+      margin-top: 4px;
+    }
+  }}
 </style>

+ 201 - 0
src/views/tab8/index.vue

@@ -0,0 +1,201 @@
+<!--  -->
+<template>
+  <div class="tab8">
+    <div class="top">
+      <el-form
+        :model="ruleForm"
+        ref="ruleForm"
+        label-width="100px"
+        class="demo-ruleForm"
+      >
+        <el-form-item label="操作日期:">
+          <el-date-picker
+            style="width: 300px"
+            v-model="time"
+            type="daterange"
+            range-separator="-"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期"
+          >
+          </el-date-picker>
+          <span class="userName">操作人员:</span>
+          <el-input
+            placeholder="请输入"
+            v-model="ruleForm.searchKey"
+            style="width: 300px; margin-right: 50px"
+          ></el-input>
+          <el-button @click="inquire">查 询</el-button>
+          <el-button @click="reset">重 置</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+    <!-- 表格 -->
+    <div class="table">
+      <el-table :data="tableData" style="width: 100%">
+        <el-table-column label="序号" width="80">
+          <template slot-scope="scope">
+            {{ scope.$index + (ruleForm.pageNum - 1) * ruleForm.pageSize + 1 }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="userName" label="操作者"> </el-table-column>
+        <el-table-column prop="createTime" label="操作日期"> </el-table-column>
+        <el-table-column prop="ip" label="ip地址"> </el-table-column>
+        <el-table-column prop="type" label="操作模块"> </el-table-column>
+        <el-table-column prop="description" label="操作记录"> </el-table-column>
+      </el-table>
+    </div>
+    <!-- 分页 -->
+    <div class="paging">
+      <span class="zong">共 {{ total }} 条</span>
+      <el-pagination
+        layout="sizes,prev,pager,next,jumper"
+        :total="total"
+        :page-sizes="[15, 30, 45, 60]"
+        :current-page="ruleForm.pageNum"
+        @current-change="currentChange"
+        @size-change="sizeChange"
+      >
+      </el-pagination>
+    </div>  </div>
+</template>
+
+<script>
+import { logList } from '@/apis/tab8'
+export default {
+  name: 'tab8',
+  components: {},
+  data () {
+    return {
+      total: 0,
+      time: '',
+      ruleForm: {
+        pageNum: 1,
+        pageSize: 15,
+        startTime: '',
+        endTime: '',
+        searchKey: ''
+      },
+      tableData: []
+    }
+  },
+  computed: {},
+  // 监控data中的数据变化
+  watch: {
+    time (val) {
+      this.handleSelect(val)
+    }
+  },
+  methods: {
+    // 分页器方法
+    currentChange (val) {
+      // console.log('当前页改变了', val)
+      this.ruleForm.pageNum = val
+      this.logList(this.ruleForm)
+    },
+    sizeChange (val) {
+      // console.log('条数改变了', val)
+      this.ruleForm.pageNum = 1
+      this.ruleForm.pageSize = val
+      this.logList(this.ruleForm)
+    },
+    // 点击查询
+    inquire () {
+      this.ruleForm.pageNum = 1
+      this.logList(this.ruleForm)
+    },
+    // 点击重置
+    reset () {
+      this.ruleForm = {
+        pageNum: 1,
+        pageSize: 15,
+        searchKey: ''
+      }
+      this.time = ''
+      this.logList(this.ruleForm)
+    },
+    // 封装获取列表方法
+    async logList (data) {
+      const res = await logList(data)
+      this.tableData = res.data.records
+      this.total = res.data.total
+    },
+    // 时间处理----------------
+    handleSelect (e) {
+      const date = []
+      for (const i in e) {
+        date.push(this.gettime(e[i]))
+      }
+      this.ruleForm.startTime = date[0]
+      if (date[1]) {
+        this.ruleForm.endTime = date[1].replace('00:00:00', '23:59:59')
+      }
+      if (e === null) this.ruleForm.endTime = ''
+    },
+    gettime (data) {
+      const value =
+        data.getFullYear() +
+        '-' +
+        this.checkTime(data.getMonth() + 1) +
+        '-' +
+        this.checkTime(data.getDate()) +
+        ' ' +
+        this.checkTime(data.getHours()) +
+        ':' +
+        this.checkTime(data.getMinutes()) +
+        ':' +
+        this.checkTime(data.getSeconds())
+      return value
+    },
+    checkTime (i) {
+      if (i < 10) {
+        i = '0' + i
+      }
+      return i
+    }
+  },
+  // 生命周期 - 创建完成(可以访问当前this实例)
+  created () {
+    this.logList(this.ruleForm)
+  },
+  // 生命周期 - 挂载完成(可以访问DOM元素)
+  mounted () {},
+  beforeCreate () {}, // 生命周期 - 创建之前
+  beforeMount () {}, // 生命周期 - 挂载之前
+  beforeUpdate () {}, // 生命周期 - 更新之前
+  updated () {}, // 生命周期 - 更新之后
+  beforeDestroy () {}, // 生命周期 - 销毁之前
+  destroyed () {}, // 生命周期 - 销毁完成
+  activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
+}
+</script>
+<style lang='less' scoped>
+.tab8 {
+  .top {
+    position: relative;
+    border-bottom: 1px solid black;
+    margin-bottom: 20px;
+    .userName {
+      margin-left: 50px;
+    }
+    .addUser {
+      position: absolute;
+      right: 20px;
+      top: 0;
+    }
+  }
+  /deep/.el-table__body-wrapper{
+    max-height: 580px;
+    overflow-y: auto;
+  }
+  .paging {
+    width: auto;
+    display: flex;
+    position: absolute;
+    bottom: 40px;
+    right: 50px;
+    .zong {
+      margin-right: 20px;
+      margin-top: 4px;
+    }
+  }}
+</style>