Browse Source

时间

master
maochaoying 2 years ago
parent
commit
a8552a425a
  1. 13
      src/components/dialogs/DatePicker.vue
  2. 12
      src/components/dialogs/TimePicker.vue
  3. 20
      src/mock/command.js

13
src/components/dialogs/DatePicker.vue

@ -49,10 +49,13 @@
<script setup>
import { ref } from 'vue'
import { useSettingStore } from '@/store'
import { useSettingStore, useWebSocketStore } from '@/store'
import moment from 'moment'
import { updateDateJSON } from '@/mock/command'
const settingStore = useSettingStore()
const webSocketStore = useWebSocketStore()
const props = defineProps({
hideDatePicker: {
type: Function,
@ -80,6 +83,14 @@ const handleCancel = () => {
const selectDate = () => {
settingStore.updateCurrentDate(currentDate.value)
console.log(currentDate.value)
webSocketStore.sendCommandMsg(
updateDateJSON(
parseInt(currentDate.value[0]),
parseInt(currentDate.value[1]),
parseInt(currentDate.value[2]),
),
)
props.hideDatePicker()
}
</script>

12
src/components/dialogs/TimePicker.vue

@ -48,10 +48,13 @@
<script setup>
import { ref } from 'vue'
import { useSettingStore } from '@/store'
import { useSettingStore, useWebSocketStore } from '@/store'
import moment from 'moment'
import { updateTimeJSON } from '@/mock/command'
const settingStore = useSettingStore()
const webSocketStore = useWebSocketStore()
const props = defineProps({
hideTimePicker: {
type: Function,
@ -75,6 +78,13 @@ const handleCancel = () => {
const selectTime = () => {
settingStore.updateCurrentTime(currentTime.value)
webSocketStore.sendCommandMsg(
updateTimeJSON(
parseInt(currentTime.value[0]),
parseInt(currentTime.value[1]),
0,
),
)
props.hideTimePicker()
}
</script>

20
src/mock/command.js

@ -157,3 +157,23 @@ export const sprayLiquidPump_open_for_testJSON = (ctrl, speed) => {
speed,
}
}
export const updateDateJSON = (year, month, day) => {
return {
command: 'updateDate',
messageId: 'updateDate',
year,
month,
day,
}
}
export const updateTimeJSON = (hour, min, second) => {
return {
command: 'updateTime',
messageId: 'updateTime',
hour,
min,
second,
}
}
Loading…
Cancel
Save