一键生成车次窗--初提交
This commit is contained in:
parent
b3c31c2a54
commit
8b46178f57
@ -16,57 +16,37 @@
|
||||
lazy-rules
|
||||
autogrow
|
||||
/>
|
||||
<div>
|
||||
<q-input
|
||||
outlined
|
||||
label="生成车次窗数量"
|
||||
v-model.number="generateParams.count"
|
||||
type="number"
|
||||
:rules="[(val) => val > 0 || '生成数量需要大于0']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="车次窗间隔"
|
||||
v-model.number="generateParams.interval"
|
||||
type="number"
|
||||
hint=""
|
||||
/>
|
||||
<q-list bordered class="rounded-borders">
|
||||
<q-item-label header>生成方向</q-item-label>
|
||||
|
||||
<q-list bordered separator class="rounded-borders">
|
||||
<q-item>
|
||||
<q-item-section no-wrap>
|
||||
<div class="q-gutter-sm">
|
||||
<q-radio v-model="generateParams.pd" :val="0" label="左侧" />
|
||||
<q-radio v-model="generateParams.pd" :val="1" label="右侧" />
|
||||
<q-item-section no-wrap class="q-gutter-y-sm column">
|
||||
<q-item-label> 关联的区段 </q-item-label>
|
||||
<div class="q-gutter-sm row">
|
||||
<q-chip
|
||||
v-for="item in relatedProcessPositions"
|
||||
:key="item.id"
|
||||
square
|
||||
color="primary"
|
||||
text-color="white"
|
||||
>
|
||||
{{ item.id }}
|
||||
</q-chip>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="生成" @click="onCreateTw" />
|
||||
<q-btn label="取消" @click="redset" />
|
||||
</q-card-actions>
|
||||
</div>
|
||||
</q-form>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { TrainWindowData } from 'src/drawApp/graphics/TrainWindowInteraction';
|
||||
import { Section } from 'src/graphics/section/Section';
|
||||
import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow';
|
||||
import {
|
||||
GenerateParams,
|
||||
TrainWindowDraw,
|
||||
} from 'src/graphics/trainWindow/TrainWindowDrawAssistant';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { onMounted, reactive, watch } from 'vue';
|
||||
import { computed, onMounted, reactive, watch } from 'vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
const trainWindowModel = reactive(new TrainWindowData());
|
||||
const generateParams = reactive({
|
||||
count: 1,
|
||||
interval: 5,
|
||||
pd: 1,
|
||||
});
|
||||
|
||||
drawStore.$subscribe;
|
||||
watch(
|
||||
@ -94,24 +74,13 @@ function onUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
function onCreateTw() {
|
||||
if (generateParams.count <= 0) {
|
||||
return;
|
||||
}
|
||||
let params: GenerateParams = new GenerateParams(
|
||||
generateParams.count,
|
||||
generateParams.interval,
|
||||
generateParams.pd > 0 ? true : false
|
||||
);
|
||||
const trainWindowDraw = drawStore
|
||||
.getDrawApp()
|
||||
.getDrawAssistant(TrainWindow.Type) as TrainWindowDraw;
|
||||
trainWindowDraw.generates(drawStore.selectedGraphic as TrainWindow, params);
|
||||
}
|
||||
|
||||
function redset() {
|
||||
generateParams.count = 1;
|
||||
generateParams.interval = 5;
|
||||
generateParams.pd = 1;
|
||||
const relatedProcessPositions = computed((): Section[] => {
|
||||
if (
|
||||
drawStore.selectedGraphic &&
|
||||
drawStore.selectedGraphic.type === 'TrainWindow'
|
||||
) {
|
||||
return (drawStore.selectedGraphic as TrainWindow).getRelatedSections();
|
||||
}
|
||||
return [];
|
||||
});
|
||||
</script>
|
||||
|
@ -31,6 +31,12 @@ export class TrainWindowData
|
||||
set code(v: string) {
|
||||
this.data.code = v;
|
||||
}
|
||||
get sectionId(): string {
|
||||
return this.data.code;
|
||||
}
|
||||
set sectionId(v: string) {
|
||||
this.data.code = v;
|
||||
}
|
||||
clone(): TrainWindowData {
|
||||
return new TrainWindowData(this.data.cloneMessage());
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
import { Color, Graphics, Rectangle } from 'pixi.js';
|
||||
import {
|
||||
GraphicData,
|
||||
GraphicRelationParam,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
getRectangleCenter,
|
||||
} from 'src/jl-graphic';
|
||||
import { Section } from '../section/Section';
|
||||
|
||||
export interface ITrainWindowData extends GraphicData {
|
||||
get code(): string; // 编号
|
||||
set code(v: string);
|
||||
get sectionId(): string; // 编号
|
||||
set sectionId(v: string);
|
||||
clone(): ITrainWindowData;
|
||||
copyFrom(data: ITrainWindowData): void;
|
||||
eq(other: ITrainWindowData): boolean;
|
||||
@ -19,6 +23,7 @@ export const TrainWindowConsts = {
|
||||
height: 15,
|
||||
lineWidth: 2,
|
||||
lineColor: '0x0fe81f',
|
||||
offsetSection: 60,
|
||||
};
|
||||
|
||||
export class TrainWindow extends JlGraphic {
|
||||
@ -52,6 +57,21 @@ export class TrainWindow extends JlGraphic {
|
||||
);
|
||||
rectGraphic.pivot = getRectangleCenter(rectP);
|
||||
}
|
||||
loadRealtions(): void {
|
||||
const sectionId = this.datas.sectionId;
|
||||
const section = this.queryStore.queryById<Section>(sectionId);
|
||||
if (section) {
|
||||
this.relationManage.addRelation(
|
||||
this,
|
||||
new GraphicRelationParam(section, section.datas.id)
|
||||
);
|
||||
}
|
||||
}
|
||||
getRelatedSections(): Section[] {
|
||||
return this.queryRelationByType('Section').map((rl) =>
|
||||
rl.getOtherGraphic<Section>(this)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class TrainWindowTemplate extends JlGraphicTemplate<TrainWindow> {
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
TrainWindowTemplate,
|
||||
TrainWindowConsts,
|
||||
} from './TrainWindow';
|
||||
import { Section } from '../section/Section';
|
||||
|
||||
export interface ITrainWindowDrawOptions {
|
||||
newData: () => ITrainWindowData;
|
||||
@ -99,6 +100,26 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
|
||||
}
|
||||
this.storeGraphic(...trainWindows);
|
||||
}
|
||||
oneGenerates() {
|
||||
const trainWindows: TrainWindow[] = [];
|
||||
const sections = this.app.queryStore.queryByType<Section>(Section.Type);
|
||||
sections.forEach((section) => {
|
||||
const points = section.datas.points;
|
||||
for (let i = 0; i < points.length - 1; i++) {
|
||||
const x = (points[i].x + points[i + 1].x) / 2;
|
||||
const trainWindow = new TrainWindow();
|
||||
trainWindow.loadData(this.createGraphicData());
|
||||
trainWindow.position.set(
|
||||
x,
|
||||
points[i].y - TrainWindowConsts.offsetSection
|
||||
);
|
||||
trainWindow.id = GraphicIdGenerator.next();
|
||||
trainWindow.datas.sectionId = section.id;
|
||||
trainWindows.push(trainWindow);
|
||||
}
|
||||
});
|
||||
this.storeGraphic(...trainWindows);
|
||||
}
|
||||
}
|
||||
|
||||
//碰撞检测
|
||||
@ -175,6 +196,7 @@ export class TrainWindowInteraction extends GraphicInteractionPlugin<TrainWindow
|
||||
g.eventMode = 'none';
|
||||
g.scalable = false;
|
||||
g.rotatable = false;
|
||||
g.off('selected', this.onSelected, this);
|
||||
}
|
||||
onSelected(): void {
|
||||
this.app.setOptions({
|
||||
|
@ -15,6 +15,9 @@
|
||||
<q-item clickable v-close-popup @click="buildRelations">
|
||||
<q-item-section>一键关联</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="oneClickGeneration">
|
||||
<q-item-section>一键生成</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
@ -174,6 +177,8 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { errorNotify, successNotify } from 'src/utils/CommonNotify';
|
||||
import { saveAsDraft } from 'src/api/DraftApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { TrainWindowDraw } from 'src/graphics/trainWindow/TrainWindowDrawAssistant';
|
||||
import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@ -298,6 +303,13 @@ function buildRelations() {
|
||||
console.log(app);
|
||||
}
|
||||
|
||||
function oneClickGeneration() {
|
||||
const trainWindowDraw = drawStore
|
||||
.getDrawApp()
|
||||
.getDrawAssistant(TrainWindow.Type) as TrainWindowDraw;
|
||||
trainWindowDraw.oneGenerates();
|
||||
}
|
||||
|
||||
function backConfirm() {
|
||||
router.go(-1);
|
||||
}
|
||||
|
@ -2052,6 +2052,7 @@ export namespace graphicData {
|
||||
constructor(data?: any[] | {
|
||||
common?: CommonInfo;
|
||||
code?: string;
|
||||
sectionId?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@ -2062,6 +2063,9 @@ export namespace graphicData {
|
||||
if ("code" in data && data.code != undefined) {
|
||||
this.code = data.code;
|
||||
}
|
||||
if ("sectionId" in data && data.sectionId != undefined) {
|
||||
this.sectionId = data.sectionId;
|
||||
}
|
||||
}
|
||||
}
|
||||
get common() {
|
||||
@ -2079,9 +2083,16 @@ export namespace graphicData {
|
||||
set code(value: string) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get sectionId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
|
||||
}
|
||||
set sectionId(value: string) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
sectionId?: string;
|
||||
}): TrainWindow {
|
||||
const message = new TrainWindow({});
|
||||
if (data.common != null) {
|
||||
@ -2090,12 +2101,16 @@ export namespace graphicData {
|
||||
if (data.code != null) {
|
||||
message.code = data.code;
|
||||
}
|
||||
if (data.sectionId != null) {
|
||||
message.sectionId = data.sectionId;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
sectionId?: string;
|
||||
} = {};
|
||||
if (this.common != null) {
|
||||
data.common = this.common.toObject();
|
||||
@ -2103,6 +2118,9 @@ export namespace graphicData {
|
||||
if (this.code != null) {
|
||||
data.code = this.code;
|
||||
}
|
||||
if (this.sectionId != null) {
|
||||
data.sectionId = this.sectionId;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -2113,6 +2131,8 @@ export namespace graphicData {
|
||||
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
|
||||
if (this.code.length)
|
||||
writer.writeString(2, this.code);
|
||||
if (this.sectionId.length)
|
||||
writer.writeString(3, this.sectionId);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -2128,6 +2148,9 @@ export namespace graphicData {
|
||||
case 2:
|
||||
message.code = reader.readString();
|
||||
break;
|
||||
case 3:
|
||||
message.sectionId = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user