@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,346 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Typography,
|
|
4
|
+
Button,
|
|
5
|
+
message,
|
|
6
|
+
Popconfirm,
|
|
7
|
+
Tooltip,
|
|
8
|
+
Row,
|
|
9
|
+
Col,
|
|
10
|
+
Space,
|
|
11
|
+
} from 'antd';
|
|
12
|
+
import Editor, { monaco } from '@monaco-editor/react';
|
|
13
|
+
import serialize, { deserialize } from '@/utils/serialize';
|
|
14
|
+
import {
|
|
15
|
+
BulbOutlined,
|
|
16
|
+
PlayCircleOutlined,
|
|
17
|
+
DeleteOutlined,
|
|
18
|
+
CopyOutlined,
|
|
19
|
+
SaveOutlined,
|
|
20
|
+
FullscreenOutlined,
|
|
21
|
+
FullscreenExitOutlined,
|
|
22
|
+
} from '@ant-design/icons';
|
|
23
|
+
import validateSulaConfig from './lint';
|
|
24
|
+
import * as acorn from 'acorn';
|
|
25
|
+
import * as walk from 'acorn-walk';
|
|
26
|
+
import ConfigTree, { iconRender, nameRender } from '../configTree';
|
|
27
|
+
import registerSuggestions from './suggestions';
|
|
28
|
+
import style from './index.less';
|
|
29
|
+
|
|
30
|
+
const { Title } = Typography;
|
|
31
|
+
const STRTEMP = 'const config = ';
|
|
32
|
+
|
|
33
|
+
const getEditorValue = data => {
|
|
34
|
+
return `${STRTEMP}${serialize(data, { space: 2, unsafe: true })}`;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let isRegister;
|
|
38
|
+
let decorations = [];
|
|
39
|
+
|
|
40
|
+
export default props => {
|
|
41
|
+
const monacoRef = React.useRef(null);
|
|
42
|
+
const {
|
|
43
|
+
onRun,
|
|
44
|
+
value,
|
|
45
|
+
type,
|
|
46
|
+
onFullScreen = () => {},
|
|
47
|
+
shallowHeight = 0,
|
|
48
|
+
} = props;
|
|
49
|
+
|
|
50
|
+
const editorRef = React.useRef(null);
|
|
51
|
+
const [highLightLine, setHighLightLine] = React.useState();
|
|
52
|
+
const [isFull, setFull] = React.useState(false);
|
|
53
|
+
|
|
54
|
+
const isTableAllValue = !!value?.columns;
|
|
55
|
+
|
|
56
|
+
const finalValue = getEditorValue(isTableAllValue ? {columns: value?.columns, fields: value?.fields} : value);
|
|
57
|
+
const [treeData, setTreeData] = React.useState(finalValue);
|
|
58
|
+
|
|
59
|
+
const handleCopy = () => {
|
|
60
|
+
const value1 = editorRef.current.getValue().slice(STRTEMP.length);
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const res = deserialize(value1);
|
|
64
|
+
onRun(isTableAllValue ? {...value, columns: res.columns, fields: res.fields}: res, true);
|
|
65
|
+
formatDocument();
|
|
66
|
+
setFull(false);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
message.error(`JSON 格式错误`);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const formatDocument = () => {
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
editorRef.current &&
|
|
75
|
+
editorRef.current.getAction('editor.action.formatDocument').run();
|
|
76
|
+
}, 300);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
monaco.init().then(ref => {
|
|
80
|
+
monacoRef.current = ref;
|
|
81
|
+
if (!isRegister) {
|
|
82
|
+
registerSuggestions(ref);
|
|
83
|
+
isRegister = true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const onEditorDidMount = (_monaco, editor) => {
|
|
88
|
+
editorRef.current = editor;
|
|
89
|
+
const model = editor.getModel();
|
|
90
|
+
|
|
91
|
+
formatDocument();
|
|
92
|
+
|
|
93
|
+
editor.onKeyDown(e => {
|
|
94
|
+
if (e.shiftKey) {
|
|
95
|
+
editorRef.current &&
|
|
96
|
+
editorRef.current.trigger(
|
|
97
|
+
'auto completion',
|
|
98
|
+
'editor.action.triggerSuggest',
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
editor.onDidChangeCursorPosition(e => {
|
|
104
|
+
const lineCount = editor.getModel().getLineCount();
|
|
105
|
+
if (e.position.lineNumber === 1) {
|
|
106
|
+
editor.setPosition({
|
|
107
|
+
lineNumber: 2,
|
|
108
|
+
column: 1,
|
|
109
|
+
});
|
|
110
|
+
} else if (e.position.lineNumber === lineCount) {
|
|
111
|
+
editor.setPosition({
|
|
112
|
+
lineNumber: lineCount - 1,
|
|
113
|
+
column: 1,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
editor.onMouseDown(event => {
|
|
119
|
+
clearDecorations();
|
|
120
|
+
onEditorLineChange(event.target.position);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
editor.onKeyDown(event => {
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
const position = editor.getPosition();
|
|
126
|
+
onEditorLineChange(position);
|
|
127
|
+
setTreeData(editor.getValue());
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
editor.onDidChangeModelContent(() => {
|
|
132
|
+
const content = editor.getValue();
|
|
133
|
+
const markers = monacoRef.current.editor.getModelMarkers();
|
|
134
|
+
|
|
135
|
+
if (markers.length > 0) {
|
|
136
|
+
markers.forEach(marker => {
|
|
137
|
+
monacoRef.current.editor.setModelMarkers(
|
|
138
|
+
editor.getModel(),
|
|
139
|
+
marker.owner,
|
|
140
|
+
[],
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const ast = acorn.parse(content, { locations: true });
|
|
145
|
+
walk.full(ast, node => {
|
|
146
|
+
// if (node?.loc?.start?.column < 5) {
|
|
147
|
+
validateSulaConfig(node, monacoRef.current, editor);
|
|
148
|
+
// }
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
function onEditorLineChange(position) {
|
|
154
|
+
const { lineNumber } = position || {};
|
|
155
|
+
setHighLightLine(lineNumber);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// console.log(`点击字段: ${clickType}, 点击字段所属字段: ${type}, 提示: ${suggestionType}`);
|
|
159
|
+
|
|
160
|
+
const onClickRun = () => {
|
|
161
|
+
const value1 = editorRef.current.getValue().slice(STRTEMP.length);
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
const res = deserialize(value1);
|
|
165
|
+
onRun(isTableAllValue ? {...value, columns: res.columns, fields: res.fields}: res);
|
|
166
|
+
formatDocument();
|
|
167
|
+
setFull(false);
|
|
168
|
+
message.success(`Run Success 🎉`);
|
|
169
|
+
} catch (e) {
|
|
170
|
+
message.error(`JSON 格式错误`);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const onClickDelete = () => {
|
|
175
|
+
editorRef.current.setValue(`${STRTEMP}{\n\n}`);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
function clearDecorations() {
|
|
179
|
+
if (decorations.length) {
|
|
180
|
+
decorations = editorRef.current.deltaDecorations(decorations, []);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function setDecorations(range) {
|
|
185
|
+
const [startLineNumber, startColumn, endLineNumber, endColumn] = range;
|
|
186
|
+
const newDecorations = editorRef.current.deltaDecorations(
|
|
187
|
+
[],
|
|
188
|
+
[
|
|
189
|
+
{
|
|
190
|
+
range: {
|
|
191
|
+
endColumn,
|
|
192
|
+
endLineNumber,
|
|
193
|
+
startColumn,
|
|
194
|
+
startLineNumber,
|
|
195
|
+
},
|
|
196
|
+
options: {
|
|
197
|
+
className: 'si-editor-highlight',
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
);
|
|
202
|
+
decorations = decorations.concat(newDecorations);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const handleSelect = (node, hasChildren) => {
|
|
206
|
+
const { loc, name } = node;
|
|
207
|
+
clearDecorations();
|
|
208
|
+
// 高亮
|
|
209
|
+
if (hasChildren) {
|
|
210
|
+
const [line, startColumn] = loc;
|
|
211
|
+
const keyPosition = [line, startColumn, line, 100];
|
|
212
|
+
setDecorations(keyPosition);
|
|
213
|
+
} else {
|
|
214
|
+
setDecorations(loc);
|
|
215
|
+
}
|
|
216
|
+
editorRef.current.revealLine(loc[0]); // 行跳转
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const handleFullScreen = () => {
|
|
220
|
+
setFull(true);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const handleExitFullScreen = () => {
|
|
224
|
+
setFull(false);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
editorRef?.current?.layout();
|
|
229
|
+
onFullScreen && onFullScreen(isFull);
|
|
230
|
+
}, [isFull]);
|
|
231
|
+
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
editorRef?.current?.layout();
|
|
234
|
+
}, [shallowHeight]);
|
|
235
|
+
|
|
236
|
+
const hasConfigTree = type !== 'editor';
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<div className={isFull ? style.editorWrapper : ''}>
|
|
240
|
+
<div style={{ overflow: 'hidden' }}>
|
|
241
|
+
<Title style={{ float: 'left' }} level={4}>
|
|
242
|
+
代码展示
|
|
243
|
+
</Title>
|
|
244
|
+
<Tooltip title="按 shift 键快速呼出提示">
|
|
245
|
+
<BulbOutlined
|
|
246
|
+
style={{ marginLeft: 8, lineHeight: '32px', cursor: 'pointer' }}
|
|
247
|
+
/>
|
|
248
|
+
</Tooltip>
|
|
249
|
+
<Space style={{ float: 'right' }}>
|
|
250
|
+
<Tooltip title="运行代码">
|
|
251
|
+
<Button
|
|
252
|
+
shape="circle"
|
|
253
|
+
size="small"
|
|
254
|
+
type="primary"
|
|
255
|
+
icon={<PlayCircleOutlined />}
|
|
256
|
+
onClick={onClickRun}
|
|
257
|
+
shape="circle"
|
|
258
|
+
/>
|
|
259
|
+
</Tooltip>
|
|
260
|
+
{/* <Popconfirm title="确定要清空吗?" onConfirm={onClickDelete}>
|
|
261
|
+
<Tooltip title="清空代码">
|
|
262
|
+
<Button
|
|
263
|
+
type="primary"
|
|
264
|
+
icon={<DeleteOutlined />}
|
|
265
|
+
size="small"
|
|
266
|
+
shape="circle"
|
|
267
|
+
/>
|
|
268
|
+
</Tooltip>
|
|
269
|
+
</Popconfirm> */}
|
|
270
|
+
<Tooltip title="保存">
|
|
271
|
+
<Button
|
|
272
|
+
type="primary"
|
|
273
|
+
icon={<SaveOutlined />}
|
|
274
|
+
onClick={handleCopy}
|
|
275
|
+
style={{
|
|
276
|
+
border: 'none',
|
|
277
|
+
}}
|
|
278
|
+
shape="circle"
|
|
279
|
+
size="small"
|
|
280
|
+
/>
|
|
281
|
+
</Tooltip>
|
|
282
|
+
<div>
|
|
283
|
+
<Tooltip title="退出全屏">
|
|
284
|
+
<Button
|
|
285
|
+
type="primary"
|
|
286
|
+
icon={<FullscreenExitOutlined />}
|
|
287
|
+
onClick={handleExitFullScreen}
|
|
288
|
+
style={{
|
|
289
|
+
border: 'none',
|
|
290
|
+
display: !isFull ? 'none' : '',
|
|
291
|
+
}}
|
|
292
|
+
shape="circle"
|
|
293
|
+
size="small"
|
|
294
|
+
/>
|
|
295
|
+
</Tooltip>
|
|
296
|
+
{/* <Tooltip title="全屏编辑">
|
|
297
|
+
<Button
|
|
298
|
+
type="primary"
|
|
299
|
+
icon={<FullscreenOutlined />}
|
|
300
|
+
onClick={handleFullScreen}
|
|
301
|
+
style={{
|
|
302
|
+
border: 'none',
|
|
303
|
+
display: isFull ? 'none' : '',
|
|
304
|
+
}}
|
|
305
|
+
shape="circle"
|
|
306
|
+
size="small"
|
|
307
|
+
/>
|
|
308
|
+
</Tooltip> */}
|
|
309
|
+
</div>
|
|
310
|
+
</Space>
|
|
311
|
+
</div>
|
|
312
|
+
<Row>
|
|
313
|
+
<Col span={hasConfigTree ? 16 : 24}>
|
|
314
|
+
<Editor
|
|
315
|
+
height={`calc(100vh - ${shallowHeight + 100}px)`}
|
|
316
|
+
language="javascript"
|
|
317
|
+
editorDidMount={onEditorDidMount}
|
|
318
|
+
options={{
|
|
319
|
+
selectOnLineNumbers: true,
|
|
320
|
+
renderSideBySide: false,
|
|
321
|
+
}}
|
|
322
|
+
value={finalValue}
|
|
323
|
+
// value={{columns: finalValue.columns, fields: finalValue.fields}}
|
|
324
|
+
/>
|
|
325
|
+
</Col>
|
|
326
|
+
{hasConfigTree && (
|
|
327
|
+
<Col span={8}>
|
|
328
|
+
<div className={style.title}>属性节点树</div>
|
|
329
|
+
<ConfigTree
|
|
330
|
+
style={{
|
|
331
|
+
height: 'calc(100vh - 300px)',
|
|
332
|
+
overflowY: 'scroll',
|
|
333
|
+
}}
|
|
334
|
+
level={1}
|
|
335
|
+
data={treeData}
|
|
336
|
+
onSelect={handleSelect}
|
|
337
|
+
currentLine={highLightLine}
|
|
338
|
+
iconRender={iconRender}
|
|
339
|
+
nameRender={nameRender}
|
|
340
|
+
/>
|
|
341
|
+
</Col>
|
|
342
|
+
)}
|
|
343
|
+
</Row>
|
|
344
|
+
</div>
|
|
345
|
+
);
|
|
346
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
:global {
|
|
2
|
+
.si-editor-highlight {
|
|
3
|
+
background: #1990ffab;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.title {
|
|
8
|
+
color: #1890ff;
|
|
9
|
+
padding: 12px;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.editorWrapper {
|
|
14
|
+
position: fixed;
|
|
15
|
+
left: 0;
|
|
16
|
+
right: 0;
|
|
17
|
+
top: 0;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
padding: 24px;
|
|
20
|
+
background-color: #fff;
|
|
21
|
+
z-index: 10000;
|
|
22
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { isString, isNumber, isBoolean, lowerCase } from 'lodash';
|
|
2
|
+
|
|
3
|
+
const getData = data => data.value || data;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* 其他类型暂时忽略
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const isIgnoreType = node => {
|
|
11
|
+
return getData(node).type === 'ConditionalExpression';
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 基础类型
|
|
16
|
+
*/
|
|
17
|
+
export const isStringType = node => {
|
|
18
|
+
if (isIgnoreType(node)) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return isString(getData(node).value);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const isArrayType = node => {
|
|
25
|
+
if (isIgnoreType(node)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return getData(node).type === 'ArrayExpression';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const isNumberType = node => {
|
|
32
|
+
if (isIgnoreType(node)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return isNumber(getData(node).value);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const isBooleanType = node => {
|
|
39
|
+
if (isIgnoreType(node)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return isBoolean(getData(node).value);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const isObjectType = node => {
|
|
46
|
+
if (isIgnoreType(node)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return getData(node).type === 'ObjectExpression';
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const isEmptyObjectType = node => {
|
|
53
|
+
if (isIgnoreType(node)) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return isObjectType(node) && !getData(node).value;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const isFunctionType = node => {
|
|
60
|
+
if (isIgnoreType(node)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
getData(node).type === 'ArrowFunctionExpression' ||
|
|
65
|
+
getData(node).type === 'FunctionExpression' ||
|
|
66
|
+
getData(node).type === 'ObjectMethod'
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* field
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
export const isNameType = node => {
|
|
75
|
+
return isStringType(node) || isNumberType(node) || isArrayType(node);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const isFieldRenderType = node => {
|
|
79
|
+
return isStringType(node) || isObjectType(node) || isFunctionType(node);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const isLayoutType = node => {
|
|
83
|
+
if (isIgnoreType(node)) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return ['vertical', 'horizontal', 'inline'].indexOf(getData(node).value) > -1;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const isModeType = node => {
|
|
90
|
+
// console.log(getv(node).value);
|
|
91
|
+
if (isIgnoreType(node)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return ['view', 'create', 'edit'].indexOf(getData(node).value) > -1;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 通用
|
|
99
|
+
*/
|
|
100
|
+
export const isFetchType = node => {
|
|
101
|
+
const { properties } = getData(node);
|
|
102
|
+
if (!properties.length) return false;
|
|
103
|
+
return properties.some(item => {
|
|
104
|
+
const { key, value } = item || {};
|
|
105
|
+
if ((key.name || key.value) === 'url') {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const isMethodType = node => {
|
|
112
|
+
if (isIgnoreType(node)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return ['post', 'get', 'delete'].indexOf(lowerCase(getData(node).value)) > -1;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* table
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
export const isColumnRender = node => {
|
|
123
|
+
if (isIgnoreType(node)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
return (
|
|
127
|
+
isStringType(node) ||
|
|
128
|
+
isObjectType(node) ||
|
|
129
|
+
isArrayType(node) ||
|
|
130
|
+
isFunctionType(node)
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* action
|
|
136
|
+
*/
|
|
137
|
+
export const isActionType = node => {
|
|
138
|
+
if (isIgnoreType(node)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return (
|
|
142
|
+
isStringType(node) ||
|
|
143
|
+
isObjectType(node) ||
|
|
144
|
+
isArrayType(node) ||
|
|
145
|
+
isFunctionType(node)
|
|
146
|
+
);
|
|
147
|
+
};
|