<template>
|
<div class="home-container">
|
<div style="height: 100%">
|
<el-row class="homeCard">
|
<el-cascader
|
v-model="userTableData.listQuery.searchParams.depId"
|
:props="props"
|
:options="departmentList"
|
:show-all-levels="false"
|
placeholder="请选择部门"
|
clearable
|
size="default"
|
></el-cascader>
|
<el-input size="default" v-model.trim="userTableData.listQuery.searchParams.username" placeholder="请输入用户名" style="max-width: 180px;margin-left: 10px;margin-right: 10px"> </el-input>
|
<el-input size="default" v-model.trim="userTableData.listQuery.searchParams.realName" placeholder="请输入真实姓名" style="max-width: 180px"> </el-input>
|
<el-button size="default" type="primary" class="ml10" @click="initUserTableData">
|
<el-icon>
|
<ele-Search />
|
</el-icon>
|
查询
|
</el-button>
|
</el-row>
|
<div class="homeCard">
|
<div class="main-card">
|
<el-table :data="userTableData.data" style="width: 100%" height="calc(100% - 48px)" :header-cell-style="{ background: '#fafafa' }">
|
<el-table-column type="index" label="序号" width="60" />
|
<el-table-column prop="username" label="用户名" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="realName" label="真实姓名" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="depName" label="部门" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="phone" label="手机号" show-overflow-tooltip></el-table-column>
|
<!-- <el-table-column prop="email" label="证书编号" show-overflow-tooltip></el-table-column>-->
|
<!-- <el-table-column prop="expireTime" label="证书有效期至" show-overflow-tooltip></el-table-column>-->
|
<el-table-column label="操作" width="140">
|
<template #default="scope">
|
<el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary" @click="onOpenUserDialog('查看', scope.row)">查看</el-button>
|
<el-button size="small" text type="primary" @click="onCertificate(scope.row)">证书管理</el-button>
|
<!-- <el-button style="color: red" :disabled="scope.row.userName === 'admin'" size="small" text type="primary" @click="onRowDel(scope.row)">删除</el-button>-->
|
</template>
|
</el-table-column>
|
</el-table>
|
<div class="pageBtn">
|
<el-pagination @size-change="onHandleSizeChange" small="false" @current-change="onHandleCurrentChange" class="page-position" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="userTableData.listQuery.pageIndex" background v-model:page-size="userTableData.listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="userTableData.total"> </el-pagination>
|
</div>
|
</div>
|
</div>
|
</div>
|
<userDialog ref="userRef" @getUserList="initUserTableData" />
|
<dialog-certificate ref="ctfRef" @getUserList="initUserTableData"></dialog-certificate>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
import userDialog from '/@/views/newSpecialWorkSystem/workerManage/component/userDialog.vue';
|
import dialogCertificate from "/@/views/system/user/component/dialogCertificate.vue";
|
import { userApi } from '/@/api/systemManage/user';
|
import { dutyApi } from '/@/api/systemManage/duty';
|
import { departmentApi } from '/@/api/systemManage/department';
|
import { useRoleApi } from '/@/api/systemManage/role';
|
import {workerManageApi} from "/@/api/specialWorkSystem/workerManage";
|
|
// 定义接口来定义对象的类型
|
interface TableDataRow {
|
userName: string;
|
userNickname: string;
|
roleSign: string;
|
department: string[];
|
phone: string;
|
email: string;
|
sex: string;
|
password: string;
|
overdueTime: Date;
|
status: boolean;
|
describe: string;
|
createTime: string;
|
}
|
interface DepartmentDataRow {}
|
interface TableDataState {
|
userTableData: {
|
data: Array<TableDataRow>;
|
total: number;
|
loading: boolean;
|
listQuery: {
|
searchParams: {
|
depId: string | null;
|
username: string | null;
|
realName: string | null;
|
};
|
pageIndex: number;
|
pageSize: number;
|
};
|
};
|
departmentList: [];
|
roleList: [];
|
dutyList: [];
|
userTypeList: Array<{id:number,name:string}>;
|
props:{}
|
}
|
|
export default defineComponent({
|
name: 'systemUser',
|
components: { userDialog, dialogCertificate },
|
setup() {
|
const userRef = ref();
|
const ctfRef = ref()
|
const state = reactive<TableDataState>({
|
userTableData: {
|
data: [],
|
total: 0,
|
loading: false,
|
listQuery: {
|
searchParams: {
|
depId: null,
|
username: null,
|
realName: null
|
},
|
pageIndex: 1,
|
pageSize: 10
|
}
|
},
|
departmentList: [],
|
roleList: [],
|
dutyList: [],
|
props: {
|
label: 'depName',
|
value: 'depId',
|
checkStrictly: true,
|
emitPath: false
|
},
|
userTypeList: [
|
{ id: 1, name: '超级管理员' },
|
{ id: 2, name: '管理员' },
|
{ id: 3, name: '普通员工' }
|
]
|
});
|
// 初始化表格数据
|
const initUserTableData = async () => {
|
let res = await workerManageApi().getHeaderListPage(state.userTableData.listQuery);
|
if (res.data.code === '200') {
|
state.userTableData.data = res.data.data;
|
state.userTableData.total = res.data.total;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
// 回显职务信息
|
const parseNumber = (value: number) => {
|
return state.dutyList.find((i) => i.positionId === value)?.positionName;
|
};
|
const getDepartmentData = async () => {
|
let res = await departmentApi().getDepartmentList();
|
if (res.data.code === '200') {
|
state.departmentList = res.data.data;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
const getRoleData = async () => {
|
let res = await useRoleApi().getRoleList();
|
if (res.data.code === '200') {
|
state.roleList = res.data.data;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
const getDutyData = async () => {
|
let res = await dutyApi().getAllList({positionName: '',positionCode: ''});
|
if (res.data.code === '200') {
|
state.dutyList = res.data.data;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
// 打开新增修改用户弹窗
|
const onOpenUserDialog = (type: string, value: any) => {
|
userRef.value.openDialog(type, value, state.departmentList, state.roleList, state.dutyList);
|
};
|
|
const onCertificate = (value: any)=>{
|
ctfRef.value.openDialog(value);
|
}
|
|
// 删除用户
|
const onRowDel = (row: TableDataRow) => {
|
ElMessageBox.confirm(`此操作将永久删除账户名称:“${row.realName}”,是否继续?`, '提示', {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(async () => {
|
let res = await userApi().deleteUser({ uid: row.uid });
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
duration: 2000,
|
message: '删除成功'
|
});
|
await initUserTableData();
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
})
|
.catch(() => {});
|
};
|
// 分页改变
|
const onHandleSizeChange = (val: number) => {
|
state.userTableData.listQuery.pageSize = val;
|
initUserTableData();
|
};
|
// 分页改变
|
const onHandleCurrentChange = (val: number) => {
|
state.userTableData.listQuery.pageIndex = val;
|
initUserTableData();
|
};
|
// 页面加载时
|
onMounted(() => {
|
initUserTableData();
|
getDepartmentData();
|
getRoleData();
|
getDutyData()
|
});
|
return {
|
userRef,
|
ctfRef,
|
onOpenUserDialog,
|
onCertificate,
|
onRowDel,
|
parseNumber,
|
onHandleSizeChange,
|
initUserTableData,
|
onHandleCurrentChange,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|
<style lang="scss" scoped>
|
.home-container {
|
height: calc(100vh - 144px);
|
box-sizing: border-box;
|
overflow: hidden;
|
.demo-tabs {
|
width: 100%;
|
height: 100%;
|
|
&::v-deep(.el-tabs__content) {
|
height: calc(100% - 60px);
|
}
|
|
.el-tab-pane {
|
height: 100%;
|
}
|
}
|
.homeCard {
|
width: 100%;
|
padding: 20px;
|
box-sizing: border-box;
|
background: #fff;
|
border-radius: 4px;
|
|
.main-card {
|
width: 100%;
|
height: 100%;
|
.cardTop {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 20px;
|
.mainCardBtn {
|
margin: 0;
|
}
|
}
|
.pageBtn {
|
height: 60px;
|
display: flex;
|
align-items: center;
|
justify-content: right;
|
|
.demo-pagination-block + .demo-pagination-block {
|
margin-top: 10px;
|
}
|
.demo-pagination-block .demonstration {
|
margin-bottom: 16px;
|
}
|
}
|
}
|
&:last-of-type {
|
height: calc(100% - 100px);
|
}
|
}
|
.el-row {
|
display: flex;
|
align-items: center;
|
margin-bottom: 20px;
|
&:last-child {
|
margin-bottom: 0;
|
}
|
.grid-content {
|
align-items: center;
|
min-height: 36px;
|
}
|
|
.topInfo {
|
display: flex;
|
align-items: center;
|
font-size: 16px;
|
font-weight: bold;
|
|
& > div {
|
white-space: nowrap;
|
margin-right: 20px;
|
}
|
}
|
}
|
.el-card {
|
border: 0;
|
}
|
}
|
</style>
|