Browse Source

添加设备初始化

feature/three
LiLongLong 3 months ago
parent
commit
9fb730ea5c
  1. 3
      src/apis/self.ts
  2. 264
      src/components/check/index.vue
  3. 56
      src/components/exit/index.vue
  4. 9
      src/views/craft/index.vue
  5. 14
      src/views/ore/index.vue
  6. 12
      src/views/solution/index.vue
  7. 12
      src/views/user/index.vue

3
src/apis/self.ts

@ -0,0 +1,3 @@
import http from 'libs/http'
export const getSelfStatus = (): Promise<Record<string, boolean>> => http.get('/self-test/status')

264
src/components/check/index.vue

@ -0,0 +1,264 @@
<script lang="ts" setup>
import { getContainerList } from '@/apis/container'
import { getSelfStatus } from '@/apis/self'
import { useHomeStore } from 'stores/homeStore'
import { onMounted, ref, watch } from 'vue'
interface SelfStatus {
name: string
isOrign: boolean
value: string
type: string
}
const props = defineProps({
checking: Boolean,
})
const emits = defineEmits(['update:checking'])
const homeStore = useHomeStore()
const visible = ref(props.checking)
const chemicalList = ref<Container.ContainerItem[]>([])
watch(() => props.checking, (newVal) => {
visible.value = newVal
})
onMounted(() => {
querySelfStatus()
queryContainerList()
})
const statusMap: Record<string, Record<string, string>> = {
gantryXOrigin: {
name: '机械臂x轴',
value: 'x',
type: 'axis',
},
gantryYOrigin: {
name: '机械臂y轴',
value: 'y',
type: 'axis',
},
gantryZOrigin: {
name: '机械臂z轴',
value: 'y',
type: 'axis',
},
dualRobotJoint1Origin: {
name: '机械臂01',
value: 'largeArm',
type: 'liquid',
},
dualRobotJoint2Origin: {
name: '机械臂02',
value: 'smallArm',
type: 'liquid',
},
capLiftingOrigin: {
name: '拍子电机升降',
value: '',
type: 'cap',
},
trayLifting01Origin: {
name: '加热区01托盘升降',
value: 'heat_module_01',
type: 'heat',
},
trayLifting02Origin: {
name: '加热区02托盘升降',
value: 'heat_module_01',
type: 'heat',
},
trayLifting03Origin: {
name: '加热区03托盘升降',
value: 'heat_module_01',
type: 'heat',
},
trayLifting04Origin: {
name: '加热区04托盘升降',
value: 'heat_module_04',
type: 'heat',
},
trayLifting05Origin: {
name: '加热区05托盘升降',
value: 'heat_module_05',
type: 'heat',
},
trayLifting06Origin: {
name: '加热区06托盘升降',
value: 'heat_module_06',
type: 'heat',
},
}
const deviceStatusList = ref<SelfStatus[]>([])
const querySelfStatus = () => {
getSelfStatus().then((res) => {
if (res) {
const list: SelfStatus[] = []
Object.keys(res).forEach((item) => {
list.push({
name: statusMap[item].name,
isOrign: res[item],
value: statusMap[item].value,
type: statusMap[item].type,
})
})
deviceStatusList.value = list
}
})
}
// const pumpId = ref()
const queryContainerList = () => {
getContainerList().then((res) => {
if (res) {
const list: Container.ContainerItem[] = res
const solutionList: Container.ContainerItem[] = []
list.forEach((item, index) => {
// 8,
if (index < 8) {
solutionList.push({
...item,
solutionName: `加液泵_0${index + 1}`,
})
}
})
chemicalList.value = solutionList
}
})
}
const resetOrign = (item: SelfStatus) => {
if (item.value === 'x' || item.value === 'y' || item.value === 'z') {
gantry_origin(item.value)
}
else if (item.type === 'liquied') {
dual_robot_joint_origin(item.value)
}
else if (item.type === 'heat') {
tray_lifting_origin(item.value)
}
else if (item.type === 'cap') {
cap_lifting_origin()
}
}
// TODO
// const currentPumpId = ref()
// const onPumpChange = (value: string) => {
// currentPumpId.value = value
// }
// const onPumpEmpty = () => {
// console.log('===currentPumpId===', currentPumpId.value)
// }
let currentCommandId = ''
const gantry_origin = async (motor: 'x' | 'y' | 'z') => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'gantry_origin',
params: {
[motor]: true,
},
}
await homeStore.sendControl(params)
}
const dual_robot_joint_origin = async (arm: string) => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'dual_robot_joint_origin',
params: {
target: [arm],
},
}
await homeStore.sendControl(params)
}
const cap_lifting_origin = async () => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'cap_lifting_origin',
params: {},
}
await homeStore.sendControl(params)
}
const tray_lifting_origin = async (heatId: string) => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'tray_lifting_origin',
params: {
heatId,
},
}
await homeStore.sendControl(params)
}
const cancel = () => {
emits('update:checking', false)
visible.value = false
}
</script>
<template>
<FtDialog v-model="visible" title="设备初始化" width="50%">
<div class="check-main">
<div class="check-status">
<h3>名称</h3>
<h3>是否在原点</h3>
<h3 style="text-align: center;">
操作
</h3>
</div>
<div v-for="(item) in deviceStatusList" :key="item.name" class="check-status">
<div>
{{ item.name }}
</div>
<div style="margin-left: 2rem;">
<el-icon v-if="!item.isOrign" style="color:red;font-size: 25px;">
<CloseBold />
</el-icon>
<el-icon v-else style="color:#25be25;font-size: 25px;">
<Select />
</el-icon>
</div>
<div style="text-align: center;">
<el-link type="primary" @click="resetOrign(item)">
回原点
</el-link>
</div>
</div>
<!-- <div class="check-status">
<div>
加液泵
<el-select v-model="pumpId" size="small" style="width:10rem" @change="onPumpChange">
<el-option v-for="item in chemicalList" :key="item.solutionId" :label="item.solutionName" :value="item.pumpId" />
</el-select>
</div>
<div></div>
<div style="text-align: center;">
<el-link type="primary" @click="onPumpEmpty()">
排空
</el-link>
</div>
</div> -->
</div>
<template #footer>
<FtButton @click="cancel">
取消
</FtButton>
</template>
</FtDialog>
</template>
<style scoped>
.check-main{
height: 60vh;
}
.check-status{
display: grid;
grid-template-columns: 2fr 1fr 1fr;
margin-top: 5px;
}
</style>

