diff --git a/src/components/HeaderBar.vue b/src/components/HeaderBar.vue index aea7b2d..0c46474 100644 --- a/src/components/HeaderBar.vue +++ b/src/components/HeaderBar.vue @@ -1,6 +1,6 @@ - + {{ pageNameMap[route.path] }} @@ -60,6 +60,10 @@ onMounted(() => { }); }); +function goHome(){ + router.push('/home') +} + const pageNameMap: Record = { "/": "基质喷涂转印仪", "/environment": "环境设置", diff --git a/src/services/globalCmd/cmdTypes.ts b/src/services/globalCmd/cmdTypes.ts index a8fcd13..707dc59 100644 --- a/src/services/globalCmd/cmdTypes.ts +++ b/src/services/globalCmd/cmdTypes.ts @@ -78,3 +78,15 @@ export type ControlValueType = { isOpen: boolean; }; }; + +export type Light = { + brightness:number +} + +export type Axis ={ + index: number; + x1: number; + y1: number; + x2: number; + y2: number; +} \ No newline at end of file diff --git a/src/services/globalCmd/globalCmd.ts b/src/services/globalCmd/globalCmd.ts index 4e7b1ca..1aefa04 100644 --- a/src/services/globalCmd/globalCmd.ts +++ b/src/services/globalCmd/globalCmd.ts @@ -1,13 +1,13 @@ import httpRequest, { type BaseResponse } from "../httpRequest"; import { addTxnRecord } from "../txn"; -import type { VoltageType, ControlValueType, SyringeType, WorkType } from "./cmdTypes"; +import type { VoltageType, ControlValueType, SyringeType, WorkType, Light, MachineryType } from "./cmdTypes"; //移动电机 -export function moveMotorToPosition(params: { commandName: string; params: Record }) { +export function moveMotorToPosition(params:MachineryType) { const commandId = addTxnRecord({ ...params, category: "debug" }); return httpRequest>({ url: "/api/cmd/moveMotorToPosition", - params: { ...params, commandId }, + params: { params, commandId, commandName: "moveMotorToPosition"}, method: "POST", }); } @@ -17,7 +17,7 @@ export function switchThreeWayValve(params: { type: string }) { const commandId = addTxnRecord({ ...params, category: "debug" }); return httpRequest>({ url: "/api/cmd/switchThreeWayValve", - params: { ...params, commandId }, + params: { params, commandId }, method: "POST", }); } @@ -55,7 +55,7 @@ export function turnOffSyringePump() { //开始喷涂 export function startWork(params: WorkType) { - return httpRequest>({ url: "/api/cmd/startWork", params, method: "POST" }); + return httpRequest>({ url: "/api/cmd/startWork", params:{params}, method: "POST" }); } export function stopWork() { return httpRequest>({ url: "/api/cmd/stopWork", params: {}, method: "POST" }); @@ -71,6 +71,7 @@ export function pushInTray(params: Record) { export function rotate(params: any) { return httpRequest>({ url: "/api/cmd/rotate", params, method: "POST" }); } + export function setMotorSpeed(params: { axis: "X" | "Y" | "Z"; speed: number }) { return httpRequest>({ url: "/api/cmd/setMotorSpeed", params: { params }, method: "POST" }); } @@ -106,16 +107,16 @@ export function stopDehumidify() { } //停止电机 -export function stopMotor(params: any) { - return httpRequest>({ url: "/api/cmd/stopMotor", params, method: "POST" }); +export function stopMotor(params: {axis:string}) { + return httpRequest>({ url: "/api/cmd/stopMotor", params:{params}, method: "POST" }); } //关闭照明灯 -export function turnOffLightPanel(params: any) { - return httpRequest>({ url: "/api/cmd/turnOffLightPanel", params, method: "POST" }); +export function turnOffLightPanel(params: Light) { + return httpRequest({ url: "/api/cmd/turnOffLightPanel", params:{params}, method: "POST" }); } //开启照明灯 -export function turnOnLightPanel(params: any) { - return httpRequest>({ url: "/api/cmd/turnOnLightPanel", params, method: "POST" }); +export function turnOnLightPanel(params: {brightness:number}) { + return httpRequest>({ url: "/api/cmd/turnOnLightPanel", params:{params}, method: "POST" }); } diff --git a/src/services/matrix/craft.ts b/src/services/matrix/craft.ts index 8f2c0be..8e8bf64 100644 --- a/src/services/matrix/craft.ts +++ b/src/services/matrix/craft.ts @@ -1,9 +1,9 @@ import type { WorkType } from "../globalCmd/cmdTypes"; import httpRequest, { type BaseResponse } from "../httpRequest"; -import type { CraftItem } from "@/services/matrix/type"; +import type { CraftItem, HistoryItem } from "@/services/matrix/type"; export function getList(params: { pageSize: number; pageNum: number }) { - return httpRequest({ + return httpRequest>({ url: "/api/matrixCraft/list", params: { ...params }, method: "POST", @@ -42,7 +42,7 @@ export function delCraft(ids:string){ } export function getHistoryList(params:{pageSize:number, pageNum:number}){ - return httpRequest({ + return httpRequest>({ url: `/api/log/list`, params: { ...params }, method: "GET", diff --git a/src/services/matrix/manage.ts b/src/services/matrix/manage.ts index 1fb909b..a2c62f5 100644 --- a/src/services/matrix/manage.ts +++ b/src/services/matrix/manage.ts @@ -27,7 +27,7 @@ export function updateMatrix(params:{name: string, id: number}){ } export function del(ids:string){ - return httpRequest({ + return httpRequest>({ url: `/api/matrix/${ids}`, method: "DELETE", }); diff --git a/src/services/matrix/type.ts b/src/services/matrix/type.ts index 3880371..b252c5d 100644 --- a/src/services/matrix/type.ts +++ b/src/services/matrix/type.ts @@ -1,4 +1,5 @@ import type { WorkType } from "../globalCmd/cmdTypes"; +import History from '@/views/History.vue'; export type ResponseParams = { pageNum: number; @@ -13,7 +14,7 @@ export const defaultParams = { export type MatrixItem = { id: number; name: string; - isSelected?: boolean; + matrixName:string; }; export type MatrixItemList = { @@ -24,5 +25,12 @@ export type MatrixItemList = { export type CraftItem = { id: number; name: string; - matrixId: number; + matrixId: number | null; } & WorkType; + +export type HistoryItem = { + id: number; + matrixId: number; + matrixInfo:string; + status: 1 | 2; +} diff --git a/src/stores/setting.ts b/src/stores/setting.ts index 69938e5..80cbfaa 100644 --- a/src/stores/setting.ts +++ b/src/stores/setting.ts @@ -1,16 +1,24 @@ import { defineStore } from "pinia"; import { ref } from "vue"; import * as R from "ramda"; -import type { MatrixItem } from "@/services/matrix/type"; +import type { CraftItem, MatrixItem } from "@/services/matrix/type"; export const useSettingStore = defineStore("setting", () => { + //基质列表 const matrixList = ref([]); const setMatrixList = (data: MatrixItem[]) => { matrixList.value = data; }; + //工艺列表 + const matrixCraftList = ref([]); + const setMatrixCraftList = (data: CraftItem[]) => { + matrixCraftList.value = data; + }; return { matrixList, setMatrixList, + matrixCraftList, + setMatrixCraftList }; }); diff --git a/src/views/History.vue b/src/views/History.vue index 6783053..571cd9e 100644 --- a/src/views/History.vue +++ b/src/views/History.vue @@ -33,14 +33,14 @@ import { ref, onMounted } from 'vue' import { getHistoryList, delHistoryLog} from '@/services/matrix/craft' import { useSettingStore } from '@/stores/setting' - import type { CraftItem } from "@/services/matrix/type"; + import type { CraftItem, HistoryItem } from "@/services/matrix/type"; import { ElMessage, ElMessageBox } from "element-plus"; import route_v from "@/assets/route_vertical.png"; import route_h from "@/assets/route_horizontal.png"; let total = ref() const loading = ref(false) const settingStore = useSettingStore() - let tableData = ref([]) + let tableData = ref([]) const defaultCraft: CraftItem = { id: 1, name: '', @@ -58,7 +58,6 @@ }; onMounted(()=>{ - tableData.value = settingStore.matrixList getLogList() }) @@ -69,16 +68,15 @@ pageSize:10, } loading.value = true; - getHistoryList(params).then((res:any)=>{ - - let list = [] - res.data.list.forEach((item:any)=>{ + getHistoryList(params).then((res)=>{ + let list = [] + res.data.list.forEach((item)=>{ let { matrixInfo } = item if(matrixInfo){ - matrixInfo = JSON.parse(matrixInfo) + let matrixData = JSON.parse(matrixInfo) item ={ ...item, - ...matrixInfo, + ...matrixData, } } list.push(item) @@ -92,12 +90,12 @@ const historyTableRef = ref() const onDel = () => { - const selectRows = historyTableRef.value.getSelectionRows() + const selectRows = historyTableRef.value.getSelectionRows() as HistoryItem[] if(!selectRows.length){ ElMessage.error('请选择要删除的数据') return; } - const ids = selectRows.map((item:any) => item.id) + const ids = selectRows.map((item) => item.id) ElMessageBox.confirm('确认删除此条数据吗?','提示',{ confirmButtonText: '确认', cancelButtonText: '取消', diff --git a/src/views/debug/index.vue b/src/views/debug/index.vue index c6e24fc..becef3a 100644 --- a/src/views/debug/index.vue +++ b/src/views/debug/index.vue @@ -338,6 +338,7 @@ import type { SyringeParams, VoltageType, ControlValueType, + Axis, } from "@/services/globalCmd/cmdTypes"; import { moveMotorToPosition, @@ -349,7 +350,6 @@ import { turnOffSyringePump, startWork, stopWork, - rotate, stopMotor, turnOffLightPanel, turnOnLightPanel, @@ -359,6 +359,8 @@ import { type WashType, startWash } from "@/services/globalCmd/globalCmd"; +import type { BaseResponse } from "@/services/httpRequest"; +import type { WorkType } from '../../services/globalCmd/cmdTypes'; const activeName = ref("debug"); const voltageValue = ref(); const syringeForm = ref({ @@ -366,15 +368,27 @@ const syringeForm = ref({ time: 0, direction: "1", }); -const workForm = ref>({ +const workForm = ref({ routeType: 1, + space: 2, + nitrogenFlowVelocity: 1, + nitrogenAirPressure: 1, + matrixFlowVelocity: 1, + voltage: 1, + needPower: false, + height: 6, + movementSpeed: 10, + position: [], }); -const axis = ref({ +const axis = ref({ index: 0, + x1: 10, + y1: 10, + x2: 20, + y2: 20, }); const rotateForm = ref<{ axis: "X" | "Y" | "Z"; speed: number }>({ axis: "X", speed: 20 }); -let subscription: any; watch(voltageValue,(newVal)=>{ if(newVal > 5000){ @@ -389,41 +403,35 @@ watch(voltageValue,(newVal)=>{ onMounted(() => { //连接websocket const wsClient = createWebSocket(sharedWsUrl); - subscription = wsClient.dataOb.subscribe(data => { - //@ts-ignore - if (data.type == "moveMotorToPosition") { - //@ts-ignore - ElMessage.success(data.data.text); - } + const subscription = wsClient.dataOb.subscribe(data => { }); wsClient.connect(); -}); -onUnmounted(() => { - subscription && subscription.unsubscribe(); + onUnmounted(() => { + subscription && subscription.unsubscribe(); + }); }); + + const machineryForm = ref>({}); const onMoveMachinery = (axis: string) => { if (!axis) return; - const params = { - commandName: "moveMotorToPosition", - params: { + const params = { axis, position: parseFloat(machineryForm.value[axis]), - }, }; - moveMotorToPosition(params).then((res: any) => { + moveMotorToPosition(params).then((res) => { console.log("-----moveMotorToPosition----res---", res); success(res); }); }; const onSwitchThreeWayValve = (type: string) => { - const params = { - params: { type }, + const params = { + type, }; - switchThreeWayValve(params).then((res: any) => { + switchThreeWayValve(params).then((res) => { console.log("---onSwitchThreeWayValve---res---", res); success(res); }); @@ -436,14 +444,14 @@ const onControlValve = (type: ControlNitrogen, open: boolean) => { isOpen: open, }, }; - controlValve(params).then((res: any) => { + controlValve(params).then((res) => { console.log("---onControlValve---res---", res); success(res); }); }; const onStopDehumidify = () => { - stopDehumidify().then((res: any) => { + stopDehumidify().then((res) => { success(res); }); }; @@ -459,7 +467,7 @@ function onStartWash(type: WashType) { } const onStopWash = () => { - stopWash({}).then((res: any) => { + stopWash({}).then((res) => { success(res); }); }; @@ -469,7 +477,7 @@ const onTurnOnHighVoltage = () => { const params = { params: { voltage: +voltageValue.value }, }; - turnOnHighVoltage(params).then((res: any) => { + turnOnHighVoltage(params).then((res) => { console.log("---onTurnOnHighVoltage- 电压控制 on --res---", res); success(res); }); @@ -477,7 +485,7 @@ const onTurnOnHighVoltage = () => { //电压控制 关闭 const onTurnOffHighVoltage = () => { - turnOffHighVoltage().then((res: any) => { + turnOffHighVoltage().then((res) => { console.log("---onTurnOffHighVoltage- 电压控制 off--res---", res); success(res); }); @@ -493,35 +501,31 @@ const onTurnOnSyringePump = () => { // time: syringeForm.value.time, }, }; - turnOnSyringePump(params).then((res: any) => { + turnOnSyringePump(params).then((res) => { console.log("---onTurnOffHighVoltage- 电泵开启--res---", res); success(res); }); }; const onTurnOffSyringePump = () => { - turnOffSyringePump().then((res: any) => { + turnOffSyringePump().then((res) => { success(res); }); }; const onStartWork = () => { - const params = { - params: { + const params = { ...workForm.value, - position: [axis.value], - }, + position: [axis.value], }; - startWork(params).then((res: any) => { - console.log("startWork-----", startWork); + startWork(params).then((res) => { success(res); }); }; function onStopWork() { - stopWork().then((res: any) => { - console.log("startWork-----", startWork); + stopWork().then((res) => { success(res); }); } @@ -531,51 +535,35 @@ const onRotate = () => { ...rotateForm.value, }; - setMotorSpeed(params).then((res: any) => { + setMotorSpeed(params).then((res) => { success(res); }); }; const onStopRotate = (axis: string) => { - const params = { - params: { - axis, - }, - }; - stopMotor(params).then((res: any) => { - console.log("res--停止电机-"); + stopMotor({axis}).then((res) => { success(res); }); }; -type resData = { - code: number; - msg: string; -}; let brightness = ref() const onTurnOnLightPanel = () => { - const params = { - params: { - brightness: brightness.value - }, - }; - turnOnLightPanel(params).then((res: any) => { + turnOnLightPanel({brightness: brightness.value}).then(res => { success(res); }); }; function onTurnOffLightPanel() { const params = { - params: { - brightness: 40, - }, + brightness: 40, }; - turnOffLightPanel(params).then((res: any) => { + turnOffLightPanel(params).then((res) => { success(res); }); } -function success(data: resData) { + +function success(data:BaseResponse) { if (data && data.msg == "ok") { ElMessage.success("发送成功"); } else { diff --git a/src/views/matrixCraft/index.vue b/src/views/matrixCraft/index.vue index 9fac6dc..e1730e2 100644 --- a/src/views/matrixCraft/index.vue +++ b/src/views/matrixCraft/index.vue @@ -51,6 +51,7 @@ @@ -93,12 +94,14 @@ import { ElMessage, ElMessageBox } from "element-plus"; import route_h from "@/assets/route_horizontal.png"; import route_v from "@/assets/route_vertical.png"; - let total = ref() + import type { MatrixItem } from '../matrixManage/type'; + let total = ref(0) const settingStore = useSettingStore() let sprayVisible = ref(false) - let tableData = ref([]) + let tableData = ref([]) let operType = ref('add') let loading = ref(false) + const searchForm = ref({ matrixCraftName:undefined, matrixId:undefined, @@ -126,11 +129,9 @@ }else{ onMatrixChange(null) } - console.log('defaultSprayData---', defaultSprayData) }) onMounted(()=>{ let matrixList = settingStore.matrixList - tableData.value = matrixList; if(matrixList && matrixList.length){ onMatrixChange(matrixList[0].id) }else{ @@ -149,8 +150,10 @@ } loading.value = true; - getList(params).then((res:any)=>{ - tableData.value = res.data.list + getList(params).then((res)=>{ + let list = res.data.list + settingStore.setMatrixCraftList(list) + tableData.value = list total.value = res.data.total }).finally(()=>{ loading.value = false; @@ -176,12 +179,12 @@ } const onDel = () => { - const selectRows = craftTableRef.value.getSelectionRows() + const selectRows = craftTableRef.value.getSelectionRows() as CraftItem[] if(!selectRows.length){ ElMessage.error('请选择要删除的数据') return; } - const ids = selectRows.map((item:any) => item.id) + const ids = selectRows.map(item => item.id) ElMessageBox.confirm('确认删除此条数据吗?','提示',{ confirmButtonText: '确认', cancelButtonText: '取消', @@ -252,7 +255,7 @@ } - function onMatrixChange(val: any) { + function onMatrixChange(val:number|null) { defaultSprayData.value.matrixId = val } diff --git a/src/views/matrixManage/add.vue b/src/views/matrixManage/add.vue index e6246a3..6bd6fc4 100644 --- a/src/views/matrixManage/add.vue +++ b/src/views/matrixManage/add.vue @@ -24,7 +24,7 @@ }) const addVisible = ref(false) let addForm = ref({name:''}) - const addFormRef:any = ref() + const addFormRef = ref() let operateType = 'add' const showDialog = (type:string, craftItem:{name:string}) => { diff --git a/src/views/matrixManage/matrixList.vue b/src/views/matrixManage/matrixList.vue index fcab8ad..89418ee 100644 --- a/src/views/matrixManage/matrixList.vue +++ b/src/views/matrixManage/matrixList.vue @@ -32,18 +32,18 @@
{{ pageNameMap[route.path] }}