From e491cdb48129752324c4e3764f99bd9203c56dec Mon Sep 17 00:00:00 2001
From: lgq <1015864684@qq.com>
Date: 星期二, 31 三月 2026 09:48:44 +0800
Subject: [PATCH] 1.新增VF205门禁机代码
---
vf205_access/src/view/config/menu/systemSetting/passwordOpenDoorSettingView.js | 144 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 144 insertions(+), 0 deletions(-)
diff --git a/vf205_access/src/view/config/menu/systemSetting/passwordOpenDoorSettingView.js b/vf205_access/src/view/config/menu/systemSetting/passwordOpenDoorSettingView.js
new file mode 100644
index 0000000..7c4b764
--- /dev/null
+++ b/vf205_access/src/view/config/menu/systemSetting/passwordOpenDoorSettingView.js
@@ -0,0 +1,144 @@
+import dxui from '../../../../../dxmodules/dxUi.js'
+import std from '../../../../../dxmodules/dxStd.js'
+import viewUtils from "../../../viewUtils.js"
+import topView from "../../../topView.js"
+import i18n from "../../../i18n.js"
+import systemSettingView from '../systemSettingView.js'
+import screen from '../../../../screen.js'
+import sqliteService from '../../../../service/sqliteService.js'
+import logger from '../../../../../dxmodules/dxLogger.js'
+const passwordOpenDoorSettingView = {}
+passwordOpenDoorSettingView.init = function () {
+ /**************************************************鍒涘缓灞忓箷*****************************************************/
+ const screenMain = dxui.View.build('passwordOpenDoorSettingView', dxui.Utils.LAYER.MAIN)
+ passwordOpenDoorSettingView.screenMain = screenMain
+ screenMain.scroll(false)
+ screenMain.bgColor(0xffffff)
+ screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_LOADED, () => {
+ topView.changeTheme(true)
+
+ const configAll = screen.getConfig()
+ passwordOpenDoorSettingView.info[0].switch.select(configAll['sys.pwd'] == 1)
+ // 鍔犺浇搴旀�ュ紑浠撳瘑鐮侊紙浠庢暟鎹簱锛�
+ if (passwordOpenDoorSettingView.info[1].input) {
+ try {
+ const passwords = sqliteService.d1_emergency_password.findAll()
+ if (passwords && passwords.length > 0) {
+ // 鍙樉绀虹涓�涓瘑鐮侊紝鍥犱负搴旀�ュ紑浠撳瘑鐮佸湪璁惧涓粎鏈夊敮涓�鐨�1涓�
+ passwordOpenDoorSettingView.info[1].input.text(passwords[0].password || '')
+ }
+ } catch (error) {
+ logger.error('鍔犺浇搴旀�ュ紑浠撳瘑鐮佸け璐�:', error)
+ }
+ }
+ })
+
+ const titleBox = viewUtils.title(screenMain, systemSettingView.screenMain, 'passwordOpenDoorSettingViewTitle', 'systemSettingView.passwordOpenDoorSetting')
+ titleBox.align(dxui.Utils.ALIGN.TOP_MID, 0, 70)
+
+ passwordOpenDoorSettingView.info = [
+ {
+ title: "systemSettingView.passwordOpenDoor",
+ type: 'switch',
+ },
+ {
+ title: "搴旀�ュ紑浠撳瘑鐮�",
+ type: 'input',
+ placeholder: '璇疯緭鍏ヨ嚦灏�8浣嶅簲鎬ュ紑浠撳瘑鐮�',
+ password: true
+ }
+ ]
+
+ const passwordOpenDoorSettingBox = dxui.View.build('passwordOpenDoorSettingBox', screenMain)
+ viewUtils._clearStyle(passwordOpenDoorSettingBox)
+ passwordOpenDoorSettingBox.align(dxui.Utils.ALIGN.TOP_MID, 0, 140)
+ passwordOpenDoorSettingBox.setSize(screen.screenSize.width, 600)
+ passwordOpenDoorSettingBox.bgOpa(0)
+ passwordOpenDoorSettingBox.flexFlow(dxui.Utils.FLEX_FLOW.ROW_WRAP)
+ passwordOpenDoorSettingBox.flexAlign(dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.START, dxui.Utils.FLEX_ALIGN.START)
+ passwordOpenDoorSettingBox.obj.lvObjSetStylePadGap(0, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
+ passwordOpenDoorSettingBox.borderWidth(1)
+ passwordOpenDoorSettingBox.setBorderColor(0xDEDEDE)
+ passwordOpenDoorSettingBox.obj.setStyleBorderSide(dxui.Utils.ENUM.LV_BORDER_SIDE_TOP, 0)
+
+ passwordOpenDoorSettingView.info.forEach(item => {
+ const itemBox = dxui.View.build(item.title, passwordOpenDoorSettingBox)
+ viewUtils._clearStyle(itemBox)
+ itemBox.setSize(760, 76)
+ itemBox.borderWidth(1)
+ itemBox.setBorderColor(0xDEDEDE)
+ itemBox.obj.setStyleBorderSide(dxui.Utils.ENUM.LV_BORDER_SIDE_BOTTOM, 0)
+
+ const itemLabel = dxui.Label.build(item.title + 'Label', itemBox)
+ itemLabel.dataI18n = item.title
+ itemLabel.align(dxui.Utils.ALIGN.LEFT_MID, 0, 0)
+ itemLabel.textFont(viewUtils.font(26))
+
+ if (item.unit) {
+ const unitLabel = dxui.Label.build(item.title + 'UnitLabel', itemBox)
+ unitLabel.text(item.unit)
+ unitLabel.align(dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
+ unitLabel.textFont(viewUtils.font(26))
+ }
+
+ switch (item.type) {
+ case 'switch':
+ const __switch = dxui.Switch.build(item.title + 'switch', itemBox)
+ __switch.align(dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
+ __switch.setSize(70, 35)
+ item.switch = __switch
+ break;
+ case 'input':
+ const input = viewUtils.input(itemBox, item.title + 'input', undefined, undefined, item.placeholder)
+ input.align(dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
+ input.setSize(300, 40)
+ input.setPasswordMode(item.password)
+ item.input = input
+ break;
+ }
+ })
+
+ const saveBtn = viewUtils.bottomBtn(screenMain, screenMain.id + 'saveBtn', 'systemSettingView.save', () => {
+ const emergencyPassword = passwordOpenDoorSettingView.info[1].input.text()
+ const saveConfigData = {
+ sys: {
+ pwd: passwordOpenDoorSettingView.info[0].switch.isSelect() ? 1 : 0
+ }
+ }
+
+ // 鏇存柊鏁版嵁搴撲腑鐨勫簲鎬ュ紑浠撳瘑鐮�
+ try {
+ // 鍏堝垹闄ゆ棫鐨勫簲鎬ュ紑浠撳瘑鐮�
+ sqliteService.d1_emergency_password.deleteAll()
+ // 娣诲姞鏂扮殑搴旀�ュ紑浠撳瘑鐮�
+ if (emergencyPassword) {
+ sqliteService.d1_emergency_password.save({
+ id: 'emergency_' + Date.now(),
+ password: emergencyPassword,
+ description: '绯荤粺璁剧疆鐨勫簲鎬ュ紑浠撳瘑鐮�',
+ createTime: Date.now(),
+ updateTime: Date.now(),
+ status: 1
+ })
+ }
+ } catch (error) {
+ logger.error('鏇存柊搴旀�ュ紑浠撳瘑鐮佸け璐�:', error)
+ }
+
+ const res = screen.saveConfig(saveConfigData)
+ if (res === true) {
+ passwordOpenDoorSettingView.statusPanel.success()
+ std.setTimeout(() => {
+ // 鎴愬姛杩斿洖涓婁竴灞傜晫闈�
+ dxui.loadMain(systemSettingView.screenMain)
+ }, 500)
+ } else {
+ passwordOpenDoorSettingView.statusPanel.fail()
+ }
+ })
+ saveBtn.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, -83)
+
+ passwordOpenDoorSettingView.statusPanel = viewUtils.statusPanel(screenMain, 'systemSettingView.success', 'systemSettingView.fail')
+}
+
+export default passwordOpenDoorSettingView
--
Gitblit v1.9.3