Browse Source

fix:debug弹窗修改拖拽

master
guoapeng 5 months ago
parent
commit
f12f6399bf
  1. 1
      src/apis/system.ts
  2. 52
      src/components/common/FTStream/index.vue
  3. 32
      src/libs/utils.ts
  4. 2
      src/stores/useSystemStore.ts
  5. 5
      src/views/home/index.vue
  6. 58
      src/views/point/index.vue

1
src/apis/system.ts

@ -10,3 +10,4 @@ export const login = (params: { username: string, password: string }) => http.po
export const control = (params: any) => http.post('/function', params) export const control = (params: any) => http.post('/function', params)
export const debugControl = (params: any) => http.post('/function/debug', params) export const debugControl = (params: any) => http.post('/function/debug', params)
export const getDeviceStatus = () => http.get('/device-status/')

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

@ -16,6 +16,8 @@ const title = computed(() => {
}) })
const maskBodyRef = ref<HTMLElement | null>(null) const maskBodyRef = ref<HTMLElement | null>(null)
const maskRef = ref<HTMLElement | null>(null)
const maskHeaderRef = ref<HTMLElement | null>(null)
const statusMap = { const statusMap = {
error: 'danger', error: 'danger',
@ -37,14 +39,59 @@ watch(
}, },
{ deep: true }, { deep: true },
) )
//
let isDragging = false
let offsetX = 0
let offsetY = 0
const handleMouseDown = (event: MouseEvent | TouchEvent) => {
if (maskRef.value && maskHeaderRef.value) {
isDragging = true
const clientX = 'clientX' in event ? event.clientX : event.touches[0].clientX
const clientY = 'clientY' in event ? event.clientY : event.touches[0].clientY
offsetX = clientX - maskRef.value.offsetLeft
offsetY = clientY - maskRef.value.offsetTop
document.addEventListener('mousemove', handleMouseMove)
document.addEventListener('mouseup', handleMouseUp)
document.addEventListener('touchmove', handleMouseMove)
document.addEventListener('touchend', handleMouseUp)
}
}
const handleMouseMove = (event: MouseEvent | TouchEvent) => {
if (maskRef.value && isDragging) {
const clientX = 'clientX' in event ? event.clientX : event.touches[0].clientX
const clientY = 'clientY' in event ? event.clientY : event.touches[0].clientY
// body
const bodyWidth = document.body.clientWidth
const bodyHeight = document.body.clientHeight
// body
const newLeft = Math.max(0, Math.min(clientX - offsetX, bodyWidth - maskRef.value.offsetWidth))
const newTop = Math.max(0, Math.min(clientY - offsetY, bodyHeight - maskRef.value.offsetHeight))
maskRef.value.style.left = `${newLeft}px`
maskRef.value.style.top = `${newTop}px`
}
}
const handleMouseUp = () => {
isDragging = false
document.removeEventListener('mousemove', handleMouseMove)
document.removeEventListener('mouseup', handleMouseUp)
document.removeEventListener('touchmove', handleMouseMove)
document.removeEventListener('touchend', handleMouseUp)
}
</script> </script>
<template> <template>
<teleport to="body"> <teleport to="body">
<!-- 使用 transition 组件包裹 mask 元素 --> <!-- 使用 transition 组件包裹 mask 元素 -->
<transition name="mask-fade"> <transition name="mask-fade">
<div v-if="visible && systemStore.isDebug" class="mask">
<div class="mask-header">
<div v-if="visible && systemStore.isDebug" ref="maskRef" class="mask" @mousedown="handleMouseDown" @touchstart="handleMouseDown">
<div ref="maskHeaderRef" class="mask-header">
<p>{{ title }}</p> <p>{{ title }}</p>
<el-icon @click="systemStore.updateStreamVisible(false)"> <el-icon @click="systemStore.updateStreamVisible(false)">
<Close /> <Close />
@ -86,6 +133,7 @@ watch(
height: 50px; height: 50px;
font-size: 30px; font-size: 30px;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
cursor: move; //
.el-icon svg{ .el-icon svg{
width: 30px; width: 30px;
} }

32
src/libs/utils.ts

@ -24,8 +24,36 @@ export const sendControl = async (params: any, type?: string) => {
return return
} }
if (systemStatus.spraying && (type === 'debug' || sprayingDisableCmd.includes(params.cmdCode))) {
FtMessage.error('设备正在喷涂中,请等待喷涂完成')
if (!systemStatus.spraying && ['matrix_spray_stop'].includes(params.cmdCode)) {
FtMessage.error('设备没有正在喷涂的任务')
return
}
if (systemStatus.paused && (type === 'debug' || sprayingDisableCmd.includes(params.cmdCode))) {
FtMessage.error('喷涂暂停中,请等待喷涂完成')
return
}
if (!systemStatus.paused && ['matrix_spray_continue'].includes(params.cmdCode)) {
FtMessage.error('当前没有暂停的喷涂任务, 无法继续')
return
}
if (!systemStatus.suspendable && ['matrix_spray_pause'].includes(params.cmdCode)) {
FtMessage.error('当前不可以暂停')
return
}
if (systemStatus.cleaningSyringePipeline && (type === 'debug' || ['nozzle_pipeline_wash', 'matrix_spray_start', 'matrix_prefill'].includes(params.cmdCode))) {
FtMessage.error('正在清洗注射器管路, 无法执行')
return
}
if (systemStatus.cleaningNozzlePipeline && (type === 'debug' || ['syringe_pipeline_wash', 'matrix_spray_start', 'matrix_prefill'].includes(params.cmdCode))) {
FtMessage.error('正在清洗喷嘴管路, 无法执行')
return
}
if (systemStatus.prefilling && (type === 'debug' || ['nozzle_pipeline_wash', 'syringe_pipeline_wash', 'matrix_spray_start'].includes(params.cmdCode))) {
FtMessage.error('正在预充管路, 无法执行')
return return
} }

