浏览代码

实时标绘 预案保存

Hwf 8 月之前
父节点
当前提交
6f8c5cc0b2
共有 3 个文件被更改,包括 36 次插入16 次删除
  1. 3 4
      src/api/globalMap/onlinePlotting.ts
  2. 3 0
      src/types/components.d.ts
  3. 30 12
      src/views/globalMap/RightMenu/OnlinePlotting.vue

+ 3 - 4
src/api/globalMap/onlinePlotting.ts

@@ -1,4 +1,3 @@
-
 import request from '@/utils/request';
 
 // 获取预案列表
@@ -25,9 +24,9 @@ export const getPatternInfo = (id) => {
   });
 };
 // 预案更新
-export const updatePatternInfo = (id, data) => {
+export const updatePatternInfo = (data) => {
   return request({
-    url: '/api/pattern/update/' + id,
+    url: '/api/pattern/update/' + data.id,
     method: 'put',
     data: data
   });
@@ -37,7 +36,7 @@ export const updatePatternInfo = (id, data) => {
 export const createPattern = (data) => {
   return request({
     url: '/api/pattern/create',
-    method: 'put',
+    method: 'post',
     data: data
   });
 };

+ 3 - 0
src/types/components.d.ts

@@ -48,6 +48,8 @@ declare module 'vue' {
     ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
     ElSelect: typeof import('element-plus/es')['ElSelect']
+    ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
+    ElSkeletonItem: typeof import('element-plus/es')['ElSkeletonItem']
     ElSlider: typeof import('element-plus/es')['ElSlider']
     ElStep: typeof import('element-plus/es')['ElStep']
     ElSteps: typeof import('element-plus/es')['ElSteps']
@@ -61,6 +63,7 @@ declare module 'vue' {
     ElTimeline: typeof import('element-plus/es')['ElTimeline']
     ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
     ElTooltip: typeof import('element-plus/es')['ElTooltip']
+    ElTree: typeof import('element-plus/es')['ElTree']
     ElUpload: typeof import('element-plus/es')['ElUpload']
     FileUpload: typeof import('./../components/FileUpload/index.vue')['default']
     FooterSection: typeof import('./../components/FooterSection/index.vue')['default']

+ 30 - 12
src/views/globalMap/RightMenu/OnlinePlotting.vue

@@ -84,8 +84,7 @@
     <div v-show="tipTitle !== ''" class="tipTitle">{{ tipTitle }}</div>
   </div>
 
-
-  <Dialog v-model="showEdit" title="编辑" width="450px" height="200px" style="position: fixed; top: 1280px">
+  <Dialog v-model="showEdit" title="预案管理" width="450px" height="200px" style="position: fixed; top: 1280px">
     <el-input v-model="editData.pattern_name" />
     <div class="footer">
       <el-button :loading="buttonLoading" type="primary" @click="submitForm">确定</el-button>
@@ -98,7 +97,13 @@
 import { nanoid } from 'nanoid';
 import { deepClone } from '@/utils';
 import { useHistory } from '@/hooks/useHistory';
-import { deletePatternById, getPatternInfo, getPatternList, updatePatternInfo } from '@/api/globalMap/onlinePlotting';
+import {
+  createPattern,
+  deletePatternById,
+  getPatternInfo,
+  getPatternList,
+  updatePatternInfo
+} from '@/api/globalMap/onlinePlotting';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const getDrawTool = inject('getDrawTool');
@@ -480,7 +485,8 @@ const patternList = ref([]);
 let total = ref(0);
 let editData = ref({
   id: '',
-  pattern_name: ''
+  pattern_name: '',
+  content: {}
 });
 let showEdit = ref(false);
 let buttonLoading = ref(false);
@@ -512,18 +518,22 @@ const handleEdit = (id) => {
 };
 const submitForm = () => {
   buttonLoading.value = true;
-  updatePatternInfo(editData.value.id, editData.value)
-    .then((res) => {
-      proxy.$modal.msgSuccess('更新成功');
+  const flag = !!editData.value.id;
+  const method = flag ? updatePatternInfo : createPattern;
+  debugger
+  method(editData.value)
+    .then(() => {
+      proxy.$modal.msgSuccess(flag ? '更新成功' : '保存成功');
       showEdit.value = false;
+      editData.value = {
+        id: '',
+        pattern_name: '',
+        content: {}
+      };
       getList();
     })
     .finally(() => {
       buttonLoading.value = false;
-      editData.value = {
-        id: '',
-        pattern_name: ''
-      };
     });
 };
 
@@ -531,7 +541,14 @@ const cancel = () => {
   buttonLoading.value = false;
   showEdit.value = false;
 };
-const handleShowDialog = () => {};
+const handleShowDialog = () => {
+  editData.value = {
+    id: '',
+    pattern_name: '',
+    content: currentState.value
+  };
+  showEdit.value = true;
+};
 onMounted(() => {
   getList();
 });
@@ -632,6 +649,7 @@ onMounted(() => {
 .tab-content3 {
   .custom-table {
     width: 100%;
+    color: #000;
     .tr {
       display: flex;
       font-size: 32px;