|
|
@@ -11,6 +11,9 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
var Common = require('../../common/Common.js').default;
|
|
|
+var Notify = require('../../common/Notify.js').default;
|
|
|
+var CssUtil = require('../../common/CssUtil.js').default;
|
|
|
+var JsUtil = require('../../common/JsUtil.js').default;
|
|
|
var QueryPage = require('./QueryPage.vue').default;
|
|
|
var Loading = require('../../loading/src/Loading.vue').default;
|
|
|
var ClientOrganization = require('../../client-organization/src/ClientOrganization.vue').default;
|
|
|
@@ -113,7 +116,6 @@ export default {
|
|
|
_self.loading = false;
|
|
|
console.log(data);
|
|
|
_self.infoWindowDto = data;
|
|
|
-
|
|
|
|
|
|
// 计算显示的部件
|
|
|
if (_self.infoWindowDto.componentName != undefined && _self.infoWindowDto.componentName != '') {
|
|
|
@@ -124,8 +126,6 @@ export default {
|
|
|
_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') {
|
|
|
@@ -144,50 +144,35 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 动态初始化仪表盘
|
|
|
- */
|
|
|
+ * 动态初始化仪表盘
|
|
|
+ */
|
|
|
dynamicInit: function () {
|
|
|
let _self = this;
|
|
|
- // 注意:在webpack中直接使用import(url).then()会错误的解析url。
|
|
|
- // 如果url是静态的值,举例'xxx.js', webpack打包的时候,会去src对应的目录下面找js文件。
|
|
|
- // 如果url是变量,举例const url = '', webpack打包的时候,原理不清晰...,测试结果时浏览器不会发出http请求加载后端的js文件。
|
|
|
- // const jsUrl = '' + '/DictionaryBase/Dashboard/BASE/2020080401.js';
|
|
|
- // const jsUrl = '/DictionaryAsset/Dashboard/EAM/20220309_095250.js';
|
|
|
+
|
|
|
const componentName = _self.infoWindowDto.componentName;
|
|
|
const cssUrl = _self.infoWindowDto.cssUrl;
|
|
|
+
|
|
|
if(cssUrl != null && cssUrl != undefined){
|
|
|
- _self.dynamicLoadCss('${cssUrl}');
|
|
|
+ CssUtil.dynamicLoadCss(cssUrl, componentName);
|
|
|
}
|
|
|
+
|
|
|
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 + ',两者必须相同。';
|
|
|
+ let promise = JsUtil.dynamicLoadJsModule(jsUrl);
|
|
|
+ promise.then(remoteComponent => {
|
|
|
+ console.log('remoteComponent:' + remoteComponent.default.name);
|
|
|
+ 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 = '${componentName}';
|
|
|
- }).catch(error => {
|
|
|
- console.error(error);
|
|
|
- });`;
|
|
|
- eval(command);
|
|
|
+ window.app.component(componentName, remoteComponent.default);
|
|
|
+ }, errorData => {
|
|
|
+ console.error(errorData);
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * 动态加载CSS
|
|
|
- */
|
|
|
- dynamicLoadCss: function (url) {
|
|
|
- var head = document.getElementsByTagName('head')[0];
|
|
|
- var link = document.createElement('link');
|
|
|
- link.type='text/css';
|
|
|
- link.rel = 'stylesheet';
|
|
|
- link.href = url;
|
|
|
- head.appendChild(link);
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* 数据选择事件
|
|
|
*/
|