ソースを参照

修改查询窗口渲染

xlj_bule 4 年 前
コミット
a126499cfc
1 ファイル変更24 行追加74 行削除
  1. 24 74
      packages/info/src/InfoWindow.vue

+ 24 - 74
packages/info/src/InfoWindow.vue

@@ -89,7 +89,6 @@ export default {
   },
 
   mounted: function () {
-    this.getModules();
   },
 
   methods: {
@@ -114,16 +113,19 @@ export default {
           _self.loading = false;
           console.log(data);
           _self.infoWindowDto = data;
-          _self.dynamicInit();
+          
 
           // 计算显示的部件
           if (_self.infoWindowDto.componentName != undefined && _self.infoWindowDto.componentName != '') {
             _self.componentName = _self.infoWindowDto.componentName;
+            _self.dynamicInit();
           } else if (_self.infoWindowDto.infoWindowType == undefined || _self.infoWindowDto.infoWindowType == 'TableGrid'
               || _self.infoWindowDto.infoWindowType == 'NONE') {
             _self.componentName = 'QueryPage';
           }
 
+          
+
           _self.$nextTick(function () {
             if (_self.infoWindowDto.componentName == undefined || _self.infoWindowDto.componentName == '') {
               if (_self.infoWindowDto.infoWindowType == undefined || _self.infoWindowDto.infoWindowType == 'TableGrid' || _self.infoWindowDto.infoWindowType == 'NONE') {
@@ -151,23 +153,27 @@ export default {
       // 如果url是变量,举例const url = '', webpack打包的时候,原理不清晰...,测试结果时浏览器不会发出http请求加载后端的js文件。
       // const jsUrl = '' + '/DictionaryBase/Dashboard/BASE/2020080401.js';
       // const jsUrl = '/DictionaryAsset/Dashboard/EAM/20220309_095250.js';
-      const cssUrl = _self.getCssUrlByInfoWindow(_self.infoWindowDto);
-      _self.dynamicLoadCss(cssUrl);
-      const jsUrl = _self.getJsUrlByInfoWindow(_self.infoWindowDto);
-      let command = `import('${jsUrl}').then(remoteComponent => {
-      console.log('remoteComponent:' + remoteComponent.default, remoteComponent.default.name);
-        console.log('remoteComponent:' + remoteComponent.default, remoteComponent.default.name);
-          app.component(remoteComponent.default.name, remoteComponent.default);
-          var item = {
-              id: remoteComponent.default.name,
-              componentName: remoteComponent.default.name
+      const componentName = _self.infoWindowDto.componentName;
+      const cssUrl = _self.infoWindowDto.cssUrl;
+      if(cssUrl != null && cssUrl != undefined){
+        _self.dynamicLoadCss('${cssUrl}');
+      }
+      const jsUrl = _self.infoWindowDto.jsUrl;
+      if(jsUrl != null && jsUrl != undefined){
+        let command = `import('${jsUrl}').then(remoteComponent => {
+          if('${componentName}' !== remoteComponent.default.name){
+            let errorMessage = '数据字典-查询窗口自定义组件部件名称定义的是' + '${componentName}' + ',但是程序中name定义的是' + remoteComponent.default.name + ',两者必须相同。';
+            console.error(errorMessage);
+            Notify.error('查询窗口自定义组件定义错误', errorMessage, false);
+          }else{
+            app.component('${componentName}', remoteComponent.default);
           }
-          _self.componentName = item.componentName;
-          console.log(item);
-      }).catch(error => {
-          console.error(error);
-      });`;
-      eval(command);
+          _self.componentName = '${componentName}';
+        }).catch(error => {
+            console.error(error);
+        });`;
+        eval(command);
+      }
     },
 
     /**
@@ -182,62 +188,6 @@ export default {
       head.appendChild(link);
     },
 
-    /**
-    * [getModules 获取模块]
-    * @return {[type]} [description]
-    */
-    getModules: function () {
-      var _self = this;
-      $.ajax({
-        url: Common.getApiURL('moduleResource/getModuleDtos'),
-        type: 'get',
-        dataType: 'json',
-        beforeSend: function (request) {
-          Common.addTokenToRequest(request);
-        },
-        success: function (data) {
-          _self.moduleDtos = data;
-        },
-        error: function (XMLHttpRequest, textStatus, errorThrown) {
-          Common.processException(XMLHttpRequest, textStatus, errorThrown);
-        },
-      });
-    },
-
-
-    /**
-      * 根据模块编号查询jsUrl
-      * @param {Object} infoWindow
-      */
-    getJsUrlByInfoWindow: function (infoWindow) {
-      var _self = this;
-      var jsUrl = null;
-      var result = _self.moduleDtos.filter(v => v.no === infoWindow.moduleNo);
-      if (result != null && result.length > 0) {
-        var item = result[0];
-        jsUrl = '/' + item.dictionaryName + '/InfoWindow/' + item.no + '/' + infoWindow.no + '.js';
-      }
-      return jsUrl;
-
-    },
-
-
-
-    /**
-      * 根据模块编号查询Css Url
-      * @param {Object} infoWindow
-      */
-    getCssUrlByInfoWindow: function (infoWindow) {
-      var _self = this;
-      var cssUrl = null;
-      var result = _self.moduleDtos.filter(v => v.no === infoWindow.moduleNo);
-      if (result != null && result.length > 0) {
-        var item = result[0];
-        cssUrl = '/' + item.dictionaryName + '/InfoWindow/' + item.no + '/' + infoWindow.no + '.css';
-      }
-      return cssUrl;
-    },
-
     /**
          * 数据选择事件
          */