继电器调整
This commit is contained in:
parent
215dab15c7
commit
66cce194de
@ -59,14 +59,14 @@ const relayCabinetStore = useRelayCabinetStore();
|
||||
const $q = useQuasar();
|
||||
const tableRef = ref<QTable>();
|
||||
const deviceTypeMap = {
|
||||
Turnout: '道岔',
|
||||
signal: '信号机',
|
||||
1: '道岔',
|
||||
5: '信号机',
|
||||
};
|
||||
const columns: QTable['columns'] = [
|
||||
{
|
||||
name: 'type',
|
||||
name: 'deviceType',
|
||||
label: '设备类型',
|
||||
field: (row) => deviceTypeMap[row.type as keyof typeof deviceTypeMap],
|
||||
field: (row) => deviceTypeMap[row.deviceType as keyof typeof deviceTypeMap],
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'code', label: '设备编号', field: 'code', align: 'center' },
|
||||
|
@ -8,12 +8,12 @@
|
||||
<q-form ref="myForm" @submit="onSubmit" @reset="onReset">
|
||||
<q-select
|
||||
outlined
|
||||
v-model="relateRelayConfig.type"
|
||||
v-model="relateRelayConfig.deviceType"
|
||||
:options="optionsType"
|
||||
label="设备类型"
|
||||
:map-options="true"
|
||||
:emit-value="true"
|
||||
:rules="[(val) => val.trim() != '' || '设备类型不能为空']"
|
||||
:rules="[(val) => val != '' || '设备类型不能为空']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
@ -27,7 +27,7 @@
|
||||
v-for="(
|
||||
combinationtype, index
|
||||
) in relateRelayConfig.combinationtypes"
|
||||
:key="combinationtype.code"
|
||||
:key="combinationtype"
|
||||
v-model="combinationtype.expanded"
|
||||
:label="combinationtype.code"
|
||||
@click="toggleItem(index)"
|
||||
@ -95,8 +95,6 @@ import { onMounted, ref, watch } from 'vue';
|
||||
import { QForm, useQuasar } from 'quasar';
|
||||
import { JlGraphic } from 'src/jl-graphic';
|
||||
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
|
||||
import { Turnout } from 'src/graphics/turnout/Turnout';
|
||||
import { Signal } from 'src/graphics/signal/Signal';
|
||||
import { Relay } from 'src/graphics/relay/Relay';
|
||||
import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
|
||||
import {
|
||||
@ -104,6 +102,7 @@ import {
|
||||
editDeviceRelateRelay,
|
||||
RelateRelaylistItem,
|
||||
} from 'src/drawApp/relayCabinetLayoutApp';
|
||||
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||
|
||||
defineExpose({ editRelateRelays });
|
||||
|
||||
@ -111,7 +110,7 @@ const relayCabinetStore = useRelayCabinetStore();
|
||||
const $q = useQuasar();
|
||||
const showRangeConfig = ref(true);
|
||||
const relateRelayConfig = ref<{
|
||||
type: string;
|
||||
deviceType: graphicData.RelatedRef.DeviceType | undefined;
|
||||
code: string;
|
||||
combinationtypes: {
|
||||
code: string;
|
||||
@ -120,7 +119,7 @@ const relateRelayConfig = ref<{
|
||||
expanded: boolean;
|
||||
}[];
|
||||
}>({
|
||||
type: '',
|
||||
deviceType: undefined,
|
||||
code: '',
|
||||
combinationtypes: [
|
||||
{ code: '组合类型', refRelays: [], refRelaysCode: [], expanded: false },
|
||||
@ -129,8 +128,8 @@ const relateRelayConfig = ref<{
|
||||
const handleState = ref('新建设备关联继电器');
|
||||
|
||||
const optionsType = [
|
||||
{ label: '道岔', value: Turnout.Type },
|
||||
{ label: '信号机', value: Signal.Type },
|
||||
{ label: '道岔', value: graphicData.RelatedRef.DeviceType.Turnout },
|
||||
{ label: '信号机', value: graphicData.RelatedRef.DeviceType.signal },
|
||||
];
|
||||
|
||||
let selectGraphic: JlGraphic[] = [];
|
||||
@ -175,7 +174,7 @@ async function onSubmit() {
|
||||
});
|
||||
const deviceRelateRelay = new relayCabinetGraphicData.DeviceRelateRelay(
|
||||
{
|
||||
type: relateRelayConfig.value.type,
|
||||
deviceType: relateRelayConfig.value.deviceType,
|
||||
code: relateRelayConfig.value.code,
|
||||
combinationtypes: combinationtypes,
|
||||
}
|
||||
@ -216,7 +215,7 @@ async function editRelateRelays(row: RelateRelaylistItem) {
|
||||
selectGraphic = [];
|
||||
drawApp.updateSelected();
|
||||
editRow = row;
|
||||
relateRelayConfig.value.type = row.type;
|
||||
relateRelayConfig.value.deviceType = row.deviceType;
|
||||
relateRelayConfig.value.code = row.code;
|
||||
row.combinationtypes.forEach((combinationtype) => {
|
||||
const refCode: string[] = [];
|
||||
@ -305,7 +304,7 @@ function onReset() {
|
||||
clickIndex = null;
|
||||
handleState.value = '新建设备关联继电器';
|
||||
relateRelayConfig.value = {
|
||||
type: '',
|
||||
deviceType: undefined,
|
||||
code: '',
|
||||
combinationtypes: [
|
||||
{ code: '组合类型', refRelays: [], refRelaysCode: [], expanded: false },
|
||||
|
@ -25,7 +25,7 @@
|
||||
<script setup lang="ts">
|
||||
import { RelayData } from 'src/drawApp/relayCabinetGraphics/RelayInteraction';
|
||||
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
|
||||
import { useFormData } from 'src/components/DrawAppFormUtils';
|
||||
import { useFormData } from 'src/components/relayCabinetAppFormUtils';
|
||||
import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
|
||||
|
||||
const relayCabinetStore = useRelayCabinetStore();
|
||||
|
30
src/components/relayCabinetAppFormUtils.ts
Normal file
30
src/components/relayCabinetAppFormUtils.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { type GraphicDataBase } from 'src/drawApp/graphics/GraphicDataBase';
|
||||
import { IDrawApp, JlGraphic } from 'src/jl-graphic';
|
||||
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
|
||||
import { onMounted, onUnmounted, reactive } from 'vue';
|
||||
|
||||
const drawStore = useRelayCabinetStore();
|
||||
|
||||
export function useFormData<T extends GraphicDataBase>(
|
||||
source: T,
|
||||
app: IDrawApp
|
||||
) {
|
||||
const data = reactive<T>(source);
|
||||
|
||||
onMounted(() => {
|
||||
app.bindFormData(data);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
app.unbindFormData(data);
|
||||
});
|
||||
|
||||
function onUpdate() {
|
||||
const graphic = drawStore.selectedGraphic as JlGraphic;
|
||||
if (graphic) {
|
||||
app.updateGraphicAndRecord(graphic, data);
|
||||
}
|
||||
}
|
||||
|
||||
return { data, onUpdate };
|
||||
}
|
@ -229,7 +229,7 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
|
||||
}
|
||||
|
||||
export interface RelateRelaylistItem {
|
||||
type: string;
|
||||
deviceType: graphicData.RelatedRef.DeviceType | undefined;
|
||||
code: string;
|
||||
combinationtypes: {
|
||||
code: string;
|
||||
@ -258,7 +258,7 @@ export function editDeviceRelateRelay(
|
||||
) {
|
||||
for (let i = 0; i < refRelaysList.length; i++) {
|
||||
if (
|
||||
refRelaysList[i].type == editRow.type &&
|
||||
refRelaysList[i].deviceType == editRow.deviceType &&
|
||||
refRelaysList[i].code == editRow.code
|
||||
) {
|
||||
refRelaysList[i] = newData;
|
||||
@ -271,7 +271,7 @@ export function editDeviceRelateRelay(
|
||||
export function deleteDeviceRelateRelay(row: RelateRelaylistItem) {
|
||||
for (let i = 0; i < refRelaysList.length; i++) {
|
||||
if (
|
||||
refRelaysList[i].type == row.type &&
|
||||
refRelaysList[i].deviceType == row.deviceType &&
|
||||
refRelaysList[i].code == row.code
|
||||
) {
|
||||
refRelaysList.splice(i, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user