|
@@ -11,7 +11,7 @@
|
|
</div>
|
|
</div>
|
|
<div class="hum-page-title" style="margin-top: 30px">断面图</div>
|
|
<div class="hum-page-title" style="margin-top: 30px">断面图</div>
|
|
<div class="hum-page-section">
|
|
<div class="hum-page-section">
|
|
- <div ref="chart" class="chart" :style="{height: '400px', width: '100%'}" />
|
|
|
|
|
|
+ <SectionChart :sections="sections" />
|
|
</div>
|
|
</div>
|
|
<div class="hum-page-title" style="margin-top: 30px">断面表</div>
|
|
<div class="hum-page-title" style="margin-top: 30px">断面表</div>
|
|
<div class="hum-page-section">
|
|
<div class="hum-page-section">
|
|
@@ -44,7 +44,9 @@
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
<el-button v-if="scope.row.isEdit" size="mini" type="text" icon="el-icon-circle-check" @click="saveSection(scope.row)">保存</el-button>
|
|
<el-button v-if="scope.row.isEdit" size="mini" type="text" icon="el-icon-circle-check" @click="saveSection(scope.row)">保存</el-button>
|
|
- <el-button v-else size="mini" type="text" icon="el-icon-s-operation" @click="editSection(scope.row)">编辑</el-button>
|
|
|
|
|
|
+ <el-button v-else size="mini" type="text" icon="el-icon-edit" @click="editSection(scope.row)">编辑</el-button>
|
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-top" @click="insertSection(scope.$index - 1)">向上插入</el-button>
|
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-bottom" @click="insertSection(scope.$index + 1)">向下插入</el-button>
|
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="deleteSection(scope.$index)">删除</el-button>
|
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="deleteSection(scope.$index)">删除</el-button>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -58,14 +60,14 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import * as echarts from 'echarts'
|
|
|
|
-require('echarts/theme/macarons') // echarts theme
|
|
|
|
-import resize from '@/utils/resize'
|
|
|
|
import { getSite, updateSite } from '@/api/site/site'
|
|
import { getSite, updateSite } from '@/api/site/site'
|
|
-import { addSection } from '@/api/site/berthing'
|
|
|
|
|
|
+import { addSection, getSection } from '@/api/site/berthing'
|
|
|
|
+import SectionChart from './chart';
|
|
|
|
|
|
export default {
|
|
export default {
|
|
- mixins: [resize],
|
|
|
|
|
|
+ components: {
|
|
|
|
+ SectionChart,
|
|
|
|
+ },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
id: 0,
|
|
id: 0,
|
|
@@ -84,7 +86,6 @@ export default {
|
|
{required: true, message: "断面名称不能为空", trigger: "blur"}
|
|
{required: true, message: "断面名称不能为空", trigger: "blur"}
|
|
],
|
|
],
|
|
},
|
|
},
|
|
- chart: null,
|
|
|
|
uploadAction: `${process.env.VUE_APP_BASE_API}/berthing/uploadFile`
|
|
uploadAction: `${process.env.VUE_APP_BASE_API}/berthing/uploadFile`
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -94,6 +95,14 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ loadSection() {
|
|
|
|
+ getSection(this.id).then((res) => {
|
|
|
|
+ const positions = JSON.parse(res.data.positions) || [];
|
|
|
|
+ this.sections = positions;
|
|
|
|
+ this.form.berthingName = res.data.berthingName;
|
|
|
|
+ this.tableSections = positions.map(({ x, y }) => ({ x, y, isEdit: false }))
|
|
|
|
+ })
|
|
|
|
+ },
|
|
loadSite() {
|
|
loadSite() {
|
|
getSite(this.siteId).then((res) => {
|
|
getSite(this.siteId).then((res) => {
|
|
this.site = { ...res.data };
|
|
this.site = { ...res.data };
|
|
@@ -104,6 +113,12 @@ export default {
|
|
this.tableSections = (res.data || []).map(({ x, y }) => ({ x, y, isEdit: false }))
|
|
this.tableSections = (res.data || []).map(({ x, y }) => ({ x, y, isEdit: false }))
|
|
},
|
|
},
|
|
saveSection(s) {
|
|
saveSection(s) {
|
|
|
|
+ if (!/^-?\d+(\.\d+)?$/.test(this.form.x)) {
|
|
|
|
+ return this.$message.error("起点距必须是数字")
|
|
|
|
+ }
|
|
|
|
+ if (!/^-?\d+(\.\d+)?$/.test(this.form.y)) {
|
|
|
|
+ return this.$message.error("高程必须是数字")
|
|
|
|
+ }
|
|
s.x = this.form.x;
|
|
s.x = this.form.x;
|
|
s.y = this.form.y;
|
|
s.y = this.form.y;
|
|
s.isEdit = false;
|
|
s.isEdit = false;
|
|
@@ -115,6 +130,31 @@ export default {
|
|
this.form.y = s.y;
|
|
this.form.y = s.y;
|
|
s.isEdit = true;
|
|
s.isEdit = true;
|
|
},
|
|
},
|
|
|
|
+ insertSection(index) {
|
|
|
|
+ this.form.x = 0;
|
|
|
|
+ this.form.y = 0;
|
|
|
|
+ if (index < 0) {
|
|
|
|
+ this.sections = [
|
|
|
|
+ { x: 0, y: 0 },
|
|
|
|
+ ...this.sections,
|
|
|
|
+ ]
|
|
|
|
+ this.tableSections = [
|
|
|
|
+ { x: 0, y: 0, isEdit: true },
|
|
|
|
+ ...this.tableSections,
|
|
|
|
+ ]
|
|
|
|
+ } else {
|
|
|
|
+ this.sections = [
|
|
|
|
+ ...this.sections.slice(0, index),
|
|
|
|
+ { x: 0, y: 0 },
|
|
|
|
+ ...this.sections.slice(index),
|
|
|
|
+ ]
|
|
|
|
+ this.tableSections = [
|
|
|
|
+ ...this.tableSections.slice(0, index),
|
|
|
|
+ { x: 0, y: 0, isEdit: true },
|
|
|
|
+ ...this.tableSections.slice(index),
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
deleteSection(index) {
|
|
deleteSection(index) {
|
|
this.tableSections.splice(index, 1);
|
|
this.tableSections.splice(index, 1);
|
|
this.sections = this.tableSections.map(({ x, y }) => ({ x, y }));
|
|
this.sections = this.tableSections.map(({ x, y }) => ({ x, y }));
|
|
@@ -125,10 +165,7 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.loading = true;
|
|
this.loading = true;
|
|
- const promise = this.id
|
|
|
|
- ? updateSite({ ...this.form, siteId: this.siteId })
|
|
|
|
- : addSection({ ...this.form, siteId: this.siteId, positions: this.sections });
|
|
|
|
- promise.then(response => {
|
|
|
|
|
|
+ addSection({ ...this.form, siteId: this.siteId, positions: this.sections }).then(response => {
|
|
this.$modal.msgSuccess(this.id ? "编辑成功" : "新增成功");
|
|
this.$modal.msgSuccess(this.id ? "编辑成功" : "新增成功");
|
|
this.$router.back();
|
|
this.$router.back();
|
|
}).finally(() => {
|
|
}).finally(() => {
|
|
@@ -136,113 +173,6 @@ export default {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- setOptions(sections) {
|
|
|
|
- const xAxisData = sections.map(({ x }) => x);
|
|
|
|
- const seriesData = sections.map(({ y }) => y);
|
|
|
|
- this.chart.setOption({
|
|
|
|
- xAxis: {
|
|
|
|
- name: '起点距',
|
|
|
|
- boundaryGap: false,
|
|
|
|
- data: xAxisData,
|
|
|
|
- type: 'category',
|
|
|
|
- axisLine: {
|
|
|
|
- lineStyle: {
|
|
|
|
- color: '#FF8500'
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- axisTick: {
|
|
|
|
- lineStyle: {
|
|
|
|
- color: '#8D99A4'
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- axisLabel: {
|
|
|
|
- color: '#54606C'
|
|
|
|
- },
|
|
|
|
- nameTextStyle: {
|
|
|
|
- color: '#54606C'
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- yAxis: [
|
|
|
|
- {
|
|
|
|
- name: '高程(m)',
|
|
|
|
- axisLine: {
|
|
|
|
- show: true,
|
|
|
|
- lineStyle: {
|
|
|
|
- color: '#FF8500'
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- axisTick: {
|
|
|
|
- show: true,
|
|
|
|
- lineStyle: {
|
|
|
|
- color: '#8D99A4'
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- axisLabel: {
|
|
|
|
- color: '#54606C'
|
|
|
|
- },
|
|
|
|
- nameTextStyle: {
|
|
|
|
- color: '#54606C'
|
|
|
|
- },
|
|
|
|
- min: 'dataMin',
|
|
|
|
- max: 'dataMax',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- axisLine: {
|
|
|
|
- show: true,
|
|
|
|
- lineStyle: {
|
|
|
|
- color: '#FF8500'
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- axisTick: {
|
|
|
|
- show: false,
|
|
|
|
- },
|
|
|
|
- axisLabel: {
|
|
|
|
- show: false,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- grid: {
|
|
|
|
- left: 50,
|
|
|
|
- right: 50,
|
|
|
|
- bottom: 40,
|
|
|
|
- top: 40,
|
|
|
|
- containLabel: true
|
|
|
|
- },
|
|
|
|
- tooltip: {
|
|
|
|
- trigger: 'axis',
|
|
|
|
- axisPointer: {
|
|
|
|
- type: 'cross'
|
|
|
|
- },
|
|
|
|
- padding: [5, 10]
|
|
|
|
- },
|
|
|
|
- series: [{
|
|
|
|
- name: '高程',
|
|
|
|
- itemStyle: {
|
|
|
|
- normal: {
|
|
|
|
- color: '#FF8500',
|
|
|
|
- lineStyle: {
|
|
|
|
- color: '#FF8500',
|
|
|
|
- width: 2
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- areaStyle: {
|
|
|
|
- color: '#FF8500',
|
|
|
|
- opacity: 0.5
|
|
|
|
- },
|
|
|
|
- smooth: false,
|
|
|
|
- symbol: 'none',
|
|
|
|
- type: 'line',
|
|
|
|
- data: seriesData,
|
|
|
|
- animations: false,
|
|
|
|
- }]
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- watch: {
|
|
|
|
- sections(value) {
|
|
|
|
- this.setOptions(value)
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
this.id = this.$route.params.id;
|
|
this.id = this.$route.params.id;
|
|
@@ -250,16 +180,9 @@ export default {
|
|
if (this.siteId) {
|
|
if (this.siteId) {
|
|
this.loadSite();
|
|
this.loadSite();
|
|
}
|
|
}
|
|
- this.$nextTick(() => {
|
|
|
|
- this.chart = echarts.init(this.$refs.chart, 'macarons');
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- beforeDestroy() {
|
|
|
|
- if (!this.chart) {
|
|
|
|
- return
|
|
|
|
|
|
+ if (this.id) {
|
|
|
|
+ this.loadSection();
|
|
}
|
|
}
|
|
- this.chart.dispose()
|
|
|
|
- this.chart = null
|
|
|
|
},
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|