@houaoran/designer 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/dist/components.es.js +11424 -0
  4. package/dist/components.umd.js +878 -0
  5. package/dist/index.es.js +39113 -0
  6. package/dist/index.umd.js +1187 -0
  7. package/package.json +96 -0
  8. package/src/components/DragBox.vue +49 -0
  9. package/src/components/DragTool.vue +235 -0
  10. package/src/components/EventConfig.vue +557 -0
  11. package/src/components/FcDesigner.vue +2569 -0
  12. package/src/components/FcTitle.vue +69 -0
  13. package/src/components/FetchConfig.vue +415 -0
  14. package/src/components/FieldInput.vue +371 -0
  15. package/src/components/FnConfig.vue +315 -0
  16. package/src/components/FnEditor.vue +327 -0
  17. package/src/components/FnInput.vue +103 -0
  18. package/src/components/FormLabel.vue +47 -0
  19. package/src/components/HtmlEditor.vue +125 -0
  20. package/src/components/JsonPreview.vue +146 -0
  21. package/src/components/OptionsTextInput.vue +151 -0
  22. package/src/components/PropsInput.vue +72 -0
  23. package/src/components/Required.vue +75 -0
  24. package/src/components/Row.vue +26 -0
  25. package/src/components/SignaturePad.vue +176 -0
  26. package/src/components/Struct.vue +153 -0
  27. package/src/components/StructEditor.vue +121 -0
  28. package/src/components/StructTree.vue +209 -0
  29. package/src/components/TableOptions.vue +164 -0
  30. package/src/components/TreeOptions.vue +167 -0
  31. package/src/components/TypeSelect.vue +144 -0
  32. package/src/components/Validate.vue +302 -0
  33. package/src/components/ValueInput.vue +89 -0
  34. package/src/components/Warning.vue +46 -0
  35. package/src/components/ai/AiPanel.vue +1122 -0
  36. package/src/components/ai/MarkdownRenderer.vue +548 -0
  37. package/src/components/language/LanguageConfig.vue +174 -0
  38. package/src/components/language/LanguageInput.vue +191 -0
  39. package/src/components/style/BackgroundInput.vue +315 -0
  40. package/src/components/style/BorderInput.vue +242 -0
  41. package/src/components/style/BoxSizeInput.vue +166 -0
  42. package/src/components/style/BoxSpaceInput.vue +269 -0
  43. package/src/components/style/ColorInput.vue +90 -0
  44. package/src/components/style/ConfigItem.vue +118 -0
  45. package/src/components/style/FontInput.vue +197 -0
  46. package/src/components/style/PositionInput.vue +146 -0
  47. package/src/components/style/RadiusInput.vue +164 -0
  48. package/src/components/style/ShadowContent.vue +335 -0
  49. package/src/components/style/ShadowInput.vue +91 -0
  50. package/src/components/style/SizeInput.vue +118 -0
  51. package/src/components/style/StyleConfig.vue +307 -0
  52. package/src/components/table/Table.vue +252 -0
  53. package/src/components/table/TableView.vue +1058 -0
  54. package/src/components/tableForm/TableForm.vue +471 -0
  55. package/src/components/tableForm/TableFormColumnView.vue +103 -0
  56. package/src/components/tableForm/TableFormView.vue +46 -0
  57. package/src/components/tree/FcTree.vue +713 -0
  58. package/src/components/tree/FcTreeNode.vue +216 -0
  59. package/src/config/base/field.js +43 -0
  60. package/src/config/base/form.js +132 -0
  61. package/src/config/base/style.js +26 -0
  62. package/src/config/base/validate.js +15 -0
  63. package/src/config/index.js +70 -0
  64. package/src/config/menu.js +24 -0
  65. package/src/config/rule/alert.js +45 -0
  66. package/src/config/rule/button.js +49 -0
  67. package/src/config/rule/card.js +40 -0
  68. package/src/config/rule/cascader.js +121 -0
  69. package/src/config/rule/checkbox.js +68 -0
  70. package/src/config/rule/col.js +86 -0
  71. package/src/config/rule/collapse.js +30 -0
  72. package/src/config/rule/collapseItem.js +36 -0
  73. package/src/config/rule/color.js +53 -0
  74. package/src/config/rule/date.js +66 -0
  75. package/src/config/rule/dateRange.js +60 -0
  76. package/src/config/rule/divider.js +31 -0
  77. package/src/config/rule/editor.js +31 -0
  78. package/src/config/rule/group.js +86 -0
  79. package/src/config/rule/html.js +43 -0
  80. package/src/config/rule/image.js +32 -0
  81. package/src/config/rule/input.js +62 -0
  82. package/src/config/rule/number.js +49 -0
  83. package/src/config/rule/password.js +52 -0
  84. package/src/config/rule/radio.js +43 -0
  85. package/src/config/rule/rate.js +44 -0
  86. package/src/config/rule/row.js +46 -0
  87. package/src/config/rule/select.js +70 -0
  88. package/src/config/rule/signaturePad.js +59 -0
  89. package/src/config/rule/slider.js +53 -0
  90. package/src/config/rule/space.js +44 -0
  91. package/src/config/rule/subForm.js +47 -0
  92. package/src/config/rule/switch.js +46 -0
  93. package/src/config/rule/tabPane.js +29 -0
  94. package/src/config/rule/table.js +37 -0
  95. package/src/config/rule/tableForm.js +115 -0
  96. package/src/config/rule/tableFormColumn.js +55 -0
  97. package/src/config/rule/tabs.js +38 -0
  98. package/src/config/rule/tag.js +69 -0
  99. package/src/config/rule/text.js +41 -0
  100. package/src/config/rule/textarea.js +63 -0
  101. package/src/config/rule/time.js +58 -0
  102. package/src/config/rule/timeRange.js +49 -0
  103. package/src/config/rule/title.js +37 -0
  104. package/src/config/rule/transfer.js +59 -0
  105. package/src/config/rule/tree.js +70 -0
  106. package/src/config/rule/treeSelect.js +77 -0
  107. package/src/config/rule/upload.js +107 -0
  108. package/src/form/index.js +19 -0
  109. package/src/index.js +173 -0
  110. package/src/locale/en.js +981 -0
  111. package/src/locale/zh-cn.js +983 -0
  112. package/src/style/fonts/fc-icons.woff +0 -0
  113. package/src/style/icon.css +1052 -0
  114. package/src/style/index.css +836 -0
  115. package/src/utils/form.js +9 -0
  116. package/src/utils/highlight/highlight.min.js +307 -0
  117. package/src/utils/highlight/javascript.min.js +80 -0
  118. package/src/utils/highlight/style.css +1 -0
  119. package/src/utils/highlight/xml.min.js +29 -0
  120. package/src/utils/hintStubs.js +120 -0
  121. package/src/utils/index.js +544 -0
  122. package/src/utils/jsonDiff.js +173 -0
  123. package/src/utils/locale.js +23 -0
  124. package/src/utils/message.js +19 -0
  125. package/src/utils/template.js +105 -0
  126. package/types/index.d.ts +575 -0
