vap1 0.6.6 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/components/Box/Box.d.ts +14 -2
  2. package/components/Box/Box.js +3 -3
  3. package/components/Lists/VList.js +2 -2
  4. package/components/Lists/components/SearchTool.d.ts +1 -1
  5. package/components/Lists/components/SearchTool.js +2 -2
  6. package/components/Lists/index.d.ts +2 -1
  7. package/components/SearchTool/SearchBand/hooks.js +1 -1
  8. package/components/SearchTool/SearchBand/type.d.ts +2 -2
  9. package/components/SearchTool/SearchBar/ActionButtons.d.ts +2 -2
  10. package/components/SearchTool/SearchBar/ByField.js +3 -3
  11. package/components/SearchTool/SearchBar/type.d.ts +8 -2
  12. package/components/Tables/ApiTable.d.ts +1 -1
  13. package/components/Tables/ApiTable.js +1 -1
  14. package/components/Tables/ApiTableModal.d.ts +1 -1
  15. package/components/Tables/ApiTableModal.js +1 -1
  16. package/components/Tables/Components/useTableContext.d.ts +1 -1
  17. package/components/Tables/Components/useTableContext.js +1 -4
  18. package/components/Tables/VTable.d.ts +1 -1
  19. package/components/Tables/VTable.js +8 -4
  20. package/components/Tables/index.d.ts +1 -1
  21. package/components/UForm/UForm.js +3 -3
  22. package/components/UForm/UFormModal.js +1 -1
  23. package/components/UForm/UInfoModal.js +1 -1
  24. package/components/UForm/_FormUtils.d.ts +1 -1
  25. package/components/UForm/_input.js +1 -1
  26. package/components/UForm/_register.d.ts +1 -1
  27. package/components/UForm/index.d.ts +9 -3
  28. package/components/_common/AutoComplete.d.ts +1 -1
  29. package/components/_common/AutoComplete.js +1 -1
  30. package/package.json +1 -1
  31. package/uform/panel/Propreties/Component/LinkAsyncFunction.js +1 -1
  32. package/uform/panel/Propreties/Component/ValidateAsyncFunction.js +1 -1
  33. package/uform/utils/Convert.js +1 -1
  34. package/utils/Renders/FileRender.d.ts +1 -1
  35. package/utils/Renders/FileRender.js +1 -1
  36. package/utils/VAP.d.ts +6 -1
  37. package/utils/VAP.js +27 -7
