Merge branch 'master' of git.code.tencent.com:beijing-rtss-test/bj-rtss-client

This commit is contained in:
Yuan 2023-11-13 17:04:14 +08:00
commit 91984105e5
13 changed files with 284 additions and 112 deletions

View File

@ -42,6 +42,24 @@ export async function addTrain(data: {
const response = await api.post(`${UriBase}/train/add`, data); const response = await api.post(`${UriBase}/train/add`, data);
return response.data; return response.data;
} }
/**
*
* @param id id
* @param simulationId 仿id
* @param trainLength
* @param wheelDiameter
*/
export async function updateTrain(data: {
id: string;
simulationId: string;
trainLength?: number;
wheelDiameter?: number;
}) {
const response = await api.post(`${UriBase}/train/update`, data);
return response.data;
}
/** /**
* *
* @param simulationId 仿id * @param simulationId 仿id

View File

@ -1,11 +1,5 @@
export enum CategoryType { export enum CategoryType {
JK = 'JK', JK = 'JK', // 交控(11)
TH = 'TH', TH = 'TH', // 通号(12)
ZDWX = 'ZDWX', ZDWX = 'ZDWX', // 浙大网新
} }
export const categoryTypeOptions = [
{ label: '交控(11)', value: CategoryType.JK },
{ label: '通号(12)', value: CategoryType.TH },
{ label: '浙大网新', value: CategoryType.ZDWX },
];

View File

@ -16,7 +16,7 @@
type="number" type="number"
dense dense
outlined outlined
:label="`列车偏移(mm)[长度${props.kmLength}mm]`" :label="`列车偏移(mm)【长度${props.kmLength}mm】`"
:max="kmLength" :max="kmLength"
:min="0" :min="0"
v-model.number="offset" v-model.number="offset"
@ -41,6 +41,17 @@
:options="lengthOptions" :options="lengthOptions"
> >
</q-select> </q-select>
<q-input
type="number"
dense
outlined
label="列车轮径(mm)【770-840mm】"
:max="840"
:min="770"
v-model.number="wheelDiameter"
lazy-rules
:rules="wheelDiameterRules"
/>
<q-card-actions align="right" class="text-primary"> <q-card-actions align="right" class="text-primary">
<q-btn flat label="取消" @click="onDialogCancel" v-close-popup /> <q-btn flat label="取消" @click="onDialogCancel" v-close-popup />
<q-btn flat label="确认" type="submit" /> <q-btn flat label="确认" type="submit" />
@ -68,6 +79,10 @@ const props = defineProps({
type: Number, type: Number,
required: true, required: true,
}, },
wDiameter: {
type: Number,
default: 800,
},
}); });
const dir = ref(1); const dir = ref(1);
const offset = ref(0); const offset = ref(0);
@ -94,6 +109,7 @@ onMounted(() => {
if (mapId) { if (mapId) {
getLengthOption(mapId); getLengthOption(mapId);
} }
wheelDiameter.value = props.wDiameter;
}); });
function getLengthOption(mapId: number) { function getLengthOption(mapId: number) {
@ -117,9 +133,16 @@ function onCreate() {
dir: dir.value, dir: dir.value,
offset: offset.value, offset: offset.value,
trainLength: trainLength.value, trainLength: trainLength.value,
wheelDiameter: wheelDiameter.value,
}); });
} }
}); });
} }
const wheelDiameter = ref(800);
const wheelDiameterRules = [
(val: string) => (val !== null && val !== '') || '偏移量不能为空!',
(val: number) => (val >= 770 && val <= 840) || '列车轮径在770到840mm之间',
];
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -90,6 +90,11 @@ const list: KeyType[] = [
key: 'controlDelayTime', key: 'controlDelayTime',
formatFn: controlDelayTimeFormat, formatFn: controlDelayTimeFormat,
}, },
{
label: '列车轮径',
key: 'wheelDiameter',
formatFn: wheelDiameterFormat,
},
]; ];
const list2: DynamicKeyType[] = [ const list2: DynamicKeyType[] = [
// //
@ -191,6 +196,9 @@ function upslopeFormat(v: boolean) {
// function runningUpFormat(v: boolean) { // function runningUpFormat(v: boolean) {
// return v ? '' : ''; // return v ? '' : '';
// } // }
function wheelDiameterFormat(v: number) {
return `${v} mm`;
}
function offsetFormat(v: number) { function offsetFormat(v: number) {
return `${v / 1000} m`; return `${v / 1000} m`;
} }

View File

@ -252,29 +252,37 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin<Section>
componentProps: { dev: section, kmLength: d }, componentProps: { dev: section, kmLength: d },
cancel: true, cancel: true,
persistent: true, persistent: true,
}).onOk((data: { offset: number; dir: 1 | 0; trainLength: string }) => { }).onOk(
const params = { (data: {
simulationId, offset: number;
mapId, dir: 1 | 0;
up: !!data.dir, trainLength: string;
id: section.datas.id, wheelDiameter: number;
headOffset: data.offset, }) => {
}; const params = {
if (data.trainLength) { simulationId,
Object.assign(params, { trainLength: +data.trainLength }); mapId,
} up: !!data.dir,
addTrain(params) id: section.datas.id,
.then(() => { headOffset: data.offset,
successNotify('添加列车成功!'); wheelDiameter: data.wheelDiameter,
}) };
.catch((err) => { if (data.trainLength) {
const error = err as ApiError; Object.assign(params, { trainLength: +data.trainLength });
Notify.create({ }
type: 'negative', addTrain(params)
message: `添加列车失败!: ${error.title}`, .then(() => {
successNotify('添加列车成功!');
})
.catch((err) => {
const error = err as ApiError;
Notify.create({
type: 'negative',
message: `添加列车失败!: ${error.title}`,
});
}); });
}); }
}); );
}; };
SectionOperateMenu.open(e.global); SectionOperateMenu.open(e.global);
} }

View File

@ -10,9 +10,10 @@ import {
JlGraphic, JlGraphic,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
import { removeTrain } from 'src/api/Simulation'; import { removeTrain, updateTrain } from 'src/api/Simulation';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { successNotify, errorNotify } from '../../utils/CommonNotify'; import { successNotify, errorNotify } from '../../utils/CommonNotify';
import { Dialog } from 'quasar';
export class TrainState extends GraphicStateBase implements ITrainState { export class TrainState extends GraphicStateBase implements ITrainState {
constructor(proto?: state.TrainState) { constructor(proto?: state.TrainState) {
let states; let states;
@ -122,6 +123,12 @@ export class TrainState extends GraphicStateBase implements ITrainState {
set controlDelayTime(v: number) { set controlDelayTime(v: number) {
this.states.controlDelayTime = v; this.states.controlDelayTime = v;
} }
get wheelDiameter(): number {
return this.states.wheelDiameter;
}
set wheelDiameter(v: number) {
this.states.wheelDiameter = v;
}
clone(): TrainState { clone(): TrainState {
return new TrainState(this.states.cloneMessage()); return new TrainState(this.states.cloneMessage());
} }
@ -133,6 +140,9 @@ export class TrainState extends GraphicStateBase implements ITrainState {
} }
} }
const wheelDiameterChange: MenuItemOptions = {
name: '列车轮径调整',
};
const removeTrainConfig: MenuItemOptions = { const removeTrainConfig: MenuItemOptions = {
name: '清除列车', name: '清除列车',
}; };
@ -140,7 +150,7 @@ const TrainOperateMenu: ContextMenu = ContextMenu.init({
name: '列车操作菜单', name: '列车操作菜单',
groups: [ groups: [
{ {
items: [removeTrainConfig], items: [wheelDiameterChange, removeTrainConfig],
}, },
], ],
}); });
@ -181,6 +191,32 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
const lineStore = useLineStore(); const lineStore = useLineStore();
const simulationId = lineStore.simulationId || ''; const simulationId = lineStore.simulationId || '';
const mapId = lineStore.mapId as number; const mapId = lineStore.mapId as number;
wheelDiameterChange.handler = () => {
Dialog.create({
title: '列车轮径调整',
message: '列车轮径(mm)【770-840mm】, 请调整!',
prompt: {
model: train.states.wheelDiameter + '',
isValid: (val) => +val >= 770 && +val <= 840,
type: 'number',
},
cancel: true,
persistent: true,
}).onOk((data) => {
const params = {
id: train.states.id,
simulationId: simulationId,
wheelDiameter: +data,
};
updateTrain(params)
.then(() => {
successNotify('列车轮径调整成功!');
})
.catch((err) => {
errorNotify('列车轮径调整失败!', err);
});
});
};
removeTrainConfig.handler = () => { removeTrainConfig.handler = () => {
removeTrain({ removeTrain({
simulationId, simulationId,

View File

@ -151,30 +151,38 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
componentProps: { dev: turnout, kmLength: d }, componentProps: { dev: turnout, kmLength: d },
cancel: true, cancel: true,
persistent: true, persistent: true,
}).onOk((data: { offset: number; dir: 1 | 0; trainLength: string }) => { }).onOk(
const params = { (data: {
simulationId, offset: number;
mapId, dir: 1 | 0;
up: !!data.dir, trainLength: string;
id: turnout.datas.id, wheelDiameter: number;
devicePort: port, }) => {
headOffset: data.offset, const params = {
}; simulationId,
if (data.trainLength) { mapId,
Object.assign(params, { trainLength: +data.trainLength }); up: !!data.dir,
} id: turnout.datas.id,
addTrain(params) devicePort: port,
.then(() => { headOffset: data.offset,
successNotify('添加列车成功!'); wheelDiameter: data.wheelDiameter,
}) };
.catch((err) => { if (data.trainLength) {
const error = err as ApiError; Object.assign(params, { trainLength: +data.trainLength });
Notify.create({ }
type: 'negative', addTrain(params)
message: `添加列车失败!: ${error.title}`, .then(() => {
successNotify('添加列车成功!');
})
.catch((err) => {
const error = err as ApiError;
Notify.create({
type: 'negative',
message: `添加列车失败!: ${error.title}`,
});
}); });
}); }
}); );
}; };
TurnoutOperationMenu.open(e.global); TurnoutOperationMenu.open(e.global);
} }

View File

@ -54,6 +54,8 @@ export interface ITrainState extends GraphicState {
set trainKilometer(v: number); set trainKilometer(v: number);
get controlDelayTime(): number; get controlDelayTime(): number;
set controlDelayTime(v: number); set controlDelayTime(v: number);
get wheelDiameter(): number;
set wheelDiameter(v: number);
} }
interface bodyWH { interface bodyWH {

View File

@ -116,7 +116,7 @@ import {
getCategoryInfo, getCategoryInfo,
} from '../api/CategoryInfoApi'; } from '../api/CategoryInfoApi';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { categoryTypeOptions } from 'src/components/CategoryType'; import { CategoryType } from 'src/components/CategoryType';
const $q = useQuasar(); const $q = useQuasar();
@ -219,7 +219,7 @@ function onCreate() {
const params: createParams = { const params: createParams = {
name: editInfo.categoryName, name: editInfo.categoryName,
code: editInfo.code, code: editInfo.code,
config: editInfo.config, config: JSON.stringify(editInfo.config),
}; };
if (editInfo.id) { if (editInfo.id) {
await saveCategoryData(+editInfo.id, params); await saveCategoryData(+editInfo.id, params);
@ -286,7 +286,7 @@ function editData(row: CategoryItem) {
editInfo.id = res.id + ''; editInfo.id = res.id + '';
editInfo.categoryName = res.name; editInfo.categoryName = res.name;
editInfo.code = res.code; editInfo.code = res.code;
editInfo.config = res.config || ''; editInfo.config = res.config ? JSON.parse(res.config) : '';
createFormShow.value = true; createFormShow.value = true;
}) })
.catch((err) => { .catch((err) => {
@ -297,4 +297,16 @@ function editData(row: CategoryItem) {
}); });
}); });
} }
const categoryTypeOptions = computed(() => {
const list: { label: string; value: string }[] = [];
for (let item in CategoryType) {
const obj = {
label: item,
value: CategoryType[item as CategoryType],
};
list.push(obj);
}
return list;
});
</script> </script>

View File

@ -151,7 +151,7 @@ import { publishDraft } from '../api/PublishApi';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { PictureType } from 'src/protos/picture'; import { PictureType } from 'src/protos/picture';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { categoryTypeOptions } from 'src/components/CategoryType'; import { getCategoryList } from 'src/api/CategoryInfoApi';
const $q = useQuasar(); const $q = useQuasar();
@ -169,6 +169,7 @@ const tableHeight = computed(() => {
const router = useRouter(); const router = useRouter();
onMounted(() => { onMounted(() => {
getCategoryOptions();
tableRef.value.requestServerInteraction(); tableRef.value.requestServerInteraction();
}); });
@ -365,7 +366,7 @@ const pictureType = ref(PictureType.StationLayout);
function categoryName(val?: string) { function categoryName(val?: string) {
let n = ''; let n = '';
if (val) { if (val) {
const find = categoryTypeOptions.find((item) => { const find = categoryTypeOptions.value.find((item) => {
return item.value == val; return item.value == val;
}); });
n = find ? find.label : val; n = find ? find.label : val;
@ -392,4 +393,23 @@ function goToPath(row: DraftItem) {
} }
router.push({ path: path }); router.push({ path: path });
} }
const categoryTypeOptions = ref<{ label: string; value: string }[]>([]);
function getCategoryOptions() {
getCategoryList()
.then((res) => {
const arr: { label: string; value: string }[] = [];
res.forEach((item) => {
const obj = {
label: item.name,
value: item.code,
};
arr.push(obj);
});
categoryTypeOptions.value = arr;
})
.catch((err) => {
console.log(err, '获取厂家列表失败!');
});
}
</script> </script>

View File

@ -99,7 +99,7 @@ import { createSimulation } from 'src/api/Simulation';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { MapInfo } from 'src/api/ProjectLinkApi'; import { MapInfo } from 'src/api/ProjectLinkApi';
import { categoryTypeOptions } from 'src/components/CategoryType'; import { getCategoryList } from 'src/api/CategoryInfoApi';
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const $q = useQuasar(); const $q = useQuasar();
@ -117,6 +117,7 @@ const tableHeight = computed(() => {
}); });
onMounted(() => { onMounted(() => {
getCategoryOptions();
tableRef.value.requestServerInteraction(); tableRef.value.requestServerInteraction();
selected.value = props.selects; selected.value = props.selects;
}); });
@ -156,7 +157,7 @@ const columnDefs: QTableColumn[] = [
function categoryName(val?: string) { function categoryName(val?: string) {
let n = ''; let n = '';
if (val) { if (val) {
const find = categoryTypeOptions.find((item) => { const find = categoryTypeOptions.value.find((item) => {
return item.value == val; return item.value == val;
}); });
n = find ? find.label : val; n = find ? find.label : val;
@ -309,4 +310,23 @@ watch(
} }
} }
); );
const categoryTypeOptions = ref<{ label: string; value: string }[]>([]);
function getCategoryOptions() {
getCategoryList()
.then((res) => {
const arr: { label: string; value: string }[] = [];
res.forEach((item) => {
const obj = {
label: item.name,
value: item.code,
};
arr.push(obj);
});
categoryTypeOptions.value = arr;
})
.catch((err) => {
console.log(err, '获取厂家列表失败!');
});
}
</script> </script>

View File

@ -66,14 +66,14 @@
<div class="text-h6"> <div class="text-h6">
{{ wheelEditInfo.id ? '编辑轮径' : '新建轮径' }} {{ wheelEditInfo.id ? '编辑轮径' : '新建轮径' }}
</div> </div>
<q-input <!-- <q-input
outlined outlined
label="轮径名称" label="轮径名称"
v-model="wheelEditInfo.name" v-model="wheelEditInfo.name"
lazy-rules lazy-rules
:rules="[(val) => val.length > 0 || '请输入名称!']" :rules="[(val) => val.length > 0 || '请输入名称!']"
/> /> -->
<q-input <!-- <q-input
outlined outlined
label="轮径安装轴位" label="轮径安装轴位"
v-model.number="wheelEditInfo.axial_position" v-model.number="wheelEditInfo.axial_position"
@ -99,7 +99,7 @@
label="安装方向" label="安装方向"
lazy-rules lazy-rules
:rules="[(val) => val.length > 0 || '请输入左侧或者右侧!']" :rules="[(val) => val.length > 0 || '请输入左侧或者右侧!']"
></q-select> ></q-select> -->
<q-input <q-input
outlined outlined
@ -160,53 +160,53 @@ onMounted(() => {
wheelTableRef.value.requestServerInteraction(); wheelTableRef.value.requestServerInteraction();
}); });
const directionOptions = [ // const directionOptions = [
{ label: '左侧', value: 'LEFT' }, // { label: '', value: 'LEFT' },
{ label: '右侧', value: 'RIGHT' }, // { label: '', value: 'RIGHT' },
]; // ];
function getDirectionName(val: string) { // function getDirectionName(val: string) {
let n = ''; // let n = '';
if (val) { // if (val) {
const find = directionOptions.find((item) => { // const find = directionOptions.find((item) => {
return item.value == val; // return item.value == val;
}); // });
n = find ? find.label : ''; // n = find ? find.label : '';
} // }
return n; // return n;
} // }
// //
const wheelColumnDefs: QTableColumn[] = [ const wheelColumnDefs: QTableColumn[] = [
{ // {
name: 'name', // name: 'name',
label: '名称', // label: '',
field: 'name', // field: 'name',
required: true, // required: true,
align: 'center', // align: 'center',
}, // },
{ // {
name: 'axial_position', // name: 'axial_position',
label: '安装轴位', // label: '',
field: 'axial_position', // field: 'axial_position',
required: true, // required: true,
align: 'center', // align: 'center',
}, // },
{ // {
name: 'diameter', // name: 'diameter',
label: '车轮直径(mm)', // label: '(mm)',
field: 'diameter', // field: 'diameter',
required: true, // required: true,
align: 'center', // align: 'center',
}, // },
{ // {
name: 'install_direction', // name: 'install_direction',
label: '安装方向', // label: '',
field: (row) => { // field: (row) => {
return getDirectionName(row.install_direction); // return getDirectionName(row.install_direction);
}, // },
required: true, // required: true,
align: 'center', // align: 'center',
}, // },
{ {
name: 'max_diameter', name: 'max_diameter',
label: '车轮的最大直径(mm)', label: '车轮的最大直径(mm)',

View File

@ -1015,6 +1015,7 @@ export namespace state {
vobcState?: TrainVobcState; vobcState?: TrainVobcState;
trainKilometer?: number; trainKilometer?: number;
controlDelayTime?: number; controlDelayTime?: number;
wheelDiameter?: number;
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -1064,6 +1065,9 @@ export namespace state {
if ("controlDelayTime" in data && data.controlDelayTime != undefined) { if ("controlDelayTime" in data && data.controlDelayTime != undefined) {
this.controlDelayTime = data.controlDelayTime; this.controlDelayTime = data.controlDelayTime;
} }
if ("wheelDiameter" in data && data.wheelDiameter != undefined) {
this.wheelDiameter = data.wheelDiameter;
}
} }
} }
get id() { get id() {
@ -1162,6 +1166,12 @@ export namespace state {
set controlDelayTime(value: number) { set controlDelayTime(value: number) {
pb_1.Message.setField(this, 15, value); pb_1.Message.setField(this, 15, value);
} }
get wheelDiameter() {
return pb_1.Message.getFieldWithDefault(this, 16, 0) as number;
}
set wheelDiameter(value: number) {
pb_1.Message.setField(this, 16, value);
}
static fromObject(data: { static fromObject(data: {
id?: string; id?: string;
up?: boolean; up?: boolean;
@ -1178,6 +1188,7 @@ export namespace state {
vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>; vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>;
trainKilometer?: number; trainKilometer?: number;
controlDelayTime?: number; controlDelayTime?: number;
wheelDiameter?: number;
}): TrainState { }): TrainState {
const message = new TrainState({}); const message = new TrainState({});
if (data.id != null) { if (data.id != null) {
@ -1225,6 +1236,9 @@ export namespace state {
if (data.controlDelayTime != null) { if (data.controlDelayTime != null) {
message.controlDelayTime = data.controlDelayTime; message.controlDelayTime = data.controlDelayTime;
} }
if (data.wheelDiameter != null) {
message.wheelDiameter = data.wheelDiameter;
}
return message; return message;
} }
toObject() { toObject() {
@ -1244,6 +1258,7 @@ export namespace state {
vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>; vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>;
trainKilometer?: number; trainKilometer?: number;
controlDelayTime?: number; controlDelayTime?: number;
wheelDiameter?: number;
} = {}; } = {};
if (this.id != null) { if (this.id != null) {
data.id = this.id; data.id = this.id;
@ -1290,6 +1305,9 @@ export namespace state {
if (this.controlDelayTime != null) { if (this.controlDelayTime != null) {
data.controlDelayTime = this.controlDelayTime; data.controlDelayTime = this.controlDelayTime;
} }
if (this.wheelDiameter != null) {
data.wheelDiameter = this.wheelDiameter;
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -1326,6 +1344,8 @@ export namespace state {
writer.writeInt64(14, this.trainKilometer); writer.writeInt64(14, this.trainKilometer);
if (this.controlDelayTime != 0) if (this.controlDelayTime != 0)
writer.writeInt64(15, this.controlDelayTime); writer.writeInt64(15, this.controlDelayTime);
if (this.wheelDiameter != 0)
writer.writeInt32(16, this.wheelDiameter);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -1380,6 +1400,9 @@ export namespace state {
case 15: case 15:
message.controlDelayTime = reader.readInt64(); message.controlDelayTime = reader.readInt64();
break; break;
case 16:
message.wheelDiameter = reader.readInt32();
break;
default: reader.skipField(); default: reader.skipField();
} }
} }