Browse Source

复原操作需要二次确认

任一存 1 year ago
parent
commit
578c82301c
1 changed files with 27 additions and 12 deletions
  1. 27 12
      src/App.vue

+ 27 - 12
src/App.vue

@@ -185,9 +185,10 @@
         </div>
         <div class="button-row">
           <el-button
+            type="danger"
             class="btn"
             :disabled="rawWholeDataHistory.currentIdx < 0"
-            @click="restoreRawWholeData"
+            @click="onClickRestore"
           >
             复原
           </el-button>
@@ -223,7 +224,7 @@
 <script>
 import * as d3 from "d3";
 import { getWholeData, uploadWholeData, resetWholeData } from "./api.js";
-import { ElLoading, ElMessage } from 'element-plus'
+import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
 import {getDistance2D, computePointDistanceAndRowSlope, getNeighbourLocations} from '@/utils.js'
 import deepClone from 'lodash/cloneDeep'
 import PointEditor from '@/components/PointEditor.vue'
@@ -1112,25 +1113,39 @@ export default {
       this.rawWholeDataHistory.history.push(deepClone(rawWholeData))
       this.rawWholeDataHistory.currentIdx++
     }, // end of method addPoint
-    restoreRawWholeData() {
+    onClickRestore() {
       if (!this.formData.sceneCode.trim()) {
         window.alert('场景码必填!')
         return
       }
 
-      this.loadingHandler = ElLoading.service({
-        lock: true,
-        text: 'Loading',
-        background: 'rgba(0, 0, 0, 0.7)',
-      })
+      ElMessageBox.confirm(
+        '此操作将会恢复点位数据为算法提供的初始值。',
+        '禁告',
+        {
+          type: 'warning',
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+        }
+      ).then(() => {
+        this.loadingHandler = ElLoading.service({
+          lock: true,
+          text: 'Loading',
+          background: 'rgba(0, 0, 0, 0.7)',
+        })
 
-      resetWholeData(this.formData.sceneCode).then((res) => {
+        return resetWholeData(this.formData.sceneCode)
+      }).then(() => {
+        return this.getWholeData()
+      }).then(() => {
         ElMessage({
-          message: res,
-          type: 'success',
+          message: '操作成功',
+          type: 'success'
         })
-        this.getWholeData()
       }).catch((err) => {
+        if (err === 'cancel') {
+          return
+        }
         ElMessage({
           message: err,
           type: 'error',