文件

191 行
7.2 KiB
HTML
可执行文件

<!--[1.7.12]-->
<style>
.el-pagination {
padding: 8px;
}
</style>
<div class="goodsBox" id="jurUserApp" v-cloak>
<div style="margin-bottom:10px;" v-if="operate.userAdd">
<el-button type="primary" @click="addUser" size="small">新增用户</el-button>
</div>
<div>
<el-table border :data="usersList" size="small" style="width: 100%;">
<el-table-column type="index" label="序号" width="50"></el-table-column>
<el-table-column prop="login_name" label="登录账号" show-overflow-tooltip></el-table-column>
<el-table-column prop="name" label="真实名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="role_name" label="用户角色" show-overflow-tooltip></el-table-column>
<el-table-column prop="add_time" label="添加时间" show-overflow-tooltip></el-table-column>
<el-table-column label="状态">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="1"
inactive-value="2"
@change="changeStatus(scope.row.id)"
:disabled="operate.changeStatus?false:true">
</el-switch>
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="130" style="border-right: none;">
<template slot-scope="scope">
<el-button v-if="operate.userAdd"
type="text" size="small"
@click="usersEdit(scope.row.id)">编辑
</el-button>
<el-button v-if="operate.userDel"
style="color: #aaaaaa" size="mini"
@click="deleteUsers(scope.row.id)"
type="text">删除
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="len">
</el-pagination>
</div>
</div>
<script type="text/javascript">
var app = new Vue({
el: '#jurUserApp',
data () {
return {
operate: {},
usersList: [],
len: 0,
currentPage: 1,
currentLimit: 10,
}
},
methods: {
addUser () {
layer.open({
type: 2,
title: '添加用户',
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
shade: 0,
offset: 'rb',
content: '/index.php/Retail/MerchantJurUsers/userAdd',
end: () => {
this.getData();
}
});
},
//删除角色
deleteUsers (id) {
this.$confirm('删除后用户可能产生变动,请谨慎操作!确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
$.ajax({
url: '/index.php/Retail/MerchantJurUsers/usersDel',
type: 'post',
data: {
id: id
},
success: (res) => {
if (res.status == 1) {
this.$message.success(res.msg);
this.getData();
} else {
this.$message.warning(res.msg);
}
}
})
}).catch(() => {
});
},
handleSizeChange(val) {
this.currentLimit = val;//切换每页数量
this.currentPage = 1;
this.getData();
},
handleCurrentChange(val) {
this.currentPage = val;
this.getData();//切换页数
},
//获取列表
getData () {
$.ajax({
url: '/index.php/Retail/MerchantJurUsers/getUser',
type: 'post',
data: {
page: this.currentPage,
limit: this.currentLimit
},
success: (res) => {
if (res.status == 1) {
this.usersList = [];
this.usersList = res.data;
this.len = res.count;
} else {
this.$message.warning(res.msg);
}
}
})
},
//修改状态
changeStatus(id) {
$.ajax({
url: '/index.php/Retail/MerchantJurUsers/changeStatus',
type: 'post',
data: {
id: id
},
success: (res) => {
if (res.status == 1) {
this.$message.success(res.msg);
} else {
this.$message.warning(res.msg);
}
}
})
},
usersEdit (id) {
layer.open({
type: 2,
title: '添加用户',
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
offset: 'rb',
shade: 0,
content: "{:U('userAdd')}?id=" + id,
end: ()=> {
this.getData();
}
});
},
//获取操作权限
getOperate() {
let auth_list = {
userAdd: '/index.php/Retail/MerchantJurUsers/userAdd',
changeStatus: '/index.php/Retail/MerchantJurUsers/changeStatus',
userDel: '/index.php/Retail/MerchantJurUsers/userDel',
};
$.ajax({
url: '/index.php/Retail/Component/checkOperateAuth',
type: "post",
data: {
auth_list: JSON.stringify(auth_list),
},
success: (res) => {
if (res.status == 1) {
this.operate = res.data;
}
}
})
}
},
created: function () {
this.getData();
this.getOperate();
}
});
</script>