<!--
|
* @Author: lzhe lzhe@example.com
|
* @Date: 2024-03-26 10:28:33
|
* @LastEditors: lzhe lzhe@example.com
|
* @LastEditTime: 2024-04-03 18:22:26
|
* @FilePath: /smart-web/src/views/master/person/main/index.vue
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
-->
|
<template>
|
<div class="user-main">
|
<div class="user-top">
|
<div class="right-bottom">
|
<el-button type="primary" @click="addPerson">新建</el-button>
|
<el-button type="primary" @click="resetPerson">密码重置</el-button>
|
<el-button type="danger" plain @click="delData">删除</el-button>
|
</div>
|
<div>
|
<el-input v-model="searchData.account" placeholder="账号" style="width: 180px;margin-right: 8px;" clearable></el-input>
|
<el-input v-model="searchData.realName" placeholder="账号昵称" style="width: 180px;margin-right: 8px;" clearable></el-input>
|
<el-button type="primary" @click="searchclick">搜索</el-button>
|
</div>
|
</div>
|
<div class="user-table">
|
<el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" />
|
<el-table-column prop="account" label="账号"></el-table-column>
|
<el-table-column prop="realName" label="账号昵称"></el-table-column>
|
<el-table-column prop="roleName" label="所属角色"></el-table-column>
|
<el-table-column prop="deptName" label="数据权限"></el-table-column>
|
<el-table-column prop="name" label="账号状态">
|
<template #default="scope">
|
<el-switch v-model="scope.row.status" @click="changeStatus(scope.row)" />
|
</template>
|
</el-table-column>
|
<el-table-column fixed="right" label="操作">
|
<template #default="scope">
|
<el-button type="text" size="small" @click="table_edit(scope.row, scope.$index)">编辑</el-button>
|
<el-button text type="primary" size="small" @click="table_unlock(scope.row, scope.$index)">解锁</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-pagination
|
style="margin-top: 12px;"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
:current-page="currentPage4"
|
:page-sizes="[15, 50, 100]"
|
:page-size="15"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total">
|
</el-pagination>
|
</div>
|
</div>
|
|
<el-dialog title="部门调整" v-model="departmentVisible" :width="400" destroy-on-close>
|
<el-form :model="departmentFrom" :rules="departmentVisibleRules" :disabled="mode=='show'" ref="dialogForm" label-width="80px" label-position="center">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="部门" prop="department">
|
<el-select v-model="departmentFrom.department" style="width: 100%">
|
<el-option v-for="item in groups" :key="item.id" :label="item.label" :value="item.id"/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<el-button @click="departmentVisible=false" >取 消</el-button>
|
<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="departmentSubmit()">保 存</el-button>
|
</template>
|
</el-dialog>
|
|
<save-dialog v-if="dialog.save" ref="saveDialog" @success="addUserSuccess" @closed="dialog.save=false"></save-dialog>
|
</template>
|
<script>
|
import saveDialog from './addUser'
|
export default {
|
name: "bakalaka",
|
data(){
|
return {
|
selection: [],
|
searchData: {
|
account: "",
|
realName: "",
|
current: "1",
|
size: "15"
|
},
|
total: 0,
|
isSaveing: false,
|
groups: [],
|
departmentFrom: {
|
department: ""
|
},
|
departmentVisibleRules: {
|
department:[
|
{required: true, message: '请选择部门'}
|
]
|
},
|
departmentVisible: false,
|
dialog: {
|
save: false
|
},
|
leftActive: true,
|
input: '',
|
options: [{
|
value: '选项1',
|
label: '黄金糕'
|
}],
|
input3: '',
|
tableData: []
|
}
|
},
|
created(){
|
|
},
|
mounted(){
|
this.searchUser();
|
},
|
components: {
|
saveDialog
|
},
|
methods: {
|
addUserSuccess() {
|
this.searchclick();
|
},
|
changeStatus(row) {
|
row.status = !row.status;
|
var obj = {
|
enable: true,
|
id: row.id
|
}
|
var str = "";
|
if(row.status) {
|
obj.enable = false;
|
str = "停用";
|
}else {
|
obj.status = true;
|
str = "启用";
|
}
|
this.$confirm('确定要'+str+row.account+'?','提示', {
|
type: 'warning',
|
}).then(() => {
|
//const loading = this.$loading()
|
//loading.close()
|
this.$HTTP.post("/api/blade-user/changeStatus?"+this.$TOOL.qsStringify(obj)).then(res=> {
|
this.isSaveing = false;
|
if(res.code == 200) {
|
this.searchclick();
|
this.$message.success("操作成功");
|
}else {
|
this.$alert(res.message, "提示", {type: 'error'});
|
}
|
})
|
}).catch(() => {
|
//取消
|
})
|
},
|
table_unlock(row) {
|
this.$confirm('确定将选择账号解锁??','提示', {
|
type: 'warning',
|
}).then(() => {
|
this.$HTTP.post("/api/blade-user/unlock?userId="+row.id).then(res=> {
|
if(res.code == 200) {
|
this.searchclick();
|
this.$message.success("操作成功");
|
}else {
|
this.$alert(res.message, "提示", {type: 'error'});
|
}
|
})
|
}).catch(() => {
|
//取消
|
})
|
},
|
searchclick() {
|
this.searchData.current = "1";
|
this.searchData.size = "15";
|
this.searchUser();
|
},
|
searchUser() {
|
this.$HTTP.get("/api/blade-user/page",this.searchData).then(res=> {
|
if(res.code == 200) {
|
res.data.records.forEach(item=> {
|
if(item.status == "1") {
|
item.status = true;
|
}else {
|
item.status = false;
|
}
|
})
|
this.tableData = res.data.records;
|
this.total = res.data.total;
|
console.log(this.tableData)
|
}
|
})
|
},
|
departmentSubmit() {
|
this.departmentVisible=false; //部门调整
|
},
|
//添加
|
addPerson(){
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open()
|
})
|
},
|
table_edit(row){
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open('edit').setData(row)
|
})
|
},
|
//查看
|
table_show(row){
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open('show').setData(row)
|
})
|
},
|
handleSelectionChange(selection) {
|
this.selection = selection;
|
},
|
resetPerson() {
|
if(this.selection.length == 0) {
|
this.$message({
|
message: '请选择至少一条数据',
|
type: 'warning'
|
});
|
return;
|
}
|
var selStr = "";
|
this.selection.map(item=> {
|
selStr += item.id + ","
|
})
|
selStr = selStr.replace(/,$/, '');
|
var that = this;
|
this.$confirm('是否确认删除选中账号?','提示', {
|
type: 'warning',
|
}).then(() => {
|
that.$HTTP.post("/api/blade-user/reset-password?userIds="+selStr).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.searchUser();
|
}
|
})
|
}).catch(() => {
|
//取消
|
})
|
},
|
delData() {
|
if(this.selection.length == 0) {
|
this.$message({
|
message: '请选择至少一条数据',
|
type: 'warning'
|
});
|
return;
|
}
|
var selStr = "";
|
this.selection.map(item=> {
|
selStr += item.id + ","
|
})
|
selStr = selStr.replace(/,$/, '');
|
var that = this;
|
this.$HTTP.get("/api/blade-user/check-user-is-bind-employee?userIds="+selStr).then(res=> {
|
if(res.code == 200) {
|
this.$confirm('是否确认删除选中账号?','提示', {
|
type: 'warning',
|
}).then(() => {
|
that.$HTTP.post("/api/blade-user/remove?ids="+selStr).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.searchUser();
|
}
|
})
|
}).catch(() => {
|
//取消
|
})
|
}
|
})
|
},
|
changeDepartment() {
|
this.departmentVisible = true;
|
},
|
changeTab(name) {
|
if(name == 1) {
|
this.leftActive = true;
|
}else {
|
this.leftActive = false;
|
}
|
},
|
handleSizeChange(val) {
|
console.log(`每页 ${val} 条`);
|
this.searchData.current = "1";
|
this.searchData.size = val;
|
this.searchUser();
|
},
|
handleCurrentChange(val) {
|
console.log(`当前页: ${val}`);
|
this.searchData.current = val;
|
this.searchUser();
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.user-main {
|
background-color: #f9fafb;
|
border: 1px solid #dcdfe6;
|
box-shadow: 0 2px 4px 0 rgba(0,0,0,.12), 0 0 6px 0 rgba(0,0,0,.04);
|
margin: 8px;
|
padding: 8px;
|
background-color: #fff;
|
}
|
.user-top {
|
width: 100%;
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 8px;
|
}
|
.user-table {
|
width: 100%;
|
margin-bottom: 8px;
|
|
}
|
.multipleTableRef {
|
margin-bottom: 8px;
|
}
|
</style>
|