|
@@ -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="../../static/kj/element-ui/theme-chalk/index.css">
|
|
|
- <link rel="stylesheet" href="../../static/sa.css">
|
|
|
+ <link rel="stylesheet" href="../../static/sa.css">
|
|
|
<script src="../../static/kj/vue.min.js"></script>
|
|
|
<script src="../../static/kj/element-ui/index.js"></script>
|
|
|
<script src="../../static/kj/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>
|
|
@@ -30,7 +33,12 @@
|
|
|
|
|
|
</el-form>
|
|
|
<!-- ------------- 快捷按钮 ------------- -->
|
|
|
- <sa-item type="fast-btn" show="add,delete,reset"></sa-item>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" @click="add()" v-if="sa.isAuth('tb-costomer-maintain-user-add')">新增
|
|
|
+ </el-button>
|
|
|
+ <el-button type="danger" icon="el-icon-delete" @click="deleteByIds()"
|
|
|
+ v-if="sa.isAuth('tb-costomer-maintain-user-del')">删除
|
|
|
+ </el-button>
|
|
|
+ <el-button type="info" icon="el-icon-refresh" @click="sa.f5()">重置</el-button>
|
|
|
<!-- ------------- 数据列表 ------------- -->
|
|
|
<el-table class="data-table" ref="data-table" :data="dataList">
|
|
|
<sa-td type="selection"></sa-td>
|
|
@@ -38,51 +46,51 @@
|
|
|
<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="450px">
|
|
|
<template slot-scope="s">
|
|
|
<span @click="getInfo(s.row)">
|
|
|
<el-button type="success" class="c-btn" icon="el-icon-view">查看</el-button>
|
|
|
</span>
|
|
|
- <span @click="updateName(s.row)">
|
|
|
+ <span @click="updateName(s.row)" v-if="sa.isAuth('tb-costomer-maintain-user-edit')">
|
|
|
<el-button type="primary" class="c-btn" icon="el-icon-edit">改名称</el-button>
|
|
|
</span>
|
|
|
- <span @click="updateAvatar(s.row)">
|
|
|
+ <span @click="updateAvatar(s.row)" v-if="sa.isAuth('tb-costomer-maintain-user-edit')">
|
|
|
<el-button type="primary" class="c-btn" icon="el-icon-edit">改头像</el-button>
|
|
|
</span>
|
|
|
- <span @click="updatePassword(s.row)">
|
|
|
+ <span @click="updatePassword(s.row)" v-if="sa.isAuth('tb-costomer-maintain-user-edit')">
|
|
|
<el-button type="primary" class="c-btn" icon="el-icon-edit">改密码</el-button>
|
|
|
</span>
|
|
|
- <span @click="roleFn(s.row)">
|
|
|
+ <span @click="roleFn(s.row)" v-if="sa.isAuth('tb-costomer-maintain-user-edit')">
|
|
|
<el-button type="primary" class="c-btn" icon="el-icon-edit">角色</el-button>
|
|
|
</span>
|
|
|
- <span @click="del(s.row)">
|
|
|
+ <span @click="del(s.row)" v-if="sa.isAuth('tb-costomer-maintain-user-del')">
|
|
|
<el-button 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="roleDialog.title"
|
|
|
- :visible.sync="roleDialog.visible"
|
|
|
- width="60%">
|
|
|
- <div >
|
|
|
- <el-checkbox @change="handleCheckAllChange">全选</el-checkbox>
|
|
|
- <div style="margin: 15px 0;"></div>
|
|
|
- <el-checkbox-group v-model="roleDialog.form.roleId">
|
|
|
- <el-checkbox v-for="role in roleList" :label="role.id+''" :key="role.id">{{role.name}}</el-checkbox>
|
|
|
- </el-checkbox-group>
|
|
|
- </div>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="roleDialog.visible = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="confirmSetRole">确 定</el-button>
|
|
|
- </span>
|
|
|
+ <el-dialog :title="roleDialog.title" :visible.sync="roleDialog.visible" width="60%">
|
|
|
+ <div>
|
|
|
+ <el-checkbox @change="handleCheckAllChange">全选</el-checkbox>
|
|
|
+ <div style="margin: 15px 0;"></div>
|
|
|
+ <el-checkbox-group v-model="roleDialog.form.roleId">
|
|
|
+ <el-checkbox v-for="role in roleList" :label="role.id+''" :key="role.id">{{role.name}}
|
|
|
+ </el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="roleDialog.visible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="confirmSetRole">确 定</el-button>
|
|
|
+ </span>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
- <script>
|
|
|
+ <script>
|
|
|
var app = new Vue({
|
|
|
components: {
|
|
|
"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
|
|
@@ -90,86 +98,93 @@
|
|
|
},
|
|
|
el: '.vue-box',
|
|
|
data: {
|
|
|
- roleDialog:{
|
|
|
- visible:false,
|
|
|
- title:'',
|
|
|
- form:{
|
|
|
- id:'',
|
|
|
- roleId:[],
|
|
|
+ roleDialog: {
|
|
|
+ visible: false,
|
|
|
+ title: '',
|
|
|
+ form: {
|
|
|
+ id: '',
|
|
|
+ roleId: [],
|
|
|
}
|
|
|
},
|
|
|
- sa: sa, // 超级对象
|
|
|
- p: { // 查询参数
|
|
|
+ sa: sa, // 超级对象
|
|
|
+ p: { // 查询参数
|
|
|
name: '',
|
|
|
- customerId:sa.p('customerId',''),
|
|
|
+ customerId: sa.p('customerId', ''),
|
|
|
sort_type: 0,
|
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
|
},
|
|
|
dataCount: 0,
|
|
|
- dataList: [], // 数据集合
|
|
|
- roleList: [], // 角色集合
|
|
|
+ dataList: [], // 数据集合
|
|
|
+ roleList: [], // 角色集合
|
|
|
},
|
|
|
methods: {
|
|
|
- roleFn(data){
|
|
|
- Object.assign(this.roleDialog,{
|
|
|
- visible:true,
|
|
|
- title:'设置['+data.name+']角色属性',
|
|
|
- form:{
|
|
|
- id:data.id,
|
|
|
- roleId:data.roleId.split(',')
|
|
|
+ roleFn(data) {
|
|
|
+ Object.assign(this.roleDialog, {
|
|
|
+ visible: true,
|
|
|
+ title: '设置[' + data.name + ']角色属性',
|
|
|
+ form: {
|
|
|
+ id: data.id,
|
|
|
+ roleId: data.roleId.split(',')
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- handleCheckAllChange(){
|
|
|
- let roleId=this.roleDialog.form.roleId;
|
|
|
- let allIds=this.roleList.map(obj=>obj.id+'');
|
|
|
- this.roleDialog.form.roleId=roleId.length!=allIds.length?allIds:[];
|
|
|
+ handleCheckAllChange() {
|
|
|
+ let roleId = this.roleDialog.form.roleId;
|
|
|
+ let allIds = this.roleList.map(obj => obj.id + '');
|
|
|
+ this.roleDialog.form.roleId = roleId.length != allIds.length ? allIds : [];
|
|
|
},
|
|
|
- confirmSetRole(){
|
|
|
- let roleId=this.roleDialog.form.roleId;
|
|
|
- if(roleId.length == 0) {
|
|
|
+ confirmSetRole() {
|
|
|
+ let roleId = this.roleDialog.form.roleId;
|
|
|
+ if (roleId.length == 0) {
|
|
|
return sa.msg('请选择一个角色')
|
|
|
}
|
|
|
- let o={
|
|
|
- id:this.roleDialog.form.id,
|
|
|
- roleId:this.roleDialog.form.roleId.join(',')
|
|
|
+ let o = {
|
|
|
+ id: this.roleDialog.form.id,
|
|
|
+ roleId: this.roleDialog.form.roleId.join(',')
|
|
|
}
|
|
|
- sa.ajax('/admin/setRole',o,function(resp){
|
|
|
+ sa.ajax('/admin/setRole', o, function(resp) {
|
|
|
this.f5();
|
|
|
- this.roleDialog.visible=false;
|
|
|
+ this.roleDialog.visible = false;
|
|
|
}.bind(this))
|
|
|
},
|
|
|
// 刷新
|
|
|
- f5: function(isPage){
|
|
|
- sa.ajax('/admin/getCustomerAdminList', this.p, function(res){
|
|
|
- this.dataList = res.data; // 数据
|
|
|
+ f5: function(isPage) {
|
|
|
+ sa.ajax('/admin/getCustomerAdminList', this.p, function(res) {
|
|
|
+ this.dataList = res.data; // 数据
|
|
|
this.dataCount = res.dataCount;
|
|
|
- sa.f5TableHeight(); // 刷新表格高度
|
|
|
+ sa.f5TableHeight(); // 刷新表格高度
|
|
|
}.bind(this));
|
|
|
},
|
|
|
// 新增
|
|
|
add: function() {
|
|
|
- sa.showIframe('新增用户', 'customer-admin-add.html?customerId=' + this.p.customerId, '550px', '75%');
|
|
|
+ sa.showIframe('新增用户', 'customer-admin-add.html?customerId=' + this.p.customerId, '550px',
|
|
|
+ '75%');
|
|
|
},
|
|
|
// 查看详情
|
|
|
getInfo: function(data) {
|
|
|
- sa.showIframe('账号详情', '../../sa-view-sp/sp-admin/admin-info.html?id=' + data.id, '700px', '80%');
|
|
|
+ sa.showIframe('账号详情', '../../sa-view-sp/sp-admin/admin-info.html?id=' + data.id, '700px',
|
|
|
+ '80%');
|
|
|
//sa.$page.openAdminInfo(data.id, data.name);
|
|
|
},
|
|
|
// 查看 - 根据选中的
|
|
|
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]);
|
|
|
},
|
|
|
// 修改名称
|
|
|
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 +193,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,29 +244,34 @@
|
|
|
},
|
|
|
// 修改用户的状态
|
|
|
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', {adminId: data.id, status: data.status}, function(res) {
|
|
|
+ var is_ok = false; // 记录是否成功
|
|
|
+ var ajax = sa.ajax('/admin/updateStatus', {
|
|
|
+ adminId: 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;
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 删除
|
|
|
- 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(); // 刷新表格高度
|
|
|
})
|
|
|
});
|
|
|
},
|
|
@@ -247,32 +280,37 @@
|
|
|
// 获取选中元素的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));
|
|
|
},
|
|
|
- getRoleList(){
|
|
|
+ getRoleList() {
|
|
|
// 加载角色
|
|
|
- sa.ajax('/role/getCustomerRoleList',{customerId:this.p.customerId}, function(res){
|
|
|
- this.roleList = res.data; // 数据
|
|
|
- }.bind(this), {msg: null});
|
|
|
+ sa.ajax('/role/getCustomerRoleList', {
|
|
|
+ customerId: this.p.customerId
|
|
|
+ }, function(res) {
|
|
|
+ this.roleList = res.data; // 数据
|
|
|
+ }.bind(this), {
|
|
|
+ msg: null
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
- created: function(){
|
|
|
+ created: function() {
|
|
|
this.f5();
|
|
|
- sa.onInputEnter(); // 监听回车执行查询
|
|
|
+ sa.onInputEnter(); // 监听回车执行查询
|
|
|
this.getRoleList();
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|