添加列车总长选择

This commit is contained in:
dong 2023-08-28 14:32:42 +08:00
parent 0c2ba751b9
commit 66b240b674
6 changed files with 52 additions and 15 deletions

View File

@ -55,7 +55,7 @@ export async function getProjectLinkInfo(id: number): Promise<LinkInfo> {
*/
export async function getProjectLinkTrainSizeByMapId(
id: number
): Promise<TrainSizeInfo> {
): Promise<TrainSizeInfo[]> {
const response = await api.get(`${UriBase}/mapInfo/trainSize/${id}`);
return response.data;
}

View File

@ -27,6 +27,7 @@ export async function destroySimulation(data: { simulationId: string }) {
* @param id
* @param devicePort
* @param headOffset A端为偏移原点
* @param trainLength
*/
export async function addTrain(data: {
simulationId: string;
@ -34,6 +35,7 @@ export async function addTrain(data: {
id: string;
devicePort?: string;
headOffset: number;
trainLength?: number;
}) {
const response = await api.post(`${UriBase}/train/add`, data);
return response.data;

View File

@ -12,7 +12,7 @@
v-model="props.dev.code"
/>
</q-card-section>
<q-card-section class="q-pt-none">
<q-card-section class="q-py-none">
<q-input
type="number"
dense
@ -30,18 +30,29 @@
v-model="dir"
label="运行方向"
dense
outlined
:options="dirOptions"
emitValue
mapOptions
>
</q-select>
</q-card-section>
<q-card-section>
<q-select
v-model="trainLength"
label="列车总长度(mm)"
dense
outlined
:options="lengthOptions"
>
</q-select>
</q-card-section>
<q-card-actions align="right" class="text-primary">
<q-btn flat label="取消" @click="onDialogCancel" v-close-popup />
<q-btn
flat
label="确认"
@click="onDialogOK({ dir, offset })"
@click="onDialogOK({ dir, offset, trainLength })"
v-close-popup
/>
</q-card-actions>
@ -51,9 +62,11 @@
<script setup lang="ts">
import { useDialogPluginComponent } from 'quasar';
import { getProjectLinkTrainSizeByMapId } from 'src/api/ProjectLinkApi';
import { Section } from 'src/graphics/section/Section';
import { Turnout } from 'src/graphics/turnout/Turnout';
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
const props = defineProps({
dev: {
@ -78,5 +91,25 @@ const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent();
const offsetRules = (val: number) =>
(val >= 0 && val <= props.kmLength) || `偏移量在0到${props.kmLength}之间!`;
const route = useRoute();
const lengthOptions = ref<string[]>([]);
const trainLength = ref('');
onMounted(() => {
const mapId = route.query.mapId as string;
if (mapId) {
getLengthOption(+mapId);
}
});
function getLengthOption(mapId: number) {
getProjectLinkTrainSizeByMapId(mapId).then((res) => {
res.forEach((item) => {
if (!lengthOptions.value.includes(item.total_length + '')) {
lengthOptions.value.push(item.total_length + '');
}
});
});
}
</script>
<style scoped></style>

View File

@ -180,13 +180,17 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin<Section>
componentProps: { dev: section, kmLength: d },
cancel: true,
persistent: true,
}).onOk((data: { offset: number; dir: 1 | 0 }) => {
addTrain({
}).onOk((data: { offset: number; dir: 1 | 0; trainLength: string }) => {
const params = {
simulationId,
up: !!data.dir,
id: section.datas.index + '',
headOffset: data.offset,
})
};
if (data.trainLength) {
Object.assign(params, { trainLength: +data.trainLength });
}
addTrain(params)
.then(() => {
successNotify('添加列车成功!');
})

View File

@ -115,6 +115,7 @@
<q-select
outlined
class="q-mt-md"
use-chips
v-model="editLinkInfo.mids"
:options="midsOptions"
multiple
@ -127,6 +128,7 @@
<q-select
outlined
class="q-mt-md"
use-chips
v-model="editLinkInfo.sids"
:options="sidsOptions"
multiple

View File

@ -174,7 +174,7 @@
/>
<q-input
outlined
label="车厢长度"
label="车厢长度(mm)"
v-model.number="sizeEditInfo.carriage_length"
type="number"
lazy-rules
@ -182,7 +182,7 @@
/>
<q-input
outlined
label="总长度"
label="总长度(mm)"
v-model.number="sizeEditInfo.total_length"
type="number"
lazy-rules
@ -457,10 +457,6 @@ async function modelOnRequest(props: any) {
modelPagination.value.descending = descending;
modelRows.splice(0, modelRows.length, ...(pageData.records as []));
} catch (err) {
console.log(
'🚀 ~ file: TrainModelManage.vue:441 ~ modelOnRequest ~ err:',
err
);
const error = err as ApiError;
$q.notify({
type: 'negative',
@ -563,14 +559,14 @@ const sizeColumnDefs: QTableColumn[] = [
},
{
name: 'carriage_length',
label: '车厢长度',
label: '车厢长度(mm)',
field: 'carriage_length',
required: true,
align: 'center',
},
{
name: 'total_length',
label: '总长度',
label: '总长度(mm)',
field: 'total_length',
required: true,
align: 'center',