驱动采集列表增加数据校验和可变行列数
This commit is contained in:
parent
d829bd45d8
commit
7688aa6b0d
@ -5,6 +5,7 @@
|
||||
class="ceil"
|
||||
:class="{
|
||||
heightLight:
|
||||
!setCellDialog &&
|
||||
ciCjList?.cjList[col - 1].bitList[row - 1].refRelays.length,
|
||||
}"
|
||||
v-for="col in setCellMessage.cols"
|
||||
@ -39,7 +40,7 @@
|
||||
v-model.number="setCellMessage.rows"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val || '请输入数据集位数!']"
|
||||
:rules="[(val) => val > 0 || '请输入数据集位数!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
@ -47,7 +48,7 @@
|
||||
v-model.number="setCellMessage.cols"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val || '请输入数据集个数!']"
|
||||
:rules="[(val) => val > 0 || '请输入数据集个数!']"
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
@ -61,7 +62,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import DraggableDialog from 'src/components/common/DraggableDialog.vue';
|
||||
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
|
||||
import { loadCiCjList, creatCiCjList } from 'src/drawApp/relayCabinetLayoutApp';
|
||||
@ -75,6 +76,17 @@ const setCellMessage = ref<{ rows: number; cols: number }>({
|
||||
});
|
||||
let ciCjList: relayCabinetGraphicData.CiCj | undefined;
|
||||
|
||||
watch(
|
||||
() => relayCabinetStore.updateCiCjList,
|
||||
(val) => {
|
||||
if (val) {
|
||||
relayCabinetStore.updateCiCjList = false;
|
||||
setCellDialog.value = true;
|
||||
setCellDialog.value = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
ciCjList = loadCiCjList();
|
||||
if (ciCjList == undefined) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
class="ceil"
|
||||
:class="{
|
||||
heightLight:
|
||||
!setCellDialog &&
|
||||
ciQdList?.qdList[col - 1].bitList[row - 1].refRelays.length,
|
||||
}"
|
||||
v-for="col in setCellMessage.cols"
|
||||
@ -39,7 +40,7 @@
|
||||
v-model.number="setCellMessage.rows"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val || '请输入数据集位数!']"
|
||||
:rules="[(val) => val > 0 || '请输入数据集位数!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
@ -47,7 +48,7 @@
|
||||
v-model.number="setCellMessage.cols"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val || '请输入数据集个数!']"
|
||||
:rules="[(val) => val > 0 || '请输入数据集个数!']"
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
@ -61,7 +62,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import DraggableDialog from 'src/components/common/DraggableDialog.vue';
|
||||
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
|
||||
import { loadCiQdList, creatCiQdList } from 'src/drawApp/relayCabinetLayoutApp';
|
||||
@ -75,6 +76,17 @@ const setCellMessage = ref<{ rows: number; cols: number }>({
|
||||
});
|
||||
let ciQdList: relayCabinetGraphicData.CiQd | undefined;
|
||||
|
||||
watch(
|
||||
() => relayCabinetStore.updateCiCjList,
|
||||
(val) => {
|
||||
if (val) {
|
||||
relayCabinetStore.updateCiCjList = false;
|
||||
setCellDialog.value = true;
|
||||
setCellDialog.value = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
ciQdList = loadCiQdList();
|
||||
if (ciQdList == undefined) {
|
||||
|
@ -147,6 +147,24 @@ async function onSubmit() {
|
||||
if (res) {
|
||||
try {
|
||||
const ciCjList = loadCiCjList();
|
||||
const map = new Map<string, string>();
|
||||
ciCjList.cjList.forEach((cjDataSet, i) => {
|
||||
cjDataSet.bitList.forEach((cjData, j) => {
|
||||
cjData.refRelays.forEach((refRelay) => {
|
||||
map.set(refRelay.relayId, `${j + 1}-${i + 1}`);
|
||||
refRelay;
|
||||
});
|
||||
});
|
||||
});
|
||||
collectionConfig.value.refRelays.forEach((refRelayId) => {
|
||||
const hasSet = map.get(refRelayId);
|
||||
if (hasSet) {
|
||||
const refRelayCode = relayCabinetStore
|
||||
.getDrawApp()
|
||||
.queryStore.queryById<Relay>(refRelayId).datas.code;
|
||||
throw `在采集列表${hasSet}中已经选择了编号为${refRelayCode}的继电器`;
|
||||
}
|
||||
});
|
||||
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
|
||||
ciCjList.cjList[click.col - 1].bitList[click.row - 1].refRelays = [];
|
||||
collectionConfig.value.refRelays.forEach((relayId) => {
|
||||
@ -154,6 +172,7 @@ async function onSubmit() {
|
||||
new relayCabinetGraphicData.CjDataItem({ relayId, position: 0 })
|
||||
);
|
||||
});
|
||||
relayCabinetStore.updateCiCjList = true;
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '更新成功',
|
||||
@ -162,7 +181,7 @@ async function onSubmit() {
|
||||
} catch (err) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: '更新失败',
|
||||
message: err as string,
|
||||
});
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
|
@ -142,6 +142,24 @@ async function onSubmit() {
|
||||
if (res) {
|
||||
try {
|
||||
const ciQdList = loadCiQdList();
|
||||
const map = new Map<string, string>();
|
||||
ciQdList.qdList.forEach((qdDataSet, i) => {
|
||||
qdDataSet.bitList.forEach((qdData, j) => {
|
||||
qdData.refRelays.forEach((refRelay) => {
|
||||
map.set(refRelay, `${j + 1}-${i + 1}`);
|
||||
refRelay;
|
||||
});
|
||||
});
|
||||
});
|
||||
collectionConfig.value.refRelays.forEach((refRelayId) => {
|
||||
const hasSet = map.get(refRelayId);
|
||||
if (hasSet) {
|
||||
const refRelayCode = relayCabinetStore
|
||||
.getDrawApp()
|
||||
.queryStore.queryById<Relay>(refRelayId).datas.code;
|
||||
throw `在驱动列表${hasSet}中已经选择了编号为${refRelayCode}的继电器`;
|
||||
}
|
||||
});
|
||||
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
|
||||
ciQdList.qdList[click.col - 1].bitList[click.row - 1].refRelays =
|
||||
collectionConfig.value.refRelays;
|
||||
@ -150,10 +168,11 @@ async function onSubmit() {
|
||||
message: '更新成功',
|
||||
});
|
||||
showCollectionConfig.value = false;
|
||||
relayCabinetStore.updateCiCjList = true;
|
||||
} catch (err) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: '更新失败',
|
||||
message: err as string,
|
||||
});
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
|
@ -383,13 +383,43 @@ export function loadCiCjList() {
|
||||
}
|
||||
|
||||
export function creatCiCjList(rows: number, cols: number) {
|
||||
ciCjList = new relayCabinetGraphicData.CiCj();
|
||||
ciCjList.dsCount = rows;
|
||||
for (let i = 0; i < cols; i++) {
|
||||
ciCjList.cjList[i] = new relayCabinetGraphicData.CjDataSet();
|
||||
ciCjList.cjList[i].name = 'D' + (i + 1);
|
||||
for (let j = 0; j < rows; j++) {
|
||||
ciCjList.cjList[i].bitList[j] = new relayCabinetGraphicData.CjData();
|
||||
if (ciCjList == undefined) {
|
||||
ciCjList = new relayCabinetGraphicData.CiCj();
|
||||
ciCjList.dsCount = rows;
|
||||
for (let i = 0; i < cols; i++) {
|
||||
ciCjList.cjList[i] = new relayCabinetGraphicData.CjDataSet();
|
||||
ciCjList.cjList[i].name = 'D' + (i + 1);
|
||||
for (let j = 0; j < rows; j++) {
|
||||
ciCjList.cjList[i].bitList[j] = new relayCabinetGraphicData.CjData();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const oldRows = ciCjList.dsCount;
|
||||
ciCjList.dsCount = rows;
|
||||
const oldCols = ciCjList.cjList.length;
|
||||
//数据集个数改变
|
||||
if (oldCols < cols) {
|
||||
for (let i = oldCols; i < cols; i++) {
|
||||
ciCjList.cjList[i] = new relayCabinetGraphicData.CjDataSet();
|
||||
ciCjList.cjList[i].name = 'D' + (i + 1);
|
||||
for (let j = 0; j < rows; j++) {
|
||||
ciCjList.cjList[i].bitList[j] = new relayCabinetGraphicData.CjData();
|
||||
}
|
||||
}
|
||||
} else if (oldCols > cols) {
|
||||
ciCjList.cjList.splice(cols);
|
||||
}
|
||||
//数据集位数改变
|
||||
if (oldRows < rows) {
|
||||
for (let i = 0; i < cols; i++) {
|
||||
for (let j = oldRows; j < rows; j++) {
|
||||
ciCjList.cjList[i].bitList[j] = new relayCabinetGraphicData.CjData();
|
||||
}
|
||||
}
|
||||
} else if (oldRows > rows) {
|
||||
for (let i = 0; i < cols; i++) {
|
||||
ciCjList.cjList[i].bitList.splice(rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -401,13 +431,43 @@ export function loadCiQdList() {
|
||||
}
|
||||
|
||||
export function creatCiQdList(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();
|
||||
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();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const oldRows = ciQdList.dsCount;
|
||||
ciQdList.dsCount = rows;
|
||||
const oldCols = ciQdList.qdList.length;
|
||||
//数据集个数改变
|
||||
if (oldCols < cols) {
|
||||
for (let i = oldCols; 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();
|
||||
}
|
||||
}
|
||||
} else if (oldCols > cols) {
|
||||
ciQdList.qdList.splice(cols);
|
||||
}
|
||||
//数据集位数改变
|
||||
if (oldRows < rows) {
|
||||
for (let i = 0; i < cols; i++) {
|
||||
for (let j = oldRows; j < rows; j++) {
|
||||
ciQdList.qdList[i].bitList[j] = new relayCabinetGraphicData.QdData();
|
||||
}
|
||||
}
|
||||
} else if (oldRows > rows) {
|
||||
for (let i = 0; i < cols; i++) {
|
||||
ciQdList.qdList[i].bitList.splice(rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -453,7 +453,6 @@ function openCiCjList() {
|
||||
})
|
||||
.onCancel(() => {
|
||||
ciCjListDialogInstance = null;
|
||||
relayCabinetStore.setEditCiCjConfig(null);
|
||||
relayCabinetStore.showCiCjConfig = false;
|
||||
});
|
||||
}
|
||||
@ -467,7 +466,6 @@ function openCiQdList() {
|
||||
})
|
||||
.onCancel(() => {
|
||||
ciQdListDialogInstance = null;
|
||||
relayCabinetStore.setEditCiCjConfig(null);
|
||||
relayCabinetStore.showCiQdConfig = false;
|
||||
});
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ export const useRelayCabinetStore = defineStore('relayCabinet', {
|
||||
table: undefined as QTable | undefined,
|
||||
showCombinationTypeConfig: false,
|
||||
tableOfCombinationType: undefined as QTable | undefined,
|
||||
updateCiCjList: false,
|
||||
editCiCjConfigIndex: null as CiCjConfigCeil | null,
|
||||
showCiCjConfig: false,
|
||||
showCiQdConfig: false,
|
||||
|
Loading…
Reference in New Issue
Block a user