Ver código fonte

表单重置

soft5566 2 anos atrás
pai
commit
f0678be508
1 arquivos alterados com 35 adições e 17 exclusões
  1. 35 17
      src/views/perimeterMgr/index.vue

+ 35 - 17
src/views/perimeterMgr/index.vue

@@ -496,7 +496,7 @@
 				</el-row>
 			</div>
 		</el-dialog>
-		<el-dialog title="地图" :visible.sync="dialogMapVisible" width="60%">
+		<el-dialog title="地图" v-if="dialogMapVisible" :visible.sync="dialogMapVisible" width="60%">
 			<baidu-map style="width: 100%; height: 450px;" :center="center" :zoom="zoom" @click="handleMapClick">
 				<bm-marker :position="markerPosition"></bm-marker>
 			</baidu-map>
@@ -970,20 +970,46 @@
 
 			document.addEventListener('fullscreenchange', this.handleFullScreenChange);
 		},
+		watch: {
+			dialogAddVisible(newVal, oldVal) {
+				if (newVal == true) {
+					this.$nextTick(() => {
+						this.$refs.addDialogForm.resetFields(); // 重置表单
+					});
+				}
+			},
+			dialogAddProductVisible(newVal, oldVal) {
+				if (newVal == true) {
+					this.$nextTick(() => {
+						this.$refs.addProductForm.resetFields();
+					});
+				}
+			}
+		},
 		beforeDestroy() {
 			document.removeEventListener('fullscreenchange', this.handleFullScreenChange);
 		},
 		methods: {
 			showMapDialog() {
-				this.zoom = 13
-				this.center = {
-					lng: 115.36400612205159,
-					lat: 28.850799952953487
-				}
-				this.markerPosition = {
-					lng: 115.36400612205159,
-					lat: 28.850799952953487
+				this.$set(this.zoom, 13)
+
+				if (this.dialogAddVisible) {
+					var t = this.formAddDialog.jingwei.split(',')
+					this.$set(this.center, 'lng', t[0])
+					this.$set(this.center, 'lat', t[1])
+
+					this.$set(this.markerPosition, 'lng', t[0])
+					this.$set(this.markerPosition, 'lat', t[1])
+
+				} else if (this.dialogModifyVisible) {
+					var t = this.formModifyDialog.jingwei.split(',')
+					this.$set(this.center, 'lng', t[0])
+					this.$set(this.center, 'lat', t[1])
+
+					this.$set(this.markerPosition, 'lng', t[0])
+					this.$set(this.markerPosition, 'lat', t[1])
 				}
+
 				this.dialogMapVisible = true;
 			},
 			handleMapClick(e) {
@@ -1259,10 +1285,6 @@
 				// this.$set(this.formAddProduct, 'product_name', '')
 				// this.$set(this.formAddProduct, 'product_desc', '')
 				// this.$set(this.formAddProduct, 'price', '')
-				
-				this.$nextTick(() => {
-					this.$refs.addProductForm.resetFields();
-				})
 
 				this.dialogAddProductVisible = true
 			},
@@ -1352,10 +1374,6 @@
 				// this.$set(this.formAddDialog, 'detail_img', [1, 2])
 				// this.detail_img_array = []
 
-				this.$nextTick(() => {
-					this.$refs["addDialogForm"].resetFields(); // 重置表单
-				});
-
 				this.dialogAddVisible = true
 			},
 			/**