<template>
|
<div class="app-container">
|
<el-row :gutter="15">
|
<!--左侧树形开始-->
|
<el-col :span="5">
|
<el-card class="box-card" shadow="never">
|
<my-tree ref="searchTree" :tree-list="treeDataList" @setNode="nodeClick" @search="search"></my-tree>
|
</el-card>
|
</el-col>
|
<!--左侧树形结束-->
|
<!--右侧列表开始-->
|
<el-col :span="19">
|
<el-card class="box-card" shadow="never">
|
<!--搜索条件-->
|
<div class="filter-container">
|
<my-search ref="searchBar" :items="items" @search="fifterForm"></my-search>
|
</div>
|
<el-row style="margin-top: 15px">
|
<el-col>
|
<!--列表-->
|
<my-table-v2 ref="myTable" :filter="filterFrom" :table="table"/>
|
</el-col>
|
</el-row>
|
</el-card>
|
</el-col>
|
</el-row>
|
<!--添加/编辑弹窗-->
|
<edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search"/>
|
<editRole
|
v-if="editRoleSetting.show"
|
:setting="editRoleSetting"
|
@close="editRoleSetting.show = false"
|
@search="search"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import myTree from '@/components/myTree/index';
|
import MyTableV2 from '@/components/myTable/myTableV2';
|
import MyButton from '@/components/myButton/myButton';
|
import SettingIplatform from '@/utils/settingIplatform';
|
import items from './items';
|
import edit from './edit';
|
import editRole from './editRole';
|
import * as finsystenant from '@/api/baseSetting/finsystenant';
|
import * as user from '@/api/user';
|
import {LongToDateTime} from "@/utils/DateFormatter";
|
|
export default {
|
name: 'index',
|
components: { MyButton, MyTableV2, myTree, edit, editRole },
|
data() {
|
return {
|
// 搜索框
|
items: items,
|
// 树数据
|
treeDataList: [],
|
// 搜索条件
|
filterFrom: {
|
tenantCode: null,
|
userName: null,
|
userCode: null,
|
},
|
curOrgId: null,
|
// 添加&编辑设置
|
tenantId: null, //区划id
|
tenantCode: null, //区划code
|
tenantName: null, //区划名称
|
data_scope: 0, //角色范围
|
editSetting: {
|
title: '',
|
id: '',
|
tenantId: '',
|
show: false,
|
},
|
// 编辑角色配置
|
editRoleSetting: {
|
title: '',
|
data_scope: 0,
|
id: '',
|
show: false,
|
},
|
// 表格数据
|
table: {
|
showIndex: true, // 是否显示序号
|
expand: false, // 是否显示详情数据
|
url: SettingIplatform.apiBaseURL + '/pc/fin/sys/tenant/user/select/list', // 请求地址
|
// 工具条
|
tools: {
|
columnsCtrl: {
|
// 列控制按钮
|
show: false,
|
},
|
generalExport: {
|
// 通用导出按钮
|
show: false,
|
},
|
// 自定义工具条按钮
|
custom: [
|
{
|
name: '新增',
|
click: () => {
|
this.showAdd(null);
|
},
|
},
|
],
|
},
|
// 列信息
|
columns: [
|
{title: '人员姓名', field: 'userName', align: 'left', minWidth: 140},
|
{title: '登录名', field: 'userCode', align: 'left', minWidth: 140},
|
{title: '手机号', field: 'userPhone', align: 'center', width: 110},
|
{ title: '所属机构', field: 'tenantName', align: 'center', minWidth: 150 },
|
{ title: '部门', field: 'sysDeptName', align: 'center' },
|
{
|
field: 'status',
|
title: '状态',
|
align: 'center',
|
width: 80,
|
switch: (row) => {
|
const result = {};
|
if (row.status == 1) {
|
Object.assign(result, {
|
value: true, // 开
|
label: '启用', // 开的描述
|
click: () => {
|
// 点击事件
|
this.updState(row)
|
},
|
});
|
} else {
|
Object.assign(result, {
|
value: false, // 关
|
label: '禁用', // 关的描述
|
click: () => {
|
this.updState(row)
|
},
|
});
|
}
|
return result;
|
},
|
}
|
],
|
// 操作信息
|
operation: {
|
show: true, // 显示操作列
|
width: '250', // 列宽
|
attr: [
|
{
|
title: '角色',
|
events: (row) => {
|
this.showEditRole(row.id);
|
},
|
},
|
{
|
title: '编辑',
|
events: (row) => {
|
this.showAdd(row.id);
|
},
|
},
|
{
|
title: '密码初始化',
|
events: (row) => {
|
this.updPassWord(row);
|
},
|
},
|
],
|
},
|
paging: {
|
show: true, // 显示分页
|
// 分页信息
|
page: {
|
small: false,
|
pageNum: 1,
|
pageSize: 10,
|
total: 0,
|
},
|
},
|
},
|
};
|
},
|
created() {
|
// 获取机构树
|
this.initTreeData();
|
this.data_scope = this.$store.getters.userInfo ? this.$store.getters.userInfo.lv : ''
|
if(this.data_scope===0){
|
this.data_scope=1
|
}
|
this.editSetting.data_scope = this.data_scope;
|
this.editRoleSetting.data_scope = this.data_scope;
|
},
|
methods: {
|
//导入
|
importUser() {
|
this.importSetting.dialogShow = true
|
this.importSetting.onSuccess = (response, callBack) => {
|
if (response.code === 1) {
|
this.$message.success(response.msg)
|
this.search(1)
|
} else {
|
this.$message.warning(response.msg)
|
}
|
callBack()
|
}
|
},
|
// 左侧树初始化
|
initTreeData() {
|
finsystenant.getTree().then((res) => {
|
const content = res || [];
|
this.treeDataList.splice(0, this.treeDataList.length);
|
this.treeDataList = content;
|
if (this.treeDataList && this.treeDataList.length > 0) {
|
this.tenantId = this.treeDataList[0].id;
|
this.tenantName = this.treeDataList[0].label;
|
this.tenantCode = this.treeDataList[0].code;
|
}
|
});
|
},
|
updState(row) {
|
let vm = this
|
let text = row.status === 0 ? "启用" : "禁用";
|
vm.$modal.confirm('确认要' + text + '"' + row.userName + '"吗?').then(function () {
|
let params = Object.assign({}, row)
|
params.status = row.status === 1 ? 0 : 1
|
user.updateStatus(params).then(res => {
|
if (res) {
|
row.status = row.status === 1 ? 0 : 1
|
vm.$modal.msgSuccess(text + "成功");
|
}
|
})
|
})
|
},
|
nodeClick(param) {
|
param = param || {};
|
this.p = Object.assign(
|
{},
|
{
|
id: param.id,
|
name: param.name,
|
code: param.code,
|
lv: param.lv,
|
},
|
);
|
let data_scope = Number(this.data_scope) + (param.lv-1)
|
if (this.p.code != undefined && this.p.code != null) {
|
this.filterFrom.tenantCode = this.p.code;
|
this.tenantId = this.p.id;
|
this.tenantName = this.p.name;
|
this.editSetting.tenantCode = this.p.code;
|
this.editSetting.data_scope = data_scope;
|
this.editRoleSetting.data_scope = data_scope;
|
} else {
|
this.filterFrom.tenantCode = 0;
|
}
|
this.table.paging.page.pageNum = 1;
|
this.search(1);
|
},
|
/** 初始化密码 */
|
updPassWord(row) {
|
this.$modal
|
.confirm('是否确认初始化名称为"' + row.userName + '"的密码?')
|
.then(function () {
|
user.updPassWord(row).then((res) => {
|
});
|
})
|
.then((res) => {
|
this.$modal
|
.confirm('初始化密码成功,新密码为:123456')
|
.then((res) => {
|
|
})
|
.catch(() => {
|
});
|
this.search();
|
})
|
.catch(() => {
|
});
|
},
|
// 查询table列表
|
search(pageNum) {
|
if (pageNum != undefined) {
|
this.$refs.myTable.search(pageNum);
|
} else {
|
this.$refs.myTable.search();
|
}
|
},
|
fifterForm(params) {
|
this.filterFrom = Object.assign(this.filterFrom, params);
|
this.search();
|
},
|
showAdd(id) {
|
let title = '添加';
|
if (id != null) {
|
title = '编辑';
|
}
|
if (!this.tenantName) {
|
this.$message.warning('请选择您要添加人员的机构!');
|
return;
|
}
|
this.editSetting.tenantId = this.tenantId;
|
this.editSetting.tenantName = this.tenantName;
|
this.editSetting.id = id;
|
this.editSetting.title = title;
|
this.editSetting.show = true;
|
},
|
// 删除用户账号
|
del(row) {
|
row.isDelete = 0;
|
this.$modal
|
.confirm('是否要删除"' + row.userName + '"的账号?')
|
.then(function () {
|
user.updateStatus(row).then((res) => {
|
});
|
})
|
.then((res) => {
|
this.$message.success('删除成功!');
|
this.search();
|
})
|
.catch(() => {
|
});
|
},
|
showEditRole(id) {
|
let title = '添加';
|
if (id != null) {
|
title = '编辑角色';
|
}
|
this.editRoleSetting.id = id;
|
this.editRoleSetting.title = title;
|
this.editRoleSetting.show = true;
|
},
|
// 重置
|
reset() {
|
this.filterFrom.tenantCode = null;
|
this.filterFrom.userName = null;
|
this.filterFrom.userCode = null;
|
this.filterFrom.status = 1;
|
this.search(1);
|
},
|
},
|
};
|
</script>
|
|
<style scoped></style>
|