新增门禁:实现访问管理界面与Mock端到端测试

This commit is contained in:
wangzhibiao committed 2026-09-16 11:43:58 +08:00
1 parent 20c5d494cf
commit d976fcfb4d
29 files changed
+2423 -281

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 智慧培训管理平台
VUE_APP_TITLE = SYFJGYD学员管理系统
# 开发环境配置
ENV = 'development'
+2 -2
View File
@@ -1,5 +1,5 @@
# 页面标题 智慧培训管理平台
VUE_APP_TITLE = 智慧培训管理平台
# 页面标题 SYFJGYD学员管理系统
VUE_APP_TITLE = SYFJGYD学员管理系统
# 生产环境配置
ENV = 'production'
+68
View File
@@ -0,0 +1,68 @@
import request from '@/utils/request'
// 查询宿舍关联的外部资源映射(包含房间与门锁映射及主锁健康度)
export function getDormMapping(dormId) {
return request({
url: '/train/access/mapping/dorm/' + dormId,
method: 'get'
})
}
// 绑定或修改宿舍外部房间映射
export function bindRoomMapping(data) {
return request({
url: '/train/access/mapping/bind-room',
method: 'post',
data: data
})
}
// 绑定或新增宿舍外部门锁映射
export function bindLockMapping(data) {
return request({
url: '/train/access/mapping/bind-lock',
method: 'post',
data: data
})
}
// 解除/失效指定的外部资源映射
export function unbindMapping(mappingId) {
return request({
url: '/train/access/mapping/' + mappingId,
method: 'delete'
})
}
// 查询门禁授权列表
export function listAuth(query) {
return request({
url: '/train/access/auth/list',
method: 'get',
params: query
})
}
// 获取门禁授权详细信息
export function getAuthDetail(authId) {
return request({
url: '/train/access/auth/' + authId,
method: 'get'
})
}
// 查询门禁授权关联的外部操作流水历史(脱敏)
export function getOperationHistory(doorAuthId) {
return request({
url: '/train/access/operations/' + doorAuthId,
method: 'get'
})
}
// 手动触发学员门禁权限对账
export function manualReconcile(enrollmentId) {
return request({
url: '/train/access/reconcile/' + enrollmentId,
method: 'post'
})
}
@@ -2,11 +2,11 @@
<div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
<transition name="sidebarLogoFade">
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo" />
<img v-if="logo" :src="logo" class="sidebar-logo">
<h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
</router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo" />
<img v-if="logo" :src="logo" class="sidebar-logo">
<h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
</router-link>
</transition>
@@ -25,19 +25,19 @@ export default {
required: true
}
},
data() {
return {
title: process.env.VUE_APP_TITLE || 'SYFJGYD学员管理系统',
logo: logoImg
}
},
computed: {
variables() {
return variables;
return variables
},
sideTheme() {
return this.$store.state.settings.sideTheme
}
},
data() {
return {
title: '智慧培训管理平台',
logo: logoImg
}
}
}
</script>
+162 -269
View File
@@ -1,61 +1,48 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="学员学号,关联train_student.s_id" prop="studentId">
<el-alert
title="门禁授权管理规范:门禁授权受学员报到确认、住宿安排及排课计划自动驱动。根据当前安全策略,在线密码凭证待业务侧安全交付方案确认(密文脱敏),系统不持久化亦不展示任何密码明文、Token或密钥。"
type="info"
:closable="false"
show-icon
style="margin-bottom: 16px;"
/>
<el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="80px">
<el-form-item label="学员学号" prop="studentId">
<el-input
v-model="queryParams.studentId"
placeholder="请输入学员学号,关联train_student.s_id"
placeholder="请输入学员学号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属开班计划ID,train_class_plan.plan_id" prop="planId">
<el-form-item label="宿舍楼栋" prop="dormBuilding">
<el-input
v-model="queryParams.planId"
placeholder="请输入所属开班计划ID,train_class_plan.plan_id"
v-model="queryParams.dormBuilding"
placeholder="请输入楼栋"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="分配宿舍ID,train_dormitory_info.dorm_id" prop="dormId">
<el-form-item label="房间号" prop="dormRoom">
<el-input
v-model="queryParams.dormId"
placeholder="请输入分配宿舍ID,train_dormitory_info.dorm_id"
v-model="queryParams.dormRoom"
placeholder="请输入房间号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="床位号" prop="bedNo">
<el-input
v-model="queryParams.bedNo"
placeholder="请输入床位号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="权限生效时间" prop="authStart">
<el-date-picker clearable
v-model="queryParams.authStart"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择权限生效时间">
</el-date-picker>
</el-form-item>
<el-form-item label="权限失效时间 (开班结束自动失效)" prop="authEnd">
<el-date-picker clearable
v-model="queryParams.authEnd"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择权限失效时间 (开班结束自动失效)">
</el-date-picker>
</el-form-item>
<el-form-item label="创建管理员账号" prop="createUser">
<el-input
v-model="queryParams.createUser"
placeholder="请输入创建管理员账号"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="授权状态" prop="authStatus">
<el-select v-model="queryParams.authStatus" placeholder="全部状态" clearable>
<el-option label="待授权 (PENDING_GRANT)" value="PENDING_GRANT" />
<el-option label="授权中 (GRANTING)" value="GRANTING" />
<el-option label="生效中 (ACTIVE)" value="ACTIVE" />
<el-option label="待注销 (PENDING_REVOKE)" value="PENDING_REVOKE" />
<el-option label="注销中 (REVOKING)" value="REVOKING" />
<el-option label="已注销 (REVOKED)" value="REVOKED" />
<el-option label="异常 (ERROR)" value="ERROR" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -64,87 +51,79 @@
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['train:auth:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['train:auth:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['train:auth:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['train:auth:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
</el-row>
<el-table v-loading="loading" :data="authList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="权限分配ID" align="center" prop="authId" />
<el-table-column label="学员学号,关联train_student.s_id" align="center" prop="studentId" />
<el-table-column label="所属开班计划ID,train_class_plan.plan_id" align="center" prop="planId" />
<el-table-column label="分配宿舍ID,train_dormitory_info.dorm_id" align="center" prop="dormId" />
<el-table-column label="床位号" align="center" prop="bedNo" />
<el-table-column label="0 未下发人脸 1 已下发人脸至智能锁 2 下发失败" align="center" prop="faceSyncStatus" />
<el-table-column label="权限生效时间" align="center" prop="authStart" width="180">
<el-table v-loading="loading" :data="authList">
<el-table-column label="授权ID" align="center" prop="authId" width="80" />
<el-table-column label="报名ID" align="center" prop="enrollmentId" width="90">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.authStart, '{y}-{m}-{d}') }}</span>
<span>{{ scope.row.enrollmentId || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="权限失效时间 (开班结束自动失效)" align="center" prop="authEnd" width="180">
<el-table-column label="学员姓名" align="center" width="110">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.authEnd, '{y}-{m}-{d}') }}</span>
<span>{{ scope.row.studentName || scope.row.studentId || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="创建管理员账号" align="center" prop="createUser" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="学员学号" align="center" prop="studentId" width="120" />
<el-table-column label="宿舍安排" align="center" min-width="130">
<template slot-scope="scope">
<span>{{ scope.row.dormBuilding || '' }} {{ scope.row.dormRoom || '' }} ({{ scope.row.bedNo || '-' }}床)</span>
</template>
</el-table-column>
<el-table-column label="业务授权状态" align="center" width="140">
<template slot-scope="scope">
<el-tag v-if="scope.row.authStatus === 'ACTIVE'" type="success" effect="dark" size="small">生效中 (ACTIVE)</el-tag>
<el-tag v-else-if="scope.row.authStatus === 'PENDING_GRANT'" type="info" size="small">待授权 (PENDING_GRANT)</el-tag>
<el-tag v-else-if="scope.row.authStatus === 'GRANTING'" type="warning" size="small">授权中 (GRANTING)</el-tag>
<el-tag v-else-if="scope.row.authStatus === 'PENDING_REVOKE'" type="warning" size="small">待注销 (PENDING_REVOKE)</el-tag>
<el-tag v-else-if="scope.row.authStatus === 'REVOKING'" type="warning" size="small">注销中 (REVOKING)</el-tag>
<el-tag v-else-if="scope.row.authStatus === 'REVOKED'" type="info" size="small">已注销 (REVOKED)</el-tag>
<el-tag v-else-if="scope.row.authStatus === 'ERROR'" type="danger" size="small">异常 (ERROR)</el-tag>
<el-tag v-else size="small">{{ scope.row.authStatus || 'UNKNOWN' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="凭据类型" align="center" width="130">
<template slot-scope="scope">
<el-tag size="mini" type="info">{{ scope.row.credentialType || 'ONLINE_PASSWORD' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="安全凭据状态" align="center" min-width="160">
<template slot-scope="{ row }">
<el-tag size="mini" type="warning">{{ row.authStatus ? '凭证待业务侧安全交付方案确认' : '待确认' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="权限生效时间" align="center" min-width="150">
<template slot-scope="scope">
<span v-if="scope.row.authStart">{{ parseTime(scope.row.authStart, '{y}-{m}-{d} {h}:{i}') }}</span>
<el-tag v-else size="mini" type="info">WAITING_FOR_PREREQUISITE</el-tag>
</template>
</el-table-column>
<el-table-column label="权限失效时间" align="center" min-width="150">
<template slot-scope="scope">
<span v-if="scope.row.authEnd">{{ parseTime(scope.row.authEnd, '{y}-{m}-{d} {h}:{i}') }}</span>
<el-tag v-else size="mini" type="info">WAITING_FOR_PREREQUISITE</el-tag>
</template>
</el-table-column>
<el-table-column label="重试次数" align="center" prop="retryCount" width="80" />
<el-table-column label="异常说明" align="center" prop="lastError" :show-overflow-tooltip="true" min-width="120" />
<el-table-column label="管理操作" align="center" width="160" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
v-hasPermi="['train:access:query']"
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['train:auth:edit']"
>修改</el-button>
icon="el-icon-document"
@click="handleOperationHistory(scope.row)"
>操作流水</el-button>
<el-button
v-hasPermi="['train:access:reconcile']"
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['train:auth:remove']"
>删除</el-button>
icon="el-icon-refresh"
@click="handleManualReconcile(scope.row)"
>手动对账</el-button>
</template>
</el-table-column>
</el-table>
@@ -157,212 +136,126 @@
@pagination="getList"
/>
<!-- 添加或修改宿舍权限分配对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="学员学号,关联train_student.s_id" prop="studentId">
<el-input v-model="form.studentId" placeholder="请输入学员学号,关联train_student.s_id" />
</el-form-item>
<el-form-item label="所属开班计划ID,train_class_plan.plan_id" prop="planId">
<el-input v-model="form.planId" placeholder="请输入所属开班计划ID,train_class_plan.plan_id" />
</el-form-item>
<el-form-item label="分配宿舍ID,train_dormitory_info.dorm_id" prop="dormId">
<el-input v-model="form.dormId" placeholder="请输入分配宿舍ID,train_dormitory_info.dorm_id" />
</el-form-item>
<el-form-item label="床位号" prop="bedNo">
<el-input v-model="form.bedNo" placeholder="请输入床位号" />
</el-form-item>
<el-form-item label="权限生效时间" prop="authStart">
<el-date-picker clearable
v-model="form.authStart"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择权限生效时间">
</el-date-picker>
</el-form-item>
<el-form-item label="权限失效时间 (开班结束自动失效)" prop="authEnd">
<el-date-picker clearable
v-model="form.authEnd"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择权限失效时间 (开班结束自动失效)">
</el-date-picker>
</el-form-item>
<el-form-item label="创建管理员账号" prop="createUser">
<el-input v-model="form.createUser" placeholder="请输入创建管理员账号" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<!-- 外部操作流水历史对话框 -->
<el-dialog title="外部设备操作流水 (External Operation History)" :visible.sync="operationOpen" width="850px" append-to-body>
<el-alert
title="安全提示:操作流水记录了系统向外部门禁/门锁发起的调度记录,已执行全链路敏感信息脱敏(无明文密码、无AppSecret、无Token)。"
type="info"
:closable="false"
show-icon
style="margin-bottom: 15px;"
/>
<el-table v-loading="operationLoading" :data="operationList" size="small" border empty-text="当前暂无外部操作流水记录">
<el-table-column label="流水ID" prop="operationId" width="80" align="center" />
<el-table-column label="操作类型" prop="operationType" width="140" align="center">
<template slot-scope="scope">
<el-tag v-if="scope.row.operationType === 'GRANT_PASSCODE'" type="success" size="mini">下发密码 (GRANT)</el-tag>
<el-tag v-else-if="scope.row.operationType === 'REVOKE_PASSCODE'" type="danger" size="mini">注销密码 (REVOKE)</el-tag>
<el-tag v-else size="mini">{{ scope.row.operationType }}</el-tag>
</template>
</el-table-column>
<el-table-column label="执行状态" prop="operationStatus" width="100" align="center">
<template slot-scope="scope">
<el-tag v-if="scope.row.operationStatus === 'SUCCESS'" type="success" size="mini">成功</el-tag>
<el-tag v-else-if="scope.row.operationStatus === 'FAILED'" type="danger" size="mini">失败</el-tag>
<el-tag v-else-if="scope.row.operationStatus === 'RUNNING'" type="warning" size="mini">运行中</el-tag>
<el-tag v-else size="mini">{{ scope.row.operationStatus }}</el-tag>
</template>
</el-table-column>
<el-table-column label="尝试次数" prop="attemptCount" width="80" align="center" />
<el-table-column label="请求时间" align="center" width="150">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.requestedAt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="完成时间" align="center" width="150">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.completedAt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="外部流水引用" prop="externalOperationRef" align="center" min-width="120" :show-overflow-tooltip="true" />
<el-table-column label="错误说明" prop="sanitizedErrorMessage" align="center" min-width="120" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span style="color: #F56C6C;">{{ scope.row.sanitizedErrorMessage || '-' }}</span>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
<el-button @click="operationOpen = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listAuth, getAuth, delAuth, addAuth, updateAuth } from "@/api/train/auth"
import { listAuth, getOperationHistory, manualReconcile } from '@/api/train/access'
export default {
name: "Auth",
name: 'Auth',
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 宿舍权限分配表格数据
authList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
studentId: null,
planId: null,
dormId: null,
bedNo: null,
faceSyncStatus: null,
authStart: null,
authEnd: null,
createUser: null,
dormBuilding: null,
dormRoom: null,
authStatus: null
},
// 表单参数
form: {},
// 表单校验
rules: {
studentId: [
{ required: true, message: "学员学号,关联train_student.s_id不能为空", trigger: "blur" }
],
planId: [
{ required: true, message: "所属开班计划ID,train_class_plan.plan_id不能为空", trigger: "blur" }
],
dormId: [
{ required: true, message: "分配宿舍ID,train_dormitory_info.dorm_id不能为空", trigger: "blur" }
],
createUser: [
{ required: true, message: "创建管理员账号不能为空", trigger: "blur" }
],
}
operationOpen: false,
operationLoading: false,
operationList: []
}
},
created() {
this.getList()
},
methods: {
/** 查询宿舍权限分配列表 */
getList() {
this.loading = true
listAuth(this.queryParams).then(response => {
this.authList = response.rows
this.total = response.total
this.authList = response.rows || []
this.total = response.total || 0
this.loading = false
}).catch(() => {
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
authId: null,
studentId: null,
planId: null,
dormId: null,
bedNo: null,
faceSyncStatus: null,
authStart: null,
authEnd: null,
createUser: null,
createTime: null,
updateTime: null,
remark: null
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.resetForm('queryForm')
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.authId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加宿舍权限分配"
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const authId = row.authId || this.ids
getAuth(authId).then(response => {
this.form = response.data
this.open = true
this.title = "修改宿舍权限分配"
handleOperationHistory(row) {
this.operationOpen = true
this.operationLoading = true
getOperationHistory(row.authId).then(res => {
this.operationList = res.data || []
this.operationLoading = false
}).catch(() => {
this.operationLoading = false
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.authId != null) {
updateAuth(this.form).then(response => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addAuth(this.form).then(response => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const authIds = row.authId || this.ids
this.$modal.confirm('是否确认删除宿舍权限分配编号为"' + authIds + '"的数据项?').then(function() {
return delAuth(authIds)
}).then(() => {
handleManualReconcile(row) {
if (!row.enrollmentId) {
this.$modal.msgError('当前授权记录未关联报名信息,无法执行对账')
return
}
this.$modal.confirm(
'确认对报名编号 [' + row.enrollmentId + '] 执行门禁对账?系统将严格遵循业务前置校验规则。'
).then(() => {
return manualReconcile(row.enrollmentId)
}).then(res => {
this.$modal.msgSuccess(res.msg || '对账执行成功')
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('train/auth/export', {
...this.queryParams
}, `auth_${new Date().getTime()}.xlsx`)
}
}
}
@@ -101,6 +101,13 @@
icon="el-icon-view"
@click="handleDetail(scope.row)"
>详情</el-button>
<el-button
v-hasPermi="['train:access:query']"
size="mini"
type="text"
icon="el-icon-key"
@click="handleAccessMapping(scope.row)"
>门禁映射</el-button>
</template>
</el-table-column>
</el-table>
@@ -200,11 +207,143 @@
<el-button @click="detailOpen = false">关 闭</el-button>
</div>
</el-dialog>
<!-- DMS门禁资源映射管理对话框 -->
<el-dialog :title="'DMS门禁资源映射 - ' + (currentDorm.dormBuilding || '') + ' ' + (currentDorm.dormRoom || '')" :visible.sync="mappingOpen" width="850px" append-to-body>
<!-- 主锁配置健康诊断警告 -->
<div style="margin-bottom: 15px;">
<el-alert
v-if="mappingHealth.status === 'HEALTHY'"
title="主锁配置正常:检测到 1 个有效主锁 (Primary Lock),具备门禁授权下发条件。"
type="success"
show-icon
:closable="false"
/>
<el-alert
v-else-if="mappingHealth.status === 'MISSING_PRIMARY'"
title="配置异常:未配置主锁 (0 primary lock)!门禁授权下发将被阻断。"
type="error"
show-icon
:closable="false"
/>
<el-alert
v-else-if="mappingHealth.status === 'MULTIPLE_PRIMARIES'"
:title="'配置异常:检测到多个主锁 (' + (mappingData.primaryLocks ? mappingData.primaryLocks.length : 0) + ' primary locks)!违反单一主锁约束,门禁授权下发将被阻断。'"
type="error"
show-icon
:closable="false"
/>
</div>
<!-- 宿舍基本信息 -->
<el-descriptions :column="3" border size="small" style="margin-bottom: 15px;">
<el-descriptions-item label="宿舍ID">{{ currentDorm.dormId }}</el-descriptions-item>
<el-descriptions-item label="楼栋/房间">{{ currentDorm.dormBuilding }} - {{ currentDorm.dormRoom }}</el-descriptions-item>
<el-descriptions-item label="核定床位">{{ currentDorm.capacity }} 人</el-descriptions-item>
</el-descriptions>
<!-- 外部房间映射 -->
<el-card shadow="never" style="margin-bottom: 15px;">
<div slot="header" class="clearfix">
<span style="font-weight: bold;"><i class="el-icon-office-building" /> 外部房间映射 (Room Mapping)</span>
</div>
<div v-if="mappingData.roomMapping">
<el-descriptions :column="2" border size="small">
<el-descriptions-item label="供应商编码">{{ mappingData.roomMapping.vendorCode }}</el-descriptions-item>
<el-descriptions-item label="外部房间ID">{{ mappingData.roomMapping.externalRoomId }}</el-descriptions-item>
<el-descriptions-item label="外部房间名称">{{ mappingData.roomMapping.externalRoomName || '-' }}</el-descriptions-item>
<el-descriptions-item label="映射状态">
<el-tag :type="mappingData.roomMapping.mappingStatus === 'ACTIVE' ? 'success' : 'info'" size="mini">
{{ mappingData.roomMapping.mappingStatus }}
</el-tag>
</el-descriptions-item>
</el-descriptions>
<div style="margin-top: 10px; text-align: right;">
<el-button type="danger" size="mini" plain icon="el-icon-delete" @click="handleUnbind(mappingData.roomMapping.mappingId)">解除房间绑定</el-button>
</div>
</div>
<div v-else>
<el-alert title="当前宿舍尚未绑定外部DMS房间。" type="info" :closable="false" style="margin-bottom: 10px;" />
<el-form :inline="true" :model="roomForm" size="small">
<el-form-item label="供应商">
<el-input v-model="roomForm.vendorCode" placeholder="如 MOCK_DMS" style="width: 140px;" />
</el-form-item>
<el-form-item label="外部房间ID">
<el-input v-model="roomForm.externalRoomId" placeholder="例如 ROOM_101" style="width: 160px;" />
</el-form-item>
<el-form-item label="外部房间名">
<el-input v-model="roomForm.externalRoomName" placeholder="例如 101室" style="width: 160px;" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-link" @click="submitBindRoom">绑定房间</el-button>
</el-form-item>
</el-form>
</div>
</el-card>
<!-- 外部门锁映射 (0..N) -->
<el-card shadow="never">
<div slot="header" class="clearfix">
<span style="font-weight: bold;"><i class="el-icon-lock" /> 外部门锁映射 (Lock Mappings, 0..N)</span>
</div>
<el-table :data="mappingData.lockMappings" size="small" border empty-text="暂无门锁映射">
<el-table-column label="供应商" prop="vendorCode" width="110" align="center" />
<el-table-column label="外部门锁ID" prop="externalLockId" align="center" />
<el-table-column label="外部门锁名称" prop="externalLockName" align="center" />
<el-table-column label="型号" prop="lockModel" width="110" align="center" />
<el-table-column label="主锁标识" width="120" align="center">
<template slot-scope="scope">
<el-tag v-if="scope.row.isPrimary" type="success" size="mini">主锁 (Primary)</el-tag>
<el-tag v-else type="info" size="mini">次要锁</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" width="80" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.mappingStatus === 'ACTIVE' ? 'success' : 'info'" size="mini">
{{ scope.row.mappingStatus }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="90" align="center">
<template slot-scope="scope">
<el-button size="mini" type="text" style="color: #F56C6C;" icon="el-icon-delete" @click="handleUnbind(scope.row.mappingId)">解绑</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加门锁表单 -->
<div style="margin-top: 15px; border-top: 1px dashed #EBEEF5; padding-top: 15px;">
<div style="font-size: 13px; font-weight: bold; margin-bottom: 8px;">添加门锁映射:</div>
<el-form :inline="true" :model="lockForm" size="small">
<el-form-item label="供应商">
<el-input v-model="lockForm.vendorCode" placeholder="如 MOCK_DMS" style="width: 120px;" />
</el-form-item>
<el-form-item label="外部门锁ID">
<el-input v-model="lockForm.externalLockId" placeholder="例如 LOCK_101" style="width: 140px;" />
</el-form-item>
<el-form-item label="门锁名称">
<el-input v-model="lockForm.externalLockName" placeholder="例如 101门正锁" style="width: 130px;" />
</el-form-item>
<el-form-item label="主锁">
<el-switch v-model="lockForm.isPrimary" active-text="是" inactive-text="否" />
</el-form-item>
<el-form-item>
<el-button type="success" icon="el-icon-plus" @click="submitBindLock">添加门锁</el-button>
</el-form-item>
</el-form>
</div>
</el-card>
<div slot="footer" class="dialog-footer">
<el-button @click="mappingOpen = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listDormitory, getDormitory, addDormitory } from '@/api/train/dormitory'
import { getDormMapping, bindRoomMapping, bindLockMapping, unbindMapping } from '@/api/train/access'
export default {
name: 'Dormitory',
@@ -218,6 +357,34 @@ export default {
open: false,
detailOpen: false,
detailData: {},
mappingOpen: false,
currentDorm: {},
mappingData: {
dormitory: {},
roomMapping: null,
lockMappings: [],
primaryLocks: [],
health: {}
},
mappingHealth: {
status: 'HEALTHY',
message: '',
primaryCount: 0
},
roomForm: {
dormId: null,
vendorCode: 'MOCK_DMS',
externalRoomId: '',
externalRoomName: ''
},
lockForm: {
dormId: null,
vendorCode: 'MOCK_DMS',
externalLockId: '',
externalLockName: '',
lockModel: 'SMART_LOCK_M1',
isPrimary: true
},
queryParams: {
pageNum: 1,
pageSize: 10,
@@ -296,6 +463,52 @@ export default {
this.detailOpen = true
})
},
handleAccessMapping(row) {
this.currentDorm = row
this.roomForm.dormId = row.dormId
this.lockForm.dormId = row.dormId
this.loadMapping(row.dormId)
this.mappingOpen = true
},
loadMapping(dormId) {
getDormMapping(dormId).then(res => {
const data = res.data || {}
this.mappingData = data
this.mappingHealth = data.health || { status: 'HEALTHY', primaryCount: (data.primaryLocks || []).length }
})
},
submitBindRoom() {
if (!this.roomForm.externalRoomId) {
this.$modal.msgError('请输入外部房间ID')
return
}
bindRoomMapping(this.roomForm).then(() => {
this.$modal.msgSuccess('外部房间映射绑定成功')
this.roomForm.externalRoomId = ''
this.roomForm.externalRoomName = ''
this.loadMapping(this.currentDorm.dormId)
})
},
submitBindLock() {
if (!this.lockForm.externalLockId) {
this.$modal.msgError('请输入外部门锁ID')
return
}
bindLockMapping(this.lockForm).then(() => {
this.$modal.msgSuccess('外部门锁映射绑定成功')
this.lockForm.externalLockId = ''
this.lockForm.externalLockName = ''
this.loadMapping(this.currentDorm.dormId)
})
},
handleUnbind(mappingId) {
this.$modal.confirm('是否确认解绑该外部映射?').then(() => {
return unbindMapping(mappingId)
}).then(() => {
this.$modal.msgSuccess('解绑成功')
this.loadMapping(this.currentDorm.dormId)
}).catch(() => {})
},
submitForm() {
this.$refs['form'].validate(valid => {
if (valid) {