@@ -0,0 +1,371 @@
1
+ <template>
2
+ <div class="_fd-field-input">
3
+ <i class="fc-icon icon-group" @click.stop="copy"></i>
4
+ <el-input
5
+ v-if="!fieldList.length"
6
+ v-model="value"
7
+ :readonly="fieldReadonly || disabled"
8
+ :disabled="fieldReadonly || disabled"
9
+ @focus="onFocus"
10
+ @blur="onInput"
11
+ >
12
+ <template #append v-if="!fieldReadonly">
13
+ <i class="fc-icon icon-auto" @click="makeField"></i>
14
+ </template>
15
+ </el-input>
16
+ <el-tree-select
17
+ v-else
18
+ v-model="value"
19
+ :readonly="fieldReadonly || disabled"
20
+ :disabled="disabled"
21
+ :allow-create="!fieldReadonly"
22
+ :filterable="true"
23
+ :default-first-option="!fieldReadonly"
24
+ :indent="10"
25
+ :checkStrictly="isSubform && relationField !== true"
26
+ popper-class="_fd-field-popper"
27
+ @focus="onFocus"
28
+ @change="onInput"
29
+ @current-change="currentChange"
30
+ :data="processedFieldList"
31
+ :props="{ value: 'value', label: 'label' }"
32
+ node-key="value"
33
+ />
34
+ </div>
35
+ </template>
36
+
37
+ <script>
38
+ import {defineComponent, nextTick, onUnmounted} from 'vue';
39
+ import uniqueId from '@form-create/utils/lib/unique';
40
+ import {copyTextToClipboard, escapeRegExp} from '../utils';
41
+ import errorMessage from '../utils/message';
42
+ import is from '@form-create/utils/lib/type';
43
+ import {deepCopy} from '@form-create/utils/lib/deepextend';
44
+
45
+ export default defineComponent({
46
+ name: 'FieldInput',
47
+ inject: ['designer'],
48
+ emits: ['update:modelValue'],
49
+ props: {
50
+ modelValue: String,
51
+ disabled: Boolean,
52
+ },
53
+ computed: {
54
+ fieldList() {
55
+ if (this.key) {
56
+ return this.getFieldList();
57
+ }
58
+ return [];
59
+ },
60
+ processedFieldList() {
61
+ this.nodeMap.clear();
62
+ return this.processFieldListForTreeSelect(this.fieldList);
63
+ },
64
+ subformFieldList() {
65
+ const fieldList = this.designer.setupState.fieldList || [];
66
+ const _fieldList = this.fieldLeafSelectable ? fieldList : this.removeLeafNodes(deepCopy(fieldList));
67
+ if (_fieldList.length) {
68
+ return _fieldList;
69
+ }
70
+ return fieldList;
71
+ },
72
+ fieldReadonly() {
73
+ return this.designer.setupState.fieldReadonly;
74
+ },
75
+ isSubform() {
76
+ return this.activeRule && this.activeRule._menu.subForm;
77
+ },
78
+ activeRule() {
79
+ return this.designer.setupState.activeRule;
80
+ },
81
+ relationField() {
82
+ return this.designer.props.config.relationField;
83
+ },
84
+ fieldLeafSelectable() {
85
+ return this.designer.props.config.fieldLeafSelectable !== false;
86
+ },
87
+ t() {
88
+ return this.designer.setupState.t;
89
+ },
90
+ },
91
+ data() {
92
+ return {
93
+ value: this.modelValue || '',
94
+ oldValue: '',
95
+ key: 1,
96
+ activeNode: null,
97
+ nodeMap: new Map(), // 存储节点映射关系
98
+ };
99
+ },
100
+ watch: {
101
+ modelValue(n) {
102
+ // 如果有字段列表,需要将原始值转换为唯一ID
103
+ if (this.fieldList.length > 0) {
104
+ const uniqueId = this.findUniqueIdByValue(n);
105
+ this.value = uniqueId || n;
106
+ } else {
107
+ this.value = n;
108
+ }
109
+ },
110
+ fieldList: {
111
+ handler() {
112
+ // 当字段列表变化时,重新映射当前值
113
+ if (this.fieldList.length > 0 && this.modelValue) {
114
+ const uniqueId = this.findUniqueIdByValue(this.modelValue);
115
+ if (uniqueId) {
116
+ this.value = uniqueId;
117
+ }
118
+ }
119
+ },
120
+ immediate: true,
121
+ deep: true,
122
+ },
123
+ },
124
+ methods: {
125
+ getFieldList() {
126
+ let fieldList = this.designer.props.config?.fieldList || [];
127
+ if (this.relationField === false) {
128
+ return fieldList;
129
+ }
130
+ if (this.isSubform) {
131
+ fieldList = this.subformFieldList;
132
+ } else {
133
+ const rule = this.activeRule;
134
+ let ctx = rule && rule.__fc__ && rule.__fc__.parent;
135
+ while (ctx) {
136
+ if (ctx.rule._menu && ['array', 'object'].indexOf(ctx.rule._menu.subForm) > -1) {
137
+ const _fieldList = this.findChildrenById(fieldList, ctx.rule.field) || fieldList;
138
+ if (_fieldList.length) {
139
+ fieldList = _fieldList;
140
+ }
141
+ break;
142
+ } else {
143
+ ctx = ctx.parent;
144
+ }
145
+ }
146
+ }
147
+ return fieldList;
148
+ },
149
+ removeLeafNodes(tree) {
150
+ if (!Array.isArray(tree) || tree.length === 0) {
151
+ return tree;
152
+ }
153
+
154
+ function recurse(nodes) {
155
+ return nodes.filter(node => {
156
+ if (node.children && node.children.length > 0) {
157
+ node.children = recurse(node.children);
158
+ return true;
159
+ }
160
+ return false;
161
+ });
162
+ }
163
+
164
+ return recurse(tree);
165
+ },
166
+ findChildrenById(tree, id) {
167
+ if (!Array.isArray(tree)) {
168
+ return null;
169
+ }
170
+ for (const node of tree) {
171
+ if (node.value === id) {
172
+ return node.children || [];
173
+ }
174
+ if (node.children) {
175
+ const result = this.findChildrenById(node.children, id);
176
+ if (result !== null) {
177
+ return result;
178
+ }
179
+ }
180
+ }
181
+ return null;
182
+ },
183
+ copy() {
184
+ copyTextToClipboard(this.modelValue);
185
+ },
186
+ getSubChildren() {
187
+ let subChildren = this.designer.setupState.getSubFormChildren(this.activeRule) || [];
188
+ subChildren = is.trueArray(subChildren) ? subChildren : this.designer.setupState.children;
189
+ return subChildren;
190
+ },
191
+ getSubFieldChildren() {
192
+ const subChildren = this.getSubChildren();
193
+ const list = [];
194
+ const getRule = children => {
195
+ children &&
196
+ children.forEach(rule => {
197
+ if (rule && rule._fc_drag_tag && rule.field) {
198
+ list.push({...rule, children: []});
199
+ } else if (rule && rule.children) {
200
+ getRule(rule.children);
201
+ }
202
+ });
203
+ return list;
204
+ };
205
+ return getRule(subChildren);
206
+ },
207
+ checkValue(inputValue = null) {
208
+ const oldField = this.oldValue;
209
+ const temp = escapeRegExp(oldField);
210
+ let field = ((inputValue !== null ? inputValue : this.value) || '').replace(/[\s\ ]/g, '');
211
+ if (!field) {
212
+ errorMessage(this.t('computed.fieldEmpty'));
213
+ return oldField;
214
+ } else if (!/^[a-zA-Z]/.test(field)) {
215
+ errorMessage(this.t('computed.fieldChar'));
216
+ return oldField;
217
+ } else if (oldField !== field) {
218
+ const flag = field.indexOf('.') > -1;
219
+ if (flag) {
220
+ field = field.replaceAll('.', '_');
221
+ }
222
+ if (
223
+ this.designer.setupState.getConfig('checkFieldUnique') !== false &&
224
+ this.getSubFieldChildren().filter(v => v.field === field).length > 0
225
+ ) {
226
+ errorMessage(this.t('computed.fieldExist', {label: field}));
227
+ return oldField;
228
+ }
229
+ if (flag) {
230
+ return field;
231
+ }
232
+ }
233
+ this.oldValue = '';
234
+ return field;
235
+ },
236
+ onFocus() {
237
+ this.oldValue = this.value;
238
+ },
239
+ makeField() {
240
+ this.oldValue = this.value;
241
+ this.value = uniqueId();
242
+ this.onInput();
243
+ },
244
+ updateRule(node) {
245
+ const update = {...(node.update || {})};
246
+ if (!update.title) {
247
+ update.title = node.label;
248
+ }
249
+ this.designer.setupState.mergeRule(this.activeRule, update);
250
+ this.designer.setupState.updateRuleFormData();
251
+ },
252
+ onInput() {
253
+ if (this.value !== this.modelValue) {
254
+ const actualValue = this.nodeMap.has(this.value) ? this.getOriginalValueByUniqueId(this.value) : this.value;
255
+ this.value = this.checkValue(actualValue);
256
+ if (this.value !== this.modelValue) {
257
+ const node = this.activeNode;
258
+ this.activeNode = null;
259
+ this.oldValue = this.value;
260
+ this.designer.emit('changeField', {field: this.value, oldField: this.modelValue, rule: this.activeRule});
261
+ this.$emit('update:modelValue', this.value);
262
+ if (node) {
263
+ this.updateRule(node);
264
+ }
265
+ }
266
+ }
267
+ },
268
+ currentChange(node) {
269
+ this.activeNode = node;
270
+ },
271
+ processFieldListForTreeSelect(fieldList, parentPath = '') {
272
+ if (!Array.isArray(fieldList)) {
273
+ return [];
274
+ }
275
+
276
+ return fieldList.map((item, index) => {
277
+ const uniqueId = parentPath ? `${parentPath}.${index}` : `${index}`;
278
+ const processedItem = {
279
+ ...item,
280
+ id: uniqueId, // 使用 id 作为唯一标识
281
+ originalValue: item.value, // 保存原始值
282
+ value: uniqueId, // 使用唯一 ID 作为 value
283
+ };
284
+
285
+ // 存储映射关系,用于后续查找原始值
286
+ this.nodeMap.set(uniqueId, item);
287
+
288
+ if (item.children && item.children.length > 0) {
289
+ processedItem.children = this.processFieldListForTreeSelect(item.children, uniqueId);
290
+ }
291
+
292
+ return processedItem;
293
+ });
294
+ },
295
+ getOriginalValueByUniqueId(uniqueId) {
296
+ const node = this.nodeMap.get(uniqueId);
297
+ return node ? node.value : uniqueId;
298
+ },
299
+ findUniqueIdByValue(value, fieldList = null) {
300
+ const list = fieldList || this.fieldList;
301
+ if (!Array.isArray(list)) {
302
+ return null;
303
+ }
304
+
305
+ for (let i = 0; i < list.length; i++) {
306
+ const item = list[i];
307
+ if (item.value === value) {
308
+ return i.toString();
309
+ }
310
+ if (item.children && item.children.length > 0) {
311
+ const result = this.findUniqueIdByValue(value, item.children);
312
+ if (result !== null) {
313
+ return `${i}.${result}`;
314
+ }
315
+ }
316
+ }
317
+ return null;
318
+ },
319
+ },
320
+ mounted() {
321
+ const updateKey = () => {
322
+ nextTick(() => {
323
+ ++this.key;
324
+ });
325
+ };
326
+ this.designer.setupState.bus.$on('dragEnd', updateKey);
327
+ onUnmounted(() => {
328
+ this.designer.setupState.bus.$off('dragEnd', updateKey);
329
+ });
330
+ },
331
+ });
332
+ </script>
333
+
334
+ <style>
335
+ ._fd-field-input {
336
+ width: 100%;
337
+ position: relative;
338
+ }
339
+
340
+ ._fd-field-input > .fc-icon {
341
+ position: absolute;
342
+ right: 28px;
343
+ top: 1px;
344
+ z-index: 3;
345
+ color: #a8abb2;
346
+ cursor: pointer;
347
+ width: 24px;
348
+ height: 24px;
349
+ text-align: center;
350
+ }
351
+
352
+ ._fd-field-input .el-input-group__append {
353
+ width: 25px;
354
+ padding: 0;
355
+ margin: 0;
356
+ color: #aaaaaa;
357
+ cursor: pointer;
358
+ }
359
+
360
+ ._fd-field-popper .el-tree-node__content {
361
+ padding: 2px 0;
362
+ color: #333;
363
+ }
364
+
365
+ ._fd-field-popper .el-select-dropdown__list > .el-select-dropdown__item {
366
+ padding-left: 15px;
367
+ border-bottom: 1px solid #ececec;
368
+ box-sizing: border-box;
369
+ height: 26px;
370
+ }
371
+ </style>
@@ -0,0 +1,315 @@
1
+ <template>
2
+ <div class="_fd-fn-list">
3
+ <el-badge :value="eventNum" type="warning" :hidden="eventNum < 1">
4
+ <el-button @click="visible=true" size="small">{{ t('event.title') }}</el-button>
5
+ </el-badge>
6
+ <el-dialog class="_fd-fn-list-dialog" :title="t('event.title')" v-model="visible" destroy-on-close
7
+ :close-on-click-modal="false"
8
+ append-to-body
9
+ width="1080px">
10
+ <el-container class="_fd-fn-list-con" style="height: 600px">
11
+ <el-aside style="width:300px;">
12
+ <el-container class="_fd-fn-list-l">
13
+ <el-header class="_fd-fn-list-head" height="40px">
14
+ <el-text type="primary" size="default">
15
+ {{ t('event.list') }}
16
+ </el-text>
17
+ </el-header>
18
+ <el-main>
19
+ <el-menu
20
+ :default-active="defActive"
21
+ v-model="activeData">
22
+ <template v-for="(item, name) in event">
23
+ <el-menu-item :index="name">
24
+ <div class="_fd-fn-list-method" @click.stop="edit(item)">
25
+ <span>function<span>{{ name }}</span></span>
26
+ <span class="_fd-label" v-if="eventInfo[name]">{{ eventInfo[name] }}</span>
27
+ <span class="_fd-dot" v-if="item.fn"></span>
28
+ </div>
29
+ </el-menu-item>
30
+ </template>
31
+ </el-menu>
32
+ </el-main>
33
+ </el-container>
34
+ </el-aside>
35
+ <el-main>
36
+ <el-container class="_fd-fn-list-r">
37
+ <el-header class="_fd-fn-list-head" height="40px" v-if="activeData">
38
+ <el-button size="small" @click="close">{{ t('props.cancel') }}</el-button>
39
+ <el-button size="small" type="primary" @click="save" color="#2f73ff">{{
40
+ t('props.save')
41
+ }}
42
+ </el-button>
43
+ </el-header>
44
+ <el-main v-if="activeData">
45
+ <FnEditor ref="fn" v-model="eventStr" :name="activeData.item.name"
46
+ :args="activeData.item.args"/>
47
+ </el-main>
48
+ </el-container>
49
+ </el-main>
50
+ </el-container>
51
+ <template #footer>
52
+ <div>
53
+ <el-button size="default" @click="visible=false">{{ t('props.cancel') }}</el-button>
54
+ <el-button type="primary" size="default" @click="submit" color="#2f73ff">{{
55
+ t('props.ok')
56
+ }}
57
+ </el-button>
58
+ </div>
59
+ </template>
60
+ </el-dialog>
61
+ </div>
62
+ </template>
63
+
64
+ <script>
65
+ import unique from '@form-create/utils/lib/unique';
66
+ import deepExtend from '@form-create/utils/lib/deepextend';
67
+ import {defineComponent} from 'vue';
68
+ import FnEditor from './FnEditor.vue';
69
+ import errorMessage from '../utils/message';
70
+
71
+ const PREFIX = '[[FORM-CREATE-PREFIX-';
72
+ const SUFFIX = '-FORM-CREATE-SUFFIX]]';
73
+
74
+ export default defineComponent({
75
+ name: 'FnConfig',
76
+ emits: ['update:modelValue'],
77
+ props: {
78
+ modelValue: [Object, undefined, null],
79
+ eventConfig: {
80
+ type: Array,
81
+ default: () => []
82
+ },
83
+ },
84
+ inject: ['designer'],
85
+ components: {
86
+ FnEditor,
87
+ },
88
+ data() {
89
+ return {
90
+ visible: false,
91
+ activeData: null,
92
+ defActive: 'no',
93
+ event: {},
94
+ cus: false,
95
+ eventStr: '',
96
+ };
97
+ },
98
+ computed: {
99
+ eventInfo() {
100
+ const info = {};
101
+ this.eventConfig.forEach(v => {
102
+ info[v.name] = v.info;
103
+ });
104
+ return info;
105
+ },
106
+ t() {
107
+ return this.designer.setupState.t;
108
+ },
109
+ eventNum() {
110
+ let num = 0;
111
+ Object.keys(this.modelValue || {}).forEach(k => {
112
+ if (this.modelValue[k]) {
113
+ num++;
114
+ }
115
+ });
116
+ return num;
117
+ },
118
+ },
119
+ watch: {
120
+ visible(v) {
121
+ this.event = v ? this.loadFN(deepExtend({}, this.modelValue || {})) : {};
122
+ if (!v) {
123
+ this.destroy();
124
+ }
125
+ },
126
+ },
127
+ methods: {
128
+ getArgs(item) {
129
+ return item.args.join(', ');
130
+ },
131
+ loadFN(e) {
132
+ const val = {};
133
+ this.eventConfig.forEach(item => {
134
+ const k = item.name;
135
+ const fn = e[k] || '';
136
+ val[k] = {
137
+ item, fn
138
+ }
139
+ });
140
+ return val;
141
+ },
142
+ parseFN(e) {
143
+ const on = {};
144
+ Object.keys(e).forEach(k => {
145
+ if (e[k].fn) {
146
+ on[k] = e[k].fn;
147
+ }
148
+ });
149
+ return on;
150
+ },
151
+ edit(data) {
152
+ data.key = unique();
153
+ this.activeData = data;
154
+ this.eventStr = data.fn || (PREFIX + `function ${data.item.name}(${this.getArgs(data.item)}){}` + SUFFIX);
155
+ this.defActive = data.item.name;
156
+ },
157
+ save() {
158
+ if (this.$refs.fn.save()) {
159
+ this.activeData.fn = this.eventStr;
160
+ this.destroy();
161
+ return true;
162
+ }
163
+ return false;
164
+ },
165
+ destroy() {
166
+ this.activeData = null;
167
+ this.defActive = 'no';
168
+ },
169
+ close() {
170
+ this.destroy();
171
+ },
172
+ submit() {
173
+ if (this.activeData && !this.save()) {
174
+ return;
175
+ }
176
+ this.$emit('update:modelValue', this.parseFN(this.event));
177
+ this.visible = false;
178
+ this.destroy();
179
+ },
180
+ }
181
+ });
182
+ </script>
183
+
184
+ <style>
185
+ ._fd-fn-list, ._fd-fn-list .el-badge {
186
+ width: 100%;
187
+ }
188
+
189
+ ._fd-fn-list .el-button {
190
+ font-weight: 400;
191
+ width: 100%;
192
+ border-color: #2E73FF;
193
+ color: #2E73FF;
194
+ }
195
+
196
+ ._fd-fn-list-con .el-main {
197
+ padding: 0;
198
+ }
199
+
200
+ ._fd-fn-list-l, ._fd-fn-list-r {
201
+ display: flex;
202
+ flex-direction: column;
203
+ flex: 1;
204
+ height: 100%;
205
+ border: 1px solid #ececec;
206
+ }
207
+
208
+ ._fd-fn-list-head {
209
+ display: flex;
210
+ padding: 5px 15px;
211
+ border-bottom: 1px solid #eee;
212
+ background: #f8f9ff;
213
+ align-items: center;
214
+ }
215
+
216
+ ._fd-fn-list-head .el-button.is-link {
217
+ color: #2f73ff;
218
+ }
219
+
220
+ ._fd-fn-list-r {
221
+ border-left: 0 none;
222
+ }
223
+
224
+ ._fd-fn-list-r ._fd-fn-list-head {
225
+ justify-content: flex-end;
226
+ }
227
+
228
+ ._fd-fn-list-l > .el-main, ._fd-fn-list-r > .el-main {
229
+ display: flex;
230
+ flex-direction: row;
231
+ flex: 1;
232
+ flex-basis: auto;
233
+ box-sizing: border-box;
234
+ min-width: 0;
235
+ width: 100%;
236
+ }
237
+
238
+ ._fd-fn-list-r > .el-main {
239
+ flex-direction: column;
240
+ }
241
+
242
+ ._fd-fn-list-l .el-menu {
243
+ padding: 0 10px 5px;
244
+ border-right: 0 none;
245
+ width: 100%;
246
+ border-top: 0 none;
247
+ overflow: auto;
248
+ }
249
+
250
+ ._fd-fn-list-l .el-menu-item.is-active {
251
+ background: #e4e7ed;
252
+ color: #303133;
253
+ }
254
+
255
+ ._fd-fn-list-l .el-menu-item {
256
+ height: auto;
257
+ line-height: 1em;
258
+ border: 1px solid #ECECEC;
259
+ border-radius: 5px;
260
+ padding: 0;
261
+ margin-top: 5px;
262
+ }
263
+
264
+ ._fd-fn-list-method {
265
+ display: flex;
266
+ flex-direction: column;
267
+ justify-content: center;
268
+ padding: 10px 20px 10px 0;
269
+ font-size: 14px;
270
+ line-height: 1em;
271
+ font-family: monospace;
272
+ width: 100%;
273
+ overflow: hidden;
274
+ white-space: pre-wrap;
275
+ position: relative;
276
+ box-sizing: border-box;
277
+ }
278
+
279
+
280
+ ._fd-fn-list-method ._fd-label {
281
+ margin-top: 4px;
282
+ color: #AAAAAA;
283
+ font-size: 12px;
284
+ }
285
+
286
+ ._fd-fn-list-method ._fd-dot {
287
+ position: absolute;
288
+ top: 50%;
289
+ margin-top: -3px;
290
+ right: 16px;
291
+ display: block;
292
+ width: 6px;
293
+ height: 6px;
294
+ background: #00C050;
295
+ border-radius: 15px;
296
+ }
297
+
298
+ ._fd-fn-list-method-info > span:first-child, ._fd-fn-list-method > span:first-child {
299
+ color: #9D238C;
300
+ }
301
+
302
+ ._fd-fn-list-method-info > span:first-child > span, ._fd-fn-list-method > span:first-child > span {
303
+ color: #000;
304
+ margin-left: 10px;
305
+ }
306
+
307
+ ._fd-fn-list-con .CodeMirror {
308
+ height: 100%;
309
+ width: 100%;
310
+ }
311
+
312
+ ._fd-fn-list-con .CodeMirror-wrap pre.CodeMirror-line {
313
+ padding-left: 20px;
314
+ }
315
+ </style>