feat:审批

This commit is contained in:
dzc committed 2025-01-12 20:49:49 +08:00
1 parent f5c3e0b0ea
commit cd86ae5521
18 files changed
+2025 -1658

No files matched your search

+136 -121
View File
@@ -1,19 +1,25 @@
<template>
<div class="system-user-dialog-container">
<el-dialog :close-on-click-modal="false" :title="dataForm.userId ? $t('common.editBtn') : $t('common.addBtn')"
draggable v-model="visible">
<el-dialog
:close-on-click-modal="false"
:title="dataForm.userId ? $t('common.editBtn') : $t('common.addBtn')"
draggable
v-model="visible"
>
<el-form :model="dataForm" :rules="dataRules" label-width="90px" ref="dataFormRef" v-loading="loading">
<el-row :gutter="20">
<el-col :span="12" class="mb20">
<el-form-item :label="$t('sysuser.username')" prop="username">
<el-input :disabled="dataForm.userId !== ''" placeholder="请输入用户名"
v-model="dataForm.username"></el-input>
<el-input
:disabled="dataForm.userId !== ''"
placeholder="请输入用户名"
v-model="dataForm.username"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="$t('sysuser.password')" prop="password">
<el-input clearable placeholder="请输入密码" type="password"
v-model="dataForm.password"></el-input>
<el-input clearable placeholder="请输入密码" type="password" v-model="dataForm.password"></el-input>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
@@ -29,24 +35,28 @@
<el-col :span="12" class="mb20">
<el-form-item :label="$t('sysuser.role')" prop="role">
<el-select clearable multiple placeholder="请选择角色" v-model="dataForm.role">
<el-option :key="item.roleId" :label="item.roleName" :value="item.roleId"
v-for="item in roleData" />
<el-option :key="item.roleId" :label="item.roleName" :value="item.roleId" v-for="item in roleData" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="$t('sysuser.post')" prop="post">
<el-select clearable multiple placeholder="请选择岗位" v-model="dataForm.post">
<el-option :key="item.postId" :label="item.postName" :value="item.postId"
v-for="item in postData" />
<el-option :key="item.postId" :label="item.postName" :value="item.postId" v-for="item in postData" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="$t('sysuser.dept')" prop="deptId">
<el-tree-select :data="deptData"
:props="{ value: 'id', label: 'name', children: 'children' }" check-strictly
class="w100" clearable placeholder="请选择所属部门" v-model="dataForm.deptId">
<el-tree-select
:data="deptData"
:props="{ value: 'id', label: 'name', children: 'children' }"
check-strictly
class="w100"
clearable
placeholder="请选择所属部门"
v-model="dataForm.deptId"
>
</el-tree-select>
</el-form-item>
</el-col>
@@ -64,8 +74,9 @@
<el-col :span="12" class="mb20">
<el-form-item :label="$t('sysuser.lockFlag')" prop="lockFlag">
<el-radio-group v-model="dataForm.lockFlag">
<el-radio :key="index" :label="item.value" border v-for="(item, index) in lock_flag">{{
item.label }} </el-radio>
<el-radio :key="index" :label="item.value" border v-for="(item, index) in lock_flag"
>{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
@@ -73,9 +84,10 @@
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
<el-button @click="onSubmit" type="primary" :disabled="loading">{{ $t('common.confirmButtonText')
}}</el-button>
<el-button @click="visible = false">{{ $t("common.cancelButtonText") }}</el-button>
<el-button @click="onSubmit" type="primary" :disabled="loading">{{
$t("common.confirmButtonText")
}}</el-button>
</span>
</template>
</el-dialog>
@@ -83,155 +95,158 @@
</template>
<script lang="ts" name="systemUserDialog" setup>
import { addObj, getObj, putObj, validatePhone, validateUsername } from '/@/api/admin/user';
import { list as roleList } from '/@/api/admin/role';
import { list as postList } from '/@/api/admin/post';
import { deptTree } from '/@/api/admin/dept';
import { useDict } from '/@/hooks/dict';
import { useI18n } from 'vue-i18n';
import { useMessage } from '/@/hooks/message';
import { rule } from '/@/utils/validate';
import { addObj, getObj, putObj, validatePhone, validateUsername } from "/@/api/admin/user"
import { list as roleList } from "/@/api/admin/role"
import { list as postList } from "/@/api/admin/post"
import { deptTree } from "/@/api/admin/dept"
import { useDict } from "/@/hooks/dict"
import { useI18n } from "vue-i18n"
import { useMessage } from "/@/hooks/message"
import { rule } from "/@/utils/validate"
const { t } = useI18n();
const { t } = useI18n()
// 定义刷新表格emit
const emit = defineEmits(['refresh']);
const emit = defineEmits(["refresh"])
// @ts-ignore
const { lock_flag } = useDict('lock_flag');
const { lock_flag } = useDict("lock_flag")
// 定义变量内容
const dataFormRef = ref();
const visible = ref(false);
const deptData = ref<any[]>([]);
const roleData = ref<any[]>([]);
const postData = ref<any[]>([]);
const loading = ref(false);
const dataFormRef = ref()
const visible = ref(false)
const deptData = ref<any[]>([])
const roleData = ref<any[]>([])
const postData = ref<any[]>([])
const loading = ref(false)
const props = defineProps({
deptId: {
type: String,
default: '',
}
});
default: "",
},
})
const dataForm = reactive({
userId: '',
username: '',
password: '' as String | undefined,
salt: '',
wxOpenid: '',
qqOpenid: '',
lockFlag: '0',
phone: '' as String | undefined,
deptId: '',
userId: "",
username: "",
password: "" as String | undefined,
salt: "",
wxOpenid: "",
qqOpenid: "",
lockFlag: "0",
phone: "" as String | undefined,
deptId: "",
roleList: [],
postList: [],
nickname: '',
name: '',
email: '',
nickname: "",
name: "",
email: "",
post: [] as string[],
role: [] as string[],
});
})
const dataRules = ref({
// 用户名校验,不能为空 、长度 5-20、不能和已有数据重复
username: [
{ required: true, message: '用户名不能为空', trigger: 'blur' },
{ min: 5, max: 20, message: '用户名称长度必须介于 5 和 20 之间', trigger: 'blur' },
{ required: true, message: "用户名不能为空", trigger: "blur" },
{ min: 5, max: 20, message: "用户名称长度必须介于 5 和 20 之间", trigger: "blur" },
{
validator: (rule: any, value: any, callback: any) => {
validateUsername(rule, value, callback, dataForm.userId !== '');
validateUsername(rule, value, callback, dataForm.userId !== "")
},
trigger: 'blur',
trigger: "blur",
},
],
password: [
{ required: true, message: '密码不能为空', trigger: 'blur' },
{ required: true, message: "密码不能为空", trigger: "blur" },
{
min: 6,
max: 20,
message: '用户密码长度必须介于 5 和 20 之间',
trigger: 'blur',
message: "用户密码长度必须介于 5 和 20 之间",
trigger: "blur",
},
],
// 姓名校验,不能为空、只能是中文
name: [
{ validator: rule.overLength, trigger: 'blur' },
{ required: true, message: '姓名不能为空', trigger: 'blur' },
{ validator: rule.chinese, trigger: 'blur' },
{ validator: rule.overLength, trigger: "blur" },
{ required: true, message: "姓名不能为空", trigger: "blur" },
{ validator: rule.chinese, trigger: "blur" },
],
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
role: [{ required: true, message: '角色不能为空', trigger: 'blur' }],
post: [{ required: true, message: '岗位不能为空', trigger: 'blur' }],
deptId: [{ required: true, message: "部门不能为空", trigger: "blur" }],
role: [{ required: true, message: "角色不能为空", trigger: "blur" }],
// post: [{ required: true, message: '岗位不能为空', trigger: 'blur' }],
// 手机号校验,不能为空、新增的时不能重复校验
phone: [
{ required: true, message: '手机号不能为空', trigger: 'blur' },
{ validator: rule.validatePhone, trigger: 'blur' },
{ required: true, message: "手机号不能为空", trigger: "blur" },
{ validator: rule.validatePhone, trigger: "blur" },
{
validator: (rule: any, value: any, callback: any) => {
validatePhone(rule, value, callback, dataForm.userId !== '');
validatePhone(rule, value, callback, dataForm.userId !== "")
},
trigger: 'blur',
trigger: "blur",
},
],
email: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }, { validator: rule.overLength, trigger: 'blur' }],
lockFlag: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
});
email: [
{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] },
{ validator: rule.overLength, trigger: "blur" },
],
lockFlag: [{ required: true, message: "状态不能为空", trigger: "blur" }],
})
// 打开弹窗
const openDialog = async (id: string) => {
visible.value = true;
dataForm.userId = '';
visible.value = true
dataForm.userId = ""
// 重置表单数据
nextTick(() => {
dataFormRef.value?.resetFields();
});
dataFormRef.value?.resetFields()
})
// 修改获取用户信息
if (id) {
dataForm.userId = id;
await getUserData(id);
dataForm.password = '******';
dataForm.userId = id
await getUserData(id)
dataForm.password = "******"
}
// 加载使用的数据
getDeptData();
getPostData();
getRoleData();
};
getDeptData()
getPostData()
getRoleData()
}
// 提交
const onSubmit = async () => {
const valid = await dataFormRef.value.validate().catch(() => { });
if (!valid) return false;
const valid = await dataFormRef.value.validate().catch(() => {})
if (!valid) return false
try {
const { userId, phone, password } = dataForm;
const { userId, phone, password } = dataForm
if (userId) {
// 清除占位符,避免提交错误的数据
if (phone?.includes('*')) dataForm.phone = undefined;
if (password?.includes('******')) dataForm.password = undefined;
if (phone?.includes("*")) dataForm.phone = undefined
if (password?.includes("******")) dataForm.password = undefined
loading.value = true;
await putObj(dataForm);
useMessage().success(t('common.editSuccessText'));
visible.value = false; // 关闭弹窗
emit('refresh');
loading.value = true
await putObj(dataForm)
useMessage().success(t("common.editSuccessText"))
visible.value = false // 关闭弹窗
emit("refresh")
} else {
loading.value = true;
await addObj(dataForm);
useMessage().success(t('common.addSuccessText'));
visible.value = false; // 关闭弹窗
emit('refresh');
loading.value = true
await addObj(dataForm)
useMessage().success(t("common.addSuccessText"))
visible.value = false // 关闭弹窗
emit("refresh")
}
} catch (error: any) {
useMessage().error(error.msg);
useMessage().error(error.msg)
} finally {
loading.value = false;
loading.value = false
}
};
}
/**
* 从服务器获取用户数据
@@ -242,57 +257,57 @@ const onSubmit = async () => {
*/
const getUserData = async (id: string) => {
try {
loading.value = true;
const { data } = await getObj(id);
Object.assign(dataForm, data);
loading.value = true
const { data } = await getObj(id)
Object.assign(dataForm, data)
if (data.roleList) {
dataForm.role = data.roleList.map((item) => item.roleId);
dataForm.role = data.roleList.map((item) => item.roleId)
}
if (data.postList) {
dataForm.post = data.postList.map((item) => item.postId);
dataForm.post = data.postList.map((item) => item.postId)
}
} catch (err: any) {
useMessage().error(err.msg);
useMessage().error(err.msg)
} finally {
loading.value = false;
loading.value = false
}
};
}
// 初始化部门数据
const getDeptData = () => {
// 获取部门数据
deptTree().then((res) => {
deptData.value = res.data;
deptData.value = res.data
// 默认选择在树中选中的部门
if (!dataForm.userId) {
dataForm.deptId = props.deptId;
dataForm.deptId = props.deptId
}
});
};
})
}
// 岗位数据
const getPostData = () => {
postList().then((res) => {
postData.value = res.data;
postData.value = res.data
// 默认选择第一个
if (!dataForm.userId) {
dataForm.post = [res.data[0].postId];
dataForm.post = [res.data[0].postId]
}
});
};
})
}
// 角色数据
const getRoleData = () => {
roleList().then((res) => {
roleData.value = res.data;
roleData.value = res.data
// 默认选择第一个
if (!dataForm.userId) {
dataForm.role = [res.data[0].roleId];
dataForm.role = [res.data[0].roleId]
}
});
};
})
}
// 暴露变量
defineExpose({
openDialog,
});
})
</script>
+170 -116
View File
@@ -4,13 +4,23 @@
<pane size="15">
<div class="layout-padding-auto layout-padding-view">
<el-scrollbar>
<query-tree :placeholder="$t('common.queryDeptTip')" :query="deptData.queryList"
:show-expand="true" @node-click="handleNodeClick">
<query-tree
:placeholder="$t('common.queryDeptTip')"
:query="deptData.queryList"
:show-expand="true"
@node-click="handleNodeClick"
>
<!-- 没有数据权限提示 -->
<template #default="{ node, data }">
<el-tooltip v-if="data.isLock" class="item" effect="dark"
:content="$t('sysuser.noDataScopeTip')" placement="right-start">
<span>{{ node.label }}
<el-tooltip
v-if="data.isLock"
class="item"
effect="dark"
:content="$t('sysuser.noDataScopeTip')"
placement="right-start"
>
<span
>{{ node.label }}
<SvgIcon name="ele-Lock" />
</span>
</el-tooltip>
@@ -25,68 +35,97 @@
<el-row v-show="showSearch">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-form-item :label="$t('sysuser.username')" prop="username">
<el-input v-model="state.queryForm.username"
:placeholder="$t('sysuser.inputUsernameTip')" clearable />
<el-input v-model="state.queryForm.username" :placeholder="$t('sysuser.inputUsernameTip')" clearable />
</el-form-item>
<el-form-item :label="$t('sysuser.phone')" prop="phone">
<el-input v-model="state.queryForm.phone" :placeholder="$t('sysuser.inputPhoneTip')"
clearable />
<el-input v-model="state.queryForm.phone" :placeholder="$t('sysuser.inputPhoneTip')" clearable />
</el-form-item>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t('common.queryBtn')
}}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t("common.queryBtn") }}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button v-auth="'sys_user_add'" icon="folder-add" type="primary"
@click="userDialogRef.openDialog()">
{{ $t('common.addBtn') }}
<el-button v-auth="'sys_user_add'" icon="folder-add" type="primary" @click="userDialogRef.openDialog()">
{{ $t("common.addBtn") }}
</el-button>
<el-button plain v-auth="'sys_user_add'" class="ml10" icon="upload-filled" type="primary"
@click="excelUploadRef.show()">
{{ $t('common.importBtn') }}
<el-button
plain
v-auth="'sys_user_add'"
class="ml10"
icon="upload-filled"
type="primary"
@click="excelUploadRef.show()"
>
{{ $t("common.importBtn") }}
</el-button>
<el-button plain v-auth="'sys_user_del'" :disabled="multiple" class="ml10" icon="Delete"
type="primary" @click="handleDelete(selectObjs)">
{{ $t('common.delBtn') }}
<el-button
plain
v-auth="'sys_user_del'"
:disabled="multiple"
class="ml10"
icon="Delete"
type="primary"
@click="handleDelete(selectObjs)"
>
{{ $t("common.delBtn") }}
</el-button>
<right-toolbar v-model:showSearch="showSearch" :export="'sys_user_export'"
@exportExcel="exportExcel" @queryTable="getDataList" class="ml10 mr20"
style="float: right" />
<right-toolbar
v-model:showSearch="showSearch"
:export="'sys_user_export'"
@exportExcel="exportExcel"
@queryTable="getDataList"
class="ml10 mr20"
style="float: right"
/>
</div>
</el-row>
<el-table v-loading="state.loading" :data="state.dataList" @selection-change="handleSelectionChange"
row-key="userId" border :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle">
<el-table
v-loading="state.loading"
:data="state.dataList"
@selection-change="handleSelectionChange"
row-key="userId"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
>
<el-table-column :selectable="handleSelectable" type="selection" width="40" />
<el-table-column :label="$t('sysuser.index')" type="index" width="60" fixed="left" />
<el-table-column :label="$t('sysuser.username')" prop="username" fixed="left"
show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysuser.name')" prop="name"
show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysuser.phone')" prop="phone"
show-overflow-tooltip></el-table-column>
<el-table-column
:label="$t('sysuser.username')"
prop="username"
fixed="left"
show-overflow-tooltip
></el-table-column>
<el-table-column :label="$t('sysuser.name')" prop="name" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysuser.phone')" prop="phone" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysuser.post')" show-overflow-tooltip>
<template #default="scope">
<el-tag v-for="(item, index) in scope.row.postList" :key="index">{{ item.postName
}}</el-tag>
<el-tag v-for="(item, index) in scope.row.postList" :key="index">{{ item.postName }}</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.role')" show-overflow-tooltip>
<template #default="scope">
<el-tag v-for="(item, index) in scope.row.roleList" :key="index">{{ item.roleName
}}</el-tag>
<el-tag v-for="(item, index) in scope.row.roleList" :key="index">{{ item.roleName }}</el-tag>
</template>
</el-table-column>
<el-table-column width="80" label="人脸">
<template #default="{ row }">
<preview-image :src="row.faceImgs" />
</template>
</el-table-column>
<el-table-column :label="$t('sysuser.lockFlag')" show-overflow-tooltip>
<template #default="scope">
<el-switch v-model="scope.row.lockFlag" @change="changeSwitch(scope.row)"
active-value="0" inactive-value="9"></el-switch>
<el-switch
v-model="scope.row.lockFlag"
@change="changeSwitch(scope.row)"
active-value="0"
inactive-value="9"
></el-switch>
</template>
</el-table-column>
<el-table-column :label="$t('common.action')" width="300" fixed="right">
@@ -95,29 +134,40 @@
<!-- 重置密码 -->
<popover-input v-model="inputPassword" @confirm="changePassword(scope.row)">
<template #default>
<el-button v-auth="'sys_user_edit'" icon="RefreshLeft" text type="primary"
class="mr-4">
{{ $t('sysuser.passwordBtn') }}
<el-button v-auth="'sys_user_edit'" icon="RefreshLeft" text type="primary" class="mr-4">
{{ $t("sysuser.passwordBtn") }}
</el-button>
</template>
</popover-input>
<!-- 修改信息 -->
<el-button v-auth="'sys_user_edit'" icon="edit-pen" text type="primary"
@click="userDialogRef.openDialog(scope.row.userId)">
{{ $t('common.editBtn') }}
<el-button
v-auth="'sys_user_edit'"
icon="edit-pen"
text
type="primary"
@click="userDialogRef.openDialog(scope.row.userId)"
>
{{ $t("common.editBtn") }}
</el-button>
<!-- 人脸管理 -->
<el-button icon="User" text type="primary"
@click="faceManageRef.openDialog(scope.row.userId)">
<el-button icon="User" text type="primary" @click="faceManageRef.openDialog(scope.row.userId)">
人脸管理
</el-button>
<!-- 删除用户 -->
<el-tooltip :content="$t('sysuser.deleteDisabledTip')"
:disabled="scope.row.userId !== '1'" placement="top">
<el-tooltip
:content="$t('sysuser.deleteDisabledTip')"
:disabled="scope.row.userId !== '1'"
placement="top"
>
<span style="margin-left: 12px">
<el-button icon="delete" v-auth="'sys_user_del'"
:disabled="scope.row.username === 'admin'" text type="primary"
@click="handleDelete([scope.row.userId])">{{ $t('common.delBtn') }}
<el-button
icon="delete"
v-auth="'sys_user_del'"
:disabled="scope.row.username === 'admin'"
text
type="primary"
@click="handleDelete([scope.row.userId])"
>{{ $t("common.delBtn") }}
</el-button>
</span>
</el-tooltip>
@@ -125,8 +175,7 @@
</template>
</el-table-column>
</el-table>
<pagination v-bind="state.pagination" @current-change="currentChangeHandle"
@size-change="sizeChangeHandle">
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle">
</pagination>
</div>
</pane>
@@ -136,126 +185,131 @@
<face-manage ref="faceManageRef" @refresh="getDataList(false)" />
<upload-excel ref="excelUploadRef" :title="$t('sysuser.importUserTip')"
temp-url="/admin/sys-file/local/file/user.xlsx" url="/admin/user/import" @refreshDataList="getDataList" />
<upload-excel
ref="excelUploadRef"
:title="$t('sysuser.importUserTip')"
temp-url="/admin/sys-file/local/file/user.xlsx"
url="/admin/user/import-face"
@refreshDataList="getDataList"
/>
</div>
</template>
<script lang="ts" name="systemUser" setup>
import { delObj, pageList, putObj } from '/@/api/admin/user';
import { deptTree } from '/@/api/admin/dept';
import { BasicTableProps, useTable } from '/@/hooks/table';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useI18n } from 'vue-i18n';
import { delObj, pageList, putObj } from "/@/api/admin/user"
import { deptTree } from "/@/api/admin/dept"
import { BasicTableProps, useTable } from "/@/hooks/table"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useI18n } from "vue-i18n"
// 动态引入组件
const UserForm = defineAsyncComponent(() => import('./form.vue'));
const FaceManage = defineAsyncComponent(() => import('./face-manage.vue'));
const QueryTree = defineAsyncComponent(() => import('/@/components/QueryTree/index.vue'));
const PopoverInput = defineAsyncComponent(() => import('/@/components/PopoverInput/index.vue'));
const UserForm = defineAsyncComponent(() => import("./form.vue"))
const FaceManage = defineAsyncComponent(() => import("./face-manage.vue"))
const QueryTree = defineAsyncComponent(() => import("/@/components/QueryTree/index.vue"))
const PopoverInput = defineAsyncComponent(() => import("/@/components/PopoverInput/index.vue"))
const { t } = useI18n();
const { t } = useI18n()
// 定义变量内容
const userDialogRef = ref();
const faceManageRef = ref();
const excelUploadRef = ref();
const queryRef = ref();
const showSearch = ref(true);
const inputPassword = ref();
const userDialogRef = ref()
const faceManageRef = ref()
const excelUploadRef = ref()
const queryRef = ref()
const showSearch = ref(true)
const inputPassword = ref()
// 多选rows
const selectObjs = ref([]) as any;
const selectObjs = ref([]) as any
// 是否可以多选
const multiple = ref(true);
const multiple = ref(true)
// 定义表格查询、后台调用的API
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
deptId: '',
username: '',
phone: '',
deptId: "",
username: "",
phone: "",
},
pageList: pageList,
});
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile, tableStyle } = useTable(state);
})
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile, tableStyle } = useTable(state)
// 部门树使用的数据
const deptData = reactive({
queryList: (name: String) => {
return deptTree({
deptName: name,
});
})
},
});
})
// 清空搜索条件
const resetQuery = () => {
queryRef.value?.resetFields();
state.queryForm.deptId = '';
getDataList();
};
queryRef.value?.resetFields()
state.queryForm.deptId = ""
getDataList()
}
// 点击树
const handleNodeClick = (e: any) => {
state.queryForm.deptId = e.id;
getDataList();
};
state.queryForm.deptId = e.id
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile('/admin/user/export', Object.assign(state.queryForm, { ids: selectObjs }), 'users.xlsx');
};
downBlobFile("/admin/user/export", Object.assign(state.queryForm, { ids: selectObjs }), "users.xlsx")
}
// 是否可以多选
const handleSelectable = (row: any) => {
return row.username !== 'admin';
};
return row.username !== "admin"
}
// 多选事件
const handleSelectionChange = (objs: { userId: string }[]) => {
selectObjs.value = objs.map(({ userId }) => userId);
multiple.value = !objs.length;
};
selectObjs.value = objs.map(({ userId }) => userId)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm(t('common.delConfirmText'));
await useMessageBox().confirm(t("common.delConfirmText"))
} catch {
return;
return
}
try {
await delObj(ids);
getDataList();
useMessage().success(t('common.delSuccessText'));
await delObj(ids)
getDataList()
useMessage().success(t("common.delSuccessText"))
} catch (err: any) {
useMessage().error(err.msg);
useMessage().error(err.msg)
}
};
}
//表格内开关 (用户状态)
const changeSwitch = async (row: any) => {
// 不修改密码
row.password = undefined;
row.phone = undefined;
await putObj(row);
useMessage().success(t('common.optSuccessText'));
getDataList();
};
row.password = undefined
row.phone = undefined
await putObj(row)
useMessage().success(t("common.optSuccessText"))
getDataList()
}
//修改用户密码
const changePassword = async (row: any) => {
if (!inputPassword.value || inputPassword.value.length < 6 || inputPassword.value.length > 20) {
useMessage().error(t('sysuser.inputPasswordTip'));
return;
useMessage().error(t("sysuser.inputPasswordTip"))
return
}
row.phone = undefined;
row.password = inputPassword.value;
await putObj(row);
useMessage().success(t('common.optSuccessText'));
getDataList();
};
row.phone = undefined
row.password = inputPassword.value
await putObj(row)
useMessage().success(t("common.optSuccessText"))
getDataList()
}
</script>