|
@@ -1,12 +1,13 @@
|
|
|
<!DOCTYPE html>
|
|
|
<html>
|
|
|
<head>
|
|
|
- <title>管理员列表</title>
|
|
|
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
|
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
|
|
+ <title>管理员列表</title>
|
|
|
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
|
+ <meta name="viewport"
|
|
|
+ content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
|
|
<!-- 所有的 css & js 资源 -->
|
|
|
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
|
|
|
- <link rel="stylesheet" href="../../static/sa.css">
|
|
|
+ <link rel="stylesheet" href="../../static/sa.css">
|
|
|
<script src="https://unpkg.com/vue@2.6.10/dist/vue.min.js"></script>
|
|
|
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
|
|
|
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
|
|
@@ -15,7 +16,9 @@
|
|
|
<script src="../../static/sa.js"></script>
|
|
|
<script src="../../static/kj/upload-util.js"></script>
|
|
|
<style type="text/css">
|
|
|
- .el-radio{margin-right: 10px;}
|
|
|
+ .el-radio {
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
@@ -28,7 +31,8 @@
|
|
|
<sa-item name="角色">
|
|
|
<el-select v-model="p.roleId">
|
|
|
<el-option label="全部" value=""></el-option>
|
|
|
- <el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id"></el-option>
|
|
|
+ <el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id">
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
|
</sa-item>
|
|
|
<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
|
|
@@ -43,8 +47,9 @@
|
|
|
</el-form>
|
|
|
<!-- ------------- 快捷按钮 ------------- -->
|
|
|
<div class="fast-btn">
|
|
|
- <el-button type="primary" icon="el-icon-plus" @click="add" v-if="sa.isAuth('sp-admin-add')">新增</el-button>
|
|
|
- <el-button type="info" icon="el-icon-refresh" @click="f5">重置</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" @click="add" v-if="sa.isAuth('sp-admin-add')">新增
|
|
|
+ </el-button>
|
|
|
+ <el-button type="info" icon="el-icon-refresh" @click="f5">重置</el-button>
|
|
|
</div>
|
|
|
<!-- ------------- 数据列表 ------------- -->
|
|
|
<el-table class="data-table" ref="data-table" :data="dataList">
|
|
@@ -56,12 +61,13 @@
|
|
|
<span v-else>{{s.row.name}}</span>
|
|
|
</template>
|
|
|
</sa-td>
|
|
|
- <sa-td type="text" name="部门" prop="deptName" not='系统管理'></sa-td>
|
|
|
+ <sa-td type="text" name="所属组织" prop="deptName" not='系统管理'></sa-td>
|
|
|
<sa-td type="text" name="所属角色" prop="roleName"></sa-td>
|
|
|
<sa-td type="datetime" name="创建日期" prop="createTime" width="150px"></sa-td>
|
|
|
<sa-td type="datetime" name="最后登录" prop="loginTime" width="150px"></sa-td>
|
|
|
<sa-td type="text" name="登录次数" prop="loginCount" not="0" width="100px"></sa-td>
|
|
|
- <sa-td type="switch" name="账号状态" prop="status" :jv="{1: '正常', 2: '禁用[#ff4949]'}" @change="s => updateStatus(s.row)" width="120px"></sa-td>
|
|
|
+ <sa-td type="switch" name="账号状态" prop="status" :jv="{1: '正常', 2: '禁用[#ff4949]'}"
|
|
|
+ @change="s => updateStatus(s.row)" width="120px"></sa-td>
|
|
|
<el-table-column label="操作" fixed="right" width="330px">
|
|
|
<template slot-scope="s">
|
|
|
<span @click="getInfo(s.row)">
|
|
@@ -72,13 +78,16 @@
|
|
|
修改资料 <i class="el-icon-arrow-down el-icon--right"></i>
|
|
|
</el-button>
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
+ <span @click="updateDept(s.row)" v-if="s.row.deptId!=9999999">
|
|
|
+ <el-dropdown-item>修改组织</el-dropdown-item>
|
|
|
+ </span>
|
|
|
<span @click="updateName(s.row)">
|
|
|
<el-dropdown-item>改手机号</el-dropdown-item>
|
|
|
</span>
|
|
|
<span @click="updateNickName(s.row)">
|
|
|
<el-dropdown-item>改姓名</el-dropdown-item>
|
|
|
</span>
|
|
|
-
|
|
|
+
|
|
|
<span @click="updatePassword(s.row)">
|
|
|
<el-dropdown-item>改密码</el-dropdown-item>
|
|
|
</span>
|
|
@@ -89,23 +98,39 @@
|
|
|
修改角色为 <i class="el-icon-arrow-down el-icon--right"></i>
|
|
|
</el-button>
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
- <span v-for="role in roleList" :key="role.id" @click="updateRoleId(s.row, role.id, role.name)">
|
|
|
- <el-dropdown-item :style=" s.row.roleId == role.id ? {color: 'blue'} : null ">{{role.name}}</el-dropdown-item>
|
|
|
+ <span v-for="role in roleList" :key="role.id"
|
|
|
+ @click="updateRoleId(s.row, role.id, role.name)">
|
|
|
+ <el-dropdown-item :style=" s.row.roleId == role.id ? {color: 'blue'} : null ">
|
|
|
+ {{role.name}}</el-dropdown-item>
|
|
|
</span>
|
|
|
</el-dropdown-menu>
|
|
|
</el-dropdown>
|
|
|
<span @click="del(s.row)">
|
|
|
- <el-button v-if="sa.isAuth('sp-admin-del')" type="danger" class="c-btn" icon="el-icon-delete">删除</el-button>
|
|
|
+ <el-button v-if="sa.isAuth('sp-admin-del')" type="danger" class="c-btn"
|
|
|
+ icon="el-icon-delete">删除</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<!-- 分页 -->
|
|
|
- <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
|
|
|
+ <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
|
|
|
+ </sa-item>
|
|
|
</div>
|
|
|
-
|
|
|
+ <el-dialog title="修改组织" :modal="false" :visible.sync="modal.visible" width="400px">
|
|
|
+ <div class="c-item">
|
|
|
+ <label class="c-label"><span style="color: red;">*</span>组织:</label>
|
|
|
+ <el-select v-model="modal.deptId" multiple>
|
|
|
+ <el-option label="请选择" v-for="(item,index) in deptList" :key="item.id" :label="item.name"
|
|
|
+ :value="item.id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="modal.visible=false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="sureFn">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
- <script>
|
|
|
+ <script>
|
|
|
var app = new Vue({
|
|
|
components: {
|
|
|
"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
|
|
@@ -113,8 +138,8 @@
|
|
|
},
|
|
|
el: '.vue-box',
|
|
|
data: {
|
|
|
- sa: sa, // 超级对象
|
|
|
- p: { // 查询参数
|
|
|
+ sa: sa, // 超级对象
|
|
|
+ p: { // 查询参数
|
|
|
id: '',
|
|
|
name: '',
|
|
|
roleId: '',
|
|
@@ -122,22 +147,62 @@
|
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
|
},
|
|
|
+ deptList:[],
|
|
|
+ modal: {
|
|
|
+ visible:false,
|
|
|
+ deptId:[],
|
|
|
+ form: {
|
|
|
+ id: '',
|
|
|
+ deptId: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
dataCount: 0,
|
|
|
- dataList: [], // 数据集合
|
|
|
- roleList: [], // 角色集合
|
|
|
+ dataList: [], // 数据集合
|
|
|
+ roleList: [], // 角色集合
|
|
|
},
|
|
|
methods: {
|
|
|
+ updateDept(data) {
|
|
|
+ Object.assign(this.modal,{
|
|
|
+ visible:true,
|
|
|
+ deptId:data.deptId.split(',').map(id=>parseInt(id)),
|
|
|
+ form:{
|
|
|
+ id:data.id,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ sureFn(){
|
|
|
+ let data=this.modal.form;
|
|
|
+ let deptId=this.modal.deptId.join(',')
|
|
|
+ if(!deptId){
|
|
|
+ sa.error('请选择组织');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ data.deptId=deptId;
|
|
|
+ sa.ajax('/admin/updateDept', data, function(res) {
|
|
|
+ this.modal.visible=false;
|
|
|
+ this.f5();
|
|
|
+ }.bind(this));
|
|
|
+ },
|
|
|
+ getDeptList() {
|
|
|
+ sa.ajax('/TbDept/getList', {
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 100
|
|
|
+ }, function(resp) {
|
|
|
+ let list = resp.data;
|
|
|
+ this.deptList = list;
|
|
|
+ }.bind(this))
|
|
|
+ },
|
|
|
// 刷新
|
|
|
- f5: function(isPage){
|
|
|
- sa.ajax('/admin/getList', this.p, function(res){
|
|
|
- this.dataList = res.data; // 数据
|
|
|
+ f5: function(isPage) {
|
|
|
+ sa.ajax('/admin/getList', this.p, function(res) {
|
|
|
+ this.dataList = res.data; // 数据
|
|
|
this.dataCount = res.dataCount;
|
|
|
- sa.f5TableHeight(); // 刷新表格高度
|
|
|
+ sa.f5TableHeight(); // 刷新表格高度
|
|
|
}.bind(this));
|
|
|
},
|
|
|
// 新增
|
|
|
add: function() {
|
|
|
- sa.showIframe('添加用户','admin-add.html','600px','80%');
|
|
|
+ sa.showIframe('添加用户', 'admin-add.html', '600px', '80%');
|
|
|
},
|
|
|
// 查看详情
|
|
|
getInfo: function(data) {
|
|
@@ -146,20 +211,26 @@
|
|
|
},
|
|
|
// 查看登录日志
|
|
|
getAdminLogin: function(data) {
|
|
|
- sa.showIframe('登录日志', '../sp-admin-login/sp-admin-login-list.html?accId=' + data.id, '90%', '90%');
|
|
|
+ sa.showIframe('登录日志', '../sp-admin-login/sp-admin-login-list.html?accId=' + data.id, '90%',
|
|
|
+ '90%');
|
|
|
},
|
|
|
// 查看 - 根据选中的
|
|
|
getBySelect: function(data) {
|
|
|
var selection = this.$refs['data-table'].selection;
|
|
|
- if(selection.length == 0) {
|
|
|
+ if (selection.length == 0) {
|
|
|
return sa.msg('请选择一条数据')
|
|
|
}
|
|
|
this.getInfo(selection[0]);
|
|
|
},
|
|
|
updateNickName: function(data) {
|
|
|
- layer.prompt({title: '修改姓名'}, function(pass, index){
|
|
|
+ layer.prompt({
|
|
|
+ title: '修改姓名'
|
|
|
+ }, function(pass, index) {
|
|
|
layer.close(index);
|
|
|
- sa.ajax('/admin/updateNickName', {id: data.id, nickname: pass}, function(res){
|
|
|
+ sa.ajax('/admin/updateNickName', {
|
|
|
+ id: data.id,
|
|
|
+ nickname: pass
|
|
|
+ }, function(res) {
|
|
|
data.nickname = pass;
|
|
|
layer.msg('修改成功');
|
|
|
})
|
|
@@ -167,9 +238,14 @@
|
|
|
},
|
|
|
// 修改名称
|
|
|
updateName: function(data) {
|
|
|
- layer.prompt({title: '请输入新的手机号'}, function(pass, index){
|
|
|
+ layer.prompt({
|
|
|
+ title: '请输入新的手机号'
|
|
|
+ }, function(pass, index) {
|
|
|
layer.close(index);
|
|
|
- sa.ajax('/admin/update', {id: data.id, name: pass}, function(res){
|
|
|
+ sa.ajax('/admin/update', {
|
|
|
+ id: data.id,
|
|
|
+ name: pass
|
|
|
+ }, function(res) {
|
|
|
data.name = pass;
|
|
|
layer.msg('修改成功');
|
|
|
})
|
|
@@ -178,36 +254,49 @@
|
|
|
// 修改头像
|
|
|
updateAvatar: function(data) {
|
|
|
sa.uploadImage(function(src) {
|
|
|
- var p = {id: data.id, avatar: src};
|
|
|
+ var p = {
|
|
|
+ id: data.id,
|
|
|
+ avatar: src
|
|
|
+ };
|
|
|
sa.ajax('/admin/updateAvatar', p, function(res) {
|
|
|
sa.msg('上传成功');
|
|
|
- data.avatar = src;
|
|
|
+ data.avatar = src;
|
|
|
}.bind(this));
|
|
|
})
|
|
|
},
|
|
|
// 修改密码
|
|
|
updatePassword: function(data) {
|
|
|
- layer.prompt({title: '修改密码'}, function(pass, index){
|
|
|
+ layer.prompt({
|
|
|
+ title: '修改密码'
|
|
|
+ }, function(pass, index) {
|
|
|
layer.close(index);
|
|
|
- if(pass.length < 4) {
|
|
|
+ if (pass.length < 4) {
|
|
|
return layer.msg('新密码长度请不要低于4位');
|
|
|
}
|
|
|
- sa.ajax('/admin/updatePassword', {id: data.id, password: pass}, function(res){
|
|
|
+ sa.ajax('/admin/updatePassword', {
|
|
|
+ id: data.id,
|
|
|
+ password: pass
|
|
|
+ }, function(res) {
|
|
|
layer.msg('修改成功');
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
// 修改角色
|
|
|
updateRoleId: function(data, roleId, roleName) {
|
|
|
- if(data.id == sa.$sys.getCurrUser().id) {
|
|
|
- return sa.alert('不能自己修改自己的角色');
|
|
|
+ if (data.id == sa.$sys.getCurrUser().id) {
|
|
|
+ return sa.alert('不能自己修改自己的角色');
|
|
|
}
|
|
|
- if(data.roleId == roleId) {
|
|
|
- return sa.alert('该用户已经是' + roleName + '了');
|
|
|
+ if (data.roleId == roleId) {
|
|
|
+ return sa.alert('该用户已经是' + roleName + '了');
|
|
|
}
|
|
|
var str = '将此账号修改为 [' + roleName + '], 请确认?';
|
|
|
- layer.confirm(str, {title: '请确认'}, function() {
|
|
|
- sa.ajax('/admin/updateRole', {id: data.id, roleId: roleId}, function(res) {
|
|
|
+ layer.confirm(str, {
|
|
|
+ title: '请确认'
|
|
|
+ }, function() {
|
|
|
+ sa.ajax('/admin/updateRole', {
|
|
|
+ id: data.id,
|
|
|
+ roleId: roleId
|
|
|
+ }, function(res) {
|
|
|
sa.msg('修改成功');
|
|
|
data.roleId = roleId;
|
|
|
data.roleName = roleName;
|
|
@@ -216,19 +305,22 @@
|
|
|
},
|
|
|
// 修改用户的状态
|
|
|
updateStatus: function(data) {
|
|
|
- if(data.id == sa.$sys.getCurrUser().id) {
|
|
|
- data.status = 3 - data.status;
|
|
|
- return sa.alert('不能自己封禁自己');
|
|
|
+ if (data.id == sa.$sys.getCurrUser().id) {
|
|
|
+ data.status = 3 - data.status;
|
|
|
+ return sa.alert('不能自己封禁自己');
|
|
|
}
|
|
|
- var is_ok = false; // 记录是否成功
|
|
|
- var ajax = sa.ajax('/admin/updateStatus', {id: data.id, status: data.status}, function(res) {
|
|
|
+ var is_ok = false; // 记录是否成功
|
|
|
+ var ajax = sa.ajax('/admin/updateStatus', {
|
|
|
+ id: data.id,
|
|
|
+ status: data.status
|
|
|
+ }, function(res) {
|
|
|
sa.msg('修改成功');
|
|
|
is_ok = true;
|
|
|
}.bind(this));
|
|
|
// 如果未能修改成功, 则回滚
|
|
|
$.when(ajax).done(function() {
|
|
|
- if(is_ok == false) {
|
|
|
- data.status = 3 - data.status;
|
|
|
+ if (is_ok == false) {
|
|
|
+ data.status = 3 - data.status;
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -246,12 +338,14 @@
|
|
|
}.bind(this));
|
|
|
},
|
|
|
// 删除
|
|
|
- del: function (data) {
|
|
|
- sa.confirm('是否删除,此操作不可撤销', function(){
|
|
|
- sa.ajax('/admin/delete', {id: data.id},function(res){
|
|
|
+ del: function(data) {
|
|
|
+ sa.confirm('是否删除,此操作不可撤销', function() {
|
|
|
+ sa.ajax('/admin/delete', {
|
|
|
+ id: data.id
|
|
|
+ }, function(res) {
|
|
|
sa.arrayDelete(app.dataList, data);
|
|
|
sa.ok('删除成功');
|
|
|
- sa.f5TableHeight(); // 刷新表格高度
|
|
|
+ sa.f5TableHeight(); // 刷新表格高度
|
|
|
})
|
|
|
});
|
|
|
},
|
|
@@ -260,29 +354,33 @@
|
|
|
// 获取选中元素的id列表
|
|
|
let selection = this.$refs['data-table'].selection;
|
|
|
let ids = sa.getArrayField(selection, 'id');
|
|
|
- if(selection.length == 0) {
|
|
|
+ if (selection.length == 0) {
|
|
|
return sa.msg('请至少选择一条数据')
|
|
|
}
|
|
|
// 提交删除
|
|
|
sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
|
|
|
- sa.ajax('/admin/deleteByIds', {ids: ids.join(',')}, function(res) {
|
|
|
+ sa.ajax('/admin/deleteByIds', {
|
|
|
+ ids: ids.join(',')
|
|
|
+ }, function(res) {
|
|
|
sa.arrayDelete(this.dataList, selection);
|
|
|
sa.ok('删除成功');
|
|
|
- sa.f5TableHeight(); // 刷新表格高度
|
|
|
+ sa.f5TableHeight(); // 刷新表格高度
|
|
|
}.bind(this))
|
|
|
}.bind(this));
|
|
|
},
|
|
|
},
|
|
|
- created: function(){
|
|
|
+ created: function() {
|
|
|
this.f5();
|
|
|
- sa.onInputEnter(); // 监听回车执行查询
|
|
|
+ this.getDeptList();
|
|
|
+ sa.onInputEnter(); // 监听回车执行查询
|
|
|
// 加载角色
|
|
|
- sa.ajax('/role/getList', function(res){
|
|
|
- this.roleList = res.data; // 数据
|
|
|
- }.bind(this), {msg: null});
|
|
|
+ sa.ajax('/role/getList', function(res) {
|
|
|
+ this.roleList = res.data; // 数据
|
|
|
+ }.bind(this), {
|
|
|
+ msg: null
|
|
|
+ });
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|