diff --git a/src/views/coalFeeding.vue b/src/views/coalFeeding.vue index f672444..135a5d2 100644 --- a/src/views/coalFeeding.vue +++ b/src/views/coalFeeding.vue @@ -92,7 +92,7 @@ > {{ row.label }} -
+
回车侧
@@ -108,9 +108,9 @@ {{ item.team }} -
+ @drop="onDjDrop($event, item, getUnitDropId('up', index), index)">
@@ -175,6 +175,11 @@
{{ dj.eqm }} {{ dj.eqm }} +
@@ -206,10 +211,10 @@ {{ item.tempera1 }} °C
-
+ @drop="onDjDrop($event, item, getUnitDropId('down', index), index)">
@@ -272,6 +278,11 @@
{{ dj.eqm }} {{ dj.eqm }} +
@@ -1441,9 +1452,21 @@ const clearError = () => { const getCellId = (prefix: string | undefined, index: number) => { return prefix ? `${prefix}${index}` : undefined; }; +const getUnitDropId = (section: "up" | "down", index: number) => { + return `unit_${section}_${index}`; +}; +const getMotorSlotId = (section: "up" | "down", index: number, slot: number) => { + return getMotorBindingKey(section, index, slot); +}; const getTempDropId = (side: "tempera1" | "tempera2", item: CoalUnit, index: number) => { return `${side}_unit${item.unit}_${index + 1}`; }; +const getUnitBindingKey = (section: "up" | "down", index: number) => { + return `binding_unit_${section}_${index}`; +}; +const getMotorBindingKey = (section: "up" | "down", index: number, slot: number) => { + return `binding_motor_${section}_${index}_${slot}`; +}; const isTimeRow = (row: BlockRowConfig) => row.kind === "time"; const getCellValue = (item: CoalUnit, row: BlockRowConfig) => { if (row.kind === "time" && row.section) { @@ -1479,8 +1502,6 @@ const updateCellValue = (item: CoalUnit, row: BlockRowConfig, event: Event) => { const onPointDragStart = (event: DragEvent, point: PointItem) => { if (event.dataTransfer) { event.dataTransfer.setData('text/plain', JSON.stringify(point)); - console.log('start000000000'); - console.log('event.dataTransfer.getData("text/plain"):', JSON.parse(event.dataTransfer.getData("text/plain"))); } }; const onDjDragOver = (event: DragEvent) => { @@ -1492,22 +1513,67 @@ const onDjDragOver = (event: DragEvent) => { }; const pendingPointUpdates = ref>([]); -const onDjDrop = (event: DragEvent, dropItem: any, temp: string,index?:number) => { +const getRolePointId = (unit: any, equipmentIndex: number, rolePointIndex: number) => { + return unit?.equipments?.[equipmentIndex]?.role_points?.[rolePointIndex]?.point_id; +}; + +const assignUnitTiming = (targetItem: CoalUnit, section: SectionKey, unit: any) => { + targetItem[section].run_time_sec = unit?.run_time_sec ?? ""; + targetItem[section].stop_time_sec = unit?.stop_time_sec ?? ""; + targetItem[section].acc_time_sec = unit?.acc_time_sec ?? ""; + targetItem[section].bl_time_sec = unit?.bl_time_sec ?? ""; +}; + +const onDjDrop = (event: DragEvent, dropItem: any, DomId: string,index:number) => { event.preventDefault(); if (!event.dataTransfer) return; - const rawJson = event.dataTransfer.getData("text/plain"); - if (!rawJson) return; - const raw = JSON.parse(rawJson); - const key = temp; - console.log('raw:', raw); - console.log('key:', key); + const unitJson = event.dataTransfer.getData("text/plain"); + if (!unitJson) return; + const unit = JSON.parse(unitJson); + console.log('unit:', unit); + console.log('DomId:', DomId); console.log('index:', index); console.log('dropItem:', dropItem); - const existing = pendingPointUpdates.value.find((item) => item.key === key); - if (existing) { - existing.value = String(raw.id); - } else { - pendingPointUpdates.value.push({ key, value: String(raw.id) }); + const targetItem = dataList[index]; + //1、unit与targetItem的元素Id绑定 + if (unit?.id) { + pendingPointUpdates.value.push({key: DomId, value: String(unit.id)}); + } + //测点Id与电机DomId绑定 + const djMotor1 = getRolePointId(unit, 0, 0); + const djMotor2 = getRolePointId(unit, 0, 1); + const djMotor3 = getRolePointId(unit, 1, 0); + const djMotor4 = getRolePointId(unit, 1, 1); + console.log('djMotor1:', djMotor1); + console.log('djMotor2:', djMotor2); + console.log('djMotor3:', djMotor1); + console.log('djMotor4:', djMotor1); + let djDomId1 = '', djDomId2 = '', djDomId3 = '', djDomId4 = ''; + if (DomId.includes("unit_up_")) { + assignUnitTiming(targetItem, "team_top", unit); + djDomId1 = 'unit'+index+'_up_0'; + djDomId2 = 'unit'+index+'_up_1'; + djDomId3 = 'unit'+index+'_up_2'; + djDomId4 = 'unit'+index+'_up_3'; + } + if (DomId.includes("unit_down_")) { + assignUnitTiming(targetItem, "team_bottom", unit); + djDomId1 = 'unit'+index+'_down_0'; + djDomId2 = 'unit'+index+'_down_1'; + djDomId3 = 'unit'+index+'_down_2'; + djDomId4 = 'unit'+index+'_down_3'; + } + if (djMotor1) { + pendingPointUpdates.value.push({key: djDomId1, value: String(djMotor1)}); + } + if (djMotor2) { + pendingPointUpdates.value.push({key: djDomId2, value: String(djMotor2)}); + } + if (djMotor3) { + pendingPointUpdates.value.push({key: djDomId3, value: String(djMotor3)}); + } + if (djMotor4) { + pendingPointUpdates.value.push({key: djDomId4, value: String(djMotor4)}); } }; @@ -1560,6 +1626,7 @@ const toggleDjStop = ( }; const commitPointUpdates = () => { if (!pendingPointUpdates.value.length) return; + console.log('pendingPointUpdates',pendingPointUpdates.value); const data: Record = {}; pendingPointUpdates.value.forEach((item) => { data[item.key] = item.value; @@ -1593,9 +1660,11 @@ const initWebSocket = () => { if (entries.length) { entries.forEach(([elementId]) => { const el = document.getElementById(elementId); - const span = el?.querySelector("span"); - if (span) { - span.textContent = data.data.value_text ?? ""; + const valueTarget = + el?.querySelector("[data-monitor-value]") || + el?.querySelector("span"); + if (valueTarget) { + valueTarget.textContent = data.data.value_text ?? ""; } }); // entries.forEach(([elementId]) => {