vap1 0.2.4 → 0.2.6

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.
@@ -160,10 +160,6 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
160
160
  (0, react_1.useLayoutEffect)(function () {
161
161
  setTimeout(resize, 5);
162
162
  }, []);
163
- var paginationProps = {};
164
- // if (props.pagination && props.mode == 'inner') {
165
- // paginationProps.hideOnSinglePage = true;
166
- // }
167
163
  return react_1.default.createElement(Layout_1.Layout, { id: domId, className: utils_1.StringUtil.className(className, props.className), style: style, ref: _layoutRef },
168
164
  props.selectBar && (0, _register_1.getSelectBar)(props.selectBar.type) != null && react_1.default.createElement(SelectBar_1.SelectBar, __assign({}, props.selectBar, { ref: selectRef, onSelect: function () {
169
165
  var args = [];
@@ -195,5 +191,5 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
195
191
  } }), props.actionBar ? (lodash_1.default.isArray(props.actionBar) ? react_1.default.createElement(SearchBar_1.SearchBar.ActionButtons, { buttons: props.actionBar }) : props.actionBar) : []),
196
192
  react_1.default.createElement(BoxContext.Provider, { value: { state: state, resize: resize, root: contextRef, selectRef: selectRef } },
197
193
  react_1.default.createElement("div", { className: 'ubox-content', ref: contextRef }, state != null && props.children)),
198
- props.pagination && react_1.default.createElement(Upagination_1.UPagination, __assign({}, paginationProps, props.pagination, { className: HEIGHT_OMIT }))));
194
+ props.pagination && react_1.default.createElement(Upagination_1.UPagination, __assign({}, props.pagination, { className: HEIGHT_OMIT }))));
199
195
  });
@@ -1,3 +1,22 @@
1
1
  import React from 'react';
2
2
  import type { SearchBarByFieldProps } from './index';
3
+ /**
4
+ * 仅内容使用
5
+ */
6
+ type InnerSearchBarByFieldProps = SearchBarByFieldProps & {
7
+ /**
8
+ * 强制展开
9
+ */
10
+ __innerExpand?: boolean;
11
+ /**
12
+ * 强制外展示
13
+ */
14
+ __innerOutside?: boolean;
15
+ /**
16
+ * 是否在Keyword中弹出
17
+ */
18
+ __innnerPopup?: boolean;
19
+ };
20
+ export declare const InnerSearchBarByField: React.FC<InnerSearchBarByFieldProps>;
3
21
  export declare const SearchBarByField: React.FC<SearchBarByFieldProps>;
22
+ export {};
@@ -53,35 +53,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
53
53
  return (mod && mod.__esModule) ? mod : { "default": mod };
54
54
  };
55
55
  Object.defineProperty(exports, "__esModule", { value: true });
56
- exports.SearchBarByField = void 0;
56
+ exports.SearchBarByField = exports.InnerSearchBarByField = void 0;
57
57
  var react_1 = __importStar(require("react"));
58
58
  var lodash_1 = __importDefault(require("lodash"));
59
59
  var antd_1 = require("antd");
60
60
  var Button_1 = require("../_adapt/Button");
61
61
  var Popover_1 = require("../_adapt/Popover");
62
- // import { Icon, } from '../_adapt/Icon';
63
62
  var utils_1 = require("../../utils");
64
63
  var Const_1 = require("../_setup/Const");
65
64
  var SearchField_1 = require("./SearchField");
66
65
  var _register_1 = require("./_register");
