Files
pj_admin_cloud/src/views/admin/system/userFaceApprove/index.vue
T
2026-09-10 15:34:23 +08:00

390 lines
13 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">
<SearchPanel
v-show="showSearch"
ref="queryRef"
:model="state.queryForm"
:loading="Boolean(state.loading)"
:search-text="$t('common.queryBtn')"
:reset-text="$t('common.resetBtn')"
@search="getDataList"
@reset="resetQuery"
>
<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: 180px" label="人脸质量" prop="qualityCategory">
<el-select v-model="state.queryForm.qualityCategory" placeholder="全部" clearable>
<el-option
v-for="option in FACE_QUALITY_FILTER_OPTIONS"
:key="option.value"
:label="option.label"
:value="option.value"
/>
</el-select>
</el-form-item>
</SearchPanel>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button
plain
v-auth="'userFace_sysUserFace_del'"
:disabled="multiple"
class="ml10"
icon="Delete"
type="primary"
@click="handleDelete(selectIds)"
>
删除
</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>
</el-row>
<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>
<el-table
v-loading="state.loading"
:data="state.dataList"
row-key="userId"
@selection-change="handleSelectionChange"
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="userMobile" show-overflow-tooltip />
<el-table-column label="部门" prop="deptName" width="200" show-overflow-tooltip />
<el-table-column label="人脸">
<template #default="{ row }">
<preview-image :src="row.faceImg" />
</template>
</el-table-column>
<el-table-column label="人脸质量" min-width="150">
<template #default="{ row }">
<el-tooltip :content="getFaceQualityTooltip(row)" placement="top" :show-after="250">
<span
tabindex="0"
role="status"
:aria-label="getFaceQualityTooltip(row)"
class="inline-flex cursor-help rounded-sm focus:outline-none focus:ring-2 focus:ring-primary-light-5"
>
<el-tag
:type="getFaceQualityTagType(row)"
size="small"
effect="plain"
class="min-w-[112px] justify-center whitespace-nowrap tabular-nums"
>
{{ getFaceQualityLabel(row) }}
</el-tag>
</span>
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="审核状态" prop="processStatus" show-overflow-tooltip min-width="100">
<template #default="{ row }">
<dict-tag :options="check_status" :value="row.processStatus" />
</template>
</el-table-column>
<el-table-column label="创建时间" prop="createTime" show-overflow-tooltip min-width="160" />
<el-table-column label="审核时间" prop="processTime" show-overflow-tooltip min-width="160" />
<el-table-column label="操作" min-width="160" fixed="right">
<template #default="{ row }">
<el-button
type="primary"
v-if="row.isCheckUser && row.processStatus != '2'"
size="small"
link
icon="VideoPlay"
@click="deal(row)"
>
开始处理
</el-button>
<el-button v-auth="'userFace_sysUserFace_del'" link type="danger" icon="Delete" @click="delFace(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
</template>
</DraggableDepTree>
</div>
<!-- 审批抽屉 -->
<process-drawer ref="processDrawerRef" @task-submit-event="taskSubmitEvent" />
<!-- 批量审批对话框 -->
<batch-deal ref="batchDealRef" @task-submit-event="taskSubmitEvent" />
</div>
</template>
<script lang="ts" setup>
import { BasicTableProps, useTable } from "/@/hooks/table"
import ProcessDrawer from "/@/components/processDrawer/index.vue"
import { getUserFaceList } from "/@/api/admin/userFaceApprove"
import { useMessage } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
import { getDicts } from "/@/api/admin/dict"
import * as userFaceApi from "/@/api/admin/userFace"
import { ElLoading } from "element-plus"
const BatchDeal = defineAsyncComponent(() => import("./batchDeal.vue"))
const { check_status } = useDict("check_status")
const queryRef = ref()
const showSearch = ref(true)
const draggableDepTreeRef = ref() // 树组件ref引用
const activeName = ref("2")
const tabItems = ref<any>([{}])
const processDrawerRef = ref()
const batchDealRef = ref()
const loading = ref()
/** PC 当前阶段用于判定低质量人脸的固定阈值,与终端默认在库阈值保持一致。 */
const LIBRARY_FACE_QUALITY_THRESHOLD = 0.6
/** 人脸质量查询分类,与后端分页接口的 qualityCategory 协议值保持一致。 */
const FACE_QUALITY_FILTER_OPTIONS = [
{ label: "合格", value: "qualified" },
{ label: "低质量", value: "low" },
{ label: "检测失败", value: "failed" },
{ label: "未检测", value: "pending" },
] as const
/** Element Plus 小号状态标签允许使用的语义类型。 */
type FaceQualityTagType = "success" | "warning" | "danger" | "info"
/** 审批列表中与服务端人脸质量字段有关的最小行结构。 */
interface UserFaceQualityRow {
/** 虹软综合质量分,数据库 decimal 可能由不同网关序列化为数字或文本。 */
qualityScore?: number | string | null
/** 服务端质量状态;历史未检测记录为空。 */
qualityStatus?: string | null
/** 终端完成质量检测的时间。 */
qualityCheckedAt?: string | null
/** 虹软 SDK 或终端插件错误码。 */
qualityErrorCode?: number | string | null
/** 最后一次成功写入质量结果的终端设备主键。 */
qualityDeviceId?: number | string | null
}
/** 人脸质量单元格的紧凑展示模型。 */
interface FaceQualityDisplay {
/** 标签内可直接理解的状态与分数文案。 */
label: string
/** 与状态对应的 Element Plus 语义颜色。 */
tagType: FaceQualityTagType
/** 包含阈值、时间、来源和排查动作的完整辅助说明。 */
tooltip: string
}
/**
* 将服务端人脸质量字段归一化为不依赖颜色的表格状态。
*
* @param row 审批列表人脸记录
* @returns 标签文案、语义颜色和完整诊断说明
*/
const resolveFaceQuality = (row: UserFaceQualityRow): FaceQualityDisplay => {
const checkedAt = row.qualityCheckedAt || "未知"
const deviceId = row.qualityDeviceId ?? "未知"
if (row.qualityStatus === "detected") {
const score = Number(row.qualityScore)
if (row.qualityScore == null || row.qualityScore === "" || !Number.isFinite(score) || score < 0 || score > 1) {
return {
label: "数据异常",
tagType: "danger",
tooltip: `服务端质量状态为已检测,但质量分无效。检测时间:${checkedAt};来源设备:${deviceId}`,
}
}
const scoreText = score.toFixed(2)
if (score < LIBRARY_FACE_QUALITY_THRESHOLD) {
return {
label: `低质量 ${scoreText}`,
tagType: "warning",
tooltip: `质量分 ${scoreText},低于当前阈值 ${LIBRARY_FACE_QUALITY_THRESHOLD.toFixed(
2,
)}。请排查照片清晰度、光照、人脸角度及人脸区域大小。检测时间:${checkedAt};来源设备:${deviceId}`,
}
}
return {
label: `合格 ${scoreText}`,
tagType: "success",
tooltip: `质量分 ${scoreText},达到当前阈值 ${LIBRARY_FACE_QUALITY_THRESHOLD.toFixed(
2,
)}。检测时间:${checkedAt};来源设备:${deviceId}`,
}
}
if (row.qualityStatus === "failed") {
const errorCode = row.qualityErrorCode == null ? "未知" : row.qualityErrorCode
return {
label: "检测失败",
tagType: "danger",
tooltip: `质量检测失败,错误码:${errorCode}。请确认终端虹软质量授权和本地图片有效性。检测时间:${checkedAt};来源设备:${deviceId}`,
}
}
return {
label: "未检测",
tagType: "info",
tooltip: "尚未收到终端质量检测结果,可在终端人脸管理中执行存量检测。",
}
}
/** 返回人脸质量标签文案。 */
const getFaceQualityLabel = (row: UserFaceQualityRow) => resolveFaceQuality(row).label
/** 返回人脸质量标签语义类型。 */
const getFaceQualityTagType = (row: UserFaceQualityRow) => resolveFaceQuality(row).tagType
/** 返回人脸质量 Tooltip 与无障碍说明。 */
const getFaceQualityTooltip = (row: UserFaceQualityRow) => resolveFaceQuality(row).tooltip
// 多选rows
const selectObjs = ref([]) as any
const selectIds = ref([]) as any
// 是否可以多选
const multiple = ref(true)
// 定义表格查询、后台调用的API
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
deptId: "",
username: "",
phone: "",
qualityCategory: "",
isDeepDept: false,
processStatus: "2",
},
pageList: getUserFaceList,
})
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 handleSelectable = (row: any) => {
return row.username !== "admin"
}
// 多选事件
const handleSelectionChange = (objs: { userId: string; processId: string | null }[]) => {
selectObjs.value = objs.map(({ userId, processId }) => ({ userId, processId }))
selectIds.value = objs.map((item: any) => item.id)
multiple.value = !objs.length
}
// 批量开始处理
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 deal = (row: any) => {
if (!row.processId) return useMessage().warning("流程id不存在")
processDrawerRef.value.openProcessDrawer(row)
}
// 审批提交事件
const taskSubmitEvent = () => {
getDataList()
}
// 全屏loading
const loadingStart = () => {
loading.value = ElLoading.service({
lock: true,
text: "删除中...",
background: "rgba(0, 0, 0, 0.7)",
})
}
// 删除人脸
const delFace = async (row: any) => {
try {
await useMessage().delConfirm("是否删除人脸?")
loadingStart()
await userFaceApi.delObjs([row.id]).finally(() => loading.value.close())
useMessage().success("删除成功")
getDataList()
} catch (error) {
console.log(error)
} finally {
loading.value.close()
}
}
// 批量删除人脸
const handleDelete = async (ids: any) => {
try {
await useMessage().delConfirm("是否批量删除人脸?")
loadingStart()
await userFaceApi.delObjs(ids).finally(() => loading.value.close())
useMessage().success("删除成功")
getDataList()
} catch (error: any) {
useMessage().error(error)
} finally {
loading.value.close()
}
}
</script>