@bit-sun/business-component 2.1.1-alpha.21 → 2.1.1-alpha.22
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/.fatherrc.ts +1 -1
- package/.umirc.ts +6 -6
- package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +2 -0
- package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +2 -0
- package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +6 -0
- package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +2 -0
- package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +2 -0
- package/dist/components/Business/JsonQueryTable/function.d.ts +37 -0
- package/dist/components/Business/JsonQueryTable/index.d.ts +3 -0
- package/dist/components/Business/JsonQueryTable/static.d.ts +39 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +23981 -16708
- package/dist/index.js +24288 -17010
- package/dist/utils/utils.d.ts +2 -0
- package/package.json +10 -4
- package/src/components/Business/AddSelectBusiness/index.tsx +105 -83
- package/src/components/Business/BsSulaQueryTable/index.tsx +5 -0
- package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -0
- package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -0
- package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -0
- package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -0
- package/src/components/Business/JsonQueryTable/configButton/index.js +20 -0
- package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -0
- package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -0
- package/src/components/Business/JsonQueryTable/configTree/index.js +82 -0
- package/src/components/Business/JsonQueryTable/configTree/index.less +44 -0
- package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -0
- package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -0
- package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -0
- package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -0
- package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -0
- package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -0
- package/src/components/Business/JsonQueryTable/function.ts +62 -0
- package/src/components/Business/JsonQueryTable/index.less +19 -0
- package/src/components/Business/JsonQueryTable/index.md +328 -0
- package/src/components/Business/JsonQueryTable/index.tsx +320 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -0
- package/src/components/Business/JsonQueryTable/static.ts +356 -0
- package/src/components/Business/SearchSelect/BusinessUtils.ts +109 -1
- package/src/components/Business/SearchSelect/index.md +117 -0
- package/src/components/Business/SearchSelect/utils.ts +2 -2
- package/src/components/Functional/AddSelect/index.md +32 -0
- package/src/components/Functional/BillEntry/index.tsx +0 -1
- package/src/index.ts +3 -1
- package/src/utils/getFormMode.js +12 -0
- package/src/utils/serialize.js +7 -0
- package/src/utils/utils.ts +42 -2
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import * as basicTypes from './basicType';
|
|
2
|
+
let monaco;
|
|
3
|
+
let editor;
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
isArrayType,
|
|
7
|
+
isStringType,
|
|
8
|
+
isNumberType,
|
|
9
|
+
isBooleanType,
|
|
10
|
+
isNameType,
|
|
11
|
+
isFieldRenderType,
|
|
12
|
+
isLayoutType,
|
|
13
|
+
isObjectType,
|
|
14
|
+
isMethodType,
|
|
15
|
+
isFunctionType,
|
|
16
|
+
isModeType,
|
|
17
|
+
isColumnRender,
|
|
18
|
+
isActionType,
|
|
19
|
+
} = basicTypes;
|
|
20
|
+
|
|
21
|
+
const errorMarks = (node, message = '类型错误') => {
|
|
22
|
+
const name = node?.key?.name || node?.key?.value || node.value || '';
|
|
23
|
+
const { loc } = node;
|
|
24
|
+
|
|
25
|
+
monaco.editor.setModelMarkers(editor.getModel(), 'propFunc', [
|
|
26
|
+
{
|
|
27
|
+
startLineNumber: loc.start.line,
|
|
28
|
+
startColumn: loc.start.column + 1,
|
|
29
|
+
endLineNumber: loc.end.line,
|
|
30
|
+
endColumn: loc.end.column + 1,
|
|
31
|
+
message: `${name} ${message}`,
|
|
32
|
+
severity: monaco.MarkerSeverity.Error,
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function requiredValidate(field, name) {
|
|
38
|
+
const nameList = Array.isArray(name) ? name : [name];
|
|
39
|
+
const { properties } = field;
|
|
40
|
+
if (!properties) return;
|
|
41
|
+
if (
|
|
42
|
+
!properties.some(item => {
|
|
43
|
+
const itemName = item?.key?.name || item?.key?.value || item.value;
|
|
44
|
+
return nameList.some(v => itemName === v);
|
|
45
|
+
})
|
|
46
|
+
) {
|
|
47
|
+
errorMarks(field, `缺少必填项${name}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default (data, _monaco, _editor) => {
|
|
52
|
+
if (!data) return;
|
|
53
|
+
monaco = _monaco;
|
|
54
|
+
editor = _editor;
|
|
55
|
+
const { properties = [] } = data;
|
|
56
|
+
|
|
57
|
+
properties.forEach(node => {
|
|
58
|
+
const { key } = node;
|
|
59
|
+
const name = key?.name || key?.value;
|
|
60
|
+
if (node?.loc?.start?.column < 5) {
|
|
61
|
+
// 仅对最外层校验,内部校验直接处理外部字段
|
|
62
|
+
validate(node, name);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function validate(node, name) {
|
|
68
|
+
return true
|
|
69
|
+
/**
|
|
70
|
+
* fields字段校验
|
|
71
|
+
*/
|
|
72
|
+
const fieldTypes = ['fields'];
|
|
73
|
+
if (fieldTypes.includes(name)) {
|
|
74
|
+
if (!isArrayType(node)) {
|
|
75
|
+
errorMarks(node, '应为数组类型');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const { elements } = node.value || {};
|
|
79
|
+
elements.forEach(field => {
|
|
80
|
+
if (!isObjectType(field)) {
|
|
81
|
+
errorMarks(field, '应为对象类型');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { properties } = field;
|
|
86
|
+
if (!properties) return;
|
|
87
|
+
if (
|
|
88
|
+
!properties.some(item => {
|
|
89
|
+
const itemName = item?.key?.name || item?.key?.value || item.value;
|
|
90
|
+
return itemName === 'fields';
|
|
91
|
+
})
|
|
92
|
+
) {
|
|
93
|
+
requiredValidate(field, 'name');
|
|
94
|
+
requiredValidate(field, ['field', 'render']);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
properties.forEach(item => {
|
|
98
|
+
const itemName = item?.key?.name || item?.key?.value || item.value;
|
|
99
|
+
if (itemName === 'name' && !isNameType(item)) {
|
|
100
|
+
errorMarks(item);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (itemName === 'label') {
|
|
104
|
+
if (!isStringType(item)) {
|
|
105
|
+
errorMarks(item);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (itemName === 'field') {
|
|
110
|
+
if (!isFieldRenderType(item)) {
|
|
111
|
+
errorMarks(item);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (isObjectType(item)) {
|
|
115
|
+
const { properties: renderProperties } = item.value;
|
|
116
|
+
if (!renderProperties) return;
|
|
117
|
+
renderProperties.forEach(renderItem => {
|
|
118
|
+
const renderItemName =
|
|
119
|
+
renderItem.key.name || renderItem.key.value;
|
|
120
|
+
if (renderItemName === 'type') {
|
|
121
|
+
if (!isStringType(renderItem) && !isFunctionType(renderItem)) {
|
|
122
|
+
errorMarks(renderItem);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (itemName === 'valuePropName' && !isStringType(item)) {
|
|
131
|
+
errorMarks(item);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (itemName === 'rules' && !isArrayType(item)) {
|
|
135
|
+
errorMarks(item);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (itemName === 'wrapFormItem' && !isBooleanType(item)) {
|
|
139
|
+
errorMarks(item);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (itemName === 'initialDisabled' && !isBooleanType(item)) {
|
|
143
|
+
errorMarks(item);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (itemName === 'initialVisible' && !isBooleanType(item)) {
|
|
147
|
+
errorMarks(item);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (itemName === 'dependency') {
|
|
151
|
+
if (!isObjectType(item)) {
|
|
152
|
+
errorMarks(item);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const { properties: depProperties } = item.value;
|
|
156
|
+
if (!depProperties) return;
|
|
157
|
+
depProperties.forEach(depItem => {
|
|
158
|
+
const depName = depItem.key.name || depItem.key.value;
|
|
159
|
+
const depType = ['value', 'source', 'disabled', 'visible'];
|
|
160
|
+
if (!depType.includes(depName)) {
|
|
161
|
+
errorMarks(
|
|
162
|
+
depType,
|
|
163
|
+
'dependency 只可以包含value source disabled visible四种类型',
|
|
164
|
+
);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (!isObjectType(depItem)) {
|
|
168
|
+
errorMarks(depItem);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const { properties: depItemProperties } = depItem.value;
|
|
172
|
+
if (!depItemProperties) return;
|
|
173
|
+
depItemProperties.forEach(depNode => {
|
|
174
|
+
const depNodeName = depNode.key.name || depNode.key.value;
|
|
175
|
+
const allowDepTypes = [
|
|
176
|
+
'relates',
|
|
177
|
+
'inputs',
|
|
178
|
+
'cases',
|
|
179
|
+
'ignores',
|
|
180
|
+
'type',
|
|
181
|
+
'output',
|
|
182
|
+
'defaultOutput',
|
|
183
|
+
];
|
|
184
|
+
if (!allowDepTypes.includes(depNodeName)) {
|
|
185
|
+
errorMarks(depNode, '多余类型');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (depNodeName === 'relates') {
|
|
190
|
+
if (!isArrayType(depNode)) {
|
|
191
|
+
errorMarks(depNode);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (depNodeName === 'inputs') {
|
|
196
|
+
if (!isArrayType(depNode)) {
|
|
197
|
+
errorMarks(depNode);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (depNodeName === 'cases') {
|
|
202
|
+
if (!isArrayType(depNode)) {
|
|
203
|
+
errorMarks(depNode);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (depNodeName === 'ignores') {
|
|
208
|
+
if (!isArrayType(depNode)) {
|
|
209
|
+
errorMarks(depNode);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (itemName === 'render' && !isFieldRenderType(item)) {
|
|
218
|
+
errorMarks(item);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* layout
|
|
227
|
+
*/
|
|
228
|
+
if (name === 'layout') {
|
|
229
|
+
if (!isLayoutType(node)) {
|
|
230
|
+
errorMarks(node);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 请求校验
|
|
237
|
+
*/
|
|
238
|
+
const fetchType = [
|
|
239
|
+
'remoteSource',
|
|
240
|
+
'remoteDataSource',
|
|
241
|
+
'remoteValues',
|
|
242
|
+
'submit',
|
|
243
|
+
];
|
|
244
|
+
if (fetchType.includes(name)) {
|
|
245
|
+
if (!isObjectType(node)) {
|
|
246
|
+
errorMarks(node, '应为对象类型');
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
requiredValidate(node.value, 'url');
|
|
250
|
+
const { properties } = node.value;
|
|
251
|
+
if (!properties) return;
|
|
252
|
+
properties.forEach(item => {
|
|
253
|
+
const itemName = item.key.name || item.key.value;
|
|
254
|
+
if (itemName === 'url' && !isStringType(item)) {
|
|
255
|
+
errorMarks(item);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (itemName === 'method' && !isMethodType(item)) {
|
|
259
|
+
errorMarks(item);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (itemName === 'params' && !isObjectType(item)) {
|
|
263
|
+
errorMarks(item);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (itemName === 'extraParams' && !isObjectType(item)) {
|
|
267
|
+
errorMarks(item);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (itemName === 'convertParams' && !isFunctionType(item)) {
|
|
271
|
+
errorMarks(item);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (itemName === 'converter' && !isFunctionType(item)) {
|
|
275
|
+
errorMarks(item);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* columns
|
|
283
|
+
*/
|
|
284
|
+
if (name === 'columns') {
|
|
285
|
+
if (!isArrayType(node)) {
|
|
286
|
+
errorMarks(node);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const { elements } = node.value || {};
|
|
291
|
+
elements.forEach(column => {
|
|
292
|
+
if (!isObjectType(column)) {
|
|
293
|
+
errorMarks(column, '应为对象类型');
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const { properties } = column;
|
|
298
|
+
if (!properties) return;
|
|
299
|
+
properties.forEach(item => {
|
|
300
|
+
const itemName = item?.key?.name || item?.key?.value || item.value;
|
|
301
|
+
if (itemName === 'key') {
|
|
302
|
+
if (!isStringType(item)) {
|
|
303
|
+
errorMarks(item, '应为字符串类型');
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (itemName === 'title') {
|
|
308
|
+
if (!isStringType(item)) {
|
|
309
|
+
errorMarks(item, '应为字符串类型');
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (itemName === 'render') {
|
|
314
|
+
if (!isColumnRender(item)) {
|
|
315
|
+
errorMarks(item);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* mode
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
if (name === 'mode') {
|
|
328
|
+
if (!isModeType(node)) {
|
|
329
|
+
errorMarks(node, 'mode可选类型为view create edit');
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* action
|
|
336
|
+
*/
|
|
337
|
+
if (name === 'actionsRender' || name === 'leftActionsRender') {
|
|
338
|
+
if (!isActionType(node)) {
|
|
339
|
+
errorMarks(node);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* formItem
|
|
346
|
+
*/
|
|
347
|
+
if (name === 'itemLayout') {
|
|
348
|
+
if (!isObjectType(node)) {
|
|
349
|
+
errorMarks(node);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const { properties } = node.value;
|
|
354
|
+
properties.forEach(item => {
|
|
355
|
+
const itemName = item?.key?.name || item?.key?.value || item.value;
|
|
356
|
+
if (itemName === 'span') {
|
|
357
|
+
if (!isNumberType(item)) {
|
|
358
|
+
errorMarks(item);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (itemName === 'gutter') {
|
|
363
|
+
if (!isNumberType(item)) {
|
|
364
|
+
errorMarks(item);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (itemName === 'offset') {
|
|
369
|
+
if (!isNumberType(item)) {
|
|
370
|
+
errorMarks(item);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (itemName === 'labelCol') {
|
|
376
|
+
if (!isObjectType(item)) {
|
|
377
|
+
errorMarks(item);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (itemName === 'wrapperCol') {
|
|
382
|
+
if (!isObjectType(item)) {
|
|
383
|
+
errorMarks(item);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export default monaco => [
|
|
2
|
+
{
|
|
3
|
+
type: 'action',
|
|
4
|
+
label: 'back',
|
|
5
|
+
detail: '返回上一级',
|
|
6
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
7
|
+
insertTextRules:
|
|
8
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
9
|
+
insertText: "'back'",
|
|
10
|
+
documentation: {
|
|
11
|
+
value: ``,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'action',
|
|
16
|
+
label: 'request',
|
|
17
|
+
detail: '请求',
|
|
18
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
19
|
+
insertTextRules:
|
|
20
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
21
|
+
insertText:
|
|
22
|
+
'{\n type: "request",\n url: "${1:\u002Fsula.json}",\n method: "${2:get}",\n},',
|
|
23
|
+
documentation: {
|
|
24
|
+
value: ``,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'action',
|
|
29
|
+
label: 'forward',
|
|
30
|
+
detail: '前进一级',
|
|
31
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
32
|
+
insertTextRules:
|
|
33
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
34
|
+
insertText: "'forward'",
|
|
35
|
+
documentation: {
|
|
36
|
+
value: ``,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'action',
|
|
41
|
+
label: 'modalform',
|
|
42
|
+
detail: '弹框表单插件',
|
|
43
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
44
|
+
insertTextRules:
|
|
45
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
46
|
+
insertText:
|
|
47
|
+
'{\n type: "modalform",\n title: "Title",\n mode: "edit",\n fields: [\n {\n name: "input",\n label: "input",\n field: {\n type: "input",\n props: {\n placeholder: "请输入"\n }\n },\n rules: [\n {\n required: true,\n message: "请输入"\n }\n ]\n }\n ],\n remoteValues: {\n url: "\u002Fdetail.json",\n method: "post",\n params: {\n id: 1,\n },\n },\n submit: {\n url: "\u002Fadd.json",\n method: "post"\n },\n},',
|
|
48
|
+
documentation: {
|
|
49
|
+
value: `
|
|
50
|
+
属性名 | 描述 | 类型
|
|
51
|
+
---|:--:|---:
|
|
52
|
+
fields | 表单配置 | -
|
|
53
|
+
title | 弹框标题 | -
|
|
54
|
+
mode | 表单模式 | -
|
|
55
|
+
remoteValues | 远程表单值的请求配置 | -
|
|
56
|
+
submit | 提交表单数据的请求配置 | -
|
|
57
|
+
`,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'action',
|
|
62
|
+
label: 'drawerform',
|
|
63
|
+
detail: '弹框表单插件',
|
|
64
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
65
|
+
insertTextRules:
|
|
66
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
67
|
+
insertText:
|
|
68
|
+
'{\n type: "drawerform",\n title: "Title",\n mode: "edit",\n fields: [\n {\n name: "input",\n label: "input",\n field: {\n type: "input",\n props: {\n placeholder: "请输入"\n }\n },\n rules: [\n {\n required: true,\n message: "请输入"\n }\n ]\n }\n ],\n remoteValues: {\n url: "\u002Fdetail.json",\n method: "post",\n params: {\n id: 1,\n },\n },\n submit: {\n url: "\u002Fadd.json",\n method: "post"\n },\n},',
|
|
69
|
+
documentation: {
|
|
70
|
+
value: `
|
|
71
|
+
属性名 | 描述 | 类型
|
|
72
|
+
---|:--:|---:
|
|
73
|
+
fields | 表单配置 | -
|
|
74
|
+
title | 抽屉标题 | -
|
|
75
|
+
mode | 表单模式 | -
|
|
76
|
+
remoteValues | 远程表单值的请求配置 | -
|
|
77
|
+
submit | 提交表单数据的请求配置 | -
|
|
78
|
+
`,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'action',
|
|
83
|
+
label: 'refreshtable',
|
|
84
|
+
detail: '刷新表格',
|
|
85
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
86
|
+
insertTextRules:
|
|
87
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
88
|
+
insertText: "'refreshtable'",
|
|
89
|
+
documentation: {
|
|
90
|
+
value: ``,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'action',
|
|
95
|
+
label: 'resettable',
|
|
96
|
+
detail: '重置表格',
|
|
97
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
98
|
+
insertTextRules:
|
|
99
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
100
|
+
insertText: "'resettable'",
|
|
101
|
+
documentation: {
|
|
102
|
+
value: ``,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
type: 'action',
|
|
107
|
+
label: 'route',
|
|
108
|
+
detail: '路由跳转',
|
|
109
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
110
|
+
insertTextRules:
|
|
111
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
112
|
+
insertText:
|
|
113
|
+
'{\n type: "route",\n path: "${1:\u002Fcreate}",\n params: {\n "${2:mode}": "${3:create}"\n },\n},',
|
|
114
|
+
documentation: {
|
|
115
|
+
value: ``,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default monaco => [
|
|
2
|
+
{
|
|
3
|
+
type: 'dependency',
|
|
4
|
+
label: 'dependency',
|
|
5
|
+
detail: '级联插件',
|
|
6
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
7
|
+
insertTextRules:
|
|
8
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
9
|
+
insertText:
|
|
10
|
+
'dependency: {\n ${1:value}: {\n relates: ["${2:relateName}"],\n inputs: [["${3:relateValue}"]],\n output: ${4:"outputValue"},\n ignores: [[${5:"ignoreValue"}]],\n defaultOutput: ${6:"value"},\n },\n},',
|
|
11
|
+
documentation: {
|
|
12
|
+
value: `### 表单级联配置 [文档](https://doc.sula.now.sh/zh/plugin/form-dependency.html)
|
|
13
|
+
#### 可选value visible source disabled 配置
|
|
14
|
+
* **relates** 受哪项表单影响
|
|
15
|
+
* **inputs** relates数组对应的表单值
|
|
16
|
+
* **output** 匹配到inputs时 输出值
|
|
17
|
+
* **ignores** relates忽略的值
|
|
18
|
+
* **defaultOutput** 匹配ignores或未匹配到inputs时,输出值
|
|
19
|
+
`,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import dependency from './dependency';
|
|
2
|
+
import actions from './actions';
|
|
3
|
+
import request from './request';
|
|
4
|
+
|
|
5
|
+
function registerSuggestions(monaco) {
|
|
6
|
+
monaco.languages.registerCompletionItemProvider('javascript', {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
provideCompletionItems(model, position) {
|
|
9
|
+
// 其他提示
|
|
10
|
+
return {
|
|
11
|
+
suggestions: [
|
|
12
|
+
...dependency(monaco),
|
|
13
|
+
...actions(monaco),
|
|
14
|
+
...request(monaco),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default registerSuggestions;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export default monaco => [
|
|
2
|
+
{
|
|
3
|
+
type: 'fetch',
|
|
4
|
+
label: 'remoteDataSource',
|
|
5
|
+
detail: '远程表单值',
|
|
6
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
7
|
+
insertTextRules:
|
|
8
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
9
|
+
insertText:
|
|
10
|
+
"remoteDataSource: {\n url: '${1:\u002Fsula.json}',\n method: '${2:GET}',\n params: {\n '${3:name}': '${4:sula}'\n },\n convertParams({ params }) {\n return params;\n },\n converter({ data }) {\n return data;\n },\n},",
|
|
11
|
+
documentation: {
|
|
12
|
+
value: `
|
|
13
|
+
属性名 | 描述 | 类型
|
|
14
|
+
---|:--:|---:
|
|
15
|
+
url | 请求地址 |string
|
|
16
|
+
method| 请求方法 |'post' 'get'
|
|
17
|
+
params | 请求参数 | object
|
|
18
|
+
convertParams | 请求参数转换方法 | (ctx, config) => params
|
|
19
|
+
converter | 返回参数转换方法 | (ctx, config) => any
|
|
20
|
+
`,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'fetch',
|
|
25
|
+
label: 'remoteSource',
|
|
26
|
+
detail: '远程数据源',
|
|
27
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
28
|
+
insertTextRules:
|
|
29
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
30
|
+
insertText:
|
|
31
|
+
"remoteSource: {\n url: '${1:\u002Fsula.json}',\n method: '${2:GET}',\n params: {\n '${3:name}': '${4:sula}'\n },\n convertParams({ params }) {\n return params\n },\n converter({ data }) {\n return data;\n },\n},",
|
|
32
|
+
documentation: {
|
|
33
|
+
value: `
|
|
34
|
+
属性名 | 描述 | 类型
|
|
35
|
+
---|:--:|---:
|
|
36
|
+
url | 请求地址 |string
|
|
37
|
+
method| 请求方法 |'post' 'get'
|
|
38
|
+
params | 请求参数 | object
|
|
39
|
+
convertParams | 请求参数转换方法 | (ctx, config) => params
|
|
40
|
+
converter | 返回参数转换方法 | (ctx, config) => any
|
|
41
|
+
`,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'fetch',
|
|
46
|
+
label: 'remoteValues',
|
|
47
|
+
detail: '远程数据值',
|
|
48
|
+
kind: monaco.languages.CompletionItemKind.Property,
|
|
49
|
+
insertTextRules:
|
|
50
|
+
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
51
|
+
insertText:
|
|
52
|
+
"remoteValues: {\n url: '${1:\u002Fsula.json}',\n method: '${2:GET}',\n params: {\n '${3:name}': '${4:sula}'\n },\n convertParams({ params }) {\n return params\n },\n converter({ data }) {\n return data;\n },\n},",
|
|
53
|
+
documentation: {
|
|
54
|
+
value: `
|
|
55
|
+
属性名 | 描述 | 类型
|
|
56
|
+
---|:--:|---:
|
|
57
|
+
url | 请求地址 |string
|
|
58
|
+
method| 请求方法 |'post' 'get'
|
|
59
|
+
params | 请求参数 | object
|
|
60
|
+
convertParams | 请求参数转换方法 | (ctx, config) => params
|
|
61
|
+
converter | 返回参数转换方法 | (ctx, config) => any
|
|
62
|
+
`,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
];
|