增加数据位置调整功能

This commit is contained in:
joylink_zhaoerwei 2024-06-25 19:02:34 +08:00
parent 35eab5ac87
commit 0e7de4afa8
4 changed files with 180 additions and 11 deletions

View File

@ -32,6 +32,12 @@
</div>
</div>
<template v-slot:titleButton>
<q-btn
color="primary"
label="清空"
style="margin-right: 10px"
@click="clearCiQdListData"
/>
<q-btn
color="primary"
label="设置"
@ -85,6 +91,7 @@ import {
loadCiQdList,
creatCiQdList,
refRelaysListMap,
clearCiQdList,
} from 'src/drawApp/relayCabinetLayoutApp';
import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
import { Relay } from 'src/graphics/relay/Relay';
@ -171,6 +178,14 @@ function updateMap() {
});
}
function clearCiQdListData() {
clearCiQdList(setCellMessage.value.rows, setCellMessage.value.cols);
ciQdList = loadCiQdList();
updateMap();
setCellDialog.value = true;
setCellDialog.value = false;
}
const showTooltip = ref(false);
function onMouseOver(e: MouseEvent) {
if ((e.target as HTMLElement).clientHeight > 30) {

View File

@ -60,6 +60,11 @@
<q-btn label="提交" type="submit" color="primary" class="q-mr-md" />
<q-btn label="返回" color="primary" @click="goBack" />
</div>
<q-separator inset></q-separator>
<div class="q-gutter-sm q-pa-md row justify-center">
<q-btn label="添加位置" color="red" @click="addPosition" />
<q-btn label="删除位置" color="red" @click="deletePosition" />
</div>
</q-form>
</q-card>
</div>
@ -74,7 +79,11 @@ import {
useRelayCabinetStore,
} from 'src/stores/relayCabinet-store';
import { Relay } from 'src/graphics/relay/Relay';
import { loadCiCjList } from 'src/drawApp/relayCabinetLayoutApp';
import {
deleteCjDataPositionByIndex,
addCjDataPositionByIndex,
loadCiCjList,
} from 'src/drawApp/relayCabinetLayoutApp';
import { PhaseFailureProtector } from 'src/graphics/phaseFailureProtector/PhaseFailureProtector';
import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
@ -239,6 +248,18 @@ function goBack() {
relayCabinetStore.showCiCjConfig = false;
}
function addPosition() {
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
addCjDataPositionByIndex(click.row - 1, click.col - 1);
relayCabinetStore.updateCiCjList = true;
}
function deletePosition() {
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
deleteCjDataPositionByIndex(click.row - 1, click.col - 1);
relayCabinetStore.updateCiCjList = true;
}
onUnmounted(() => {
relayCabinetStore.showCiCjConfig = false;
});

View File

@ -51,6 +51,11 @@
<q-btn label="提交" type="submit" color="primary" class="q-mr-md" />
<q-btn label="返回" color="primary" @click="goBack" />
</div>
<q-separator inset></q-separator>
<div class="q-gutter-sm q-pa-md row justify-center">
<q-btn label="添加位置" color="red" @click="addPosition" />
<q-btn label="删除位置" color="red" @click="deletePosition" />
</div>
</q-form>
</q-card>
</div>
@ -65,7 +70,11 @@ import {
useRelayCabinetStore,
} from 'src/stores/relayCabinet-store';
import { Relay } from 'src/graphics/relay/Relay';
import { loadCiQdList } from 'src/drawApp/relayCabinetLayoutApp';
import {
addQdDataPositionByIndex,
deleteQdDataPositionByIndex,
loadCiQdList,
} from 'src/drawApp/relayCabinetLayoutApp';
import { PhaseFailureProtector } from 'src/graphics/phaseFailureProtector/PhaseFailureProtector';
const relayCabinetStore = useRelayCabinetStore();
@ -198,6 +207,18 @@ function goBack() {
relayCabinetStore.showCiCjConfig = false;
}
function addPosition() {
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
addQdDataPositionByIndex(click.row - 1, click.col - 1);
relayCabinetStore.updateCiCjList = true;
}
function deletePosition() {
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
deleteQdDataPositionByIndex(click.row - 1, click.col - 1);
relayCabinetStore.updateCiCjList = true;
}
onUnmounted(() => {
relayCabinetStore.showCiCjConfig = false;
});

View File

@ -452,6 +452,51 @@ export function clearCiCjList(rows: number, cols: number) {
}
}
export function deleteCjDataPositionByIndex(row: number, col: number) {
const allCjData: relayCabinetGraphicData.CjData[] = [];
ciCjList.cjList.forEach((cj, i) => {
cj.bitList.forEach((bit, j) => {
if (i !== col || j !== row) {
allCjData.push(bit);
}
});
});
allCjData.push(new relayCabinetGraphicData.CjData());
const allCjData2D = convertTo2DArray(
allCjData,
ciCjList.cjList.length,
ciCjList.dsCount
) as relayCabinetGraphicData.CjData[][];
ciCjList.cjList.forEach((cj, i) => {
cj.bitList.forEach((bit, j) => {
cj.bitList[j] = allCjData2D[i][j];
});
});
}
export function addCjDataPositionByIndex(row: number, col: number) {
const allCjData: relayCabinetGraphicData.CjData[] = [];
ciCjList.cjList.forEach((cj, i) => {
cj.bitList.forEach((bit, j) => {
allCjData.push(bit);
if (i == col && j == row) {
allCjData.push(new relayCabinetGraphicData.CjData());
}
});
});
allCjData.pop();
const allCjData2D = convertTo2DArray(
allCjData,
ciCjList.cjList.length,
ciCjList.dsCount
) as relayCabinetGraphicData.CjData[][];
ciCjList.cjList.forEach((cj, i) => {
cj.bitList.forEach((bit, j) => {
cj.bitList[j] = allCjData2D[i][j];
});
});
}
//驱动列表的增删改查
let ciQdList: relayCabinetGraphicData.CiQd;
export function loadCiQdList() {
@ -460,15 +505,7 @@ export function loadCiQdList() {
export function creatCiQdList(rows: number, cols: number) {
if (ciQdList == undefined) {
ciQdList = new relayCabinetGraphicData.CiQd();
ciQdList.dsCount = rows;
for (let i = 0; i < cols; i++) {
ciQdList.qdList[i] = new relayCabinetGraphicData.QdDataSet();
ciQdList.qdList[i].name = 'D' + (i + 1);
for (let j = 0; j < rows; j++) {
ciQdList.qdList[i].bitList[j] = new relayCabinetGraphicData.QdData();
}
}
clearCiQdList(rows, cols);
} else {
const oldRows = ciQdList.dsCount;
ciQdList.dsCount = rows;
@ -519,3 +556,78 @@ export function creatCiQdListByCombinationtype(
}
}
}
export function clearCiQdList(rows: number, cols: number) {
ciQdList = new relayCabinetGraphicData.CiQd();
ciQdList.dsCount = rows;
for (let i = 0; i < cols; i++) {
ciQdList.qdList[i] = new relayCabinetGraphicData.QdDataSet();
ciQdList.qdList[i].name = 'D' + (i + 1);
for (let j = 0; j < rows; j++) {
ciQdList.qdList[i].bitList[j] = new relayCabinetGraphicData.QdData();
}
}
}
export function deleteQdDataPositionByIndex(row: number, col: number) {
const allQdData: relayCabinetGraphicData.QdData[] = [];
ciQdList.qdList.forEach((qd, i) => {
qd.bitList.forEach((bit, j) => {
if (i !== col || j !== row) {
allQdData.push(bit);
}
});
});
allQdData.push(new relayCabinetGraphicData.QdData());
const allQdData2D = convertTo2DArray(
allQdData,
ciQdList.qdList.length,
ciQdList.dsCount
) as relayCabinetGraphicData.QdData[][];
ciQdList.qdList.forEach((qd, i) => {
qd.bitList.forEach((bit, j) => {
qd.bitList[j] = allQdData2D[i][j];
});
});
}
export function addQdDataPositionByIndex(row: number, col: number) {
const allQdData: relayCabinetGraphicData.QdData[] = [];
ciQdList.qdList.forEach((qd, i) => {
qd.bitList.forEach((bit, j) => {
allQdData.push(bit);
if (i == col && j == row) {
allQdData.push(new relayCabinetGraphicData.QdData());
}
});
});
allQdData.pop();
const allQdData2D = convertTo2DArray(
allQdData,
ciQdList.qdList.length,
ciQdList.dsCount
) as relayCabinetGraphicData.QdData[][];
ciQdList.qdList.forEach((qd, i) => {
qd.bitList.forEach((bit, j) => {
qd.bitList[j] = allQdData2D[i][j];
});
});
}
//一维数组变二维数组
export function convertTo2DArray(
sourceArray: any[],
rowCount: any,
colCount: any
): any[][] {
const result: any[][] = [];
for (let i = 0; i < rowCount; i++) {
const row: any[] = [];
for (let j = 0; j < colCount; j++) {
const index = i * colCount + j;
row.push(sourceArray[index]);
}
result.push(row);
}
return result;
}