Browse Source

按钮状态

master
maochaoying 2 years ago
parent
commit
3889b177d6
  1. 9
      src/api/index.js
  2. 121
      src/pages/index.vue

9
src/api/index.js

@ -21,13 +21,20 @@ export const breakOffAutoCheckApi = id => {
}) })
} }
export const saveCheckResult = (checkNumber, currentTaskId) => {
export const saveCheckResult = (
checkNumber,
currentTaskId,
result_serial,
result_img,
) => {
return request({ return request({
url: `/check/save`, url: `/check/save`,
method: 'POST', method: 'POST',
data: { data: {
checkNumber, checkNumber,
taskId: currentTaskId, taskId: currentTaskId,
result_serial,
result_img,
}, },
}) })
} }

121
src/pages/index.vue

@ -306,11 +306,13 @@
</div> </div>
</div> </div>
<div class="progress_btn"> <div class="progress_btn">
<p class="title">核查进度0/121</p>
<t-progress theme="plump" :percentage="0" />
<p class="title">
核查进度{{ hasTestedLength }} / {{ testArrLength }}
</p>
<t-progress theme="plump" :percentage="detailProcess" />
</div> </div>
<div class="history_btn">
<p class="first">3号核反应堆</p>
<div class="history_btn" @click="catCurrentTaskDetail">
<p class="first">{{ imageStore.nuclearCoreName }}</p>
<p class="second">当前历史记录</p> <p class="second">当前历史记录</p>
</div> </div>
</div> </div>
@ -366,7 +368,7 @@ import {
import socket from '@/utils/websocket' import socket from '@/utils/websocket'
import Cookie from '@/utils/cookie' import Cookie from '@/utils/cookie'
import { MessagePlugin } from 'tdesign-vue-next' import { MessagePlugin } from 'tdesign-vue-next'
import { ref, onMounted, computed } from 'vue'
import { ref, onMounted, computed, onUnmounted } from 'vue'
import Excel from 'cpns/Excel' import Excel from 'cpns/Excel'
import Nuclear from 'cpns/Nuclear' import Nuclear from 'cpns/Nuclear'
import Image from 'cpns/Image' import Image from 'cpns/Image'
@ -377,6 +379,7 @@ import DetailTable from 'cpns/DetailTable'
import Debug from 'cpns/Debug' import Debug from 'cpns/Debug'
import { startAutoCheckApi, breakOffAutoCheckApi, saveCheckResult } from '@/api' import { startAutoCheckApi, breakOffAutoCheckApi, saveCheckResult } from '@/api'
import { getProcessTaskInfoApi, getNextCoordApi } from '@/api/task' import { getProcessTaskInfoApi, getNextCoordApi } from '@/api/task'
import { getCharacterRecognitionResult } from '@/command'
const accountStore = useAccountStore() const accountStore = useAccountStore()
const taskStore = useTaskStore() const taskStore = useTaskStore()
const imageStore = useImageStore() const imageStore = useImageStore()
@ -468,7 +471,7 @@ const getInitData = async () => {
} else { } else {
taskStore.updateCurrentCoord(null) taskStore.updateCurrentCoord(null)
// taskStore.updateCurrentTaskId(null) // taskStore.updateCurrentTaskId(null)
taskStore.updateExcelData([])
// taskStore.updateExcelData([])
imageStore.updateShowImage(false) imageStore.updateShowImage(false)
taskStore.updateCheckStatus(false) taskStore.updateCheckStatus(false)
taskStore.updateTaskStatus(0) taskStore.updateTaskStatus(0)
@ -522,15 +525,10 @@ const nextBtn = async () => {
} }
const check = async () => { const check = async () => {
const checkNumber = checkStore.checkNumber
const currentTaskId = taskStore.currentTaskId
// //
// //
const res = await saveCheckResult(checkNumber, currentTaskId)
if (res?.code == 200) {
//
// exceldata
}
// ws
websocketsend(getCharacterRecognitionResult)
} }
onMounted(async () => { onMounted(async () => {
@ -539,7 +537,104 @@ onMounted(async () => {
getInitData() getInitData()
}) })
const catCurrentTaskDetail = () => {
const currentTaskId = taskStore.currentTaskId
//
taskStore.updateCurrentDetailTaskId(currentTaskId)
imageStore.updateShowImage(false)
accountStore.changePage(0)
taskStore.getExcelList(currentTaskId)
}
onUnmounted(() => {
websock.value.close()
})
// websocket // websocket
//
const lockReconnect = ref(false)
//
const timeoutnum = ref(null)
const websock = ref(null)
const reconnect = () => {
//
if (lockReconnect.value) {
return
}
lockReconnect.value = true
//
timeoutnum.value && clearTimeout(timeoutnum.value)
timeoutnum.value = setTimeout(function () {
//
initWebSocket()
lockReconnect.value = false
}, 5000)
}
//
const websocketonmessage = async e => {
//
const data = JSON.parse(e.data)
const checkNumber = checkStore.checkNumber
const currentTaskId = taskStore.currentTaskId
console.log(data)
const { messageId, success } = data
if (success) {
switch (messageId) {
case 'getCharacterRecognitionResult':
// result
// result_img
// result_serial
const res = await saveCheckResult(checkNumber, currentTaskId)
if (res?.code == 200) {
//
// exceldata
taskStore.getExcelList(taskStore.currentTaskId)
}
break
default:
break
}
} else {
MessagePlugin('error', { content: 'ws发送指令执行错误' })
}
}
const websocketonopen = () => {
console.log('客户端链接成功!!!')
}
const websocketonerror = () => {
reconnect()
}
//
const websocketsend = data => {
websock.value.send(data)
}
const websocketclose = () => {
reconnect()
}
const initWebSocket = () => {
//weosocket
const wsuri = import.meta.env.VITE_WEBSOCKET_CAMERA_URL
websock.value = new WebSocket(wsuri)
//
websock.value.onmessage = websocketonmessage
//
websock.value.onopen = websocketonopen
//
websock.value.onerror = websocketonerror
//
websock.value.onclose = websocketclose
}
initWebSocket()
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

Loading…
Cancel
Save