|
|
@@ -0,0 +1,86 @@
|
|
|
+<template>
|
|
|
+ <div id="lowcode-box" />
|
|
|
+</template>
|
|
|
+
|
|
|
+
|
|
|
+<script>
|
|
|
+
|
|
|
+// 这样打包会打进来
|
|
|
+// import 'lowcode/sdk/sdk.js';
|
|
|
+// import 'lowcode/lib/themes/antd.css';
|
|
|
+// import 'lowcode/lib/helper.css';
|
|
|
+// import 'lowcode/sdk/iconfont.css';
|
|
|
+import { lowcodeConfig } from './LowcodeConfig.js';
|
|
|
+
|
|
|
+import LowcodeWindowResource from './LowcodeWindowResource.js';
|
|
|
+import Common from '../../common/Common.js';
|
|
|
+import Notify from '../../common/Notify.js';
|
|
|
+
|
|
|
+export default {
|
|
|
+
|
|
|
+ name: 'LowcodeWidget',
|
|
|
+
|
|
|
+ props: {
|
|
|
+ lowcodeWindowNo: {
|
|
|
+ type: String,
|
|
|
+ default: null,
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+ watch: {
|
|
|
+ 'lowcodeWindowNo': function (to, from) {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ let _self = this;
|
|
|
+ this.$nextTick(function () {
|
|
|
+ _self.init();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化lowcode实例
|
|
|
+ */
|
|
|
+ init() {
|
|
|
+ if (this.lowcodeWindowNo == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化lowcode实例之前,先判断是否已经有lowcode实例,如果有的话就销毁。
|
|
|
+ this.destory();
|
|
|
+
|
|
|
+ let lowcode = window.lowcodeRequire('lowcode/embed');
|
|
|
+ let _self = this;
|
|
|
+
|
|
|
+ LowcodeWindowResource.readJson(this.lowcodeWindowNo).then(baseObjectResponse => {
|
|
|
+ if (baseObjectResponse.errorCode === 0) {
|
|
|
+ let lowcodeJSON = JSON.parse(baseObjectResponse.data);
|
|
|
+ _self.lowcodeScoped = lowcode.embed('#lowcode-box', lowcodeJSON, {}, lowcodeConfig);
|
|
|
+ } else {
|
|
|
+ Notify.error('提示', baseObjectResponse.errorMessage, false);
|
|
|
+ }
|
|
|
+ }, errorData => {
|
|
|
+ Common.processException(errorData);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 销毁lowcode实例
|
|
|
+ */
|
|
|
+ destory(){
|
|
|
+ let _self = this;
|
|
|
+ if(_self.lowcodeScoped != null){
|
|
|
+ _self.lowcodeScoped.unmount();
|
|
|
+ _self.lowcodeScoped = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|