Browse Source

修复查询窗口2次重复加载的BUG。

yangzhijie 4 năm trước cách đây
mục cha
commit
8aed19071e
2 tập tin đã thay đổi với 28 bổ sung24 xóa
  1. 1 1
      package.json
  2. 27 23
      packages/info/src/InfoWindow.vue

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pc-component-v3",
-  "version": "1.0.6",
+  "version": "1.0.8",
   "description": "",
   "main": "dist/pc-component-v3.js",
   "scripts": {

+ 27 - 23
packages/info/src/InfoWindow.vue

@@ -32,11 +32,10 @@ export default {
   },
 
   props: {
-    'whereClauseSource':
-        {
-          type: Object,
-          default: null,
-        },
+    'whereClauseSource': {
+      type: Object,
+      default: null,
+    },
     'isSearchWidget': {
       type: Boolean,
       default: null,
@@ -56,6 +55,7 @@ export default {
   },
 
   emits: ['dataSelected', 'valueChanged', 'deleteSelected'],
+
   data: function () {
     return {
       'infoWindowNo': '',
@@ -68,24 +68,30 @@ export default {
   watch: {
     '$route': function (to, from) {
       this.getInfoWindowNo();
-      this.loadData();
+    },
+
+    'infoWindowNo': {
+      handler: function(newValue, oldValue){
+        if(newValue != oldValue){
+          this.loadData();
+        }
+      },
+      immediate: true,
     },
   },
 
   mounted: function () {
     this.getInfoWindowNo();
-    this.loadData();
   },
 
   methods: {
     /**
-             * 加载数据
-             */
+     * 加载数据
+     */
     loadData: function () {
-      if (this.infoWindowNo == undefined || this.infoWindowNo.length == 0) {
+      if (this.infoWindowNo == null || this.infoWindowNo.length == 0) {
         return;
       }
-
       var _self = this;
       _self.$refs.loading.show();
       $.ajax({
@@ -127,16 +133,15 @@ export default {
     },
 
     /**
-             * 根据 infoWindowNo 加载数据
-             */
+     * 根据 infoWindowNo 加载数据
+     */
     loadByInfoWindowNo: function (infoWindowNo) {
       this.infoWindowNo = infoWindowNo;
-      this.loadData();
     },
 
     /**
-             * 数据选择事件
-             */
+     * 数据选择事件
+     */
     dataSelected: function (data) {
       this.$emit('dataSelected', data);
     },
@@ -146,15 +151,15 @@ export default {
     },
 
     /**
-             * 数据删除事件
-             */
+     * 数据删除事件
+     */
     deleteSelected: function (data) {
       this.$emit('deleteSelected', data);
     },
 
     /**
-             * 获取选择的数据
-             */
+     * 获取选择的数据
+     */
     getSelectedModelDatas: function (data) {
       var _self = this;
       return _self.$refs.infoComponent.getSelectedModelDatas();
@@ -172,12 +177,11 @@ export default {
     },
 
     /**
-             * 获取查询窗口的编号
-             */
+     * 获取查询窗口的编号
+     */
     getInfoWindowNo: function () {
       if (this.$route.params != undefined) {
         var routeInfoWindowNo = this.$route.params.infoWindowNo;
-
         // 如果是搜索框,那么填充查询窗口编号
         if (this.isSearchWidget != true) {
           this.infoWindowNo = routeInfoWindowNo;