vap1 0.2.5 → 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
  }
@@ -93,7 +93,7 @@ var antd_1 = require("antd");
93
93
  var BasicLayout = /** @class */ (function (_super) {
94
94
  __extends(BasicLayout, _super);
95
95
  function BasicLayout() {
96
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
96
+ var _this = _super !== null && _super.apply(this, arguments) || this;
97
97
  _this.state = { siders: [] };
98
98
  return _this;
99
99
  }
@@ -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.5","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"}
package/utils/Global.d.ts CHANGED
@@ -157,11 +157,24 @@ export type GlobalSetting = {
157
157
  * outside 模式时, input 区域的默认宽度
158
158
  */
159
159
  FIELD_IPNUT_WIDTH: number;
160
+ /**
161
+ * POP(从keyword中弹出) 模式时, label 区域的默认宽度
162
+ */
163
+ FIELD_LABEL_WIDTH_POP: number;
164
+ /**
165
+ * POP(从keyword中弹出) 模式时, input 区域的默认宽度
166
+ */
167
+ FIELD_IPNUT_WIDTH_POP: number;
160
168
  /**
161
169
  * keyword 模式时, 关键字搜索框的宽度
162
170
  * 说明: 非 outside 模式时 ,宽度 = label+input
163
171
  */
164
172
  FIELD_KEYWORD_WIDTH: number;
173
+ /**
174
+ * 通过关键字弹出时,按钮对齐方式
175
+ * left 为对齐左边输入框
176
+ */
177
+ POPUP_BUTTONS_POSITION: 'left' | 'center' | 'right';
165
178
  };
166
179
  GRID: {
167
180
  GUTTER: [number, number];
package/utils/Global.js CHANGED
@@ -68,10 +68,13 @@ var DEFAULT = {
68
68
  REVERSE: false, USE_MODAL: false, DISABLE_KEYWORD: false,
69
69
  FIELD_AWAYS_OUTSIDE: false,
70
70
  AWAYS_EXPAND: false,
71
- FIELD_IPNUT_WIDTH: 150,
72
71
  FIELD_LABEL_WIDTH: 80,
72
+ FIELD_IPNUT_WIDTH: 150,
73
+ FIELD_LABEL_WIDTH_POP: 96,
74
+ FIELD_IPNUT_WIDTH_POP: 220,
73
75
  FIELD_INSIDE_WIDTH: 200,
74
76
  FIELD_KEYWORD_WIDTH: 240,
77
+ POPUP_BUTTONS_POSITION: 'left',
75
78
  },
76
79
  TABLE: {
77
80
  SIZE: 'small',
@@ -2,7 +2,7 @@ import type { BaseOption, PlainObject } from '../basetype';
2
2
  /**
3
3
  * 阻止事件简单封装
4
4
  */
5
- export declare const stopEvent: (evt: any, callback?: any) => void;
5
+ export declare const stopEvent: (evt: any, callback?: () => void) => void;
6
6
  /**
7
7
  * 将一个参数对象转换为 url Pattern 形式
8
8
  */
@@ -39,4 +39,30 @@ export declare const getOptions: (items: BaseOption[]) => BaseOption[];
39
39
  * 等待一个方法返回 true
40
40
  */
41
41
  export declare const waitFor: (assert: () => boolean, delay?: number) => Promise<void>;
42
+ /**
43
+ * 提交一个表单
44
+ */
45
+ type SubmitFormOptions = {
46
+ /**
47
+ * 地址
48
+ */
49
+ url: string;
50
+ /**
51
+ * 表单提交方法,默认为 POST
52
+ */
53
+ method?: 'GET' | 'POST';
54
+ /**
55
+ * 提交 target 方式,如果是iframe 传iframename,默认为 _blank
56
+ */
57
+ target?: string;
58
+ /**
59
+ * 表单数据
60
+ */
61
+ formData: Record<string, string | number | boolean>;
62
+ /**
63
+ * 拼接在url上的数据
64
+ */
65
+ urlParam?: Record<string, string | number | boolean>;
66
+ };
67
+ export declare const submitForm: (options: SubmitFormOptions) => void;
42
68
  export {};
package/utils/PageUtil.js CHANGED
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.waitFor = exports.getOptions = exports.currentApp = exports.clearURL = exports.resolveURL = exports.hasRole = exports.IpToInt = exports.paramToUri = exports.stopEvent = void 0;
53
+ exports.submitForm = exports.waitFor = exports.getOptions = exports.currentApp = exports.clearURL = exports.resolveURL = exports.hasRole = exports.IpToInt = exports.paramToUri = exports.stopEvent = void 0;
54
54
  var lodash_1 = __importDefault(require("lodash"));
55
55
  var StringUtil_1 = require("./StringUtil");
56
56
  var _Support_1 = require("./_Support");
@@ -190,3 +190,26 @@ var waitFor = function (assert, delay) {
190
190
  });
191
191
  };
192
192
  exports.waitFor = waitFor;
193
+ var submitForm = function (options) {
194
+ var url = (0, exports.resolveURL)(options.url);
195
+ if (options.urlParam) {
196
+ url = (0, exports.paramToUri)(options.urlParam, url);
197
+ }
198
+ var form = document.createElement('form');
199
+ form.style.display = 'none';
200
+ form.action = url;
201
+ form.method = options.method || 'POST';
202
+ ;
203
+ form.target = options.target || '_blank';
204
+ lodash_1.default.keys(options.formData).map(function (field) {
205
+ var input = document.createElement('input');
206
+ input.setAttribute('type', 'hidden');
207
+ input.setAttribute('name', field);
208
+ input.setAttribute('value', options[field]);
209
+ form.appendChild(input);
210
+ });
211
+ document.body.append(form);
212
+ form.submit();
213
+ window.setTimeout(function () { return document.body.removeChild(form); }, 200);
214
+ };
215
+ exports.submitForm = submitForm;
@@ -1,4 +1,4 @@
1
- import { CONFIG } from './Global';
1
+ import type { PlainObject } from '../basetype';
2
2
  export declare const CACHE_URL: Set<string>;
3
3
  /**
4
4
  * 构造一个等待 Promise ,用于部分场景,如:
@@ -18,4 +18,4 @@ export interface Result {
18
18
  [props: string]: any;
19
19
  }
20
20
  export declare const filterNull: (param: any) => any;
21
- export declare const AOP_BEFORE: typeof CONFIG.AJAX.beforeSend;
21
+ export declare const AOP_BEFORE: (url: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", headers: HeadersInit, query: PlainObject) => [string, "GET" | "POST" | "PUT" | "DELETE" | "PATCH", HeadersInit, PlainObject];