56
src/components/exit/index.vue

@ -1,51 +1,23 @@
<script lang="ts" setup>
import deviceSvg from '@/assets/images/init-device.svg'
import CancelSvg from '@/assets/images/user-cancel.svg'
import LogoutSvg from '@/assets/images/user-logout.svg'
import x_Svg from '@/assets/images/x.svg'
import y_Svg from '@/assets/images/y.svg'
import z_Svg from '@/assets/images/z.svg'
import { logout } from 'apis/login'
import Check from 'components/check/index.vue'
import { delToken } from 'libs/token'
import { useDebugStore } from 'stores/debugStore'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const isLoading = ref(false)
const router = useRouter()
const debugStore = useDebugStore()
const axisList = ref<Exit.Axis[]>([{
name: 'X',
icon: x_Svg,
value: 'x',
color: 'rgb(252 137 60)',
}, {
name: 'Y',
icon: y_Svg,
value: 'y',
color: 'rgb(105 165 253)',
}, {
name: 'Z',
icon: z_Svg,
value: 'z',
color: 'rgb(136 121 254)',
}])
const openModal = () => {
isLoading.value = true
}
let currentCommandId = ''
const onInitAxis = async (motor: 'x' | 'y' | 'z') => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'debug_transportation_arm_reset',
params: {
dim: [motor],
},
}
await debugStore.sendControl(params)
isLoading.value = false
const checking = ref(false)
const onInitDevice = async () => {
checking.value = true
onCancel()
}
const onLogout = () => {
@ -57,6 +29,7 @@ const onLogout = () => {
const onCancel = () => {
isLoading.value = false
}
defineExpose({
openModal,
})
@ -64,16 +37,12 @@ defineExpose({
<template>
<div v-if="isLoading" class="loading-overlay">
<div>
<div class="init-axis">
<div v-for="axis in axisList" :key="axis.value" class="loading-content" @click="onInitAxis(axis.value)">
<img :src="axis.icon" alt="Icon" width="80">
<div style="color: #ececec;">
初始化<span :style="{ color: axis.color, padding: '10px' }">{{ axis.name }}</span>
<div class="loading-content" @click="onInitDevice()">
<img :src="deviceSvg" alt="Icon" width="80">
<div style="color: rgb(243 168 74);">
设备初始化
</div>
</div>
</div>
<div class="init-logout">
<div class="loading-content" @click="onLogout">
<img :src="LogoutSvg" alt="Icon" width="80">
<div style="color: #9358df;">
@ -87,7 +56,8 @@ defineExpose({
</div>
</div>
</div>
</div>
<div v-if="checking">
<Check v-model:checking="checking" />
</div>
</template>

9
src/views/craft/index.vue

@ -177,19 +177,14 @@ const returnOre = () => {
</main>
<AddCraftDialog ref="addCraftRef" @ok="queryCrafList" />
<!-- 执行工艺选择加热区 -->
<el-dialog v-model="heatVisible" title="执行工艺" width="30vw">
<FtDialog v-model="heatVisible" title="添加矿石" width="30%" :ok-handle="onStart" @cancel="heatVisible = false">
<div style="display: flex; justify-content: center;align-items: center;">
<label>选择加热区</label>
<el-select v-model="heatId" style="width:200px" size="small">
<el-option v-for="el in heatList" :key="el.id" :label="`${el.name}`" :value="el.id" />
</el-select>
</div>
<div style="display: flex; justify-content: center;align-items: center; height:100px">
<FtButton type="primary" @click="onStart">
开始执行
</FtButton>
</div>
</el-dialog>
</FtDialog>
<CraftStatus ref="craftStatusRef" />
<div class="return-ore">
<FtButton @click="returnOre">

14
src/views/ore/index.vue

@ -88,7 +88,7 @@ const onConfirm = () => {
...oreForm.value,
}
let apiFn = null
if (oreForm.value.id) {
if (oreForm.value && oreForm.value.id) {
params.id = oreForm.value.id
apiFn = editOre
}
@ -165,21 +165,11 @@ const onShowCraft = () => {
</el-table>
<!-- <FtTable :columns="columns" has-header :btn-list="btnList" :get-data-fn="queryOresList" /> -->
</div>
<FtDialog v-model="visible" title="添加矿石" width="30%">
<FtDialog v-model="visible" title="添加矿石" width="30%" :ok-handle="onConfirm" @cancel="closeDialog">
<div class="add-content">
<label>矿石名称</label>
<span><el-input v-model="name" placeholder="矿石名称" style="width:200px" /></span>
</div>
<template #footer>
<div class="footer">
<FtButton @click="closeDialog">
取消
</FtButton>
<FtButton type="primary" :loading="loading" :click-handle="onConfirm">
确定
</FtButton>
</div>
</template>
</FtDialog>
</div>
</template>

12
src/views/solution/index.vue

@ -125,21 +125,11 @@ const closeDialog = () => {
<el-table-column prop="updateTime" label="更新时间" />
</el-table>
</div>
<FtDialog v-model="visible" title="添加溶液" width="30%">
<FtDialog v-model="visible" title="添加溶液" width="30%" :ok-handle="onConfirm" @cancel="closeDialog">
<div class="add-content">
<label>溶液名称</label>
<span><el-input v-model="name" placeholder="溶液名称" style="width:200px" /></span>
</div>
<template #footer>
<div class="footer">
<FtButton @click="closeDialog">
取消
</FtButton>
<FtButton type="primary" :click-handle="onConfirm">
确定
</FtButton>
</div>
</template>
</FtDialog>
</div>
</template>

12
src/views/user/index.vue

@ -154,7 +154,7 @@ const doSave = () => {
<el-table-column prop="updateTime" label="更新时间" />
</el-table>
</div>
<FtDialog v-model="visible" title="添加用户" width="30%">
<FtDialog v-model="visible" title="添加用户" width="30%" :ok-handle="() => { onConfirm(userFormRef) }" @cancel="closeDialog">
<div>
<el-form ref="userFormRef" :model="userForm" label-width="auto" style="max-width: 600px">
<el-form-item
@ -210,16 +210,6 @@ const doSave = () => {
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="footer">
<FtButton @click="closeDialog">
取消
</FtButton>
<FtButton type="primary" :click-handle="() => { onConfirm(userFormRef) }">
确定
</FtButton>
</div>
</template>
</FtDialog>
</div>
</template>

Loading…
Cancel
Save