Browse Source

fix:状态添加

master
guoapeng 5 months ago
parent
commit
add7d772ae
  1. 3
      .env.dev
  2. 3
      .env.prod
  3. 3
      .env.test
  4. 3
      .eslintrc-auto-import.json
  5. 1
      auto-imports.d.ts
  6. 17
      src/apis/system.ts
  7. 40
      src/components/common/FTButton/index.vue
  8. 9
      src/components/common/FTDialog/index.vue
  9. 13
      src/components/common/FTStream/index.vue
  10. 158
      src/components/home/Check/index.vue
  11. 28
      src/components/home/stop/index.vue
  12. 17
      src/components/martixCraft/Edit/index.vue
  13. 4
      src/components/point/Edit/index.vue
  14. 104
      src/components/spray/startSpray/index.vue
  15. 19
      src/components/spray/trayGraph/index.vue
  16. 1
      src/env.d.ts
  17. 10
      src/libs/http.ts
  18. 4
      src/libs/socket.ts
  19. 183
      src/libs/utils.ts
  20. 21
      src/stores/useSystemStore.ts
  21. 23
      src/views/clean/index.vue
  22. 238
      src/views/debug/index.vue
  23. 21
      src/views/home/index.vue
  24. 13
      src/views/login/index.vue
  25. 54
      src/views/main/index.vue
  26. 1
      src/views/point/index.vue
  27. 123
      src/views/spray/index.vue
  28. 81
      src/views/spraySet/index.vue
  29. 4
      vite.config.ts

3
.env.dev

@ -2,4 +2,5 @@
FT_NODE_ENV=dev
FT_WS_URL=ws://192.168.1.199:8080/ws
FT_WS_URL=ws://192.168.1.199:8080/ws
FT_PROXY=http://192.168.1.199:8080

3
.env.prod

@ -2,4 +2,5 @@
FT_NODE_ENV=prod
FT_WS_URL=ws://192.168.1.168/ws
FT_WS_URL=ws://192.168.1.168/ws
FT_PROXY=http://192.168.1.168

3
.env.test

@ -2,4 +2,5 @@
FT_NODE_ENV=test
FT_WS_URL=ws://192.168.1.205/ws/
FT_WS_URL=ws://192.168.1.200:8080/ws
FT_PROXY=http://192.168.1.199:8080

3
.eslintrc-auto-import.json

@ -76,6 +76,7 @@
"watchEffect": true,
"watchPostEffect": true,
"watchSyncEffect": true,
"withModifiers": true
"withModifiers": true,
"ElNotification": true
}
}

1
auto-imports.d.ts

@ -7,6 +7,7 @@
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const ElNotification: typeof import('element-plus/es')['ElNotification']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']

17
src/apis/system.ts

@ -6,20 +6,7 @@ import http from 'libs/http'
*/
export const login = (params: { username: string, password: string }) => http.post('/auth/login', params)
export const getStreamData = () => fetch('/api/cmd/stream-data')
export const control = (params: any) => fetch('/api/device/front/control', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
})
export const control = (params: any) => http.post('/function', params)
export const debugControl = (params: any) => fetch('/api/device/debug/front/control', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
})
export const debugControl = (params: any) => http.post('/function/debug', params)

40
src/components/common/FTButton/index.vue

