From 83aa977be806b6f998ee889792c2dc1c38520e7c Mon Sep 17 00:00:00 2001 From: LiLongLong <13717757313@163.com> Date: Fri, 30 May 2025 21:11:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=B8=9A=E5=8A=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/system.ts | 44 +-- src/app.vue | 93 +++++-- src/assets/styles/variable.scss | 2 +- src/components/common/BTButton/index.vue | 2 +- src/components/common/FTDialog/index.vue | 2 +- src/components/common/SoftKeyboard/index.vue | 37 ++- src/components/formula/FormulaConfig.vue | 100 +++++-- src/components/formula/FormulaTable.vue | 39 ++- src/components/home/Environment.vue | 2 +- src/components/home/HomeFormula.vue | 2 +- src/components/home/HomeLogLevel.vue | 7 +- src/components/home/HomeOperation.vue | 129 +++++++-- src/components/home/HomeSetting.vue | 28 +- src/components/home/config.vue | 21 +- src/components/liquid/LiquidLevel.vue | 25 +- src/components/liquid/ScaleMark.vue | 11 - src/components/seal/DashboardChart.vue | 22 +- src/components/setting/History.vue | 105 ++++++- src/components/setting/HistoryDetail.vue | 67 +++++ src/layouts/default.vue | 95 ++++++- src/libs/countdownTimer.ts | 13 +- src/libs/messageBox.ts | 27 ++ src/libs/pinyinDict.json | 398 +++++++++++++++++++++++++++ src/libs/socket.ts | 65 +++-- src/libs/timer.ts | 47 ++++ src/libs/utils.ts | 11 +- src/router/index.ts | 2 +- src/stores/deviceStore.ts | 23 ++ src/stores/formulaStore.ts | 97 +++---- src/stores/homeStore.ts | 80 +++--- src/stores/initHomeData.ts | 68 +++++ src/stores/liquidStore.ts | 39 ++- src/stores/sealStore.ts | 12 +- src/stores/systemStore.ts | 67 +++-- src/types/device.d.ts | 9 + src/types/home.d.ts | 6 - src/types/liquid.d.ts | 12 + src/types/seal.d.ts | 9 +- src/types/setting.d.ts | 10 +- src/types/websocket.d.ts | 8 +- src/views/audit/index.vue | 64 +++-- src/views/debug/index.vue | 37 ++- src/views/formula/index.vue | 58 ++-- src/views/home/chart.vue | 5 +- src/views/home/index.vue | 50 ++-- src/views/liquid/index.vue | 160 +++++++++-- src/views/login/index.vue | 2 - src/views/seal/index.vue | 230 +++++++++++++--- src/views/setting/index.vue | 4 +- 49 files changed, 1954 insertions(+), 492 deletions(-) delete mode 100644 src/components/liquid/ScaleMark.vue create mode 100644 src/components/setting/HistoryDetail.vue create mode 100644 src/libs/messageBox.ts create mode 100644 src/libs/pinyinDict.json create mode 100644 src/libs/timer.ts create mode 100644 src/stores/deviceStore.ts create mode 100644 src/stores/initHomeData.ts diff --git a/src/apis/system.ts b/src/apis/system.ts index 608baf3..f3a6130 100644 --- a/src/apis/system.ts +++ b/src/apis/system.ts @@ -1,24 +1,36 @@ import { createWebSocket } from 'libs/socket' const wsClient = createWebSocket() -export async function sendCmd(params: { className: string, fnName: string, params: Record }) { +export async function sendCmd(resParams: { className: string, fnName: string, params: Record }) { const res = await wsClient.waitAndSend({ messageType: 'Command', - fnName: params.fnName, - className: params.className, + fnName: resParams.fnName, + className: resParams.className, messageId: `msg_${Date.now()}`, - params: params.params, + params: resParams.params, + }) + if (res.ackcode === 0) { + return res.rely + } + else { + throw new Error(res.message) + } +} +export async function syncSendCmd(resParams: { className: string, fnName: string, params: Record }) { + return await wsClient.sendRequest({ + messageType: 'Command', + fnName: resParams.fnName, + className: resParams.className, + messageId: `msg_${Date.now()}`, + params: resParams.params, + }) +} + +export async function subscribeEvent(fromFn: string | '*', callback: (response: Socket.WebSocketResponse) => void) { + wsClient.socket.addEventListener('message', (event) => { + const data = JSON.parse(event.data) + if (data.messageType === 'Report' && data.fromFn === fromFn) { + callback && callback(data) + } }) - return res } -// export const sendCmd = (params: { className: string, fnName: string }) => async () => { -// const res = await wsClient.waitAndSend({ -// messageType: 'Command', -// fnName: params.fnName, -// className: params.className, -// messageId: `msg_${Date.now()}`, -// params: { -// }, -// }) -// return res -// } diff --git a/src/app.vue b/src/app.vue index 537609c..66ea1e4 100644 --- a/src/app.vue +++ b/src/app.vue @@ -1,16 +1,60 @@ diff --git a/src/assets/styles/variable.scss b/src/assets/styles/variable.scss index 6e62db4..b1c617e 100644 --- a/src/assets/styles/variable.scss +++ b/src/assets/styles/variable.scss @@ -4,4 +4,4 @@ $danger-color: #DF1515; $warn-color: #EE8223; $info-color: #909399; $gradient-color: linear-gradient(185deg, rgb(175 216 255) -90%, #fff 24%); -$main-container: calc(100vh - 16vh) \ No newline at end of file +$main-container-height: calc(100vh - 16vh) \ No newline at end of file diff --git a/src/components/common/BTButton/index.vue b/src/components/common/BTButton/index.vue index c9fe4db..9589570 100644 --- a/src/components/common/BTButton/index.vue +++ b/src/components/common/BTButton/index.vue @@ -88,7 +88,7 @@ const handleClick = (event: MouseEvent) => { :loading="loading" :style="{ backgroundColor: disabled ? '#e8e8e8' : bgColor, - color: textColor, + color: disabled ? '#939393' : textColor, width, height, borderRadius, diff --git a/src/components/common/FTDialog/index.vue b/src/components/common/FTDialog/index.vue index bbbf805..91258b0 100644 --- a/src/components/common/FTDialog/index.vue +++ b/src/components/common/FTDialog/index.vue @@ -16,7 +16,6 @@ const props = defineProps({ }, okHandle: { type: Function, - default: () => {}, }, }) const emits = defineEmits(['update:visible', 'ok', 'cancel']) @@ -65,6 +64,7 @@ watch( @click="cancel" /> +// import pinyinDict from 'libs/pinyinDict.json' import { computed, defineEmits, defineProps, onMounted, ref, watch, watchEffect } from 'vue' const props = defineProps<{ @@ -13,7 +14,9 @@ const emits = defineEmits<{ (e: 'confirm', value: string): void (e: 'close'): void }>() - +const languageType = ref('en') +// const cnList = ref([]) +// const pinyinMap: Record = pinyinDict as unknown as Record onMounted(() => { document.addEventListener('click', (e: any) => { if (isOpen.value && !e.target?.name) { @@ -46,10 +49,13 @@ const keyboardLayout = computed(() => { ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '/'], ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 'enter'], ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '?', '.', ':'], - [' ', 'close'], + [' ', 'en', 'close'], ] }) const specialKeys = ['del', 'enter', ' '] +// const handleKeyCn = (cn: string) => { +// console.log('cn===', cn) +// } const handleKeyPress = (key: string) => { activeKey.value = key setTimeout(() => { @@ -66,8 +72,19 @@ const handleKeyPress = (key: string) => { else if (key === 'close') { closeKeyboard() } + else if ((key === 'en' || key === 'cn') && props.keyboardType === 'text') { + languageType.value = key === 'en' ? 'cn' : 'en' + keyboardLayout.value[4][1] = key === 'en' ? 'cn' : 'en' + } else { - emits('update:modelValue', props.modelValue + key) + const keyValue = props.modelValue + key + emits('update:modelValue', keyValue) + // if (props.keyboardType === 'text' && languageType.value === 'cn') { + // const cn = pinyinMap[keyValue] + // if (cn.length) { + // cnList.value = cn as unknown as string[] + // } + // } } } @@ -89,6 +106,18 @@ watch(() => props.isVisible, (newVal) => { -->
+
diff --git a/src/components/formula/FormulaConfig.vue b/src/components/formula/FormulaConfig.vue index efd3f4e..5f7e47b 100644 --- a/src/components/formula/FormulaConfig.vue +++ b/src/components/formula/FormulaConfig.vue @@ -1,13 +1,17 @@ @@ -53,12 +72,12 @@ const deleteRecipe = (index: number) => { :class="{ selected: selectedIndex === index }" @click="selectRecipe(item, index)" > - {{ item.name ? item.name : `配方${index + 1}` }} + {{ item.name }}
- diff --git a/src/components/home/Environment.vue b/src/components/home/Environment.vue index a403c56..3446794 100644 --- a/src/components/home/Environment.vue +++ b/src/components/home/Environment.vue @@ -88,7 +88,7 @@ onMounted(() => { .env-row{ display: grid; grid-template-columns: repeat(2, 1fr); - height: 4.8vw; + height: 7.8vh; padding: 7px; .env-row-label{ display: flex; diff --git a/src/components/home/HomeFormula.vue b/src/components/home/HomeFormula.vue index 0d5b4ed..dcef2f2 100644 --- a/src/components/home/HomeFormula.vue +++ b/src/components/home/HomeFormula.vue @@ -6,7 +6,7 @@ import { ref, watchEffect } from 'vue' const formulaStore = useFormulaStore() const formulaInfo = ref() watchEffect(() => { - formulaInfo.value = formulaStore.currentSelectedFormulaInfo + formulaInfo.value = formulaStore.selectedFormulaInfo }) diff --git a/src/components/home/HomeLogLevel.vue b/src/components/home/HomeLogLevel.vue index b2feff3..4769e3c 100644 --- a/src/components/home/HomeLogLevel.vue +++ b/src/components/home/HomeLogLevel.vue @@ -1,11 +1,13 @@ diff --git a/src/components/home/HomeSetting.vue b/src/components/home/HomeSetting.vue index 5d1d174..4cb4914 100644 --- a/src/components/home/HomeSetting.vue +++ b/src/components/home/HomeSetting.vue @@ -6,7 +6,8 @@ import homeRunSvg from 'assets/images/home/home-run.svg' import homeSettingSvg from 'assets/images/home/home-setting.svg' import CascadingSelectModal from 'components/common/CascadingSelectModal/index.vue' import Config from 'components/home/Config.vue' -import { onMounted, provide, ref } from 'vue' +import { cloneDeep } from 'lodash' +import { onMounted, provide, ref, watchEffect } from 'vue' import { useRouter } from 'vue-router' const configRef = ref() @@ -21,13 +22,26 @@ const isModalOpen = ref(false) const optionsLeft = ref([]) const optionsRight = ref([]) const selectedValue = ref() +const disinfectionState = ref(homeStore.disinfectionState) // 消毒设置 const disinfectFormulaVisible = ref(false) +const selectedByFormulas = ref(cloneDeep(formulaStore.selectedFormulaInfo)) + const onDisinfectConfig = () => { - formulaStore.initFormulaData() + if (selectedByFormulas.value) { + formulaStore.updateSelectedFormulaDataByList(cloneDeep(selectedByFormulas.value)) + } + else { + formulaStore.updateSelectedFormulaDataByList(cloneDeep(formulaStore.defaultFormulaInfo)) + } disinfectFormulaVisible.value = true } +watchEffect(() => { + disinfectionState.value = homeStore.disinfectionState + selectedByFormulas.value = formulaStore.selectedFormulaInfo +}) + onMounted(() => { // 初始化正负压力值 homeStore.getPressureConfig() @@ -40,7 +54,7 @@ const onShowChart = () => { // 保存消毒参数 const onSave = () => { const formData = configRef.value?.getFormData() - formulaStore.updateSelectedFormulaData(formData) + formulaStore.updateSelectedFormulaDataByList(cloneDeep(formData)) onClose() } @@ -48,7 +62,6 @@ const onSave = () => { const onSetPressure = () => { // 接口中获取压力值 const pressureConfig = homeStore.pressureConfig - console.log('pressureConfig---', pressureConfig) const { typeDisplayNames, types } = pressureConfig const intensitys: Record = pressureConfig.intensitys const left: System.Option[] = [] @@ -78,9 +91,9 @@ const onSetPressure = () => { isModalOpen.value = true } -const handleConfirm = (value: string[]) => { - console.log('value---', value) +const handleConfirm = (value: string | number[]) => { isModalOpen.value = false + homeStore.updatePressure(value) } const handleCancel = () => { isModalOpen.value = false @@ -112,6 +125,7 @@ const onClose = () => { border-radius="5px" text-color="#1989fa" padding="0.8vw" + :disabled="disinfectionState.state === 'idle'" @click="onShowChart" >