| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <el-container class="is-vertical">
- <sc-page-header @add="table_add"></sc-page-header>
- <el-container class="user-container">
- <el-aside width="310px">
- <el-header>
- <el-input v-model="filterText" clearable placeholder="输入关键字进行过滤"></el-input>
- <el-button title="重置部门" circle @click="dept_unset">
- <template #icon><sc-iconify icon="iconoir:remove-link"></sc-iconify></template>
- </el-button>
- </el-header>
- <el-main class="nopadding">
- <el-scrollbar>
- <el-tree ref="treeRef" node-key="id" :data="deptTree" :expand-on-click-node="false" highlight-current check-strictly :filter-node-method="filterNode" @node-click="data => nodeClick(data)">
- <template #default="{ data }">
- <vxe-text-ellipsis :id="data.id" :title="data.name" class="custom-tree-node" :content="data.name"></vxe-text-ellipsis>
- </template>
- </el-tree>
- </el-scrollbar>
- </el-main>
- </el-aside>
- <scTable ref="xGridTable" :apiObj="$API.auth.user" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns">
- <template #action="{ row }">
- <el-button type="primary" link @click="password_rest(row)">
- <template #icon><sc-iconify icon="material-symbols:arrow-split"></sc-iconify></template>重置密码
- </el-button>
- <el-button type="primary" link @click="table_edit(row)">
- <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
- </el-button>
- <el-button type="primary" link @click="table_del(row)">
- <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
- </el-button>
- </template>
- </scTable>
- </el-container>
- </el-container>
- <user-detail v-if="dialog" ref="userRef" :deptTree="deptTree" @success="refreshTable" @closed="dialog = false"></user-detail>
- </template>
- <script setup>
- import XEUtils from "xe-utils";
- import API from "@/api";
- import { mapFormItemInput } from "@/components/scTable/helper";
- import userDetail from "./detail";
- const filterText = ref("");
- const deptTree = ref([]);
- const treeRef = ref();
- watch(() => filterText.value, value => treeRef.value.filter(value));
- const filterNode = (value, data) => {
- if (!value) return true;
- return data.name.includes(value);
- }
- const nodeClick = data => {
- XEUtils.set(formConfig.data, "deptId", data.id);
- refreshTable();
- }
- const dept_unset = () => {
- treeRef.value.setCurrentKey();
- XEUtils.set(formConfig.data, "deptId", null);
- refreshTable();
- }
- const toolbarConfig = reactive({
- enabled: true,
- export: true
- });
- const formConfig = reactive({
- data: {},
- items: [
- mapFormItemInput("usernameLike", "用户名"),
- mapFormItemInput("nickNameLike", "用户昵称"),
- mapFormItemInput("phoneLike", "手机号")
- ]
- });
- const paramsColums = reactive([
- { column: "orderBy", defaultValue: "id_desc" },
- { column: "deptId" },
- { column: "usernameLike" },
- { column: "nickNameLike" },
- { column: "phoneLike" }
- ]);
- const columns = reactive([
- { type: "seq", width: 60 },
- { type: "html", field: "username", title: "用户名", minWidth: 160, sortable: true },
- { type: "html", field: "nickName", title: "用户昵称", minWidth: 160, sortable: true },
- { type: "html", field: "dept.name", title: "所属部门", minWidth: 160, sortable: true },
- { type: "html", field: "gender", title: "性别", minWidth: 100, sortable: true },
- { type: "html", field: "phone", title: "手机号", minWidth: 120, sortable: true },
- { type: "html", field: "email", title: "邮箱", minWidth: 160, sortable: true },
- { visible: false, type: "html", field: "idcard", title: "身份证号", minWidth: 160, sortable: true, formatter: ({ cellValue, row }) => cellValue || XEUtils.get(XEUtils.toStringJSON(row.features), "idcard") },
- { title: "操作", fixed: "right", width: 220, align: "center", slots: { default: "action" } }
- ]);
- // 显示隐藏 筛选表单
- const xGridTable = ref();
- const refreshTable = (mode = "add") => xGridTable.value.searchData(mode);
- const userRef = ref();
- const dialog = ref(false);
- const table_add = () => {
- dialog.value = true;
- nextTick(() => userRef.value?.open());
- }
- const table_edit = row => {
- dialog.value = true;
- nextTick(() => userRef.value?.setData(row));
- }
- const table_del = ({ id }) => {
- ElMessageBox.confirm("是否确认删除该用户?", "删除警告", {
- type: "warning",
- confirmButtonText: "确定",
- cancelButtonText: "取消"
- }).then(() => {
- API.auth.user.del(({ id })).then(() => {
- ElMessage.success("操作成功");
- refreshTable();
- });
- }).catch(() => {});
- }
- const password_rest = ({ id, username }) => {
- ElMessageBox.confirm(`是否确认重置"${username}"密码?`, "重置密码", {
- type: "warning",
- confirmButtonText: "确定",
- cancelButtonText: "取消"
- }).then(() => {
- API.auth.user.resetPass(({ id })).then(() => {
- ElNotification.success({
- title: "提示",
- message: `密码已重置,密码为:123456`,
- duration: 1500
- });
- });
- }).catch(() => {});
- }
- const fetchDept = () => API.system.dept.get({ orderBy: "deptSort_asc" }).then(res => deptTree.value = XEUtils.toArrayTree(res, { parentKey: "pid" })).catch(() => deptTree.value = []);
- fetchDept();
- </script>
- <style lang="scss" scoped>
- .user-container {border-top: 1px solid var(--el-border-color-light);}
- .user-container .el-aside {display: flex;flex-direction: column;}
- .user-container .el-aside .el-header .el-button {margin-left: 10px;}
- .user-container .el-aside .el-main {padding-top: 15px;padding-left: 15px;}
- .user-container .el-aside + .el-main {padding-top: 15px;}
- @media (max-width: 992px) {
- .aminui-main > .el-container > .el-container.user-container {display: block;margin-top: 0;border: none;}
- .user-container .el-aside {width: 100%;}
- .user-container .el-aside .el-main {padding-bottom: 15px;}
- .user-container .el-aside + .el-main {margin-top: 15px;}
- }
- </style>
|