372 lines
12 KiB
Vue
372 lines
12 KiB
Vue
<template>
|
|
<div class="layout-padding">
|
|
<div class="layout-padding-auto layout-padding-view">
|
|
<DraggableDepTree
|
|
ref="draggableDepTreeRef"
|
|
placeholder="请输入部门名称"
|
|
:show-expand="true"
|
|
@getSelectNode="handleGetSelectNode"
|
|
switch-inactive-text="包含"
|
|
switch-active-text="不包含"
|
|
:defaultTreeWidth="20"
|
|
:nodeClickable="false"
|
|
>
|
|
<template #default>
|
|
<el-row v-show="showSearch">
|
|
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
|
<el-form-item style="width: 250px" label="用户" prop="userId">
|
|
<select-user v-model="state.queryForm.userId" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="用户名" prop="username">
|
|
<el-input v-model="state.queryForm.username" placeholder="请输入用户名" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="手机号" prop="phone">
|
|
<el-input v-model="state.queryForm.phone" placeholder="请输入手机号" clearable />
|
|
</el-form-item>
|
|
<el-form-item style="width: 250px" label="部门" prop="deptId">
|
|
<select-dept v-model="state.queryForm.deptId" clearable />
|
|
</el-form-item>
|
|
<el-form-item style="width: 250px" label="角色" prop="role">
|
|
<select-role v-model="state.queryForm.role" clearable />
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button icon="Search" type="primary" @click="getDataList">查询</el-button>
|
|
<el-button icon="Refresh" @click="resetQuery">重置</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()">新增</el-button>
|
|
<el-button plain v-auth="'sys_user_export'" class="ml10" icon="upload-filled" type="primary" @click="excelUploadRef.show()">
|
|
导入
|
|
</el-button>
|
|
<el-button
|
|
plain
|
|
v-auth="'sys_user_del'"
|
|
:disabled="multiple"
|
|
class="ml10"
|
|
icon="Delete"
|
|
type="primary"
|
|
@click="handleDelete(selectObjs)"
|
|
>
|
|
删除
|
|
</el-button>
|
|
<el-button
|
|
plain
|
|
v-auth="'sys_user_del'"
|
|
v-if="activeName == '1'"
|
|
:disabled="multiple"
|
|
class="ml10"
|
|
icon="VideoPlay"
|
|
type="primary"
|
|
@click="doBatchDeal"
|
|
>
|
|
审批
|
|
</el-button>
|
|
<div class="flex justify-between items-center">
|
|
<el-tabs class="flex-1" v-model="activeName" @tab-click="handleClickTabItem">
|
|
<el-tab-pane v-for="v in tabItems" :key="v.id" :label="v.label" :name="v.value" />
|
|
</el-tabs>
|
|
|
|
<right-toolbar
|
|
v-model:showSearch="showSearch"
|
|
:export="'sys_user_export'"
|
|
@exportExcel="exportExcel"
|
|
@queryTable="getDataList"
|
|
class="ml10"
|
|
style="float: right"
|
|
/>
|
|
</div>
|
|
</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-column :selectable="handleSelectable" type="selection" width="40" />
|
|
<el-table-column label="#" type="index" width="60" fixed="left" />
|
|
<el-table-column label="用户名" prop="username" fixed="left" show-overflow-tooltip />
|
|
<el-table-column label="姓名" prop="name" show-overflow-tooltip min-width="150" />
|
|
<el-table-column label="手机号" prop="phone" show-overflow-tooltip min-width="150" />
|
|
<el-table-column label="部门" prop="deptName" show-overflow-tooltip min-width="150" />
|
|
<el-table-column label="角色" show-overflow-tooltip min-width="150">
|
|
<template #default="scope">
|
|
<el-tag v-for="(item, index) in scope.row.roleList" :key="index">{{ item.roleName }}</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="启用" show-overflow-tooltip min-width="150">
|
|
<template #default="{ row }">
|
|
<el-switch
|
|
:disabled="!auth('sys_user_edit') || row.processStatus != '2'"
|
|
v-model="row.lockFlag"
|
|
@change="changeSwitch(row)"
|
|
active-value="0"
|
|
inactive-value="9"
|
|
></el-switch>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="人脸">
|
|
<template #default="{ row }">
|
|
<preview-image :src="row.faceImgs" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column v-if="false" label="全局人脸" show-overflow-tooltip>
|
|
<template #default="{ row }">
|
|
<el-switch
|
|
:disabled="!auth('userFace_sysUserFace_global_face')"
|
|
v-if="row.isGlobalFace"
|
|
v-model="row.isGlobalFace"
|
|
@change="changeGlobalFaceSwitch(row)"
|
|
active-value="1"
|
|
inactive-value="0"
|
|
/>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
v-auths="['sys_user_edit', 'userFace_sysUserFace_view', 'sys_user_del']"
|
|
label="操作"
|
|
min-width="300"
|
|
width="300"
|
|
fixed="right"
|
|
>
|
|
<template #default="{ row }">
|
|
<div style="display: flex; justify-content: center">
|
|
<!-- 重置密码 -->
|
|
<popover-input v-if="row.processStatus == '2'" v-model="inputPassword" @confirm="changePassword(row)">
|
|
<template #default>
|
|
<el-button v-auth="'sys_user_edit'" icon="RefreshLeft" text type="primary" class="mr-4">密码</el-button>
|
|
</template>
|
|
</popover-input>
|
|
<!-- 修改信息 -->
|
|
<el-button
|
|
v-if="row.processStatus == '2'"
|
|
v-auth="'sys_user_edit'"
|
|
icon="edit-pen"
|
|
text
|
|
type="primary"
|
|
@click="userDialogRef.openDialog(row.userId)"
|
|
>
|
|
修改
|
|
</el-button>
|
|
<!-- 人脸管理 -->
|
|
<el-button
|
|
v-if="row.processStatus == '2'"
|
|
v-auth="'userFace_sysUserFace_view'"
|
|
icon="User"
|
|
text
|
|
type="primary"
|
|
@click="faceManageRef.openDialog(row.userId)"
|
|
>
|
|
人脸管理
|
|
</el-button>
|
|
<el-button v-if="row.processStatus == 1" type="primary" size="small" link icon="VideoPlay" @click="deal(row)">
|
|
开始处理
|
|
</el-button>
|
|
<!-- 删除用户 -->
|
|
<el-tooltip content="admin 不允许被删除" :disabled="row.userId !== '1'" placement="top">
|
|
<span style="margin-left: 12px">
|
|
<el-button
|
|
icon="delete"
|
|
v-auth="'sys_user_del'"
|
|
:disabled="row.username === 'admin'"
|
|
text
|
|
type="primary"
|
|
@click="handleDelete([row.userId])"
|
|
>
|
|
删除
|
|
</el-button>
|
|
</span>
|
|
</el-tooltip>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
|
|
</template>
|
|
</DraggableDepTree>
|
|
</div>
|
|
|
|
<user-form ref="userDialogRef" @refresh="getDataList(false)" :deptId="state.queryForm.deptId" />
|
|
<face-manage ref="faceManageRef" @refresh="getDataList(false)" />
|
|
<upload-excel
|
|
ref="excelUploadRef"
|
|
title="用户导入"
|
|
temp-url="/admin/sys-file/local/file/user.xlsx"
|
|
url="/admin/user/import-face"
|
|
@refreshDataList="getDataList"
|
|
/>
|
|
|
|
<!-- 审批抽屉 -->
|
|
<process-drawer ref="processDrawerRef" @task-submit-event="taskSubmitEvent" />
|
|
|
|
<!-- 批量审批对话框 -->
|
|
<batch-deal ref="batchDealRef" @task-submit-event="taskSubmitEvent" />
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" name="systemUser" setup>
|
|
import { delObj, pageList, putObj } from "/@/api/admin/user"
|
|
import { putGlobalFace } from "/@/api/admin/userFace"
|
|
import { BasicTableProps, useTable } from "/@/hooks/table"
|
|
import { useMessage, useMessageBox } from "/@/hooks/message"
|
|
import { useI18n } from "vue-i18n"
|
|
import { auth } from "/@/utils/authFunction"
|
|
import { getDicts } from "/@/api/admin/dict"
|
|
import ProcessDrawer from "/@/components/processDrawer/index.vue"
|
|
|
|
const UserForm = defineAsyncComponent(() => import("./form.vue"))
|
|
const FaceManage = defineAsyncComponent(() => import("./face-manage.vue"))
|
|
const PopoverInput = defineAsyncComponent(() => import("/@/components/PopoverInput/index.vue"))
|
|
const BatchDeal = defineAsyncComponent(() => import("./batchDeal.vue"))
|
|
|
|
const { t } = useI18n()
|
|
|
|
const userDialogRef = ref()
|
|
const faceManageRef = ref()
|
|
const excelUploadRef = ref()
|
|
const queryRef = ref()
|
|
const showSearch = ref(true)
|
|
const inputPassword = ref()
|
|
const draggableDepTreeRef = ref() // 树组件ref引用
|
|
const activeName = ref("2")
|
|
const tabItems = ref<any>([{}])
|
|
const processDrawerRef = ref()
|
|
const batchDealRef = ref()
|
|
|
|
// 多选rows
|
|
const selectObjs = ref([]) as any
|
|
// 是否可以多选
|
|
const multiple = ref(true)
|
|
|
|
// 定义表格查询、后台调用的API
|
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
dataList: [],
|
|
queryForm: {
|
|
deptId: "",
|
|
username: "",
|
|
phone: "",
|
|
isDeepDept: false,
|
|
processStatus: "2",
|
|
},
|
|
pageList: pageList,
|
|
})
|
|
const { getDataList, currentChangeHandle, sizeChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
|
|
|
|
// 清空搜索条件
|
|
const resetQuery = () => {
|
|
queryRef.value?.resetFields()
|
|
state.queryForm.deptId = ""
|
|
state.queryForm.deptIds = []
|
|
draggableDepTreeRef.value.resetData()
|
|
getDataList()
|
|
}
|
|
|
|
// 树节点选择时
|
|
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: boolean) => {
|
|
state.queryForm.deptId = curClickedNode.id
|
|
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
|
state.queryForm.isInclude = !isDeepTree
|
|
getDataList()
|
|
}
|
|
|
|
onMounted(async () => {
|
|
const { data } = await getDicts("check_status")
|
|
tabItems.value = data
|
|
})
|
|
|
|
// tab点击切换
|
|
const handleClickTabItem = (e: any) => {
|
|
state.queryForm.processStatus = tabItems.value[e.index].value
|
|
getDataList()
|
|
}
|
|
|
|
// 点击开始处理
|
|
const deal = (row: any) => {
|
|
if (!row.processId) return useMessage().warning("流程id不存在")
|
|
processDrawerRef.value.openProcessDrawer(row)
|
|
}
|
|
|
|
// 批量开始处理
|
|
const doBatchDeal = () => {
|
|
if (!selectObjs.value.length) return useMessage().warning("流程id不存在")
|
|
const processIds = selectObjs.value.filter((item: any) => item.processId).map((item: any) => item.processId)
|
|
batchDealRef.value.openDialog(processIds)
|
|
}
|
|
|
|
// 审批提交事件
|
|
const taskSubmitEvent = () => {
|
|
getDataList()
|
|
}
|
|
|
|
// 导出excel
|
|
const exportExcel = () => {
|
|
postDownBlobFile("/admin/user/export", Object.assign(state.queryForm, { ids: selectObjs }), "用户管理.xlsx")
|
|
}
|
|
|
|
// 是否可以多选
|
|
const handleSelectable = (row: any) => {
|
|
return row.username !== "admin"
|
|
}
|
|
|
|
// 多选事件
|
|
const handleSelectionChange = (objs: { userId: string; processId: string | null }[]) => {
|
|
selectObjs.value = objs.map(({ userId, processId }) => ({ userId, processId }))
|
|
multiple.value = !objs.length
|
|
}
|
|
|
|
// 删除操作
|
|
const handleDelete = async (ids: string[]) => {
|
|
try {
|
|
await useMessageBox().confirm(t("common.delConfirmText"))
|
|
} catch {
|
|
return
|
|
}
|
|
|
|
try {
|
|
await delObj(ids)
|
|
getDataList()
|
|
useMessage().success(t("common.delSuccessText"))
|
|
} catch (err: any) {
|
|
useMessage().error(err.msg)
|
|
}
|
|
}
|
|
|
|
//表格内开关 (用户状态)
|
|
const changeSwitch = async (row: any) => {
|
|
// 不修改密码
|
|
row.password = undefined
|
|
row.phone = undefined
|
|
await putObj(row)
|
|
useMessage().success(t("common.optSuccessText"))
|
|
getDataList()
|
|
}
|
|
|
|
const changeGlobalFaceSwitch = async (row: any) => {
|
|
if (!row.isGlobalFace) return
|
|
// 不修改密码
|
|
await putGlobalFace({ userId: row.userId, isGlobalFace: row.isGlobalFace })
|
|
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
|
|
}
|
|
|
|
row.phone = undefined
|
|
row.password = inputPassword.value
|
|
await putObj(row)
|
|
useMessage().success(t("common.optSuccessText"))
|
|
getDataList()
|
|
}
|
|
</script>
|