This commit is contained in:
zfjia committed 2026-11-03 18:31:01 +08:00
1 parent 6e529c7ef7
commit eb5ad9518d
36 files changed
+4195 -581

No files matched your search

@@ -205,7 +205,7 @@
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="260" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" width="340" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
@@ -221,6 +221,13 @@
@click="handleSync(scope.row)"
v-hasPermi="['lock:device:sync']"
>同步</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-key"
@click="handleDeviceAuth(scope.row)"
v-hasPermi="['lock:auth:list']"
>锁内授权</el-button>
<el-button
size="mini"
type="text"
@@ -286,11 +293,122 @@
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!-- 锁内授权对账对话框 -->
<el-dialog title="锁内授权对账" :visible.sync="deviceAuthOpen" width="1100px" append-to-body @closed="closeDeviceAuth">
<div class="auth-toolbar">
<div class="auth-device">
<span class="auth-device-name">{{ deviceAuthDevice.deviceSn }}</span>
<span class="auth-device-extra">{{ deviceAuthDevice.deviceName }} / 房间 {{ deviceAuthDevice.roomNo || '-' }}</span>
</div>
<div>
<el-button
type="primary"
size="mini"
icon="el-icon-refresh"
:loading="deviceAuthQuerying"
@click="handleReadDeviceAuth"
>读取锁内授权</el-button>
<el-button
size="mini"
icon="el-icon-refresh-right"
:loading="deviceAuthLoading"
@click="loadDeviceAuthSnapshot"
>刷新结果</el-button>
</div>
</div>
<el-alert :title="deviceAuthSnapshot.notice" type="info" :closable="false" show-icon />
<div class="auth-summary">
<el-tag size="mini" :type="queryStatusTag(deviceAuthSnapshot.queryStatus)">读取:{{ deviceAuthSnapshot.queryStatusName || '未读取' }}</el-tag>
<span v-if="deviceAuthSnapshot.queryTime" class="auth-summary-item">时间:{{ deviceAuthSnapshot.queryTime }}</span>
<span v-if="deviceAuthSnapshot.queryMsg" class="auth-summary-item">说明:{{ deviceAuthSnapshot.queryMsg }}</span>
<span class="auth-summary-item">设备侧 {{ deviceAuthSnapshot.deviceCount || 0 }}</span>
<span class="auth-summary-item">平台 {{ deviceAuthSnapshot.platformCount || 0 }}</span>
<span class="auth-summary-item">一致 {{ deviceAuthSnapshot.matchedCount || 0 }}</span>
<span class="auth-summary-item text-danger">仅设备 {{ deviceAuthSnapshot.deviceOnlyCount || 0 }}</span>
<span class="auth-summary-item text-warning">仅平台 {{ deviceAuthSnapshot.platformOnlyCount || 0 }}</span>
<span class="auth-summary-item">不支持查询 {{ deviceAuthSnapshot.notQueryableCount || 0 }}</span>
</div>
<el-table v-loading="deviceAuthLoading" :data="deviceAuthSnapshot.rows" size="mini" max-height="440" border>
<el-table-column label="来源" width="80" align="center">
<template slot-scope="scope">
<el-tag size="mini" :type="scope.row.source === 'DEVICE' ? '' : 'info'">{{ scope.row.source === 'DEVICE' ? '设备侧' : '平台' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="索引" width="60" align="center">
<template slot-scope="scope">{{ scope.row.rowIndex == null ? '-' : scope.row.rowIndex }}</template>
</el-table-column>
<el-table-column label="凭据(脱敏)" prop="credential" min-width="140" show-overflow-tooltip />
<el-table-column label="类型" prop="authTypeName" width="80" align="center" />
<el-table-column label="人员" width="170" show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.personNo">{{ scope.row.personName }}({{ scope.row.personNo }})</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="对账" width="130" align="center">
<template slot-scope="scope">
<el-tag size="mini" :type="matchStatusTag(scope.row.matchStatus)">{{ scope.row.matchStatusName }}</el-tag>
</template>
</el-table-column>
<el-table-column label="生效时间" prop="beginTime" width="150" align="center" />
<el-table-column label="失效时间" prop="endTime" width="150" align="center" />
<el-table-column label="清除" width="90" align="center">
<template slot-scope="scope">
<el-tag size="mini" :type="clearStatusTag(scope.row.clearStatus)">{{ scope.row.clearStatusName }}</el-tag>
</template>
</el-table-column>
<el-table-column label="说明" prop="remark" min-width="180" show-overflow-tooltip />
<el-table-column label="操作" width="80" align="center">
<template slot-scope="scope">
<el-button
v-if="scope.row.clearable"
size="mini"
type="text"
icon="el-icon-delete"
style="color: #f56c6c"
@click="handleClearDeviceAuth(scope.row)"
>清除</el-button>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
<el-dialog title="选择凭据类型" :visible.sync="deviceAuthClearOpen" width="400px" append-to-body>
<div class="auth-clear-tip">
设备返回的凭据「{{ deviceAuthClearRow.credential }}」在平台没有匹配授权,无法自动判断类型。
</div>
<el-radio-group v-model="deviceAuthClearType">
<el-radio label="02">密码</el-radio>
<el-radio label="04">IC卡</el-radio>
</el-radio-group>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="deviceAuthClearOpen = false">取 消</el-button>
<el-button size="mini" type="danger" :loading="deviceAuthClearing" @click="confirmClearDeviceAuth">确认清除</el-button>
</div>
</el-dialog>
</el-dialog>
</div>
</template>
<script>
import { listDevice, getDevice, delDevice, addDevice, updateDevice, syncTime, batchSyncTime, remoteSwitch, clearFaceAuthByDevices } from "@/api/iot/device";
import {
listDevice,
getDevice,
delDevice,
addDevice,
updateDevice,
syncTime,
batchSyncTime,
remoteSwitch,
clearFaceAuthByDevices,
queryDeviceAuths,
getDeviceAuthSnapshot,
clearDeviceAuth
} from "@/api/iot/device";
export default {
name: "Device",
@@ -325,7 +443,18 @@ export default {
deviceSn: [
{ required: true, message: "门锁SN不能为空", trigger: "blur" }
]
}
},
deviceAuthOpen: false,
deviceAuthLoading: false,
deviceAuthQuerying: false,
deviceAuthDevice: {},
deviceAuthSnapshot: { rows: [] },
deviceAuthClearOpen: false,
deviceAuthClearRow: {},
deviceAuthClearType: "02",
deviceAuthClearing: false,
deviceAuthTimer: null,
deviceAuthRefreshTimer: null
};
},
created() {
@@ -457,6 +586,148 @@ export default {
this.$modal.msgSuccess("开锁指令已下发");
}).catch(() => {});
},
handleDeviceAuth(row) {
this.deviceAuthDevice = row;
this.deviceAuthSnapshot = { rows: [] };
this.deviceAuthOpen = true;
this.loadDeviceAuthSnapshot();
},
loadDeviceAuthSnapshot() {
if (!this.deviceAuthDevice.deviceId) {
return Promise.resolve();
}
this.deviceAuthLoading = true;
return getDeviceAuthSnapshot(this.deviceAuthDevice.deviceId).then(response => {
this.deviceAuthSnapshot = response.data || { rows: [] };
if (!this.deviceAuthSnapshot.rows) {
this.deviceAuthSnapshot.rows = [];
}
this.deviceAuthLoading = false;
}, () => {
this.deviceAuthLoading = false;
});
},
handleReadDeviceAuth() {
if (this.deviceAuthQuerying) {
return;
}
this.deviceAuthQuerying = true;
queryDeviceAuths(this.deviceAuthDevice.deviceId).then(() => {
this.$modal.msgSuccess("读取指令已下发,正在等待设备返回");
this.loadDeviceAuthSnapshot();
this.startDeviceAuthPolling();
}, () => {}).then(() => {
this.deviceAuthQuerying = false;
});
},
startDeviceAuthPolling() {
this.stopDeviceAuthPolling();
let tries = 0;
this.deviceAuthTimer = setInterval(() => {
tries++;
this.loadDeviceAuthSnapshot().then(() => {
const status = this.deviceAuthSnapshot.queryStatus;
if ((status && status !== "0" && status !== "1") || tries >= 15) {
this.stopDeviceAuthPolling();
}
});
}, 2000);
},
stopDeviceAuthPolling() {
if (this.deviceAuthTimer) {
clearInterval(this.deviceAuthTimer);
this.deviceAuthTimer = null;
}
},
closeDeviceAuth() {
this.stopDeviceAuthPolling();
if (this.deviceAuthRefreshTimer) {
clearTimeout(this.deviceAuthRefreshTimer);
this.deviceAuthRefreshTimer = null;
}
this.deviceAuthClearOpen = false;
},
handleClearDeviceAuth(row) {
if (!row || !row.deviceAuthId) {
return;
}
if (row.authType) {
this.$modal.confirm('确认清除设备侧' + (row.authTypeName || '') + '授权「' + row.credential + '」?平台对应授权状态将同步更新。').then(() => {
this.submitClearDeviceAuth(row, row.authType);
}).catch(() => {});
return;
}
this.deviceAuthClearRow = row;
this.deviceAuthClearType = "02";
this.deviceAuthClearOpen = true;
},
confirmClearDeviceAuth() {
this.submitClearDeviceAuth(this.deviceAuthClearRow, this.deviceAuthClearType);
},
submitClearDeviceAuth(row, authType) {
const target = row || this.deviceAuthClearRow;
const type = authType || this.deviceAuthClearType;
if (!target || !target.deviceAuthId || this.deviceAuthClearing) {
return;
}
this.deviceAuthClearing = true;
clearDeviceAuth(this.deviceAuthDevice.deviceId, {
deviceAuthId: target.deviceAuthId,
authType: type
}).then(() => {
this.deviceAuthClearOpen = false;
this.$modal.msgSuccess("清除指令已下发");
this.loadDeviceAuthSnapshot();
this.scheduleDeviceAuthRefresh();
}, () => {}).then(() => {
this.deviceAuthClearing = false;
});
},
scheduleDeviceAuthRefresh() {
if (this.deviceAuthRefreshTimer) {
clearTimeout(this.deviceAuthRefreshTimer);
}
this.deviceAuthRefreshTimer = setTimeout(() => {
this.deviceAuthRefreshTimer = null;
this.loadDeviceAuthSnapshot();
}, 4000);
},
queryStatusTag(status) {
if (status === "2") {
return "success";
}
if (status === "3" || status === "4") {
return "danger";
}
if (status === "0" || status === "1") {
return "warning";
}
return "info";
},
matchStatusTag(status) {
if (status === "MATCHED") {
return "success";
}
if (status === "DEVICE_ONLY") {
return "danger";
}
if (status === "PLATFORM_ONLY") {
return "warning";
}
return "info";
},
clearStatusTag(status) {
if (status === "2") {
return "success";
}
if (status === "1") {
return "warning";
}
if (status === "3") {
return "danger";
}
return "info";
},
handleDelete(row) {
const deviceIds = row.deviceId || this.ids;
this.$modal.confirm('是否确认删除门锁编号为"' + deviceIds + '"的数据项?').then(function() {
@@ -486,4 +757,34 @@ export default {
.text-warning {
color: #e6a23c;
}
.auth-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.auth-device-name {
font-weight: 600;
margin-right: 8px;
}
.auth-device-extra {
color: #909399;
font-size: 12px;
}
.auth-summary {
display: flex;
flex-wrap: wrap;
align-items: center;
margin: 10px 0;
font-size: 12px;
color: #606266;
}
.auth-summary-item {
margin-left: 14px;
}
.auth-clear-tip {
margin-bottom: 16px;
color: #606266;
line-height: 1.6;
}
</style>