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" >