67
- var txt = utils_1.i18n.txt;
68
- var SearchBarByField = function (props) {
69
- // @ts-ignore
66
+ var InnerSearchBarByField = function (props) {
70
67
  var isAwaysExpand = utils_1.GLOBAL.CONFIG.SEARCHBAR.AWAYS_EXPAND || props.__innerExpand;
71
68
  var _a = __read((0, react_1.useState)(props.default || {}), 2), data = _a[0], setData = _a[1];
72
69
  var _b = __read((0, react_1.useState)(isAwaysExpand), 2), isExpand = _b[0], _setIsExpand = _b[1];
73
- var _c = __read((0, react_1.useState)(null), 2), layout = _c[0], setLayout = _c[1];
74
- // const warpData = (data) => {
75
- // let result: any = {};
76
- // _.keys(data).map(key => {
77
- // if (data[key] === null || data[key] === undefined) {
78
- // result[key] = ''
79
- // } else {
80
- // result[key] = data[key];
81
- // }
82
- // })
83
- // return result;
84
- // }
85
70
  var clear = function () { return setData(function (prev) {
86
71
  var data = {};
87
72
  lodash_1.default.keys(prev).map(function (item) {
@@ -98,67 +83,76 @@ var SearchBarByField = function (props) {
98
83
  setTimeout(function () { return props.onExpand(isExpand); }, 3);
99
84
  }
100
85
  };
101
- (0, react_1.useLayoutEffect)(function () {
102
- var layout = {
103
- rows: [],
104
- cols: 3,
105
- minWidth: 0,
106
- // @ts-ignore
107
- isOutSide: utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_AWAYS_OUTSIDE || props.__innerOutside,
108
- labelWidth: 0,
109
- inputWidth: 0,
110
- };
111
- if (props.fields == undefined || props.fields.length == 0) {
112
- setLayout(layout);
113
- return;
86
+ // 说明,默认以 3 列展示,弹框展示时,超过6个字段默认两列,小于6个字段默认1列
87
+ var cols = (0, react_1.useMemo)(function () {
88
+ if (props.cols)
89
+ return props.cols;
90
+ if (props.fields == undefined || !lodash_1.default.isArray(props.fields) || props.fields.length == 0)
91
+ return 3;
92
+ if (props.__innnerPopup) {
93
+ if (props.fields.length < 6)
94
+ return 1;
95
+ return 2;
114
96
  }
115
97
  ;
116
- if (lodash_1.default.has(props, 'cols'))
117
- layout.cols = props.cols;
118
- layout.rows.push([]);
98
+ return 3;
99
+ }, [props.fields]);
100
+ var layout = (0, react_1.useMemo)(function () {
101
+ if (props.fields == undefined || !lodash_1.default.isArray(props.fields) || props.fields.length == 0)
102
+ return null;
103
+ var rows = [];
104
+ var isOutSide = utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_AWAYS_OUTSIDE || props.__innerOutside;
105
+ rows.push([]); // 日前已使用
119
106
  var rowUse = 0;
120
107
  props.fields.map(function (field) {
121
108
  if (field.roleCode && !utils_1.PageUtil.hasRole(field.roleCode))
122
109
  return;
123
110
  var SearchField = (0, _register_1.getSearchField)(field.type);
124
111
  if (SearchField.outside)
125
- layout.isOutSide = true;
126
- field.span = field.span || SearchField.defaultSpan || 1;
112
+ isOutSide = true;
113
+ if (field.span) {
114
+ if (field.span > cols)
115
+ field.span = cols;
116
+ }
117
+ else {
118
+ field.span = SearchField.defaultSpan || 1;
119
+ }
127
120
  var tryfill = rowUse + field.span;
128
- if (tryfill > layout.cols) {
129
- layout.rows.push([{ field: field, SearchField: SearchField.component }]);
121
+ if (tryfill > cols) {
122
+ rows.push([{ field: field, SearchField: SearchField.component }]);
130
123
  rowUse = field.span;
131
124
  }
132
125
  else {
133
- layout.rows[layout.rows.length - 1].push({ field: field, SearchField: SearchField.component });
126
+ rows[rows.length - 1].push({ field: field, SearchField: SearchField.component });
134
127
  rowUse += field.span;
135
128
  }
136
129
  });
137
- if (layout.isOutSide) {
138
- if (lodash_1.default.isArray(props.fieldWidth)) {
139
- layout.labelWidth = props.fieldWidth[0];
140
- layout.inputWidth = props.fieldWidth[1];
141
- }
142
- else {
143
- layout.labelWidth = utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_LABEL_WIDTH;
144
- layout.inputWidth = utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_IPNUT_WIDTH;
145
- }
146
- }
147
- else if (lodash_1.default.has(props, 'fieldWidth')) {
148
- if (lodash_1.default.isNumber(props.fieldWidth)) {
149
- layout.inputWidth = props.fieldWidth;
150
- }
151
- else {
152
- layout.inputWidth = props.fieldWidth[0] + props.fieldWidth[1];
130
+ return { rows: rows, isOutSide: isOutSide };
131
+ }, [props.fields]);
132
+ var _c = __read((0, react_1.useMemo)(function () {
133
+ if (layout == null)
134
+ return [0, 0];
135
+ // 标签在内模式(placehoder表现)
136
+ if (!layout.isOutSide) {
137
+ if (lodash_1.default.has(props, 'fieldWidth')) {
138
+ if (lodash_1.default.isNumber(props.fieldWidth)) {
139
+ return [0, props.fieldWidth];
140
+ }
141
+ else {
142
+ return [0, props.fieldWidth[0] + props.fieldWidth[1]];
143
+ }
153
144
  }
145
+ return [0, utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_INSIDE_WIDTH];
154
146
  }
155
- else {
156
- layout.inputWidth = utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_INSIDE_WIDTH;
147
+ if (props.fieldWidth && lodash_1.default.isArray(props.fieldWidth))
148
+ return props.fieldWidth;
149
+ // 标签在外模式(label表现)
150
+ if (props.__innnerPopup) {
151
+ return [utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_LABEL_WIDTH_POP, utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_IPNUT_WIDTH_POP];
157
152
  }
158
- layout.minWidth = layout.rows[0].length * (layout.labelWidth + layout.inputWidth) + 90;
159
- setLayout(layout);
160
- }, [props.fields]);
161
- var rowRender = (0, react_1.useCallback)(function (rows, layout) { return rows.map(function (item) {
153
+ return [utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_LABEL_WIDTH, utils_1.GLOBAL.CONFIG.SEARCHBAR.FIELD_IPNUT_WIDTH];
154
+ }, [layout]), 2), labelWidth = _c[0], inputWidth = _c[1];
155
+ var rowRender = (0, react_1.useCallback)(function (rows) { return rows.map(function (item) {
162
156
  var field = __assign({}, item.field);
163
157
  var txt;
164
158
  txt = (item.field.ik && utils_1.i18n.hasKey(item.field.ik)) ? utils_1.i18n.txt(item.field.ik) : item.field.label;
@@ -168,35 +162,29 @@ var SearchBarByField = function (props) {
168
162
  field.placeholder = utils_1.i18n.txt(key) + txt;
169
163
  }
170
164
  var SearchInput = layout.isOutSide ? SearchField_1.InputOutSide : SearchField_1.InputInSide;
171
- return react_1.default.createElement(SearchInput, { key: item.field.field, disabled: props.disabled, labelWidth: layout.labelWidth, inputWidth: layout.inputWidth, field: field, SearchField: item.SearchField, onChange: function (value) {
165
+ return react_1.default.createElement(SearchInput, { key: item.field.field, disabled: props.disabled, labelWidth: labelWidth, inputWidth: inputWidth, field: field, SearchField: item.SearchField, onChange: function (value) { return setData(function (prev) {
172
166
  var _a, _b;
173
167
  var formData;
174
168
  if (lodash_1.default.isObject(value)) {
175
- formData = __assign(__assign({}, data), value);
169
+ formData = __assign(__assign({}, prev), value);
176
170
  }
177
171
  else if (lodash_1.default.isString(value)) {
178
172
  // let val = _.trim(value);
179
173
  // if (val.length == 0) {
180
174
  // formData = _.omit(data, item.field.field);
181
175
  // } else {
182
- formData = __assign(__assign({}, data), (_a = {}, _a[item.field.field] = value, _a));
176
+ formData = __assign(__assign({}, prev), (_a = {}, _a[item.field.field] = value, _a));
183
177
  // }
184
178
  }
185
179
  else {
186
- formData = __assign(__assign({}, data), (_b = {}, _b[item.field.field] = value, _b));
180
+ formData = __assign(__assign({}, prev), (_b = {}, _b[item.field.field] = value, _b));
187
181
  }
188
- // _.keys(formData).map(key => {
189
- // if (formData[key] === null || formData[key] === undefined) {
190
- // // _.unset(formData, key)
191
- // // formData[key] = undefined;
192
- // }
193
- // })
194
- setData(formData);
195
182
  if (lodash_1.default.isFunction(props.onChange)) {
196
183
  props.onChange(formData);
197
184
  }
198
- }, triggerSearch: function () { return props.onSearch(data); }, data: data });
199
- }); }, [data]);
185
+ return formData;
186
+ }); }, triggerSearch: function () { return props.onSearch(data); }, data: data });
187
+ }); }, [data, layout]);
200
188
  var btnRender = function (rowSize, isExpand) {
201
189
  if (props.hideAction || isExpand || isAwaysExpand)
202
190
  return utils_1.Const.NONE;
@@ -207,21 +195,44 @@ var SearchBarByField = function (props) {
207
195
  rowSize > 1 && utils_1.GLOBAL.CONFIG.SEARCHBAR.USE_MODAL && react_1.default.createElement(Popover_1.Popover, { content: "更多条件" },
208
196
  react_1.default.createElement(Button_1.Button, { disabled: props.disabled, icon: 'filter' })));
209
197
  };
198
+ var _d = __read((0, react_1.useMemo)(function () {
199
+ if (layout == null)
200
+ return ['', {}];
201
+ var clazz = ['c-searchbar-btns'];
202
+ var style = { marginLeft: layout.isOutSide ? labelWidth : 0 };
203
+ if (props.__innnerPopup) {
204
+ clazz.push('c-searchbar-btns-' + utils_1.GLOBAL.CONFIG.SEARCHBAR.POPUP_BUTTONS_POSITION);
205
+ if (utils_1.GLOBAL.CONFIG.SEARCHBAR.POPUP_BUTTONS_POSITION != 'left') {
206
+ lodash_1.default.unset(style, 'marginLeft');
207
+ }
208
+ }
209
+ return [clazz.join(' '), style];
210
+ }, [layout.isOutSide]), 2), btnsClass = _d[0], fristBtnStyle = _d[1];
210
211
  var moreRender = function (layout) { return [
211
- lodash_1.default.tail(layout.rows).map(function (row) { return layout.isOutSide ? react_1.default.createElement("div", { className: 'c-searchbar-outgroup' }, rowRender(row, layout)) : react_1.default.createElement(antd_1.Input.Group, { compact: true }, rowRender(row, layout)); }),
212
- props.hideAction ? utils_1.Const.NONE : react_1.default.createElement("div", { className: 'c-searchbar-btns' },
213
- react_1.default.createElement(Button_1.Button, { disabled: props.disabled, style: { marginLeft: layout.isOutSide ? layout.labelWidth : 0 }, icon: 'search', type: "primary", onClick: function (e) { return utils_1.PageUtil.stopEvent(e, search); } }, txt(Const_1.V.BTN_SEARCH)),
214
- react_1.default.createElement(Button_1.Button, { disabled: props.disabled, icon: 'redo', onClick: function (e) { return utils_1.PageUtil.stopEvent(e, clear); } }, txt(Const_1.V.BTN_RESET)),
215
- !isAwaysExpand && react_1.default.createElement(Button_1.Button, { disabled: props.disabled, icon: 'filter', onClick: function (e) { return utils_1.PageUtil.stopEvent(e, function () { return setIsExpand(false); }); } }, txt(Const_1.V.BTN_LESS)))
212
+ lodash_1.default.tail(layout.rows).map(function (row) { return layout.isOutSide ? react_1.default.createElement("div", { className: 'c-searchbar-outgroup' }, rowRender(row)) : react_1.default.createElement(antd_1.Input.Group, { compact: true }, rowRender(row)); }),
213
+ props.hideAction ? utils_1.Const.NONE : react_1.default.createElement("div", { className: btnsClass },
214
+ react_1.default.createElement(Button_1.Button, { disabled: props.disabled, style: fristBtnStyle, icon: 'search', type: "primary", onClick: function (e) { return utils_1.PageUtil.stopEvent(e, search); } }, utils_1.i18n.txt(Const_1.V.BTN_SEARCH)),
215
+ react_1.default.createElement(Button_1.Button, { disabled: props.disabled, icon: 'redo', onClick: function (e) { return utils_1.PageUtil.stopEvent(e, clear); } }, utils_1.i18n.txt(Const_1.V.BTN_RESET)),
216
+ !isAwaysExpand && react_1.default.createElement(Button_1.Button, { disabled: props.disabled, icon: 'filter', onClick: function (e) { return utils_1.PageUtil.stopEvent(e, function () { return setIsExpand(false); }); } }, utils_1.i18n.txt(Const_1.V.BTN_LESS)))
216
217
  ]; };
218
+ var fieldsStyle = (0, react_1.useMemo)(function () {
219
+ if (layout == null)
220
+ return {};
221
+ var width = cols * (labelWidth + inputWidth);
222
+ if (props.__innnerPopup)
223
+ return { width: width + 12 };
224
+ return { minWidth: width + 90 };
225
+ }, [layout.rows]);
217
226
  if (layout == null)
218
227
  return react_1.default.createElement("div", { className: 'c-searchbar-fields' });
219
- return react_1.default.createElement("div", { className: 'c-searchbar-fields', style: { minWidth: layout.minWidth } }, layout.rows.length && react_1.default.createElement(react_1.default.Fragment, null,
228
+ return react_1.default.createElement("div", { className: 'c-searchbar-fields', style: fieldsStyle }, layout.rows.length && react_1.default.createElement(react_1.default.Fragment, null,
220
229
  layout.isOutSide ? react_1.default.createElement("div", { className: "c-searchbar-outgroup c-searchbar-fixgroup" },
221
- rowRender(layout.rows[0], layout),
230
+ rowRender(layout.rows[0]),
222
231
  btnRender(layout.rows.length, isExpand)) : react_1.default.createElement(antd_1.Input.Group, { compact: true, className: "c-searchbar-fixgroup" },
223
- rowRender(layout.rows[0], layout),
232
+ rowRender(layout.rows[0]),
224
233
  btnRender(layout.rows.length, isExpand)),
225
234
  isExpand && moreRender(layout)));
226
235
  };
236
+ exports.InnerSearchBarByField = InnerSearchBarByField;
237
+ var SearchBarByField = function (props) { return react_1.default.createElement(exports.InnerSearchBarByField, __assign({}, props)); };
227
238
  exports.SearchBarByField = SearchBarByField;
@@ -60,28 +60,30 @@ var Const_1 = require("../_setup/Const");
60
60
  var SearchBarByKeyword = function (props) {
61
61
  var _a = __read((0, react_1.useState)(false), 2), open = _a[0], setOpen = _a[1];
62
62
  var spanRef = (0, react_1.useRef)(null);
63
- var inputProps = {
64
- className: "c-searchbar-keyword",
65
- placeholder: utils_1.i18n.txt(Const_1.V.INPUT_SEARCH_KEYWORD),
66
- allowClear: true,
67
- };
68
- if (props.keyword !== true) {
69
- if (props.keyword.placeholder) {
70
- inputProps.placeholder = props.keyword.placeholder;
63
+ var inputProps = (0, react_1.useMemo)(function () {
64
+ var searchProps = {
65
+ className: "c-searchbar-keyword",
66
+ placeholder: utils_1.i18n.txt(Const_1.V.INPUT_SEARCH_KEYWORD),
67
+ allowClear: true,
68
+ };
69
+ if (props.keyword !== true) {
70
+ if (props.keyword.placeholder) {
71
+ searchProps.placeholder = props.keyword.placeholder;
72
+ }
71
73
  }
72
- }
74
+ return searchProps;
75
+ }, []);
76
+ var suffixProps = {};
73
77
  if (props.fields && props.fields.length) {
74
- inputProps.suffix = react_1.default.createElement(react_1.default.Fragment, null,
78
+ suffixProps.suffix = react_1.default.createElement(react_1.default.Fragment, null,
75
79
  react_1.default.createElement("span", { ref: spanRef, onClick: function () { return setOpen(true); }, style: { pointerEvents: props.disabled ? 'none' : 'unset' }, className: 'vicon vicon-menu', title: utils_1.i18n.txt(Const_1.V.INPUT_SEARCH_ADVANCE) }, "\u00A0"),
76
80
  react_1.default.createElement(Popover_1.Popover, { open: open, onOpenChange: setOpen, trigger: "click", placement: "bottom", content: react_1.default.createElement(react_1.default.Fragment, null,
77
81
  react_1.default.createElement("h3", null, utils_1.i18n.txt(Const_1.V.INPUT_SEARCH_ADVANCE)),
78
82
  react_1.default.createElement("div", { className: 'c-searchbar' },
79
- react_1.default.createElement(ByField_1.SearchBarByField, __assign({}, props, { onSearch: function (param) {
83
+ react_1.default.createElement(ByField_1.InnerSearchBarByField, __assign({}, props, { __innerExpand: true, __innerOutside: true, __innnerPopup: true, onSearch: function (param) {
80
84
  props.onSearch(param);
81
85
  setOpen(false);
82
- },
83
- // @ts-ignore
84
- __innerExpand: true, __innerOutside: true })))), overlayClassName: 'c-searchbar-keyword-more', getPopupContainer: function () {
86
+ } })))), overlayClassName: 'c-searchbar-keyword-more', getPopupContainer: function () {
85
87
  var maskEls = document.getElementsByClassName('ant-modal-mask');
86
88
  var hasMask = false;
87
89
  for (var i = 0, _i = maskEls.length; i < _i; i++) {
@@ -95,6 +97,6 @@ var SearchBarByKeyword = function (props) {
95
97
  return spanRef.current.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
96
98
  } }));
97
99
  }
98
- return react_1.default.createElement(antd_1.Input.Search, __assign({}, inputProps, { onSearch: function (keyword) { return props.onSearch({ keyword_: keyword }); }, enterButton: utils_1.i18n.txt(Const_1.V.BTN_SEARCH) }));
100
+ return react_1.default.createElement(antd_1.Input.Search, __assign({}, inputProps, suffixProps, { onSearch: function (keyword) { return props.onSearch({ keyword_: keyword }); }, enterButton: utils_1.i18n.txt(Const_1.V.BTN_SEARCH) }));
99
101
  };
100
102
  exports.SearchBarByKeyword = SearchBarByKeyword;
@@ -64,10 +64,8 @@ export type Field = BaseItem & {
64
64
  config?: any;
65
65
  };
66
66
  /**
67
- *
68
- * 说明,内部两个属性,暂不开放,如需使用,自行处理编译问题
69
- * __innerExpand
70
- * __innerOutside
67
+ * 当没有指定 keyword时,SearchBar的配置参数
68
+ * 指字 keyword 时,将出以弹出方式展示
71
69
  */
72
70
  export type SearchBarByFieldProps = {
73
71
  /**
@@ -253,6 +253,8 @@ var _VTable = (0, react_1.forwardRef)(function (props, ref) {
253
253
  update();
254
254
  },
255
255
  getCheckboxProps: function (record) {
256
+ if (lodash_1.default.isFunction(props.selectDisabled))
257
+ return { disabled: props.selectDisabled(record) };
256
258
  if (!lodash_1.default.has(record, rowKey))
257
259
  return { disabled: true };
258
260
  return { disabled: false };
@@ -263,7 +265,7 @@ var _VTable = (0, react_1.forwardRef)(function (props, ref) {
263
265
  // scroll={scroll}
264
266
  // tableLayout="fixed"
265
267
  // showSorterTooltip={false}
266
- size: utils_1.GLOBAL.CONFIG.TABLE.SIZE, locale: { emptyText: react_1.default.createElement(antd_1.Empty, { style: { marginTop: 24 } }) } }, props, tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns, dataSource: list, loading: isQuerying, onChange: function (x, y, field) {
268
+ size: utils_1.GLOBAL.CONFIG.TABLE.SIZE, locale: { emptyText: react_1.default.createElement(antd_1.Empty, { style: { marginTop: 24 } }) } }, lodash_1.default.omit(props, ['children']), tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns, dataSource: list, loading: isQuerying, onChange: function (x, y, field) {
267
269
  if (field.column) {
268
270
  orderBy(field.field, field.order == 'ascend' ? 'asc' : 'desc');
269
271
  }
@@ -686,7 +686,7 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
686
686
  txt(Const_1.V.ACT_UPDATE),
687
687
  action.objectName,
688
688
  " : ",
689
- react_1.default.createElement("b", null, treeState.titleField)) : ADD_TITLE() }, modals.modalState.modalProps, { fields: FIELDS.current, default: getDefault(), onOk: function (data) {
689
+ react_1.default.createElement("b", null, modals.modalState.data[treeState.titleField])) : ADD_TITLE() }, modals.modalState.modalProps, { fields: FIELDS.current, default: getDefault(), onOk: function (data) {
690
690
  modals.hide();
691
691
  if (modals.modalState.isEdit) {
692
692
  update(data, modals.modalState.extra.position);
@@ -526,7 +526,8 @@ var _UForm = (0, react_1.forwardRef)(function (props, ref) {
526
526
  return;
527
527
  if (field.type) {
528
528
  var info = (0, _register_1.getUFormInput)(field.type);
529
- if (info.isMultiple && field.field.indexOf(',') > 0) {
529
+ // && field.field.indexOf(',') > 0
530
+ if (info.isMultiple) {
530
531
  state.multipleFields.current.add(field.field);
531
532
  }
532
533
  }
@@ -24,6 +24,7 @@ export type GroupType = 'default' | 'tabs' | 'collapse';
24
24
  export type LinkValue = string | number | boolean;
25
25
  import type { _FieldType } from './_FieldType';
26
26
  import type { SizeType } from '../_adapt/_Antd5';
27
+ import type { TableColumn } from '../Tables';
27
28
  /**
28
29
  * 联动结果 : 改变目标字段的交互属性
29
30
  * 所有属性为可选,需要改变几项属性,则只返回包含几个属性的对象,
@@ -193,6 +194,10 @@ export type UFormField = BaseItem & {
193
194
  * 回显方法
194
195
  */
195
196
  render?: (txt: any, obj?: any) => React.ReactNode;
197
+ /**
198
+ * 字段选项,适用于 `table` `json-table` 等
199
+ */
200
+ columns?: TableColumn[];
196
201
  };
197
202
  export type UFormFieldGroup = BaseItem & {
198
203
  /**
@@ -16,7 +16,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.UPagination = void 0;
18
18
  var react_1 = __importDefault(require("react"));
19
- var Pagination_1 = require("../_adapt/Pagination");
19
+ // import { Pagination } from '../_adapt/Pagination';
20
+ var antd_1 = require("antd");
20
21
  var utils_1 = require("../../utils");
21
22
  var i18n_1 = require("../../utils/i18n");
22
23
  var TXT = (0, i18n_1.fastRegister)({
@@ -112,6 +113,6 @@ var getConfig = function (total, totalAcc, cost) {
112
113
  };
113
114
  var UPagination = function (props) {
114
115
  var conf = getConfig(props.total, props.totalAcc, props.cost);
115
- return react_1.default.createElement(Pagination_1.Pagination, __assign({}, conf, props, { className: utils_1.StringUtil.className(['c-pagination', 'c-pagination-style' + (props.mode || utils_1.GLOBAL.CONFIG.PAGINATION.THEME || 1)], props.className) }));
116
+ return react_1.default.createElement(antd_1.Pagination, __assign({}, conf, props, { onShowSizeChange: props.onChange, className: utils_1.StringUtil.className(['c-pagination', 'c-pagination-style' + (props.mode || utils_1.GLOBAL.CONFIG.PAGINATION.THEME || 1)], props.className) }));
116
117
  };
117
118
  exports.UPagination = UPagination;
@@ -0,0 +1,9 @@
1
+ import type { GlobalSetting } from '../../utils/Global';
2
+ /**
3
+ * 将 PUT/PATCH/DELETE 请求转换为 POST
4
+ */
5
+ export declare const rewriteToPost: GlobalSetting['AJAX']['beforeSend'];
6
+ /**
7
+ * 自动识别 Mock 请求
8
+ */
9
+ export declare const autoMock: GlobalSetting['AJAX']['beforeSend'];
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.autoMock = exports.rewriteToPost = void 0;
7
+ var lodash_1 = __importDefault(require("lodash"));
8
+ /**
9
+ * 常用 Ajax 设置
10
+ */
11
+ var reUrl = function (url, method) {
12
+ if (url.indexOf('?') > 0) {
13
+ return url + '&_method=' + method;
14
+ }
15
+ return url + '?_method=' + method;
16
+ };
17
+ /**
18
+ * 将 PUT/PATCH/DELETE 请求转换为 POST
19
+ */
20
+ var rewriteToPost = function (url, method, header, param) {
21
+ var re_url = url;
22
+ var re_method = method;
23
+ var old_method = lodash_1.default.trim(lodash_1.default.toLower(method));
24
+ switch (old_method) {
25
+ case 'put':
26
+ case 'delete':
27
+ case 'patch':
28
+ re_url = reUrl(re_url, old_method);
29
+ re_method = 'POST';
30
+ break;
31
+ default:
32
+ break;
33
+ }
34
+ return [re_url, re_method, header, param];
35
+ };
36
+ exports.rewriteToPost = rewriteToPost;
37
+ /**
38
+ * 自动识别 Mock 请求
39
+ */
40
+ var autoMock = function (url, method, header, param) {
41
+ return [url, method, header, param];
42
+ };
43
+ exports.autoMock = autoMock;
package/index.js CHANGED
@@ -138,7 +138,7 @@ Object.defineProperty(exports, "ColorPicker", { enumerable: true, get: function
138
138
  // Enrich antd Components
139
139
  var Upagination_1 = require("./components/_common/Upagination"); // 增强版 Pagination
140
140
  Object.defineProperty(exports, "UPagination", { enumerable: true, get: function () { return Upagination_1.UPagination; } });
141
- // VAP Data Components
141
+ // VAP Data Components
142
142
  var UForm_1 = require("./components/UForm"); // UForm 系列
143
143
  Object.defineProperty(exports, "UForm", { enumerable: true, get: function () { return UForm_1.UForm; } });
144
144
  Object.defineProperty(exports, "UFormModal", { enumerable: true, get: function () { return UForm_1.UFormModal; } });
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.2.4","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.2.6","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
@@ -87,7 +87,7 @@ var FormEditor = function (props) {
87
87
  react_1.default.createElement(index_1.Button.Group, { style: { float: 'right', marginRight: 6, display: 'block' } },
88
88
  editor.form.isGroup && react_1.default.createElement(index_1.Button, { icon: "plus", onClick: function () { return editor.addGroup(); } }, "\u6DFB\u52A0\u5206\u7EC4"),
89
89
  react_1.default.createElement(index_1.Button, { icon: 'eye', type: "primary", onClick: function () {
90
- if (schema.fields && schema.fields.length > 1) {
90
+ if (editor.form.fields && editor.form.fields.length > 0) {
91
91
  setOpen(true);
92
92
  }
93
93
  else {
@@ -1,6 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import type { FormItem } from '../schema';
3
3
  import type { PlainObject } from '../../basetype';
4
+ export type CustomConfig = {
5
+ label: string;
6
+ key: string;
7
+ type: string;
8
+ defaultValue?: any;
9
+ options?: PlainObject;
10
+ };
4
11
  export type FormInput = {
5
12
  title: string;
6
13
  type: string;
@@ -13,6 +20,7 @@ export type FormInput = {
13
20
  defaultProperties?: PlainObject;
14
21
  defaultConfig?: PlainObject;
15
22
  defaultPlaceholder?: string;
23
+ customConfig?: CustomConfig[];
16
24
  };
17
25
  type FormGroup = {
18
26
  title: string;
@@ -10,17 +10,49 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
15
35
  };
16
36
  Object.defineProperty(exports, "__esModule", { value: true });
17
- var react_1 = __importDefault(require("react"));
37
+ var react_1 = __importStar(require("react"));
18
38
  var index_1 = require("../../../index");
39
+ var index_2 = require("../../../index");
19
40
  var plugins_1 = require("../../plugins");
20
41
  var FieldPlugin_1 = require("./Component/FieldPlugin");
21
42
  var OptionTable_1 = require("./Component/OptionTable");
43
+ var _register_1 = require("../../../components/UForm/_register");
22
44
  exports.default = (function (props) {
45
+ var _a, _b;
23
46
  var setFieldProperties = props.setFieldProperties, field = props.field, input = props.input, baseSpan = props.baseSpan;
47
+ var config = field.config || {};
48
+ var setConfig = function (key, value) {
49
+ config[key] = value;
50
+ setFieldProperties('config', config);
51
+ };
52
+ var renderCustomConfig = function (item) {
53
+ var element = (0, _register_1.getUFormInput)(item.type).component;
54
+ return (0, react_1.createElement)(element, __assign(__assign({}, item), { field: item.type, title: '' }));
55
+ };
24
56
  return react_1.default.createElement(react_1.default.Fragment, null,
25
57
  react_1.default.createElement(index_1.Form.Item, { label: "\u5B57\u6BB5\u540D", required: true },
26
58
  react_1.default.createElement(index_1.Input, { size: 'small', value: field.field, onChange: function (evt) { return setFieldProperties('field', evt.target.value); } })),
@@ -41,5 +73,13 @@ exports.default = (function (props) {
41
73
  input.fieldCount == null && react_1.default.createElement(index_1.Form.Item, { label: "\u9ED8\u8BA4\u503C" },
42
74
  react_1.default.createElement(index_1.Input, { size: 'small', placeholder: '\u8F93\u5165\u53D6\u503C', value: field._default, onChange: function (evt) { return setFieldProperties('_default', evt.target.value); } })),
43
75
  input.hasOption && react_1.default.createElement(OptionTable_1.OptionTable, __assign({}, props)),
76
+ ((_a = field.customConfig) === null || _a === void 0 ? void 0 : _a.length) > 0 && react_1.default.createElement(index_2.Divider, { orientation: "left" }, "\u81EA\u5B9A\u4E49\u5C5E\u6027"),
77
+ ((_b = field.customConfig) === null || _b === void 0 ? void 0 : _b.length) > 0 && field.customConfig.map(function (item) {
78
+ var value = config[item.key] || item.defaultValue || null;
79
+ var onChange = function (v) {
80
+ setConfig(item.key, v);
81
+ };
82
+ return react_1.default.createElement(index_1.Form.Item, { label: item.label }, renderCustomConfig(__assign(__assign({}, item), { value: value, onChange: onChange })));
83
+ }),
44
84
  react_1.default.createElement(FieldPlugin_1.FieldPlugin, __assign({}, props, { slot: plugins_1.PluginSlot.FIELD_BASE })));
45
85
  });