From 74672d31b58f60d2ff54ed4658613137d9480ff6 Mon Sep 17 00:00:00 2001 From: wangqiyang Date: Thu, 23 Jul 2026 15:28:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=89=AB=E6=8F=8F=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=89=8D=E7=AB=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/SystemSettings/index.vue | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/views/SystemSettings/index.vue b/src/views/SystemSettings/index.vue index 1455c7f..167174a 100644 --- a/src/views/SystemSettings/index.vue +++ b/src/views/SystemSettings/index.vue @@ -90,6 +90,26 @@ 确认修改 +
+
+
扫描数量
+ +
+
+
+
+
当前数量
+
{{ currentScanLoopCount }}
+
+
+
+
+ + + + 保存扫描数量 +
+
@@ -217,6 +237,10 @@ const setSystemTime = async () => { // ─── 电表型号 ───────────────────────────────────── const currentMeterFirm = ref('') const selectedMeterFirm = ref('') +const minScanLoopCount = ref(1) +const maxScanLoopCount = ref(10) +const currentScanLoopCount = ref(10) +const scanLoopCount = ref(10) const getMeterFirm = async () => { try { @@ -260,6 +284,58 @@ const setMeterFirm = async () => { } } +const getScanConfig = async () => { + try { + const res = await RPC.post('/m9z/scan/getConfig', {}) + const loopCount = Number(res?.loop_count || 10) + minScanLoopCount.value = Number(res?.min_loop_count || 1) + maxScanLoopCount.value = Number(res?.max_loop_count || 10) + currentScanLoopCount.value = loopCount + scanLoopCount.value = loopCount + } catch (e) { + // 错误由 rpc.js 处理 + } +} + +const setScanConfig = async () => { + const nextLoopCount = Number(scanLoopCount.value) + if (!Number.isInteger(nextLoopCount)) { + ElMessage.warning('请输入整数扫描数量') + return + } + if (nextLoopCount < minScanLoopCount.value || nextLoopCount > maxScanLoopCount.value) { + ElMessage.warning(`扫描数量范围为 ${minScanLoopCount.value}-${maxScanLoopCount.value}`) + return + } + if (nextLoopCount === currentScanLoopCount.value) { + ElMessage.info('扫描数量未变更') + return + } + try { + await ElMessageBox.confirm( + `确认要将扫描数量修改为 ${nextLoopCount} 吗?`, + '提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ) + const res = await RPC.post('/m9z/scan/setConfig', { + loop_count: nextLoopCount, + }) + if (res?.success) { + const loopCount = Number(res.loop_count || nextLoopCount) + currentScanLoopCount.value = loopCount + scanLoopCount.value = loopCount + ElMessage.success(`扫描数量已修改为 ${loopCount}`) + } + } catch (e) { + if (e === 'cancel' || e === 'close') return + // 其他错误由 rpc.js 处理 + } +} + // ─── 修改密码 ───────────────────────────────────── const pwdForm = ref({ oldPassword: '', newPassword: '', confirmPassword: '' }) @@ -341,6 +417,7 @@ const handleSessionRestored = () => { getSystemTime() getPasswordStatus() getMeterFirm() + getScanConfig() } onMounted(() => { @@ -349,6 +426,7 @@ onMounted(() => { getSystemTime() getPasswordStatus() getMeterFirm() + getScanConfig() // 监听 session 恢复事件 window.addEventListener('m9z:session-restored', handleSessionRestored) @@ -510,6 +588,12 @@ onUnmounted(() => { } } } + + .config-line { + margin-top: 28px; + padding-top: 18px; + border-top: 1px solid rgba(#0e9228, .35); + } } } }