This commit is contained in:
fan 2021-04-07 17:15:06 +08:00
commit cd936dea42

View File

@ -43,23 +43,37 @@
</el-form>
</el-row>
<el-row>
<el-table :data="stationIntervalData" border style="width: 100%" height="320">
<el-table-column prop="startStationCode" :label="$t('planMonitor.modifying.startingStation')" width="120">
<el-table v-loading="dataLoading" :data="stationIntervalData" border style="width: 100%" height="420">
<el-table-column
prop="startStationCode"
:label="$t('planMonitor.modifying.startingStation')"
width="140"
:filters="startStationFilters"
:filter-method="filterStartStation"
column-key="startStationCode"
>
<template slot-scope="scope">
<span style="margin-left: 10px">{{ formatName(scope.row.startStationCode) }}</span>
</template>
</el-table-column>
<el-table-column prop="startSectionCode" :label="$t('planMonitor.modifying.startSection')" width="120">
<el-table-column prop="startSectionCode" :label="$t('planMonitor.modifying.startSection')" width="100">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ formatName(scope.row.startSectionCode) }}</span>
</template>
</el-table-column>
<el-table-column prop="endStationCode" :label="$t('planMonitor.modifying.endStation')" width="120">
<el-table-column
prop="endStationCode"
:label="$t('planMonitor.modifying.endStation')"
width="140"
:filters="endStationFilters"
:filter-method="filterEndStation"
column-key="endStationCode"
>
<template slot-scope="scope">
<span style="margin-left: 10px">{{ formatName(scope.row.endStationCode) }}</span>
</template>
</el-table-column>
<el-table-column prop="endSectionCode" :label="$t('planMonitor.modifying.endSection')" width="120">
<el-table-column prop="endSectionCode" :label="$t('planMonitor.modifying.endSection')" width="100">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ formatName(scope.row.endSectionCode) }}</span>
</template>
@ -105,9 +119,9 @@
</el-table>
</el-row>
<div class="button-group" style="text-align: center; margin-top: 10px;">
<el-button @click="handleStationDistance">更新距离</el-button>
<el-button :loading="loading" :disabled="updateloading" @click="handleStationDistance">更新距离</el-button>
<el-button @click="doClose">关闭</el-button>
<el-button @click="handleStationTime">更新</el-button>
<el-button :loading="updateloading" :disabled="loading" @click="handleStationTime">更新</el-button>
</div>
</el-dialog>
</template>
@ -122,8 +136,12 @@ export default {
data() {
return {
dialogShow: false,
dataLoading:false,
loading: false,
updateloading:false,
DirectionCodeMap: {},
startStationFilters:[],
endStationFilters:[],
stationIntervalData: [],
params: {},
form: {
@ -153,16 +171,39 @@ export default {
this.DirectionCodeMap[elem.value] = elem.label;
});
if (this.$route.query.lineCode) {
this.dataLoading = true;
getMapStationRunUser(this.$route.query.mapId).then(resp =>{
const list = resp.data.list;
this.stationIntervalData = [];
this.stationIntervalData = list;
const startStationFilterMap = {};
const endStationFilterMap = {};
list.forEach(stationRun=>{
if (!startStationFilterMap[stationRun.startStationCode]) {
startStationFilterMap[stationRun.startStationCode] = {text:formatName(stationRun.startStationCode), value:stationRun.startStationCode};
}
if (!endStationFilterMap[stationRun.endStationCode]) {
endStationFilterMap[stationRun.endStationCode] = {text:formatName(stationRun.endStationCode), value:stationRun.endStationCode};
}
});
this.startStationFilters = Object.values(startStationFilterMap).sort((a, b)=>{
const startStationA = this.$store.getters['map/getDeviceByCode'](a.value);
const startStationB = this.$store.getters['map/getDeviceByCode'](b.value);
return startStationA.kmRange - startStationB.kmRange;
});
this.endStationFilters = Object.values(endStationFilterMap).sort((a, b)=>{
const endStationA = this.$store.getters['map/getDeviceByCode'](a.value);
const endStationB = this.$store.getters['map/getDeviceByCode'](b.value);
return endStationA.kmRange - endStationB.kmRange;
});
this.form.level1 = '';
this.form.level2 = '';
this.form.level3 = '';
this.form.level4 = '';
this.form.level5 = '';
this.dataLoading = false;
});
}
},
@ -184,32 +225,33 @@ export default {
}
},
handleStationTime() {
this.updateloading = true;
setStationRunning(this.$route.query.mapId, this.stationIntervalData).then(resp => {
this.updateloading = false;
this.$message.success(this.$t('planMonitor.modifying.modifySuccess'));
}).catch((error) => {
this.$messageBox(this.$t('planMonitor.modifying.modifyFailed') + ': ' + error.message);
});
},
handleStationDistance() {
updateRunlevelDistance(this.$route.query.mapId).then(resp => {
if (resp.data) {
this.$message.success('更新成功');
const list = resp.data;
const stationIntervalData = [];
this.stationIntervalData.forEach(station=>{
if (list[station.id]) {
const tempStation = Object.assign({}, station);
tempStation.distance = list[station.id];
stationIntervalData.push(tempStation);
}
});
this.stationIntervalData = stationIntervalData;
} else {
this.$messageBox('更新失败:数据为空');
}
}).catch((error) => {
this.$messageBox('更新失败: ' + error.message);
});
this.$confirm('运行等级将重置为默认值,是否确定?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
this.loading = true;
updateRunlevelDistance(this.$route.query.mapId).then(resp => {
if (resp.data) {
this.loading = false;
this.$message.success('更新成功');
this.stationIntervalData = resp.data;
} else {
this.$messageBox('更新失败:数据为空');
}
}).catch((error) => {
this.$messageBox('更新失败: ' + error.message);
});
}).catch(() => { });
},
doShow(params) {
this.params = params || {};
@ -217,8 +259,13 @@ export default {
this.dialogShow = true;
},
doClose() {
this.loading = false;
this.dialogShow = false;
},
filterStartStation(value, row) {
return row.startStationCode == value;
},
filterEndStation(value, row) {
return row.endStationCode == value;
}
}
};