22 changed files with 819 additions and 923 deletions
-
2src/apis/crafts.ts
-
3src/apis/system.ts
-
318src/components/check1/index.vue
-
49src/components/craft/AddCraft/index.vue
-
0src/components/home/Countdown/Countdown.vue
-
6src/components/home/ExecuteCraft/index.vue
-
2src/components/home/Tube/index.vue
-
35src/components/system/Check/index.vue
-
60src/components/system/EditDate/index.vue
-
0src/components/system/Stop/index.vue
-
59src/components/systemConfig/Edit/index.vue
-
22src/layouts/default.vue
-
1src/libs/utils.ts
-
2src/router/index.ts
-
11src/router/routes.ts
-
6src/stores/systemStore.ts
-
6src/types/system.d.ts
-
123src/views/home/index.vue
-
59src/views/systemConfig/index.vue
@ -1,318 +0,0 @@ |
|||
<script lang="ts" setup> |
|||
import { ElMessage } from 'element-plus' |
|||
import { socket } from 'libs/socket' |
|||
import { useHomeStore } from 'stores/homeStore' |
|||
import { useSystemStore } from 'stores/systemStore' |
|||
import { onMounted, onUnmounted, ref } from 'vue' |
|||
import { getSelfFinish, getSelfStatus } from '@/apis/self' |
|||
|
|||
interface SelfStatus { |
|||
name: string |
|||
isOrign: boolean |
|||
value: string |
|||
type: string |
|||
} |
|||
const emits = defineEmits(['close']) |
|||
const homeStore = useHomeStore() |
|||
const systemStore = useSystemStore() |
|||
|
|||
const loading = ref(false) |
|||
|
|||
onMounted(() => { |
|||
socket.init(receiveMessage, 'cmd_debug') |
|||
socket.init(receiveMessage, 'cmd_response') |
|||
onStartSelfTest() |
|||
}) |
|||
onUnmounted(() => { |
|||
clearInterval(patrolTimes.value) |
|||
socket.unregisterCallback(receiveMessage, 'cmd_debug') |
|||
socket.unregisterCallback(receiveMessage, 'cmd_response') |
|||
}) |
|||
|
|||
const receiveMessage = (data: Socket.cmdData) => { |
|||
data.commandId === currentCommandId && systemStore.pushSystemList(data) |
|||
} |
|||
|
|||
const onStartSelfTest = () => { |
|||
patrolSelfStatus() |
|||
} |
|||
const statusMap: Record<string, Record<string, string>> = { |
|||
doorOrigin: { |
|||
name: '门', |
|||
value: '', |
|||
type: 'door', |
|||
}, |
|||
shakeOrigin: { |
|||
name: '摇匀电机', |
|||
value: '', |
|||
type: 'shake', |
|||
}, |
|||
gantryXOrigin: { |
|||
name: '机械臂x轴', |
|||
value: 'x', |
|||
type: 'axis', |
|||
}, |
|||
gantryYOrigin: { |
|||
name: '机械臂y轴', |
|||
value: 'y', |
|||
type: 'axis', |
|||
}, |
|||
gantryZOrigin: { |
|||
name: '机械臂z轴', |
|||
value: 'z', |
|||
type: 'axis', |
|||
}, |
|||
dualRobotOrigin: { |
|||
name: '加液机械臂', |
|||
value: '', |
|||
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_02', |
|||
type: 'heat', |
|||
}, |
|||
trayLifting03Origin: { |
|||
name: '加热区03托盘升降', |
|||
value: 'heat_module_03', |
|||
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 patrolTimes = ref() |
|||
const patrolSelfStatus = () => { |
|||
loading.value = true |
|||
patrolTimes.value = setInterval(() => { |
|||
querySelfStatus() |
|||
}, 1000) |
|||
} |
|||
|
|||
const deviceStatusList = ref<SelfStatus[]>([]) |
|||
const selfStateComplete = ref(false) |
|||
const querySelfStatus = () => { |
|||
const orignStatusList = [] |
|||
getSelfStatus().then((res) => { |
|||
console.log('res', res) |
|||
loading.value = false |
|||
if (res) { |
|||
try { |
|||
const list: SelfStatus[] = [] |
|||
const keys = Object.keys(res) |
|||
keys.forEach((item) => { |
|||
list.push({ |
|||
name: statusMap[item].name, |
|||
isOrign: res[item], |
|||
value: statusMap[item].value, |
|||
type: statusMap[item].type, |
|||
}) |
|||
if (res[item]) { |
|||
orignStatusList.push(item) |
|||
} |
|||
if (orignStatusList.length === keys.length) { |
|||
clearInterval(patrolTimes.value) |
|||
selfStateComplete.value = true |
|||
} |
|||
}) |
|||
deviceStatusList.value = list |
|||
console.log('deviceStatusList', list) |
|||
} |
|||
catch (e) { |
|||
console.log('error', e) |
|||
} |
|||
} |
|||
}).catch(() => { |
|||
loading.value = false |
|||
}) |
|||
} |
|||
|
|||
const resetOrign = (item: SelfStatus) => { |
|||
if (item.type === 'door') { |
|||
door_origin() |
|||
} |
|||
if (item.type === 'shake') { |
|||
shake_origin() |
|||
} |
|||
else if (item.value === 'x' || item.value === 'y' || item.value === 'z') { |
|||
gantry_origin(item.value) |
|||
} |
|||
else if (item.type === 'liquid') { |
|||
dual_robot_origin() |
|||
} |
|||
else if (item.type === 'heat') { |
|||
tray_lifting_origin(item.value) |
|||
} |
|||
else if (item.type === 'cap') { |
|||
cap_lifting_origin() |
|||
} |
|||
} |
|||
|
|||
const shake_origin = async () => { |
|||
currentCommandId = Date.now().toString() |
|||
|
|||
const params = { |
|||
commandId: currentCommandId, |
|||
command: `shake_origin`, |
|||
params: {}, |
|||
} |
|||
await homeStore.sendControl(params) |
|||
} |
|||
|
|||
const door_origin = async () => { |
|||
currentCommandId = Date.now().toString() |
|||
|
|||
const params = { |
|||
commandId: currentCommandId, |
|||
command: `door_origin`, |
|||
params: {}, |
|||
} |
|||
await homeStore.sendControl(params) |
|||
} |
|||
|
|||
// 先注释 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_${motor}_origin`, |
|||
params: {}, |
|||
} |
|||
await homeStore.sendControl(params) |
|||
} |
|||
|
|||
const dual_robot_origin = async () => { |
|||
currentCommandId = Date.now().toString() |
|||
const params = { |
|||
commandId: currentCommandId, |
|||
command: 'dual_robot_origin', |
|||
params: {}, |
|||
} |
|||
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 onComplete = () => { |
|||
getSelfFinish().then(() => { |
|||
ElMessage.success('自检完成') |
|||
emits('close') |
|||
}) |
|||
} |
|||
|
|||
// const cancel = () => { |
|||
// emits('update:checking', false) |
|||
// visible.value = false |
|||
// } |
|||
</script> |
|||
|
|||
<template> |
|||
<FtDialog visible title="自检" width="50%"> |
|||
<div v-loading="loading" class="check-main"> |
|||
<!-- <div v-if="type !== 'cancel'"> --> |
|||
<!-- <span style="color: red">所有电机回原点后才可操作</span> --> |
|||
<!-- </div> --> |
|||
<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 v-if="!item.isOrign" style="text-align: center;"> |
|||
<ft-button type="primary" :click-handle="() => resetOrign(item)"> |
|||
回原点 |
|||
</ft-button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<template #footer> |
|||
<FtButton :disabled="!selfStateComplete" :click-handle="onComplete"> |
|||
关闭 |
|||
</FtButton> |
|||
</template> |
|||
</FtDialog> |
|||
</template> |
|||
|
|||
<style scoped> |
|||
.check-main{ |
|||
height: 70vh; |
|||
overflow: auto; |
|||
} |
|||
.check-status{ |
|||
display: grid; |
|||
grid-template-columns: 2fr 1fr 1fr; |
|||
margin-top: 5px; |
|||
height: 30px; |
|||
} |
|||
</style> |
@ -0,0 +1,60 @@ |
|||
<script setup lang="ts"> |
|||
import { setTime } from 'apis/system' |
|||
import { FtMessage } from 'libs/message' |
|||
import { useSystemStore } from 'stores/systemStore' |
|||
import { ref } from 'vue' |
|||
|
|||
const emits = defineEmits(['ok', 'close']) |
|||
const form = ref<{ datetime?: string }>({ |
|||
datetime: useSystemStore().currentTime, |
|||
}) |
|||
|
|||
const formRef = ref() |
|||
|
|||
const rules = { |
|||
datetime: [ |
|||
{ required: true, message: '请选择时间', trigger: 'change' }, |
|||
], |
|||
} |
|||
|
|||
const okHandle = async () => { |
|||
try { |
|||
const valid = await formRef.value.validate() |
|||
if (!valid) { |
|||
return |
|||
} |
|||
await setTime(form.value) |
|||
FtMessage.success('修改成功') |
|||
emits('ok') |
|||
} |
|||
catch (e) { |
|||
console.log(e) |
|||
} |
|||
} |
|||
|
|||
const cancel = () => { |
|||
emits('close') |
|||
} |
|||
</script> |
|||
|
|||
<template> |
|||
<ft-dialog visible title="设置日期与时间" width="40%" :ok-handle="okHandle" @cancel="cancel"> |
|||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto"> |
|||
<el-form-item label="日期与时间" prop="datetime"> |
|||
<el-date-picker |
|||
v-model="form.datetime" |
|||
:show-now="false" |
|||
format="YYYY-MM-DD hh:mm:ss" |
|||
value-format="YYYY-MM-DD hh:mm:ss" |
|||
style="width: 100%" |
|||
type="datetime" |
|||
placeholder="请选择日期和时间" |
|||
/> |
|||
</el-form-item> |
|||
</el-form> |
|||
</ft-dialog> |
|||
</template> |
|||
|
|||
<style scoped lang="scss"> |
|||
|
|||
</style> |
@ -0,0 +1,59 @@ |
|||
<script setup lang="ts"> |
|||
import { updateConfig } from 'apis/system' |
|||
import { FtMessage } from 'libs/message' |
|||
import { inject, ref } from 'vue' |
|||
|
|||
const emits = defineEmits(['ok', 'cancel']) |
|||
|
|||
const data = inject('currentData') |
|||
|
|||
const form = ref<System.SystemConfig>(data as System.SystemConfig) |
|||
const formRef = ref() |
|||
|
|||
const rules = { |
|||
value: [ |
|||
{ required: true, message: '请输入值', trigger: 'blur' }, |
|||
], |
|||
} |
|||
|
|||
const okHandle = async () => { |
|||
try { |
|||
const valid = await formRef.value.validate() |
|||
if (!valid) { |
|||
return |
|||
} |
|||
|
|||
await updateConfig(form.value) |
|||
FtMessage.success('保存成功') |
|||
emits('ok') |
|||
} |
|||
catch (error) { |
|||
console.log(error) |
|||
} |
|||
} |
|||
const cancel = () => { |
|||
emits('cancel') |
|||
} |
|||
</script> |
|||
|
|||
<template> |
|||
<FtDialog visible title="编辑" width="30%" :ok-handle="okHandle" @cancel="cancel"> |
|||
<el-form ref="formRef" label-width="auto" :model="form" :rules="rules" label-suffix=": "> |
|||
<el-form-item label="名称"> |
|||
<el-tag>{{ form.name }}</el-tag> |
|||
</el-form-item> |
|||
<el-form-item label="code"> |
|||
<el-tag>{{ form.code }}</el-tag> |
|||
</el-form-item> |
|||
<el-form-item label="值" prop="value"> |
|||
<el-input v-model="form.value" placeholder="请输入值" /> |
|||
</el-form-item> |
|||
</el-form> |
|||
</FtDialog> |
|||
</template> |
|||
|
|||
<style scoped lang="scss"> |
|||
.el-tag { |
|||
margin-right: 5px; |
|||
} |
|||
</style> |
@ -0,0 +1,59 @@ |
|||
<script setup lang="ts"> |
|||
import { configList } from 'apis/system' |
|||
import Edit from 'components/systemConfig/Edit/index.vue' |
|||
import { provide, ref, useTemplateRef } from 'vue' |
|||
|
|||
const upDataVisible = ref(false) |
|||
const currentData = ref<Point.Point>() |
|||
provide('currentData', currentData) |
|||
|
|||
const edit = (data: Point.Point[]) => { |
|||
currentData.value = data[0] |
|||
upDataVisible.value = true |
|||
} |
|||
|
|||
const tableRef = useTemplateRef('tableRef') |
|||
const ok = () => { |
|||
tableRef.value?.initData() |
|||
cancel() |
|||
} |
|||
const cancel = () => { |
|||
upDataVisible.value = false |
|||
} |
|||
const btnList = [ |
|||
{ |
|||
name: '编辑', |
|||
type: 'primary', |
|||
serverUrl: 'edit', |
|||
serverCondition: 1, |
|||
}, |
|||
] |
|||
const columns = [ |
|||
{ |
|||
type: 'selection', |
|||
}, |
|||
{ |
|||
title: '名称', |
|||
key: 'name', |
|||
}, |
|||
{ |
|||
title: 'code', |
|||
key: 'code', |
|||
}, |
|||
{ |
|||
title: '值', |
|||
key: 'value', |
|||
}, |
|||
] |
|||
</script> |
|||
|
|||
<template> |
|||
<div> |
|||
<FtTable ref="tableRef" :columns="columns" has-header :btn-list="btnList" :get-data-fn="configList" @edit="edit" /> |
|||
<Edit v-if="upDataVisible" @ok="ok" @cancel="cancel" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<style scoped lang="scss"> |
|||
|
|||
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue