diff --git a/error.md b/error.md new file mode 100644 index 0000000..ddefeba --- /dev/null +++ b/error.md @@ -0,0 +1,40 @@ +tsucc = 0, +ksucc = 0, + +kappe_begin = 10000, +kappe_code_error = 10001, // 代码错误 +kappe_cmd_not_support = 10003, // 命令不支持 +kappe_parse_json_err = 10004, // 解析json错误 +kappe_std_exception = 10005, // 标准库异常 +kappe_db_operate_error = 10006, // 数据库操作错误 +kappe_missing_param = 10007, // 缺少参数 +kappe_param_num_err = 10008, // 参数个数错误 +kappe_param_value_err = 10009, // 参数值错误 + +kappe_user_not_exist = 10101, // 用户不存在 +kappe_passwd_error = 10102, // 密码错误 + +kappe_disinfectant_insufficient = 10201, // 消毒液不足 +kappe_the_bottom_of_the_device_has_water = 10202, // 设备底部有水 +kappe_the_evaporation_bin_has_water = 10203, // 蒸发仓有水 +kappe_the_sensor_is_preheating = 10204, // 传感器正在预热 +kappe_not_detect_udisk = 10205, // 未检测到U盘 +kappe_udisk_wr_fail = 10206, // U盘读写错误 +kappe_open_file_error = 10207, // 文件操作错误 +kappe_adding_liquid_is_already_in_place = 10208, // 液体已加到位 +kappe_adding_liquid_is_greater_than_the_maximum_capacity_of_the_device = 10209, // 加液大于设备最大容量 +kappe_sensor_is_pre_heating = 10210, // 传感器正在预热 +kappe_state_is_busy = 10211, // 设备忙 +kappe_is_adding_liquid = 10212, // 加液中 +kappe_is_draining_liquid = 10213, // 排液中 +kappe_is_dis infecting = 10214, // 消毒中 +kappe_is_air_leak_detect_testing = 10215, // 气密性测试中 +kappe_setting_id_out_of_range = 10216, // 设置ID超出范围 +kappe_exception_flag_is_setted = 10217, // 异常标志已设置 +kappe_disinfection_state_is_wrong = 10218, // 消毒状态错误 +kappe_component_cfg_not_find = 10219, // 组件配置未找到 + +kappe_liquid_ctrl_reboot = 10300, +kappe_power_control_reboot = 10301, + +kappe_device_checkpoint_check_fail = 20000, // diff --git a/src/apis/home.ts b/src/apis/home.ts index 453e3d8..db3b0d5 100644 --- a/src/apis/home.ts +++ b/src/apis/home.ts @@ -10,6 +10,5 @@ export const initHomeData: () => Promise { // 过渡页面加载进度 startProgress() + // 环境(探头)数据需要轮询获取,没有上报的事件 + setInterval(async () => { + await readH2o2Data() + }, 2000) }) const initDeviceInfo = async () => { @@ -55,7 +59,8 @@ const startProgress = () => { } }, 100) } -const initData = async () => { + +const readH2o2Data = async () => { const envParams = { fnName: 'readH2O2SensorData', className: 'FrontEndRealtimeDisplayContentMgr', @@ -65,7 +70,8 @@ const initData = async () => { if (resData.val.length) { homeStore.updateHomeData(resData.val) } - +} +const initData = async () => { // 获取消毒时状态 const disinfectionParams = { className: 'DisinfectionCtrlServiceExt', @@ -75,7 +81,7 @@ const initData = async () => { const disinfectionData = await sendCmd(disinfectionParams) homeStore.updateHomeDisinfectionState(disinfectionData) - // 消毒液使用状态 + // 消毒液当前使用余量 const liquidParams = { fnName: 'getState', className: 'AddLiquidService', @@ -94,6 +100,7 @@ const initData = async () => { homeStore.setDeviceState(deviceData) } +// 消毒液最大量 const initLiquidConfig = async () => { const params = { className: 'AddLiquidService', diff --git a/src/components/common/SelectModal/index.vue b/src/components/common/SelectModal/index.vue index 0e06198..c4707e7 100644 --- a/src/components/common/SelectModal/index.vue +++ b/src/components/common/SelectModal/index.vue @@ -1,5 +1,5 @@ diff --git a/src/components/home/HomeLogLevel.vue b/src/components/home/HomeLogLevel.vue index 4769e3c..2282527 100644 --- a/src/components/home/HomeLogLevel.vue +++ b/src/components/home/HomeLogLevel.vue @@ -1,23 +1,27 @@ - import type { FormInstance } from 'element-plus' import { useSettingStore } from '@/stores/settingStore' +import { syncSendCmd } from 'apis/system' import SoftKeyboard from 'components/common/SoftKeyboard/index.vue' -import { onMounted, ref, watchEffect } from 'vue' +import { FtMessage } from 'libs/message' +import { ref, watchEffect } from 'vue' +const emits = defineEmits(['refresh']) const settingStore = useSettingStore() const visible = ref(settingStore.addUserVisible) const modalType = ref(settingStore.userModalState) @@ -14,13 +17,13 @@ const softKeyboardRef = ref() const userFormRef = ref() const focusedInput = ref(null) const modalTitle = ref('新增用户') -const userForm = ref({ - uid: '', - id: '', +const userForm = ref>({ + name: '', passwd: '', - confirmPassword: '', - is_admin: false, + confirmPasswd: '', + roleType: '', }) + watchEffect(() => { modalType.value = settingStore.userModalState if (settingStore.userModalState === 'edit') { @@ -34,19 +37,10 @@ watchEffect(() => { } visible.value = settingStore.addUserVisible if (focusedInput.value) { - userForm.value[focusedInput.value as keyof typeof userForm.value] = inputValue.value + userForm.value[focusedInput.value] = inputValue.value } }) -onMounted(() => { - // 离开输入框焦点时 关闭软键盘 - document.addEventListener('click', (e: any) => { - if (softKeyboardRef.value && !e.target?.name) { - keyboardVisible.value = false - } - }) -}) - const onSave = (formRef: FormInstance | undefined) => { if (!formRef) { return @@ -78,6 +72,30 @@ const openKeyboard = (e: any) => { const doEdit = () => { } const doSave = () => { + const name = userForm.value.name + const passwd = userForm.value.passwd + const confirmPasswd = userForm.value.confirmPasswd + const roleType = userForm.value.roleType + if (passwd !== confirmPasswd) { + FtMessage.error('输入的密码不一致') + return + } + const saveParams = { + className: 'UserMgrService', + fnName: 'addUser', + params: { + name, + passwd, + roleType: roleType ? 'admin' : 'maintainer', + }, + } + + syncSendCmd(saveParams).then((res) => { + if (res.ackcode === 0) { + FtMessage.success('成功') + emits('refresh') + } + }) } const onClose = () => { settingStore.updateVisible(false) @@ -92,17 +110,18 @@ const handleConfirm = (value: string) => {
- + -
+
{ trigger: ['blur', 'change'], }" > - + - +
- + @@ -138,6 +157,7 @@ const handleConfirm = (value: string) => { v-model="inputValue" :is-visible="keyboardVisible" :keyboard-type="keyboardType" + @update-keyboard-visible="(visible) => keyboardVisible = visible" @confirm="handleConfirm" @close="keyboardVisible = false" /> diff --git a/src/components/setting/Device.vue b/src/components/setting/Device.vue new file mode 100644 index 0000000..07c1557 --- /dev/null +++ b/src/components/setting/Device.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/components/setting/ModifyPwd.vue b/src/components/setting/ModifyPwd.vue new file mode 100644 index 0000000..22e4817 --- /dev/null +++ b/src/components/setting/ModifyPwd.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/src/components/setting/SystemDate.vue b/src/components/setting/SystemDate.vue new file mode 100644 index 0000000..913dc7b --- /dev/null +++ b/src/components/setting/SystemDate.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/components/setting/User.vue b/src/components/setting/User.vue index ed9d387..91b5ff9 100644 --- a/src/components/setting/User.vue +++ b/src/components/setting/User.vue @@ -1,33 +1,69 @@ @@ -69,7 +108,5 @@ const onDelUser = () => { .history-export{ margin: 2vw; } - .history-table{ - } } diff --git a/src/layouts/default.vue b/src/layouts/default.vue index c771bb4..ad73a5a 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -1,4 +1,5 @@ diff --git a/src/libs/deviceComm.ts b/src/libs/deviceComm.ts new file mode 100644 index 0000000..47397ef --- /dev/null +++ b/src/libs/deviceComm.ts @@ -0,0 +1,42 @@ +import { useHomeStore } from '@/stores/homeStore' +import { useLiquidStore } from '@/stores/liquidStore' +import { useSealStore } from '@/stores/sealStore' +import { ref, watchEffect } from 'vue' + +const homeStore = useHomeStore() +const liquidStore = useLiquidStore() +const sealStore = useSealStore() +const addWorkState = ref(liquidStore.liquidStateData)// 加液状态 +const drainWorkState = ref(liquidStore.liquidStateData)// 排液状态 +const sealInfo = ref(sealStore.sealInfo) + +watchEffect(() => { + addWorkState.value = liquidStore.liquidAddWorkState + drainWorkState.value = liquidStore.liquidDrainWorkState + sealInfo.value = sealStore.sealInfo +}) + +export const getDeviceStatus = () => { + let statusName = '' + if (!homeStore.isDeviceIdle) { + statusName = '正在进行消毒,不可操作' + return statusName + } + // 正在进行加液 + if (addWorkState.value.workState !== 'idle') { + statusName = '正在进行加液操作...' + return statusName + } + // 正在进行排液 + if (drainWorkState.value.workState !== 'idle') { + statusName = '正在进行排液操作...' + return statusName + } + + // 正在密封测试 + if (sealInfo.value.workState !== 'idle') { + statusName = '正在进行排液操作...' + return statusName + } + return statusName +} diff --git a/src/libs/socket.ts b/src/libs/socket.ts index b489924..7fe96e3 100644 --- a/src/libs/socket.ts +++ b/src/libs/socket.ts @@ -1,4 +1,3 @@ -// src/utils/websocket.ts import type { Ref } from 'vue' import { ref, watch } from 'vue' import { FtMessageBox } from './messageBox' @@ -142,7 +141,7 @@ export class WebSocketClient { } } - // 类型安全的取消订阅方法 + // 取消订阅方法 public unsubscribe(messageType: string | '*', callback: (response: Socket.WebSocketResponse) => void) { const listeners = this.eventListeners.get(messageType) if (listeners) { diff --git a/src/libs/utils.ts b/src/libs/utils.ts index 03c644e..5e9fd95 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -40,3 +40,71 @@ export const sealStateMap = >{ leakText: '检漏中', stopping: '停止中', } + +export const compareJSON = (obj1: any, obj2: any) => { + const result: Record = {} + // 遍历obj1的所有属性 + for (const key in obj1) { + if (Object.prototype.hasOwnProperty.call(obj1, key)) { + if (!Object.prototype.hasOwnProperty.call(obj2, key)) { + // obj2中不存在该属性 + result[key] = { obj1: obj1[key], obj2: undefined } + } + else if (typeof obj1[key] !== typeof obj2[key]) { + // 类型不同 + result[key] = { obj1: obj1[key], obj2: obj2[key] } + } + else if (typeof obj1[key] === 'object' && obj1[key] !== null && obj2[key] !== null) { + // 递归比较对象 + const nestedDiff = compareJSON(obj1[key], obj2[key]) + if (Object.keys(nestedDiff).length > 0) { + result[key] = nestedDiff + } + } + else if (obj1[key] !== obj2[key]) { + // 基本类型值不同 + result[key] = { oldVal: obj1[key], newVal: obj2[key] } + } + } + } + return result +} + +let isFullscreen = false +export const openFullscreen = () => { + const elem = document.documentElement + if (!isFullscreen) { + isFullscreen = true + elem.requestFullscreen() + } + else { + isFullscreen = false + document.exitFullscreen() + } +} + +export const convertValuesToString = (jsonObj: Record, exName: string) => { + const result: Record = {} + for (const [key, value] of Object.entries(jsonObj)) { + if (key !== exName) { + result[key] = String(value) + } + else { + result[key] = value + } + } + return result +} + +export const convertValuesToInt = (jsonObj: Record, exName: string) => { + const result: Record = {} + for (const [key, value] of Object.entries(jsonObj)) { + if (key !== exName) { + result[key] = Number(value) + } + else { + result[key] = value + } + } + return result +} diff --git a/src/stores/formulaStore.ts b/src/stores/formulaStore.ts index 7ce5c0c..38b1a95 100644 --- a/src/stores/formulaStore.ts +++ b/src/stores/formulaStore.ts @@ -1,18 +1,23 @@ -import { syncSendCmd } from 'apis/system' +import { FtMessage } from '@/libs/message' +import { sendCmd, syncSendCmd } from 'apis/system' import { cloneDeep } from 'lodash' -import { nanoid } from 'nanoid' import { defineStore } from 'pinia' -import { ref } from 'vue' +import { computed, ref } from 'vue' -const logList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((el) => { - return { - value: el, - name: `${el} Log`, - } -}) +// 常量定义 +const LOG_ITEMS = Array.from({ length: 12 }, (_, i) => ({ + value: i + 1, + name: `${i + 1} Log`, +})) + +const PRESSURE_TYPES = [ + { name: '常压', value: 'constantPressure' }, + { name: '正压', value: 'positivePressure' }, + { name: '负压', value: 'negativePressure' }, +] -// 默认配方信息 -const createDefaultFormulaInfo = () => ({ +// 默认配方函数 +const createDefaultFormulaInfo = (): Formula.FormulaItem => ({ continued_gs: 200, continued_humi: 60, continued_satur: 60, @@ -25,114 +30,131 @@ const createDefaultFormulaInfo = () => ({ stoped_humi: 85, stoped_satur: 85, name: '默认配置', - formula_id: nanoid(), }) export const useFormulaStore = defineStore('formula', () => { - // 初始化数据 - const logEnums = logList - const pressurList = [ - { name: '常压', value: 'constantPressure' }, - { name: '正压', value: 'positivePressure' }, - { name: '负压', value: 'negativePressure' }, - ] - const logLevels = ref([{ - label: '', - value: '', - }]) + // 状态定义 + const logEnums = LOG_ITEMS + const pressurList = PRESSURE_TYPES + const logLevelOptions = ref([]) const defaultFormulaInfo = ref(createDefaultFormulaInfo()) - const pressurOptionList = ref(['10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%']) const currentSelectedFormulaInfo = ref(cloneDeep(defaultFormulaInfo.value)) - const selectedFormulaInfo = ref() - const initFormulaInfo = ref(cloneDeep(defaultFormulaInfo.value)) - // 配方可配置数据 + const selectedFormulaInfo = ref(null) const formulaConfigList = ref([]) const formulaList = ref([]) + const loglevel = ref('1') + + // 计算属性 + const isDefaultFormula = computed(() => currentSelectedFormulaInfo.value.name === defaultFormulaInfo.value.name) - const names: Record = {} - const initData = () => { - // 重置配方默认值 及 消毒等级 - formulaConfigList.value.forEach((item) => { - // defaultFormulaInfo.value[item.setting_id] = item.default_val - names[item.setting_id] = item.name_ch + // 私有 + const mapConfigToFormula = (config: Formula.FormulaConfig[]) => { + const formulaMap: Record = {} + config.forEach((item) => { + formulaMap[item.setting_id] = Number(item.val) if (item.val_type === 'enum' && item.setting_id === 'loglevel') { updateLogLevels(item) } }) + formulaMap.name = '默认配置' + return formulaMap as Formula.FormulaItem } + // 公共方法 const updateFormulaConfigData = (data: Formula.FormulaConfig[]) => { - const config = data.filter(item => item.is_visible_in_formula_page) - formulaConfigList.value = config - const formulaMap: Record = {} - config.forEach((item) => { - formulaMap[item.setting_id] = Number(item.val) - }) - formulaMap.name = '默认配置' - defaultFormulaInfo.value = formulaMap as Formula.FormulaItem + const visibleConfig = data.filter(item => item.is_visible_in_formula_page) + formulaConfigList.value = visibleConfig + defaultFormulaInfo.value = mapConfigToFormula(visibleConfig) } const updateLogLevels = (logLevelItem: Formula.FormulaConfig) => { const list: System.Option[] = [] - const enum_display_names = logLevelItem.enum_display_names - const enums = logLevelItem.enums - enums && enums.forEach((item: number, index: number) => { + const { enum_display_names, enums } = logLevelItem + loglevel.value = String(logLevelItem.default_val) + + enums?.forEach((item: number, index: number) => { list.push({ - label: enum_display_names[index], + label: enum_display_names?.[index] || '', value: item, }) }) - logLevels.value = list + logLevelOptions.value = list + } + + const updateLogLevel = (level: string) => { + loglevel.value = level } - // 配方中的压力控制 const updatePressurList = (pressurData: string[]) => { pressurOptionList.value = cloneDeep(pressurData) } - // 配方管理从列表中选择的配方 用来编辑及回显 const updateSelectedFormulaData = (formulaItem: Formula.FormulaItem) => { - console.error('formulaItem----', formulaItem) currentSelectedFormulaInfo.value = cloneDeep(formulaItem) } - // 从配方列表中选择的配方 const updateSelectedFormulaDataByList = (formulaItem: Formula.FormulaItem) => { selectedFormulaInfo.value = cloneDeep(formulaItem) } - const initFormulaList = () => { - const params = { - className: 'SettingMgrService', - fnName: 'getAllFormula', - params: {}, - } - syncSendCmd(params).then((res) => { + const initFormulaList = async () => { + try { + const params = { + className: 'SettingMgrService', + fnName: 'getAllFormula', + params: {}, + } + const res = await syncSendCmd(params) if (res.rely) { formulaList.value = res.rely } - }) + } + catch (error) { + console.error('获取配方列表失败', error) + } } const initFormulaData = () => { - initFormulaInfo.value = cloneDeep(defaultFormulaInfo.value) + selectedFormulaInfo.value = null + resetToDefaultFormula() + } + + const resetToDefaultFormula = () => { + currentSelectedFormulaInfo.value = cloneDeep(defaultFormulaInfo.value) } - initData() + const saveDisinfectFormula = async (formData: Formula.FormulaItem) => { + try { + const params = { + className: 'DisinfectionCtrlServiceExt', + fnName: 'startWithFormula', + params: { + formulaid: formData.formula_id, + }, + } + await sendCmd(params) + FtMessage.success('已启动消毒程序') + } + catch (error) { + console.error('保存消毒配方失败', error) + FtMessage.error('启动消毒程序失败') + } + } return { - // 变量 + // 属性 logEnums, pressurList, pressurOptionList, - initFormulaInfo, currentSelectedFormulaInfo, formulaList, formulaConfigList, - logLevels, + loglevel, + logLevelOptions, selectedFormulaInfo, defaultFormulaInfo, + isDefaultFormula, // 方法 updatePressurList, updateSelectedFormulaData, @@ -140,5 +162,8 @@ export const useFormulaStore = defineStore('formula', () => { initFormulaList, updateSelectedFormulaDataByList, updateFormulaConfigData, + saveDisinfectFormula, + updateLogLevel, + resetToDefaultFormula, } }) diff --git a/src/stores/homeStore.ts b/src/stores/homeStore.ts index c4538e9..461d39c 100644 --- a/src/stores/homeStore.ts +++ b/src/stores/homeStore.ts @@ -1,7 +1,7 @@ import { sendCmd } from 'apis/system' import { PARSSURE_DATA } from 'libs/constant' import { defineStore } from 'pinia' -import { ref } from 'vue' +import { computed, ref } from 'vue' // 空闲 idle // 初始化 init @@ -16,43 +16,37 @@ import { ref } from 'vue' const h2O2Data: Home.DisplayrelyMgrParams[] = [{ type: 'inside', title: '仓内', - temp: '20', - rh: '30', - rs: '40', - h2o2: '20', -}, { - type: 'probe1', - title: '探头1', - temp: '0', - rh: '0', - rs: '0', - h2o2: '0', -}, { - type: 'probe2', - title: '探头2', - temp: '0', - rh: '0', - rs: '0', - h2o2: '0', + temp: 0, + rh: 0, + rs: 0, + h2o2: 0, + chartId: 'inside', }] +// 消毒中状态初始值 +const initDisinfectState = { + curStateRemainTimeS: 0, + h2o2SensorData: h2O2Data, + injectedVelocity: 0, + nlog: 0, + state: 'idle', + statedisplayName: '空闲', + tlog: 0, +} + export const useHomeStore = defineStore('home', () => { const h2O2SensorData = ref(h2O2Data) + const pressureConfig = ref(PARSSURE_DATA) const curStateRemainTime = ref() - const loglevel = ref('1') - const logLevelList = [{ - label: '1级', - value: 1, - }, { - label: '2级', - value: 2, - }, { - label: '3级', - value: 3, - }, { - label: '4级', - value: 4, - }] + const disinfectionState = ref(initDisinfectState)// 当前设备正在消毒时的状态 + const deviceStete = ref({ state: 'idle' }) // 设备状态 + let renderTimer: any + + /** + * @function updateHomeData + * @params data 当前设备所有环境数据。 仓内、探头 + * @desc 获取当前的压力值 + */ const updateHomeData = (data: Home.DisplayrelyMgr[]) => { if (data && data.length) { data.forEach((item, index) => { @@ -64,8 +58,10 @@ export const useHomeStore = defineStore('home', () => { } } - // 压力值 - const pressureConfig = ref(PARSSURE_DATA) + /** + * @function getPressureConfig + * @desc 获取当前的压力值 + */ const getPressureConfig = async () => { const pressureParams = { className: 'PipelinePressureControl', @@ -76,7 +72,11 @@ export const useHomeStore = defineStore('home', () => { pressureConfig.value = res } - // 设置压力 + /** + * @function updatePressure + * @param pressureData : 数组 压力类型及选择的压力值 + * @desc 更新压力类型及选择的压力值 + */ const updatePressure = async (pressureData: string | number[]) => { if (pressureData && pressureData.length) { const type = pressureData[0] @@ -88,8 +88,7 @@ export const useHomeStore = defineStore('home', () => { }, } await sendCmd(pressureTypeParams) - // type 是正压或负压时保存设置的压力值 - if (type === 'positivePressure' || type === 'positivePressure') { + if (type === 'positivePressure' || type === 'positivePressure') { // type 是正压或负压时保存设置的压力值 const intensity = pressureData[1] const intensityParams = { className: 'PipelinePressureControl', @@ -103,65 +102,64 @@ export const useHomeStore = defineStore('home', () => { } } - // 设置消毒等级 - const updateLogLevel = (level: string) => { - loglevel.value = String(level) - } - - const stopDisinfect = () => { - disinfectionState.value.state = 'finished' - } - - // 设备状态 - const deviceStete = ref({ - state: 'idle', - }) + /** + * @function setDeviceState + * @param deviceInfo 当前设备状态 + */ const setDeviceState = (deviceInfo: Device.State) => { deviceStete.value = deviceInfo } - // 当前设备正在消毒时的状态 - const disinfectionState = ref({ - curStateRemainTimeS: 0, - h2o2SensorData: [ - { - h2o2: 0, - online: true, - rh: 32.79, - rs: 32.08, - temp: 25.89, - }, - ], - injectedVelocity: 0, - nlog: 0, - state: 'idle', - statedisplayName: '空闲', - tlog: 0, - }) + /** + * @function updateHomeDisinfectionState + * @param disinfectState 当前设备消毒状态 + */ const updateHomeDisinfectionState = (disinfectState: Home.DisinfectState) => { disinfectionState.value = disinfectState + if (!renderTimer) { + renderTimer = setTimeout(() => { + h2O2SensorData.value = [...disinfectionState.value.h2o2SensorData] // 创建副本 + renderTimer = null + }, 3000) as unknown as NodeJS.Timeout // 类型断言兼容不同环境 + } } + /** + * @function updateHomeRemainTime + * @param timer 当前设备消毒状态下的剩余时间 + */ const updateHomeRemainTime = (timer: string) => { curStateRemainTime.value = timer } + + const isDeviceIdle = computed(() => { + return disinfectionState.value.state.toLocaleLowerCase() === 'idle' || disinfectionState.value.state === 'finished' + }) + + const subscribeDisinfectEvent = () => { + // 发起订阅 + const subParams = { + className: 'DisinfectionCtrlServiceExt', + fnName: 'startStateReport', + params: {}, + } + sendCmd(subParams) + } return { - // 变量 + // 属性 h2O2SensorData, - logLevelList, - loglevel, deviceStete, disinfectionState, pressureConfig, curStateRemainTime, + isDeviceIdle, // 方法 updateHomeData, updatePressure, - updateLogLevel, - stopDisinfect, setDeviceState, updateHomeDisinfectionState, getPressureConfig, updateHomeRemainTime, + subscribeDisinfectEvent, } }) diff --git a/src/stores/initHomeData.ts b/src/stores/initHomeData.ts index d25ca31..a2bee33 100644 --- a/src/stores/initHomeData.ts +++ b/src/stores/initHomeData.ts @@ -7,14 +7,11 @@ const liquidStore = useLiquidStore() export const initData = async () => { // 初始化消毒液桶数据 - console.log('--------1-------') await initLiquidConfig() // 轮询设备状态、消毒状态、消毒液使用状态 // setInterval(() => { // }, 1000) - console.log('--------2-------') await initBaseData() - console.log('--------3-------') } const initLiquidConfig = async () => { @@ -24,7 +21,6 @@ const initLiquidConfig = async () => { params: {}, } const liquidConfig = await sendCmd(params) - console.log('liquidConfig----------', liquidConfig) liquidStore.initLiquidConfig(liquidConfig) } diff --git a/src/stores/liquidStore.ts b/src/stores/liquidStore.ts index 195a07a..bf3fbde 100644 --- a/src/stores/liquidStore.ts +++ b/src/stores/liquidStore.ts @@ -33,11 +33,13 @@ export const useLiquidStore = defineStore('Liquid', () => { } return { + // 属性 liquidAddWorkState, liquidDrainWorkState, liquidTotal, liquidPeriod, liquidStateData, + // 方法 updateAddLiquidWorkState, updateDrainLiquidWorkState, initLiquidConfig, diff --git a/src/stores/settingStore.ts b/src/stores/settingStore.ts index 6025978..ea7c6e9 100644 --- a/src/stores/settingStore.ts +++ b/src/stores/settingStore.ts @@ -19,51 +19,37 @@ export const useSettingStore = defineStore('setting', () => { code: 'deviceInfo', }] - const historyList = [ - { - name: '2021-01-03', - }, - { - name: '2021-01-02', - }, - { - name: '2021-01-01', - }, - ] + const historyList: Record[] = [] /* ********************** 用户管理 **************************** */ - const userList = ref([{ - uid: 'admin(管理员)', - passwd: '111', - is_admin: true, - id: '02384', - }, { - uid: '测试人员', - passwd: '222', - is_admin: true, - id: '1111', - }]) + const userList = ref([]) const addUserVisible = ref(false) + const modifyPwdVisible = ref(false) const userModalState = ref('add') - const currentEditUser = ref() + const currentEditUser = ref() const updateUserModalState = (state: string) => { userModalState.value = state } - const updateCurrentEditUser = (userItem: Setting.User) => { + const updateCurrentEditUser = (userItem: User.UserItem) => { currentEditUser.value = userItem } const updateVisible = (visible: boolean) => { addUserVisible.value = visible } + const updatePwdVisible = (visible: boolean) => { + modifyPwdVisible.value = visible + } return { settingMenus, historyList, addUserVisible, + modifyPwdVisible, userModalState, currentEditUser, userList, updateVisible, updateUserModalState, updateCurrentEditUser, + updatePwdVisible, } }) diff --git a/src/types/audit.d.ts b/src/types/audit.d.ts new file mode 100644 index 0000000..e92802b --- /dev/null +++ b/src/types/audit.d.ts @@ -0,0 +1,8 @@ +declare namespace Audit { + interface AuditItem { + behaviorZH: string + behaviorinfo: string + date: string + userName: string + } +} diff --git a/src/types/formula.d.ts b/src/types/formula.d.ts index 7c00c0d..b6e7e30 100644 --- a/src/types/formula.d.ts +++ b/src/types/formula.d.ts @@ -12,11 +12,11 @@ declare namespace Formula { stoped_humi: string | number stoped_satur: string | number name: string | number - formula_id: string | number + formula_id?: string | number } interface FormulaConfig { - default_val: number | boolean + default_val: string | number | boolean enum_display_names: Array enums: Array is_editable: boolean diff --git a/src/types/home.d.ts b/src/types/home.d.ts index 6772234..d3b766e 100644 --- a/src/types/home.d.ts +++ b/src/types/home.d.ts @@ -1,13 +1,14 @@ declare namespace Home { interface DisplayrelyMgr { - temp: string - rh: string - rs: string - h2o2: string + temp: number + rh: number + rs: number + h2o2: number } interface DisplayrelyMgrParams extends DisplayrelyMgr { type: string title: string + chartId: string } interface ResultData { @@ -18,11 +19,11 @@ declare namespace Home { getFormData: () => void } - interface DisinfectH2owState { - h2o2: string | number - temp: string | number - rh: string | number - rs: string | number + interface DisinfectH2owState extends DisplayrelyMgrParams { + h2o2: number + temp: number + rh: number + rs: number online?: boolean } diff --git a/src/types/user.d.ts b/src/types/user.d.ts index ee30fac..28988b8 100644 --- a/src/types/user.d.ts +++ b/src/types/user.d.ts @@ -30,4 +30,18 @@ declare namespace User { name: string roleType: string } + + interface UserItem { + id?: number + name: string + passwd: string + roleType: string + confirmPasswd?: string + } + + interface Passwd { + passwd: string + newpasswd: string + confirmNewpasswd?: string + } } diff --git a/src/views/audit/index.vue b/src/views/audit/index.vue index 6a95fc4..c29731c 100644 --- a/src/views/audit/index.vue +++ b/src/views/audit/index.vue @@ -1,30 +1,53 @@