panhui 6 лет назад
Родитель
Сommit
9d523ffbf7
2 измененных файлов с 60 добавлено и 17 удалено
  1. 34 6
      src/main/vue/src/components/VuforiaImageInfo.vue
  2. 26 11
      src/main/vue/src/pages/LandMark.vue

+ 34 - 6
src/main/vue/src/components/VuforiaImageInfo.vue

@@ -103,6 +103,13 @@ export default {
           mapIndex: ''
         }
       }
+    },
+  },
+  watch: {
+    formData() {
+      if (this.originalData.id != this.formData.id) {
+        this.originalData = { ...this.formData };
+      }
     }
   },
   created() {
@@ -180,8 +187,14 @@ export default {
     //     }
     // });
   },
+  mounted() {
+    if (this.originalData.id != this.formData.id) {
+      this.originalData = { ...this.formData };
+    }
+  },
   data() {
     return {
+      originalData: {},
       saving: false,
       rules: {
         vuforiaImageGroupId:
@@ -213,7 +226,7 @@ export default {
         x: this.formData.posX || '',
         y: this.formData.posY || '',
         index: this.formData.mapIndex || "",
-        angle:this.formData.angle||''
+        angle: this.formData.angle || ''
       }
     },
     landmarkId() {
@@ -231,8 +244,8 @@ export default {
     },
     mapAddition() {
       // if (this.areaWidth < 3000) {
-        this.areaWidth += 500
-        this.areaHeight += 500
+      this.areaWidth += 500
+      this.areaHeight += 500
       // }
 
     },
@@ -255,15 +268,30 @@ export default {
       });
     },
     submit() {
-      var data = JSON.parse(JSON.stringify(this.formData));
-      if (data.posX && data.posY && Number(data.posX) < Number(this.$refs.drugAreaContent.width) && Number(data.posY) < Number(this.$refs.drugAreaContent.height)) {
-        data.mapIndex = Number(data.posX) * Number(this.$refs.drugAreaContent.width) + Number(data.posY)
+      var data = {};
+      if(this.formData.id){
+        data.id=this.formData.id
       }
+      for (var key in this.formData) {
+        if (this.formData[key] != this.originalData[key]) {
+          data[key] = this.formData[key];
+
+          if (key == 'posX' || key == 'posY') {
+            if (this.formData.posX && this.formData.posY && Number(this.formData.posX) < Number(this.$refs.drugAreaContent.width) && Number(this.formData.posY) < Number(this.$refs.drugAreaContent.height)) {
+              data.mapIndex = Number(this.formData.posX) * Number(this.$refs.drugAreaContent.width) + Number(this.formData.posY);
+            }
+          }
+        }
+      }
+
+
+
       this.$http.post({
         url: this.formData.id ? '/vuforiaImageInfo/update' : '/vuforiaImageInfo/save',
         data: data
       }).then(res => {
         if (res.success) {
+          this.originalData = { ...this.formData };
           this.$message.success('成功');
           this.$emit('hide')
           this.$emit('update')

+ 26 - 11
src/main/vue/src/pages/LandMark.vue

@@ -9,7 +9,7 @@
             </el-form-item>
             <el-form-item prop="ownedCityId" label="所属城市Id">
               <template>
-                <el-select v-model="formData.ownedCityId" clearable filterable  placeholder="请选择" :disabled="'ownedCityId'==subColumn">
+                <el-select v-model="formData.ownedCityId" clearable filterable placeholder="请选择" :disabled="'ownedCityId'==subColumn">
                   <el-option v-for="item in ownedCityIdOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                 </el-select>
               </template>
@@ -74,7 +74,7 @@
             </el-form-item>
             <el-form-item prop="vuforiaDataName" label="识别图集名称">
               <template>
-                <el-select v-model="formData.vuforiaImageGroupId" filterable   clearable placeholder="请选择" @change="changeVuforiaImageGroup">
+                <el-select v-model="formData.vuforiaImageGroupId" filterable clearable placeholder="请选择" @change="changeVuforiaImageGroup">
                   <el-option v-for="(item,index) in vuforiaImageGroupList" :key="item.id" :label="item.vuforiaDataName" :value="item.id"></el-option>
                 </el-select>
               </template>
@@ -145,7 +145,7 @@
               </el-form-item>
               <el-form-item prop="frontLevelId" label="上级地标ID">
                 <template>
-                  <el-select v-model="formData.frontLevelId" clearable  filterable  placeholder="请选择" :disabled="'frontLevelId'==subColumn">
+                  <el-select v-model="formData.frontLevelId" clearable filterable placeholder="请选择" :disabled="'frontLevelId'==subColumn">
                     <el-option v-for="item in frontLevelIdOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                   </el-select>
                 </template>
@@ -232,6 +232,8 @@ export default {
 
           this.formData = res.data;
 
+          this.originalData = { ...res.data };
+
           if (this.$route.query.column) {
             this.formData[this.subColumn] = this.subValue;
           }
@@ -300,7 +302,7 @@ export default {
   },
   data() {
     return {
-
+      originalData: {},
       saving: false,
       formData: {
         latitude: 32.05838,
@@ -388,19 +390,32 @@ export default {
       });
     },
     submit() {
-      var data = JSON.parse(JSON.stringify(this.formData));
-      data.keyword = data.keyword.join();
-  const loading = this.$loading({
-          lock: true,
-        });
-      
+      var data ={};
+       if(this.formData.id){
+        data.id=this.formData.id
+      }
+      for (var key in this.formData) {
+        if (this.formData[key] != this.originalData[key]) {
+          data[key] = this.formData[key];
+          if (key == 'keyword') {
+            data[key] = data[key].join();
+          }
+        }
+      }
+      console.log(data)
+
+      const loading = this.$loading({
+        lock: true,
+      });
+
       this.$http.post({
         url: this.formData.id ? '/landMark/update' : '/landMark/save',
         data: data
       }).then(res => {
-      loading.close();
+        loading.close();
         if (res.success) {
           this.$message.success('成功');
+          this.originalData={...this.formData};
           if (!this.formData.id) {
             this.$router.replace({
               name: '',