sun-form-v3 1.0.70 → 1.0.72
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/abap-DfvySaIJ.js +1404 -0
- package/dist/apex-B__0irD3.js +332 -0
- package/dist/assets/css.worker-OK053IOu.js +84 -0
- package/dist/assets/editor.worker-D9iUZyMP.js +11 -0
- package/dist/assets/html.worker-CL40hqKM.js +458 -0
- package/dist/assets/json.worker-6f9bhSHY.js +42 -0
- package/dist/assets/ts.worker-B6g3wjaE.js +37021 -0
- package/dist/azcli-CDMGhRmx.js +74 -0
- package/dist/bat-0Mk8aqzx.js +106 -0
- package/dist/bicep-BBi_I06Z.js +108 -0
- package/dist/cameligo-D0G_Zm6X.js +180 -0
- package/dist/clojure-o2ZKLeMp.js +767 -0
- package/dist/coffee-DOQff5VC.js +238 -0
- package/dist/cpp-CQGJnWhD.js +395 -0
- package/dist/csharp-C1jLsHl8.js +332 -0
- package/dist/csp-C_ttMQaW.js +59 -0
- package/dist/css-BC202kVV.js +193 -0
- package/dist/cssMode-D3INtz5D.js +1541 -0
- package/dist/cypher-DwtEH7Fi.js +269 -0
- package/dist/dart-D9XknsP2.js +287 -0
- package/dist/dockerfile-DgsNjqqa.js +136 -0
- package/dist/ecl-BAMCHBl6.js +462 -0
- package/dist/elixir-CegIttP8.js +575 -0
- package/dist/favicon.ico +0 -0
- package/dist/flow9-9608t7UV.js +148 -0
- package/dist/freemarker2-hasIzj0A.js +995 -0
- package/dist/fsharp-CCtt9-1_.js +223 -0
- package/dist/go-CGUIPbct.js +224 -0
- package/dist/graphql-BNRIFFIn.js +157 -0
- package/dist/handlebars-Cqza9dif.js +425 -0
- package/dist/hcl-C__KLIXe.js +189 -0
- package/dist/html-QpDlLWtS.js +314 -0
- package/dist/htmlMode-3p93KT8l.js +1551 -0
- package/dist/index2-jkDcibEo.js +120443 -0
- package/dist/ini-CeKYn_zA.js +77 -0
- package/dist/java-Dm24deQl.js +238 -0
- package/dist/javascript-CSPB5Brm.js +76 -0
- package/dist/jsonMode-qA6pURD0.js +1957 -0
- package/dist/julia-BImNW7VE.js +517 -0
- package/dist/kotlin-BfE79GEb.js +259 -0
- package/dist/less-DglNOcaC.js +168 -0
- package/dist/lexon-BA0dRz9Q.js +163 -0
- package/dist/liquid-BWuASSim.js +246 -0
- package/dist/lua-DMkWzJcm.js +168 -0
- package/dist/m3-sA-5shO8.js +216 -0
- package/dist/markdown-OYRB1igA.js +235 -0
- package/dist/mdx-CnHJXO9F.js +171 -0
- package/dist/mips-rRzkJ_7G.js +204 -0
- package/dist/msdax-DoVJdUhd.js +381 -0
- package/dist/mysql-Ty44IHXo.js +884 -0
- package/dist/objective-c-VUfyhYrA.js +189 -0
- package/dist/pascal-DkASiYyw.js +257 -0
- package/dist/pascaligo-p-ELPlVO.js +170 -0
- package/dist/perl-Cjl1FxLZ.js +632 -0
- package/dist/pgsql-DjVenF7s.js +857 -0
- package/dist/php-CwvGzZOO.js +506 -0
- package/dist/pla-Br1iaBIV.js +143 -0
- package/dist/postiats-BaeP8zZY.js +913 -0
- package/dist/powerquery-CLCshuo8.js +896 -0
- package/dist/powershell-CZV50w5N.js +245 -0
- package/dist/protobuf-MV3XTewJ.js +426 -0
- package/dist/pug-DkDg4c4l.js +408 -0
- package/dist/python-CRYsEVap.js +282 -0
- package/dist/qsharp-BAtiKA97.js +291 -0
- package/dist/r-8ocrd-h-.js +249 -0
- package/dist/razor-DyEtGntt.js +556 -0
- package/dist/redis-9sZiddxc.js +308 -0
- package/dist/redshift-DQfTOGC0.js +815 -0
- package/dist/restructuredtext-DXU-vkgr.js +180 -0
- package/dist/ruby-DotfqwMf.js +517 -0
- package/dist/rust-BIauJ5KN.js +349 -0
- package/dist/sb-CmWMvDEV.js +121 -0
- package/dist/scala-C81brEbk.js +376 -0
- package/dist/scheme-D0pcFz2x.js +114 -0
- package/dist/scss-BOdN2fGG.js +268 -0
- package/dist/shell-6E09eAkU.js +227 -0
- package/dist/solidity-CWStzA1K.js +1373 -0
- package/dist/sophia-76Sb6CWe.js +205 -0
- package/dist/sparql-BmZTkOWT.js +207 -0
- package/dist/sql-Cs9TBAW5.js +859 -0
- package/dist/st-B-rqE1Bu.js +422 -0
- package/dist/style.css +1 -0
- package/dist/sun-form-v3.es.js +4 -0
- package/dist/sun-form-v3.umd.js +1902 -0
- package/dist/swift-Btsj6YxQ.js +318 -0
- package/dist/systemverilog-B3RHBRa2.js +582 -0
- package/dist/tcl-Dpj776pn.js +238 -0
- package/dist/tsMode-BrlIPEQw.js +885 -0
- package/dist/twig-Bb9JmBsE.js +398 -0
- package/dist/typescript-CYTudnTM.js +349 -0
- package/dist/typespec-CDWeg3SU.js +123 -0
- package/dist/vb-DEXnYwEI.js +378 -0
- package/dist/wgsl-D602c1lx.js +445 -0
- package/dist/xml-B-x5164u.js +101 -0
- package/dist/yaml-Buq2hM65.js +212 -0
- package/package.json +5 -8
- package/src/App.vue +0 -9
- package/src/assets/font/YouSheBiaoTiHei-2.ttf +0 -0
- package/src/assets/font/demo.css +0 -539
- package/src/assets/font/demo_index.html +0 -1200
- package/src/assets/font/iconfont.css +0 -191
- package/src/assets/font/iconfont.js +0 -1
- package/src/assets/font/iconfont.json +0 -317
- package/src/assets/font/iconfont.ttf +0 -0
- package/src/assets/font/iconfont.woff +0 -0
- package/src/assets/font/iconfont.woff2 +0 -0
- package/src/assets/img/bg_footer.png +0 -0
- package/src/assets/img/bg_title.png +0 -0
- package/src/assets/img/file.png +0 -0
- package/src/assets/img/logo.png +0 -0
- package/src/assets/img/logo2.png +0 -0
- package/src/assets/img/logo22.png +0 -0
- package/src/assets/img/logo23.png +0 -0
- package/src/assets/img/logo3.png +0 -0
- package/src/assets/img//347/237/251/345/275/242@2x.png +0 -0
- package/src/assets/logo.svg +0 -1
- package/src/assets/styles/element/index.scss +0 -15
- package/src/assets/styles/index.css +0 -3
- package/src/components/a.js +0 -14
- package/src/components/aDesigner/config.vue +0 -127
- package/src/components/aDesigner/design.vue +0 -20
- package/src/components/aDesigner/designer.js +0 -342
- package/src/components/aDesigner/http.js +0 -292
- package/src/components/aDesigner/index.vue +0 -144
- package/src/components/aDesigner/panel.vue +0 -144
- package/src/components/aDesigner/show.vue +0 -24
- package/src/components/widgetCommonComps/commonApiConfig/index.vue +0 -194
- package/src/components/widgetCommonComps/commonCard/index.vue +0 -36
- package/src/components/widgetCommonComps/commonCodeEditor/editor.vue +0 -219
- package/src/components/widgetCommonComps/commonCodeEditor/modalEditor.vue +0 -68
- package/src/components/widgetCommonComps/commonCollapseCard/index.vue +0 -10
- package/src/components/widgetCommonComps/commonContainer/index.vue +0 -95
- package/src/components/widgetCommonComps/commonJsonInput/index.vue +0 -59
- package/src/components/widgetCommonComps/commonLabelContainer/index.vue +0 -39
- package/src/components/widgetCommonComps/commonSidetree/index.vue +0 -61
- package/src/components/widgetCommonComps/commonTypeInput/index.vue +0 -75
- package/src/components/widgetCommonComps/commonWidgetLabelContainer/index.vue +0 -55
- package/src/components/widgetCommonComps/index copy.js +0 -17
- package/src/components/widgetCommonComps/index.js +0 -17
- package/src/components/widgetConfigComps/config-input/index.vue +0 -60
- package/src/components/widgetConfigComps/index copy.js +0 -13
- package/src/components/widgetConfigComps/index.js +0 -17
- package/src/components/widgetShowComps/index.js +0 -29
- package/src/components/widgetShowComps/widget-form/index.vue +0 -43
- package/src/components/widgetShowComps/widget-homepage/index.vue +0 -41
- package/src/components/widgetShowComps/widget-input/index.vue +0 -85
- package/src/components/widgetShowComps/widget-select/index.vue +0 -31
- package/src/designer.js +0 -342
- package/src/http.js +0 -293
- package/src/index.js +0 -24
- package/src/index2.js +0 -23
- package/src/main.js +0 -19
- package/src/remark.js +0 -708
- package/src/testBtn.vue +0 -11
- package/src/testInput.vue +0 -12
- package/src/util/jsformat.js +0 -568
- package/src/widgetConfig.js +0 -1112
package/src/components/a.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
const modules =
|
2
|
-
import.meta.glob('./test**.vue', {
|
3
|
-
eager: true
|
4
|
-
});
|
5
|
-
console.log('modules',modules);
|
6
|
-
const components = Object.fromEntries(
|
7
|
-
Object.entries(modules).map(([path, module]) => {
|
8
|
-
const componentName = module.default.name
|
9
|
-
return [componentName, module.default];
|
10
|
-
})
|
11
|
-
);
|
12
|
-
export default {
|
13
|
-
...components,
|
14
|
-
};
|
@@ -1,127 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<common-card title="基础属性" class="mb-1">
|
3
|
-
<div class="w-full">
|
4
|
-
<common-label-container label="唯一名称">
|
5
|
-
<el-input v-model="chosenWidget.id" disabled>
|
6
|
-
<template #append>
|
7
|
-
<el-button icon="Refresh" />
|
8
|
-
</template>
|
9
|
-
</el-input>
|
10
|
-
</common-label-container>
|
11
|
-
<common-label-container label="组件标签">
|
12
|
-
<el-input v-model="chosenWidget.props.label">
|
13
|
-
</el-input>
|
14
|
-
</common-label-container>
|
15
|
-
<common-label-container label="字段名称">
|
16
|
-
<el-input v-model="chosenWidget.props.zdname" placeholder="填写会作为表单字段名称">
|
17
|
-
</el-input>
|
18
|
-
</common-label-container>
|
19
|
-
<common-label-container label="默认赋值">
|
20
|
-
<common-type-input v-model="chosenWidget.props.value"></common-type-input>
|
21
|
-
</common-label-container>
|
22
|
-
<common-label-container label="备注内容">
|
23
|
-
<el-input v-model="chosenWidget.props.remark" placeholder="填写会有备注提示内容">
|
24
|
-
</el-input>
|
25
|
-
</common-label-container>
|
26
|
-
<common-label-container label="组件宽度">
|
27
|
-
<el-slider v-model="chosenWidget.props.width" :step="2" show-stops :max="24" :min="6" />
|
28
|
-
</common-label-container>
|
29
|
-
<common-label-container label="标签宽度">
|
30
|
-
<el-input v-model="chosenWidget.props.labelWidth" placeholder="请填写标签信息">
|
31
|
-
</el-input>
|
32
|
-
</common-label-container>
|
33
|
-
<common-label-container label="标签位置">
|
34
|
-
<el-radio-group v-model="chosenWidget.props.labelPosition">
|
35
|
-
<el-radio-button value="left" label="居左"></el-radio-button>
|
36
|
-
<el-radio-button value="top" label="居上"></el-radio-button>
|
37
|
-
</el-radio-group>
|
38
|
-
</common-label-container>
|
39
|
-
<common-label-container label="标签对齐">
|
40
|
-
<el-radio-group v-model="chosenWidget.props.labelAlign">
|
41
|
-
<el-radio-button value="left" label="居左"></el-radio-button>
|
42
|
-
<el-radio-button value="right" label="居右"></el-radio-button>
|
43
|
-
</el-radio-group>
|
44
|
-
</common-label-container>
|
45
|
-
<common-label-container label="是否隐藏">
|
46
|
-
<el-radio-group v-model="chosenWidget.props.hide">
|
47
|
-
<el-radio-button :value="false" label="显示"></el-radio-button>
|
48
|
-
<el-radio-button :value="true" label="隐藏"></el-radio-button>
|
49
|
-
</el-radio-group>
|
50
|
-
</common-label-container>
|
51
|
-
</div>
|
52
|
-
<!-- <common-json-input v-model="data.chosenWidget.props.list"></common-json-input> -->
|
53
|
-
<common-api-config :designer="designer" v-if="chosenWidget.props.apiSet"
|
54
|
-
v-model="chosenWidget.props.apiSet"></common-api-config>
|
55
|
-
<component :ref="chosenWidget.id" :is="getComponent(chosenWidget.type)" :widget="chosenWidget" :designer="designer">
|
56
|
-
</component>
|
57
|
-
</common-card>
|
58
|
-
<common-card title="事件属性">
|
59
|
-
<common-label-container label="onCreated">
|
60
|
-
<modalEditor v-model="chosenWidget.props.onCreated" :params="['widget', 'self', 'app']" :designer="designer">
|
61
|
-
</modalEditor>
|
62
|
-
</common-label-container>
|
63
|
-
<common-label-container label="onMounted">
|
64
|
-
<modalEditor v-model="chosenWidget.props.onMounted" :params="['widget', 'self', 'app']" :designer="designer">
|
65
|
-
</modalEditor>
|
66
|
-
</common-label-container>
|
67
|
-
<common-label-container label="onInput">
|
68
|
-
<modalEditor v-model="chosenWidget.props.onInput" :params="['value', 'widget', 'self', 'app']"
|
69
|
-
:designer="designer">
|
70
|
-
</modalEditor>
|
71
|
-
</common-label-container>
|
72
|
-
<common-label-container label="onChange">
|
73
|
-
<modalEditor v-model="chosenWidget.props.onChange" :params="['value', 'widget', 'self', 'app']"
|
74
|
-
:designer="designer">
|
75
|
-
</modalEditor>
|
76
|
-
</common-label-container>
|
77
|
-
<common-label-container label="onFocus">
|
78
|
-
<modalEditor v-model="chosenWidget.props.onFocus" :params="['value', 'widget', 'self', 'app']"
|
79
|
-
:designer="designer">
|
80
|
-
</modalEditor>
|
81
|
-
</common-label-container>
|
82
|
-
<common-label-container label="onBlur">
|
83
|
-
<modalEditor v-model="chosenWidget.props.onBlur" :params="['value', 'widget', 'self', 'app']"
|
84
|
-
:designer="designer">
|
85
|
-
</modalEditor>
|
86
|
-
</common-label-container>
|
87
|
-
<common-label-container label="onHandle">
|
88
|
-
<modalEditor v-model="chosenWidget.props.onHandle" :params="['widget', 'self', 'app']" :designer="designer">
|
89
|
-
</modalEditor>
|
90
|
-
</common-label-container>
|
91
|
-
</common-card>
|
92
|
-
<!-- <common-code-editor v-model="data.chosenWidget.props.value"></common-code-editor> -->
|
93
|
-
<!-- <modalEditor v-model="data.chosenWidget.props.value"></modalEditor> -->
|
94
|
-
<!-- <CommonTypeInput v-model="data.chosenWidget.props.value"></CommonTypeInput> -->
|
95
|
-
<!-- <common-api-config :designer="designer" v-if="chosenWidget.props.apiSet"
|
96
|
-
v-model="chosenWidget.props.apiSet"></common-api-config>
|
97
|
-
{{ chosenWidget }} -->
|
98
|
-
<!-- {{ designer.widgetConfig }} -->
|
99
|
-
</template>
|
100
|
-
|
101
|
-
<script setup>
|
102
|
-
|
103
|
-
import { ref, reactive, watch, computed, defineAsyncComponent } from 'vue';
|
104
|
-
import commonCodeEditor from '../widgetCommonComps/commonCodeEditor/editor.vue'
|
105
|
-
import modalEditor from '../widgetCommonComps/commonCodeEditor/modalEditor.vue'
|
106
|
-
const modules = import.meta.glob('../widgetConfigComps/**/index.vue');
|
107
|
-
const components = Object.fromEntries(
|
108
|
-
Object.entries(modules).map(([path, importFn]) => {
|
109
|
-
const match = path.match(/\/([^/]+)\/index\.vue$/);
|
110
|
-
const componentName = match ? match[1] : null;
|
111
|
-
return [componentName, defineAsyncComponent(importFn)];
|
112
|
-
})
|
113
|
-
);
|
114
|
-
const getComponent = (type) => {
|
115
|
-
return components['config-' + type] || null;
|
116
|
-
};
|
117
|
-
defineOptions({ name: "config" })
|
118
|
-
let props = defineProps({
|
119
|
-
designer: {
|
120
|
-
type: Object,
|
121
|
-
default: {}
|
122
|
-
}
|
123
|
-
})
|
124
|
-
let designer = props.designer
|
125
|
-
let chosenWidget = computed(() => designer.chosenWidget)
|
126
|
-
</script>
|
127
|
-
<style scoped lang="scss"></style>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<commonContainer class="h-full w-full" :widget="designer.widgetConfig" :designer="designer">
|
3
|
-
<widget-homepage :widget="designer.widgetConfig" :designer="designer"></widget-homepage>
|
4
|
-
</commonContainer>
|
5
|
-
</template>
|
6
|
-
|
7
|
-
<script setup>
|
8
|
-
import { ref, reactive, toRaw, markRaw } from 'vue';
|
9
|
-
let props = defineProps({
|
10
|
-
designer: {
|
11
|
-
type: Object,
|
12
|
-
default: {}
|
13
|
-
}
|
14
|
-
})
|
15
|
-
let designer = props.designer
|
16
|
-
let homeWidget = designer.widgetConfig
|
17
|
-
defineOptions({ name: "design" })
|
18
|
-
</script>
|
19
|
-
|
20
|
-
<style scoped lang="scss"></style>
|
@@ -1,342 +0,0 @@
|
|
1
|
-
import XEUtils from "xe-utils"
|
2
|
-
import Http from './http'
|
3
|
-
import {
|
4
|
-
ElNotification
|
5
|
-
} from 'element-plus'
|
6
|
-
import {
|
7
|
-
reactive,
|
8
|
-
ref,
|
9
|
-
watch
|
10
|
-
} from 'vue'
|
11
|
-
/**
|
12
|
-
* 设计器类,用于管理组件配置和交互
|
13
|
-
* @class Designer
|
14
|
-
* @param {Object} options 初始化选项,包含组件配置
|
15
|
-
*/
|
16
|
-
class Designer {
|
17
|
-
constructor({
|
18
|
-
widgetConfig,
|
19
|
-
showMode = false
|
20
|
-
}) {
|
21
|
-
/**
|
22
|
-
* 渲染器模式
|
23
|
-
*/
|
24
|
-
this.showMode = ref(showMode)
|
25
|
-
/**
|
26
|
-
* 反向响应式的组件配置对象
|
27
|
-
*/
|
28
|
-
this.widgetConfig = reactive(widgetConfig);
|
29
|
-
/**
|
30
|
-
* XEUtils 工具库实例
|
31
|
-
*/
|
32
|
-
this.$utils = XEUtils;
|
33
|
-
/**
|
34
|
-
* 组件映射表,用于快速查找组件
|
35
|
-
*/
|
36
|
-
this.widgetMap = new Map();
|
37
|
-
/**
|
38
|
-
* Vue 实例映射表,用于快速查找 Vue 实例
|
39
|
-
*/
|
40
|
-
this.vueInstanceMap = new Map();
|
41
|
-
/**
|
42
|
-
* 组件ID列表
|
43
|
-
*/
|
44
|
-
this.widgetIds = [];
|
45
|
-
/**
|
46
|
-
* 当前选中的组件引用
|
47
|
-
*/
|
48
|
-
this.chosenWidget = ref(null);
|
49
|
-
/**
|
50
|
-
* 操作历史列表
|
51
|
-
*/
|
52
|
-
this.historyList = [];
|
53
|
-
/**
|
54
|
-
* 操作历史索引
|
55
|
-
*/
|
56
|
-
this.historyIndex = ref(0);
|
57
|
-
/**
|
58
|
-
* 标记是否在操作历史中
|
59
|
-
*/
|
60
|
-
this.isHistory = false;
|
61
|
-
/**
|
62
|
-
* Http服务实例,用于发起请求
|
63
|
-
*/
|
64
|
-
this.$http = new Http({
|
65
|
-
baseUrl: "/api"
|
66
|
-
});
|
67
|
-
/**
|
68
|
-
* 根据组件配置构建组件映射表
|
69
|
-
*/
|
70
|
-
this.buildWidgetMap(this.widgetConfig);
|
71
|
-
/**
|
72
|
-
* 监听组件配置的变化,重建组件映射表,并更新选中组件
|
73
|
-
*/
|
74
|
-
watch(() => this.widgetConfig, (val) => {
|
75
|
-
this.rebuildWidgetMap();
|
76
|
-
this.chosenWidget.value = this.getWidgetById(this.widgetConfig.chosenId);
|
77
|
-
}, {
|
78
|
-
deep: true,
|
79
|
-
immediate: true
|
80
|
-
});
|
81
|
-
/**
|
82
|
-
* 监听组件列表的变化,记录操作历史
|
83
|
-
*/
|
84
|
-
watch(() => this.widgetConfig.widgetList, (val) => {
|
85
|
-
if (!this.isHistory) {
|
86
|
-
this.historyList.push({
|
87
|
-
widgetConfig: this.$utils.clone(this.widgetConfig, true),
|
88
|
-
time: this.$utils.toDateString(new Date(), 'HH:mm:ss'),
|
89
|
-
index: this.historyList.length
|
90
|
-
});
|
91
|
-
this.historyIndex.value = this.historyList.length - 1;
|
92
|
-
} else {
|
93
|
-
this.isHistory = false;
|
94
|
-
}
|
95
|
-
}, {
|
96
|
-
deep: true,
|
97
|
-
immediate: true
|
98
|
-
});
|
99
|
-
}
|
100
|
-
eventHandle({
|
101
|
-
value = null,
|
102
|
-
eventType,
|
103
|
-
widget,
|
104
|
-
tableItemData
|
105
|
-
}) {
|
106
|
-
if (!this.showMode) return;
|
107
|
-
if (widget.props[eventType]) {
|
108
|
-
let funcstr = widget.props[eventType]
|
109
|
-
let func = new Function('value', 'widget','self','app', funcstr);
|
110
|
-
func(value, widget, this.getVueInstance(widget.id), this)
|
111
|
-
}
|
112
|
-
}
|
113
|
-
/**
|
114
|
-
* 设置vue实例
|
115
|
-
*/
|
116
|
-
setVueIncetance(id, vueInstance) {
|
117
|
-
this.vueInstanceMap.set(id, vueInstance);
|
118
|
-
}
|
119
|
-
/**
|
120
|
-
* 获取vue实例
|
121
|
-
*/
|
122
|
-
getVueInstance(id) {
|
123
|
-
return this.vueInstanceMap.get(id);
|
124
|
-
}
|
125
|
-
/**
|
126
|
-
* 设置当前选中的组件
|
127
|
-
* @param {Object} chosenWidget 选中的组件对象
|
128
|
-
*/
|
129
|
-
setChosenWidget(chosenWidget) {
|
130
|
-
this.chosenWidget.value = chosenWidget;
|
131
|
-
}
|
132
|
-
/**
|
133
|
-
* 根据组件的apiSet配置发起请求
|
134
|
-
* @param {Object} widget 当前组件对象
|
135
|
-
*/
|
136
|
-
requestByApisetConfig(widget) {
|
137
|
-
let apiSet = widget.props.apiSet;
|
138
|
-
if (!apiSet || !apiSet.apiurl) {
|
139
|
-
return;
|
140
|
-
}
|
141
|
-
let params = {};
|
142
|
-
let headers = {};
|
143
|
-
let method = apiSet.method;
|
144
|
-
if (apiSet.contentType == "FormData") {
|
145
|
-
if (method == "post" || method == "put" || method == "patch") {
|
146
|
-
method += "FormData";
|
147
|
-
}
|
148
|
-
}
|
149
|
-
if (apiSet.params.length) {
|
150
|
-
apiSet.params.forEach(e => {
|
151
|
-
params[e.label] = e.value;
|
152
|
-
});
|
153
|
-
}
|
154
|
-
if (apiSet.headers.length) {
|
155
|
-
apiSet.headers.forEach(e => {
|
156
|
-
headers[e.label] = e.value;
|
157
|
-
});
|
158
|
-
}
|
159
|
-
if (apiSet.paramsFormat) {
|
160
|
-
let fun = new Function("params", "widget", "app", apiSet.paramsFormat);
|
161
|
-
let paramData = this.$utils.clone(params, true);
|
162
|
-
var funcData = fun(paramData, widget, this);
|
163
|
-
if (funcData && typeof this.$utils.isPlainObject(funcData)) {
|
164
|
-
params = funcData;
|
165
|
-
}
|
166
|
-
}
|
167
|
-
if (apiSet.headersFormat) {
|
168
|
-
let fun = new Function("headers", "widget", "app", apiSet.headersFormat);
|
169
|
-
let headerData = this.$utils.clone(headers, true);
|
170
|
-
var funcData = fun(headerData, widget, this);
|
171
|
-
if (funcData && typeof this.$utils.isPlainObject(funcData)) {
|
172
|
-
headers = funcData;
|
173
|
-
}
|
174
|
-
}
|
175
|
-
this.$http[method](apiSet.apiurl, params, headers)
|
176
|
-
.then(res => {
|
177
|
-
if (apiSet.successFormat) {
|
178
|
-
let fun = new Function("res", "widget", "app", apiSet.successFormat);
|
179
|
-
fun(res, widget, this);
|
180
|
-
}
|
181
|
-
})
|
182
|
-
.catch(err => {
|
183
|
-
if (apiSet.errorFormat) {
|
184
|
-
let fun = new Function("error", "widget", "app", apiSet.errorFormat);
|
185
|
-
fun(err, widget, this);
|
186
|
-
}
|
187
|
-
});
|
188
|
-
}
|
189
|
-
/**
|
190
|
-
* 根据ID获取组件
|
191
|
-
* @param {String} id 组件ID
|
192
|
-
* @returns {Object|null} 组件对象或null(如果未找到)
|
193
|
-
*/
|
194
|
-
getWidgetById(id) {
|
195
|
-
return this.widgetMap.get(id);
|
196
|
-
}
|
197
|
-
/**
|
198
|
-
* 根据历史索引更新组件配置
|
199
|
-
* @param {Object} updates 更新的对象
|
200
|
-
*/
|
201
|
-
updateByHistory(updates) {
|
202
|
-
this.isHistory = true;
|
203
|
-
this.$utils.destructuring(this.widgetConfig, updates);
|
204
|
-
}
|
205
|
-
/**
|
206
|
-
* 更新组件的属性
|
207
|
-
* @param {String} id 组件ID
|
208
|
-
* @param {Object} updates 更新的对象
|
209
|
-
* @param {Boolean} force 是否强制更新,即使存在相同的ID
|
210
|
-
*/
|
211
|
-
updateWidget(id, updates, force) {
|
212
|
-
const widget = this.getWidgetById(id);
|
213
|
-
if (widget) {
|
214
|
-
console.log('widget', widget);
|
215
|
-
console.log('updates', updates);
|
216
|
-
if (widget.id !== updates.id) {
|
217
|
-
if (this.widgetIds.includes(updates.id) && !force) {
|
218
|
-
ElNotification.warning('已经存在相同的id的组件,组件id不允许重复');
|
219
|
-
return;
|
220
|
-
}
|
221
|
-
}
|
222
|
-
if (id === 'homepage') {
|
223
|
-
if (updates.id !== id) {
|
224
|
-
ElNotification.warning('主页面的id不允许修改');
|
225
|
-
}
|
226
|
-
updates.id = updates.type = 'homepage';
|
227
|
-
}
|
228
|
-
this.$utils.destructuring(widget, updates);
|
229
|
-
} else {
|
230
|
-
console.warn(`Widget with id ${id} not found.`);
|
231
|
-
}
|
232
|
-
}
|
233
|
-
/**
|
234
|
-
* 重建组件映射表
|
235
|
-
*/
|
236
|
-
rebuildWidgetMap() {
|
237
|
-
this.widgetMap.clear();
|
238
|
-
this.widgetIds = [];
|
239
|
-
this.buildWidgetMap(this.widgetConfig);
|
240
|
-
}
|
241
|
-
/**
|
242
|
-
* 递归构建组件映射表
|
243
|
-
* @param {Object} widget 当前组件对象
|
244
|
-
*/
|
245
|
-
buildWidgetMap(widget) {
|
246
|
-
this.widgetMap.set(widget.id, widget);
|
247
|
-
this.widgetIds.push(widget.id);
|
248
|
-
if (widget.widgetList && widget.widgetList.length) {
|
249
|
-
widget.widgetList.forEach(widget => {
|
250
|
-
this.buildWidgetMap(widget);
|
251
|
-
});
|
252
|
-
}
|
253
|
-
}
|
254
|
-
/**
|
255
|
-
* 设置当前选中的组件ID
|
256
|
-
* @param {String} id 组件ID
|
257
|
-
*/
|
258
|
-
setChosenId(id) {
|
259
|
-
this.widgetConfig.chosenId = id;
|
260
|
-
}
|
261
|
-
/**
|
262
|
-
* 获取当前选中的组件ID
|
263
|
-
* @returns {String} 当前选中的组件ID
|
264
|
-
*/
|
265
|
-
getChosenId() {
|
266
|
-
return this.widgetConfig.chosenId;
|
267
|
-
}
|
268
|
-
/**
|
269
|
-
* 获取初始化的数据对象
|
270
|
-
* @param {Object} obj 初始数据对象
|
271
|
-
* @returns {Object} 处理后的初始数据对象
|
272
|
-
*/
|
273
|
-
getChosenInitData(obj) {
|
274
|
-
obj = this.$utils.clone(obj, true);
|
275
|
-
obj.id = this.getUniqueId(obj.type);
|
276
|
-
this.setChosenId(obj.id);
|
277
|
-
let delkeyArr = ['isForm', 'canAddDataTableQuery', 'canAddDataTableList', 'addToPanel', 'active'];
|
278
|
-
let delkey = (key) => {
|
279
|
-
delete obj[key];
|
280
|
-
}
|
281
|
-
delkeyArr.forEach(e => {
|
282
|
-
delkey(e);
|
283
|
-
});
|
284
|
-
return obj;
|
285
|
-
}
|
286
|
-
/**
|
287
|
-
* 生成唯一的ID
|
288
|
-
* @param {String} prefix ID前缀
|
289
|
-
* @returns {String} 唯一的ID
|
290
|
-
*/
|
291
|
-
getUniqueId(prefix) {
|
292
|
-
return prefix + '_' + Math.floor(new Date().getTime() % 100000) + "" + this.$utils.uniqueId();
|
293
|
-
}
|
294
|
-
/**
|
295
|
-
* 获取组件列表
|
296
|
-
* @returns {Array} 组件列表
|
297
|
-
*/
|
298
|
-
getWidgetList() {
|
299
|
-
return this.widgetConfig.widgetList;
|
300
|
-
}
|
301
|
-
/**
|
302
|
-
* 获取组件配置
|
303
|
-
* @returns {Object} 组件配置对象
|
304
|
-
*/
|
305
|
-
getWidgetConfig() {
|
306
|
-
return this.widgetConfig;
|
307
|
-
}
|
308
|
-
/**
|
309
|
-
* 更新组件配置
|
310
|
-
* @param {Object} config 新的组件配置
|
311
|
-
*/
|
312
|
-
updateWidgetConfig(config) {
|
313
|
-
this.widgetConfig = config;
|
314
|
-
}
|
315
|
-
/**
|
316
|
-
* 根据组件ID查找其父组件
|
317
|
-
* @param {String} id 组件ID
|
318
|
-
* @returns {Object|null} 父组件对象或null(如果未找到)
|
319
|
-
*/
|
320
|
-
getParentWidgetById(id) {
|
321
|
-
function recurse(items) {
|
322
|
-
for (const item of items) {
|
323
|
-
if (item.id === id) {
|
324
|
-
let index = items.findIndex(e => e.id === id);
|
325
|
-
return {
|
326
|
-
widgetList: items,
|
327
|
-
index: index
|
328
|
-
};
|
329
|
-
}
|
330
|
-
if (item.widgetList && item.widgetList.length > 0) {
|
331
|
-
const activeItem = recurse(item.widgetList);
|
332
|
-
if (activeItem) {
|
333
|
-
return activeItem;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
}
|
337
|
-
return null;
|
338
|
-
}
|
339
|
-
return recurse(this.widgetConfig.widgetList);
|
340
|
-
}
|
341
|
-
}
|
342
|
-
export default Designer;
|