|
@@ -4,9 +4,9 @@
|
|
|
class="form1"
|
|
|
label-position="left"
|
|
|
>
|
|
|
- <el-form-item label="场景名或完整url">
|
|
|
+ <el-form-item label="场景码">
|
|
|
<el-input
|
|
|
- v-model="sceneNameOrUrl"
|
|
|
+ v-model="formData.sceneCode"
|
|
|
autofocus
|
|
|
/>
|
|
|
</el-form-item>
|
|
@@ -179,13 +179,21 @@
|
|
|
确定
|
|
|
</el-button>
|
|
|
</div>
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- :disabled="rawWholeDataHistory.currentIdx < 0"
|
|
|
- @click="uploadAddPointResult"
|
|
|
- >
|
|
|
- 上传补点结果
|
|
|
- </el-button>
|
|
|
+ <div class="btn-group">
|
|
|
+ <el-button
|
|
|
+ :disabled="rawWholeDataHistory.currentIdx < 0"
|
|
|
+ @click="restoreRawWholeData"
|
|
|
+ >
|
|
|
+ 复原
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :disabled="rawWholeDataHistory.currentIdx < 0"
|
|
|
+ @click="uploadAddPointResult"
|
|
|
+ >
|
|
|
+ 保存
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
<!-- <div>{{ rawWholeDataHistory.history.length }}</div>
|
|
|
<div>{{ rawWholeDataHistory.currentIdx }}</div>
|
|
|
<div
|
|
@@ -196,15 +204,23 @@
|
|
|
</div> -->
|
|
|
</el-form>
|
|
|
</div>
|
|
|
+
|
|
|
+ <PointEditor
|
|
|
+ v-if="isEditingPoint"
|
|
|
+ :initial-point-data="pointDataForEditor"
|
|
|
+ @cancel="isEditingPoint = false"
|
|
|
+ @confirm="onPointEditorConfirm"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import * as d3 from "d3";
|
|
|
-import { getWholeData, uploadWholeData } from "./api.js";
|
|
|
+import { getWholeData, uploadWholeData, resetWholeData } from "./api.js";
|
|
|
import { ElLoading, ElMessage } from 'element-plus'
|
|
|
import {getDistance2D, computePointDistanceAndRowSlope, getNeighbourLocations} from '@/utils.js'
|
|
|
import deepClone from 'lodash/cloneDeep'
|
|
|
+import PointEditor from '@/components/PointEditor.vue'
|
|
|
|
|
|
// 视口尺寸
|
|
|
let svgWidth = document.documentElement.clientWidth - 200
|
|
@@ -281,13 +297,16 @@ function brushed(e) {
|
|
|
|
|
|
export default {
|
|
|
name: 'App',
|
|
|
+ components: {
|
|
|
+ PointEditor,
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- // sceneNameOrUrl: 'SS-t-XkquhxxurM',
|
|
|
- sceneNameOrUrl: 'SS-t-NZUICC2fRLi',
|
|
|
infoText: '',
|
|
|
loadingHandler: null,
|
|
|
formData: {
|
|
|
+ // sceneCode: 'SS-t-XkquhxxurM',
|
|
|
+ sceneCode: 'SS-t-NZUICC2fRLi',
|
|
|
path1: process.env.NODE_ENV === 'production' ? '' : '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,47,76,101,125',
|
|
|
path2: '',
|
|
|
startPoint: process.env.NODE_ENV === 'production' ? '' : '-38.5, 10.8',
|
|
@@ -302,6 +321,8 @@ export default {
|
|
|
history: [],
|
|
|
currentIdx: -1,
|
|
|
},
|
|
|
+ isEditingPoint: false,
|
|
|
+ pointDataForEditor: {},
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -404,8 +425,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
getWholeData() {
|
|
|
- if (!this.sceneNameOrUrl.trim()) {
|
|
|
- window.alert('场景名或完整url必填!')
|
|
|
+ if (!this.formData.sceneCode.trim()) {
|
|
|
+ window.alert('场景码必填!')
|
|
|
return
|
|
|
}
|
|
|
this.loadingHandler = ElLoading.service({
|
|
@@ -419,7 +440,7 @@ export default {
|
|
|
gNode.selectAll('circle').remove()
|
|
|
|
|
|
|
|
|
- getWholeData(this.sceneNameOrUrl).then((res) => {
|
|
|
+ getWholeData(this.formData.sceneCode).then((res) => {
|
|
|
this.rawWholeDataHistory.history = []
|
|
|
this.rawWholeDataHistory.currentIdx = -1
|
|
|
|
|
@@ -509,6 +530,14 @@ export default {
|
|
|
})
|
|
|
that.infoText = ''
|
|
|
})
|
|
|
+
|
|
|
+ gNode.selectAll('rect').on('click', function(e, d) {
|
|
|
+ // console.log(d)
|
|
|
+ const id = d[d.length - 1]
|
|
|
+ console.log(rawWholeData[id - 1])
|
|
|
+ that.isEditingPoint = true
|
|
|
+ that.pointDataForEditor = deepClone(rawWholeData[id - 1])
|
|
|
+ })
|
|
|
},
|
|
|
renderPath() {
|
|
|
if (!this.formData.path1.trim()) {
|
|
@@ -519,7 +548,6 @@ export default {
|
|
|
gNode.selectAll('circle.path1').remove()
|
|
|
gNode.selectAll('circle.path2').remove()
|
|
|
|
|
|
-
|
|
|
let rawPathDataIndex = this.inputPathStringToArray(this.formData.path1)
|
|
|
if (rawPathDataIndex === -1) {
|
|
|
return
|
|
@@ -993,8 +1021,46 @@ export default {
|
|
|
this.rawWholeDataHistory.history.push(deepClone(rawWholeData))
|
|
|
this.rawWholeDataHistory.currentIdx++
|
|
|
}, // end of method addPoint
|
|
|
+ restoreRawWholeData() {
|
|
|
+ if (!this.formData.sceneCode.trim()) {
|
|
|
+ window.alert('场景码必填!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.loadingHandler = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: 'Loading',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)',
|
|
|
+ })
|
|
|
+
|
|
|
+ resetWholeData(this.formData.sceneCode).then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: res,
|
|
|
+ type: 'success',
|
|
|
+ })
|
|
|
+ this.getWholeData()
|
|
|
+ }).catch((err) => {
|
|
|
+ ElMessage({
|
|
|
+ message: err,
|
|
|
+ type: 'error',
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.loadingHandler.close()
|
|
|
+ })
|
|
|
+ },
|
|
|
uploadAddPointResult() {
|
|
|
- uploadWholeData(this.sceneNameOrUrl, rawWholeData).then((res) => {
|
|
|
+ if (!this.formData.sceneCode.trim()) {
|
|
|
+ window.alert('场景码必填!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.loadingHandler = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: 'Loading',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)',
|
|
|
+ })
|
|
|
+
|
|
|
+ uploadWholeData(this.formData.sceneCode, rawWholeData).then((res) => {
|
|
|
ElMessage({
|
|
|
message: res,
|
|
|
type: 'success',
|
|
@@ -1004,8 +1070,30 @@ export default {
|
|
|
message: err,
|
|
|
type: 'error',
|
|
|
})
|
|
|
+ }).finally(() => {
|
|
|
+ this.loadingHandler.close()
|
|
|
})
|
|
|
},
|
|
|
+ onPointEditorConfirm(data) {
|
|
|
+ rawWholeData[data.id - 1].x = data.x
|
|
|
+ rawWholeData[data.id - 1].y = data.y
|
|
|
+ rawWholeData[data.id - 1].z = data.z
|
|
|
+ rawWholeData[data.id - 1].weight = data.weight
|
|
|
+ rawWholeData[data.id - 1].ids = data.ids
|
|
|
+
|
|
|
+ // 渲染
|
|
|
+ gNode.selectAll('rect').remove()
|
|
|
+ this.renderWholePoints()
|
|
|
+
|
|
|
+ // 存入历史记录
|
|
|
+ if (this.rawWholeDataHistory.currentIdx < this.rawWholeDataHistory.history.length - 1) {
|
|
|
+ this.rawWholeDataHistory.history = this.rawWholeDataHistory.history.slice(0, this.rawWholeDataHistory.currentIdx + 1)
|
|
|
+ }
|
|
|
+ this.rawWholeDataHistory.history.push(deepClone(rawWholeData))
|
|
|
+ this.rawWholeDataHistory.currentIdx++
|
|
|
+
|
|
|
+ this.isEditingPoint = false
|
|
|
+ }
|
|
|
},
|
|
|
}
|
|
|
</script>
|