form-driver 0.4.19 → 0.4.21
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/README.md +15 -0
- package/dist/m3.js +1 -1
- package/es/m3.js +1734 -1289
- package/lib/m3.js +1733 -1287
- package/package.json +2 -2
- package/src/framework/Init.tsx +6 -0
- package/src/framework/MUtil.tsx +145 -0
- package/src/framework/Schema.ts +16 -2
- package/src/index.ts +0 -1
- package/src/types/MDateRangeType.ts +65 -24
- package/src/types/MDateTimeType.ts +73 -29
- package/src/ui/editor/basic/ACascadePicker.tsx +23 -15
- package/src/ui/editor/basic/ADatetimePicker.tsx +103 -39
- package/src/ui/editor/basic/AGB2260.tsx +25 -14
- package/src/ui/editor/basic/ARangePicker.tsx +110 -26
- package/src/ui/widget/SelectBox.tsx +35 -15
- package/types/framework/Init.d.ts +1 -0
- package/types/framework/MUtil.d.ts +14 -0
- package/types/framework/Schema.d.ts +11 -0
- package/types/index.d.ts +0 -1
- package/types/types/MDateRangeType.d.ts +2 -0
- package/types/types/MDateTimeType.d.ts +2 -2
- package/types/ui/editor/basic/ADatetimePicker.d.ts +2 -1
- package/types/ui/editor/basic/AGB2260.d.ts +1 -0
- package/types/ui/editor/basic/ARangePicker.d.ts +5 -3
- package/types/ui/widget/SelectBox.d.ts +10 -3
package/es/m3.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import 'antd/dist/antd.css';
|
|
2
|
-
import 'antd-mobile/dist/antd-mobile.css';
|
|
3
2
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
-
import { message, DatePicker as DatePicker$1, Cascader, Radio, Rate, Upload, Button, TreeSelect, InputNumber, Checkbox, Modal, Input, Select, Popover, Divider, Popconfirm, List, Row, Col, Space, Table, Spin, Tooltip, Progress, Tabs } from 'antd';
|
|
3
|
+
import { message, ConfigProvider, DatePicker as DatePicker$1, Cascader, Radio, Rate, Upload, Button, TreeSelect, InputNumber, Checkbox, Modal, Input, Select, Popover, Divider, Popconfirm, List, Row, Col, Space, Table, Spin, Tooltip, Progress, Tabs } from 'antd';
|
|
5
4
|
import React, { memo, useRef, useState, useCallback, useEffect, useMemo, createElement } from 'react';
|
|
6
5
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
7
6
|
import _, { result } from 'lodash';
|
|
8
7
|
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
9
8
|
import _construct from '@babel/runtime/helpers/esm/construct';
|
|
10
9
|
import moment from 'moment';
|
|
11
|
-
import { DatePicker, Picker,
|
|
12
|
-
import zhCN from 'antd/
|
|
10
|
+
import { DatePicker, Picker, CascadePicker } from 'antd-mobile';
|
|
11
|
+
import zhCN from 'antd/es/locale/zh_CN';
|
|
13
12
|
import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
14
13
|
import { CloseOutlined, LoadingOutlined, QuestionCircleTwoTone, PlusOutlined, HolderOutlined, CaretUpOutlined, CaretDownOutlined, CloseCircleFilled, CheckOutlined, CaretRightOutlined } from '@ant-design/icons';
|
|
15
14
|
import TextArea from 'antd/lib/input/TextArea';
|
|
@@ -18,8 +17,10 @@ import { draggable, dropTargetForElements, monitorForElements } from '@atlaskit/
|
|
|
18
17
|
import clsx from 'clsx';
|
|
19
18
|
import Button$1 from 'antd/lib/button';
|
|
20
19
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
|
|
20
|
+
import zhCN$1 from 'antd/lib/date-picker/locale/zh_CN';
|
|
21
21
|
import ReactDOM from 'react-dom';
|
|
22
22
|
import debounce from 'lodash/debounce';
|
|
23
|
+
import 'moment/locale/zh-cn';
|
|
23
24
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
24
25
|
import OSS from 'ali-oss';
|
|
25
26
|
|
|
@@ -176,1279 +177,1658 @@ function _createForOfIteratorHelperLoose$e(o, allowArrayLike) { var it = typeof
|
|
|
176
177
|
function _unsupportedIterableToArray$e(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$e(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$e(o, minLen); }
|
|
177
178
|
|
|
178
179
|
function _arrayLikeToArray$e(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* 枚举字段可以写成空格分隔的字符串,也能写成MEnumField[],这个函数将两种形式转换成统一的MEnumField[]
|
|
193
|
-
* @deprecated 改成用MUtils.option
|
|
194
|
-
*/
|
|
195
|
-
standardFields: function standardFields(fs) {
|
|
196
|
-
if (typeof fs === "string") {
|
|
197
|
-
return fs.split(" ").map(function (aEnum) {
|
|
198
|
-
var _kv$;
|
|
199
|
-
|
|
200
|
-
var kv = aEnum.split("=");
|
|
201
|
-
return {
|
|
202
|
-
label: kv[0],
|
|
203
|
-
value: (_kv$ = kv[1]) != null ? _kv$ : kv[0]
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
} else if (fs) {
|
|
207
|
-
return fs;
|
|
208
|
-
} else {
|
|
209
|
-
return [];
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* 获取enumFields或者setFields,返回标准的MEnumField[]
|
|
215
|
-
* @param f 如果f是nil,返回[]
|
|
216
|
-
*/
|
|
217
|
-
option: function option(f) {
|
|
218
|
-
var _result;
|
|
219
|
-
|
|
220
|
-
var result;
|
|
180
|
+
var defaultTheme = {
|
|
181
|
+
READABLE_UNKNOWN: "?",
|
|
182
|
+
READABLE_BLANK: "-",
|
|
183
|
+
READABLE_INVALID: "❓",
|
|
184
|
+
READABLE_ERROR: "❗",
|
|
185
|
+
themeName: "antMiddle"
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* 注册viewer,type,morph(viewer和type之间的关联)
|
|
189
|
+
*/
|
|
221
190
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
} else {
|
|
225
|
-
var ori;
|
|
191
|
+
var Assembly = /*#__PURE__*/function () {
|
|
192
|
+
var _proto = Assembly.prototype;
|
|
226
193
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
194
|
+
/** 根据定义返回View,返回nil表示没有可用的View */
|
|
195
|
+
_proto.getViewerOf = function getViewerOf(f, morph) {
|
|
196
|
+
if (f.editor && morph === "editor") {
|
|
197
|
+
if (_.isString(f.editor)) {
|
|
198
|
+
return _.get(this.viewers, f.editor);
|
|
231
199
|
} else {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
ori = (_ref = (_f$option = f.option) != null ? _f$option : f.setFields) != null ? _ref : f.enumFields; // 只是为了保险
|
|
200
|
+
return f.editor;
|
|
235
201
|
}
|
|
202
|
+
} else if (f.readable && morph === "readable") {
|
|
203
|
+
if (_.isString(f.readable)) {
|
|
204
|
+
return _.get(this.viewers, f.readable);
|
|
205
|
+
} else {
|
|
206
|
+
return f.readable;
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
var viewer = _.get(this.morph, morph + "." + f.type);
|
|
236
210
|
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
var _kv$2;
|
|
240
|
-
|
|
241
|
-
var kv = aEnum.split("=");
|
|
242
|
-
return {
|
|
243
|
-
label: kv[0],
|
|
244
|
-
value: (_kv$2 = kv[1]) != null ? _kv$2 : kv[0]
|
|
245
|
-
};
|
|
246
|
-
});
|
|
211
|
+
if (_.isString(viewer)) {
|
|
212
|
+
return _.get(this.viewers, viewer);
|
|
247
213
|
} else {
|
|
248
|
-
|
|
214
|
+
return viewer;
|
|
249
215
|
}
|
|
250
216
|
}
|
|
217
|
+
};
|
|
251
218
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
/** 如果出错了,返回这么个元素,可能用在BaseEditor子类或者其他的东西上 */
|
|
256
|
-
error: function error(msg, schema) {
|
|
257
|
-
return jsxs("div", {
|
|
258
|
-
style: {
|
|
259
|
-
color: "white",
|
|
260
|
-
border: "1px solid darkgrey",
|
|
261
|
-
background: "red",
|
|
262
|
-
textAlign: "center",
|
|
263
|
-
borderRadius: "5px"
|
|
264
|
-
},
|
|
265
|
-
children: [msg, schema ? jsx("pre", {
|
|
266
|
-
style: {
|
|
267
|
-
whiteSpace: "pre-wrap",
|
|
268
|
-
textAlign: "left"
|
|
269
|
-
},
|
|
270
|
-
children: JSON.stringify(schema)
|
|
271
|
-
}) : undefined]
|
|
272
|
-
}, Date.now());
|
|
273
|
-
},
|
|
274
|
-
sign: function sign(v) {
|
|
275
|
-
if (_.isNil(v)) {
|
|
276
|
-
return null;
|
|
219
|
+
_proto.validate = function validate(s, v, path) {
|
|
220
|
+
if (path === void 0) {
|
|
221
|
+
path = "";
|
|
277
222
|
}
|
|
278
223
|
|
|
279
|
-
|
|
280
|
-
},
|
|
224
|
+
var result = undefined;
|
|
281
225
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
phoneLike: function phoneLike() {
|
|
286
|
-
// eslint-disable-next-line no-restricted-globals
|
|
287
|
-
return screen.height / screen.width > 1.5;
|
|
288
|
-
},
|
|
289
|
-
// /**
|
|
290
|
-
// * 计算文字的宽度
|
|
291
|
-
// * @param text 文字
|
|
292
|
-
// * @param font 字体
|
|
293
|
-
// * @returns 宽度,单位是px
|
|
294
|
-
// */
|
|
295
|
-
// getTextWidth(text:string, font?:string) {
|
|
296
|
-
// var canvas = _messurer ?? (_messurer = document.createElement("canvas"));
|
|
297
|
-
// var context = canvas.getContext("2d");
|
|
298
|
-
// if(!context) {
|
|
299
|
-
// console.error('神奇的事情发生了:canvas.getContext("2d")居然能返回null');
|
|
300
|
-
// return text.length * 10; // 总比出不来好
|
|
301
|
-
// }
|
|
302
|
-
// if(font){
|
|
303
|
-
// context.font = font;
|
|
304
|
-
// }
|
|
305
|
-
// var metrics = context.measureText(text);
|
|
306
|
-
// return metrics.width;
|
|
307
|
-
// }
|
|
226
|
+
for (var _iterator = _createForOfIteratorHelperLoose$e(this.types[s.type].validators), _step; !(_step = _iterator()).done;) {
|
|
227
|
+
var validator = _step.value;
|
|
228
|
+
result = validator(this, s, v, path);
|
|
308
229
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
return 0;
|
|
230
|
+
if (result === "pass" && s.type !== "weight") {
|
|
231
|
+
return undefined;
|
|
232
|
+
} else if (typeof result === "object") {
|
|
233
|
+
MUtil.debug("校验", path, result.message);
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
316
236
|
}
|
|
317
237
|
|
|
318
|
-
return
|
|
319
|
-
}
|
|
238
|
+
return undefined;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
_proto.addViewer = function addViewer(name, v) {
|
|
242
|
+
if (this.viewers[name]) {
|
|
243
|
+
console.error("addViewer: \u5DF2\u7ECF\u5B58\u5728\u540D\u4E3A " + name + " \u7684 Viewer\uFF0C\u65E0\u6CD5\u518D\u6B21\u6DFB\u52A0\uFF01");
|
|
244
|
+
return;
|
|
245
|
+
} else {
|
|
246
|
+
this.viewers[name] = v;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
320
249
|
|
|
250
|
+
_proto.addEditor = function addEditor(name, v) {
|
|
251
|
+
if (this.editors[name]) {
|
|
252
|
+
console.error("addEditor: \u5DF2\u7ECF\u5B58\u5728\u540D\u4E3A " + name + " \u7684 Editor\uFF0C\u65E0\u6CD5\u518D\u6B21\u6DFB\u52A0\uFF01");
|
|
253
|
+
return;
|
|
254
|
+
} else {
|
|
255
|
+
this.editors[name] = v;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
321
258
|
/**
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
259
|
+
* 增加一种数据类型
|
|
260
|
+
* 例:
|
|
261
|
+
* const hpOrg = {name: "hpOrg", type: {validators: ..., toReadable: ...}, editor: HPOrgEditor, readable: "DivViewer"}
|
|
262
|
+
* addType(hpOrg)
|
|
263
|
+
* @param typeParam 类型的描述对象
|
|
326
264
|
*/
|
|
327
|
-
|
|
328
|
-
if (a) {
|
|
329
|
-
var idx = a.indexOf(element);
|
|
265
|
+
;
|
|
330
266
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
267
|
+
_proto.addType = function addType(typeParam) {
|
|
268
|
+
var name = typeParam.name,
|
|
269
|
+
type = typeParam.type,
|
|
270
|
+
editor = typeParam.editor,
|
|
271
|
+
_typeParam$readable = typeParam.readable,
|
|
272
|
+
readable = _typeParam$readable === void 0 ? "DivViewer" : _typeParam$readable;
|
|
273
|
+
this.types[name] = type;
|
|
334
274
|
|
|
335
|
-
|
|
336
|
-
} else {
|
|
337
|
-
return a;
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
fieldOfLayout: function fieldOfLayout(fields, spec) {
|
|
341
|
-
var objectFieldMap = _.chain(fields).keyBy("name").value();
|
|
275
|
+
_.set(this.morph, "editor." + name, editor);
|
|
342
276
|
|
|
343
|
-
|
|
277
|
+
_.set(this.morph, "readable." + name, readable);
|
|
278
|
+
};
|
|
344
279
|
|
|
345
|
-
|
|
346
|
-
|
|
280
|
+
function Assembly() {
|
|
281
|
+
var _this = this;
|
|
347
282
|
|
|
348
|
-
|
|
283
|
+
this.types = {};
|
|
284
|
+
this.viewers = {};
|
|
285
|
+
this.editors = {};
|
|
286
|
+
this.morph = {};
|
|
287
|
+
this.theme = defaultTheme;
|
|
349
288
|
|
|
350
|
-
|
|
351
|
-
|
|
289
|
+
this.toReadable = function (s, v, parent) {
|
|
290
|
+
var t = _this.types[s.type];
|
|
352
291
|
|
|
353
|
-
|
|
292
|
+
if (t) {
|
|
293
|
+
var _r;
|
|
354
294
|
|
|
355
|
-
|
|
356
|
-
var def = objectFieldMap[f];
|
|
295
|
+
var r;
|
|
357
296
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
297
|
+
if (_.isString(s.toReadable)) {
|
|
298
|
+
// eslint-disable-next-line no-new-func
|
|
299
|
+
r = new Function("_", "value", "theme", "const {READABLE_UNKNOWN, READABLE_BLANK, READABLE_INVALID, READABLE_ERROR} = theme; return " + s.toReadable)(_, v, _this.theme);
|
|
300
|
+
} else if (_.isFunction(s.toReadable)) {
|
|
301
|
+
r = s.toReadable(v, parent, _this);
|
|
361
302
|
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
303
|
|
|
365
|
-
|
|
366
|
-
},
|
|
304
|
+
r = (_r = r) != null ? _r : t.toReadable(_this, s, v);
|
|
367
305
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
* 2. path是""时返回原始对象
|
|
372
|
-
* @param a
|
|
373
|
-
* @param path
|
|
374
|
-
*/
|
|
375
|
-
get: function get(a, path) {
|
|
376
|
-
if (_.isNil(a) || _.isNil(path)) {
|
|
377
|
-
return undefined;
|
|
378
|
-
} else if (path === "") {
|
|
379
|
-
return a;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return _.get(a, path);
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* a : database
|
|
387
|
-
* v : newValue
|
|
388
|
-
* 跟lodash的set一样,除了path是""时等效于_.assign(a, v)
|
|
389
|
-
*/
|
|
390
|
-
set: function set(a, path, v) {
|
|
391
|
-
if (path === "") {
|
|
392
|
-
// 如果 database 是数组,需要特殊处理
|
|
393
|
-
if (_.isArray(a)) a.length = v.length;
|
|
394
|
-
|
|
395
|
-
_.assign(a, v);
|
|
396
|
-
} else {
|
|
397
|
-
_.set(a, path, v);
|
|
398
|
-
}
|
|
399
|
-
},
|
|
400
|
-
debug: function debug(d) {
|
|
401
|
-
for (var _len = arguments.length, optionalParams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
402
|
-
optionalParams[_key - 1] = arguments[_key];
|
|
403
|
-
}
|
|
306
|
+
if (s.postfix) {
|
|
307
|
+
r += s.postfix;
|
|
308
|
+
}
|
|
404
309
|
|
|
405
|
-
|
|
406
|
-
|
|
310
|
+
return r;
|
|
311
|
+
} else {
|
|
312
|
+
return s.type + "类型无效";
|
|
313
|
+
}
|
|
314
|
+
}; // 校验types是否使用了无效的编辑器名字
|
|
407
315
|
|
|
408
|
-
/**
|
|
409
|
-
* 填入默认值
|
|
410
|
-
* @param schema 你懂得
|
|
411
|
-
* @param database 数据库,会被修改的
|
|
412
|
-
* @param path 路径
|
|
413
|
-
*/
|
|
414
|
-
applyDefaultValue: function applyDefaultValue(schema, database, path) {
|
|
415
|
-
// FIXME 多测试下,type是object或其他简单类型的情况
|
|
416
|
-
if (schema.type === "object") {
|
|
417
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose$e((_schema$objectFields = schema.objectFields) != null ? _schema$objectFields : []), _step3; !(_step3 = _iterator3()).done;) {
|
|
418
|
-
var _schema$objectFields;
|
|
419
316
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
_.set(database, path, schema.defaultValue);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
filterHide: function filterHide(schema, database) {
|
|
430
|
-
var _schema$objectFields2;
|
|
317
|
+
for (var morphName in this.morph) {
|
|
318
|
+
for (var typeName in this.morph[morphName]) {
|
|
319
|
+
if (!this.types[typeName]) {
|
|
320
|
+
throw SyntaxError("\u7C7B\u578B" + typeName + "\u672A\u5B9A\u4E49");
|
|
321
|
+
}
|
|
431
322
|
|
|
432
|
-
|
|
433
|
-
var hm = MUtil.hideMap(database, (_schema$objectFields2 = schema.objectFields) != null ? _schema$objectFields2 : [], schema.uispec);
|
|
434
|
-
var finalData = _.isArray(database) ? [] : {};
|
|
323
|
+
var viewerName = this.morph[morphName][typeName];
|
|
435
324
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
325
|
+
if (!this.viewers[viewerName]) {
|
|
326
|
+
throw SyntaxError("\u89C6\u56FE" + viewerName + "\u672A\u5B9A\u4E49");
|
|
327
|
+
}
|
|
439
328
|
}
|
|
440
329
|
}
|
|
330
|
+
}
|
|
441
331
|
|
|
442
|
-
|
|
443
|
-
|
|
332
|
+
return Assembly;
|
|
333
|
+
}();
|
|
334
|
+
var assembly = new Assembly();
|
|
444
335
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
*/
|
|
455
|
-
hideMap: function hideMap(database, objectFields, uispec) {
|
|
456
|
-
// 构造字段依赖计算的脚本,类似这样:
|
|
457
|
-
// let {name,role,gender,alias,tel,email,citizenship,student} = {"name":"aaa","alias":"bbb","tel":"1"};citizenship=='中国大陆'
|
|
458
|
-
var l1fields = _.uniq( // 名字要唯一
|
|
459
|
-
objectFields.filter(function (e) {
|
|
460
|
-
return !!e.name;
|
|
461
|
-
}) // 过滤掉没有名字的字段
|
|
462
|
-
.map(function (e) {
|
|
463
|
-
return _.first(e.name.split("."));
|
|
464
|
-
}) // 对于objectFields里类似student.no/student.state的字段,这里只要拼一个student就可以了
|
|
465
|
-
);
|
|
336
|
+
/**
|
|
337
|
+
* 非空校验,数据不能是null/undefined/""/NaN/[]
|
|
338
|
+
* 要在其他条件之前,以便required=false时短路掉nil的数据,否则后面的校验全都得处理nil
|
|
339
|
+
* @param a
|
|
340
|
+
* @param schema
|
|
341
|
+
* @param value
|
|
342
|
+
* @param path
|
|
343
|
+
* @returns
|
|
344
|
+
*/
|
|
466
345
|
|
|
467
|
-
|
|
346
|
+
function validateRequired$1(a, schema, value, path) {
|
|
347
|
+
if (schema.required) {
|
|
348
|
+
if (_.isNil(value) || value === "" || _.isNaN(value) || _.isArray(value) && value.length == 0) {
|
|
349
|
+
return {
|
|
350
|
+
message: "您还没有填完这一项",
|
|
351
|
+
path: path
|
|
352
|
+
};
|
|
353
|
+
} // 凡是总有例外
|
|
468
354
|
|
|
469
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose$e(objectFields), _step4; !(_step4 = _iterator4()).done;) {
|
|
470
|
-
var f = _step4.value;
|
|
471
355
|
|
|
472
|
-
|
|
473
|
-
|
|
356
|
+
if (schema.type === "set" && schema.openOption) {
|
|
357
|
+
if (value.length === 1 && !value[0]) {
|
|
358
|
+
return {
|
|
359
|
+
message: "您还没有填完这一项",
|
|
360
|
+
path: path
|
|
361
|
+
}; // 开放set,只勾了开放选项,没有填内容,也要算空
|
|
474
362
|
}
|
|
475
363
|
}
|
|
364
|
+
} else {
|
|
365
|
+
if (_.isNil(value)) {
|
|
366
|
+
return "pass";
|
|
367
|
+
}
|
|
368
|
+
}
|
|
476
369
|
|
|
477
|
-
|
|
478
|
-
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
/** 和validateRequired相同,但不短路 */
|
|
479
373
|
|
|
480
|
-
|
|
374
|
+
function validateRequiredNS(a, schema, value, path) {
|
|
375
|
+
var v = validateRequired$1(a, schema, value, path);
|
|
481
376
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
377
|
+
if (v === "pass") {
|
|
378
|
+
return undefined;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function validateDateMinMax(a, schema, value, path) {
|
|
382
|
+
if (schema.min) {
|
|
383
|
+
if (!value || value < schema.min) {
|
|
384
|
+
return {
|
|
385
|
+
message: "\u8BF7\u9009\u62E9" + schema.min + "\u4E4B\u540E\u7684\u65F6\u95F4",
|
|
386
|
+
path: path
|
|
387
|
+
};
|
|
485
388
|
}
|
|
389
|
+
}
|
|
486
390
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
391
|
+
if (schema.max) {
|
|
392
|
+
if (!value || value > schema.max) {
|
|
393
|
+
return {
|
|
394
|
+
message: "\u8BF7\u9009\u62E9" + schema.min + "\u4E4B\u524D\u7684\u65F6\u95F4",
|
|
395
|
+
path: path
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
}
|
|
493
399
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* 数组项数不超过[min, max]
|
|
404
|
+
* @param schema
|
|
405
|
+
* @param value 应该是个数组
|
|
406
|
+
*/
|
|
497
407
|
|
|
498
|
-
|
|
408
|
+
function validateArrayItemMinMax(a, schema, value, path) {
|
|
409
|
+
if (schema.min) {
|
|
410
|
+
if (!value || value.length < schema.min) {
|
|
411
|
+
return {
|
|
412
|
+
message: "\u81F3\u5C11\u9009\u62E9" + schema.min + "\u9879",
|
|
413
|
+
path: path
|
|
414
|
+
};
|
|
499
415
|
}
|
|
416
|
+
}
|
|
500
417
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
418
|
+
if (schema.max) {
|
|
419
|
+
if (!value || value.length > schema.max) {
|
|
420
|
+
return {
|
|
421
|
+
message: "\u6700\u591A\u9009\u62E9" + schema.max + "\u9879",
|
|
422
|
+
path: path
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
}
|
|
506
426
|
|
|
507
|
-
|
|
427
|
+
return undefined;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* 字符串长度不超过[min, max]
|
|
431
|
+
* @param schema
|
|
432
|
+
* @param value 应该是个字符串
|
|
433
|
+
*/
|
|
508
434
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
return {
|
|
435
|
+
function validateStringMinMax$1(a, schema, value, path) {
|
|
436
|
+
if (schema.min) {
|
|
437
|
+
if (!value || value.length < schema.min) {
|
|
438
|
+
return {
|
|
439
|
+
message: "\u81F3\u5C11" + schema.min + "\u4E2A\u5B57",
|
|
440
|
+
path: path
|
|
441
|
+
};
|
|
513
442
|
}
|
|
514
|
-
}
|
|
443
|
+
}
|
|
515
444
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
445
|
+
if (schema.max) {
|
|
446
|
+
if (value && value.length > schema.max) {
|
|
447
|
+
return {
|
|
448
|
+
message: "\u6700\u591A" + schema.max + "\u4E2A\u5B57",
|
|
449
|
+
path: path
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}
|
|
524
453
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
454
|
+
return undefined;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* 数字不超过[min, max]
|
|
458
|
+
* @param schema
|
|
459
|
+
* @param value 应该是个数字
|
|
460
|
+
*/
|
|
530
461
|
|
|
531
|
-
|
|
462
|
+
function validateNumberMinMax(a, schema, value, path) {
|
|
463
|
+
var temp = Number(value);
|
|
532
464
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
465
|
+
if (!_.isNil(schema.max)) {
|
|
466
|
+
if (!_.isFinite(temp) || temp > schema.max) {
|
|
467
|
+
return {
|
|
468
|
+
message: "\u6700\u591A" + schema.max,
|
|
469
|
+
path: path
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
}
|
|
536
473
|
|
|
537
|
-
|
|
474
|
+
if (!_.isNil(schema.min)) {
|
|
475
|
+
if (!_.isFinite(temp) || temp < schema.min) {
|
|
476
|
+
return {
|
|
477
|
+
message: "\u6700\u5C11" + schema.min,
|
|
478
|
+
path: path
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
}
|
|
538
482
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
483
|
+
return undefined;
|
|
484
|
+
}
|
|
485
|
+
function generateRegexValidate$1(regex, mismatchMsg) {
|
|
486
|
+
return function (a, schema, value, path) {
|
|
487
|
+
var asstr = _.toString(value);
|
|
488
|
+
|
|
489
|
+
if (!regex.test(asstr)) {
|
|
490
|
+
return {
|
|
491
|
+
message: mismatchMsg,
|
|
492
|
+
path: path
|
|
493
|
+
};
|
|
543
494
|
}
|
|
544
|
-
},
|
|
545
|
-
scoreOf: function scoreOf(f, database) {
|
|
546
|
-
var v = _.get(database, f.name);
|
|
547
495
|
|
|
548
|
-
|
|
549
|
-
|
|
496
|
+
return undefined;
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* 数据用Object.prototype.toString.call返回的类型是预期的
|
|
501
|
+
* 可以用Object.prototype.toString.call(<预期的类型>)来查看你想要的数据类型的expectType
|
|
502
|
+
* @param expectType 预期类型,例如:"[object Object]" "[object Null]" "[object Number]" "[object Date]" "[object Array]"
|
|
503
|
+
* @param mismatchMsg 如果不匹配,提示的错误信息
|
|
504
|
+
* @returns
|
|
505
|
+
*/
|
|
550
506
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
var score = 0;
|
|
556
|
-
var opts = MUtil.standardFields(f.setFields);
|
|
507
|
+
function generateJsPrototypeValidate(expectType, mismatchMsg) {
|
|
508
|
+
if (mismatchMsg === void 0) {
|
|
509
|
+
mismatchMsg = "数据有误,请重填此项";
|
|
510
|
+
}
|
|
557
511
|
|
|
558
|
-
|
|
559
|
-
|
|
512
|
+
return function (a, schema, value, path) {
|
|
513
|
+
if (Object.prototype.toString.call(value) == expectType) {
|
|
514
|
+
return undefined;
|
|
515
|
+
} else {
|
|
516
|
+
return {
|
|
517
|
+
message: mismatchMsg,
|
|
518
|
+
path: path
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function generateSchemaValidate(valueSchema, mismatchMsg) {
|
|
524
|
+
return function (a, schema, value, path) {
|
|
525
|
+
var r = assembly.validate(valueSchema, value, "");
|
|
560
526
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
527
|
+
if (!r) {
|
|
528
|
+
return r;
|
|
529
|
+
} else {
|
|
530
|
+
return {
|
|
531
|
+
message: mismatchMsg != null ? mismatchMsg : r.message,
|
|
532
|
+
path: path
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
var Validator = {
|
|
538
|
+
validateRequired: validateRequired$1,
|
|
539
|
+
validateRequiredNS: validateRequiredNS,
|
|
540
|
+
validateDateMinMax: validateDateMinMax,
|
|
541
|
+
validateStringMinMax: validateStringMinMax$1,
|
|
542
|
+
validateNumberMinMax: validateNumberMinMax,
|
|
543
|
+
generateRegexValidate: generateRegexValidate$1
|
|
544
|
+
};
|
|
567
545
|
|
|
568
|
-
|
|
546
|
+
var EmtpyType = {
|
|
547
|
+
validators: [],
|
|
548
|
+
createDefaultValue: function createDefaultValue(assembly, s) {
|
|
549
|
+
if (s.defaultValue) {
|
|
550
|
+
return _.clone(s.defaultValue);
|
|
569
551
|
} else {
|
|
570
|
-
return
|
|
552
|
+
return undefined;
|
|
571
553
|
}
|
|
572
554
|
},
|
|
555
|
+
standardValue: function standardValue(assembly, s, v, strict) {
|
|
556
|
+
return v;
|
|
557
|
+
},
|
|
558
|
+
toReadable: function toReadable(assembly, s, vs) {
|
|
559
|
+
if (_.isNil(vs)) {
|
|
560
|
+
return assembly.theme.READABLE_BLANK;
|
|
561
|
+
}
|
|
573
562
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
563
|
+
return vs;
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
function createDefaultValue(assembly, s) {
|
|
567
|
+
if (s.defaultValue) {
|
|
568
|
+
return _.clone(s.defaultValue);
|
|
569
|
+
} else {
|
|
570
|
+
return undefined;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
584
573
|
|
|
585
|
-
|
|
574
|
+
var MDateTimeType = _.assign({}, EmtpyType, {
|
|
575
|
+
validators: [validateRequired$1, validateDateMinMax],
|
|
576
|
+
antConf: function antConf(schema) {
|
|
577
|
+
var _dataFormat, _dataFormat2, _dataFormat3, _dataFormat4, _dataFormat5, _dataFormat6, _dataFormat7, _dataFormat8;
|
|
586
578
|
|
|
579
|
+
var dataFormat = schema.dataFormat;
|
|
580
|
+
var readableFormat;
|
|
581
|
+
var mode;
|
|
582
|
+
var showTime = false;
|
|
587
583
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
584
|
+
switch (schema.type) {
|
|
585
|
+
case "year":
|
|
586
|
+
mode = "year";
|
|
587
|
+
dataFormat = (_dataFormat = dataFormat) != null ? _dataFormat : "YYYY";
|
|
588
|
+
readableFormat = "YYYY";
|
|
589
|
+
break;
|
|
592
590
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
591
|
+
case "yearMonth":
|
|
592
|
+
mode = "month";
|
|
593
|
+
dataFormat = (_dataFormat2 = dataFormat) != null ? _dataFormat2 : "YYYYMM";
|
|
594
|
+
readableFormat = "YYYY.MM";
|
|
595
|
+
break;
|
|
598
596
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
597
|
+
case "yearMonthDay":
|
|
598
|
+
mode = "date";
|
|
599
|
+
dataFormat = (_dataFormat3 = dataFormat) != null ? _dataFormat3 : "YYYYMMDD";
|
|
600
|
+
readableFormat = "YYYY.MM.DD";
|
|
601
|
+
break;
|
|
602
602
|
|
|
603
|
-
|
|
604
|
-
|
|
603
|
+
case "datetime":
|
|
604
|
+
mode = undefined;
|
|
605
|
+
dataFormat = (_dataFormat4 = dataFormat) != null ? _dataFormat4 : "x";
|
|
606
|
+
readableFormat = "YYYY.MM.DD HH:mm";
|
|
607
|
+
showTime = true;
|
|
608
|
+
break;
|
|
605
609
|
|
|
606
|
-
|
|
610
|
+
case "date":
|
|
611
|
+
switch (schema.datePrecision) {
|
|
612
|
+
case "year":
|
|
613
|
+
mode = "year";
|
|
614
|
+
dataFormat = (_dataFormat5 = dataFormat) != null ? _dataFormat5 : "YYYY";
|
|
615
|
+
readableFormat = "YYYY";
|
|
616
|
+
break;
|
|
607
617
|
|
|
608
|
-
|
|
609
|
-
|
|
618
|
+
case "month":
|
|
619
|
+
mode = "month";
|
|
620
|
+
dataFormat = (_dataFormat6 = dataFormat) != null ? _dataFormat6 : "YYYYMM";
|
|
621
|
+
readableFormat = "YYYY.MM";
|
|
622
|
+
break;
|
|
610
623
|
|
|
611
|
-
|
|
624
|
+
case "minute":
|
|
625
|
+
mode = undefined;
|
|
626
|
+
dataFormat = (_dataFormat7 = dataFormat) != null ? _dataFormat7 : "x";
|
|
627
|
+
readableFormat = "YYYY.MM.DD HH:mm";
|
|
628
|
+
showTime = true;
|
|
629
|
+
break;
|
|
612
630
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
631
|
+
default:
|
|
632
|
+
// "day" 或未指定
|
|
633
|
+
mode = "date";
|
|
634
|
+
dataFormat = (_dataFormat8 = dataFormat) != null ? _dataFormat8 : "YYYYMMDD";
|
|
635
|
+
readableFormat = "YYYY.MM.DD";
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
618
638
|
|
|
619
|
-
|
|
639
|
+
break;
|
|
640
|
+
// case "yearAndQuarter":
|
|
641
|
+
// case "yearAndWeek":
|
|
642
|
+
// return MUtil.error(`移动端不支持${this.props.schema.type}`, this.props.schema);
|
|
620
643
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
644
|
+
default:
|
|
645
|
+
return undefined;
|
|
624
646
|
}
|
|
625
647
|
|
|
626
|
-
return
|
|
648
|
+
return {
|
|
649
|
+
dataFormat: dataFormat,
|
|
650
|
+
readableFormat: readableFormat,
|
|
651
|
+
mode: mode,
|
|
652
|
+
showTime: showTime
|
|
653
|
+
};
|
|
627
654
|
},
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
* @param s 原始数据,参见moment
|
|
632
|
-
* @param srcFormat 原始数据的格式,默认x(时间戳)
|
|
633
|
-
* @param dstFormat 转换成的数据格式,默认YYYY年MM月DD日
|
|
634
|
-
* @param fallback 如果原始数据是nil,返回fallback
|
|
635
|
-
*/
|
|
636
|
-
momentFormat: function momentFormat(s, srcFormat, dstFormat, fallback) {
|
|
637
|
-
if (srcFormat === void 0) {
|
|
638
|
-
srcFormat = "x";
|
|
655
|
+
toReadable: function toReadable(assembly, schema, v) {
|
|
656
|
+
if (_.isNil(v)) {
|
|
657
|
+
return assembly.theme.READABLE_BLANK;
|
|
639
658
|
}
|
|
640
659
|
|
|
641
|
-
|
|
642
|
-
dstFormat = "YYYY年MM月DD日";
|
|
643
|
-
}
|
|
660
|
+
var c = MDateTimeType.antConf(schema);
|
|
644
661
|
|
|
645
|
-
if (
|
|
646
|
-
|
|
662
|
+
if (!c) {
|
|
663
|
+
return assembly.theme.READABLE_INVALID;
|
|
647
664
|
}
|
|
648
665
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
666
|
+
var asMoment = moment(v, c.dataFormat);
|
|
667
|
+
return asMoment.format(c.readableFormat);
|
|
668
|
+
}
|
|
669
|
+
});
|
|
652
670
|
|
|
653
|
-
|
|
654
|
-
},
|
|
671
|
+
/** 根据 precision 获取可读格式 */
|
|
655
672
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
* @param template 如果有子结构,创建子结构的模板
|
|
661
|
-
*/
|
|
662
|
-
jsonSchema2MFieldSchema: function jsonSchema2MFieldSchema(e, base, template) {
|
|
663
|
-
if (base === void 0) {
|
|
664
|
-
base = {
|
|
665
|
-
name: "",
|
|
666
|
-
type: "string"
|
|
667
|
-
};
|
|
668
|
-
}
|
|
673
|
+
function getReadableFormat(precision, showTime) {
|
|
674
|
+
switch (precision) {
|
|
675
|
+
case "year":
|
|
676
|
+
return "YYYY";
|
|
669
677
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
678
|
+
case "month":
|
|
679
|
+
return "YYYY.MM";
|
|
673
680
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
if (e.enum) {
|
|
677
|
-
var _base$enumFields;
|
|
681
|
+
case "minute":
|
|
682
|
+
return "YYYY.MM.DD HH:mm";
|
|
678
683
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
};
|
|
684
|
-
});
|
|
685
|
-
} else {
|
|
686
|
-
base.type = "string";
|
|
687
|
-
base.max = e.maxLength;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
break;
|
|
691
|
-
|
|
692
|
-
case "number":
|
|
693
|
-
case "integer":
|
|
694
|
-
base.type = "int";
|
|
695
|
-
break;
|
|
696
|
-
|
|
697
|
-
case "object":
|
|
698
|
-
base.type = "object";
|
|
699
|
-
base.objectFields = [];
|
|
700
|
-
base.uispec = {
|
|
701
|
-
type: "flowForm",
|
|
702
|
-
layout: MUtil.phoneLike() ? "vertical" : "horizontal",
|
|
703
|
-
comma: ":"
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
for (var key in e.properties) {
|
|
707
|
-
var jsmField = e.properties[key];
|
|
708
|
-
|
|
709
|
-
var m3Field = _.assign({}, template, {
|
|
710
|
-
name: key,
|
|
711
|
-
label: key,
|
|
712
|
-
type: "object"
|
|
713
|
-
});
|
|
684
|
+
default:
|
|
685
|
+
return showTime ? "YYYY.MM.DD HH:mm:ss" : "YYYY.MM.DD";
|
|
686
|
+
}
|
|
687
|
+
}
|
|
714
688
|
|
|
715
|
-
|
|
716
|
-
|
|
689
|
+
function timeExpr(assembly, v, tillNow, readableFormat) {
|
|
690
|
+
if (tillNow) {
|
|
691
|
+
return "至今";
|
|
692
|
+
}
|
|
717
693
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
} else {
|
|
722
|
-
m3Field.type = "不支持的json schema:object.properties的value是boolean";
|
|
723
|
-
base.objectFields.push();
|
|
724
|
-
}
|
|
725
|
-
}
|
|
694
|
+
if (!v) {
|
|
695
|
+
return assembly.theme.READABLE_UNKNOWN;
|
|
696
|
+
}
|
|
726
697
|
|
|
727
|
-
|
|
698
|
+
return moment(v, "x").format(readableFormat);
|
|
699
|
+
}
|
|
728
700
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
type: "array"
|
|
734
|
-
};
|
|
701
|
+
function timeRangeExpr(assembly, from, to, tillNow, readableFormat) {
|
|
702
|
+
if (readableFormat === void 0) {
|
|
703
|
+
readableFormat = "YYYY.MM.DD";
|
|
704
|
+
}
|
|
735
705
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
} else {
|
|
743
|
-
base.arrayMember.type = "不支持的json schema:array.items是undefined";
|
|
744
|
-
}
|
|
706
|
+
return timeExpr(assembly, from, false, readableFormat) + " - " + timeExpr(assembly, to, tillNow, readableFormat);
|
|
707
|
+
}
|
|
708
|
+
var MDateRangeType = _.assign({}, EmtpyType, {
|
|
709
|
+
validators: [validateRequired$1],
|
|
710
|
+
toReadable: function toReadable(assembly, s, vs) {
|
|
711
|
+
var _s$dateRange;
|
|
745
712
|
|
|
746
|
-
|
|
713
|
+
if (_.isNil(vs)) {
|
|
714
|
+
return assembly.theme.READABLE_BLANK;
|
|
715
|
+
}
|
|
747
716
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
case "boolean":
|
|
751
|
-
default:
|
|
752
|
-
base.type = "不支持的json schema:array.items是" + e.type;
|
|
753
|
-
break;
|
|
717
|
+
if (!_.isArray(vs)) {
|
|
718
|
+
return assembly.theme.READABLE_INVALID;
|
|
754
719
|
}
|
|
755
720
|
|
|
756
|
-
|
|
721
|
+
var fmt = getReadableFormat(s.dateRangePrecision, (_s$dateRange = s.dateRange) == null ? void 0 : _s$dateRange.showTime);
|
|
722
|
+
return timeRangeExpr(assembly, vs[0], vs[1], vs[2], fmt);
|
|
757
723
|
},
|
|
758
724
|
|
|
759
725
|
/**
|
|
760
|
-
*
|
|
761
|
-
* @param object 要修改的对象,
|
|
762
|
-
* @param renameTo
|
|
763
|
-
* @param removeNotExistKey 是否在结果里面去除renameTo里不存在的key
|
|
764
|
-
* @returns 返回一个改过key名字的新对象
|
|
726
|
+
* 同toReadable,但数据无效时返回nil
|
|
765
727
|
*/
|
|
766
|
-
|
|
767
|
-
if (
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
var result = {};
|
|
728
|
+
toReadableN: function toReadableN(assembly, s, vs) {
|
|
729
|
+
if (!_.isNil(vs) && _.isArray(vs)) {
|
|
730
|
+
var _s$dateRange2;
|
|
772
731
|
|
|
773
|
-
|
|
774
|
-
|
|
732
|
+
var fmt = getReadableFormat(s.dateRangePrecision, (_s$dateRange2 = s.dateRange) == null ? void 0 : _s$dateRange2.showTime);
|
|
733
|
+
return timeRangeExpr(assembly, vs[0], vs[1], vs[2], fmt);
|
|
734
|
+
}
|
|
775
735
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
} else {
|
|
780
|
-
newKey = oldKey;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
736
|
+
return undefined;
|
|
737
|
+
}
|
|
738
|
+
});
|
|
783
739
|
|
|
784
|
-
|
|
785
|
-
}
|
|
740
|
+
function _createForOfIteratorHelperLoose$d(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$d(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
786
741
|
|
|
787
|
-
|
|
788
|
-
},
|
|
742
|
+
function _unsupportedIterableToArray$d(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$d(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$d(o, minLen); }
|
|
789
743
|
|
|
790
|
-
|
|
791
|
-
|
|
744
|
+
function _arrayLikeToArray$d(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
745
|
+
var next = Date.now() - 1617265950471; // /** 用来测量字符串长度 */
|
|
746
|
+
// let _messurer: HTMLCanvasElement|undefined;
|
|
792
747
|
|
|
748
|
+
var MUtil = {
|
|
793
749
|
/**
|
|
794
|
-
*
|
|
750
|
+
* 每次调用,返回不一样的数字
|
|
751
|
+
* @returns
|
|
795
752
|
*/
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
arr[_key2] = arguments[_key2];
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
return _.compact(arr).join(".");
|
|
753
|
+
unique: function unique() {
|
|
754
|
+
return next++;
|
|
802
755
|
},
|
|
803
756
|
|
|
804
757
|
/**
|
|
805
|
-
*
|
|
806
|
-
* @
|
|
758
|
+
* 枚举字段可以写成空格分隔的字符串,也能写成MEnumField[],这个函数将两种形式转换成统一的MEnumField[]
|
|
759
|
+
* @deprecated 改成用MUtils.option
|
|
807
760
|
*/
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
761
|
+
standardFields: function standardFields(fs) {
|
|
762
|
+
if (typeof fs === "string") {
|
|
763
|
+
return fs.split(" ").map(function (aEnum) {
|
|
764
|
+
var _kv$;
|
|
765
|
+
|
|
766
|
+
var kv = aEnum.split("=");
|
|
767
|
+
return {
|
|
768
|
+
label: kv[0],
|
|
769
|
+
value: (_kv$ = kv[1]) != null ? _kv$ : kv[0]
|
|
770
|
+
};
|
|
771
|
+
});
|
|
772
|
+
} else if (fs) {
|
|
773
|
+
return fs;
|
|
774
|
+
} else {
|
|
775
|
+
return [];
|
|
776
|
+
}
|
|
812
777
|
},
|
|
813
778
|
|
|
814
779
|
/**
|
|
815
|
-
*
|
|
816
|
-
* @param
|
|
817
|
-
* @returns 空数组表示校验通过,否则返回校验错误信息
|
|
780
|
+
* 获取enumFields或者setFields,返回标准的MEnumField[]
|
|
781
|
+
* @param f 如果f是nil,返回[]
|
|
818
782
|
*/
|
|
819
|
-
|
|
820
|
-
var
|
|
821
|
-
|
|
822
|
-
var error = function error(msg) {
|
|
823
|
-
return result.push({
|
|
824
|
-
message: msg,
|
|
825
|
-
path: MUtil.jsonPath(parentPath, s.name)
|
|
826
|
-
});
|
|
827
|
-
};
|
|
783
|
+
option: function option(f) {
|
|
784
|
+
var _result;
|
|
828
785
|
|
|
829
|
-
var
|
|
830
|
-
if (_.uniq(a).length !== a.length) {
|
|
831
|
-
error(msgIfFail);
|
|
832
|
-
}
|
|
833
|
-
};
|
|
786
|
+
var result;
|
|
834
787
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
checkDup(fs.map(function (f) {
|
|
840
|
-
return f.label;
|
|
841
|
-
}).filter(function (l) {
|
|
842
|
-
return l;
|
|
843
|
-
}), s.name + "文案有重复");
|
|
844
|
-
};
|
|
788
|
+
if (_.isArray(f.option)) {
|
|
789
|
+
result = f.option;
|
|
790
|
+
} else {
|
|
791
|
+
var ori;
|
|
845
792
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
793
|
+
if (f.type == "set") {
|
|
794
|
+
ori = f.setFields;
|
|
795
|
+
} else if (f.type == "enum") {
|
|
796
|
+
ori = f.enumFields;
|
|
797
|
+
} else {
|
|
798
|
+
var _ref, _f$option;
|
|
850
799
|
|
|
851
|
-
|
|
852
|
-
error("暂不支持的选项数据类型:" + JSON.stringify(ns) + ": " + typeof ns);
|
|
800
|
+
ori = (_ref = (_f$option = f.option) != null ? _f$option : f.setFields) != null ? _ref : f.enumFields; // 只是为了保险
|
|
853
801
|
}
|
|
854
|
-
};
|
|
855
802
|
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
checkVL(MUtil.standardFields(s.enumFields));
|
|
860
|
-
} else if (s.type === "set") {
|
|
861
|
-
checkVL(MUtil.standardFields(s.setFields));
|
|
862
|
-
} else if (s.type === "matrix") {
|
|
863
|
-
stringOnlyEnum(s.matrix.x);
|
|
864
|
-
stringOnlyEnum(s.matrix.y);
|
|
865
|
-
} else if (s.type === "object") {
|
|
866
|
-
if (!s.objectFields) {
|
|
867
|
-
error("object类型未定义成员");
|
|
868
|
-
} else {
|
|
869
|
-
var _s$uispec;
|
|
803
|
+
if (typeof ori === "string") {
|
|
804
|
+
f.option = result = ori.split(" ").map(function (aEnum) {
|
|
805
|
+
var _kv$2;
|
|
870
806
|
|
|
871
|
-
|
|
872
|
-
return
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
807
|
+
var kv = aEnum.split("=");
|
|
808
|
+
return {
|
|
809
|
+
label: kv[0],
|
|
810
|
+
value: (_kv$2 = kv[1]) != null ? _kv$2 : kv[0]
|
|
811
|
+
};
|
|
812
|
+
});
|
|
813
|
+
} else {
|
|
814
|
+
f.option = result = ori; // TODO children 可能有递归的,还是得靠预处理解决
|
|
815
|
+
}
|
|
816
|
+
}
|
|
876
817
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
result = _.concat(result, MUtil.validateSchema(f, MUtil.jsonPath(parentPath, s.name)));
|
|
880
|
-
}
|
|
818
|
+
return (_result = result) != null ? _result : [];
|
|
819
|
+
},
|
|
881
820
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
var fieldNotExist = _.difference(fieldsInSegments, fields);
|
|
907
|
-
|
|
908
|
-
if (fieldNotExist.length > 0) {
|
|
909
|
-
error("分段字段名无效:" + notInSegment.join(","));
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
}
|
|
821
|
+
/** 如果出错了,返回这么个元素,可能用在BaseEditor子类或者其他的东西上 */
|
|
822
|
+
error: function error(msg, schema) {
|
|
823
|
+
return jsxs("div", {
|
|
824
|
+
style: {
|
|
825
|
+
color: "white",
|
|
826
|
+
border: "1px solid darkgrey",
|
|
827
|
+
background: "red",
|
|
828
|
+
textAlign: "center",
|
|
829
|
+
borderRadius: "5px"
|
|
830
|
+
},
|
|
831
|
+
children: [msg, schema ? jsx("pre", {
|
|
832
|
+
style: {
|
|
833
|
+
whiteSpace: "pre-wrap",
|
|
834
|
+
textAlign: "left"
|
|
835
|
+
},
|
|
836
|
+
children: JSON.stringify(schema)
|
|
837
|
+
}) : undefined]
|
|
838
|
+
}, Date.now());
|
|
839
|
+
},
|
|
840
|
+
sign: function sign(v) {
|
|
841
|
+
if (_.isNil(v)) {
|
|
842
|
+
return null;
|
|
914
843
|
}
|
|
915
844
|
|
|
916
|
-
return
|
|
845
|
+
return Math.sign(v);
|
|
917
846
|
},
|
|
918
847
|
|
|
919
848
|
/**
|
|
920
|
-
*
|
|
921
|
-
* 示例: var d = applyToConstructor(Date, [2008, 10, 8, 00, 16, 34, 254]);
|
|
922
|
-
* @param constructor
|
|
923
|
-
* @param argArray
|
|
849
|
+
* 当前设备是不是个手机(或者类似手机的设备,比如ipad上运行iphone app中的webview)
|
|
924
850
|
*/
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
return new factoryFunction();
|
|
851
|
+
phoneLike: function phoneLike() {
|
|
852
|
+
// eslint-disable-next-line no-restricted-globals
|
|
853
|
+
return screen.height / screen.width > 1.5;
|
|
929
854
|
},
|
|
855
|
+
// /**
|
|
856
|
+
// * 计算文字的宽度
|
|
857
|
+
// * @param text 文字
|
|
858
|
+
// * @param font 字体
|
|
859
|
+
// * @returns 宽度,单位是px
|
|
860
|
+
// */
|
|
861
|
+
// getTextWidth(text:string, font?:string) {
|
|
862
|
+
// var canvas = _messurer ?? (_messurer = document.createElement("canvas"));
|
|
863
|
+
// var context = canvas.getContext("2d");
|
|
864
|
+
// if(!context) {
|
|
865
|
+
// console.error('神奇的事情发生了:canvas.getContext("2d")居然能返回null');
|
|
866
|
+
// return text.length * 10; // 总比出不来好
|
|
867
|
+
// }
|
|
868
|
+
// if(font){
|
|
869
|
+
// context.font = font;
|
|
870
|
+
// }
|
|
871
|
+
// var metrics = context.measureText(text);
|
|
872
|
+
// return metrics.width;
|
|
873
|
+
// }
|
|
930
874
|
|
|
931
875
|
/**
|
|
932
|
-
*
|
|
933
|
-
* @param
|
|
934
|
-
* @param paramName 参数名字
|
|
935
|
-
* @param paramValue 参数值
|
|
936
|
-
* @param fallback 如果exprOrFunction无效,返回fallback
|
|
937
|
-
* @param _this this指针
|
|
876
|
+
* 计算文字的宽度
|
|
877
|
+
* @param text
|
|
938
878
|
*/
|
|
939
|
-
|
|
940
|
-
if (
|
|
941
|
-
|
|
879
|
+
antdTextWidth: function antdTextWidth(text) {
|
|
880
|
+
if (!text) {
|
|
881
|
+
return 0;
|
|
942
882
|
}
|
|
943
883
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
884
|
+
return text.length * 16;
|
|
885
|
+
},
|
|
947
886
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
887
|
+
/**
|
|
888
|
+
* 从数组中删掉一个元素
|
|
889
|
+
* @param a 这个数组会被改变的
|
|
890
|
+
* @param element 要删的元素
|
|
891
|
+
* @returns 修改后的数组(如果它不是nil)
|
|
892
|
+
*/
|
|
893
|
+
arrayRemove: function arrayRemove(a, element) {
|
|
894
|
+
if (a) {
|
|
895
|
+
var idx = a.indexOf(element);
|
|
896
|
+
|
|
897
|
+
if (idx >= 0) {
|
|
898
|
+
a.splice(idx, 1);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return a;
|
|
954
902
|
} else {
|
|
955
|
-
return
|
|
903
|
+
return a;
|
|
956
904
|
}
|
|
957
905
|
},
|
|
906
|
+
fieldOfLayout: function fieldOfLayout(fields, spec) {
|
|
907
|
+
var objectFieldMap = _.chain(fields).keyBy("name").value();
|
|
958
908
|
|
|
959
|
-
|
|
960
|
-
* 读取url参数,转换成map
|
|
961
|
-
* @param hashPrefix nil表示不读取hash里的参数,字符串表示读取hash里的参数,并加上这个前缀返回。默认是返回,但前缀是空字符串
|
|
962
|
-
*/
|
|
963
|
-
getQuery: function getQuery(hashPrefix) {
|
|
909
|
+
var r = {};
|
|
964
910
|
|
|
965
|
-
var
|
|
966
|
-
|
|
967
|
-
arrs.forEach(function (item) {
|
|
968
|
-
var kv = item.split(/=/);
|
|
911
|
+
for (var _iterator = _createForOfIteratorHelperLoose$d((_spec$segments = spec.segments) != null ? _spec$segments : []), _step; !(_step = _iterator()).done;) {
|
|
912
|
+
var _spec$segments;
|
|
969
913
|
|
|
970
|
-
|
|
971
|
-
|
|
914
|
+
var s = _step.value;
|
|
915
|
+
|
|
916
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose$d((_s$fields = s.fields) != null ? _s$fields : []), _step2; !(_step2 = _iterator2()).done;) {
|
|
917
|
+
var _s$fields;
|
|
918
|
+
|
|
919
|
+
var f = _step2.value;
|
|
920
|
+
|
|
921
|
+
if (_.isString(f)) {
|
|
922
|
+
var def = objectFieldMap[f];
|
|
923
|
+
|
|
924
|
+
if (def) {
|
|
925
|
+
r[f] = def;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
972
928
|
}
|
|
973
|
-
}
|
|
974
|
-
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
return _.values(r);
|
|
975
932
|
},
|
|
976
933
|
|
|
977
934
|
/**
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
*
|
|
935
|
+
* 跟lodash的get一样,除了:
|
|
936
|
+
* 1. path是nil时返回undefined
|
|
937
|
+
* 2. path是""时返回原始对象
|
|
938
|
+
* @param a
|
|
939
|
+
* @param path
|
|
981
940
|
*/
|
|
982
|
-
|
|
983
|
-
|
|
941
|
+
get: function get(a, path) {
|
|
942
|
+
if (_.isNil(a) || _.isNil(path)) {
|
|
943
|
+
return undefined;
|
|
944
|
+
} else if (path === "") {
|
|
945
|
+
return a;
|
|
946
|
+
}
|
|
984
947
|
|
|
985
|
-
|
|
986
|
-
s.id = id;
|
|
987
|
-
s.type = "text/css";
|
|
988
|
-
s.innerHTML = css;
|
|
989
|
-
document.getElementsByTagName("head")[0].appendChild(s);
|
|
948
|
+
return _.get(a, path);
|
|
990
949
|
},
|
|
991
950
|
|
|
992
951
|
/**
|
|
993
|
-
*
|
|
994
|
-
*
|
|
995
|
-
*
|
|
952
|
+
* a : database
|
|
953
|
+
* v : newValue
|
|
954
|
+
* 跟lodash的set一样,除了path是""时等效于_.assign(a, v)
|
|
996
955
|
*/
|
|
997
|
-
|
|
998
|
-
if (
|
|
999
|
-
|
|
956
|
+
set: function set(a, path, v) {
|
|
957
|
+
if (path === "") {
|
|
958
|
+
// 如果 database 是数组,需要特殊处理
|
|
959
|
+
if (_.isArray(a)) a.length = v.length;
|
|
960
|
+
|
|
961
|
+
_.assign(a, v);
|
|
962
|
+
} else {
|
|
963
|
+
_.set(a, path, v);
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
debug: function debug(d) {
|
|
967
|
+
for (var _len = arguments.length, optionalParams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
968
|
+
optionalParams[_key - 1] = arguments[_key];
|
|
1000
969
|
}
|
|
1001
970
|
|
|
1002
|
-
|
|
971
|
+
console.log(d, optionalParams);
|
|
1003
972
|
},
|
|
1004
973
|
|
|
1005
974
|
/**
|
|
1006
|
-
*
|
|
1007
|
-
* @param
|
|
1008
|
-
* @param
|
|
1009
|
-
* @param
|
|
975
|
+
* 填入默认值
|
|
976
|
+
* @param schema 你懂得
|
|
977
|
+
* @param database 数据库,会被修改的
|
|
978
|
+
* @param path 路径
|
|
1010
979
|
*/
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
var CompactArray = {
|
|
1020
|
-
indexOf: function indexOf(ca, d) {
|
|
1021
|
-
if (_.isNil(d) || _.isNil(ca)) {
|
|
1022
|
-
return -1;
|
|
1023
|
-
}
|
|
980
|
+
applyDefaultValue: function applyDefaultValue(schema, database, path) {
|
|
981
|
+
// FIXME 多测试下,type是object或其他简单类型的情况
|
|
982
|
+
if (schema.type === "object") {
|
|
983
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose$d((_schema$objectFields = schema.objectFields) != null ? _schema$objectFields : []), _step3; !(_step3 = _iterator3()).done;) {
|
|
984
|
+
var _schema$objectFields;
|
|
1024
985
|
|
|
1025
|
-
|
|
1026
|
-
|
|
986
|
+
var f = _step3.value;
|
|
987
|
+
this.applyDefaultValue(f, database, (path ? path + "." : "") + f.name);
|
|
988
|
+
}
|
|
1027
989
|
} else {
|
|
1028
|
-
|
|
990
|
+
if (!_.isNil(schema.defaultValue) && _.isNil(_.get(database, path))) {
|
|
991
|
+
_.set(database, path, schema.defaultValue);
|
|
992
|
+
}
|
|
1029
993
|
}
|
|
1030
|
-
}
|
|
1031
|
-
|
|
994
|
+
},
|
|
995
|
+
filterHide: function filterHide(schema, database) {
|
|
996
|
+
var _schema$objectFields2;
|
|
1032
997
|
|
|
1033
|
-
|
|
998
|
+
// TODO 要改成递归的
|
|
999
|
+
var hm = MUtil.hideMap(database, (_schema$objectFields2 = schema.objectFields) != null ? _schema$objectFields2 : [], schema.uispec);
|
|
1000
|
+
var finalData = _.isArray(database) ? [] : {};
|
|
1034
1001
|
|
|
1035
|
-
|
|
1002
|
+
for (var k in database) {
|
|
1003
|
+
if (!hm[k]) {
|
|
1004
|
+
finalData[k] = database[k];
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1036
1007
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
READABLE_UNKNOWN: "?",
|
|
1040
|
-
READABLE_BLANK: "-",
|
|
1041
|
-
READABLE_INVALID: "❓",
|
|
1042
|
-
READABLE_ERROR: "❗",
|
|
1043
|
-
themeName: "antMiddle"
|
|
1044
|
-
};
|
|
1045
|
-
/**
|
|
1046
|
-
* 注册viewer,type,morph(viewer和type之间的关联)
|
|
1047
|
-
*/
|
|
1008
|
+
return finalData;
|
|
1009
|
+
},
|
|
1048
1010
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1011
|
+
/**
|
|
1012
|
+
* 计算哪些field、segment需要隐藏
|
|
1013
|
+
* 支持ShowIfFunc里的函数
|
|
1014
|
+
* TODO 如果segment隐藏,里面的字段全都要隐藏
|
|
1015
|
+
* @returns 示例:
|
|
1016
|
+
* let {name,role,gender,alias,birthday,company,position,tel,email,citizenship,politicsCode,companyArch,address,work,edu,assistant,student,mib} = data;
|
|
1017
|
+
* return {politicsCode: !(citizenship=='中国大陆'),"segment:学员信息": !(_.intersection(role, ['校友']).length > 0))}
|
|
1018
|
+
* @param objectFields
|
|
1019
|
+
* @param uispec 用来计算segment是不是要展示,不填就不计算
|
|
1020
|
+
*/
|
|
1021
|
+
hideMap: function hideMap(database, objectFields, uispec) {
|
|
1022
|
+
// 构造字段依赖计算的脚本,类似这样:
|
|
1023
|
+
// let {name,role,gender,alias,tel,email,citizenship,student} = {"name":"aaa","alias":"bbb","tel":"1"};citizenship=='中国大陆'
|
|
1024
|
+
var l1fields = _.uniq( // 名字要唯一
|
|
1025
|
+
objectFields.filter(function (e) {
|
|
1026
|
+
return !!e.name;
|
|
1027
|
+
}) // 过滤掉没有名字的字段
|
|
1028
|
+
.map(function (e) {
|
|
1029
|
+
return _.first(e.name.split("."));
|
|
1030
|
+
}) // 对于objectFields里类似student.no/student.state的字段,这里只要拼一个student就可以了
|
|
1031
|
+
);
|
|
1051
1032
|
|
|
1052
|
-
|
|
1053
|
-
_proto.getViewerOf = function getViewerOf(f, morph) {
|
|
1054
|
-
if (f.editor && morph === "editor") {
|
|
1055
|
-
if (_.isString(f.editor)) {
|
|
1056
|
-
return _.get(this.viewers, f.editor);
|
|
1057
|
-
} else {
|
|
1058
|
-
return f.editor;
|
|
1059
|
-
}
|
|
1060
|
-
} else if (f.readable && morph === "readable") {
|
|
1061
|
-
if (_.isString(f.readable)) {
|
|
1062
|
-
return _.get(this.viewers, f.readable);
|
|
1063
|
-
} else {
|
|
1064
|
-
return f.readable;
|
|
1065
|
-
}
|
|
1066
|
-
} else {
|
|
1067
|
-
var viewer = _.get(this.morph, morph + "." + f.type);
|
|
1033
|
+
var showIfScript = "let {" + l1fields.join(",") + "} = data || {};\nlet hide = {";
|
|
1068
1034
|
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
} else {
|
|
1072
|
-
return viewer;
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1035
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose$d(objectFields), _step4; !(_step4 = _iterator4()).done;) {
|
|
1036
|
+
var f = _step4.value;
|
|
1076
1037
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1038
|
+
if (f.showIf) {
|
|
1039
|
+
showIfScript += "'" + f.name + "': !(" + f.showIf + "),";
|
|
1040
|
+
}
|
|
1080
1041
|
}
|
|
1081
1042
|
|
|
1082
|
-
var
|
|
1043
|
+
for (var _iterator5 = _createForOfIteratorHelperLoose$d((_uispec$segments = uispec == null ? void 0 : uispec.segments) != null ? _uispec$segments : []), _step5; !(_step5 = _iterator5()).done;) {
|
|
1044
|
+
var _uispec$segments;
|
|
1083
1045
|
|
|
1084
|
-
|
|
1085
|
-
var validator = _step.value;
|
|
1086
|
-
result = validator(this, s, v, path);
|
|
1046
|
+
var s = _step5.value;
|
|
1087
1047
|
|
|
1088
|
-
if (
|
|
1089
|
-
|
|
1090
|
-
} else if (typeof result === "object") {
|
|
1091
|
-
MUtil.debug("校验", path, result.message);
|
|
1092
|
-
return result;
|
|
1048
|
+
if (s.showIf) {
|
|
1049
|
+
showIfScript += "\"segment:" + s.label + "\": !(" + s.showIf + "),";
|
|
1093
1050
|
}
|
|
1094
1051
|
}
|
|
1095
1052
|
|
|
1096
|
-
|
|
1097
|
-
};
|
|
1053
|
+
showIfScript += "}\n"; // 如果一个segment里的所有字段都隐藏,segment就要隐藏
|
|
1098
1054
|
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
console.error("addViewer: \u5DF2\u7ECF\u5B58\u5728\u540D\u4E3A " + name + " \u7684 Viewer\uFF0C\u65E0\u6CD5\u518D\u6B21\u6DFB\u52A0\uFF01");
|
|
1102
|
-
return;
|
|
1103
|
-
} else {
|
|
1104
|
-
this.viewers[name] = v;
|
|
1105
|
-
}
|
|
1106
|
-
};
|
|
1055
|
+
for (var _iterator6 = _createForOfIteratorHelperLoose$d((_uispec$segments2 = uispec == null ? void 0 : uispec.segments) != null ? _uispec$segments2 : []), _step6; !(_step6 = _iterator6()).done;) {
|
|
1056
|
+
var _uispec$segments2;
|
|
1107
1057
|
|
|
1108
|
-
|
|
1109
|
-
if (this.editors[name]) {
|
|
1110
|
-
console.error("addEditor: \u5DF2\u7ECF\u5B58\u5728\u540D\u4E3A " + name + " \u7684 Editor\uFF0C\u65E0\u6CD5\u518D\u6B21\u6DFB\u52A0\uFF01");
|
|
1111
|
-
return;
|
|
1112
|
-
} else {
|
|
1113
|
-
this.editors[name] = v;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
/**
|
|
1117
|
-
* 增加一种数据类型
|
|
1118
|
-
* 例:
|
|
1119
|
-
* const hpOrg = {name: "hpOrg", type: {validators: ..., toReadable: ...}, editor: HPOrgEditor, readable: "DivViewer"}
|
|
1120
|
-
* addType(hpOrg)
|
|
1121
|
-
* @param typeParam 类型的描述对象
|
|
1122
|
-
*/
|
|
1123
|
-
;
|
|
1058
|
+
var _s = _step6.value;
|
|
1124
1059
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
editor = typeParam.editor,
|
|
1129
|
-
_typeParam$readable = typeParam.readable,
|
|
1130
|
-
readable = _typeParam$readable === void 0 ? "DivViewer" : _typeParam$readable;
|
|
1131
|
-
this.types[name] = type;
|
|
1060
|
+
var cond = _s.fields.map(function (f) {
|
|
1061
|
+
return "(hide['" + f + "'])";
|
|
1062
|
+
}).join(" && ");
|
|
1132
1063
|
|
|
1133
|
-
|
|
1064
|
+
showIfScript += "if(" + cond + ") { hide[\"segment:" + _s.label + "\"] = true }\n";
|
|
1065
|
+
}
|
|
1134
1066
|
|
|
1135
|
-
|
|
1136
|
-
};
|
|
1067
|
+
showIfScript += "return hide;\n"; // eslint-disable-next-line no-new-func
|
|
1137
1068
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1069
|
+
try {
|
|
1070
|
+
var fn = Object.keys(SchemaFunc);
|
|
1071
|
+
var fv = Object.values(SchemaFunc);
|
|
1140
1072
|
|
|
1141
|
-
|
|
1142
|
-
this.viewers = {};
|
|
1143
|
-
this.editors = {};
|
|
1144
|
-
this.morph = {};
|
|
1145
|
-
this.theme = defaultTheme;
|
|
1073
|
+
var hideMap = _construct(Function, ["_", "data"].concat(fn, [showIfScript])).apply(void 0, [_, database].concat(fv));
|
|
1146
1074
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1075
|
+
return hideMap;
|
|
1076
|
+
} catch (e) {
|
|
1077
|
+
console.error("Calc hideMap failed: " + e.message, "function(_,data){" + showIfScript + "}", database);
|
|
1078
|
+
return {};
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1149
1081
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1082
|
+
/**
|
|
1083
|
+
* 计算 showIf 的值
|
|
1084
|
+
* @returns Boolean
|
|
1085
|
+
* @param database
|
|
1086
|
+
* @param objectFields
|
|
1087
|
+
*/
|
|
1088
|
+
isShow: function isShow(database, objectFields, showIfExpr) {
|
|
1089
|
+
if (!showIfExpr) return true;
|
|
1152
1090
|
|
|
1153
|
-
|
|
1091
|
+
var l1fields = _.uniq(objectFields.filter(function (e) {
|
|
1092
|
+
return !!e.name;
|
|
1093
|
+
}).map(function (e) {
|
|
1094
|
+
return _.first(e.name.split("."));
|
|
1095
|
+
}));
|
|
1154
1096
|
|
|
1155
|
-
|
|
1156
|
-
// eslint-disable-next-line no-new-func
|
|
1157
|
-
r = new Function("_", "value", "theme", "const {READABLE_UNKNOWN, READABLE_BLANK, READABLE_INVALID, READABLE_ERROR} = theme; return " + s.toReadable)(_, v, _this.theme);
|
|
1158
|
-
} else if (_.isFunction(s.toReadable)) {
|
|
1159
|
-
r = s.toReadable(v, parent, _this);
|
|
1160
|
-
}
|
|
1097
|
+
var showIfScript = "let {" + l1fields.join(",") + "} = data || {};\n return " + showIfExpr;
|
|
1161
1098
|
|
|
1162
|
-
|
|
1099
|
+
try {
|
|
1100
|
+
var fn = Object.keys(SchemaFunc);
|
|
1101
|
+
var fv = Object.values(SchemaFunc);
|
|
1163
1102
|
|
|
1164
|
-
|
|
1165
|
-
r += s.postfix;
|
|
1166
|
-
}
|
|
1103
|
+
var res = _construct(Function, ["_", "data"].concat(fn, [showIfScript])).apply(void 0, [_, database].concat(fv));
|
|
1167
1104
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1105
|
+
return res;
|
|
1106
|
+
} catch (e) {
|
|
1107
|
+
console.error("Calc isShow failed: " + e.message, "function(_,data){" + showIfScript + "}", database);
|
|
1108
|
+
return true;
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
scoreOf: function scoreOf(f, database) {
|
|
1112
|
+
var v = _.get(database, f.name);
|
|
1173
1113
|
|
|
1114
|
+
if (f.type == "enum") {
|
|
1115
|
+
var _MUtil$standardFields, _MUtil$standardFields2;
|
|
1174
1116
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1117
|
+
return _.toNumber((_MUtil$standardFields = MUtil.standardFields(f.enumFields)) == null ? void 0 : (_MUtil$standardFields2 = _MUtil$standardFields.find(function (e) {
|
|
1118
|
+
return e.value == v;
|
|
1119
|
+
})) == null ? void 0 : _MUtil$standardFields2.score);
|
|
1120
|
+
} else if (f.type == "set") {
|
|
1121
|
+
var score = 0;
|
|
1122
|
+
var opts = MUtil.standardFields(f.setFields);
|
|
1180
1123
|
|
|
1181
|
-
|
|
1124
|
+
for (var _iterator7 = _createForOfIteratorHelperLoose$d(opts), _step7; !(_step7 = _iterator7()).done;) {
|
|
1125
|
+
var s = _step7.value;
|
|
1182
1126
|
|
|
1183
|
-
if (
|
|
1184
|
-
|
|
1127
|
+
if (_.find(opts, {
|
|
1128
|
+
value: v
|
|
1129
|
+
})) {
|
|
1130
|
+
score += _.toNumber(s.score);
|
|
1185
1131
|
}
|
|
1186
1132
|
}
|
|
1133
|
+
|
|
1134
|
+
return score;
|
|
1135
|
+
} else {
|
|
1136
|
+
return 0;
|
|
1187
1137
|
}
|
|
1188
|
-
}
|
|
1138
|
+
},
|
|
1189
1139
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1140
|
+
/**
|
|
1141
|
+
* 查找fs依赖(通过showIf)的所有字段
|
|
1142
|
+
* @param fs
|
|
1143
|
+
* @param all
|
|
1144
|
+
* @returns fs依赖的所有字段,包含fs。这个数组中下标小的元素,依赖下标大的元素
|
|
1145
|
+
*/
|
|
1146
|
+
dependency: function dependency(fs, all) {
|
|
1147
|
+
// 先建个索引
|
|
1148
|
+
var allFieldsIdx = _.keyBy(all, "name"); // 构造未被依赖的集合
|
|
1193
1149
|
|
|
1194
|
-
var MContext = /*#__PURE__*/React.createContext(undefined);
|
|
1195
1150
|
|
|
1196
|
-
|
|
1151
|
+
var ndep = _.keyBy(all, "name"); // 全体
|
|
1197
1152
|
|
|
1198
|
-
function _objectSpread$x(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$x(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$x(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1199
|
-
/**
|
|
1200
|
-
* 一个字段的视图
|
|
1201
|
-
*/
|
|
1202
1153
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1154
|
+
ndep = _.omit(ndep, fs.map(function (f) {
|
|
1155
|
+
return f.name;
|
|
1156
|
+
})); // 去掉fs
|
|
1157
|
+
// 构造被依赖的集合
|
|
1205
1158
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1159
|
+
var dep = new Map();
|
|
1160
|
+
fs.forEach(function (f) {
|
|
1161
|
+
return dep[f.name] = f;
|
|
1162
|
+
}); // 循环从ndep里把被依赖的字段放到dep中,直到dep不再增加
|
|
1163
|
+
// 算法有点粗暴,将就用吧
|
|
1209
1164
|
|
|
1210
|
-
|
|
1165
|
+
for (var i = 0; i < all.length; i++) {
|
|
1166
|
+
// 轮数最多all.length,防止卡死
|
|
1167
|
+
var newDepNames = [];
|
|
1211
1168
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1169
|
+
for (var dn in dep) {
|
|
1170
|
+
var _dep$dn$showIf;
|
|
1214
1171
|
|
|
1215
|
-
|
|
1172
|
+
var _i = _.intersection((_dep$dn$showIf = dep[dn].showIf) == null ? void 0 : _dep$dn$showIf.split(/[^a-zA-Z0-9_$]/), Object.keys(ndep));
|
|
1216
1173
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
}
|
|
1174
|
+
newDepNames = newDepNames.concat(_i);
|
|
1175
|
+
}
|
|
1220
1176
|
|
|
1221
|
-
|
|
1222
|
-
afterChange: function afterChange() {},
|
|
1223
|
-
changeSchema: function changeSchema() {},
|
|
1224
|
-
changeDatabase: function changeDatabase() {},
|
|
1225
|
-
name: this.props.path
|
|
1226
|
-
}, this.props);
|
|
1177
|
+
var prevSize = Object.keys(dep).length;
|
|
1227
1178
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
return ctx.rootProps.wrapper(ele, _this.props.schema);
|
|
1233
|
-
} else {
|
|
1234
|
-
return ele;
|
|
1235
|
-
}
|
|
1179
|
+
for (var _iterator8 = _createForOfIteratorHelperLoose$d(newDepNames), _step8; !(_step8 = _iterator8()).done;) {
|
|
1180
|
+
var n = _step8.value;
|
|
1181
|
+
dep[n] = allFieldsIdx[n];
|
|
1182
|
+
delete ndep[n];
|
|
1236
1183
|
}
|
|
1237
|
-
});
|
|
1238
|
-
};
|
|
1239
1184
|
|
|
1240
|
-
|
|
1241
|
-
}(React.Component);
|
|
1185
|
+
var afterSize = Object.keys(dep).length;
|
|
1242
1186
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
* @param schema
|
|
1248
|
-
* @param value
|
|
1249
|
-
* @param path
|
|
1250
|
-
* @returns
|
|
1251
|
-
*/
|
|
1187
|
+
if (prevSize == afterSize) {
|
|
1188
|
+
break; // 如果找不到更多依赖,就可以结束了
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1252
1191
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
if (_.isNil(value) || value === "" || _.isNaN(value) || _.isArray(value) && value.length == 0) {
|
|
1256
|
-
return {
|
|
1257
|
-
message: "您还没有填完这一项",
|
|
1258
|
-
path: path
|
|
1259
|
-
};
|
|
1260
|
-
} // 凡是总有例外
|
|
1192
|
+
return Object.values(dep);
|
|
1193
|
+
},
|
|
1261
1194
|
|
|
1195
|
+
/**
|
|
1196
|
+
* 用moment格式化
|
|
1197
|
+
* @param s 原始数据,参见moment
|
|
1198
|
+
* @param srcFormat 原始数据的格式,默认x(时间戳)
|
|
1199
|
+
* @param dstFormat 转换成的数据格式,默认YYYY年MM月DD日
|
|
1200
|
+
* @param fallback 如果原始数据是nil,返回fallback
|
|
1201
|
+
*/
|
|
1202
|
+
momentFormat: function momentFormat(s, srcFormat, dstFormat, fallback) {
|
|
1203
|
+
if (srcFormat === void 0) {
|
|
1204
|
+
srcFormat = "x";
|
|
1205
|
+
}
|
|
1262
1206
|
|
|
1263
|
-
if (
|
|
1264
|
-
|
|
1265
|
-
return {
|
|
1266
|
-
message: "您还没有填完这一项",
|
|
1267
|
-
path: path
|
|
1268
|
-
}; // 开放set,只勾了开放选项,没有填内容,也要算空
|
|
1269
|
-
}
|
|
1207
|
+
if (dstFormat === void 0) {
|
|
1208
|
+
dstFormat = "YYYY年MM月DD日";
|
|
1270
1209
|
}
|
|
1271
|
-
|
|
1272
|
-
if (
|
|
1273
|
-
|
|
1210
|
+
|
|
1211
|
+
if (fallback === void 0) {
|
|
1212
|
+
fallback = "不详";
|
|
1274
1213
|
}
|
|
1275
|
-
}
|
|
1276
1214
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1215
|
+
if (_.isNil(s)) {
|
|
1216
|
+
return fallback;
|
|
1217
|
+
}
|
|
1280
1218
|
|
|
1281
|
-
|
|
1282
|
-
|
|
1219
|
+
return moment(s, srcFormat).format(dstFormat);
|
|
1220
|
+
},
|
|
1283
1221
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1222
|
+
/**
|
|
1223
|
+
* 将标准的json schema转换成m3的schema
|
|
1224
|
+
* @param e json schema
|
|
1225
|
+
* @param base 如果填了一个对象,转换出的属性会放在这个对象上
|
|
1226
|
+
* @param template 如果有子结构,创建子结构的模板
|
|
1227
|
+
*/
|
|
1228
|
+
jsonSchema2MFieldSchema: function jsonSchema2MFieldSchema(e, base, template) {
|
|
1229
|
+
if (base === void 0) {
|
|
1230
|
+
base = {
|
|
1231
|
+
name: "",
|
|
1232
|
+
type: "string"
|
|
1294
1233
|
};
|
|
1295
1234
|
}
|
|
1296
|
-
}
|
|
1297
1235
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
return {
|
|
1301
|
-
message: "\u8BF7\u9009\u62E9" + schema.min + "\u4E4B\u524D\u7684\u65F6\u95F4",
|
|
1302
|
-
path: path
|
|
1303
|
-
};
|
|
1236
|
+
if (template === void 0) {
|
|
1237
|
+
template = {};
|
|
1304
1238
|
}
|
|
1305
|
-
}
|
|
1306
1239
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
* @param schema
|
|
1312
|
-
* @param value 应该是个数组
|
|
1313
|
-
*/
|
|
1240
|
+
switch (e.type) {
|
|
1241
|
+
case "string":
|
|
1242
|
+
if (e.enum) {
|
|
1243
|
+
var _base$enumFields;
|
|
1314
1244
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1245
|
+
base.type = "enum";
|
|
1246
|
+
base.enumFields = (_base$enumFields = base.enumFields) != null ? _base$enumFields : e.enum.map(function (v) {
|
|
1247
|
+
return {
|
|
1248
|
+
value: (v != null ? v : "").toString()
|
|
1249
|
+
};
|
|
1250
|
+
});
|
|
1251
|
+
} else {
|
|
1252
|
+
base.type = "string";
|
|
1253
|
+
base.max = e.maxLength;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
break;
|
|
1257
|
+
|
|
1258
|
+
case "number":
|
|
1259
|
+
case "integer":
|
|
1260
|
+
base.type = "int";
|
|
1261
|
+
break;
|
|
1262
|
+
|
|
1263
|
+
case "object":
|
|
1264
|
+
base.type = "object";
|
|
1265
|
+
base.objectFields = [];
|
|
1266
|
+
base.uispec = {
|
|
1267
|
+
type: "flowForm",
|
|
1268
|
+
layout: MUtil.phoneLike() ? "vertical" : "horizontal",
|
|
1269
|
+
comma: ":"
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
for (var key in e.properties) {
|
|
1273
|
+
var jsmField = e.properties[key];
|
|
1274
|
+
|
|
1275
|
+
var m3Field = _.assign({}, template, {
|
|
1276
|
+
name: key,
|
|
1277
|
+
label: key,
|
|
1278
|
+
type: "object"
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
if (!_.isBoolean(jsmField)) {
|
|
1282
|
+
var _jsmField$title;
|
|
1283
|
+
|
|
1284
|
+
m3Field.label = (_jsmField$title = jsmField.title) != null ? _jsmField$title : key;
|
|
1285
|
+
this.jsonSchema2MFieldSchema(jsmField, m3Field, template);
|
|
1286
|
+
base.objectFields.push(m3Field);
|
|
1287
|
+
} else {
|
|
1288
|
+
m3Field.type = "不支持的json schema:object.properties的value是boolean";
|
|
1289
|
+
base.objectFields.push();
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
break;
|
|
1294
|
+
|
|
1295
|
+
case "array":
|
|
1296
|
+
base.type = "array";
|
|
1297
|
+
base.arrayMember = {
|
|
1298
|
+
label: "",
|
|
1299
|
+
type: "array"
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
if (_.isArray(e.items)) {
|
|
1303
|
+
base.arrayMember.type = "不支持的json schema:array.items是数组";
|
|
1304
|
+
} else if (_.isBoolean(e.items)) {
|
|
1305
|
+
base.arrayMember.type = "不支持的json schema:array.items是boolean";
|
|
1306
|
+
} else if (e.items) {
|
|
1307
|
+
this.jsonSchema2MFieldSchema(e.items, base, template);
|
|
1308
|
+
} else {
|
|
1309
|
+
base.arrayMember.type = "不支持的json schema:array.items是undefined";
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
break;
|
|
1313
|
+
|
|
1314
|
+
case "null":
|
|
1315
|
+
case "any":
|
|
1316
|
+
case "boolean":
|
|
1317
|
+
default:
|
|
1318
|
+
base.type = "不支持的json schema:array.items是" + e.type;
|
|
1319
|
+
break;
|
|
1322
1320
|
}
|
|
1323
|
-
}
|
|
1324
1321
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1322
|
+
return base;
|
|
1323
|
+
},
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* 修改一个对象里的key
|
|
1327
|
+
* @param object 要修改的对象,
|
|
1328
|
+
* @param renameTo
|
|
1329
|
+
* @param removeNotExistKey 是否在结果里面去除renameTo里不存在的key
|
|
1330
|
+
* @returns 返回一个改过key名字的新对象
|
|
1331
|
+
*/
|
|
1332
|
+
renameKey: function renameKey(object, renameTo, removeNotExistKey) {
|
|
1333
|
+
if (removeNotExistKey === void 0) {
|
|
1334
|
+
removeNotExistKey = false;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
var result = {};
|
|
1338
|
+
|
|
1339
|
+
for (var oldKey in object) {
|
|
1340
|
+
var newKey = renameTo[oldKey];
|
|
1341
|
+
|
|
1342
|
+
if (!newKey) {
|
|
1343
|
+
if (removeNotExistKey) {
|
|
1344
|
+
continue;
|
|
1345
|
+
} else {
|
|
1346
|
+
newKey = oldKey;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
result[newKey] = object[oldKey];
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
return result;
|
|
1354
|
+
},
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* 提交时将时间字段转换为可读格式
|
|
1358
|
+
* @param schema 表单 schema(type 为 object 的根 schema)
|
|
1359
|
+
* @param database 表单数据
|
|
1360
|
+
* @returns 深拷贝后转换过的数据
|
|
1361
|
+
*/
|
|
1362
|
+
formatForExport: function formatForExport(schema, database) {
|
|
1363
|
+
if (_.isNil(database)) {
|
|
1364
|
+
return database;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
var result = _.cloneDeep(database);
|
|
1368
|
+
|
|
1369
|
+
var fields = schema.objectFields;
|
|
1370
|
+
|
|
1371
|
+
if (!fields) {
|
|
1372
|
+
return result;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
var _loop = function _loop() {
|
|
1376
|
+
var field = _step9.value;
|
|
1377
|
+
var value = result[field.name];
|
|
1378
|
+
|
|
1379
|
+
if (_.isNil(value)) {
|
|
1380
|
+
return "continue";
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
var type = field.type; // 时间选择器
|
|
1384
|
+
|
|
1385
|
+
if (type === "year" || type === "yearMonth" || type === "yearMonthDay" || type === "datetime" || type === "date") {
|
|
1386
|
+
var antConf = MDateTimeType.antConf(field);
|
|
1387
|
+
|
|
1388
|
+
if (antConf) {
|
|
1389
|
+
var m = moment(value, antConf.dataFormat);
|
|
1390
|
+
|
|
1391
|
+
if (m.isValid()) {
|
|
1392
|
+
result[field.name] = m.format(antConf.readableFormat);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
} // 时间范围选择器
|
|
1396
|
+
else if (type === "dateRange") {
|
|
1397
|
+
if (_.isArray(value)) {
|
|
1398
|
+
var _field$dateRange, _field$dataFormat;
|
|
1399
|
+
|
|
1400
|
+
var start = value[0],
|
|
1401
|
+
end = value[1],
|
|
1402
|
+
tillNow = value[2];
|
|
1403
|
+
var fmt = getReadableFormat(field.dateRangePrecision, (_field$dateRange = field.dateRange) == null ? void 0 : _field$dateRange.showTime);
|
|
1404
|
+
var dataFormat = (_field$dataFormat = field.dataFormat) != null ? _field$dataFormat : "x";
|
|
1405
|
+
var startStr = "";
|
|
1406
|
+
var endStr = "";
|
|
1407
|
+
|
|
1408
|
+
if (!_.isNil(start)) {
|
|
1409
|
+
var _m = moment(start, dataFormat);
|
|
1410
|
+
|
|
1411
|
+
startStr = _m.isValid() ? _m.format(fmt) : "";
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
if (tillNow) {
|
|
1415
|
+
endStr = "至今";
|
|
1416
|
+
} else if (!_.isNil(end)) {
|
|
1417
|
+
var _m2 = moment(end, dataFormat);
|
|
1418
|
+
|
|
1419
|
+
endStr = _m2.isValid() ? _m2.format(fmt) : "";
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
result[field.name] = startStr + " - " + endStr;
|
|
1423
|
+
}
|
|
1424
|
+
} // 嵌套 object
|
|
1425
|
+
else if (type === "object" && field.objectFields) {
|
|
1426
|
+
result[field.name] = MUtil.formatForExport(field, value);
|
|
1427
|
+
} // 嵌套 array
|
|
1428
|
+
else if (type === "array" && field.arrayMember && _.isArray(value)) {
|
|
1429
|
+
if (field.arrayMember.objectFields) {
|
|
1430
|
+
result[field.name] = value.map(function (item) {
|
|
1431
|
+
return MUtil.formatForExport(field.arrayMember, item);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
};
|
|
1436
|
+
|
|
1437
|
+
for (var _iterator9 = _createForOfIteratorHelperLoose$d(fields), _step9; !(_step9 = _iterator9()).done;) {
|
|
1438
|
+
var _ret = _loop();
|
|
1439
|
+
|
|
1440
|
+
if (_ret === "continue") continue;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
return result;
|
|
1444
|
+
},
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* 回填时将可读格式的时间字段反解析为内部格式
|
|
1448
|
+
* @param schema 表单 schema(type 为 object 的根 schema)
|
|
1449
|
+
* @param database 可读格式的数据
|
|
1450
|
+
* @returns 深拷贝后反解析过的数据
|
|
1451
|
+
*/
|
|
1452
|
+
parseFromExport: function parseFromExport(schema, database) {
|
|
1453
|
+
if (_.isNil(database)) {
|
|
1454
|
+
return database;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
var result = _.cloneDeep(database);
|
|
1458
|
+
|
|
1459
|
+
var fields = schema.objectFields;
|
|
1460
|
+
|
|
1461
|
+
if (!fields) {
|
|
1462
|
+
return result;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
var _loop2 = function _loop2() {
|
|
1466
|
+
var field = _step10.value;
|
|
1467
|
+
var value = result[field.name];
|
|
1468
|
+
|
|
1469
|
+
if (_.isNil(value)) {
|
|
1470
|
+
return "continue";
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
var type = field.type; // 时间选择器
|
|
1474
|
+
|
|
1475
|
+
if (type === "year" || type === "yearMonth" || type === "yearMonthDay" || type === "datetime" || type === "date") {
|
|
1476
|
+
var antConf = MDateTimeType.antConf(field);
|
|
1477
|
+
|
|
1478
|
+
if (antConf && _.isString(value)) {
|
|
1479
|
+
var m = moment(value, antConf.readableFormat);
|
|
1480
|
+
|
|
1481
|
+
if (m.isValid()) {
|
|
1482
|
+
result[field.name] = m.format(antConf.dataFormat);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
} // 时间范围选择器
|
|
1486
|
+
else if (type === "dateRange") {
|
|
1487
|
+
if (_.isString(value)) {
|
|
1488
|
+
var _field$dateRange2, _field$dataFormat2, _parts$, _parts$2;
|
|
1489
|
+
|
|
1490
|
+
var fmt = getReadableFormat(field.dateRangePrecision, (_field$dateRange2 = field.dateRange) == null ? void 0 : _field$dateRange2.showTime);
|
|
1491
|
+
var dataFormat = (_field$dataFormat2 = field.dataFormat) != null ? _field$dataFormat2 : "x";
|
|
1492
|
+
var parts = value.split(" - ");
|
|
1493
|
+
var startStr = (_parts$ = parts[0]) == null ? void 0 : _parts$.trim();
|
|
1494
|
+
var endStr = (_parts$2 = parts[1]) == null ? void 0 : _parts$2.trim();
|
|
1495
|
+
var start = null;
|
|
1496
|
+
var end = null;
|
|
1497
|
+
var tillNow = false;
|
|
1498
|
+
|
|
1499
|
+
if (startStr) {
|
|
1500
|
+
var _m3 = moment(startStr, fmt);
|
|
1501
|
+
|
|
1502
|
+
if (_m3.isValid()) {
|
|
1503
|
+
start = _m3.format(dataFormat);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
if (endStr === "至今") {
|
|
1508
|
+
tillNow = true;
|
|
1509
|
+
} else if (endStr) {
|
|
1510
|
+
var _m4 = moment(endStr, fmt);
|
|
1511
|
+
|
|
1512
|
+
if (_m4.isValid()) {
|
|
1513
|
+
end = _m4.format(dataFormat);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
result[field.name] = [start, end, tillNow];
|
|
1518
|
+
}
|
|
1519
|
+
} // 嵌套 object
|
|
1520
|
+
else if (type === "object" && field.objectFields) {
|
|
1521
|
+
result[field.name] = MUtil.parseFromExport(field, value);
|
|
1522
|
+
} // 嵌套 array
|
|
1523
|
+
else if (type === "array" && field.arrayMember && _.isArray(value)) {
|
|
1524
|
+
if (field.arrayMember.objectFields) {
|
|
1525
|
+
result[field.name] = value.map(function (item) {
|
|
1526
|
+
return MUtil.parseFromExport(field.arrayMember, item);
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
for (var _iterator10 = _createForOfIteratorHelperLoose$d(fields), _step10; !(_step10 = _iterator10()).done;) {
|
|
1533
|
+
var _ret2 = _loop2();
|
|
1534
|
+
|
|
1535
|
+
if (_ret2 === "continue") continue;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
return result;
|
|
1539
|
+
},
|
|
1540
|
+
|
|
1541
|
+
/** 啥也不干的空回调 */
|
|
1542
|
+
doNothing: function doNothing() {},
|
|
1543
|
+
|
|
1544
|
+
/**
|
|
1545
|
+
* 去掉arr中的undefined和null,拼出来一个json path
|
|
1546
|
+
*/
|
|
1547
|
+
jsonPath: function jsonPath() {
|
|
1548
|
+
for (var _len2 = arguments.length, arr = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1549
|
+
arr[_key2] = arguments[_key2];
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
return _.compact(arr).join(".");
|
|
1553
|
+
},
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* 获取一个json path的父path。
|
|
1557
|
+
* @param path 如果path是空的返回也是空的
|
|
1558
|
+
*/
|
|
1559
|
+
parentPath: function parentPath(path) {
|
|
1560
|
+
var split = path.replace(/]/g, "").split(/[.\\[]/);
|
|
1561
|
+
split.splice(-1, 1);
|
|
1562
|
+
return split.join(".");
|
|
1563
|
+
},
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* 校验一个schema
|
|
1567
|
+
* @param s 要校验的schema
|
|
1568
|
+
* @returns 空数组表示校验通过,否则返回校验错误信息
|
|
1569
|
+
*/
|
|
1570
|
+
validateSchema: function validateSchema(s, parentPath) {
|
|
1571
|
+
var result = [];
|
|
1572
|
+
|
|
1573
|
+
var error = function error(msg) {
|
|
1574
|
+
return result.push({
|
|
1575
|
+
message: msg,
|
|
1576
|
+
path: MUtil.jsonPath(parentPath, s.name)
|
|
1577
|
+
});
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
var checkDup = function checkDup(a, msgIfFail) {
|
|
1581
|
+
if (_.uniq(a).length !== a.length) {
|
|
1582
|
+
error(msgIfFail);
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
|
|
1586
|
+
var checkVL = function checkVL(fs) {
|
|
1587
|
+
checkDup(fs.map(function (f) {
|
|
1588
|
+
return f.value;
|
|
1589
|
+
}), s.name + "值有重复");
|
|
1590
|
+
checkDup(fs.map(function (f) {
|
|
1591
|
+
return f.label;
|
|
1592
|
+
}).filter(function (l) {
|
|
1593
|
+
return l;
|
|
1594
|
+
}), s.name + "文案有重复");
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
var stringOnlyEnum = function stringOnlyEnum(candidate) {
|
|
1598
|
+
var ns = MUtil.standardFields(candidate).find(function (f) {
|
|
1599
|
+
return !_.isString(f.value);
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
if (ns) {
|
|
1603
|
+
error("暂不支持的选项数据类型:" + JSON.stringify(ns) + ": " + typeof ns);
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
|
|
1607
|
+
if (s.type === "decoration") {
|
|
1608
|
+
return [];
|
|
1609
|
+
} else if (s.type === "enum") {
|
|
1610
|
+
checkVL(MUtil.standardFields(s.enumFields));
|
|
1611
|
+
} else if (s.type === "set") {
|
|
1612
|
+
checkVL(MUtil.standardFields(s.setFields));
|
|
1613
|
+
} else if (s.type === "matrix") {
|
|
1614
|
+
stringOnlyEnum(s.matrix.x);
|
|
1615
|
+
stringOnlyEnum(s.matrix.y);
|
|
1616
|
+
} else if (s.type === "object") {
|
|
1617
|
+
if (!s.objectFields) {
|
|
1618
|
+
error("object类型未定义成员");
|
|
1619
|
+
} else {
|
|
1620
|
+
var _s$uispec;
|
|
1621
|
+
|
|
1622
|
+
checkDup(s.objectFields.filter(function (f) {
|
|
1623
|
+
return f.type !== "decoration";
|
|
1624
|
+
}).map(function (f) {
|
|
1625
|
+
return f.name;
|
|
1626
|
+
}), "字段名有重复");
|
|
1627
|
+
|
|
1628
|
+
for (var _iterator11 = _createForOfIteratorHelperLoose$d(s.objectFields), _step11; !(_step11 = _iterator11()).done;) {
|
|
1629
|
+
var f = _step11.value;
|
|
1630
|
+
result = _.concat(result, MUtil.validateSchema(f, MUtil.jsonPath(parentPath, s.name)));
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
if (((_s$uispec = s.uispec) == null ? void 0 : _s$uispec.type) === "segmentForm") {
|
|
1634
|
+
if (!s.uispec.segments) {
|
|
1635
|
+
error("分段未定义");
|
|
1636
|
+
} else {
|
|
1637
|
+
checkDup(s.uispec.segments.map(function (f) {
|
|
1638
|
+
return f.label;
|
|
1639
|
+
}), "分段文案有重复");
|
|
1640
|
+
|
|
1641
|
+
var fieldsInSegments = _.flatten(s.uispec.segments.map(function (f) {
|
|
1642
|
+
return f.fields;
|
|
1643
|
+
}));
|
|
1644
|
+
|
|
1645
|
+
checkDup(fieldsInSegments, "分段字段有重复");
|
|
1646
|
+
var fields = s.objectFields.map(function (f) {
|
|
1647
|
+
return f.name;
|
|
1648
|
+
});
|
|
1649
|
+
checkDup(fields, "字段名有重复");
|
|
1650
|
+
|
|
1651
|
+
var notInSegment = _.difference(fields, fieldsInSegments);
|
|
1652
|
+
|
|
1653
|
+
if (notInSegment.length > 0) {
|
|
1654
|
+
error("字段" + notInSegment.join(",") + "未体现在分段中");
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
var fieldNotExist = _.difference(fieldsInSegments, fields);
|
|
1658
|
+
|
|
1659
|
+
if (fieldNotExist.length > 0) {
|
|
1660
|
+
error("分段字段名无效:" + notInSegment.join(","));
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
return result;
|
|
1668
|
+
},
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* 参考https://stackoverflow.com/questions/3362471/how-can-i-call-a-javascript-constructor-using-call-or-apply
|
|
1672
|
+
* 示例: var d = applyToConstructor(Date, [2008, 10, 8, 00, 16, 34, 254]);
|
|
1673
|
+
* @param constructor
|
|
1674
|
+
* @param argArray
|
|
1675
|
+
*/
|
|
1676
|
+
applyToConstructor: function applyToConstructor(constructor, argArray) {
|
|
1677
|
+
var args = [null].concat(argArray);
|
|
1678
|
+
var factoryFunction = constructor.bind.apply(constructor, args);
|
|
1679
|
+
return new factoryFunction();
|
|
1680
|
+
},
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* 执行表达式或者回调函数
|
|
1684
|
+
* @param exprOrFunction 表达式或者回调函数
|
|
1685
|
+
* @param paramName 参数名字
|
|
1686
|
+
* @param paramValue 参数值
|
|
1687
|
+
* @param fallback 如果exprOrFunction无效,返回fallback
|
|
1688
|
+
* @param _this this指针
|
|
1689
|
+
*/
|
|
1690
|
+
evalExprOrFunction: function evalExprOrFunction(exprOrFunction, paramName, paramValue, fallback, _this) {
|
|
1691
|
+
if (fallback === void 0) {
|
|
1692
|
+
fallback = undefined;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
if (_this === void 0) {
|
|
1696
|
+
_this = undefined;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
if (_.isFunction(exprOrFunction)) {
|
|
1700
|
+
return exprOrFunction.apply(_this, paramValue);
|
|
1701
|
+
} else if (_.isString(exprOrFunction)) {
|
|
1702
|
+
//return new Function("_", "value", "parent", "return (" + labelExpr + ");")(_, value, parent);
|
|
1703
|
+
var func = MUtil.applyToConstructor(Function, [].concat(paramName, ["return (" + exprOrFunction + ")"]));
|
|
1704
|
+
return func.apply(_this, paramValue);
|
|
1705
|
+
} else {
|
|
1706
|
+
return fallback;
|
|
1707
|
+
}
|
|
1708
|
+
},
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* 读取url参数,转换成map
|
|
1712
|
+
* @param hashPrefix nil表示不读取hash里的参数,字符串表示读取hash里的参数,并加上这个前缀返回。默认是返回,但前缀是空字符串
|
|
1713
|
+
*/
|
|
1714
|
+
getQuery: function getQuery(hashPrefix) {
|
|
1715
|
+
|
|
1716
|
+
var arrs = [].concat(window.location.search.split(/[?&]/), window.location.hash.split(/[#?&]/));
|
|
1717
|
+
var result = {};
|
|
1718
|
+
arrs.forEach(function (item) {
|
|
1719
|
+
var kv = item.split(/=/);
|
|
1720
|
+
|
|
1721
|
+
if (kv.length <= 2 && kv[0]) {
|
|
1722
|
+
result[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1]);
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
return result;
|
|
1726
|
+
},
|
|
1727
|
+
|
|
1728
|
+
/**
|
|
1729
|
+
* 动态创建一个CSS样式
|
|
1730
|
+
* @param css css内容,会被写进style标签里
|
|
1731
|
+
* @param id <style>的id,可以没有。如果已经存在,会被覆盖掉。
|
|
1732
|
+
*/
|
|
1733
|
+
setCss: function setCss(css, id) {
|
|
1734
|
+
var _document$getElementB;
|
|
1735
|
+
|
|
1736
|
+
var s = (_document$getElementB = document.getElementById(id)) != null ? _document$getElementB : document.createElement("style");
|
|
1737
|
+
s.id = id;
|
|
1738
|
+
s.type = "text/css";
|
|
1739
|
+
s.innerHTML = css;
|
|
1740
|
+
document.getElementsByTagName("head")[0].appendChild(s);
|
|
1741
|
+
},
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* escape数值
|
|
1745
|
+
* @param str - 字符串
|
|
1746
|
+
* @returns 会带上引号,类似"abc",str=nil时会返回""
|
|
1747
|
+
*/
|
|
1748
|
+
escapeCsv: function escapeCsv(str) {
|
|
1749
|
+
if (!_.isString(str)) {
|
|
1750
|
+
str = _.toString(str);
|
|
1331
1751
|
}
|
|
1332
|
-
}
|
|
1333
1752
|
|
|
1334
|
-
|
|
1335
|
-
}
|
|
1336
|
-
/**
|
|
1337
|
-
* 字符串长度不超过[min, max]
|
|
1338
|
-
* @param schema
|
|
1339
|
-
* @param value 应该是个字符串
|
|
1340
|
-
*/
|
|
1753
|
+
return '"' + str.replace(/["]/g, '""') + '"';
|
|
1754
|
+
},
|
|
1341
1755
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1756
|
+
/**
|
|
1757
|
+
* 判断两个值是否相同
|
|
1758
|
+
* @param v1 一个值
|
|
1759
|
+
* @param v2 另一个值
|
|
1760
|
+
* @param tolerate true用==判断,false用===判断
|
|
1761
|
+
*/
|
|
1762
|
+
isEquals: function isEquals(v1, v2, tolerate) {
|
|
1763
|
+
if (tolerate) {
|
|
1764
|
+
return v1 == v2;
|
|
1765
|
+
} else {
|
|
1766
|
+
return v1 === v2;
|
|
1349
1767
|
}
|
|
1350
1768
|
}
|
|
1769
|
+
};
|
|
1770
|
+
var CompactArray = {
|
|
1771
|
+
indexOf: function indexOf(ca, d) {
|
|
1772
|
+
if (_.isNil(d) || _.isNil(ca)) {
|
|
1773
|
+
return -1;
|
|
1774
|
+
}
|
|
1351
1775
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
path: path
|
|
1357
|
-
};
|
|
1776
|
+
if (_.isArray(ca)) {
|
|
1777
|
+
return ca.indexOf(d);
|
|
1778
|
+
} else {
|
|
1779
|
+
return ca === d ? 0 : -1;
|
|
1358
1780
|
}
|
|
1359
1781
|
}
|
|
1782
|
+
};
|
|
1360
1783
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1784
|
+
var MContext = /*#__PURE__*/React.createContext(undefined);
|
|
1785
|
+
|
|
1786
|
+
function ownKeys$x(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1787
|
+
|
|
1788
|
+
function _objectSpread$x(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$x(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$x(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1363
1789
|
/**
|
|
1364
|
-
*
|
|
1365
|
-
* @param schema
|
|
1366
|
-
* @param value 应该是个数字
|
|
1790
|
+
* 一个字段的视图
|
|
1367
1791
|
*/
|
|
1368
1792
|
|
|
1369
|
-
|
|
1370
|
-
|
|
1793
|
+
var MFieldViewer = /*#__PURE__*/function (_React$Component) {
|
|
1794
|
+
_inheritsLoose(MFieldViewer, _React$Component);
|
|
1371
1795
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
return {
|
|
1375
|
-
message: "\u6700\u591A" + schema.max,
|
|
1376
|
-
path: path
|
|
1377
|
-
};
|
|
1378
|
-
}
|
|
1796
|
+
function MFieldViewer() {
|
|
1797
|
+
return _React$Component.apply(this, arguments) || this;
|
|
1379
1798
|
}
|
|
1380
1799
|
|
|
1381
|
-
|
|
1382
|
-
if (!_.isFinite(temp) || temp < schema.min) {
|
|
1383
|
-
return {
|
|
1384
|
-
message: "\u6700\u5C11" + schema.min,
|
|
1385
|
-
path: path
|
|
1386
|
-
};
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1800
|
+
var _proto = MFieldViewer.prototype;
|
|
1389
1801
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
function generateRegexValidate$1(regex, mismatchMsg) {
|
|
1393
|
-
return function (a, schema, value, path) {
|
|
1394
|
-
var asstr = _.toString(value);
|
|
1802
|
+
_proto.render = function render() {
|
|
1803
|
+
var _this = this;
|
|
1395
1804
|
|
|
1396
|
-
|
|
1397
|
-
return {
|
|
1398
|
-
message: mismatchMsg,
|
|
1399
|
-
path: path
|
|
1400
|
-
};
|
|
1401
|
-
}
|
|
1805
|
+
var viewer = assembly.getViewerOf(this.props.schema, this.props.morph); // console.log('MFieldViewer.viewer', viewer);
|
|
1402
1806
|
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
}
|
|
1406
|
-
/**
|
|
1407
|
-
* 数据用Object.prototype.toString.call返回的类型是预期的
|
|
1408
|
-
* 可以用Object.prototype.toString.call(<预期的类型>)来查看你想要的数据类型的expectType
|
|
1409
|
-
* @param expectType 预期类型,例如:"[object Object]" "[object Null]" "[object Number]" "[object Date]" "[object Array]"
|
|
1410
|
-
* @param mismatchMsg 如果不匹配,提示的错误信息
|
|
1411
|
-
* @returns
|
|
1412
|
-
*/
|
|
1807
|
+
if (!viewer) {
|
|
1808
|
+
return MUtil.error("\u5B57\u6BB5\u7684\u89C6\u56FE\u5C1A\u672A\u5B9E\u73B0", this.props.schema);
|
|
1809
|
+
}
|
|
1413
1810
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1811
|
+
var props = _objectSpread$x({
|
|
1812
|
+
afterChange: function afterChange() {},
|
|
1813
|
+
changeSchema: function changeSchema() {},
|
|
1814
|
+
changeDatabase: function changeDatabase() {},
|
|
1815
|
+
name: this.props.path
|
|
1816
|
+
}, this.props);
|
|
1418
1817
|
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1818
|
+
var ele = /*#__PURE__*/React.createElement(viewer, props, null);
|
|
1819
|
+
return jsx(MContext.Consumer, {
|
|
1820
|
+
children: function children(ctx) {
|
|
1821
|
+
if (ctx.rootProps.wrapper && _this.props.schema.type !== 'object' && _this.props.schema.type !== 'array') {
|
|
1822
|
+
return ctx.rootProps.wrapper(ele, _this.props.schema);
|
|
1823
|
+
} else {
|
|
1824
|
+
return ele;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1428
1828
|
};
|
|
1429
|
-
}
|
|
1430
|
-
function generateSchemaValidate(valueSchema, mismatchMsg) {
|
|
1431
|
-
return function (a, schema, value, path) {
|
|
1432
|
-
var r = assembly.validate(valueSchema, value, "");
|
|
1433
1829
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
} else {
|
|
1437
|
-
return {
|
|
1438
|
-
message: mismatchMsg != null ? mismatchMsg : r.message,
|
|
1439
|
-
path: path
|
|
1440
|
-
};
|
|
1441
|
-
}
|
|
1442
|
-
};
|
|
1443
|
-
}
|
|
1444
|
-
var Validator = {
|
|
1445
|
-
validateRequired: validateRequired$1,
|
|
1446
|
-
validateRequiredNS: validateRequiredNS,
|
|
1447
|
-
validateDateMinMax: validateDateMinMax,
|
|
1448
|
-
validateStringMinMax: validateStringMinMax$1,
|
|
1449
|
-
validateNumberMinMax: validateNumberMinMax,
|
|
1450
|
-
generateRegexValidate: generateRegexValidate$1
|
|
1451
|
-
};
|
|
1830
|
+
return MFieldViewer;
|
|
1831
|
+
}(React.Component);
|
|
1452
1832
|
|
|
1453
1833
|
function _createForOfIteratorHelperLoose$c(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$c(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
1454
1834
|
|
|
@@ -1535,34 +1915,6 @@ var MEnumType = {
|
|
|
1535
1915
|
}
|
|
1536
1916
|
};
|
|
1537
1917
|
|
|
1538
|
-
var EmtpyType = {
|
|
1539
|
-
validators: [],
|
|
1540
|
-
createDefaultValue: function createDefaultValue(assembly, s) {
|
|
1541
|
-
if (s.defaultValue) {
|
|
1542
|
-
return _.clone(s.defaultValue);
|
|
1543
|
-
} else {
|
|
1544
|
-
return undefined;
|
|
1545
|
-
}
|
|
1546
|
-
},
|
|
1547
|
-
standardValue: function standardValue(assembly, s, v, strict) {
|
|
1548
|
-
return v;
|
|
1549
|
-
},
|
|
1550
|
-
toReadable: function toReadable(assembly, s, vs) {
|
|
1551
|
-
if (_.isNil(vs)) {
|
|
1552
|
-
return assembly.theme.READABLE_BLANK;
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
return vs;
|
|
1556
|
-
}
|
|
1557
|
-
};
|
|
1558
|
-
function createDefaultValue(assembly, s) {
|
|
1559
|
-
if (s.defaultValue) {
|
|
1560
|
-
return _.clone(s.defaultValue);
|
|
1561
|
-
} else {
|
|
1562
|
-
return undefined;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
1918
|
var gb2260 = [
|
|
1567
1919
|
{
|
|
1568
1920
|
value: "110000",
|
|
@@ -15067,102 +15419,36 @@ var MGB2260Type = _.assign({}, EmtpyType, {
|
|
|
15067
15419
|
}
|
|
15068
15420
|
|
|
15069
15421
|
for (var _iterator2 = _createForOfIteratorHelperLoose$b(prv.children), _step2; !(_step2 = _iterator2()).done;) {
|
|
15070
|
-
var city = _step2.value;
|
|
15071
|
-
// @ts-ignore city.value全是数字,ts并不知道
|
|
15072
|
-
var cdiff = code - city.value; // @ts-ignore
|
|
15073
|
-
|
|
15074
|
-
if (cdiff === 0) {
|
|
15075
|
-
return {
|
|
15076
|
-
label: [prv.label, city.label],
|
|
15077
|
-
code: [prv.value, city.value]
|
|
15078
|
-
};
|
|
15079
|
-
} else if (cdiff > 0 && cdiff < 100) {
|
|
15080
|
-
// @ts-ignore
|
|
15081
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose$b((_city$children = city.children) != null ? _city$children : []), _step3; !(_step3 = _iterator3()).done;) {
|
|
15082
|
-
var _city$children;
|
|
15083
|
-
|
|
15084
|
-
var dst = _step3.value;
|
|
15085
|
-
|
|
15086
|
-
// eslint-disable-next-line eqeqeq
|
|
15087
|
-
if (dst.value == code) {
|
|
15088
|
-
return {
|
|
15089
|
-
label: [prv.label, city.label, dst.label],
|
|
15090
|
-
code: [prv.value, city.value, dst.value]
|
|
15091
|
-
};
|
|
15092
|
-
}
|
|
15093
|
-
}
|
|
15094
|
-
}
|
|
15095
|
-
}
|
|
15096
|
-
}
|
|
15097
|
-
}
|
|
15098
|
-
|
|
15099
|
-
return undefined;
|
|
15100
|
-
}
|
|
15101
|
-
});
|
|
15102
|
-
|
|
15103
|
-
var MDateTimeType = _.assign({}, EmtpyType, {
|
|
15104
|
-
validators: [validateRequired$1, validateDateMinMax],
|
|
15105
|
-
antConf: function antConf(schema) {
|
|
15106
|
-
var _dataFormat, _dataFormat2, _dataFormat3, _dataFormat4;
|
|
15107
|
-
|
|
15108
|
-
var dataFormat = schema.dataFormat;
|
|
15109
|
-
var readableFormat;
|
|
15110
|
-
var mode;
|
|
15111
|
-
var showTime = false;
|
|
15112
|
-
|
|
15113
|
-
switch (schema.type) {
|
|
15114
|
-
case "year":
|
|
15115
|
-
mode = "year";
|
|
15116
|
-
dataFormat = (_dataFormat = dataFormat) != null ? _dataFormat : 'YYYY';
|
|
15117
|
-
readableFormat = 'YYYY';
|
|
15118
|
-
break;
|
|
15119
|
-
|
|
15120
|
-
case "yearMonth":
|
|
15121
|
-
mode = "month";
|
|
15122
|
-
dataFormat = (_dataFormat2 = dataFormat) != null ? _dataFormat2 : 'YYYYMM';
|
|
15123
|
-
readableFormat = 'YYYY-MM';
|
|
15124
|
-
break;
|
|
15125
|
-
|
|
15126
|
-
case "yearMonthDay":
|
|
15127
|
-
mode = "date";
|
|
15128
|
-
dataFormat = (_dataFormat3 = dataFormat) != null ? _dataFormat3 : 'YYYYMMDD';
|
|
15129
|
-
readableFormat = 'YYYY-MM-DD';
|
|
15130
|
-
break;
|
|
15131
|
-
|
|
15132
|
-
case "datetime":
|
|
15133
|
-
mode = undefined;
|
|
15134
|
-
dataFormat = (_dataFormat4 = dataFormat) != null ? _dataFormat4 : 'x';
|
|
15135
|
-
readableFormat = 'YYYY-MM-DD HH:mm';
|
|
15136
|
-
showTime = true;
|
|
15137
|
-
break;
|
|
15138
|
-
// case "yearAndQuarter":
|
|
15139
|
-
// case "yearAndWeek":
|
|
15140
|
-
// return MUtil.error(`移动端不支持${this.props.schema.type}`, this.props.schema);
|
|
15141
|
-
|
|
15142
|
-
default:
|
|
15143
|
-
return undefined;
|
|
15144
|
-
}
|
|
15422
|
+
var city = _step2.value;
|
|
15423
|
+
// @ts-ignore city.value全是数字,ts并不知道
|
|
15424
|
+
var cdiff = code - city.value; // @ts-ignore
|
|
15145
15425
|
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
return assembly.theme.READABLE_BLANK;
|
|
15156
|
-
}
|
|
15426
|
+
if (cdiff === 0) {
|
|
15427
|
+
return {
|
|
15428
|
+
label: [prv.label, city.label],
|
|
15429
|
+
code: [prv.value, city.value]
|
|
15430
|
+
};
|
|
15431
|
+
} else if (cdiff > 0 && cdiff < 100) {
|
|
15432
|
+
// @ts-ignore
|
|
15433
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose$b((_city$children = city.children) != null ? _city$children : []), _step3; !(_step3 = _iterator3()).done;) {
|
|
15434
|
+
var _city$children;
|
|
15157
15435
|
|
|
15158
|
-
|
|
15436
|
+
var dst = _step3.value;
|
|
15159
15437
|
|
|
15160
|
-
|
|
15161
|
-
|
|
15438
|
+
// eslint-disable-next-line eqeqeq
|
|
15439
|
+
if (dst.value == code) {
|
|
15440
|
+
return {
|
|
15441
|
+
label: [prv.label, city.label, dst.label],
|
|
15442
|
+
code: [prv.value, city.value, dst.value]
|
|
15443
|
+
};
|
|
15444
|
+
}
|
|
15445
|
+
}
|
|
15446
|
+
}
|
|
15447
|
+
}
|
|
15448
|
+
}
|
|
15162
15449
|
}
|
|
15163
15450
|
|
|
15164
|
-
|
|
15165
|
-
return asMoment.format(c.readableFormat);
|
|
15451
|
+
return undefined;
|
|
15166
15452
|
}
|
|
15167
15453
|
});
|
|
15168
15454
|
|
|
@@ -15817,59 +16103,6 @@ var MObjectType = {
|
|
|
15817
16103
|
}
|
|
15818
16104
|
};
|
|
15819
16105
|
|
|
15820
|
-
function timeExpr(assembly, v, tillNow, readableFormat) {
|
|
15821
|
-
if (tillNow) {
|
|
15822
|
-
return "至今";
|
|
15823
|
-
}
|
|
15824
|
-
|
|
15825
|
-
if (!v) {
|
|
15826
|
-
return assembly.theme.READABLE_UNKNOWN;
|
|
15827
|
-
}
|
|
15828
|
-
|
|
15829
|
-
return moment(v, "x").format(readableFormat);
|
|
15830
|
-
}
|
|
15831
|
-
|
|
15832
|
-
function timeRangeExpr(assembly, from, to, tillNow, readableFormat) {
|
|
15833
|
-
if (readableFormat === void 0) {
|
|
15834
|
-
readableFormat = "YYYY年MM月DD日";
|
|
15835
|
-
}
|
|
15836
|
-
|
|
15837
|
-
return timeExpr(assembly, from, false, readableFormat) + " ~ " + timeExpr(assembly, to, tillNow, readableFormat);
|
|
15838
|
-
}
|
|
15839
|
-
var MDateRangeType = _.assign({}, EmtpyType, {
|
|
15840
|
-
validators: [validateRequired$1],
|
|
15841
|
-
toReadable: function toReadable(assembly, s, vs) {
|
|
15842
|
-
var _s$dateRange;
|
|
15843
|
-
|
|
15844
|
-
if (_.isNil(vs)) {
|
|
15845
|
-
return assembly.theme.READABLE_BLANK;
|
|
15846
|
-
}
|
|
15847
|
-
|
|
15848
|
-
if (!_.isArray(vs)) {
|
|
15849
|
-
return assembly.theme.READABLE_INVALID;
|
|
15850
|
-
}
|
|
15851
|
-
|
|
15852
|
-
return timeRangeExpr(assembly, vs[0], vs[1], vs[2], (_s$dateRange = s.dateRange) != null && _s$dateRange.showTime ? "YYYY年MM月DD日 HH:mm:ss" : "YYYY年MM月DD日");
|
|
15853
|
-
},
|
|
15854
|
-
|
|
15855
|
-
/**
|
|
15856
|
-
* 同toReadable,但数据无效时返回nil
|
|
15857
|
-
* @param assembly
|
|
15858
|
-
* @param s
|
|
15859
|
-
* @param vs
|
|
15860
|
-
* @returns
|
|
15861
|
-
*/
|
|
15862
|
-
toReadableN: function toReadableN(assembly, s, vs) {
|
|
15863
|
-
if (!_.isNil(vs) && _.isArray(vs)) {
|
|
15864
|
-
var _s$dateRange2;
|
|
15865
|
-
|
|
15866
|
-
return timeRangeExpr(assembly, vs[0], vs[1], vs[2], (_s$dateRange2 = s.dateRange) != null && _s$dateRange2.showTime ? "YYYY年MM月DD日 HH:mm:ss" : "YYYY年MM月DD日");
|
|
15867
|
-
}
|
|
15868
|
-
|
|
15869
|
-
return undefined;
|
|
15870
|
-
}
|
|
15871
|
-
});
|
|
15872
|
-
|
|
15873
16106
|
function _createForOfIteratorHelperLoose$6(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$6(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15874
16107
|
|
|
15875
16108
|
function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); }
|
|
@@ -16389,6 +16622,23 @@ var ArrayViewer = /*#__PURE__*/function (_BaseViewer) {
|
|
|
16389
16622
|
function ownKeys$v(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16390
16623
|
|
|
16391
16624
|
function _objectSpread$v(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$v(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$v(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16625
|
+
|
|
16626
|
+
function toPrecision(mode) {
|
|
16627
|
+
switch (mode) {
|
|
16628
|
+
case "year":
|
|
16629
|
+
return "year";
|
|
16630
|
+
|
|
16631
|
+
case "month":
|
|
16632
|
+
return "month";
|
|
16633
|
+
|
|
16634
|
+
case "date":
|
|
16635
|
+
return "day";
|
|
16636
|
+
|
|
16637
|
+
default:
|
|
16638
|
+
return "minute";
|
|
16639
|
+
// datetime 场景
|
|
16640
|
+
}
|
|
16641
|
+
}
|
|
16392
16642
|
/**
|
|
16393
16643
|
* 日期选择框
|
|
16394
16644
|
* 配置示例:
|
|
@@ -16400,17 +16650,22 @@ function _objectSpread$v(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
16400
16650
|
* 类型是dateTime时,dataFormat默认是x,例如1608897466955
|
|
16401
16651
|
*/
|
|
16402
16652
|
|
|
16653
|
+
|
|
16403
16654
|
var ADatetimePicker = /*#__PURE__*/function (_BaseViewer) {
|
|
16404
16655
|
_inheritsLoose(ADatetimePicker, _BaseViewer);
|
|
16405
16656
|
|
|
16406
|
-
function ADatetimePicker() {
|
|
16407
|
-
|
|
16657
|
+
function ADatetimePicker(props) {
|
|
16658
|
+
var _this;
|
|
16659
|
+
|
|
16660
|
+
_this = _BaseViewer.call(this, props) || this;
|
|
16661
|
+
_this.state.pickerVisible = false;
|
|
16662
|
+
return _this;
|
|
16408
16663
|
}
|
|
16409
16664
|
|
|
16410
16665
|
var _proto = ADatetimePicker.prototype;
|
|
16411
16666
|
|
|
16412
16667
|
_proto.element = function element() {
|
|
16413
|
-
var
|
|
16668
|
+
var _this2 = this,
|
|
16414
16669
|
_this$props$schema$pr;
|
|
16415
16670
|
|
|
16416
16671
|
var antConf = MDateTimeType.antConf(this.props.schema);
|
|
@@ -16427,9 +16682,9 @@ var ADatetimePicker = /*#__PURE__*/function (_BaseViewer) {
|
|
|
16427
16682
|
if (vv) {
|
|
16428
16683
|
var vvAsM = _.isDate(vv) ? moment(vv) : vv;
|
|
16429
16684
|
|
|
16430
|
-
_BaseViewer.prototype.changeValue.call(
|
|
16685
|
+
_BaseViewer.prototype.changeValue.call(_this2, vvAsM.format(antConf.dataFormat));
|
|
16431
16686
|
} else {
|
|
16432
|
-
_BaseViewer.prototype.changeValue.call(
|
|
16687
|
+
_BaseViewer.prototype.changeValue.call(_this2, undefined);
|
|
16433
16688
|
}
|
|
16434
16689
|
};
|
|
16435
16690
|
|
|
@@ -16437,36 +16692,60 @@ var ADatetimePicker = /*#__PURE__*/function (_BaseViewer) {
|
|
|
16437
16692
|
|
|
16438
16693
|
if (MUtil.phoneLike()) {
|
|
16439
16694
|
// 手机
|
|
16440
|
-
return
|
|
16441
|
-
|
|
16442
|
-
value: dataAsDate,
|
|
16443
|
-
minDate: this.props.schema.min ? moment(this.props.schema.min, antConf.dataFormat).toDate() : undefined,
|
|
16444
|
-
maxDate: this.props.schema.max ? moment(this.props.schema.max, antConf.dataFormat).toDate() : undefined,
|
|
16445
|
-
mode: antConf.mode,
|
|
16446
|
-
onChange: onChange
|
|
16447
|
-
}, p), {}, {
|
|
16448
|
-
children: jsx("div", {
|
|
16695
|
+
return jsxs(Fragment, {
|
|
16696
|
+
children: [jsx("div", {
|
|
16449
16697
|
className: "backfill",
|
|
16698
|
+
onClick: function onClick() {
|
|
16699
|
+
if (!_this2.props.disable) _this2.setState({
|
|
16700
|
+
pickerVisible: true
|
|
16701
|
+
});
|
|
16702
|
+
},
|
|
16450
16703
|
children: dataAsDate ? moment(dataAsDate).format(antConf.readableFormat) : "请点击选择"
|
|
16451
|
-
})
|
|
16452
|
-
|
|
16704
|
+
}), jsx(DatePicker, _objectSpread$v({
|
|
16705
|
+
visible: this.state.pickerVisible,
|
|
16706
|
+
value: dataAsDate,
|
|
16707
|
+
min: this.props.schema.min ? moment(this.props.schema.min, antConf.dataFormat).toDate() : undefined,
|
|
16708
|
+
max: this.props.schema.max ? moment(this.props.schema.max, antConf.dataFormat).toDate() : undefined,
|
|
16709
|
+
precision: toPrecision(antConf.mode),
|
|
16710
|
+
onConfirm: function onConfirm(val) {
|
|
16711
|
+
onChange(val);
|
|
16712
|
+
|
|
16713
|
+
_this2.setState({
|
|
16714
|
+
pickerVisible: false
|
|
16715
|
+
});
|
|
16716
|
+
},
|
|
16717
|
+
onClose: function onClose() {
|
|
16718
|
+
_this2.setState({
|
|
16719
|
+
pickerVisible: false
|
|
16720
|
+
});
|
|
16721
|
+
}
|
|
16722
|
+
}, p))]
|
|
16723
|
+
});
|
|
16453
16724
|
} else {
|
|
16725
|
+
var _antConf$mode;
|
|
16726
|
+
|
|
16454
16727
|
// 大屏
|
|
16455
|
-
|
|
16456
|
-
|
|
16457
|
-
|
|
16458
|
-
disabledDate: function disabledDate(m) {
|
|
16459
|
-
var d = _this.props.schema.min && moment(_this.props.schema.min, antConf.dataFormat).isAfter(m) || _this.props.schema.max && moment(_this.props.schema.max, antConf.dataFormat).isBefore(m);
|
|
16460
|
-
return !!d;
|
|
16461
|
-
},
|
|
16462
|
-
format: antConf.readableFormat,
|
|
16463
|
-
style: this.props.style,
|
|
16728
|
+
// key 中加入 mode 信息,确保精度切换时组件重新挂载
|
|
16729
|
+
var pickerKey = this.props.path + "_" + ((_antConf$mode = antConf.mode) != null ? _antConf$mode : "datetime");
|
|
16730
|
+
return jsx(ConfigProvider, {
|
|
16464
16731
|
locale: zhCN,
|
|
16465
|
-
|
|
16466
|
-
|
|
16467
|
-
|
|
16468
|
-
|
|
16469
|
-
|
|
16732
|
+
children: jsx(DatePicker$1, _objectSpread$v({
|
|
16733
|
+
disabled: this.props.disable,
|
|
16734
|
+
bordered: this.props.hideBorder ? false : true,
|
|
16735
|
+
disabledDate: function disabledDate(m) {
|
|
16736
|
+
var d = _this2.props.schema.min && moment(_this2.props.schema.min, antConf.dataFormat).isAfter(m) || _this2.props.schema.max && moment(_this2.props.schema.max, antConf.dataFormat).isBefore(m);
|
|
16737
|
+
return !!d;
|
|
16738
|
+
},
|
|
16739
|
+
format: antConf.readableFormat,
|
|
16740
|
+
style: {
|
|
16741
|
+
width: "300px"
|
|
16742
|
+
},
|
|
16743
|
+
defaultValue: dataAsMoment,
|
|
16744
|
+
showTime: antConf.showTime,
|
|
16745
|
+
picker: antConf.mode,
|
|
16746
|
+
onChange: onChange
|
|
16747
|
+
}, p), pickerKey)
|
|
16748
|
+
});
|
|
16470
16749
|
}
|
|
16471
16750
|
};
|
|
16472
16751
|
|
|
@@ -16485,8 +16764,12 @@ function _objectSpread$u(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
16485
16764
|
var AGB2260 = /*#__PURE__*/function (_BaseViewer) {
|
|
16486
16765
|
_inheritsLoose(AGB2260, _BaseViewer);
|
|
16487
16766
|
|
|
16488
|
-
function AGB2260() {
|
|
16489
|
-
|
|
16767
|
+
function AGB2260(props) {
|
|
16768
|
+
var _this;
|
|
16769
|
+
|
|
16770
|
+
_this = _BaseViewer.call(this, props) || this;
|
|
16771
|
+
_this.state.pickerVisible = false;
|
|
16772
|
+
return _this;
|
|
16490
16773
|
}
|
|
16491
16774
|
|
|
16492
16775
|
var _proto = AGB2260.prototype;
|
|
@@ -16494,7 +16777,7 @@ var AGB2260 = /*#__PURE__*/function (_BaseViewer) {
|
|
|
16494
16777
|
_proto.element = function element() {
|
|
16495
16778
|
var _MGB2260Type$lookup,
|
|
16496
16779
|
_this$props$schema$pr,
|
|
16497
|
-
|
|
16780
|
+
_this2 = this;
|
|
16498
16781
|
|
|
16499
16782
|
var v = _BaseViewer.prototype.getValue.call(this);
|
|
16500
16783
|
|
|
@@ -16509,26 +16792,34 @@ var AGB2260 = /*#__PURE__*/function (_BaseViewer) {
|
|
|
16509
16792
|
var _looked$label;
|
|
16510
16793
|
|
|
16511
16794
|
// 手机
|
|
16512
|
-
return
|
|
16513
|
-
|
|
16514
|
-
disabled: this.props.disable,
|
|
16515
|
-
className: "AGB2260",
|
|
16516
|
-
data: MGB2260Type.gb2260,
|
|
16517
|
-
value: looked.code,
|
|
16518
|
-
title: this.props.schema.label,
|
|
16519
|
-
onDismiss: function onDismiss() {
|
|
16520
|
-
return console.log('dismiss');
|
|
16521
|
-
},
|
|
16522
|
-
onOk: function onOk(e) {
|
|
16523
|
-
return _BaseViewer.prototype.changeValue.call(_this, _.last(e));
|
|
16524
|
-
}
|
|
16525
|
-
}, p), {}, {
|
|
16526
|
-
children: jsx("div", {
|
|
16795
|
+
return jsxs(Fragment, {
|
|
16796
|
+
children: [jsx("div", {
|
|
16527
16797
|
className: "backfill",
|
|
16528
16798
|
style: this.props.style,
|
|
16799
|
+
onClick: function onClick() {
|
|
16800
|
+
if (!_this2.props.disable) _this2.setState({
|
|
16801
|
+
pickerVisible: true
|
|
16802
|
+
});
|
|
16803
|
+
},
|
|
16529
16804
|
children: looked == null ? void 0 : (_looked$label = looked.label) == null ? void 0 : _looked$label.join("/")
|
|
16530
|
-
})
|
|
16531
|
-
|
|
16805
|
+
}), jsx(Picker, _objectSpread$u({
|
|
16806
|
+
columns: MGB2260Type.gb2260,
|
|
16807
|
+
value: looked.code,
|
|
16808
|
+
visible: this.state.pickerVisible,
|
|
16809
|
+
onConfirm: function onConfirm(e) {
|
|
16810
|
+
_BaseViewer.prototype.changeValue.call(_this2, _.last(e));
|
|
16811
|
+
|
|
16812
|
+
_this2.setState({
|
|
16813
|
+
pickerVisible: false
|
|
16814
|
+
});
|
|
16815
|
+
},
|
|
16816
|
+
onClose: function onClose() {
|
|
16817
|
+
_this2.setState({
|
|
16818
|
+
pickerVisible: false
|
|
16819
|
+
});
|
|
16820
|
+
}
|
|
16821
|
+
}, p))]
|
|
16822
|
+
});
|
|
16532
16823
|
} else {
|
|
16533
16824
|
// PC
|
|
16534
16825
|
return jsx(Cascader, _objectSpread$u({
|
|
@@ -16540,7 +16831,7 @@ var AGB2260 = /*#__PURE__*/function (_BaseViewer) {
|
|
|
16540
16831
|
style: this.props.style,
|
|
16541
16832
|
defaultValue: looked.code,
|
|
16542
16833
|
onChange: function onChange(vv) {
|
|
16543
|
-
_BaseViewer.prototype.changeValue.call(
|
|
16834
|
+
_BaseViewer.prototype.changeValue.call(_this2, _.last(vv));
|
|
16544
16835
|
}
|
|
16545
16836
|
}, p), this.props.path);
|
|
16546
16837
|
}
|
|
@@ -17369,39 +17660,58 @@ var UnderlineInputBox = /*#__PURE__*/function (_React$Component) {
|
|
|
17369
17660
|
var SelectBox = /*#__PURE__*/function (_React$Component) {
|
|
17370
17661
|
_inheritsLoose(SelectBox, _React$Component);
|
|
17371
17662
|
|
|
17372
|
-
function SelectBox() {
|
|
17373
|
-
|
|
17663
|
+
function SelectBox(props) {
|
|
17664
|
+
var _this;
|
|
17665
|
+
|
|
17666
|
+
_this = _React$Component.call(this, props) || this;
|
|
17667
|
+
_this.state = {
|
|
17668
|
+
pickerVisible: false
|
|
17669
|
+
};
|
|
17670
|
+
return _this;
|
|
17374
17671
|
}
|
|
17375
17672
|
|
|
17376
17673
|
var _proto = SelectBox.prototype;
|
|
17377
17674
|
|
|
17378
17675
|
_proto.render = function render() {
|
|
17379
|
-
var
|
|
17676
|
+
var _this2 = this;
|
|
17380
17677
|
|
|
17381
17678
|
if (MUtil.phoneLike()) {
|
|
17382
17679
|
var _looked$label;
|
|
17383
17680
|
|
|
17384
17681
|
var looked = this.props.options.find(function (o) {
|
|
17385
|
-
return o.value ===
|
|
17682
|
+
return o.value === _this2.props.data;
|
|
17386
17683
|
});
|
|
17387
17684
|
var backfillClass = looked ? "backfill" : "backfill_empty";
|
|
17388
|
-
return
|
|
17389
|
-
|
|
17390
|
-
cols: 1,
|
|
17391
|
-
data: this.props.options,
|
|
17392
|
-
value: [this.props.data],
|
|
17393
|
-
onOk: function onOk(e) {
|
|
17394
|
-
return _this.props.onChange(_.last(e));
|
|
17395
|
-
},
|
|
17396
|
-
onDismiss: function onDismiss() {
|
|
17397
|
-
if (_this.props.onBlur) {
|
|
17398
|
-
_this.props.onBlur();
|
|
17399
|
-
}
|
|
17400
|
-
},
|
|
17401
|
-
children: jsx("div", {
|
|
17685
|
+
return jsxs(Fragment, {
|
|
17686
|
+
children: [jsx("div", {
|
|
17402
17687
|
className: backfillClass,
|
|
17688
|
+
onClick: function onClick() {
|
|
17689
|
+
return _this2.setState({
|
|
17690
|
+
pickerVisible: true
|
|
17691
|
+
});
|
|
17692
|
+
},
|
|
17403
17693
|
children: (_looked$label = looked == null ? void 0 : looked.label) != null ? _looked$label : "点击选择"
|
|
17404
|
-
})
|
|
17694
|
+
}), jsx(Picker, {
|
|
17695
|
+
columns: [this.props.options],
|
|
17696
|
+
value: [this.props.data],
|
|
17697
|
+
visible: this.state.pickerVisible,
|
|
17698
|
+
onConfirm: function onConfirm(e) {
|
|
17699
|
+
_this2.props.onChange(_.last(e));
|
|
17700
|
+
|
|
17701
|
+
_this2.setState({
|
|
17702
|
+
pickerVisible: false
|
|
17703
|
+
});
|
|
17704
|
+
},
|
|
17705
|
+
onClose: function onClose() {
|
|
17706
|
+
_this2.setState({
|
|
17707
|
+
pickerVisible: false
|
|
17708
|
+
});
|
|
17709
|
+
|
|
17710
|
+
if (_this2.props.onBlur) {
|
|
17711
|
+
_this2.props.onBlur();
|
|
17712
|
+
}
|
|
17713
|
+
}
|
|
17714
|
+
})]
|
|
17405
17715
|
});
|
|
17406
17716
|
} else {
|
|
17407
17717
|
return jsx(Select, {
|
|
@@ -22635,10 +22945,13 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
22635
22945
|
|
|
22636
22946
|
_this = _Viewer.call(this, p) || this;
|
|
22637
22947
|
_this._pickerRef = /*#__PURE__*/React.createRef();
|
|
22948
|
+
_this._startConfirmed = false; // 标记开始日期是否已确认,用于区分 onClose 是取消还是确认后的自动触发
|
|
22949
|
+
|
|
22638
22950
|
_this.state = {
|
|
22639
22951
|
ctrlVersion: 1,
|
|
22640
22952
|
noValidate: false,
|
|
22641
|
-
mobileDlg: false
|
|
22953
|
+
mobileDlg: false,
|
|
22954
|
+
mobileStep: 'start'
|
|
22642
22955
|
};
|
|
22643
22956
|
return _this;
|
|
22644
22957
|
}
|
|
@@ -22701,57 +23014,142 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
22701
23014
|
_this$getValue,
|
|
22702
23015
|
_this2 = this;
|
|
22703
23016
|
|
|
22704
|
-
|
|
23017
|
+
(_this$props$schema$pr = this.props.schema.props) != null ? _this$props$schema$pr : {};
|
|
22705
23018
|
|
|
22706
23019
|
var rangePickerData = this._data2rangePicker((_this$getValue = this.getValue()) != null ? _this$getValue : []);
|
|
22707
23020
|
|
|
22708
23021
|
if (MUtil.phoneLike()) {
|
|
22709
|
-
var _this$props$schema$da3;
|
|
23022
|
+
var _this$props$schema$da3, _this$props$schema$da4;
|
|
22710
23023
|
|
|
22711
|
-
var show = MDateRangeType.toReadableN(assembly, this.props.schema, _Viewer.prototype.getValue.call(this));
|
|
23024
|
+
var show = MDateRangeType.toReadableN(assembly, this.props.schema, _Viewer.prototype.getValue.call(this)); // 根据 precision 配置确定移动端 DatePicker 精度(使用扁平化属性 dateRangePrecision)
|
|
23025
|
+
|
|
23026
|
+
var mobilePrecision = this.props.schema.dateRangePrecision || 'day';
|
|
22712
23027
|
return jsxs(Fragment, {
|
|
22713
23028
|
children: [jsxs("div", {
|
|
22714
23029
|
className: "backfill",
|
|
22715
23030
|
onClick: function onClick() {
|
|
22716
23031
|
return _this2.setState({
|
|
22717
|
-
mobileDlg: true
|
|
23032
|
+
mobileDlg: true,
|
|
23033
|
+
mobileStep: 'start'
|
|
22718
23034
|
});
|
|
22719
23035
|
},
|
|
22720
23036
|
children: [" ", show != null ? show : '请点击选择', " "]
|
|
22721
|
-
}), jsx(
|
|
22722
|
-
visible: this.state.mobileDlg,
|
|
22723
|
-
|
|
22724
|
-
|
|
22725
|
-
|
|
22726
|
-
|
|
22727
|
-
|
|
22728
|
-
|
|
23037
|
+
}), jsx(DatePicker, {
|
|
23038
|
+
visible: this.state.mobileDlg && this.state.mobileStep === 'start',
|
|
23039
|
+
precision: mobilePrecision,
|
|
23040
|
+
title: "\u9009\u62E9\u5F00\u59CB\u65E5\u671F",
|
|
23041
|
+
min: this.props.schema.min ? new Date(this.props.schema.min) : undefined,
|
|
23042
|
+
max: this.props.schema.max ? new Date(this.props.schema.max) : undefined,
|
|
23043
|
+
onConfirm: function onConfirm(val) {
|
|
23044
|
+
_this2._startConfirmed = true;
|
|
23045
|
+
|
|
23046
|
+
_this2.setState({
|
|
23047
|
+
mobileStartDate: val,
|
|
23048
|
+
mobileStep: 'end'
|
|
22729
23049
|
});
|
|
22730
23050
|
},
|
|
22731
|
-
|
|
22732
|
-
|
|
23051
|
+
onClose: function onClose() {
|
|
23052
|
+
// antd-mobile v5 确认时会同时触发 onConfirm 和 onClose
|
|
23053
|
+
// 用实例变量同步判断:确认后的 onClose 应忽略,仅用户主动取消时才关闭
|
|
23054
|
+
if (_this2._startConfirmed) {
|
|
23055
|
+
_this2._startConfirmed = false;
|
|
23056
|
+
return;
|
|
23057
|
+
}
|
|
22733
23058
|
|
|
22734
23059
|
_this2.setState({
|
|
22735
23060
|
mobileDlg: false
|
|
22736
23061
|
});
|
|
22737
23062
|
}
|
|
22738
|
-
},
|
|
23063
|
+
}, "start_" + mobilePrecision), jsx(DatePicker, {
|
|
23064
|
+
visible: this.state.mobileDlg && this.state.mobileStep === 'end',
|
|
23065
|
+
precision: mobilePrecision,
|
|
23066
|
+
title: // 如果允许"至今"且开始时间不在未来,在标题区域展示"至今"按钮
|
|
23067
|
+
!((_this$props$schema$da3 = this.props.schema.dateRange) != null && _this$props$schema$da3.hideTillNow) && !((_this$props$schema$da4 = this.props.schema.dateRange) != null && _this$props$schema$da4.showTime) && !(this.state.mobileStartDate && this.state.mobileStartDate > new Date()) ? jsxs("div", {
|
|
23068
|
+
style: {
|
|
23069
|
+
display: 'flex',
|
|
23070
|
+
alignItems: 'center',
|
|
23071
|
+
justifyContent: 'center',
|
|
23072
|
+
gap: 12
|
|
23073
|
+
},
|
|
23074
|
+
children: [jsx("span", {
|
|
23075
|
+
children: "\u9009\u62E9\u7ED3\u675F\u65E5\u671F"
|
|
23076
|
+
}), jsx(Button, {
|
|
23077
|
+
size: "small",
|
|
23078
|
+
type: "primary",
|
|
23079
|
+
onClick: function onClick() {
|
|
23080
|
+
var startDate = _this2.state.mobileStartDate;
|
|
23081
|
+
|
|
23082
|
+
if (startDate) {
|
|
23083
|
+
_Viewer.prototype.changeValueEx.call(_this2, _this2._rangePicker2Data([moment(startDate), moment()], true), true, true);
|
|
23084
|
+
}
|
|
23085
|
+
|
|
23086
|
+
_this2.setState({
|
|
23087
|
+
mobileDlg: false
|
|
23088
|
+
});
|
|
23089
|
+
},
|
|
23090
|
+
children: "\u81F3\u4ECA"
|
|
23091
|
+
})]
|
|
23092
|
+
}) : "选择结束日期",
|
|
23093
|
+
min: this.state.mobileStartDate || (this.props.schema.min ? new Date(this.props.schema.min) : undefined),
|
|
23094
|
+
max: this.props.schema.max ? new Date(this.props.schema.max) : undefined,
|
|
23095
|
+
onConfirm: function onConfirm(val) {
|
|
23096
|
+
var startDate = _this2.state.mobileStartDate;
|
|
23097
|
+
|
|
23098
|
+
if (startDate) {
|
|
23099
|
+
// 防御:结束日期不能早于开始日期
|
|
23100
|
+
var finalEnd = val < startDate ? startDate : val;
|
|
23101
|
+
|
|
23102
|
+
_Viewer.prototype.changeValueEx.call(_this2, _this2._rangePicker2Data([moment(startDate), moment(finalEnd)], false), true, true);
|
|
23103
|
+
}
|
|
23104
|
+
|
|
23105
|
+
_this2.setState({
|
|
23106
|
+
mobileDlg: false
|
|
23107
|
+
});
|
|
23108
|
+
},
|
|
23109
|
+
onClose: function onClose() {
|
|
23110
|
+
// 回退到第一步,让用户可以重新选择开始日期
|
|
23111
|
+
_this2.setState({
|
|
23112
|
+
mobileStep: 'start'
|
|
23113
|
+
});
|
|
23114
|
+
}
|
|
23115
|
+
}, "end_" + mobilePrecision)]
|
|
22739
23116
|
});
|
|
22740
23117
|
} else {
|
|
22741
|
-
var _this$props$schema$
|
|
23118
|
+
var _this$props$schema$da5, _this$props$schema$da6, _this$props$schema$da7;
|
|
23119
|
+
|
|
23120
|
+
// 根据 precision 配置确定 PC 端 picker 模式和 showTime(使用扁平化属性 dateRangePrecision)
|
|
23121
|
+
var precision = this.props.schema.dateRangePrecision;
|
|
23122
|
+
var pcShowTime = precision === 'minute' || ((_this$props$schema$da5 = this.props.schema.dateRange) == null ? void 0 : _this$props$schema$da5.showTime);
|
|
23123
|
+
var hideFooter = ((_this$props$schema$da6 = this.props.schema.dateRange) == null ? void 0 : _this$props$schema$da6.hideTillNow) || pcShowTime; // 动态构建额外属性,避免 showTime 和 picker 同时传入导致类型冲突
|
|
23124
|
+
|
|
23125
|
+
var extraProps = {};
|
|
23126
|
+
|
|
23127
|
+
if (precision === 'year') {
|
|
23128
|
+
extraProps.picker = 'year';
|
|
23129
|
+
} else if (precision === 'month') {
|
|
23130
|
+
extraProps.picker = 'month';
|
|
23131
|
+
} else if (pcShowTime) {
|
|
23132
|
+
extraProps.showTime = true;
|
|
23133
|
+
} // 构造元素
|
|
22742
23134
|
|
|
22743
|
-
|
|
22744
|
-
return jsx(DatePicker$1.RangePicker, {
|
|
23135
|
+
|
|
23136
|
+
return jsx(DatePicker$1.RangePicker, _objectSpread$8({
|
|
22745
23137
|
ref: this._pickerRef,
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
23138
|
+
renderExtraFooter: hideFooter ? undefined : function (mode) {
|
|
23139
|
+
var _this2$_onCalendarCha;
|
|
23140
|
+
|
|
23141
|
+
// 如果开始时间超过当前时间(未来时间),不展示"至今"按钮
|
|
23142
|
+
var startMoment = (_this2$_onCalendarCha = _this2._onCalendarChangeValue) == null ? void 0 : _this2$_onCalendarCha[0];
|
|
23143
|
+
|
|
23144
|
+
if (startMoment && startMoment.isAfter(moment())) {
|
|
23145
|
+
return null;
|
|
23146
|
+
}
|
|
23147
|
+
|
|
23148
|
+
return jsx("div", {
|
|
22750
23149
|
style: {
|
|
22751
23150
|
textAlign: "right"
|
|
22752
|
-
}
|
|
22753
|
-
|
|
22754
|
-
children: jsx(Button$2, {
|
|
23151
|
+
},
|
|
23152
|
+
children: jsx(Button, {
|
|
22755
23153
|
size: "small",
|
|
22756
23154
|
style: {
|
|
22757
23155
|
width: "100px",
|
|
@@ -22763,13 +23161,13 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
22763
23161
|
},
|
|
22764
23162
|
children: "\u81F3\u4ECA"
|
|
22765
23163
|
})
|
|
22766
|
-
})
|
|
23164
|
+
});
|
|
22767
23165
|
},
|
|
22768
23166
|
bordered: this.props.hideBorder ? false : true,
|
|
22769
23167
|
style: {
|
|
22770
|
-
|
|
23168
|
+
width: "300px"
|
|
22771
23169
|
},
|
|
22772
|
-
locale: zhCN,
|
|
23170
|
+
locale: zhCN$1,
|
|
22773
23171
|
defaultValue: rangePickerData,
|
|
22774
23172
|
onCalendarChange: function onCalendarChange(d) {
|
|
22775
23173
|
_this2._onCalendarChangeValue = d;
|
|
@@ -22777,7 +23175,7 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
22777
23175
|
onChange: function onChange(vv) {
|
|
22778
23176
|
_Viewer.prototype.changeValueEx.call(_this2, _this2._rangePicker2Data(vv, false), true, true);
|
|
22779
23177
|
}
|
|
22780
|
-
}, this.state.ctrlVersion);
|
|
23178
|
+
}, extraProps), this.state.ctrlVersion + "_" + ((_this$props$schema$da7 = this.props.schema.dateRangePrecision) != null ? _this$props$schema$da7 : 'day'));
|
|
22781
23179
|
}
|
|
22782
23180
|
};
|
|
22783
23181
|
|
|
@@ -23842,7 +24240,50 @@ var ACascadePicker = /*#__PURE__*/function (_BaseViewer) {
|
|
|
23842
24240
|
var p = (_this$props$schema$pr = this.props.schema.props) != null ? _this$props$schema$pr : {};
|
|
23843
24241
|
|
|
23844
24242
|
if (MUtil.phoneLike()) {
|
|
23845
|
-
|
|
24243
|
+
var _this$state;
|
|
24244
|
+
|
|
24245
|
+
return jsxs(Fragment, {
|
|
24246
|
+
children: [jsx("div", {
|
|
24247
|
+
className: "backfill",
|
|
24248
|
+
onClick: function onClick() {
|
|
24249
|
+
return _this.setState({
|
|
24250
|
+
cascadeVisible: true
|
|
24251
|
+
});
|
|
24252
|
+
},
|
|
24253
|
+
children: show.length > 0 ? show.map(function (item) {
|
|
24254
|
+
return item.label || item.value || item;
|
|
24255
|
+
}).join('-') : '请点击选择'
|
|
24256
|
+
}), jsx(CascadePicker, _objectSpread$4({
|
|
24257
|
+
options: candidate,
|
|
24258
|
+
value: show.map(function (item) {
|
|
24259
|
+
return item.value || item;
|
|
24260
|
+
}),
|
|
24261
|
+
visible: (_this$state = this.state) == null ? void 0 : _this$state.cascadeVisible,
|
|
24262
|
+
onConfirm: function onConfirm(v) {
|
|
24263
|
+
var vLabel = [];
|
|
24264
|
+
v.forEach(function (item) {
|
|
24265
|
+
candidate.forEach(function (dataItem) {
|
|
24266
|
+
var findItem = findById(dataItem, item, "label", "value", "children");
|
|
24267
|
+
|
|
24268
|
+
if (findItem !== -1) {
|
|
24269
|
+
vLabel.push(findItem);
|
|
24270
|
+
}
|
|
24271
|
+
});
|
|
24272
|
+
});
|
|
24273
|
+
|
|
24274
|
+
_BaseViewer.prototype.changeValue.call(_this, vLabel);
|
|
24275
|
+
|
|
24276
|
+
_this.setState({
|
|
24277
|
+
cascadeVisible: false
|
|
24278
|
+
});
|
|
24279
|
+
},
|
|
24280
|
+
onClose: function onClose() {
|
|
24281
|
+
_this.setState({
|
|
24282
|
+
cascadeVisible: false
|
|
24283
|
+
});
|
|
24284
|
+
}
|
|
24285
|
+
}, p))]
|
|
24286
|
+
});
|
|
23846
24287
|
} else {
|
|
23847
24288
|
return jsx(Cascader, _objectSpread$4({
|
|
23848
24289
|
options: candidate,
|
|
@@ -24490,9 +24931,11 @@ function ensureM3() {
|
|
|
24490
24931
|
}
|
|
24491
24932
|
|
|
24492
24933
|
init = true;
|
|
24934
|
+
moment.locale('zh-cn');
|
|
24493
24935
|
assembly.types = _.merge(assembly.types, {
|
|
24494
24936
|
enum: MEnumType,
|
|
24495
24937
|
gb2260: MGB2260Type,
|
|
24938
|
+
date: MDateTimeType,
|
|
24496
24939
|
datetime: MDateTimeType,
|
|
24497
24940
|
year: MDateTimeType,
|
|
24498
24941
|
yearMonth: MDateTimeType,
|
|
@@ -24558,6 +25001,7 @@ function ensureM3() {
|
|
|
24558
25001
|
editor: {
|
|
24559
25002
|
enum: "ASelector",
|
|
24560
25003
|
gb2260: "AGB2260",
|
|
25004
|
+
date: "ADatetimePicker",
|
|
24561
25005
|
datetime: "ADatetimePicker",
|
|
24562
25006
|
year: "ADatetimePicker",
|
|
24563
25007
|
yearMonth: "ADatetimePicker",
|
|
@@ -24586,6 +25030,7 @@ function ensureM3() {
|
|
|
24586
25030
|
readable: {
|
|
24587
25031
|
enum: "DivViewer",
|
|
24588
25032
|
gb2260: "DivViewer",
|
|
25033
|
+
date: "DivViewer",
|
|
24589
25034
|
datetime: "DivViewer",
|
|
24590
25035
|
year: "DivViewer",
|
|
24591
25036
|
yearMonth: "DivViewer",
|