新建root html file,root.html

账号管理

成都杜甫草堂博物馆综合信息管理平台

{{userData.userName}},欢迎您

登出

首页

账号管理

{{date + ' 星期' + week + ' ' + time}}

添加账号

账号列表

新增用户组

用户组管理

用户名

选择头像

自定义

真实姓名

密码

确认密码

所属用户组

--请选择--

{{item.groupName}}

保存

序号用户名真实姓名所属用户组创建管理员创建时间操作

{{item.id}}{{item.userName}}{{item.realName}}{{item.groupName}}{{item.createName}}{{item.createTime}}

修改

删除

总计{{total}}人

  • «

  • {{i}}
  • {{i}}

    ...

  • »

  • 上一页
  • 下一页

用户组名称

用户组权限

一级权限二级权限

{{item.title}}

{{second.title}}

提示:1、选择二级权限时必须选择对应的一级权限,否则不生效!

保存

序号名称权限创建管理员创建时间操作

{{item.id}}{{item.groupName}}{{item.userAuthority}}admin{{item.createTime}}

修改

删除

let tabs = {

1: '添加账号',

2: '账号列表',

3: '添加用户组',

4: '用户组列表',

};

var root = new Vue({

el: '#root',

data() {

return {

//=============>通用<=================

time: this.timeFormat('hh:mm'),

date: this.timeFormat('yyyy年MM月dd日'),

week: this.timeFormat('D'),

baseUrl: api.baseUrl,

userData: store.fetch('userLoginInfo'),

tabCurrent: 1,

tabs: tabs,

complete: false,

roles: store.fetch('userLoginInfo').roles,

//==============>新增用户<================

userImg: '',//用户上传图片

userSelectImg: 'head.png',//用户选定图片

upimgurl: '',

userEditSelectImg: '',

addUserForm: {

name: '',

header_img: 'head.png',

rel_name: '',

password: '',

group_id: '',

create_name: 'admin',

rel_name: '',

group: ''

},

confirm: '',//确认密码

groupList: [],//用户组列表,

// ==============>账号列表<===============

userPages: [],//页数

total: 0,//总条数

userList: [],//用户列表

currentPage: 1,//当前页码

//修改用户

editUserForm: {

name: '',

header_img: '',

rel_name: '',

password: '',

group_id: '',

create_name: '',

rel_name: '',

group: '',

id: ''

},

confirm1: '',

delId: '',

//================>新增用户组<=============

menuList: [],//菜单列表

addRootMenuList: [],//新增用户组权限

addUserGroupName: '',

//编辑

editGroupId: '',

editGroupName: '',

editGroupRoles: [],

delGroupId: ''

}

},

created() {

},

mounted() {

this.init();

// this.getUserGroupList();

window.pageSet();

},

methods: {

//================================>通用<====================================

//初始化

init() {

this.getDate();

if(this.menuConfig('添加账号')) {

this.tabClick(1);

return false;

}

if(this.menuConfig('账号列表')) {

this.tabClick(2);

return false;

}

if(this.menuConfig('新增用户组')) {

this.tabClick(3);

return false;

}

if(this.menuConfig('用户组管理')) {

this.tabClick(4);

return false;

}

},

//权限判断

menuConfig(menuName) {

let re = new RegExp(menuName);

return re.test(this.roles);

},

tabClick(i) {

this.tabCurrent = i;

this.complete = false;

if(i === 1) {

this.addUserInit();

}

if(i === 2) {

this.userListInit();

}

if(i === 3) {

this.addUserGroupInit()

}

if(i === 4) {

this.userGroupInit();

}

},

//添加账号初始化

addUserInit() {

// this.getMenu();

this.getUserGroupList();

this.userImg = ''

},

//账号列表初始化

userListInit() {

this.getUserList();

},

//新增用户组初始化

addUserGroupInit() {

this.getMenu();

},

//用户组管理初始化

userGroupInit() {

this.getMenu();

this.getUserGroupList();

},

//时间格式化

timeFormat(fmt) {

let date = new Date();

let week = {

0: '日',

1: '一',

2: '二',

3: '三',

4: '四',

5: '五',

6: '六'

};

var o = {

"M+" : date.getMonth()+1, //月份

"d+" : date.getDate(), //日

"h+" : date.getHours(), //小时

"m+" : date.getMinutes(), //分

"s+" : date.getSeconds(), //秒

"q+" : Math.floor((date.getMonth()+3)/3), //季度

"S" : date.getMilliseconds(), //毫秒

"D" : week[date.getDay()]

};

if(/(y+)/.test(fmt))

fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));

for(var k in o)

if(new RegExp("("+ k +")").test(fmt))

fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));

return fmt;

},

//动态获取时间、

getDate() {

setInterval(() => {

this.time = this.timeFormat('hh:mm');

this.date = this.timeFormat('yyyy年MM月dd日');

this.week = this.timeFormat('D')

},1000)

},

//登出

logout() {

store.clear('userLoginInfo');

store.clear('userData');

window.location.href = '/login.html';

},

