This commit is contained in:
fan 2020-04-30 14:50:42 +08:00
commit 26487c0dd8

View File

@ -94,7 +94,12 @@
<!--</el-form-item>-->
<el-form-item :label="$t('map.trafficSegmentData')" prop="parkSectionCodeList">
<el-button type="primary" size="small" :loading="generating" style="margin-bottom:10px" @click.native.prevent="generateParkSection">生成交路区段</el-button>
<el-table :data="addModel.parkSectionCodeList" border style="width: 97%">
<el-table
:data="addModel.parkSectionCodeList"
border
style="width: 97%"
class="el-parkSectionCode-table"
>
<el-table-column prop="sectionCode" :label="$t('map.stationName')">
<template slot-scope="scope">
<span>{{ formatName(scope.row.stationCode) }}</span>
@ -108,7 +113,7 @@
<el-table-column fixed="right" :label="$t('map.operation')" width="50">
<template slot-scope="scope">
<el-button
v-if="scope.$index!=0&&scope.$index!=addModel.parkSectionCodeList.length-1"
v-show="scope.$index!=0&&scope.$index!=addModel.parkSectionCodeList.length-1"
type="text"
size="small"
@click.native.prevent="deleteSection(addModel.parkSectionCodeList, scope.$index)"
@ -287,16 +292,29 @@ export default {
methods: {
//
rowDrop() {
const that = this;
const tbody = document.querySelector('.el-table__body-wrapper tbody');
if (tbody) {
Sortable.create(tbody, {
onEnd({ newIndex, oldIndex }) {
const currRow = that.addModel.mapRouteUnitRelList.splice(oldIndex, 1)[0];
that.addModel.mapRouteUnitRelList.splice(newIndex, 0, currRow);
}
});
}
const that = this;
const tbody = document.querySelector('.el-parkSectionCode-table tbody', {filter:'.ignoreDrag'});
if (tbody) {
Sortable.create(tbody, {
onEnd({ newIndex, oldIndex }) {
const length = that.addModel.parkSectionCodeList.length - 1;
if (newIndex != 0 && oldIndex != 0 && newIndex != length && oldIndex != length) {
that.addModel.parkSectionCodeList.splice(newIndex, 0, that.addModel.parkSectionCodeList.splice(oldIndex, 1)[0]);
const newArray = that.addModel.parkSectionCodeList.slice(0);
that.addModel.parkSectionCodeList = [];
that.$nextTick(function () {
that.addModel.parkSectionCodeList = newArray;
});
} else {
const newArray = that.addModel.parkSectionCodeList.slice(0);
that.addModel.parkSectionCodeList = [];
that.$nextTick(function () {
that.addModel.parkSectionCodeList = newArray;
});
}
}
});
}
},
generateParkSection() {
this.$refs.form.validate((valid) => {