用户角色等修复

dev_2022-04-07
yujialong 3 years ago
parent 80f209bb1a
commit 5c405f5fec
  1. 6
      src/pages/account/login/index.vue
  2. 11
      src/pages/role/list/index.vue
  3. 4
      src/pages/stat/list/index.vue
  4. 197
      src/pages/user/list/index.vue
  5. 2
      src/plugins/requests/index.js

@ -239,8 +239,12 @@ export default {
right: 0; right: 0;
} }
.login{ .login{
z-index: 4;
position: absolute;
top: 48%;
left: 50%;
transform: translate(-50%, -50%);
width: 436px; width: 436px;
margin: 188px auto 150px;
.form{ .form{
padding: 38px 38px 60px; padding: 38px 38px 60px;
border-radius: 6px; border-radius: 6px;

@ -95,7 +95,8 @@ export default {
roleVisible: false, roleVisible: false,
searchTimer: null, searchTimer: null,
permissions: [], permissions: [],
checkedIds: [] checkedIds: [],
submiting: false
}; };
}, },
computed: { computed: {
@ -196,10 +197,11 @@ export default {
this.roleVisible = true this.roleVisible = true
}, },
confirm() { confirm() {
if (this.submiting) return false
if(!this.form.roleName) return util.warningMsg('请填写角色名称') if(!this.form.roleName) return util.warningMsg('请填写角色名称')
if(!this.form.remark) return util.warningMsg('请填写角色描述') if(!this.form.remark) return util.warningMsg('请填写角色描述')
// if(!this.$refs.per.getCheckedKeys().length) return util.warningMsg('') // if(!this.$refs.per.getCheckedKeys().length) return util.warningMsg('')
this.submiting = true
let data = { let data = {
id: this.form.id, id: this.form.id,
roleName: this.form.roleName, roleName: this.form.roleName,
@ -211,7 +213,10 @@ export default {
util.successMsg(this.form.id ? '修改成功' : '新增成功') util.successMsg(this.form.id ? '修改成功' : '新增成功')
this.getData() this.getData()
this.roleVisible = false this.roleVisible = false
}).catch(res => {}) this.submiting = false
}).catch(res => {
this.submiting = false
})
}, },
handleDelete(row) { handleDelete(row) {
// ,, // ,,

@ -409,6 +409,10 @@ export default {
exportDatabase(){ exportDatabase(){
let data = this.listDataAll let data = this.listDataAll
if(this.multipleSelection.length) data = this.multipleSelection if(this.multipleSelection.length) data = this.multipleSelection
const date = (this.date && this.date.length) ? this.date.join(' - ') : ''
data.map(e => {
e.time = date
})
axios.post(this.api.databaseInfoExport,data,{ axios.post(this.api.databaseInfoExport,data,{
headers: { headers: {
token: this.token token: this.token

@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<div class="page"> <div class="page" style="margin-bottom: 20px">
<h6 class="l-title">用户列表</h6> <h6 class="l-title">筛选</h6>
<div class="page-content"> <div class="page-content">
<div class="tool"> <div class="tool" style="margin-bottom: 0">
<ul class="filter"> <ul class="filter">
<li> <li>
<label>创建时间</label> <label>创建时间</label>
@ -33,8 +33,11 @@
</ul> </ul>
<div></div> <div></div>
</div> </div>
</div>
<div class="tool"> </div>
<div class="page">
<div class="page-content">
<div class="tool" style="margin-bottom: 20px">
<ul class="filter"> <ul class="filter">
<li style="margin-bottom: 0"> <li style="margin-bottom: 0">
<label>搜索</label> <label>搜索</label>
@ -47,93 +50,93 @@
<el-button type="primary" size="small" round @click="delAllSelection" v-auth>批量删除</el-button> <el-button type="primary" size="small" round @click="delAllSelection" v-auth>批量删除</el-button>
</div> </div>
</div> </div>
</div>
<el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> <el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="80" align="center"></el-table-column> <el-table-column type="selection" width="80" align="center"></el-table-column>
<el-table-column type="index" label="序号" width="55" align="center"> <el-table-column type="index" label="序号" width="55" align="center">
</el-table-column> </el-table-column>
<el-table-column prop="account" label="账号" align="center"></el-table-column> <el-table-column prop="account" label="账号" align="center"></el-table-column>
<el-table-column prop="userName" label="姓名" align="center"></el-table-column> <el-table-column prop="userName" label="姓名" align="center"></el-table-column>
<el-table-column prop="workNumber" label="工号/学号" align="center"></el-table-column> <el-table-column prop="workNumber" label="工号/学号" align="center"></el-table-column>
<el-table-column label="权限状态" align="center"> <el-table-column label="权限状态" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.isEnable ? '启用' : '禁用'}} {{scope.row.isEnable ? '启用' : '禁用'}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="roleName" label="账号角色" align="center"></el-table-column> <el-table-column prop="roleName" label="账号角色" align="center"></el-table-column>
<el-table-column prop="loginNumber" label="登录次数" align="center"> <el-table-column prop="loginNumber" label="登录次数" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.loginNumber ? scope.row.loginNumber : 0}} {{scope.row.loginNumber ? scope.row.loginNumber : 0}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="lastLoginTime" label="上次登录时间" width="160" align="center"></el-table-column> <el-table-column prop="lastLoginTime" label="上次登录时间" width="160" align="center"></el-table-column>
<el-table-column width="300" label="操作" align="center"> <el-table-column width="300" label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="show(scope.row)" v-auth>查看</el-button> <el-button type="text" @click="show(scope.row)" v-auth>查看</el-button>
<el-button type="text" @click="edit(scope.row)" v-auth>编辑</el-button> <el-button type="text" @click="edit(scope.row)" v-auth>编辑</el-button>
<el-button type="text" @click="resetPassword(scope.row)" v-auth>重置密码</el-button> <el-button type="text" @click="resetPassword(scope.row)" v-auth>重置密码</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth>删除</el-button> <el-button type="text" @click="handleDelete(scope.row)" v-auth>删除</el-button>
<el-switch v-model="scope.row.isEnable" :active-value="1" :inactive-value="0" style="margin: 0 10px 0 5px" :active-text="scope.row.isEnable ? '开' : '关'" @change="switchOff($event,scope.row,scope.$index)" v-auth="'/user/list:禁用'"></el-switch> <el-switch v-model="scope.row.isEnable" :active-value="1" :inactive-value="0" style="margin: 0 10px 0 5px" :active-text="scope.row.isEnable ? '开' : '关'" @change="switchOff($event,scope.row,scope.$index)" v-auth="'/user/list:禁用'"></el-switch>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="pagination"> <div class="pagination">
<el-pagination background layout="total,prev, pager, next" :current-page="page" @current-change="handleCurrentChange" :total="total"></el-pagination> <el-pagination background layout="total,prev, pager, next" :current-page="page" @current-change="handleCurrentChange" :total="total"></el-pagination>
</div> </div>
</div>
<el-dialog :title="isDetail ? '查看账号' : (form.userId ? '编辑账号' : '新增账号')" :visible.sync="userVisible" width="576px" @close="closeUser" class="dialog" :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="110px" label-suffix="" :disabled="isDetail">
<el-form-item prop="account" label="账号">
<el-input v-model="form.account" ref="account" placeholder="请输入账号" @change="accountChange"></el-input>
</el-form-item>
<el-form-item prop="userName" label="用户姓名">
<el-input v-model="form.userName" placeholder="请输入姓名"></el-input>
</el-form-item>
<el-form-item prop="roleIds" label="账号角色">
<div class="role-wrap">
<el-checkbox-group v-model="form.roleIds">
<template v-for="(item,index) in roleList">
<el-checkbox v-if="item.roleName != '超级管理员'" :key="index" :label="item.id" :title="item.roleName">{{item.roleName}}</el-checkbox>
</template>
</el-checkbox-group>
</div>
</el-form-item>
<el-form-item prop="uniqueIdentification" label="唯一标识">
<el-input disabled v-model="form.uniqueIdentification" placeholder="唯一标识"></el-input>
</el-form-item>
<el-form-item prop="email" label="邮箱">
<el-input v-model="form.email" placeholder="请输入邮箱" @change="emailChange"></el-input>
</el-form-item>
<el-form-item prop="workNumber" label="工号/学号">
<el-input v-model="form.workNumber" placeholder="请输入工号/学号" @change="workNumberChange"></el-input>
</el-form-item>
<el-form-item prop="phone" label="手机号">
<el-input v-model="form.phone" maxlength="11" @change="phoneChange"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail">
<el-button size="small" @click="userVisible = false"> </el-button>
<el-button size="small" type="primary" @click="confirm"> </el-button>
</span>
</el-dialog>
<el-dialog title="批量导入" :visible.sync="importVisible" width="400px" @close="closeImport" :close-on-click-modal="false"> <el-dialog :title="isDetail ? '查看账号' : (form.userId ? '编辑账号' : '新增账号')" :visible.sync="userVisible" width="576px" @close="closeUser" class="dialog" :close-on-click-modal="false">
<div class="upload-wrap" :class="{lg: uploadFaild}"> <el-form ref="form" :model="form" :rules="rules" label-width="110px" label-suffix="" :disabled="isDetail">
<el-button class="download" size="small" @click="downLoad"><img src="../../../assets/img/download.png" alt=""> 模板下载</el-button> <el-form-item prop="account" label="账号">
<el-upload ref="import" accept=".xls,.xlsx" :headers="{token}" :on-remove="handleRemove" :on-error="uploadError" :on-success="uploadSuccess" :before-remove="beforeRemove" :limit="1" :on-exceed="handleExceed" :action="this.api.uploadFile" :file-list="uploadList" :data="{schoolId: this.schoolId}" name="file" :auto-upload="false"> <el-input v-model="form.account" ref="account" placeholder="请输入账号" @change="accountChange"></el-input>
<el-button size="small"><img src="../../../assets/img/upload.png" alt=""> 上传文件</el-button> </el-form-item>
</el-upload> <el-form-item prop="userName" label="用户姓名">
<div class="link" v-if="uploadFaild"> <el-input v-model="form.userName" placeholder="请输入姓名"></el-input>
<el-link type="primary" @click="showFaild">导入失败查看原因</el-link> </el-form-item>
</div> <el-form-item prop="roleIds" label="账号角色">
<div class="role-wrap">
<el-checkbox-group v-model="form.roleIds">
<template v-for="(item,index) in roleList">
<el-checkbox v-if="item.roleName != '超级管理员'" :key="index" :label="item.id" :title="item.roleName">{{item.roleName}}</el-checkbox>
</template>
</el-checkbox-group>
</div> </div>
<span slot="footer" class="dialog-footer"> </el-form-item>
<el-button size="small" @click="importVisible = false"> </el-button> <el-form-item prop="uniqueIdentification" label="唯一标识">
<el-button size="small" type="primary" @click="confirmImport"> </el-button> <el-input disabled v-model="form.uniqueIdentification" placeholder="唯一标识"></el-input>
</span> </el-form-item>
</el-dialog> <el-form-item prop="email" label="邮箱">
<el-input v-model="form.email" placeholder="请输入邮箱" @change="emailChange"></el-input>
</el-form-item>
<el-form-item prop="workNumber" label="工号/学号">
<el-input v-model="form.workNumber" placeholder="请输入工号/学号" @change="workNumberChange"></el-input>
</el-form-item>
<el-form-item prop="phone" label="手机号">
<el-input v-model="form.phone" maxlength="11" @change="phoneChange"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail">
<el-button size="small" @click="userVisible = false"> </el-button>
<el-button size="small" type="primary" @click="confirm"> </el-button>
</span>
</el-dialog>
<el-dialog title="批量导入" :visible.sync="importVisible" width="400px" @close="closeImport" :close-on-click-modal="false">
<div class="upload-wrap" :class="{lg: uploadFaild}">
<el-button class="download" size="small" @click="downLoad"><img src="../../../assets/img/download.png" alt=""> 模板下载</el-button>
<el-upload ref="import" accept=".xls,.xlsx" :headers="{token}" :on-remove="handleRemove" :on-error="uploadError" :on-success="uploadSuccess" :before-remove="beforeRemove" :limit="1" :on-exceed="handleExceed" :action="this.api.uploadFile" :file-list="uploadList" :data="{schoolId: this.schoolId}" name="file" :auto-upload="false">
<el-button size="small"><img src="../../../assets/img/upload.png" alt=""> 上传文件</el-button>
</el-upload>
<div class="link" v-if="uploadFaild">
<el-link type="primary" @click="showFaild">导入失败查看原因</el-link>
</div>
</div> </div>
</div> <span slot="footer" class="dialog-footer">
<el-button size="small" @click="importVisible = false"> </el-button>
<el-button size="small" type="primary" @click="confirmImport"> </el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
@ -250,7 +253,8 @@ export default {
originalAccount: '', originalAccount: '',
originalWorkNumber: '', originalWorkNumber: '',
originalPhone: '', originalPhone: '',
originalEmail: '' originalEmail: '',
submiting: false
}; };
}, },
computed: { computed: {
@ -431,10 +435,12 @@ export default {
confirm(){ confirm(){
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
if (this.submiting) return false
if(this.accountRepeat) return util.errorMsg('该账号已存在!') if(this.accountRepeat) return util.errorMsg('该账号已存在!')
if(this.workNumberRepeat) return util.errorMsg('该学号/工号已存在!') if(this.workNumberRepeat) return util.errorMsg('该学号/工号已存在!')
if(this.phoneRepeat) return util.errorMsg('该手机号已存在!') if(this.phoneRepeat) return util.errorMsg('该手机号已存在!')
if(this.emailRepeat) return util.errorMsg('该邮箱已存在!') if(this.emailRepeat) return util.errorMsg('该邮箱已存在!')
this.submiting = true
let data = this.form let data = this.form
// ,schoolId // ,schoolId
data.schoolId = data.schoolId ? data.schoolId : this.schoolId data.schoolId = data.schoolId ? data.schoolId : this.schoolId
@ -447,13 +453,19 @@ export default {
this.userVisible = false this.userVisible = false
util.successMsg('编辑成功') util.successMsg('编辑成功')
this.getData() this.getData()
}).catch(res => {}) this.submiting = false
}).catch(res => {
this.submiting = false
})
}else{ }else{
this.$post(this.api.saveUser,data).then(res => { this.$post(this.api.saveUser,data).then(res => {
this.userVisible = false this.userVisible = false
util.successMsg('添加成功') util.successMsg('添加成功')
this.getData() this.getData()
}).catch(res => {}) this.submiting = false
}).catch(res => {
this.submiting = false
})
} }
} }
}) })
@ -584,9 +596,6 @@ export default {
.l-title{ .l-title{
margin-bottom: 24px; margin-bottom: 24px;
} }
.page .page-content .tool{
margin-bottom: 30px;
}
.filter{ .filter{
flex-wrap: wrap; flex-wrap: wrap;
li{ li{

@ -28,7 +28,7 @@ function checkDisabled () {
}).then(res => { }).then(res => {
console.log(11, res.data) console.log(11, res.data)
if (res.data) { if (res.data) {
util.errorMsg('当前账号无权限,请重新登录!') util.errorMsg('账号被禁用,已强制退出,有疑问请联系管理员')
setTimeout(() => { setTimeout(() => {
store.dispatch('user/logout') store.dispatch('user/logout')
}, 1500) }, 1500)

Loading…
Cancel
Save