|
@@ -0,0 +1,208 @@
|
|
|
+<style lang="scss" scoped>
|
|
|
+table{
|
|
|
+ width: 100%;
|
|
|
+ thead{
|
|
|
+ color: #909399;
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
+ tr{
|
|
|
+ background-color: #FFF;
|
|
|
+ }
|
|
|
+ th,td{
|
|
|
+ padding: 12px 0;
|
|
|
+ padding-left: 10px;
|
|
|
+ padding-right: 10px;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ vertical-align: middle;
|
|
|
+ border-bottom: 1px solid #EBEEF5;
|
|
|
+ a{
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.search-part{
|
|
|
+ padding: 5px 15px;
|
|
|
+ .add-user{
|
|
|
+ float: right;
|
|
|
+ }
|
|
|
+}
|
|
|
+.dialog-style{
|
|
|
+ div{
|
|
|
+ text-align: center;
|
|
|
+ margin: 5px;
|
|
|
+ /deep/ .el-input{
|
|
|
+ display: inline-block;
|
|
|
+ width: 200px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.center-text{
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+</style>
|
|
|
+<template>
|
|
|
+<div>
|
|
|
+ <div class="search-part">
|
|
|
+ <!-- <label>年级:</label>
|
|
|
+ <el-select v-model="search.grade" placeholder="请选择" @change="searchUser">
|
|
|
+ <el-option
|
|
|
+ v-for="item in gradeOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select> -->
|
|
|
+ <!-- <el-button icon="el-icon-search" circle @click="searchUser"></el-button> -->
|
|
|
+ <el-button type="primary" class="add-user" @click="visibleAdd = true">新增</el-button>
|
|
|
+ </div>
|
|
|
+ <table>
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>序号</th>
|
|
|
+ <th>姓名</th>
|
|
|
+ <th>手机</th>
|
|
|
+ <!-- <th>email</th> -->
|
|
|
+ <th>学校</th>
|
|
|
+ <th>年级</th>
|
|
|
+ <th>操作</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr v-for="(item,index) in userList" :key="index">
|
|
|
+ <td>{{index + 1}}</td>
|
|
|
+ <td>{{item.name}}</td>
|
|
|
+ <td>{{item.username}}</td>
|
|
|
+ <!-- <td>{{item.email}}</td> -->
|
|
|
+ <td>{{item.region}}</td>
|
|
|
+ <td>{{gradeMap[item.grade]}}</td>
|
|
|
+ <td>
|
|
|
+ <a @click="visibleChange = true;changeUser.id = item.id">修改密码</a>
|
|
|
+
|
|
|
+ <a @click="visibleDelete = true;deleteId = item.id">删除</a>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ <el-dialog
|
|
|
+ class="dialog-style"
|
|
|
+ title="编辑"
|
|
|
+ :visible.sync="visibleAdd"
|
|
|
+ width="500px">
|
|
|
+ <div>
|
|
|
+ <label>姓名:</label>
|
|
|
+ <el-input name="name" v-model="user.name" placeholder="请输入姓名" required="required"></el-input>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label>年级:</label>
|
|
|
+ <el-select v-model="user.grade" placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in gradeOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label>手机:</label>
|
|
|
+ <el-input v-model="user.username" placeholder="请输入手机" required="required"></el-input>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label>密码:</label>
|
|
|
+ <el-input placeholder="请输入密码" v-model="user.password" show-password required="required"></el-input>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="addUser">确 定</el-button>
|
|
|
+ <el-button type="primary" @click="visibleAdd = false">取消</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ title="提示"
|
|
|
+ :visible.sync="visibleDelete"
|
|
|
+ width="200px">
|
|
|
+ <p class="center-text">确认删除?</p>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="visibleDelete = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="deleteUser">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ class="dialog-style"
|
|
|
+ title="修改密码"
|
|
|
+ :visible.sync="visibleChange"
|
|
|
+ width="500px">
|
|
|
+ <div>
|
|
|
+ <label>旧密码:</label>
|
|
|
+ <el-input placeholder="请输入旧密码" v-model="changeUser.oldPass" show-password required="required"></el-input>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label>新密码:</label>
|
|
|
+ <el-input placeholder="请输入新密码" v-model="changeUser.newPass" show-password required="required"></el-input>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="visibleChange = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="updateUser">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+</div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getUserList,addUser,updateUser,deleteUser } from '@/api/user';
|
|
|
+import { GRADE_OPTION, GRADE_MAP } from '@/services/constant';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'IssueList',
|
|
|
+ components: {
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ userList:[],
|
|
|
+ user:{},
|
|
|
+ changeUser:{},
|
|
|
+ search:{
|
|
|
+ name:'',
|
|
|
+ grade:'',
|
|
|
+ },
|
|
|
+ deleteId: -1,
|
|
|
+ gradeOptions: GRADE_OPTION,
|
|
|
+ gradeMap: GRADE_MAP,
|
|
|
+
|
|
|
+ visibleAdd:false,
|
|
|
+ visibleDelete:false,
|
|
|
+ visibleChange:false,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.searchUser();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ searchUser(){
|
|
|
+ getUserList(this.search.grade,this.search.name).then((result) => {
|
|
|
+ this.userList = result;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addUser(){
|
|
|
+ addUser(this.user).then((result) => {
|
|
|
+ alert(result.message);
|
|
|
+ this.visibleAdd = false
|
|
|
+ this.searchUser();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ updateUser(){
|
|
|
+ updateUser(this.changeUser).then((result) => {
|
|
|
+ alert(result.message);
|
|
|
+ this.visibleChange = false
|
|
|
+ this.searchUser();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ deleteUser(){
|
|
|
+ deleteUser(this.deleteId).then((result) => {
|
|
|
+ alert(result?'删除成功':'删除失败');
|
|
|
+ this.visibleDelete = false
|
|
|
+ this.searchUser();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|