//================================>添加账号<==================================

//选择头像

imgSelect(imgUrl) {

this.userSelectImg = imgUrl;

this.addUserForm.header_img = imgUrl;

},

imgSelect1(imgUrl) {

this.userEditSelectImg = imgUrl;

this.editUserForm.header_img = imgUrl;

},

//用户上传头像

userUpdateImg(e) {

this.imgUpload(e)

},

//获取用户组列表

getUserGroupList() {

api.getGroupList().then(res => {

this.complete = true;

if(res.data.status == 'success') {

this.groupList = res.data.data;

}

})

},

//提示通知

notice(title,msg,type) {

spop({

template: '

'+title+'
'+msg,

style: type,

autoclose: 3000

});

},

//图片文件上传

imgUpload(e) {

let formData = new FormData();

let file = e.target.files[0];

if(!file) {

return false

}

formData.append('fileName',file);

api.upload(formData).then(res => {

if(res.data.status == 'success') {

this.userImg = file.name;

this.notice('提示','图片上传成功','success')

}else {

this.notice('错误','图片上传失败','error')

}

}).catch(err => {

this.notice('错误','图片上传失败','error')

});

e.target.value = '';

},

//保存

addUser() {

if(!this.addUserForm.name) {

this.notice('错误','请填写用户名!','error');

this.$refs.addName.focus();

return false;

};

if(!this.addUserForm.rel_name) {

this.notice('错误','请填写真实姓名!','error');

this.$refs.addRelname.focus();

return false;

};

if(!this.addUserForm.password) {

this.notice('错误','请填写密码!','error');

this.$refs.addPassword.focus();

return false;

};

if(!this.confirm) {

this.notice('错误','请填写确认密码!','error');

this.$refs.addConfirm.focus();

return false;

}else if(this.confirm != this.addUserForm.password){

this.notice('错误','两次输入的密码不一致,请重新输入!','error');

this.confirm = '';

this.addUserForm.password = '';

this.$refs.addPassword.focus();

return false;

};

if(!this.addUserForm.group) {

this.notice('错误','请选择用户组!','error');

this.$refs.addUserGroup.focus();

return false;

};

let body = {

creatorName: this.addUserForm.create_name,

groupId: this.addUserForm.group.groupId,

groupName: this.addUserForm.group.groupName,

password: this.addUserForm.password,

realName: this.addUserForm.rel_name,

userHeader: this.addUserForm.header_img,

userName: this.addUserForm.name

};

api.addUser(body).then(res => {

if(res.data.status == 'success') {

this.notice('提示','添加成功!','success');

this.addUserForm = {

name: '',

header_img: 'head.png',

rel_name: '',

password: '',

group_id: '',

create_name: 'admin',

rel_name: '',

group: ''

};

this.confirm = '';

let body = {

author: this.userData.userName,

moduleChileName: '添加账号',

moduleName: '账号管理',

operation: '添加账号'

}

this.recordLog(body)

}else {

this.notice('错误',res.data.data.errMsg,'error');

return false;

}

}).catch(err => {

this.notice('错误','服务器开小差了,请稍后再试!','error');

})

},

//=============================>账号列表<=============================

//点击页码

selectPage(i) {

this.currentPage = i;

this.getUserList();

},

//上一页

topPage() {

if(this.currentPage === 1) {

return false;

}

this.currentPage --;

this.getUserList();

},

//下一页

nextPage() {

if(this.currentPage === this.userPages[this.userPages.length-1]) {

return false;

}

this.currentPage++;

this.getUserList();

},

//获取数据

getUserList() {

let body = {

pageSize: 10,

pageNum: this.currentPage

}

this.complete = false;

api.getUserList(body).then(res => {

this.complete = true;

if(res.data.status == 'success') {

let data = res.data.data.list;

for (const i in data) {

if(data[i].createTime) {

data[i].createTime = data[i].createTime.split(' ')[0];

}

}

this.userList = data;

this.userPages = res.data.data.navigatepageNums;

this.total = res.data.data.total;

}

});

},

//编辑用户

editUserConfig(item) {

this.userImg = ''

this.editUserForm.name = item.userName;

this.editUserForm.header_img = item.userHeaderImage;

this.editUserForm.password = item.password;

this.editUserForm.group_id = item.groupId;

this.editUserForm.group = {

groupName: item.groupName,

groupId: item.groupId

};

this.editUserForm.create_name = item.createName;

this.editUserForm.rel_name = item.realName;

this.confirm1 = item.password;

this.userEditSelectImg = item.userHeaderImage;

this.editUserForm.id = item.id

if(!(this.userEditSelectImg == 'head.png' || this.userEditSelectImg == 'head01 (1).jpg' || this.userEditSelectImg == 'head01 (2).jpg'|| this.userEditSelectImg == 'head01 (3).jpg'|| this.userEditSelectImg == 'head01 (4).jpg'|| this.userEditSelectImg == 'head01 (4).jpg')) {

this.userImg = this.userEditSelectImg

}

},

//取消编辑