@ -1,5 +1,7 @@
<script setup lang="ts">
defineProps({
import { ref } from 'vue'
const props = defineProps({
type: {
type: String,
default: 'default',
@ -12,20 +14,48 @@ defineProps({
type: Boolean,
default: false,
},
onClick: {
type: Function,
required: false,
default: () => Promise<any>,
},
})
const isLoading = ref(false)
async function handleClick() {
if (!props.onClick || isLoading.value)
return
isLoading.value = true // loading
try {
await props.onClick() //
}
finally {
isLoading.value = false // loading
}
}
const setLoading = (loading: boolean) => {
isLoading.value = loading
}
defineExpose({
setLoading,
})
</script>
<template>
<div class="ft-button" :class="{ 'ft-button-disabled': disabled || loading }">
<div class="ft-button" :class="{ 'ft-button-disabled': disabled || isLoading }" @click="handleClick">
<!-- 添加 loading 判断 -->
<div v-show="disabled || loading" class="my-button-shadow" /> <!-- 添加 loading 判断 -->
<div v-show="disabled || isLoading" class="my-button-shadow" /> <!-- 添加 loading 判断 -->
<div
class="my-button" :class="{
[`my-button-${type}`]: true,
'button-disabled': disabled || loading, // loading
'button-disabled': disabled || isLoading, // loading
}"
>
<el-icon v-if="loading" color="#fff">
<el-icon v-if="isLoading" :color="type === 'default' ? '#26509C' : '#fff'">
<!-- 添加 loading 判断 -->
<Loading class="rotate-loading" /> <!-- 添加旋转类 -->
</el-icon>

9
src/components/common/FTDialog/index.vue

@ -53,13 +53,16 @@ watch(
:show-close="false"
destroy-on-close
append-to-body
:title
:width
:title="title"
:width="width"
:before-close="cancel"
>
<slot />
<template #footer>
<div class="dialog-footer">
<div v-if="$slots.footer" class="dialog-footer">
<slot name="footer" />
</div>
<div v-else class="dialog-footer">
<ft-button @click="cancel">
取消
</ft-button>

13
src/components/common/FTStream/index.vue

@ -12,11 +12,20 @@ defineProps({
const systemStore = useSystemStore()
const title = computed(() => {
return cmdNameMap[systemStore.systemList[0]?.cmdName] || systemStore.systemList[0]?.cmdName
return cmdNameMap[systemStore.systemList[0]?.cmdCode] || systemStore.systemList[0]?.cmdCode
})
const maskBodyRef = ref<HTMLElement | null>(null)
const statusMap = {
error: 'danger',
finish: 'success',
SEND: 'primary',
receive: 'primary',
start: 'primary',
result: 'primary',
}
watch(
() => systemStore.systemList,
async () => {
@ -46,7 +55,7 @@ watch(
v-for="item in systemStore.systemList" :key="item"
:timestamp="JSON.stringify(item.content)"
>
<el-tag type="primary">
<el-tag :type="statusMap[item.status]" class="mask-tag">
{{ item.title }}
</el-tag>
</el-timeline-item>

158
src/components/home/Check/index.vue

@ -0,0 +1,158 @@
<script setup lang="ts">
import FtDialog from 'components/common/FTDialog/index.vue'
import { FtMessage } from 'libs/message'
import { socket } from 'libs/socket'
import { sendControl } from 'libs/utils'
import { nextTick, onMounted, ref } from 'vue'
const emits = defineEmits(['ok', 'cancel'])
const okLoading = ref(false)
const okHandle = () => {
okLoading.value = true
setTimeout(() => {
okLoading.value = false
FtMessage.success('保存成功')
emits('ok')
}, 300)
}
// const handleButtonClick = (callback: () => void) => {
// okLoading.value = true
// setTimeout(() => {
// okLoading.value = false
// FtMessage.success('')
// callback()
// }, 300)
// }
const list = ['x轴是否在原点', 'y轴是否在原点', 'z轴是否在原点']
onMounted(async () => {
let num = 0
await nextTick(() => {
buttonCloseRef.value.setLoading(true)
})
const interval = async () => {
if (num < list.length) {
await addTextToCheckList(list[num], num)
num++
await interval() // interval
}
}
await interval()
buttonCloseRef.value.setLoading(false)
closeVisible.value = false
})
const cancel = () => {
emits('cancel')
}
const motorXYZOrigin = async () => {
buttonRef.value.setLoading(true)
const cmdId = Date.now().toString()
const params = {
cmdCode: 'motor_xyz_origin',
cmdId,
params: {},
}
socket.init((data: any) => {
console.log(data)
if (data.cmdId === cmdId && data.status === 'success') {
buttonRef.value.setLoading(false)
closeVisible.value = true
}
}, 'cmd_response')
await sendControl(params, 'debug')
}
const checkList = ref<any>([])
const buttonRef = ref()
const buttonCloseRef = ref()
const closeVisible = ref(true)
const addTextToCheckList = async (text: string, id: number) => {
// checkList id
if (!checkList.value.some(item => item.id === id)) {
checkList.value.push({ id, title: '', result: 'padding' })
}
let displayedText = ''
return new Promise<void>((resolve) => {
const interval = setInterval(() => {
if (displayedText.length < text.length) {
displayedText += text[displayedText.length]
const itemIndex = checkList.value.findIndex(item => item.id === id)
if (itemIndex !== -1) {
checkList.value[itemIndex].title = displayedText
}
}
else {
clearInterval(interval)
// result 'success' 'failed'
const itemIndex = checkList.value.findIndex(item => item.id === id)
if (itemIndex !== -1) {
//
setTimeout(() => {
checkList.value[itemIndex].result = 'failed'
resolve() // Promise
}, Math.random() * 500) //
}
}
}, Math.random() * 200) //
})
}
</script>
<template>
<FtDialog visible title="自检" width="40%" @ok="okHandle" @cancel="cancel">
<div v-for="item in checkList" :key="item.id" class="mask-box">
<el-tag> {{ item.title }}</el-tag>
<el-icon v-show="item.result === 'success'" color="green">
<SuccessFilled />
</el-icon>
<el-icon v-show="item.result === 'failed'" color="red">
<CircleCloseFilled />
</el-icon>
<el-icon v-show="item.result === 'padding'" color="gray" class="el-icon--loading">
<Loading />
</el-icon>
</div>
<template #footer>
<ft-button v-if="closeVisible" ref="buttonCloseRef" @click="cancel">
关闭
</ft-button>
<ft-button v-else ref="buttonRef" type="primary" @click="motorXYZOrigin">
回原点
</ft-button>
</template>
</FtDialog>
</template>
<style scoped lang="scss">
.mask-box {
display: flex;
font-size: 35px;
.el-tag {
margin: 0 20px 10px 0;
width: 100%;
}
}
//
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.el-icon.el-icon--loading {
animation: spin 1s linear infinite; // Loading spin
}
</style>

28
src/components/home/stop/index.vue

@ -0,0 +1,28 @@
<script setup lang="ts">
</script>
<template>
<Teleport to="body">
<div class="mask-box">
设备急停中
</div>
</Teleport>
</template>
<style scoped lang="scss">
.mask-box {
position: absolute;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: center;
color: var(--el-color-danger);
font-size: 100px;
z-index: 10000;
top: 0;
left: 0;
}
</style>

17
src/components/martixCraft/Edit/index.vue

@ -51,15 +51,24 @@ const form = ref({
const rules = {
matrixId: [{ required: true, message: '请选择基质', trigger: 'change' }],
name: [{ required: true, message: '请输入工艺名称', trigger: 'blur' }],
motorZHeight: [{ required: true, message: '请输入Z轴高度', trigger: 'blur' }],
motorZHeight: [{ required: true, trigger: 'blur', validator: (rule: any, value: any, callback: any) => {
setTimeout(() => {
if (value < 15) {
callback(new Error('最小安全高度为15mm'))
}
else {
callback()
}
}, 500)
} }],
gasPressure: [{ required: true, message: '请输入氮气气压', trigger: 'blur' }],
volume: [{ required: true, message: '请输入基质流速', trigger: 'blur' }],
highVoltageValue: [{ required: true, message: '请输入电压', trigger: 'blur', validator: (rule: any, value: any, callback: any) => {
highVoltageValue: [{ required: true, trigger: 'blur', validator: (rule: any, value: any, callback: any) => {
if (form.value.highVoltage && !value) {
callback(new Error('请输入电压'))
}
else if (value > 5000) {
callback(new Error('最高电压不能超过5000V'))
else if (value > 6000) {
callback(new Error('最大电压为6000V'))
}
else {
callback()

4
src/components/point/Edit/index.vue

@ -22,6 +22,7 @@ const form = ref({})
const rules = {
pointName: [{ required: true, message: '请输入坐标名称', trigger: 'blur' }],
pointCode: [{ required: true, message: '请输入坐标code', trigger: 'blur' }],
x: [{ required: true, message: '请输入x', trigger: 'blur' }],
y: [{ required: true, message: '请输入y', trigger: 'blur' }],
z: [{ required: true, message: '请输入z', trigger: 'blur' }],
@ -62,6 +63,9 @@ const cancel = () => {
<el-form-item label="坐标名称" prop="pointName">
<el-input v-model="form.pointName" placeholder="" />
</el-form-item>
<el-form-item label="坐标code" prop="pointCode">
<el-input v-model="form.pointCode" placeholder="" />
</el-form-item>
<el-form-item label="x" prop="x">
<el-input v-model="form.x" type="number" placeholder="" />
</el-form-item>

104
src/components/spray/startSpray/index.vue

@ -1,31 +1,105 @@
<script setup lang="ts">
import FtDialog from 'components/common/FTDialog/index.vue'
import { ref } from 'vue'
import { useSystemStore } from 'stores/useSystemStore'
import { nextTick, ref, watch } from 'vue'
defineProps({
sourceData: {
type: Object,
default: () => {},
visible: {
type: Boolean,
default: false,
},
})
const emits = defineEmits(['ok', 'cancel'])
const emits = defineEmits(['close'])
const visible = ref(true)
const text = defineModel()
const list = defineModel()
const cancel = () => {
emits('cancel')
const close = () => {
emits('close')
}
const systemStore = useSystemStore()
const maskBodyRef = ref<HTMLElement | null>(null)
watch(
() => list.value,
async () => {
await nextTick()
if (maskBodyRef.value) {
maskBodyRef.value.scrollTop = maskBodyRef.value.scrollHeight
}
},
{ deep: true },
)
</script>
<template>
<FtDialog visible title="喷涂" width="80%" @ok="visible = false" @cancel="cancel">
{{ text }}
</FtDialog>
<teleport to="body">
<!-- 使用 transition 组件包裹 mask111 元素 -->
<transition name="mask-fade">
<div v-if="visible && systemStore.isDebug" class="mask">
<div class="mask-header">
<p>喷涂任务</p>
<el-icon @click="close">
<Close />
</el-icon>
</div>
<div ref="maskBodyRef" class="mask-body">
<el-timeline>
<el-timeline-item
v-for="(item, key) in list" :key
:timestamp="JSON.stringify(item.data.content || item.data)"
>
<el-tag type="primary" class="mask-tag">
{{ item.data.message || item.data }}
</el-tag>
</el-timeline-item>
</el-timeline>
</div>
</div>
</transition>
</teleport>
</template>
<style scoped lang="scss">
.graph-box {
display: flex;
.mask {
width: 800px;
height: 500px;
padding: 20px;
background: #fff;
box-shadow: var(--el-box-shadow-light);
position: absolute;
bottom: 650px;
right: 100px;
border-radius: 10px;
font-size: 30px;
.mask-header {
display: flex;
justify-content: space-between;
align-items: center;
height: 50px;
font-size: 30px;
border-bottom: 1px solid #ddd;
.el-icon svg{
width: 30px;
}
}
.mask-body {
padding: 10px;
height: calc(100% - 41px);
overflow: auto;
}
}
/* 定义过渡效果 */
.mask-fade-enter-active, .mask-fade-leave-active {
transition: transform 0.5s ease;
}
.mask-fade-enter-from {
transform: translateX(100%);
}
.mask-fade-leave-to {
transform: translateX(100%);
}
</style>

19
src/components/spray/trayGraph/index.vue

@ -16,6 +16,7 @@ const stage = ref()
const layer = ref()
const rect = ref()
const tr = ref()
const line = ref()
onMounted(() => {
addStage()
@ -142,7 +143,6 @@ const getSelection = () => {
const formatNum = (num: number) => {
return Math.round(num * 100) / 100
}
const line = ref()
const addLine = () => {
line.value = new Konva.Line({
@ -165,18 +165,10 @@ const updateLine = (point: { x: number, y: number }) => {
line.value.getLayer()!.batchDraw() //
}
// watch(
// () => props.select,
// (newVal) => {
// if (newVal) {
// addStage()
// }
// else {
// rect.value.destroy()
// tr.value.destroy()
// }
// },
// )
// line
const hasLine = () => {
return line.value !== undefined && line.value !== null
}
watch(
() => props.select,
@ -189,6 +181,7 @@ defineExpose({
getSelection,
addLine,
updateLine,
hasLine, //
})
</script>

1
src/env.d.ts

@ -3,6 +3,7 @@
interface ImportMetaEnv {
readonly FT_NODE_ENV: string
readonly FT_WS_URL: string
readonly FT_PROXY: string
}
interface ImportMeta {

10
src/libs/http.ts

@ -26,8 +26,7 @@ http.interceptors.response.use(
(response) => {
if (
response.status === 200
&& response.data.data !== undefined
&& !response.data.data
&& response.data.code !== '00000'
) {
// 返回错误拦截
FtMessage.error(response.data.msg)
@ -42,11 +41,6 @@ http.interceptors.response.use(
else if (response.data instanceof Blob) {
return response.data
}
else if (
response.config.url?.includes('/stream-data')
) {
return response
}
return response.data.data // 返回数据体
},
(error: any) => {
@ -63,7 +57,7 @@ http.interceptors.response.use(
FtMessage.error('网络连接错误')
}
else {
FtMessage.error(error.message)
FtMessage.error('接口请求失败')
}
error.response = {
data: {

4
src/libs/socket.ts

@ -49,7 +49,7 @@ export const socket: socket = {
// 心跳timer
hearBeat_timer: null,
// 心跳发送频率
hearBeat_interval: 500,
hearBeat_interval: 5000,
// 是否需要重连
is_reconnect: true,
// 重连次数
@ -78,7 +78,7 @@ export const socket: socket = {
const message = JSON.parse(e.data)
const fn = socket.receiveMessageCallBackObj[message.type]
if (fn) {
fn(message)
fn(message.data)
}
else {
console.error('请注册当前类型的回调函数', message)

183
src/libs/utils.ts

@ -1,36 +1,69 @@
import { control, debugControl } from 'apis/system'
import { FtMessage } from 'libs/message'
import { useSystemStore } from 'stores/useSystemStore'
export const sendControl = async (params: any, type?: string) => {
if (!params.cmdId) {
params.cmdId = Date.now()
}
const systemStore = useSystemStore()
systemStore.systemList = []
const res = await (type ? debugControl(params) : control(params))
if (!res.ok) {
const systemStatus = systemStore.systemStatus
const sprayingDisableCmd = [
'slide_tray_in',
'slide_tray_out',
'matrix_prefill',
'nozzle_pipeline_wash',
'syringe_pipeline_wash',
'matrix_spray_start',
'syringe_pipeline_wash_stop',
'matrix_prefill_stop',
]
if (systemStatus.spraying && (type === 'debug' || sprayingDisableCmd.includes(params.cmdCode))) {
FtMessage.error('设备正在喷涂中,请等待喷涂完成')
return
}
const reader = res.body!.getReader()
const decoder = new TextDecoder()
systemStore.updateStreamVisible(true)
let buffer = ''
while (true) {
const { done, value } = await reader.read()
if (done) {
break
}
const chunk = decoder.decode(value, { stream: true })
buffer += chunk
const { objects, remaining } = extractJSONObjects(buffer)
buffer = remaining
objects.forEach((jsonStr) => {
try {
const json = JSON.parse(jsonStr)
systemStore.pushSystemList(json)
}
catch (e) {
console.log(e)
}
})
if (systemStatus.spraying && (type === 'debug' || sprayingDisableCmd.includes(params.cmdCode))) {
FtMessage.error('设备正在喷涂中,请等待喷涂完成')
return
}
systemStore.systemList = []
// const cmdName = cmdNameMap[params.cmdCode as keyof typeof cmdNameMap] || params.cmdCode
const res = await (type ? control(params) : debugControl(params))
console.log(res)
// if (!res.ok) {
// FtMessage.error(`[${cmdName}]发送失败`)
// return
// }
// FtMessage.success(`[${cmdName}]已发送`)
// const reader = res.body!.getReader()
// const decoder = new TextDecoder()
// systemStore.updateStreamVisible(true)
// let buffer = ''
// FtMessage.success(`[${cmdName}]已开始执行`)
// while (true) {
// const { done, value } = await reader.read()
// if (done) {
// console.log('done')
// FtMessage.success(`[${cmdName}]执行完毕`)
// break
// }
// const chunk = decoder.decode(value, { stream: true })
// // console.log(chunk)
// buffer += chunk
// const { objects, remaining } = extractJSONObjects(buffer)
// buffer = remaining
// objects.forEach((jsonStr) => {
// try {
// const json = JSON.parse(jsonStr)
// systemStore.pushSystemList(json)
// }
// catch (e) {
// console.log(e)
// }
// })
// }
}
export const cmdNameMap = {
@ -43,7 +76,7 @@ export const cmdNameMap = {
matrix_prefill_stop: '停止预充',
nozzle_pipeline_wash: '清洗喷嘴管路',
syringe_pipeline_wash: '清洗注射器管路',
pipeline_wash_stop: '停止清洗',
syringe_pipeline_wash_stop: '结束清洗',
matrix_spray_start: '开始喷涂',
matrix_spray_stop: '结束喷涂',
matrix_spray_pause: '暂停喷涂',
@ -57,7 +90,7 @@ export const cmdNameMap = {
motor_x_to_position: 'X轴移动',
motor_y_to_position: 'Y轴移动',
motor_z_to_position: 'Z轴移动',
syringe_pump__start: '注射泵移动',
syringe_pump_start: '注射泵移动',
syringe_pump_stop: '注射泵停止移动',
high_voltage_open: '打开高压',
high_voltage_close: '关闭高压',
@ -72,52 +105,54 @@ export const cmdNameMap = {
three_way_valve_open_spray_pipeline: '打开注射器管路',
lighting_panel_open: '打开照明灯',
lighting_panel_close: '关闭照明灯',
}
const extractJSONObjects = (data: string) => {
const objects = []
let startIndex = -1
let bracketCount = 0
let inString = false
let escape = false
for (let i = 0; i < data.length; i++) {
const char = data[i]
motor_xyz_origin: '三轴回原点',
if (inString) {
if (escape) {
escape = false
}
else if (char === '\\') {
escape = true
}
else if (char === '"') {
inString = false
}
}
else {
if (char === '"') {
inString = true
}
else if (char === '{') {
// 当 bracketCount 为0时,标记一个新的 JSON 对象开始
if (bracketCount === 0) {
startIndex = i
}
bracketCount++
}
else if (char === '}') {
bracketCount--
// 当 bracketCount 归零时,说明一个 JSON 对象完整
if (bracketCount === 0 && startIndex !== -1) {
const jsonStr = data.slice(startIndex, i + 1)
objects.push(jsonStr)
startIndex = -1 // 重置起始位置
}
}
}
}
// 如果最后 bracketCount 不为0,说明还有未完成的部分
const remaining = (bracketCount > 0 && startIndex !== -1) ? data.slice(startIndex) : ''
return { objects, remaining }
}
// const extractJSONObjects = (data: string) => {
// const objects = []
// let startIndex = -1
// let bracketCount = 0
// let inString = false
// let escape = false
//
// for (let i = 0; i < data.length; i++) {
// const char = data[i]
//
// if (inString) {
// if (escape) {
// escape = false
// }
// else if (char === '\\') {
// escape = true
// }
// else if (char === '"') {
// inString = false
// }
// }
// else {
// if (char === '"') {
// inString = true
// }
// else if (char === '{') {
// // 当 bracketCount 为0时,标记一个新的 JSON 对象开始
// if (bracketCount === 0) {
// startIndex = i
// }
// bracketCount++
// }
// else if (char === '}') {
// bracketCount--
// // 当 bracketCount 归零时,说明一个 JSON 对象完整
// if (bracketCount === 0 && startIndex !== -1) {
// const jsonStr = data.slice(startIndex, i + 1)
// objects.push(jsonStr)
// startIndex = -1 // 重置起始位置
// }
// }
// }
// }
// // 如果最后 bracketCount 不为0,说明还有未完成的部分
// const remaining = (bracketCount > 0 && startIndex !== -1) ? data.slice(startIndex) : ''
// return { objects, remaining }
// }

21
src/stores/useSystemStore.ts

@ -3,19 +3,29 @@ import { defineStore } from 'pinia'
export const useSystemStore = defineStore('system', {
state: () => ({
systemStatus: {
spraying: false, // 设备是否正在进行的喷涂任务
paused: false, // 喷涂任务暂停状态
suspendable: false, // 当前状态是否可以暂停
cleaningSyringePipeline: false, // 是否正在清洗注射器管路
cleaningNozzlePipeline: false, // 是否正在清洗喷嘴管路
prefilling: false, // 是否正在预充
dehumidifierRunning: false, // 是否正在除湿
selfTestCompleted: false, // 是否完成自检
stopPressed: false, // 是否按下急停
},
systemSensor: {
humidity: 0,
},
systemIng: {},
isDebug: true,
isDebug: false,
streamVisible: false,
systemList: [{ cmdName: '' }],
systemList: [{ cmdCode: '' }],
}),
actions: {
updateSystemStatus(status: any) {
this.systemStatus = status
},
updateSystemIng(info: any) {
this.systemIng = info
updateSystemSensor(info: any) {
this.systemSensor = info
},
updateDebug() {
this.isDebug = !this.isDebug
@ -25,6 +35,7 @@ export const useSystemStore = defineStore('system', {
},
pushSystemList(text: any) {
this.systemList.push(text)
console.log(this.systemList)
},
},
})

23
src/views/clean/index.vue

@ -22,14 +22,13 @@ const syringePipelineWash = () => {
showClose: false,
}).then(() => {
const params = {
cmdName: 'syringe_pipeline_wash',
cmdCode: 'syringe_pipeline_wash',
cmdId: '',
param: {
params: {
speed: clearSpeed,
},
}
sendControl(params)
FtMessage.success('指令已发送')
}).catch(() => {
FtMessage.error('取消清洗')
})
@ -52,18 +51,26 @@ const nozzlePipelineWash = () => {
showClose: false,
}).then(() => {
const params = {
cmdName: 'nozzle_pipeline_wash',
cmdCode: 'nozzle_pipeline_wash',
cmdId: '',
param: {
params: {
speed: clearSpeed,
},
}
sendControl(params)
FtMessage.success('指令已发送')
}).catch(() => {
FtMessage.error('取消清洗')
})
}
const syringePipelineWashStop = () => {
const params = {
cmdCode: 'syringe_pipeline_wash_stop',
cmdId: '',
params: {},
}
sendControl(params)
}
</script>
<template>
@ -79,7 +86,9 @@ const nozzlePipelineWash = () => {
<FtButton type="primary" @click="nozzlePipelineWash">
清洗喷嘴管路
</FtButton>
<FtButton>结束清洗</FtButton>
<FtButton @click="syringePipelineWashStop">
结束清洗
</FtButton>
</div>
</template>

238
src/views/debug/index.vue

@ -1,9 +1,7 @@
<script setup lang="ts">
import FtButton from 'components/common/FTButton/index.vue'
import { FtMessage } from 'libs/message'
import { sendControl } from 'libs/utils'
import { reactive, ref } from 'vue'
const humidity = ref('')
import { reactive } from 'vue'
const form = reactive({
x: {
@ -28,152 +26,168 @@ const form = reactive({
speed: undefined,
voltage: undefined,
})
const motorMove = (device: 'x' | 'y' | 'z') => {
const motorMove = async (device: 'x' | 'y' | 'z') => {
if (!form[device].position || !form[device].speed) {
FtMessage.error('请补全参数')
return
}
const params = {
cmdName: { x: 'motor_x_to_position', y: 'motor_y_to_position', z: 'motor_z_to_position' }[device],
cmdCode: { x: 'motor_x_to_position', y: 'motor_y_to_position', z: 'motor_z_to_position' }[device],
cmdId: '',
param: form[device],
params: form[device],
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const motorStop = (device: 'x' | 'y' | 'z') => {
const motorStop = async (device: 'x' | 'y' | 'z') => {
const params = {
cmdName: { x: 'motor_x_stop', y: 'motor_y_stop', z: 'motor_z_stop' }[device],
cmdCode: { x: 'motor_x_stop', y: 'motor_y_stop', z: 'motor_z_stop' }[device],
cmdId: '',
param: form[device],
params: form[device],
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const motorToHome = (device: 'x' | 'y' | 'z') => {
const motorToHome = async (device: 'x' | 'y' | 'z') => {
const params = {
cmdName: { x: 'motor_x_origin', y: 'motor_y_origin', z: 'motor_z_origin' }[device],
cmdCode: { x: 'motor_x_origin', y: 'motor_y_origin', z: 'motor_z_origin' }[device],
cmdId: '',
param: form[device],
params: form[device],
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const threeWayValveOpenSyringePipeline = () => {
const threeWayValveOpenSyringePipeline = async () => {
const params = {
cmdName: 'three_way_valve_open_syringe_pipeline',
cmdCode: 'three_way_valve_open_syringe_pipeline',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const threeWayValveOpenNozzlePipeline = () => {
const threeWayValveOpenNozzlePipeline = async () => {
const params = {
cmdName: 'three_way_valve_open_nozzle_pipeline',
cmdCode: 'three_way_valve_open_nozzle_pipeline',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const threeWayValveCloseAll = () => {
const threeWayValveCloseAll = async () => {
const params = {
cmdName: 'three_way_valve_close_all',
cmdCode: 'three_way_valve_close_all',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const lightingPanelOpen = () => {
const lightingPanelOpen = async () => {
const params = {
cmdName: 'lighting_panel_open',
cmdCode: 'lighting_panel_open',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const lightingPanelClose = () => {
const lightingPanelClose = async () => {
const params = {
cmdName: 'lighting_panel_close',
cmdCode: 'lighting_panel_close',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const washValveOpen = () => {
const washValveOpen = async () => {
const params = {
cmdName: 'wash_valve_open',
cmdCode: 'wash_valve_open',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const washValveClose = () => {
const washValveClose = async () => {
const params = {
cmdName: 'wash_valve_close',
cmdCode: 'wash_valve_close',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const nozzleValveOpen = () => {
const nozzleValveOpen = async () => {
const params = {
cmdName: 'nozzle_valve_open',
cmdCode: 'nozzle_valve_open',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const nozzleValveClose = () => {
const nozzleValveClose = async () => {
const params = {
cmdName: 'nozzle_valve_close',
cmdCode: 'nozzle_valve_close',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const dehumidifierValveOpen = () => {
const dehumidifierValveOpen = async () => {
const params = {
cmdName: 'dehumidifier_valve_open',
cmdCode: 'dehumidifier_valve_open',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const dehumidifierValveClose = () => {
const dehumidifierValveClose = async () => {
const params = {
cmdName: 'dehumidifier_valve_close',
cmdCode: 'dehumidifier_valve_close',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const syringePumpInjectionVolumeSet = () => {
const syringePumpInjectionVolumeSet = async () => {
if (!form.speed) {
FtMessage.error('请输入注射泵速度')
return
}
const params = {
cmdName: 'syringe_pump_start',
cmdCode: 'syringe_pump_start',
cmdId: '',
param: {
params: {
direction: form.direction,
speed: form.speed,
},
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const syringePumpStop = () => {
const syringePumpStop = async () => {
const params = {
cmdName: 'syringe_pump_stop',
cmdCode: 'syringe_pump_stop',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const highVoltageOpen = () => {
const highVoltageOpen = async () => {
if (!form.voltage) {
FtMessage.error('请输入电压值')
return
}
if (form.voltage > 6000) {
FtMessage.error('电压值最大为6000V')
return
}
const params = {
cmdName: 'high_voltage_open',
cmdCode: 'high_voltage_open',
cmdId: '',
param: {
params: {
voltage: form.voltage,
},
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
const highVoltageClose = () => {
const highVoltageClose = async () => {
const params = {
cmdName: 'high_voltage_close',
cmdCode: 'high_voltage_close',
cmdId: '',
}
sendControl(params, 'debug')
await sendControl(params, 'debug')
}
</script>
@ -205,15 +219,15 @@ const highVoltageClose = () => {
</div>
</el-radio-group>
<FtButton type="primary" @click="motorMove('x')">
<ft-button type="primary" :on-click="() => motorMove('x')">
执行
</FtButton>
<FtButton type="primary" @click="motorStop('x')">
</ft-button>
<ft-button type="primary" :on-click="() => motorStop('x')">
停止
</FtButton>
<FtButton @click="motorToHome('x')">
</ft-button>
<ft-button :on-click="() => motorToHome('x')">
回原点
</FtButton>
</ft-button>
</div>
</el-form-item>
<el-form-item label="Y轴">
@ -240,15 +254,15 @@ const highVoltageClose = () => {
</div>
</el-radio-group>
<FtButton type="primary" @click="motorMove('y')">
<ft-button type="primary" :on-click="() => motorMove('y')">
执行
</FtButton>
<FtButton type="primary" @click="motorStop('y')">
</ft-button>
<ft-button type="primary" :on-click="() => motorStop('y')">
停止
</FtButton>
<FtButton @click="motorToHome('y')">
</ft-button>
<ft-button :on-click="() => motorToHome('y')">
回原点
</FtButton>
</ft-button>
</div>
</el-form-item>
<el-form-item label="Z轴">
@ -275,15 +289,15 @@ const highVoltageClose = () => {
</div>
</el-radio-group>
<FtButton type="primary" @click="motorMove('z')">
<ft-button type="primary" :on-click="() => motorMove('z')">
执行
</FtButton>
<FtButton type="primary" @click="motorStop('z')">
</ft-button>
<ft-button type="primary" :on-click="() => motorStop('z')">
停止
</FtButton>
<FtButton @click="motorToHome('z')">
</ft-button>
<ft-button :on-click="() => motorToHome('z')">
回原点
</FtButton>
</ft-button>
</div>
</el-form-item>
</el-form>
@ -304,25 +318,25 @@ const highVoltageClose = () => {
</el-radio>
</div>
</el-radio-group>
<FtButton type="primary" style="margin-left: 10px" @click="syringePumpInjectionVolumeSet">
<ft-button type="primary" style="margin-left: 10px" :on-click="syringePumpInjectionVolumeSet">
开始
</FtButton>
<FtButton @click="syringePumpStop">
</ft-button>
<ft-button :on-click="syringePumpStop">
停止
</FtButton>
</ft-button>
</div>
</el-form-item>
<el-form-item label="电压控制器">
<div style="display: flex; align-items: center; margin: 5px 0">
<el-input v-model="humidity" type="number" style="width: 100px;" />
<el-input v-model="form.voltage" type="number" style="width: 100px;" />
<span>V</span>
<FtButton type="primary" style="margin-left: 10px" @click="highVoltageOpen">
<ft-button type="primary" style="margin-left: 10px" :on-click="highVoltageOpen">
开启
</FtButton>
<FtButton @click="highVoltageClose">
</ft-button>
<ft-button :on-click="highVoltageClose">
关闭
</FtButton>
</ft-button>
</div>
</el-form-item>
</el-form>
@ -330,46 +344,46 @@ const highVoltageClose = () => {
<el-row :gutter="20">
<el-col :span="12">
<el-card style="display: flex;justify-content: center">
<FtButton type="primary" @click="lightingPanelOpen">
<ft-button type="primary" :on-click="lightingPanelOpen">
开启照明灯
</FtButton>
<FtButton @click="lightingPanelClose">
</ft-button>
<ft-button :on-click="lightingPanelClose">
关闭照明灯
</FtButton>
</ft-button>
<div style="margin-top: 10px;display: flex;justify-content: center">
<FtButton type="primary" @click="threeWayValveOpenSyringePipeline">
<ft-button type="primary" :on-click="threeWayValveOpenSyringePipeline">
打开喷嘴管路
</FtButton>
<FtButton type="primary" @click="threeWayValveOpenNozzlePipeline">
</ft-button>
<ft-button type="primary" :on-click="threeWayValveOpenNozzlePipeline">
打开注射器管路
</FtButton>
<FtButton @click="threeWayValveCloseAll">
</ft-button>
<ft-button :on-click="threeWayValveCloseAll">
全部关闭
</FtButton>
</ft-button>
</div>
</el-card>
</el-col>
<el-col :span="12">
<el-card style="display: flex;justify-content: center">
<FtButton type="primary" @click="washValveOpen">
<ft-button type="primary" :on-click="washValveOpen">
打开清洗阀
</FtButton>
<FtButton type="primary" @click="nozzleValveOpen">
</ft-button>
<ft-button type="primary" :on-click="nozzleValveOpen">
打开喷嘴阀
</FtButton>
<FtButton type="primary" @click="dehumidifierValveOpen">
</ft-button>
<ft-button type="primary" :on-click="dehumidifierValveOpen">
打开除湿阀
</FtButton>
</ft-button>
<div style="margin-top: 10px;display: flex;justify-content: center">
<FtButton @click="washValveClose">
<ft-button :on-click="washValveClose">
关闭清洗阀
</FtButton>
<FtButton @click="nozzleValveClose">
</ft-button>
<ft-button :on-click="nozzleValveClose">
关闭喷嘴阀
</FtButton>
<FtButton @click="dehumidifierValveClose">
</ft-button>
<ft-button :on-click="dehumidifierValveClose">
关闭除湿阀
</FtButton>
</ft-button>
</div>
</el-card>
</el-col>

21
src/views/home/index.vue

@ -1,7 +1,27 @@
<script setup lang="ts">
import Check from 'components/home/Check/index.vue'
import { ElMessageBox } from 'element-plus'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const checkVisible = ref(false)
const ok = () => {
checkVisible.value = false
}
ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', {
type: 'warning',
confirmButtonText: '确定',
showCancelButton: false,
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
closeOnHashChange: false,
}).then(() => {
checkVisible.value = true
})
</script>
<template>
@ -32,6 +52,7 @@ const router = useRouter()
<p>坐标管理</p>
</div>
</div>
<Check v-if="checkVisible" @ok="ok" @cancel="checkVisible = false" />
</div>
</template>

13
src/views/login/index.vue

@ -1,7 +1,6 @@
<script setup lang="ts">
import { login } from 'apis/system'
import { setToken } from 'libs/token'
import { onBeforeUnmount, ref } from 'vue'
import { onBeforeUnmount, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
@ -25,12 +24,16 @@ const startProgress = () => {
}
}, 100) // 500ms
}
login({ username: 'admin', password: '12345' }).then((res: any) => {
setToken(res)
onMounted(() => {
setToken('111')
startProgress()
})
// login({ username: 'admin', password: '12345' }).then((res: any) => {
// setToken(res)
//
// })
//
onBeforeUnmount(() => {
clearInterval(timer)

54
src/views/main/index.vue

@ -1,9 +1,10 @@
<script setup lang="ts">
import FtStream from 'components/common/FTStream/index.vue'
import Stop from 'components/home/stop/index.vue'
import { isClose, socket } from 'libs/socket'
import { sendControl } from 'libs/utils'
import { useSystemStore } from 'stores/useSystemStore' // systemStore
import { ref } from 'vue'
import { computed, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
@ -15,18 +16,44 @@ const statusMessage = (data: any) => {
systemStore.updateSystemStatus(data.data)
}
const ingMessage = (data: any) => {
const sensorMessage = (data: any) => {
// systemStore systemInfo
systemStore.updateSystemIng(data.data)
systemStore.updateSystemSensor(data.data)
}
socket.init(statusMessage, 'status')
socket.init(ingMessage, 'ing')
socket.init(statusMessage, 'device_status_change')
socket.init(sensorMessage, 'sensor')
socket.init(() => {}, 'pong')
const ingObj = {
idle: '空闲',
spraying: '正在喷涂中',
paused: '喷涂暂停中',
cleaningSyringePipeline: '正在清洗注射器管路',
cleaningNozzlePipeline: '正在清洗喷嘴管路',
prefilling: '正在预充中',
dehumidifierRunning: '正在除湿中',
stopPressed: '急停中',
}
const status = computed(() => {
const keys = Object.keys(systemStore.systemStatus).filter((key) => {
return !['paused', 'suspendable', 'selfTestCompleted'].includes(key)
})
let str = ''
keys.forEach((key) => {
if (systemStore.systemStatus[key as keyof typeof systemStore.systemStatus]) {
str += `${ingObj[key as keyof typeof ingObj]} | `
}
})
if (str === '') {
return '空闲'
}
else {
return str.slice(0, -2)
}
})
const logoClickCount = ref(0)
let clickTimeout: NodeJS.Timeout | null = null
@ -45,18 +72,16 @@ const handleLogoClick = () => {
}
const slideTrayIn = async () => {
// TODO
const params = {
cmdName: 'slide_tray_in',
cmdCode: 'slide_tray_in',
cmdId: '',
}
await sendControl(params)
}
const slideTrayOut = async () => {
// TODO
const params = {
cmdName: 'slide_tray_out',
cmdCode: 'slide_tray_out',
cmdId: '',
}
await sendControl(params)
@ -82,7 +107,7 @@ const slideTrayOut = async () => {
<ft-button v-if="systemStore.isDebug" @click="router.push('/debug')">
调试
</ft-button>
<ft-button v-if="route.path !== '/'" @click="router.go(-1)">
<ft-button v-if="route.path !== '/'" @click="router.push('/')">
返回
</ft-button>
</div>
@ -97,22 +122,23 @@ const slideTrayOut = async () => {
<el-footer>
<div>
<ft-button type="info">
当前湿度: {{ systemStore.systemStatus.humidity }}%RH
当前湿度: {{ systemStore.systemSensor.humidity }}%RH
</ft-button>
<ft-button type="info">
设备状态: {{ ingObj[systemStore.systemIng.workStatus] }}
设备状态: {{ status }}
</ft-button>
</div>
<div>
<ft-button @click="slideTrayIn">
<ft-button :on-click="slideTrayIn">
推入托盘
</ft-button>
<ft-button @click="slideTrayOut">
<ft-button :on-click="slideTrayOut">
推出托盘
</ft-button>
</div>
</el-footer>
<FtStream :visible="systemStore.streamVisible" />
<Stop v-if="systemStore.systemStatus.stopPressed" />
</el-container>
</template>

1
src/views/point/index.vue

@ -99,6 +99,7 @@ const delHandle = async () => {
<el-table v-loading="loading" :data="tableData" header-row-class-name="table-header" height="100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="pointName" label="坐标名称" />
<el-table-column prop="pointCode" label="坐标code" />
<el-table-column prop="x" label="x" />
<el-table-column prop="y" label="y" />
<el-table-column prop="z" label="z" />

123
src/views/spray/index.vue

@ -11,12 +11,16 @@ import Edit from 'components/martixCraft/Edit/index.vue'
import startSpray from 'components/spray/startSpray/index.vue'
import TrayGraph from 'components/spray/trayGraph/index.vue'
import { FtMessage } from 'libs/message'
import { socket } from 'libs/socket'
import { sendControl } from 'libs/utils'
import { onMounted, ref } from 'vue'
import { useSystemStore } from 'stores/useSystemStore'
import { nextTick, onMounted, ref } from 'vue'
const systemStore = useSystemStore()
const sprayRefs = ref<any>([])
const text = ref('')
const wsList = ref<any>([])
const updateParam = () => {
updateForm.value = {
@ -36,9 +40,9 @@ const submitParam = async () => {
...updateForm.value,
}
const params = {
cmdName: 'matrix_spray_change_param',
cmdCode: 'matrix_spray_change_param',
cmdId: '',
param: updateForm.value,
params: updateForm.value,
}
await sendControl(params)
infoVisible.value = false
@ -46,20 +50,6 @@ const submitParam = async () => {
const infoVisible = ref(false)
// const drawLine = async () => {
// await nextTick(() => {
// sprayRefs.value[0].addLine()
// })
// let x = 0
// let y = 0
// const poll = setInterval(() => {
// if (x > 25 || y > 75) {
// clearInterval(poll)
// }
// sprayRefs.value[0].updateLine({ x: x++, y: y++ })
// }, 500)
// }
onMounted(() => {
getMatrixList()
})
@ -136,46 +126,67 @@ const startWork = async () => {
}
const params = {
cmdName: 'matrix_spray_start',
cmdCode: 'matrix_spray_start',
cmdId: '',
param: {
params: {
...form.value,
position,
},
}
console.log(params)
await sendControl(params)
// await getSteamData()
sendControl(params)
visible.value = true
wsList.value = []
socket.init(sprayTskReceiveMessage, 'spray_tsk')
socket.init(sprayPointReceiveMessage, 'spray_point')
})
}
const sprayPointReceiveMessage = (data: any) => {
drawLine(data.index, data.point)
}
const drawLine = async (index: number, point: { x: number, y: number }) => {
await nextTick(() => {
if (!sprayRefs.value[index].hasLine) {
sprayRefs.value[index].addLine()
}
})
sprayRefs.value[index].updateLine(point)
}
// const pauseWork = async () => {
// const params = {
// cmdName: 'matrix_spray_pause',
// cmdId: '',
// }
// await sendControl(params)
// }
//
// const continueWork = async () => {
// const params = {
// cmdName: 'matrix_spray_continue',
// cmdId: '',
// param: {
// motorZHeight: form.value.motorZHeight, //
// gasPressure: form.value.gasPressure, // Mpa
// volume: form.value.volume, // uL
// highVoltage: form.value.highVoltage, //
// highVoltageValue: form.value.highVoltageValue, //
// movingSpeed: form.value.movingSpeed, //
// },
// }
// await sendControl(params)
// }
const sprayTskReceiveMessage = (data: any) => {
console.log(data)
wsList.value.push(data)
}
const pauseWork = async () => {
const params = {
cmdCode: 'matrix_spray_pause',
cmdId: '',
}
await sendControl(params)
}
const continueWork = async () => {
const params = {
cmdCode: 'matrix_spray_continue',
cmdId: '',
params: {
motorZHeight: form.value.motorZHeight, //
gasPressure: form.value.gasPressure, // Mpa
volume: form.value.volume, // uL
highVoltage: form.value.highVoltage, //
highVoltageValue: form.value.highVoltageValue, //
movingSpeed: form.value.movingSpeed, //
},
}
await sendControl(params)
}
const stopWork = async () => {
const params = {
cmdName: 'matrix_spray_stop',
cmdCode: 'matrix_spray_stop',
cmdId: '',
}
await sendControl(params)
@ -213,8 +224,8 @@ const rules = {
if (form.value.highVoltage && !value) {
callback(new Error('请输入电压'))
}
else if (value > 5000) {
callback(new Error('最大电压为5000V'))
else if (value > 6000) {
callback(new Error('最大电压为6000V'))
}
else {
callback()
@ -272,13 +283,13 @@ const addCraft = () => {
<ft-button type="primary" @click="updateParam">
调整参数
</ft-button>
<!-- <ft-button @click="pauseWork"> -->
<!-- 暂停喷涂 -->
<!-- </ft-button> -->
<!-- <ft-button @click="continueWork"> -->
<!-- 继续喷涂 -->
<!-- </ft-button> -->
<ft-button @click="stopWork">
<ft-button @click="pauseWork">
暂停喷涂
</ft-button>
<ft-button @click="continueWork">
继续喷涂
</ft-button>
<ft-button :disabled="systemStore.systemStatus.spraying" @click="stopWork">
结束喷涂
</ft-button>
</div>
@ -410,7 +421,7 @@ const addCraft = () => {
</div>
</el-form>
</el-drawer>
<start-spray v-if="visible" v-model="text" :source-data="form" @cancel="visible = false" />
<start-spray v-model="wsList" :visible @close="visible = false" />
<Edit v-if="addVisible" :matrix-list :form-data other-page @ok="ok" @cancel="addVisible = false" />
</div>
</template>

81
src/views/spraySet/index.vue

@ -31,6 +31,7 @@ const humidity = ref()
const speed = ref()
const clearSpeed = ref()
const dehumidifierStartRef = ref()
const dehumidifierStart = () => {
if (!humidity.value) {
FtMessage.error('请输入目标湿度')
@ -40,7 +41,7 @@ const dehumidifierStart = () => {
FtMessage.error('湿度参数有误')
return
}
if (humidity.value >= systemStore.systemStatus.humidity) {
if (humidity.value >= systemStore.systemSensor.humidity) {
FtMessage.info('当前不需要除湿')
return
}
@ -50,20 +51,23 @@ const dehumidifierStart = () => {
showCancelButton: true,
showClose: false,
}).then(async () => {
dehumidifierStartRef.value.setLoading(true)
const params = {
cmdName: 'dehumidifier_start',
cmdCode: 'dehumidifier_start',
cmdId: '',
param: {
params: {
humidity: humidity.value,
},
}
await sendControl(params)
dehumidifierStartRef.value.setLoading(false)
}).catch(() => {
FtMessage.error('取消除湿')
})
}
const syringePipelineWash = () => {
const syringePipelineWashRef = ref()
const syringePipelineWash = async () => {
if (!clearSpeed.value) {
FtMessage.error('请输入清洗速度')
return
@ -78,22 +82,24 @@ const syringePipelineWash = () => {
cancelButtonText: '取消',
showCancelButton: true,
showClose: false,
}).then(() => {
}).then(async () => {
syringePipelineWashRef.value.setLoading(true)
const params = {
cmdName: 'syringe_pipeline_wash',
cmdCode: 'syringe_pipeline_wash',
cmdId: '',
param: {
params: {
speed: clearSpeed.value,
},
}
console.log('sendControl', params)
sendControl(params)
FtMessage.success('指令已发送')
await sendControl(params)
syringePipelineWashRef.value.setLoading(false)
}).catch(() => {
FtMessage.error('取消清洗')
})
}
const nozzlePipelineWashRef = ref()
const nozzlePipelineWash = () => {
if (!clearSpeed.value) {
FtMessage.error('请输入清洗速度')
@ -109,21 +115,23 @@ const nozzlePipelineWash = () => {
cancelButtonText: '取消',
showCancelButton: true,
showClose: false,
}).then(() => {
}).then(async () => {
nozzlePipelineWashRef.value.setLoading(true)
const params = {
cmdName: 'nozzle_pipeline_wash',
cmdCode: 'nozzle_pipeline_wash',
cmdId: '',
param: {
params: {
speed: clearSpeed.value,
},
}
sendControl(params)
FtMessage.success('指令已发送')
await sendControl(params)
nozzlePipelineWashRef.value.setLoading(false)
}).catch(() => {
FtMessage.error('取消清洗')
})
}
const matrixPrefillRef = ref()
const matrixPrefill = () => {
if (!speed.value) {
FtMessage.error('请输入预充速度')
@ -139,43 +147,44 @@ const matrixPrefill = () => {
cancelButtonText: '取消',
showCancelButton: true,
showClose: false,
}).then(() => {
}).then(async () => {
matrixPrefillRef.value.setLoading(true)
const params = {
cmdName: 'matrix_prefill',
cmdCode: 'matrix_prefill',
cmdId: '',
param: {
params: {
speed: speed.value,
},
}
sendControl(params)
FtMessage.success('指令已发送')
await sendControl(params)
matrixPrefillRef.value.setLoading(false)
}).catch(() => {
FtMessage.error('取消预充')
})
}
const pipelineWashStop = () => {
const pipelineWashStop = async () => {
const params = {
cmdName: 'pipeline_wash_stop',
cmdCode: 'syringe_pipeline_wash_stop',
cmdId: '',
}
sendControl(params)
await sendControl(params)
}
const matrixPrefillStop = () => {
const matrixPrefillStop = async () => {
const params = {
cmdName: 'matrix_prefill_stop',
cmdCode: 'matrix_prefill_stop',
cmdId: '',
}
sendControl(params)
await sendControl(params)
}
const dehumidifierStop = () => {
const dehumidifierStop = async () => {
const params = {
cmdName: 'dehumidifier_stop',
cmdCode: 'dehumidifier_stop',
cmdId: '',
}
sendControl(params)
await sendControl(params)
}
</script>
@ -196,13 +205,13 @@ const dehumidifierStop = () => {
<el-input v-model="clearSpeed" type="number" style="width: 100px;margin:0 10px" />
<span>uL/min</span>
</div>
<ft-button type="primary" @click="syringePipelineWash">
<ft-button ref="syringePipelineWashRef" type="primary" :on-click="syringePipelineWash">
清洗注射器管路
</ft-button>
<ft-button type="primary" @click="nozzlePipelineWash">
<ft-button ref="nozzlePipelineWashRef" type="primary" :on-click="nozzlePipelineWash">
清洗喷嘴管路
</ft-button>
<ft-button @click="pipelineWashStop">
<ft-button :on-click="pipelineWashStop">
停止清洗
</ft-button>
</div>
@ -222,10 +231,10 @@ const dehumidifierStop = () => {
<el-input v-model="speed" type="number" style="width: 100px;margin:0 10px" />
<span>uL/min</span>
</div>
<ft-button type="primary" @click="matrixPrefill">
<ft-button ref="matrixPrefillRef" type="primary" :on-click="matrixPrefill">
开始预充
</ft-button>
<ft-button @click="matrixPrefillStop">
<ft-button :on-click="matrixPrefillStop">
结束预充
</ft-button>
<!-- <ft-button @click="motorToHome">回原点</ft-button> -->
@ -243,7 +252,7 @@ const dehumidifierStop = () => {
<div style="display: flex;align-items: center;margin-top: 20px">
<div style="display: flex;align-items: center;width: fit-content;margin-right: 30px">
<span>当前湿度</span>
<span class="num-text">{{ systemStore.systemStatus.humidity }}</span>
<span class="num-text">{{ systemStore.systemSensor.humidity }}</span>
<span>%RH</span>
</div>
<div style="display: flex;align-items: center;width: fit-content;margin-right: 30px">
@ -251,10 +260,10 @@ const dehumidifierStop = () => {
<el-input v-model="humidity" type="number" style="width: 100px;margin:0 10px" />
<span>%RH</span>
</div>
<ft-button type="primary" @click="dehumidifierStart">
<ft-button ref="dehumidifierStartRef" type="primary" :on-click="dehumidifierStart">
开始除湿
</ft-button>
<ft-button @click="dehumidifierStop">
<ft-button :on-click="dehumidifierStop">
停止除湿
</ft-button>
</div>

4
vite.config.ts

@ -76,8 +76,8 @@ export default defineConfig({
host: '0.0.0.0',
proxy: {
'/api': {
target: 'http://192.168.1.199:8080',
// target: 'http://192.168.1.200:8080',
// target: 'http://192.168.1.199:8080',
target: 'http://192.168.1.200:8080',
// secure: false,
changeOrigin: true, // 是否跨域
rewrite: path => path.replace(/^\/api/, 'api'),

Loading…
Cancel
Save