@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.
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/components.es.js +11424 -0
- package/dist/components.umd.js +878 -0
- package/dist/index.es.js +39113 -0
- package/dist/index.umd.js +1187 -0
- package/package.json +96 -0
- package/src/components/DragBox.vue +49 -0
- package/src/components/DragTool.vue +235 -0
- package/src/components/EventConfig.vue +557 -0
- package/src/components/FcDesigner.vue +2569 -0
- package/src/components/FcTitle.vue +69 -0
- package/src/components/FetchConfig.vue +415 -0
- package/src/components/FieldInput.vue +371 -0
- package/src/components/FnConfig.vue +315 -0
- package/src/components/FnEditor.vue +327 -0
- package/src/components/FnInput.vue +103 -0
- package/src/components/FormLabel.vue +47 -0
- package/src/components/HtmlEditor.vue +125 -0
- package/src/components/JsonPreview.vue +146 -0
- package/src/components/OptionsTextInput.vue +151 -0
- package/src/components/PropsInput.vue +72 -0
- package/src/components/Required.vue +75 -0
- package/src/components/Row.vue +26 -0
- package/src/components/SignaturePad.vue +176 -0
- package/src/components/Struct.vue +153 -0
- package/src/components/StructEditor.vue +121 -0
- package/src/components/StructTree.vue +209 -0
- package/src/components/TableOptions.vue +164 -0
- package/src/components/TreeOptions.vue +167 -0
- package/src/components/TypeSelect.vue +144 -0
- package/src/components/Validate.vue +302 -0
- package/src/components/ValueInput.vue +89 -0
- package/src/components/Warning.vue +46 -0
- package/src/components/ai/AiPanel.vue +1122 -0
- package/src/components/ai/MarkdownRenderer.vue +548 -0
- package/src/components/language/LanguageConfig.vue +174 -0
- package/src/components/language/LanguageInput.vue +191 -0
- package/src/components/style/BackgroundInput.vue +315 -0
- package/src/components/style/BorderInput.vue +242 -0
- package/src/components/style/BoxSizeInput.vue +166 -0
- package/src/components/style/BoxSpaceInput.vue +269 -0
- package/src/components/style/ColorInput.vue +90 -0
- package/src/components/style/ConfigItem.vue +118 -0
- package/src/components/style/FontInput.vue +197 -0
- package/src/components/style/PositionInput.vue +146 -0
- package/src/components/style/RadiusInput.vue +164 -0
- package/src/components/style/ShadowContent.vue +335 -0
- package/src/components/style/ShadowInput.vue +91 -0
- package/src/components/style/SizeInput.vue +118 -0
- package/src/components/style/StyleConfig.vue +307 -0
- package/src/components/table/Table.vue +252 -0
- package/src/components/table/TableView.vue +1058 -0
- package/src/components/tableForm/TableForm.vue +471 -0
- package/src/components/tableForm/TableFormColumnView.vue +103 -0
- package/src/components/tableForm/TableFormView.vue +46 -0
- package/src/components/tree/FcTree.vue +713 -0
- package/src/components/tree/FcTreeNode.vue +216 -0
- package/src/config/base/field.js +43 -0
- package/src/config/base/form.js +132 -0
- package/src/config/base/style.js +26 -0
- package/src/config/base/validate.js +15 -0
- package/src/config/index.js +70 -0
- package/src/config/menu.js +24 -0
- package/src/config/rule/alert.js +45 -0
- package/src/config/rule/button.js +49 -0
- package/src/config/rule/card.js +40 -0
- package/src/config/rule/cascader.js +121 -0
- package/src/config/rule/checkbox.js +68 -0
- package/src/config/rule/col.js +86 -0
- package/src/config/rule/collapse.js +30 -0
- package/src/config/rule/collapseItem.js +36 -0
- package/src/config/rule/color.js +53 -0
- package/src/config/rule/date.js +66 -0
- package/src/config/rule/dateRange.js +60 -0
- package/src/config/rule/divider.js +31 -0
- package/src/config/rule/editor.js +31 -0
- package/src/config/rule/group.js +86 -0
- package/src/config/rule/html.js +43 -0
- package/src/config/rule/image.js +32 -0
- package/src/config/rule/input.js +62 -0
- package/src/config/rule/number.js +49 -0
- package/src/config/rule/password.js +52 -0
- package/src/config/rule/radio.js +43 -0
- package/src/config/rule/rate.js +44 -0
- package/src/config/rule/row.js +46 -0
- package/src/config/rule/select.js +70 -0
- package/src/config/rule/signaturePad.js +59 -0
- package/src/config/rule/slider.js +53 -0
- package/src/config/rule/space.js +44 -0
- package/src/config/rule/subForm.js +47 -0
- package/src/config/rule/switch.js +46 -0
- package/src/config/rule/tabPane.js +29 -0
- package/src/config/rule/table.js +37 -0
- package/src/config/rule/tableForm.js +115 -0
- package/src/config/rule/tableFormColumn.js +55 -0
- package/src/config/rule/tabs.js +38 -0
- package/src/config/rule/tag.js +69 -0
- package/src/config/rule/text.js +41 -0
- package/src/config/rule/textarea.js +63 -0
- package/src/config/rule/time.js +58 -0
- package/src/config/rule/timeRange.js +49 -0
- package/src/config/rule/title.js +37 -0
- package/src/config/rule/transfer.js +59 -0
- package/src/config/rule/tree.js +70 -0
- package/src/config/rule/treeSelect.js +77 -0
- package/src/config/rule/upload.js +107 -0
- package/src/form/index.js +19 -0
- package/src/index.js +173 -0
- package/src/locale/en.js +981 -0
- package/src/locale/zh-cn.js +983 -0
- package/src/style/fonts/fc-icons.woff +0 -0
- package/src/style/icon.css +1052 -0
- package/src/style/index.css +836 -0
- package/src/utils/form.js +9 -0
- package/src/utils/highlight/highlight.min.js +307 -0
- package/src/utils/highlight/javascript.min.js +80 -0
- package/src/utils/highlight/style.css +1 -0
- package/src/utils/highlight/xml.min.js +29 -0
- package/src/utils/hintStubs.js +120 -0
- package/src/utils/index.js +544 -0
- package/src/utils/jsonDiff.js +173 -0
- package/src/utils/locale.js +23 -0
- package/src/utils/message.js +19 -0
- package/src/utils/template.js +105 -0
- package/types/index.d.ts +575 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="_fd-fn">
|
|
3
|
+
<div class="_fd-fn-tip">
|
|
4
|
+
<div class="_fd-fn-ind"></div>
|
|
5
|
+
<div class="cm-keyword"><span
|
|
6
|
+
>function {{ name }}(<template v-for="(item, idx) in argList"
|
|
7
|
+
>{{
|
|
8
|
+
idx > 0 ? ', ' : ''
|
|
9
|
+
}}<template v-if="item.type === 'string'">
|
|
10
|
+
<span>{{ item.name }}</span> </template
|
|
11
|
+
><template v-else
|
|
12
|
+
><el-popover placement="top-start" :width="400" :hide-after="0" trigger="click" :title="item.name"
|
|
13
|
+
><template #reference
|
|
14
|
+
><span class="_fd-fn-arg">{{ item.name }}<i class="fc-icon icon-question"></i></span
|
|
15
|
+
></template>
|
|
16
|
+
<template v-if="item.info">
|
|
17
|
+
<div class="_fd-fn-info" v-html="item.info || ''"></div>
|
|
18
|
+
</template>
|
|
19
|
+
<template v-if="item.columns">
|
|
20
|
+
<el-table :data="item.columns" border>
|
|
21
|
+
<el-table-column width="120" property="label" :label="t('props.field')"/>
|
|
22
|
+
<el-table-column property="info" :label="t('event.info')"/>
|
|
23
|
+
<el-table-column width="80" property="type" :label="t('event.type')"/>
|
|
24
|
+
</el-table>
|
|
25
|
+
</template>
|
|
26
|
+
</el-popover>
|
|
27
|
+
</template> </template
|
|
28
|
+
>) {</span
|
|
29
|
+
></div>
|
|
30
|
+
</div>
|
|
31
|
+
<div ref="editor" class="_fd-fn-editor"></div>
|
|
32
|
+
<div class="_fd-fn-tip">
|
|
33
|
+
<div class="_fd-fn-ind"></div>
|
|
34
|
+
<div class="cm-keyword">}</div>
|
|
35
|
+
</div>
|
|
36
|
+
<el-button v-if="visible && button" type="primary" size="small" @click="save">{{ t('props.save') }}</el-button>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
import 'codemirror/lib/codemirror.css';
|
|
42
|
+
import 'codemirror/addon/hint/show-hint.css';
|
|
43
|
+
import CodeMirror from 'codemirror/lib/codemirror';
|
|
44
|
+
import 'codemirror/mode/javascript/javascript';
|
|
45
|
+
import 'codemirror/addon/hint/show-hint';
|
|
46
|
+
import 'codemirror/addon/hint/javascript-hint';
|
|
47
|
+
import 'codemirror/addon/hint/anyword-hint';
|
|
48
|
+
import {defineComponent, markRaw} from 'vue';
|
|
49
|
+
import {addAutoKeyMap, toJSON} from '../utils';
|
|
50
|
+
import { getGlobalStubForParamName } from '../utils/hintStubs';
|
|
51
|
+
import errorMessage from '../utils/message';
|
|
52
|
+
|
|
53
|
+
const PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
54
|
+
const SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
55
|
+
|
|
56
|
+
export default defineComponent({
|
|
57
|
+
name: 'FnEditor',
|
|
58
|
+
emits: ['update:modelValue', 'change'],
|
|
59
|
+
props: {
|
|
60
|
+
modelValue: [String, Function],
|
|
61
|
+
name: String,
|
|
62
|
+
args: Array,
|
|
63
|
+
body: Boolean,
|
|
64
|
+
button: Boolean,
|
|
65
|
+
fnx: Boolean,
|
|
66
|
+
},
|
|
67
|
+
inject: ['designer'],
|
|
68
|
+
data() {
|
|
69
|
+
return {
|
|
70
|
+
editor: null,
|
|
71
|
+
fn: '',
|
|
72
|
+
visible: false,
|
|
73
|
+
value: '',
|
|
74
|
+
hintDebounceTimer: null,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
beforeUnmount() {
|
|
78
|
+
if (this.hintDebounceTimer) {
|
|
79
|
+
clearTimeout(this.hintDebounceTimer);
|
|
80
|
+
this.hintDebounceTimer = null;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
watch: {
|
|
84
|
+
modelValue(n) {
|
|
85
|
+
if (n != this.value && (!n || !n.__json || (n.__json && n.__json != this.value))) {
|
|
86
|
+
this.editor && this.editor.setValue(this.tidyValue());
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
argList: {
|
|
90
|
+
handler() {
|
|
91
|
+
if (this.editor) {
|
|
92
|
+
this.editor.setOption('hintOptions', this.buildHintOptions());
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
deep: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
computed: {
|
|
99
|
+
t() {
|
|
100
|
+
return this.designer.setupState.t;
|
|
101
|
+
},
|
|
102
|
+
argStr() {
|
|
103
|
+
return (this.args || []).map(arg => {
|
|
104
|
+
if (typeof arg === 'string') {
|
|
105
|
+
return arg;
|
|
106
|
+
}
|
|
107
|
+
return arg.name;
|
|
108
|
+
}).join(', ');
|
|
109
|
+
},
|
|
110
|
+
argList() {
|
|
111
|
+
return (this.args || []).map(arg => {
|
|
112
|
+
if (typeof arg === 'string') {
|
|
113
|
+
return {
|
|
114
|
+
name: arg,
|
|
115
|
+
type: 'string'
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return arg;
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
mounted() {
|
|
123
|
+
this.$nextTick(() => {
|
|
124
|
+
this.load();
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
methods: {
|
|
128
|
+
save() {
|
|
129
|
+
const str = this.editor.getValue() || '';
|
|
130
|
+
if (str.trim() === '') {
|
|
131
|
+
this.fn = '';
|
|
132
|
+
} else {
|
|
133
|
+
let fn;
|
|
134
|
+
try {
|
|
135
|
+
fn = (new Function('return function (' + this.argStr + '){\n' + str + '\n}'))();
|
|
136
|
+
} catch (e) {
|
|
137
|
+
console.error(e);
|
|
138
|
+
errorMessage(this.t('struct.errorMsg'));
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (this.body) {
|
|
142
|
+
this.fn = (this.fnx ? '$FNX:' : '') + str;
|
|
143
|
+
} else {
|
|
144
|
+
this.fn = PREFIX + fn + SUFFIX;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
this.submit();
|
|
148
|
+
return true;
|
|
149
|
+
},
|
|
150
|
+
submit() {
|
|
151
|
+
this.$emit('update:modelValue', this.fn);
|
|
152
|
+
this.$emit('change', this.fn);
|
|
153
|
+
this.value = this.fn;
|
|
154
|
+
this.visible = false;
|
|
155
|
+
},
|
|
156
|
+
trimString(input) {
|
|
157
|
+
const firstIndex = input.indexOf('{');
|
|
158
|
+
const lastIndex = input.lastIndexOf('}');
|
|
159
|
+
if (firstIndex === -1 || lastIndex === -1 || firstIndex >= lastIndex) {
|
|
160
|
+
return input;
|
|
161
|
+
}
|
|
162
|
+
return input.slice(firstIndex + 1, lastIndex).replace(/^\n+|\n+$/g, '');
|
|
163
|
+
},
|
|
164
|
+
tidyValue() {
|
|
165
|
+
let value = this.modelValue || '';
|
|
166
|
+
if (value.__json) {
|
|
167
|
+
value = value.__json;
|
|
168
|
+
}
|
|
169
|
+
if (this.fnx && typeof value === 'string' && value.indexOf('$FNX:') === 0) {
|
|
170
|
+
value = value.slice(5);
|
|
171
|
+
}
|
|
172
|
+
if (typeof value === 'function') {
|
|
173
|
+
value = this.trimString(toJSON(value)).trim();
|
|
174
|
+
} else if (!this.body) {
|
|
175
|
+
value = this.trimString(value).trim();
|
|
176
|
+
}
|
|
177
|
+
this.value = value;
|
|
178
|
+
return value;
|
|
179
|
+
},
|
|
180
|
+
buildHintOptions() {
|
|
181
|
+
return {
|
|
182
|
+
hint: (cm, options) => {
|
|
183
|
+
const additionalContext = Object.create(null);
|
|
184
|
+
(this.argList || []).forEach(arg => {
|
|
185
|
+
if (arg && arg.name) {
|
|
186
|
+
additionalContext[arg.name] = getGlobalStubForParamName(arg.name);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
const opts = Object.assign({}, options || {}, { additionalContext });
|
|
190
|
+
const js = CodeMirror.hint.javascript(cm, opts);
|
|
191
|
+
if (js && js.list && js.list.length) {
|
|
192
|
+
return js;
|
|
193
|
+
}
|
|
194
|
+
const token = cm.getTokenAt(cm.getCursor());
|
|
195
|
+
if (token && /\b(?:string|comment)\b/.test(token.type)) {
|
|
196
|
+
return js;
|
|
197
|
+
}
|
|
198
|
+
return CodeMirror.hint.anyword(cm, options);
|
|
199
|
+
},
|
|
200
|
+
completeSingle: false,
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
load() {
|
|
204
|
+
this.$nextTick(() => {
|
|
205
|
+
let value = this.tidyValue();
|
|
206
|
+
this.editor = markRaw(CodeMirror(this.$refs.editor, {
|
|
207
|
+
lineNumbers: true,
|
|
208
|
+
mode: {name: 'javascript', globalVars: true},
|
|
209
|
+
extraKeys: {'Ctrl-Space': 'autocomplete'},
|
|
210
|
+
hintOptions: this.buildHintOptions(),
|
|
211
|
+
line: true,
|
|
212
|
+
tabSize: 2,
|
|
213
|
+
lineWrapping: true,
|
|
214
|
+
value,
|
|
215
|
+
}));
|
|
216
|
+
this.editor.on('inputRead', (cm, change) => {
|
|
217
|
+
if (change.origin !== '+input' || change.text.join('').length !== 1) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const c = change.text[0];
|
|
221
|
+
if (c === '.') {
|
|
222
|
+
clearTimeout(this.hintDebounceTimer);
|
|
223
|
+
this.hintDebounceTimer = null;
|
|
224
|
+
setTimeout(() => {
|
|
225
|
+
CodeMirror.commands.autocomplete(cm);
|
|
226
|
+
}, 0);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!/[\w$]/.test(c)) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
clearTimeout(this.hintDebounceTimer);
|
|
233
|
+
this.hintDebounceTimer = setTimeout(() => {
|
|
234
|
+
this.hintDebounceTimer = null;
|
|
235
|
+
if (!this.editor || cm.state.completionActive) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
CodeMirror.commands.autocomplete(cm);
|
|
239
|
+
}, 150);
|
|
240
|
+
});
|
|
241
|
+
this.editor.on('change', () => {
|
|
242
|
+
this.visible = true;
|
|
243
|
+
});
|
|
244
|
+
addAutoKeyMap(this.editor);
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<style>
|
|
252
|
+
|
|
253
|
+
._fd-fn {
|
|
254
|
+
display: flex;
|
|
255
|
+
flex-direction: column;
|
|
256
|
+
position: relative;
|
|
257
|
+
width: 100%;
|
|
258
|
+
height: 100%;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
._fd-fn .el-button {
|
|
262
|
+
position: absolute;
|
|
263
|
+
bottom: 3px;
|
|
264
|
+
right: 5px;
|
|
265
|
+
box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
._fd-fn-editor {
|
|
269
|
+
display: flex;
|
|
270
|
+
flex: 1;
|
|
271
|
+
width: 100%;
|
|
272
|
+
overflow: auto;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
._fd-fn-editor .CodeMirror {
|
|
276
|
+
height: 100%;
|
|
277
|
+
width: 100%;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
._fd-fn-editor .CodeMirror-wrap pre.CodeMirror-line {
|
|
281
|
+
padding-left: 20px;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
._fd-fn-tip {
|
|
285
|
+
color: #000;
|
|
286
|
+
font-family: monospace;
|
|
287
|
+
direction: ltr;
|
|
288
|
+
background: #F5F5F5;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
._fd-fn-tip .cm-keyword {
|
|
292
|
+
color: #708;
|
|
293
|
+
line-height: 24px;
|
|
294
|
+
white-space: nowrap;
|
|
295
|
+
overflow-x: auto;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
._fd-fn-tip .cm-keyword::-webkit-scrollbar {
|
|
299
|
+
width: 0;
|
|
300
|
+
height: 0;
|
|
301
|
+
background-color: transparent;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
._fd-fn-ind {
|
|
305
|
+
background-color: #ECECEC;
|
|
306
|
+
width: 29px;
|
|
307
|
+
height: 24px;
|
|
308
|
+
display: inline-block;
|
|
309
|
+
margin-right: 4px;
|
|
310
|
+
border-right: 1px solid #ddd;
|
|
311
|
+
float: left;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
._fd-fn-arg {
|
|
315
|
+
text-decoration: underline;
|
|
316
|
+
cursor: pointer;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
._fd-fn-arg i {
|
|
320
|
+
font-size: 12px;
|
|
321
|
+
color: #3073ff;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
._fd-fn-info a {
|
|
325
|
+
text-decoration: underline;
|
|
326
|
+
}
|
|
327
|
+
</style>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="_fd-fn-input">
|
|
3
|
+
<el-badge type="warning" is-dot :hidden="!configured">
|
|
4
|
+
<el-button @click="visible=true" size="small">
|
|
5
|
+
<slot>
|
|
6
|
+
{{t('event.title')}}
|
|
7
|
+
</slot>
|
|
8
|
+
</el-button>
|
|
9
|
+
</el-badge>
|
|
10
|
+
<el-dialog class="_fd-fn-input-dialog _fd-config-dialog" :title="title || t('struct.title')" v-model="visible"
|
|
11
|
+
destroy-on-close
|
|
12
|
+
:close-on-click-modal="false"
|
|
13
|
+
append-to-body width="800px">
|
|
14
|
+
<FnEditor ref="editor" v-model="value" :name="name" :args="args" :body="body" :fnx="fnx"></FnEditor>
|
|
15
|
+
<template #footer>
|
|
16
|
+
<div>
|
|
17
|
+
<el-button @click="visible = false" size="default">{{ t('props.cancel') }}</el-button>
|
|
18
|
+
<el-button type="primary" @click="onOk" size="default">{{ t('props.ok') }}</el-button>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
</el-dialog>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import 'codemirror/lib/codemirror.css';
|
|
27
|
+
import 'codemirror/mode/javascript/javascript';
|
|
28
|
+
import {defineComponent} from 'vue';
|
|
29
|
+
import FnEditor from './FnEditor.vue';
|
|
30
|
+
|
|
31
|
+
export default defineComponent({
|
|
32
|
+
name: 'FnInput',
|
|
33
|
+
components: {FnEditor},
|
|
34
|
+
emits: ['update:modelValue', 'change'],
|
|
35
|
+
props: {
|
|
36
|
+
modelValue: [String, Function],
|
|
37
|
+
name: String,
|
|
38
|
+
args: Array,
|
|
39
|
+
title: String,
|
|
40
|
+
body: Boolean,
|
|
41
|
+
fnx: Boolean,
|
|
42
|
+
defaultValue: {
|
|
43
|
+
require: false
|
|
44
|
+
},
|
|
45
|
+
validate: Function,
|
|
46
|
+
},
|
|
47
|
+
inject: ['designer'],
|
|
48
|
+
computed: {
|
|
49
|
+
t() {
|
|
50
|
+
return this.designer.setupState.t;
|
|
51
|
+
},
|
|
52
|
+
configured() {
|
|
53
|
+
return !!this.modelValue;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
visible: false,
|
|
59
|
+
value: this.modelValue
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
watch: {
|
|
63
|
+
modelValue(n){
|
|
64
|
+
this.value = n;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
methods: {
|
|
68
|
+
onOk() {
|
|
69
|
+
if(this.$refs.editor.save()) {
|
|
70
|
+
this.$emit('update:modelValue', this.value);
|
|
71
|
+
this.$emit('change', this.value);
|
|
72
|
+
this.visible = false;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<style>
|
|
80
|
+
._fd-fn-input {
|
|
81
|
+
width: 100%;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
._fd-fn-input .el-badge {
|
|
85
|
+
width: 100%;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
._fd-fn-input .el-button {
|
|
89
|
+
font-weight: 400;
|
|
90
|
+
width: 100%;
|
|
91
|
+
border-color: #2E73FF;
|
|
92
|
+
color: #2E73FF;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
._fd-fn-input-dialog .CodeMirror-lint-tooltip {
|
|
96
|
+
z-index: 2021 !important;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
._fd-fn-input-dialog .el-dialog__body {
|
|
100
|
+
padding: 0px;
|
|
101
|
+
height: 500px;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span @click.capture="handleClick">
|
|
3
|
+
<template v-if="showField">
|
|
4
|
+
{{ rule.field }}
|
|
5
|
+
</template>
|
|
6
|
+
<template v-else>
|
|
7
|
+
<template v-if="rule.warning">
|
|
8
|
+
<Warning :tooltip="rule.warning">
|
|
9
|
+
{{ rule.title }}
|
|
10
|
+
</Warning>
|
|
11
|
+
</template>
|
|
12
|
+
<template v-else>
|
|
13
|
+
{{ rule.title }}
|
|
14
|
+
</template>
|
|
15
|
+
</template>
|
|
16
|
+
</span>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import {defineComponent} from 'vue';
|
|
21
|
+
import Warning from './Warning.vue';
|
|
22
|
+
|
|
23
|
+
export default defineComponent({
|
|
24
|
+
name: 'FormLabel',
|
|
25
|
+
components: {
|
|
26
|
+
Warning,
|
|
27
|
+
},
|
|
28
|
+
props: {
|
|
29
|
+
rule: Object,
|
|
30
|
+
},
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
showField: false,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
handleClick(e) {
|
|
38
|
+
if (e.ctrlKey || e.metaKey) {
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
this.showField = !this.showField;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="_fd-html-editor">
|
|
3
|
+
<el-button @click="visible=true" style="width: 100%;">{{ title || t('struct.title') }}</el-button>
|
|
4
|
+
<el-dialog class="_fd-html-editor-con" :title="title || t('struct.title')" v-model="visible"
|
|
5
|
+
:close-on-click-modal="false" append-to-body>
|
|
6
|
+
<div ref="editor" v-if="visible"></div>
|
|
7
|
+
<template #footer>
|
|
8
|
+
<div>
|
|
9
|
+
<el-button @click="visible = false" size="default">{{ t('props.cancel') }}</el-button>
|
|
10
|
+
<el-button type="primary" @click="onOk" size="default">{{ t('props.ok') }}</el-button>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
</el-dialog>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import 'codemirror/lib/codemirror.css';
|
|
19
|
+
import CodeMirror from 'codemirror/lib/codemirror';
|
|
20
|
+
import {defineComponent, markRaw} from 'vue';
|
|
21
|
+
import errorMessage from '../utils/message';
|
|
22
|
+
|
|
23
|
+
export default defineComponent({
|
|
24
|
+
name: 'HtmlEditor',
|
|
25
|
+
emits: ['update:modelValue'],
|
|
26
|
+
props: {
|
|
27
|
+
modelValue: String,
|
|
28
|
+
title: String,
|
|
29
|
+
defaultValue: {
|
|
30
|
+
require: false
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
inject: ['designer'],
|
|
34
|
+
computed: {
|
|
35
|
+
t() {
|
|
36
|
+
return this.designer.setupState.t;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
editor: null,
|
|
42
|
+
visible: false,
|
|
43
|
+
oldVal: null,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
watch: {
|
|
47
|
+
modelValue() {
|
|
48
|
+
this.load();
|
|
49
|
+
},
|
|
50
|
+
visible(n) {
|
|
51
|
+
if (n) {
|
|
52
|
+
this.load();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
methods: {
|
|
57
|
+
validateXML(xmlString) {
|
|
58
|
+
const parser = new DOMParser();
|
|
59
|
+
const xmlDoc = parser.parseFromString(xmlString, 'text/html');
|
|
60
|
+
const parseErrors = xmlDoc.getElementsByTagName('parsererror');
|
|
61
|
+
if (parseErrors.length > 0) {
|
|
62
|
+
return parseErrors[0].innerText.split('\n')[0] ?? '';
|
|
63
|
+
} else {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
load() {
|
|
68
|
+
this.oldVal = this.modelValue;
|
|
69
|
+
this.$nextTick(() => {
|
|
70
|
+
this.editor = markRaw(CodeMirror(this.$refs.editor, {
|
|
71
|
+
lineNumbers: true,
|
|
72
|
+
mode: 'xml',
|
|
73
|
+
lint: true,
|
|
74
|
+
line: true,
|
|
75
|
+
tabSize: 2,
|
|
76
|
+
lineWrapping: true,
|
|
77
|
+
value: this.modelValue || ''
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
onOk() {
|
|
82
|
+
const str = this.editor.getValue();
|
|
83
|
+
if (this.validateXML(str)) {
|
|
84
|
+
errorMessage(this.t('struct.errorMsg'));
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
this.visible = false;
|
|
88
|
+
if (str !== this.oldVal) {
|
|
89
|
+
this.$emit('update:modelValue', str);
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style>
|
|
98
|
+
._fd-html-editor {
|
|
99
|
+
width: 100%;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
._fd-html-editor .el-button {
|
|
103
|
+
font-weight: 400;
|
|
104
|
+
width: 100%;
|
|
105
|
+
border-color: #2E73FF;
|
|
106
|
+
color: #2E73FF;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
._fd-html-editor-con .CodeMirror {
|
|
110
|
+
height: 450px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
._fd-html-editor-con .CodeMirror-line {
|
|
114
|
+
line-height: 16px !important;
|
|
115
|
+
font-size: 13px !important;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
._fd-html-editor-con .CodeMirror-lint-tooltip {
|
|
119
|
+
z-index: 2021 !important;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
._fd-html-editor-con .el-dialog__body {
|
|
123
|
+
padding: 0px 20px;
|
|
124
|
+
}
|
|
125
|
+
</style>
|