2
src/stores/useSystemStore.ts

@ -10,7 +10,7 @@ export const useSystemStore = defineStore('system', {
cleaningNozzlePipeline: false, // 是否正在清洗喷嘴管路 cleaningNozzlePipeline: false, // 是否正在清洗喷嘴管路
prefilling: false, // 是否正在预充 prefilling: false, // 是否正在预充
dehumidifierRunning: false, // 是否正在除湿 dehumidifierRunning: false, // 是否正在除湿
selfTestCompleted: true, // 是否完成自检
selfTestCompleted: false, // 是否完成自检
stopPressed: false, // 是否按下急停 stopPressed: false, // 是否按下急停
}, },
systemSensor: { systemSensor: {

5
src/views/home/index.vue

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { getDeviceStatus } from 'apis/system'
import Check from 'components/home/Check/index.vue' import Check from 'components/home/Check/index.vue'
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
import { useSystemStore } from 'stores/useSystemStore' import { useSystemStore } from 'stores/useSystemStore'
@ -13,7 +14,8 @@ const ok = () => {
checkVisible.value = false checkVisible.value = false
} }
console.log(systemStore.systemStatus.selfTestCompleted)
getDeviceStatus().then((res: any) => {
systemStore.updateSystemStatus(res)
if (!systemStore.systemStatus.selfTestCompleted) { if (!systemStore.systemStatus.selfTestCompleted) {
ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', { ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', {
type: 'warning', type: 'warning',
@ -27,6 +29,7 @@ if (!systemStore.systemStatus.selfTestCompleted) {
checkVisible.value = true checkVisible.value = true
}) })
} }
})
</script> </script>
<template> <template>

58
src/views/point/index.vue

@ -1,10 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { MatrixQuery } from 'apis/matrix' import type { MatrixQuery } from 'apis/matrix'
import { del, list } from 'apis/point'
import { list } from 'apis/point'
import FtButton from 'components/common/FTButton/index.vue' import FtButton from 'components/common/FTButton/index.vue'
import Edit from 'components/point/Edit/index.vue' import Edit from 'components/point/Edit/index.vue'
import { ElMessageBox } from 'element-plus'
import { FtMessage } from 'libs/message'
import { onMounted, ref } from 'vue' import { onMounted, ref } from 'vue'
@ -31,10 +29,10 @@ const getList = async () => {
const addVisible = ref(false) const addVisible = ref(false)
const formData = ref({}) const formData = ref({})
const addHandle = () => {
formData.value = {}
addVisible.value = true
}
// const addHandle = () => {
// formData.value = {}
// addVisible.value = true
// }
const pageChange = (pageNum: number, pageSize: number) => { const pageChange = (pageNum: number, pageSize: number) => {
query.value.pageNum = pageNum query.value.pageNum = pageNum
@ -58,23 +56,23 @@ const editHandle = () => {
addVisible.value = true addVisible.value = true
} }
const delHandle = async () => {
const ids = selectedData.value.map((item: any) => item.id)
ElMessageBox.confirm('确认删除?', '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消',
showCancelButton: true,
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
closeOnHashChange: false,
}).then(async () => {
await del(ids.join(','))
FtMessage.success('删除成功')
await getList()
})
}
// const delHandle = async () => {
// const ids = selectedData.value.map((item: any) => item.id)
// ElMessageBox.confirm('', '', {
// type: 'warning',
// confirmButtonText: '',
// cancelButtonText: '',
// showCancelButton: true,
// showClose: false,
// closeOnClickModal: false,
// closeOnPressEscape: false,
// closeOnHashChange: false,
// }).then(async () => {
// await del(ids.join(','))
// FtMessage.success('')
// await getList()
// })
// }
</script> </script>
<template> <template>
@ -83,15 +81,15 @@ const delHandle = async () => {
<el-col :span="12" /> <el-col :span="12" />
<el-col :span="12"> <el-col :span="12">
<div style="float: right"> <div style="float: right">
<FtButton type="primary" @click="addHandle">
新增
</FtButton>
<!-- <FtButton type="primary" @click="addHandle"> -->
<!-- 新增 -->
<!-- </FtButton> -->
<FtButton :disabled="selectedData.length !== 1" @click="editHandle"> <FtButton :disabled="selectedData.length !== 1" @click="editHandle">
编辑 编辑
</FtButton> </FtButton>
<FtButton :disabled="selectedData.length === 0" @click="delHandle">
删除
</FtButton>
<!-- <FtButton :disabled="selectedData.length === 0" @click="delHandle"> -->
<!-- 删除 -->
<!-- </FtButton> -->
</div> </div>
</el-col> </el-col>
</el-row> </el-row>

Loading…
Cancel
Save