Browse Source

fix:调试模式保存坐标

master
guoapeng 3 months ago
parent
commit
10c8350e05
  1. 1
      src/apis/system.ts
  2. 67
      src/components/SavePosition/index.vue
  3. 18
      src/views/debug/index.vue

1
src/apis/system.ts

@ -3,3 +3,4 @@ import http from 'libs/http'
export const debugControl = <T>(params: System.CmdControlParams<T>): Promise<null> => http.post('/debug/cmd', params) export const debugControl = <T>(params: System.CmdControlParams<T>): Promise<null> => http.post('/debug/cmd', params)
export const control = <T>(params: System.CmdControlParams<T>): Promise<null> => http.post('/cmd', params) export const control = <T>(params: System.CmdControlParams<T>): Promise<null> => http.post('/cmd', params)
export const getStatus = (): Promise<System.SystemStatus> => http.get('/sys/device-status') export const getStatus = (): Promise<System.SystemStatus> => http.get('/sys/device-status')
export const getPoint = (): Promise<string> => http.get('/cmd/step/gantry-point')

67
src/components/SavePosition/index.vue

@ -0,0 +1,67 @@
<script setup lang="ts">
import { getPointList, updatePoint } from 'apis/point'
import { getPoint } from 'apis/system'
import { onMounted, ref } from 'vue'
const emits = defineEmits(['ok', 'cancel'])
const pointList = ref<Point.Point[]>([])
onMounted(async () => {
pointList.value = await getPointList()
form.value!.position = await getPoint()
})
const form = ref<Point.UpdateParams>({})
const formRef = ref()
const rules = {
id: [
{ required: true, message: '请选择名称', trigger: 'change' },
],
}
const okHandle = async () => {
try {
const valid = await formRef.value.validate()
if (!valid) {
return
}
await updatePoint(form.value!)
emits('ok')
}
catch (error) {
console.log(error)
}
}
const cancel = () => {
emits('cancel')
}
</script>
<template>
<FtDialog visible title="保存坐标" width="40%" :ok-handle="okHandle" @cancel="cancel">
<el-form ref="formRef" label-width="auto" :model="form" :rules="rules">
<el-form-item label="当前坐标">
<span>{{ form?.position }}</span>
</el-form-item>
<el-form-item label="名称" prop="id">
<el-select v-model="form.id" placeholder="请选择名称">
<el-option
v-for="item in pointList"
:key="item.id"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
</el-form>
</FtDialog>
</template>
<style scoped lang="scss">
.item-box {
display: flex;
align-items: center;
justify-content: space-between;
padding: 5px;
}
</style>

18
src/views/debug/index.vue

@ -1,8 +1,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import SavePosition from 'components/SavePosition/index.vue'
import { socket } from 'libs/socket' import { socket } from 'libs/socket'
import { useDebugStore } from 'stores/debugStore' import { useDebugStore } from 'stores/debugStore'
import { useSystemStore } from 'stores/systemStore' import { useSystemStore } from 'stores/systemStore'
import { onMounted, onUnmounted } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'
const systemStore = useSystemStore() const systemStore = useSystemStore()
@ -592,6 +593,8 @@ const debug_stop_all_motor = async () => {
} }
await debugStore.sendControl(params) await debugStore.sendControl(params)
} }
const savePositionVisible = ref(false)
</script> </script>
<template> <template>
@ -631,6 +634,11 @@ const debug_stop_all_motor = async () => {
<span>转运模组</span> <span>转运模组</span>
</div> </div>
</template> </template>
<el-form-item class="button-center">
<ft-button type="primary" size="small" @click="savePositionVisible = true">
保存当前坐标
</ft-button>
</el-form-item>
<el-divider>X轴电机</el-divider> <el-divider>X轴电机</el-divider>
<div class="card-box"> <div class="card-box">
<el-form> <el-form>
@ -1222,6 +1230,7 @@ const debug_stop_all_motor = async () => {
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
<SavePosition v-if="savePositionVisible" @ok="savePositionVisible = false" @cancel="savePositionVisible = false" />
</div> </div>
</template> </template>
@ -1288,4 +1297,11 @@ const debug_stop_all_motor = async () => {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
:deep(.el-form-item).button-center {
.el-form-item__content {
width: 100%;
display: flex;
justify-content: center;
}
}
</style> </style>
Loading…
Cancel
Save