|
@ -7,7 +7,7 @@ |
|
|
<section class="flex items-center gap-3 px-4 text-base ml-auto"> |
|
|
<section class="flex items-center gap-3 px-4 text-base ml-auto"> |
|
|
<div class="flex items-center"> |
|
|
<div class="flex items-center"> |
|
|
<span class="self-center text-right text-primary font-medium mr-3">选择基质</span> |
|
|
<span class="self-center text-right text-primary font-medium mr-3">选择基质</span> |
|
|
<el-select v-model="selectMatrix" placeholder="Select" style="width: 120px" @change="onMatrixChange"> |
|
|
|
|
|
|
|
|
<el-select v-model="selectMatrixId" placeholder="Select" style="width: 120px" @change="onMatrixChange"> |
|
|
<el-option |
|
|
<el-option |
|
|
v-for="item in settingStore.matrixList" |
|
|
v-for="item in settingStore.matrixList" |
|
|
:key="item.id" |
|
|
:key="item.id" |
|
@ -19,7 +19,7 @@ |
|
|
<span class="self-center text-right text-primary font-medium mr-3">工艺</span> |
|
|
<span class="self-center text-right text-primary font-medium mr-3">工艺</span> |
|
|
<el-select |
|
|
<el-select |
|
|
:disabled="craftList.length === 0" |
|
|
:disabled="craftList.length === 0" |
|
|
v-model="selectCraft" |
|
|
|
|
|
|
|
|
v-model="selectCraftId" |
|
|
placeholder="Select" |
|
|
placeholder="Select" |
|
|
style="width: 120px" |
|
|
style="width: 120px" |
|
|
@change="onCraftChange"> |
|
|
@change="onCraftChange"> |
|
@ -52,7 +52,7 @@ |
|
|
:columns="1" |
|
|
:columns="1" |
|
|
:rows="3" |
|
|
:rows="3" |
|
|
:cell-num="25" |
|
|
:cell-num="25" |
|
|
@select-area="onSelectArea" /> |
|
|
|
|
|
|
|
|
@select-area="area => onSelectArea(area, 0)" /> |
|
|
<Spray |
|
|
<Spray |
|
|
:width="210" |
|
|
:width="210" |
|
|
:height="610" |
|
|
:height="610" |
|
@ -63,7 +63,7 @@ |
|
|
:columns="1" |
|
|
:columns="1" |
|
|
:rows="3" |
|
|
:rows="3" |
|
|
:cell-num="25" |
|
|
:cell-num="25" |
|
|
@select-area="onSelectArea" /> |
|
|
|
|
|
|
|
|
@select-area="area => onSelectArea(area, 1)" /> |
|
|
<Spray |
|
|
<Spray |
|
|
:width="210" |
|
|
:width="210" |
|
|
:height="610" |
|
|
:height="610" |
|
@ -74,7 +74,7 @@ |
|
|
:columns="1" |
|
|
:columns="1" |
|
|
:rows="3" |
|
|
:rows="3" |
|
|
:cell-num="25" |
|
|
:cell-num="25" |
|
|
@select-area="onSelectArea" /> |
|
|
|
|
|
|
|
|
@select-area="area => onSelectArea(area, 2)" /> |
|
|
<Spray |
|
|
<Spray |
|
|
:width="210" |
|
|
:width="210" |
|
|
:height="610" |
|
|
:height="610" |
|
@ -85,7 +85,7 @@ |
|
|
:columns="1" |
|
|
:columns="1" |
|
|
:rows="3" |
|
|
:rows="3" |
|
|
:cell-num="25" |
|
|
:cell-num="25" |
|
|
@select-area="onSelectArea" /> |
|
|
|
|
|
|
|
|
@select-area="area => onSelectArea(area, 3)" /> |
|
|
</section> |
|
|
</section> |
|
|
|
|
|
|
|
|
<van-checkbox-group |
|
|
<van-checkbox-group |
|
@ -95,14 +95,13 @@ |
|
|
icon-size="28px" |
|
|
icon-size="28px" |
|
|
direction="horizontal" |
|
|
direction="horizontal" |
|
|
class="flex justify-around mt-3 w-[848px]"> |
|
|
class="flex justify-around mt-3 w-[848px]"> |
|
|
<van-checkbox name="a"></van-checkbox> |
|
|
|
|
|
<van-checkbox name="b"></van-checkbox> |
|
|
|
|
|
<van-checkbox name="c"></van-checkbox> |
|
|
|
|
|
<van-checkbox name="d"></van-checkbox> |
|
|
|
|
|
|
|
|
<van-checkbox name="0"></van-checkbox> |
|
|
|
|
|
<van-checkbox name="1"></van-checkbox> |
|
|
|
|
|
<van-checkbox name="2"></van-checkbox> |
|
|
|
|
|
<van-checkbox name="3"></van-checkbox> |
|
|
</van-checkbox-group> |
|
|
</van-checkbox-group> |
|
|
</section> |
|
|
</section> |
|
|
</div> |
|
|
</div> |
|
|
<!-- <SprayParam :sprayParam="selectCraft" @save="updateSprayParam" /> --> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
@ -110,12 +109,11 @@ |
|
|
import Spray, { type GridArea } from "@/components/Spray.vue"; |
|
|
import Spray, { type GridArea } from "@/components/Spray.vue"; |
|
|
import { onMounted, ref } from "vue"; |
|
|
import { onMounted, ref } from "vue"; |
|
|
import { startSpray, stopWork } from "@/services/globalCmd/globalCmd"; |
|
|
import { startSpray, stopWork } from "@/services/globalCmd/globalCmd"; |
|
|
import type { WorkType } from "@/services/globalCmd/cmdTypes"; |
|
|
|
|
|
|
|
|
import { checkSprayParamValid, type PositionType, type WorkType } from "@/services/globalCmd/cmdTypes"; |
|
|
import { ElMessage } from "element-plus"; |
|
|
import { ElMessage } from "element-plus"; |
|
|
import type { MatrixItem } from "./matrixManage/type"; |
|
|
|
|
|
import { useSettingStore } from "@/stores/setting"; |
|
|
import { useSettingStore } from "@/stores/setting"; |
|
|
import type { CraftItem } from "@/services/matrix/type"; |
|
|
import type { CraftItem } from "@/services/matrix/type"; |
|
|
import { getListByMatrixId } from "@/services/matrix/craft"; |
|
|
|
|
|
|
|
|
import { createCraft, getListByMatrixId, updateCraft } from "@/services/matrix/craft"; |
|
|
import SprayParam from "@/components/SprayParam.vue"; |
|
|
import SprayParam from "@/components/SprayParam.vue"; |
|
|
|
|
|
|
|
|
const defaultCraft: Partial<CraftItem> = { |
|
|
const defaultCraft: Partial<CraftItem> = { |
|
@ -136,15 +134,21 @@ const defaultCraft: Partial<CraftItem> = { |
|
|
|
|
|
|
|
|
const settingStore = useSettingStore(); |
|
|
const settingStore = useSettingStore(); |
|
|
|
|
|
|
|
|
const selectMatrix = ref<MatrixItem>( |
|
|
|
|
|
settingStore.matrixList.length > 0 ? settingStore.matrixList[0] : ({ id: 0, name: "未知" } as MatrixItem) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
const selectMatrixId = ref<number>(settingStore.matrixList.length > 0 ? settingStore.matrixList[0].id : 0); |
|
|
|
|
|
|
|
|
const craftList = ref<CraftItem[]>([]); |
|
|
const craftList = ref<CraftItem[]>([]); |
|
|
|
|
|
|
|
|
|
|
|
const selectCraftId = ref<number>(1); |
|
|
const selectCraft = ref<Partial<CraftItem>>(defaultCraft); |
|
|
const selectCraft = ref<Partial<CraftItem>>(defaultCraft); |
|
|
|
|
|
|
|
|
const selectedArea = ref<GridArea>(); |
|
|
|
|
|
const checked = ref(["a", "b"]); |
|
|
|
|
|
|
|
|
const selectedArea = ref<GridArea[]>([ |
|
|
|
|
|
{ xStart: 8, yStart: 8, xEnd: 16, yEnd: 16 }, |
|
|
|
|
|
{ xStart: 8, yStart: 8, xEnd: 16, yEnd: 16 }, |
|
|
|
|
|
{ xStart: 8, yStart: 8, xEnd: 16, yEnd: 16 }, |
|
|
|
|
|
{ xStart: 8, yStart: 8, xEnd: 16, yEnd: 16 }, |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
const checked = ref(["0"]); |
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
if (settingStore.matrixList.length > 0) { |
|
|
if (settingStore.matrixList.length > 0) { |
|
@ -152,17 +156,20 @@ onMounted(() => { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function onSelectArea(area: GridArea) { |
|
|
|
|
|
selectedArea.value = area; |
|
|
|
|
|
|
|
|
function onSelectArea(area: GridArea, index: number) { |
|
|
|
|
|
selectedArea.value[index] = area; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function onMatrixChange(val: number) { |
|
|
function onMatrixChange(val: number) { |
|
|
|
|
|
selectMatrixId.value = val; |
|
|
getListByMatrixId({ matrixId: val }).then(res => { |
|
|
getListByMatrixId({ matrixId: val }).then(res => { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
craftList.value = res.data || []; |
|
|
craftList.value = res.data || []; |
|
|
if (res.data.length > 0) { |
|
|
if (res.data.length > 0) { |
|
|
|
|
|
selectCraftId.value = res.data[0].id; |
|
|
selectCraft.value = { ...res.data[0], needPower: res.data[0].voltage > 0 }; |
|
|
selectCraft.value = { ...res.data[0], needPower: res.data[0].voltage > 0 }; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
selectCraftId.value = 0; |
|
|
selectCraft.value = defaultCraft; |
|
|
selectCraft.value = defaultCraft; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@ -173,25 +180,40 @@ function onMatrixChange(val: number) { |
|
|
|
|
|
|
|
|
function onCraftChange(val: number) { |
|
|
function onCraftChange(val: number) { |
|
|
const craft = craftList.value.find(item => item.id === val); |
|
|
const craft = craftList.value.find(item => item.id === val); |
|
|
selectCraft.value = craft || defaultCraft; |
|
|
|
|
|
|
|
|
selectCraft.value = { ...craft, needPower: craft!.voltage > 0 }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function mapAreaToPosition() { |
|
|
|
|
|
return checked.value.map(index => { |
|
|
|
|
|
const idx = +index; |
|
|
|
|
|
const pos: PositionType = { |
|
|
|
|
|
x1: selectedArea.value[idx].xStart, |
|
|
|
|
|
y1: selectedArea.value[idx].yStart, |
|
|
|
|
|
x2: selectedArea.value[idx].xEnd, |
|
|
|
|
|
y2: selectedArea.value[idx].yEnd, |
|
|
|
|
|
index: idx, |
|
|
|
|
|
}; |
|
|
|
|
|
return pos; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
function onStartSpray() { |
|
|
function onStartSpray() { |
|
|
selectCraft.value.position = [ |
|
|
|
|
|
{ |
|
|
|
|
|
x1: selectedArea.value?.xStart || 10, |
|
|
|
|
|
y1: selectedArea.value?.yStart || 10, |
|
|
|
|
|
x2: selectedArea.value?.xEnd || 20, |
|
|
|
|
|
y2: selectedArea.value?.yEnd || 20, |
|
|
|
|
|
index: 0, |
|
|
|
|
|
}, |
|
|
|
|
|
]; |
|
|
|
|
|
const params = selectCraft.value.needPower ? selectCraft : { ...selectCraft, voltage: 0 }; |
|
|
|
|
|
|
|
|
if (checked.value.length === 0) { |
|
|
|
|
|
ElMessage.error("请至少选择一个玻片"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
selectCraft.value.position = mapAreaToPosition(); |
|
|
|
|
|
const params = selectCraft.value.needPower ? selectCraft.value : { ...selectCraft.value, voltage: 0 }; |
|
|
console.log(params); |
|
|
console.log(params); |
|
|
//TODO 检查参数合法性 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const check = checkSprayParamValid(params); |
|
|
|
|
|
if (!check[0]) { |
|
|
|
|
|
ElMessage.error(check[1]); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
startSpray({ |
|
|
startSpray({ |
|
|
...(selectCraft.value as CraftItem), |
|
|
|
|
|
matrixId: selectMatrix.value.id, |
|
|
|
|
|
|
|
|
...(params as CraftItem), |
|
|
|
|
|
matrixId: selectMatrixId.value, |
|
|
matrixCraftId: selectCraft.value.id || 0, |
|
|
matrixCraftId: selectCraft.value.id || 0, |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
@ -212,7 +234,27 @@ function onStopSpray() { |
|
|
|
|
|
|
|
|
function updateSprayParam(p: WorkType) { |
|
|
function updateSprayParam(p: WorkType) { |
|
|
console.log(p); |
|
|
console.log(p); |
|
|
selectCraft.value = p as CraftItem; |
|
|
|
|
|
|
|
|
const params = !!p.needPower ? p : { ...p, voltage: 0 }; |
|
|
|
|
|
if ((params as CraftItem).id === 0) { |
|
|
|
|
|
// 创建 |
|
|
|
|
|
const p = { ...(params as CraftItem), matrixId: selectMatrixId.value }; |
|
|
|
|
|
createCraft(p).then(res => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
onMatrixChange(selectMatrixId.value); |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage.error(res.msg); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 更新 |
|
|
|
|
|
updateCraft(params as CraftItem).then(res => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
selectCraft.value = params as CraftItem; |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage.error(res.msg); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|