Browse Source

小键盘

master
maochaoying 2 years ago
parent
commit
dbda496e50
  1. 6
      .env
  2. 36
      src/components/LiquidHandle.vue
  3. 47
      src/components/Operator.vue
  4. 6
      src/components/Progress.vue
  5. 6
      src/components/SimpleKeyboard.vue
  6. 9
      src/components/dialogs/LiquidModal.vue
  7. 7
      src/mock/command.js
  8. 40
      src/pages/Home.vue
  9. 6
      src/store/modules/websocket.js

6
.env

@ -1 +1,5 @@
VITE_BASE_URL=http://127.0.0.1:8080/
VITE_BASE_WS1_URL=ws://192.168.8.10:19001/
VITE_BASE_WS2_URL=ws://192.168.8.10:19002/
# VITE_BASE_WS1_URL=ws://127.0.0.1:19001/
# VITE_BASE_WS2_URL=ws://127.0.0.1:19002/

36
src/components/LiquidHandle.vue

@ -17,7 +17,7 @@
v-if="tabType == 1" v-if="tabType == 1"
@click="stopAdd" @click="stopAdd"
> >
停加液
加液
</div> </div>
<div <div
:class="isAddLiquidStatus ? 'btn' : 'btn active'" :class="isAddLiquidStatus ? 'btn' : 'btn active'"
@ -26,7 +26,18 @@
> >
开始加液 开始加液
</div> </div>
<div class="btn active" v-if="tabType == 2" @click="startTabLiquid">
<div
:class="isPopLiquidStatus ? 'btn mr active' : 'btn mr '"
v-if="tabType == 2"
@click="stopPop"
>
停止排液
</div>
<div
:class="isPopLiquidStatus ? 'btn' : 'btn active'"
v-if="tabType == 2"
@click="startTabLiquid"
>
开始排液 开始排液
</div> </div>
</div> </div>
@ -61,6 +72,8 @@
<LiquidModal <LiquidModal
v-if="tabType == 2 && tipModalVisible" v-if="tabType == 2 && tipModalVisible"
:hideTabLiquid="hideTabLiquid" :hideTabLiquid="hideTabLiquid"
:startPopFlag="startPopFlag"
:isPopLiquidStatus="isPopLiquidStatus"
/> />
</div> </div>
</template> </template>
@ -73,6 +86,7 @@ import { storeToRefs } from 'pinia'
import { import {
startReplenishingFluidsJSON, startReplenishingFluidsJSON,
stopReplenishingFluidsJSON, stopReplenishingFluidsJSON,
stopDrainingJSON,
} from '@/mock/command' } from '@/mock/command'
const props = defineProps({ const props = defineProps({
@ -86,20 +100,38 @@ const tipModalVisible = ref(false)
const webSocketStore = useWebSocketStore() const webSocketStore = useWebSocketStore()
const isAddLiquidStatus = ref(false) const isAddLiquidStatus = ref(false)
const isPopLiquidStatus = ref(false)
const startAdd = () => { const startAdd = () => {
if (!isAddLiquidStatus.value) {
isAddLiquidStatus.value = true isAddLiquidStatus.value = true
webSocketStore.sendCommandMsg(startReplenishingFluidsJSON) webSocketStore.sendCommandMsg(startReplenishingFluidsJSON)
} }
}
const stopAdd = () => { const stopAdd = () => {
if (isAddLiquidStatus.value) {
isAddLiquidStatus.value = false isAddLiquidStatus.value = false
webSocketStore.sendCommandMsg(stopReplenishingFluidsJSON) webSocketStore.sendCommandMsg(stopReplenishingFluidsJSON)
} }
}
const stopPop = () => {
if (isPopLiquidStatus.value) {
webSocketStore.sendCommandMsg(stopDrainingJSON)
isPopLiquidStatus.value = false
}
}
const startPopFlag = () => {
isPopLiquidStatus.value = true
}
const startTabLiquid = () => { const startTabLiquid = () => {
if (!isPopLiquidStatus.value) {
tipModalVisible.value = true tipModalVisible.value = true
} }
}
const formatter = value => { const formatter = value => {
if (value > 500) { if (value > 500) {

47
src/components/Operator.vue

@ -37,6 +37,8 @@
:disabled="operatorStore.disinfectStatus" :disabled="operatorStore.disinfectStatus"
v-model="roomSize" v-model="roomSize"
class="room_size" class="room_size"
id="room_size"
@focus="handleShowKeyBoard"
/> />
<div class="log" @click="showLogPicker">{{ logVal }}</div> <div class="log" @click="showLogPicker">{{ logVal }}</div>
</div> </div>
@ -47,8 +49,8 @@
开始消毒 开始消毒
</div> </div>
<div class="progress"> <div class="progress">
<p class="title">消毒进度</p>
<div class="tube">
<p class="title">剩余时间</p>
<!-- <div class="tube">
<div <div
class="pro" class="pro"
:style="{ :style="{
@ -56,7 +58,14 @@
}" }"
></div> ></div>
</div> </div>
<div class="num">000/100</div>
<div class="num">000/100</div> -->
<div class="time">
{{
operatorStore.disinfectStatus
? `${operatorStore.estimatedRemainingTimeS} S`
: '未开始'
}}
</div>
</div> </div>
</div> </div>
<!-- <WarnModal /> --> <!-- <WarnModal /> -->
@ -73,9 +82,9 @@ import LogPicker from 'cpns/dialogs/LogPicker'
import WarnModal from 'cpns/dialogs/WarnModal' import WarnModal from 'cpns/dialogs/WarnModal'
import DisinfectantLiquidInfo from 'cpns/info/DisinfectantLiquidInfo' import DisinfectantLiquidInfo from 'cpns/info/DisinfectantLiquidInfo'
import EnvironmentInfo from 'cpns/info/EnvironmentInfo' import EnvironmentInfo from 'cpns/info/EnvironmentInfo'
import { ref } from 'vue'
import { ref, watch, onMounted, onUnmounted } from 'vue'
import { useOperatorStore, useWebSocketStore } from '@/store' import { useOperatorStore, useWebSocketStore } from '@/store'
import { startDisinfectionJSON } from '@/mock/command'
import { startDisinfectionJSON, getStateJSON } from '@/mock/command'
import { showSuccessToast, showFailToast } from 'vant' import { showSuccessToast, showFailToast } from 'vant'
const operatorStore = useOperatorStore() const operatorStore = useOperatorStore()
@ -85,6 +94,15 @@ const props = defineProps({
changeShowOperator: { changeShowOperator: {
type: Function, type: Function,
}, },
handleShowKeyBoard: {
type: Function,
},
hideKeyBoard: {
type: Function,
},
input: {
type: String,
},
}) })
const toDetail = () => { const toDetail = () => {
@ -98,6 +116,11 @@ const logVisible = ref(false)
const logVal = ref(1) const logVal = ref(1)
const roomSize = ref(0) const roomSize = ref(0)
watch(() => {
console.log(props.input)
roomSize.value = props.input.match(/\d+/g)
})
const changeLogVal = val => { const changeLogVal = val => {
logVal.value = val logVal.value = val
logVisible.value = false logVisible.value = false
@ -123,6 +146,16 @@ const showLogPicker = () => {
logVisible.value = true logVisible.value = true
} }
} }
const timer = ref(null)
onMounted(() => {
timer.value = setInterval(() => {
webSocketStore.sendCommandMsg(getStateJSON)
}, 1000)
})
onUnmounted(() => {
timer.value = null
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -285,6 +318,10 @@ const showLogPicker = () => {
color: #9e9e9e; color: #9e9e9e;
margin-bottom: 13px; margin-bottom: 13px;
} }
.time {
text-align: center;
padding: 10px;
}
.tube { .tube {
width: 292px; width: 292px;
height: 14px; height: 14px;

6
src/components/Progress.vue

@ -50,7 +50,11 @@
<script setup> <script setup>
import { useOperatorStore, useWebSocketStore } from '@/store' import { useOperatorStore, useWebSocketStore } from '@/store'
import { stopDisinfectionJSON, getStateJSON } from '@/mock/command'
import {
stopDisinfectionJSON,
getStateJSON,
getAllRecordsJSON,
} from '@/mock/command'
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
const operatorStore = useOperatorStore() const operatorStore = useOperatorStore()

6
src/components/SimpleKeyboard.vue

@ -1,5 +1,5 @@
<template> <template>
<div :class="keyboardClass"></div>
<div :class="keyboardClass" id="keyboard"></div>
</template> </template>
<script> <script>
@ -16,6 +16,10 @@ export default {
input: { input: {
type: String, type: String,
}, },
hideKeyBoard: {
type: Function,
default: () => {},
},
}, },
data: () => ({ data: () => ({
keyboard: null, keyboard: null,

9
src/components/dialogs/LiquidModal.vue

@ -42,12 +42,21 @@ const props = defineProps({
hideTabLiquid: { hideTabLiquid: {
type: Function, type: Function,
}, },
startPopFlag: {
type: Function,
},
isPopLiquidStatus: {
type: Boolean,
},
}) })
const tapLiquid = () => { const tapLiquid = () => {
if (!props.isPopLiquidStatus) {
props.startPopFlag()
webSocketStore.sendCommandMsg(startDrainingJSON) webSocketStore.sendCommandMsg(startDrainingJSON)
props?.hideTabLiquid() props?.hideTabLiquid()
} }
}
const cancelTap = () => { const cancelTap = () => {
props?.hideTabLiquid() props?.hideTabLiquid()

7
src/mock/command.js

@ -63,7 +63,7 @@ export const getAllSettingJSON = {
messageId: 'getAllSetting', messageId: 'getAllSetting',
} }
export const getAllRecords = disinfection_id => {
export const getAllRecordsJSON = disinfection_id => {
return { return {
command: 'getAllRecords', command: 'getAllRecords',
messageId: 'getAllRecords', messageId: 'getAllRecords',
@ -113,3 +113,8 @@ export const startDrainingJSON = {
command: 'startDraining', command: 'startDraining',
messageId: 'startDraining', messageId: 'startDraining',
} }
export const stopDrainingJSON = {
command: 'stopDraining',
messageId: 'stopDraining',
}

40
src/pages/Home.vue

@ -123,6 +123,9 @@
<Operator <Operator
v-if="activeTab == 1 && showOpertor" v-if="activeTab == 1 && showOpertor"
:changeShowOperator="changeShowOperator" :changeShowOperator="changeShowOperator"
:handleShowKeyBoard="handleShowKeyBoard"
:hideKeyBoard="hideKeyBoard"
:input="input"
/> />
<Progress <Progress
v-if="activeTab == 1 && !showOpertor" v-if="activeTab == 1 && !showOpertor"
@ -173,11 +176,19 @@
</div> </div>
</div> </div>
</van-overlay> --> </van-overlay> -->
<div class="key_wrap" v-if="showkeyboard">
<SimpleKeyboard
:hideKeyBoard="hideKeyBoard"
@onChange="onChange"
:input="input"
/>
</div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue' import { ref, onMounted, onBeforeUnmount } from 'vue'
import SimpleKeyboard from 'cpns/SimpleKeyboard'
import moment from 'moment' import moment from 'moment'
import Operator from 'cpns/Operator' import Operator from 'cpns/Operator'
import Progress from 'cpns/Progress' import Progress from 'cpns/Progress'
@ -203,6 +214,16 @@ const { socketCommandInstance } = storeToRefs(webSocketStore)
webSocketStore.initCommandSocket() webSocketStore.initCommandSocket()
webSocketStore.initEventSocket() webSocketStore.initEventSocket()
const showkeyboard = ref(false)
const handleShowKeyBoard = () => {
showkeyboard.value = true
}
const hideKeyBoard = () => {
showkeyboard.value = false
}
const showOpertor = ref(true) const showOpertor = ref(true)
const operatorStore = useOperatorStore() const operatorStore = useOperatorStore()
@ -214,6 +235,11 @@ const changeShowOperator = flag => {
showOpertor.value = flag showOpertor.value = flag
} }
const input = ref('')
const onChange = a => {
input.value = a
}
const changeTab = index => { const changeTab = index => {
activeTab.value = index activeTab.value = index
if (index == 5) { if (index == 5) {
@ -234,6 +260,13 @@ onMounted(() => {
setTimeout(() => { setTimeout(() => {
webSocketStore.sendCommandMsg(getStateJSON) webSocketStore.sendCommandMsg(getStateJSON)
}, 1000) }, 1000)
document.addEventListener('click', e => {
let box = document.getElementById('keyboard')
let room = document.getElementById('room_size')
if (!box?.contains(e.target) && e.target != room) {
hideKeyBoard()
}
})
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
@ -253,6 +286,13 @@ const handleLogout = () => {
height: 800px; height: 800px;
box-sizing: border-box; box-sizing: border-box;
padding: 30px; padding: 30px;
.key_wrap {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 230px;
}
.header_menu { .header_menu {
width: 100%; width: 100%;
height: 80px; height: 80px;

6
src/store/modules/websocket.js

@ -20,7 +20,7 @@ export const useWebSocketStore = defineStore({
// actions // actions
actions: { actions: {
initCommandSocket() { initCommandSocket() {
const url = 'ws://192.168.8.115:19001/'
const url = import.meta.env.VITE_BASE_WS1_URL
const init = new Socket(url) const init = new Socket(url)
const settingStore = useSettingStore() const settingStore = useSettingStore()
const userStore = useUserStore() const userStore = useUserStore()
@ -105,6 +105,8 @@ export const useWebSocketStore = defineStore({
break break
case 'login': case 'login':
break break
case 'getAllRecords':
break
case 'getAllSetting': case 'getAllSetting':
const { dbval: allSetting } = JSON.parse(ev.data) const { dbval: allSetting } = JSON.parse(ev.data)
settingStore.updateAllSettingList(allSetting) settingStore.updateAllSettingList(allSetting)
@ -120,7 +122,7 @@ export const useWebSocketStore = defineStore({
this.socketCommandInstance?.msg(message) this.socketCommandInstance?.msg(message)
}, },
initEventSocket() { initEventSocket() {
const url = 'ws://192.168.8.115:19002/'
const url = import.meta.env.VITE_BASE_WS2_URL
const init = new Socket(url) const init = new Socket(url)
init.connect() init.connect()
const deviceStore = useDeviceStore() const deviceStore = useDeviceStore()

Loading…
Cancel
Save