@@ -107,9 +107,15 @@ export type BoxProps = SearchTool & {
107
107
  */
108
108
  overflowAuto?: true;
109
109
  /**
110
- * 默认查询参数
110
+ * @deprecated
111
+ * 说明:在一些极端场景下编译,可能会有Bug,
112
+ * 统一使用 defaultParam 替代,后续版本会移除
111
113
  */
112
114
  default?: PlainObject;
115
+ /**
116
+ * 默认查询条件
117
+ */
118
+ defaultParam?: PlainObject;
113
119
  /**
114
120
  * 在部分皮肤下有效,强制不显示背景
115
121
  */
@@ -145,9 +151,15 @@ export declare const Box: React.ForwardRefExoticComponent<SearchTool & {
145
151
  */
146
152
  overflowAuto?: true;
147
153
  /**
148
- * 默认查询参数
154
+ * @deprecated
155
+ * 说明:在一些极端场景下编译,可能会有Bug,
156
+ * 统一使用 defaultParam 替代,后续版本会移除
149
157
  */
150
158
  default?: PlainObject;
159
+ /**
160
+ * 默认查询条件
161
+ */
162
+ defaultParam?: PlainObject;
151
163
  /**
152
164
  * 在部分皮肤下有效,强制不显示背景
153
165
  */
@@ -207,7 +207,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
207
207
  // const isFix = _.isBoolean(props.searchBand.fixMode) ? props.searchBand.fixMode : CONFIG.SEARCHBAND.FIX_MODE;
208
208
  // return <SearchBand
209
209
  // {...props.searchBand}
210
- // default={props.default}
210
+ // defaultParam={props.defaultParam || props.default}
211
211
  // className={HEIGHT_OMIT}
212
212
  // extraAction={null}
213
213
  // onSearch={(data) => {
@@ -217,7 +217,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
217
217
  // >{action}</SearchBand>
218
218
  // }
219
219
  if (hasBar) {
220
- return react_1.default.createElement(SearchBar_1.SearchBar, __assign({}, props.searchBar, { default: props.default, className: HEIGHT_OMIT, onExpand: function (isExpand) {
220
+ return react_1.default.createElement(SearchBar_1.SearchBar, __assign({}, props.searchBar, { defaultParam: props.defaultParam || props.default, className: HEIGHT_OMIT, onExpand: function (isExpand) {
221
221
  resize();
222
222
  if (lodash_1.default.isFunction(props.searchBar.onExpand)) {
223
223
  props.searchBar.onExpand(isExpand);
@@ -225,7 +225,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
225
225
  } }), action);
226
226
  }
227
227
  if (action) {
228
- return react_1.default.createElement(SearchBar_1.SearchBar, { onSearch: LOOP, default: props.default, className: HEIGHT_OMIT, onExpand: LOOP }, action);
228
+ return react_1.default.createElement(SearchBar_1.SearchBar, { onSearch: LOOP, defaultParam: props.defaultParam || props.default, className: HEIGHT_OMIT, onExpand: LOOP }, action);
229
229
  }
230
230
  return utils_1.Const.NONE;
231
231
  }, [props.actionBar, props.searchBar,
@@ -60,7 +60,7 @@ var VList = function (props) {
60
60
  var model = props.model;
61
61
  var app = (0, useApp_1.useApp)();
62
62
  var _a = (0, LayoutSwitcher_1.useListLayout)(props), layout = _a.layout, layouts = _a.layouts, setLayout = _a.setLayout;
63
- (0, react_1.useLayoutEffect)(function () { model.query(props.default || {}); }, []);
63
+ (0, react_1.useLayoutEffect)(function () { model.query(props.defaultParam || {}); }, []);
64
64
  var extraAction = (0, react_1.useMemo)(function () {
65
65
  if (layouts.length <= 1)
66
66
  return null;
@@ -85,7 +85,7 @@ var VList = function (props) {
85
85
  return classNames.join(' ');
86
86
  }, [props.className]);
87
87
  return react_1.default.createElement("div", { style: style, className: clazz },
88
- react_1.default.createElement(SearchTool_1.SearchTool, __assign({}, props, { onSearch: function (data) { return model.query(data, true); }, default: props.default, extraAction: extraAction, children: lodash_1.default.isEmpty(props.actionBar) ? undefined : (lodash_1.default.isArray(props.actionBar) ? react_1.default.createElement(ActionButtons_1.ActionButtons, { buttons: props.actionBar }) : props.actionBar) })),
88
+ react_1.default.createElement(SearchTool_1.SearchTool, __assign({}, props, { onSearch: function (data) { return model.query(data, true); }, defaultParam: props.defaultParam, extraAction: extraAction, children: lodash_1.default.isEmpty(props.actionBar) ? undefined : (lodash_1.default.isArray(props.actionBar) ? react_1.default.createElement(ActionButtons_1.ActionButtons, { buttons: props.actionBar }) : props.actionBar) })),
89
89
  react_1.default.createElement(BaseList_1.BaseList, __assign({}, props, { layout: layout, style: null, className: null, dataSource: model.list, loading: model.isQuerying })),
90
90
  props.pagination !== false && react_1.default.createElement(Upagination_1.UPagination, __assign({}, (0, Upagination_1.defaultPaginationProps)(props.pagination), { disabled: model.isQuerying, total: model.total, totalAcc: model.totalAcc, onChange: model.pageTo })));
91
91
  };
@@ -8,6 +8,6 @@ export type SearchToolProps = XOR<{
8
8
  }>;
9
9
  export declare const SearchTool: FC<PropsWithChildren<SearchToolProps & {
10
10
  onSearch: (data: PlainObject) => void;
11
- default?: any;
11
+ defaultParam?: any;
12
12
  extraAction?: ReactNode;
13
13
  }>>;
@@ -26,9 +26,9 @@ var SearchTool = function (props) {
26
26
  return react_1.default.createElement(SearchTool_1.SearchBar, { onSearch: function () { }, children: props.children });
27
27
  }
28
28
  if (props.searchBand)
29
- return react_1.default.createElement(SearchTool_1.SearchBand, __assign({}, props.searchBand, { default: props.default, onSearch: props.onSearch, children: props.children, extraAction: props.extraAction }));
29
+ return react_1.default.createElement(SearchTool_1.SearchBand, __assign({}, props.searchBand, { defaultParam: props.defaultParam, onSearch: props.onSearch, children: props.children, extraAction: props.extraAction }));
30
30
  if (props.searchBar)
31
- return react_1.default.createElement(SearchTool_1.SearchBar, __assign({}, props.searchBar, { default: props.default, onSearch: props.onSearch, children: props.children }));
31
+ return react_1.default.createElement(SearchTool_1.SearchBar, __assign({}, props.searchBar, { defaultParam: props.defaultParam, onSearch: props.onSearch, children: props.children }));
32
32
  return Const_1.NONE;
33
33
  };
34
34
  exports.SearchTool = SearchTool;
@@ -123,7 +123,8 @@ export type ListRenderDefine = {
123
123
  export type ListLayoutType = keyof ListRenderDefine;
124
124
  type CommonListProps = Pick<ListProps<PlainObject>, 'rowKey' | 'className' | 'style'> & ListRenderDefine & {
125
125
  defaultLayout?: ListLayoutType;
126
+ onLayoutChange?: (layout: ListLayoutType) => void;
126
127
  };
127
128
  export type BaseListProps = CommonListProps & Pick<ListProps<PlainObject>, 'dataSource' | 'loading'>;
128
- export type VListProps = CommonListProps & SearchToolProps & Pick<VTableProps, 'default' | 'model' | 'mode' | 'pagination' | 'actionBar'>;
129
+ export type VListProps = CommonListProps & SearchToolProps & Pick<VTableProps, 'defaultParam' | 'model' | 'mode' | 'pagination' | 'actionBar'>;
129
130
  export {};
@@ -129,7 +129,7 @@ var useTableColumns = function (props, labelWidth, data, fixMode) {
129
129
  }, [data]);
130
130
  };
131
131
  var useSearchBand = function (props, fixMode) {
132
- var _a = __read((0, react_1.useState)(props.default || {}), 2), state = _a[0], setState = _a[1];
132
+ var _a = __read((0, react_1.useState)(props.defaultParam || {}), 2), state = _a[0], setState = _a[1];
133
133
  var isFristMount = (0, hooks_1.useFirstMountState)();
134
134
  var labelWidth = (0, react_1.useMemo)(function () {
135
135
  if (lodash_1.default.isNumber(props.labelWidth))
@@ -44,8 +44,8 @@ export type SearchBandProps = {
44
44
  onSearch: (param: PlainObject) => void;
45
45
  /**
46
46
  * 默认参数
47
- */
48
- default?: PlainObject;
47
+ */
48
+ defaultParam?: PlainObject;
49
49
  /**
50
50
  * 如果为true, 则不会以Tag显示
51
51
  */
@@ -42,9 +42,9 @@ export type ActButton = {
42
42
  /**
43
43
  * 说明 : 最多支持2级子菜单,不能递归
44
44
  */
45
- children?: ActButton[];
45
+ children?: Array<ActButton>;
46
46
  };
47
47
  export declare const ActionButtons: FC<{
48
- buttons: (ActButton | null | false)[];
48
+ buttons: Array<ActButton | null | false>;
49
49
  size?: ButtonSize;
50
50
  }>;
@@ -75,15 +75,15 @@ var SearchField_1 = require("./SearchField");
75
75
  var _register_1 = require("./_register");
76
76
  exports.InnerSearchBarByField = (0, react_1.forwardRef)(function (props, ref) {
77
77
  var isAwaysExpand = utils_1.GLOBAL.CONFIG.SEARCHBAR.AWAYS_EXPAND || props.__innerExpand;
78
- var _a = __read((0, react_1.useState)(props.default || {}), 2), data = _a[0], setData = _a[1];
78
+ var _a = __read((0, react_1.useState)(props.defaultParam || props.default || {}), 2), data = _a[0], setData = _a[1];
79
79
  var _b = __read((0, react_1.useState)(isAwaysExpand), 2), isExpand = _b[0], _setIsExpand = _b[1];
80
80
  var clear = (0, react_1.useCallback)(function () { return setData(function (prev) {
81
81
  var data = {};
82
82
  lodash_1.default.keys(prev).map(function (item) {
83
83
  data[item] = null;
84
84
  });
85
- if (props.default) {
86
- return lodash_1.default.extend({}, data, props.default);
85
+ if (props.defaultParam || props.default) {
86
+ return lodash_1.default.extend({}, data, props.defaultParam || props.default);
87
87
  }
88
88
  return data;
89
89
  }); }, []);
@@ -48,9 +48,15 @@ export type SearchBarByFieldProps = {
48
48
  */
49
49
  onExpand?: (isShowMore: boolean) => void;
50
50
  /**
51
- * 默认参数
51
+ * @deprecated
52
+ * 说明:在一些极端场景下编译,可能会有Bug,
53
+ * 统一使用 defaultParam 替代,后续版本会移除
52
54
  */
53
- default?: any;
55
+ default?: PlainObject;
56
+ /**
57
+ * 默认参数
58
+ */
59
+ defaultParam?: PlainObject;
54
60
  /**
55
61
  * 用于单独使用时,不需要按钮的情况
56
62
  */
@@ -3,7 +3,7 @@ import type { BaseTableProps } from './index';
3
3
  import type { ApiModel } from '../../hooks/_list';
4
4
  import type { ApiOption } from '../../hooks/useApiBase';
5
5
  export type ApiTableProps = BaseTableProps & Pick<ApiOption, 'api' | 'aop' | 'tipDisabled' | 'tipField'>;
6
- export declare const ApiTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar"> & {
6
+ export declare const ApiTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar" | "defaultParam"> & {
7
7
  searchBar?: Omit<import("../SearchTool").SearchBarProps, "onChange" | "onSearch">;
8
8
  } & {
9
9
  columns: import("./index").TableCol[];
@@ -52,7 +52,7 @@ exports.ApiTable = (0, react_1.forwardRef)(function (props, ref) {
52
52
  var option = {
53
53
  api: props.api,
54
54
  rowKey: props.rowKey,
55
- param: props.default,
55
+ param: props.defaultParam || props.default || {},
56
56
  aop: props.aop,
57
57
  tipDisabled: props.tipDisabled,
58
58
  tipField: props.tipField,
@@ -3,7 +3,7 @@ import type { ModalProps } from '../_adapt/Modal';
3
3
  import type { ApiTableProps } from './ApiTable';
4
4
  import type { ApiModel } from '../../hooks/_list';
5
5
  export type ApiTableModalProps = ApiTableProps & ModalProps;
6
- export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar"> & {
6
+ export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar" | "defaultParam"> & {
7
7
  searchBar?: Omit<import("../SearchTool").SearchBarProps, "onChange" | "onSearch">;
8
8
  } & {
9
9
  columns: import(".").TableCol[];
@@ -71,7 +71,7 @@ var ApiTable_1 = require("./ApiTable");
71
71
  var utils_1 = require("../../utils");
72
72
  var API_TABLE_PROPERTIES = [
73
73
  'api', 'aop', 'tipDisabled', 'tipField',
74
- 'mode', 'columns', 'showIndex', 'rowKey', 'select', 'selectDisabled', 'actionBar', 'selectBar', 'searchBar', 'default', 'autoLoad'
74
+ 'mode', 'columns', 'showIndex', 'rowKey', 'select', 'selectDisabled', 'actionBar', 'selectBar', 'searchBar', 'default', 'defaultParam', 'autoLoad'
75
75
  ];
76
76
  exports.ApiTableModal = (0, react_1.forwardRef)(function (props, ref) {
77
77
  var modalProps = lodash_1.default.omit(props, API_TABLE_PROPERTIES);
@@ -11,6 +11,6 @@ type TableAction = {
11
11
  initObjects: (List: Array<any>) => void;
12
12
  reflushPage: (List: Array<any>) => void;
13
13
  };
14
- export declare const TableContextWrapper: FC<PropsWithChildren<Pick<VTableProps, 'default' | 'defaultSelectedKeys' | 'rowKey'>>>;
14
+ export declare const TableContextWrapper: FC<PropsWithChildren<Pick<VTableProps, 'defaultParam' | 'defaultSelectedKeys' | 'rowKey'>>>;
15
15
  export declare const useTableContext: () => TableContext & TableAction;
16
16
  export {};
@@ -73,14 +73,11 @@ var TableContextWrapper = function (props) {
73
73
  var DEFAULT = {
74
74
  selectedRowKeys: [],
75
75
  selectedObjects: [],
76
- param: {},
76
+ param: props.defaultParam || {},
77
77
  };
78
78
  if (lodash_1.default.isArray(props.defaultSelectedKeys)) {
79
79
  DEFAULT.selectedRowKeys = props.defaultSelectedKeys;
80
80
  }
81
- if (props.default) {
82
- DEFAULT.param = __assign({}, props.default);
83
- }
84
81
  return DEFAULT;
85
82
  }), 2), state = _a[0], setState = _a[1];
86
83
  var setSelection = (0, react_1.useCallback)(function (selectedRowKeys, selectedObjects) {
@@ -27,7 +27,7 @@ export type VTableProps = BaseTableProps & {
27
27
  */
28
28
  onSelectedChange?: (selectedRowKeys: Key[], selectedRows?: any[]) => void;
29
29
  };
30
- export declare const VTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<BoxProps, "default" | "mode" | "selectBar"> & {
30
+ export declare const VTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<BoxProps, "default" | "mode" | "selectBar" | "defaultParam"> & {
31
31
  searchBar?: Omit<import("../SearchTool").SearchBarProps, "onChange" | "onSearch">;
32
32
  } & {
33
33
  columns: import("./index").TableCol[];
@@ -128,7 +128,7 @@ var _VTable = (0, react_1.forwardRef)(function (props) {
128
128
  return;
129
129
  if (lodash_1.default.isFunction((_b = props.selectBar) === null || _b === void 0 ? void 0 : _b.onSelect)) {
130
130
  var param = (_a = props.selectBar).onSelect.apply(_a, __spreadArray([], __read(state.selected), false));
131
- query(__assign(__assign({}, props.default), param));
131
+ query(__assign(__assign({}, (props.defaultParam || props.default)), param));
132
132
  }
133
133
  }, [state.selected]);
134
134
  // 更新页数
@@ -162,7 +162,7 @@ var _VTable = (0, react_1.forwardRef)(function (props) {
162
162
  return;
163
163
  if (lodash_1.default.has(props.selectBar, 'config.mustSelect') && props.selectBar.config.mustSelect == true)
164
164
  return;
165
- query(props.default || {});
165
+ query(props.defaultParam || props.default || {});
166
166
  }, []);
167
167
  // 更新高度 table 需要把 head 排除设置滚动
168
168
  // useEffect(() => {
@@ -248,7 +248,7 @@ var VTableRoot = (0, react_1.forwardRef)(function (props, ref) {
248
248
  };
249
249
  }, [selectedRowKeys, param]);
250
250
  var boxBaseProps = (0, react_1.useMemo)(function () {
251
- var boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
251
+ var boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'defaultParam', 'mode']);
252
252
  if (props.actionBar) {
253
253
  if (lodash_1.default.isArray(props.actionBar)) {
254
254
  if (props.actionBar.length) {
@@ -316,7 +316,11 @@ var VTableRoot = (0, react_1.forwardRef)(function (props, ref) {
316
316
  });
317
317
  exports.VTable = (0, react_1.forwardRef)(function (props, ref) {
318
318
  var _a;
319
- var initValue = (0, react_1.useMemo)(function () { return lodash_1.default.pick(props, ['defaultSelectedKeys', 'default']); }, []);
319
+ var initValue = (0, react_1.useMemo)(function () {
320
+ var initProps = lodash_1.default.pick(props, ['defaultSelectedKeys', 'rowKey']);
321
+ initProps.defaultParam = props.defaultParam || props.default || {};
322
+ return initProps;
323
+ }, []);
320
324
  return react_1.default.createElement(useTableContext_1.TableContextWrapper, __assign({}, initValue, { rowKey: ((_a = props.model) === null || _a === void 0 ? void 0 : _a.rowKey) || props.rowKey || 'id' }),
321
325
  react_1.default.createElement(VTableRoot, __assign({}, props, { ref: ref })));
322
326
  });
@@ -22,7 +22,7 @@ type SearchToolProps = {
22
22
  * 所有VAP组装 Table 排除一些自定义属性
23
23
  */
24
24
  export type TableDefine = Omit<TableProps<PlainObject>, 'size' | 'columns' | 'dataSource' | 'bordered' | 'rowKey' | 'title' | 'loading' | 'onChange' | 'rowSelection' | 'getPopupContainer' | 'sortDirections' | 'showSorterTooltip' | 'internalHooks' | 'transformColumns' | 'internalRefs'>;
25
- export type BaseTableProps = TableDefine & Pick<BoxProps, 'mode' | 'selectBar' | 'default'> & SearchToolProps & {
25
+ export type BaseTableProps = TableDefine & Pick<BoxProps, 'mode' | 'selectBar' | 'defaultParam' | 'default'> & SearchToolProps & {
26
26
  /**
27
27
  * 列
28
28
  */
@@ -413,7 +413,7 @@ var getValue = function (multipleFields, values, initRef) {
413
413
  };
414
414
  var initValue = function (props) {
415
415
  var e_1, _a;
416
- var values = __assign(__assign({}, props.default), props.data);
416
+ var values = __assign(__assign({}, (props.defaultValue || props.default)), props.data);
417
417
  var _loop_1 = function (key) {
418
418
  var fields = key.split(',').map(lodash_1.default.trim);
419
419
  if (fields.length == 1) {
@@ -564,10 +564,10 @@ var _UForm = (0, react_1.forwardRef)(function (props, ref) {
564
564
  if (state.isGroup)
565
565
  clazz.push('c-form-group');
566
566
  return react_1.default.createElement(antd_1.Form
567
- // initialValues={props.default}
567
+ // initialValues={props.defaultValue || props.default}
568
568
  // size={props.size || GLOBAL.CONFIG.FORM.SIZE}
569
569
  , {
570
- // initialValues={props.default}
570
+ // initialValues={props.defaultValue || props.default}
571
571
  // size={props.size || GLOBAL.CONFIG.FORM.SIZE}
572
572
  className: clazz.join(' '), style: { width: state.width }, form: form },
573
573
  props.tip && react_1.default.createElement("div", { className: 'c-form-tip' }, props.tip),
@@ -93,7 +93,7 @@ var UForm_1 = require("./UForm");
93
93
  var utils_1 = require("../../utils");
94
94
  var _i18n_1 = require("../_i18n");
95
95
  var FormWrapper_1 = require("./FormWrapper");
96
- var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'size', 'width'];
96
+ var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'defaultValue', 'data', 'mode', 'size', 'width'];
97
97
  var UFormModal = function (props) {
98
98
  var ref = (0, react_1.useRef)(null);
99
99
  var modalProps = {
@@ -22,7 +22,7 @@ var utils_1 = require("../../utils");
22
22
  var UInfo_1 = require("./UInfo");
23
23
  var _i18n_1 = require("../_i18n");
24
24
  var FormWrapper_1 = require("./FormWrapper");
25
- var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'hideBorder', 'theme'];
25
+ var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'defaultValue', 'data', 'mode', 'hideBorder', 'theme'];
26
26
  var UInfoModal = function (props) {
27
27
  var param = lodash_1.default.omit(props, FORM_FIELDS);
28
28
  if (!lodash_1.default.has(props, 'title') && lodash_1.default.has(props, 'autoTitle')) {
@@ -1,5 +1,5 @@
1
1
  import type { UFormField } from './index';
2
2
  import type { BaseOption } from '../../basetype';
3
3
  import type { ValidationRule } from 'antd/es/form/Form';
4
- export declare const requireStatus: (field: UFormField, required: Map<string, boolean>, disabled: Set<string>, hiden: Set<string>) => [boolean, ValidationRule[]];
4
+ export declare const requireStatus: (field: UFormField, required: Map<string, boolean>, disabled: Set<string>, hiden: Set<string>) => [boolean, Array<ValidationRule>];
5
5
  export declare const getOptions: (items: BaseOption[], field: UFormField, data: any) => BaseOption[];
@@ -159,7 +159,7 @@ var builderApiTableSerletor = function (options, nameIdx) { return function (pro
159
159
  };
160
160
  return react_1.default.createElement(react_1.Fragment, null,
161
161
  values[0] != undefined ? react_1.default.createElement(Button_1.Button, __assign({}, params, { icon: 'select', onClick: function () { return setOpen(true); } }), getTip(values)) : react_1.default.createElement(Button_1.Button, __assign({}, params, { icon: 'select', onClick: function () { return setOpen(true); } }), (0, exports.getPlaceholder)(field, true)),
162
- react_1.default.createElement(Tables_1.ApiTableModal, __assign({ title: options.title, searchBar: options.searchBar, width: options.width || 720 }, field.config, { api: options.api, default: defaultParam, columns: __spreadArray(__spreadArray([], __read(options.columns), false), [
162
+ react_1.default.createElement(Tables_1.ApiTableModal, __assign({ title: options.title, searchBar: options.searchBar, width: options.width || 720 }, field.config, { api: options.api, defaultParam: defaultParam, columns: __spreadArray(__spreadArray([], __read(options.columns), false), [
163
163
  Tables_1.ApiTable.COL_OPERACTION({ render: function (data) { return react_1.default.createElement(Tables_1.ApiTable.ACTION, { title: "\u9009\u62E9", icon: "select", onClick: function () { return onSelect(data); } }); } })
164
164
  ], false), open: open, onCancel: function () { return setOpen(false); } })));
165
165
  }; };
@@ -69,7 +69,7 @@ export type FormFieldOptions = {
69
69
  * 校验规则
70
70
  * 支持传Rule, Rule数组,及一个方法,接收一个数组
71
71
  */
72
- rules?: ValidationRule | ValidationRule[] | ((field: UFormField) => ValidationRule | ValidationRule[]);
72
+ rules?: ValidationRule | Array<ValidationRule> | ((field: UFormField) => ValidationRule | Array<ValidationRule>);
73
73
  };
74
74
  export type FormField = FormFieldOptions & {
75
75
  component: FormFieldComponent;
@@ -172,12 +172,12 @@ export type UFormField = BaseItem & {
172
172
  /**
173
173
  * rules 用法: https://github.com/yiminghe/async-validator
174
174
  */
175
- rules?: ValidationRule[];
175
+ rules?: Array<ValidationRule>;
176
176
  /**
177
177
  * 字段联动,目前只支持 `text` `select` 类型,受影响的字段只能是具有 `options` 属性的类型
178
178
  *
179
179
  */
180
- link?: Link[];
180
+ link?: Array<Link>;
181
181
  /**
182
182
  * (试验中,暂不要使用)
183
183
  * 在复杂类型中使用时,可使用dataType定义类型
@@ -266,9 +266,15 @@ export type UFromProps = {
266
266
  */
267
267
  tip?: ReactNode;
268
268
  /**
269
- * 默认
269
+ * @deprecated
270
+ * 说明:在一些极端场景下编译,可能会有Bug,
271
+ * 统一使用 defaultValue 替代,后续版本会移除
270
272
  */
271
273
  default?: PlainObject;
274
+ /**
275
+ * 默认值
276
+ */
277
+ defaultValue?: PlainObject;
272
278
  /**
273
279
  * 数据
274
280
  */
@@ -23,7 +23,7 @@ export interface IAutoCompleteProps extends Omit<AutoCompleteProps, 'onChange'>
23
23
  /**
24
24
  * 接口默认参数
25
25
  */
26
- default?: any;
26
+ defaultParam?: any;
27
27
  onChange?: (value: any, option: any) => void;
28
28
  }
29
29
  /**
@@ -141,7 +141,7 @@ var IAutoComplete = function (props) {
141
141
  setOptions(cacheRef.current.get(text));
142
142
  return [2 /*return*/];
143
143
  }
144
- param = lodash_1.default.merge({ start_: 0, count_: 15 }, props.default);
144
+ param = lodash_1.default.merge({ start_: 0, count_: 15 }, props.defaultParam);
145
145
  if (text) {
146
146
  param[paramField] = text;
147
147
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.6.6","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.6.8","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
@@ -102,7 +102,7 @@ var LinkAsyncFunction = function (props) {
102
102
  react_1.default.createElement("b", null, "dayjs")),
103
103
  react_1.default.createElement("li", { style: { listStyle: 'none' } },
104
104
  "\u65B9\u6CD5\u8FD4\u56DE\u6253\u5370 \uFF1A",
105
- react_1.default.createElement("b", null, "print"))) }), title: props.isEdit ? '编辑联动方法' : '添加联动方法', default: { method: 'GET', url: '/api/${value}' }, fields: [
105
+ react_1.default.createElement("b", null, "print"))) }), title: props.isEdit ? '编辑联动方法' : '添加联动方法', defaultValue: { method: 'GET', url: '/api/${value}' }, fields: [
106
106
  { field: 'field', title: '被联动字段', required: true, options: targetOptions, type: 'select' },
107
107
  {
108
108
  field: 'url,method', title: '请求',
@@ -64,7 +64,7 @@ var ValidateAsyncFunction = function (props) { return react_1.default.createElem
64
64
  "\u652F\u6301 lodash \u53D8\u91CF\u540D \uFF1A",
65
65
  react_1.default.createElement("b", null, "_")),
66
66
  react_1.default.createElement("li", { style: { listStyle: 'none' } },
67
- react_1.default.createElement(index_1.Alert, { type: "error", message: "\u8BF4\u660E2\uFF1A\u5F02\u6B65\u9A8C\u8BC1\u4EC5\u652F\u6301 VAP2, \u6682\u4E0D\u652F\u6301 VAP1" }))) }), title: props.isEdit ? '编辑校验方法' : '添加校验方法', default: { method: 'GET', url: '/api/${value}' }, fields: [
67
+ react_1.default.createElement(index_1.Alert, { type: "error", message: "\u8BF4\u660E2\uFF1A\u5F02\u6B65\u9A8C\u8BC1\u4EC5\u652F\u6301 VAP2, \u6682\u4E0D\u652F\u6301 VAP1" }))) }), title: props.isEdit ? '编辑校验方法' : '添加校验方法', defaultValue: { method: 'GET', url: '/api/${value}' }, fields: [
68
68
  {
69
69
  field: 'url,method', title: '请求',
70
70
  type: 'input-with-select',
@@ -311,7 +311,7 @@ var schemaToForm = function (schema) {
311
311
  if (schema.size)
312
312
  uformProps.size = schema.size;
313
313
  if (lodash_1.default.keys(defaultValue).length > 0)
314
- uformProps.default = defaultValue;
314
+ uformProps.defaultValue = defaultValue;
315
315
  return uformProps;
316
316
  };
317
317
  exports.schemaToForm = schemaToForm;
@@ -5,7 +5,7 @@ type ImgRenderOptions = {
5
5
  style?: CSSProperties;
6
6
  width?: number;
7
7
  height?: number;
8
- default?: string;
8
+ defaultValue?: string;
9
9
  };
10
10
  export declare const ImgRender: (option?: ImgRenderOptions) => (link: string) => React.JSX.Element;
11
11
  export declare const imgRender: (link: string) => React.JSX.Element;
@@ -98,7 +98,7 @@ var ImgRender = function (option) {
98
98
  style.height = 80;
99
99
  style.width = 80;
100
100
  }
101
- var defaultValue = (option === null || option === void 0 ? void 0 : option.default) || null;
101
+ var defaultValue = (option === null || option === void 0 ? void 0 : option.defaultValue) || null;
102
102
  if (lodash_1.default.has(option, 'style')) {
103
103
  style = __assign(__assign({}, style), option.style);
104
104
  }
package/utils/VAP.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ type VapLoadFn = () => void;
1
2
  /**
2
3
  * VAP 是系统配置工具类,用于读取 xxx_conf 表的配置
3
4
  */
@@ -32,11 +33,15 @@ export type VAP = {
32
33
  * 获取浮点数配置
33
34
  */
34
35
  getFloat: (key: string, defaultValue?: number) => number;
36
+ /**
37
+ * 初始化后调用方式
38
+ */
39
+ ready: (fn: VapLoadFn) => void;
35
40
  };
36
41
  declare const _VAP: VAP;
37
42
  export declare const _SET: (key: string, text: string) => void;
38
43
  /**
39
44
  * 初始化,仅在入口脚本里面使用
40
45
  */
41
- export declare const _INIT: (confs: Record<string, string>[]) => void[];
46
+ export declare const _INIT: (confs: Record<string, string>[]) => void;
42
47
  export default _VAP;
package/utils/VAP.js CHANGED
@@ -45,8 +45,18 @@ var _Support_1 = require("./_Support");
45
45
  var Ajax_1 = require("./Ajax");
46
46
  var Global_1 = require("./Global");
47
47
  var StringUtil_1 = require("./StringUtil");
48
+ var _VAP_LOAD_FN = (0, _Support_1.globalDefault)('_VAP_LOAD_FN', { loaded: false, fns: [] });
48
49
  var defaultVAP = function () {
49
50
  return {
51
+ // loaded:false,
52
+ ready: function (fn) {
53
+ if (_VAP_LOAD_FN.loaded) {
54
+ fn();
55
+ }
56
+ else {
57
+ _VAP_LOAD_FN.fns.push(fn);
58
+ }
59
+ },
50
60
  KEYMAP: new Map(),
51
61
  system_version: '',
52
62
  has: function (key) { return _VAP.KEYMAP.has(key); },
@@ -96,13 +106,23 @@ exports._SET = _SET;
96
106
  /**
97
107
  * 初始化,仅在入口脚本里面使用
98
108
  */
99
- var _INIT = function (confs) { return (confs || []).map(function (item) {
100
- var value = lodash_1.default.trim(item.confValue);
101
- if (value)
102
- _VAP.KEYMAP.set(item.confId, value);
103
- if (item.confId == 'system_version') {
104
- _VAP.system_version = value;
109
+ var _INIT = function (confs) {
110
+ (confs || []).map(function (item) {
111
+ var value = lodash_1.default.trim(item.confValue);
112
+ if (value)
113
+ _VAP.KEYMAP.set(item.confId, value);
114
+ if (item.confId == 'system_version') {
115
+ _VAP.system_version = value;
116
+ }
117
+ });
118
+ _VAP_LOAD_FN.loaded = true;
119
+ // console.log('load', _VAP_LOAD_FN.fns)
120
+ while (_VAP_LOAD_FN.fns.length > 0) {
121
+ var fn = _VAP_LOAD_FN.fns.shift();
122
+ if (typeof fn == 'function') {
123
+ fn();
124
+ }
105
125
  }
106
- }); };
126
+ };
107
127
  exports._INIT = _INIT;
108
128
  exports.default = _VAP;