cancleEdit() {

this.editUserForm = {

name: '',

header_img: '',

rel_name: '',

password: '',

group_id: '',

create_name: '',

rel_name: '',

group: '',

id: ''

},

this.userEditSelectImg = '';

},

//保存编辑

editSubmit() {

let body = {

creatorName: this.editUserForm.create_name,

groupId: this.editUserForm.group.groupId,

groupName: this.editUserForm.group.groupName,

password: this.editUserForm.password,

realName: this.editUserForm.rel_name,

userHeader: this.editUserForm.header_img,

userName: this.editUserForm.name,

id: this.editUserForm.id

}

this.complete = false;

api.editUser(body).then(res => {

this.complete = true;

if(res.data.status == 'success') {

this.notice('提示','修改成功!','success');

$('#editUser').modal('hide');

let body = {

author: this.userData.userName,

moduleChileName: '账号列表',

moduleName: '账号管理',

operation: '修改账号'

}

this.recordLog(body)

}

this.getUserList();

})

},

//删除用户

delUser(id) {

this.delId = id;

},

delSubmit() {

let body = {

id: this.delId

};

this.complete = false;

api.delUser(body).then(res => {

this.complete = true;

if(res.data.status == 'success') {

this.notice('提示','删除成功!','success');

$('#delModal').modal('hide');

this.getUserList()

let body = {

author: this.userData.userName,

moduleChileName: '账号列表',

moduleName: '账号管理',

operation: '删除账号'

}

this.recordLog(body)

}else {

this.notice('提示','删除失败!','error');

$('#delModal').modal('hide');

}

}).catch(err => {

this.complete = true;

this.notice('提示','服务器开小差了,请稍后再试!','error');

})

},

//=============================>新增用户组<=============================

getMenu() {

this.complete = false;

api.getMenuList().then(res => {

this.complete = true;

if(res.data.status == 'success') {

let data = res.data.data;

this.menuList = data;

let add = {

title: '新增'

}

this.menuList.push(add)

}

}).catch(err => {

this.notice('提示','服务器开小差了,请稍后再试!','error');

})

},

saveUserGroup() {

if(!this.addUserGroupName) {

this.notice('提示','请填写用户组名称!','error');

this.$refs.rootName.focus()

}

if(this.addRootMenuList.length < 1) {

this.notice('提示','请至少选择一项权限!','error');

}

let userAuthority = this.addRootMenuList.join(',');

let userGroupName = this.addUserGroupName;

let body = {

userAuthority,

userGroupName

}

this.complete = false;

api.addUserGroup(body).then(res => {

this.complete = true;

if(res.data.status == 'success') {

this.notice('提示','添加成功!','success');

this.addRootMenuList = [];

this.addUserGroupName = '';

let body = {

author: this.userData.userName,

moduleChileName: '新增用户组',

moduleName: '账号管理',

operation: '新增用户组'

}

this.recordLog(body)

}else {

this.notice('提示','添加失败!','error');

}

}).catch(err => {

this.complete = true;

this.notice('提示','服务器开小差了,请稍后再试!','error');

})

},

//=================================>用户组管理<==================================

editGroup(item) {

this.editGroupId = item.id;

this.editGroupName = item.groupName;

this.editGroupRoles = item.userAuthority.split(',')

},

cancleEditGroup() {

this.editGroupId = '';

this.editGroupName = '';

this.editGroupRoles = [];

},

saveEditGroup() {

let body = {

id: this.editGroupId,

userAuthority: this.editGroupRoles.join(','),

userGroupName: this.editGroupName

}

this.complete = false;

api.edieUserGroup(body).then(res => {

this.complete = true;

if(res.data.status == 'success') {

this.notice('提示','修改成功!','success');

$('#editRoot').modal('hide');

this.getUserGroupList()

let body = {

author: this.userData.userName,

moduleChileName: '用户组管理',

moduleName: '账号管理',

operation: '修改用户组'

}

this.recordLog(body)

}else {

this.notice('提示','修改失败!','error');

}

}).catch(err => {

this.complete = true;

this.notice('提示','服务器开小差了,请稍后再试!','error');

})

},

delGroup(id) {

this.delGroupId = id;

$('#delModal').modal('show');

},

delGroupSubmit() {

let body = {

id: this.delGroupId

}

this.complete = false;

api.delGroup(body).then(res => {

this.complete = true;

if(res.data.status == 'success') {

this.notice('提示','删除成功!','success');

$('#delModal').modal('hide');

this.getUserGroupList()

let body = {

author: this.userData.userName,

moduleChileName: '用户组管理',

moduleName: '账号管理',

operation: '删除用户组'

}

this.recordLog(body)

}else {

this.notice('提示','删除失败!','error');

$('#delModal').modal('hide');

}

}).catch(err => {

this.complete = true;

this.notice('提示','服务器开小差了,请稍后再试!','error');

})

},

recordLog(body,fn=false) {

api.updateLog(body).then(res => {

if(fn) {

let newFN = new Function(fn);

newFN();

}

}).catch(err => {

console.error(err)

})

},

}

})

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值