vap1 0.1.9 → 0.2.0

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.
@@ -64,7 +64,7 @@ const ActionButton = (props) => {
64
64
  if (props.danger)
65
65
  btnParam.danger = true;
66
66
  if (props.confirm && props.disabled !== true) {
67
- return react_1.default.createElement(Popconfirm_1.Popconfirm, { trigger: "click", placement: "bottomLeft", onConfirm: props.onClick, title: lodash_1.default.isString(props.confirm) ? props.confirm : props.confirm() },
67
+ return react_1.default.createElement(Popconfirm_1.Popconfirm, { key: Math.floor(lodash_1.default.random() * 1000000) + '', trigger: "click", placement: "bottomLeft", onConfirm: props.onClick, title: lodash_1.default.isString(props.confirm) ? props.confirm : props.confirm() },
68
68
  react_1.default.createElement(Button_1.Button, Object.assign({}, props.config, btnParam), props.label));
69
69
  }
70
70
  btnParam.onClick = (evt) => utils_1.PageUtil.stopEvent(evt, props.onClick);
@@ -48,24 +48,27 @@ const ActionBar = props => {
48
48
  update();
49
49
  };
50
50
  }, []);
51
- let buttons = [];
52
51
  const [selectedRowKeys, selectedObjects] = props.selectedRef.current.selected;
53
- (props.buttons || []).map(btn => {
54
- if (btn === false)
55
- return;
56
- if (btn === null) {
57
- buttons.push(null);
58
- return;
59
- }
60
- let sub = convertButton(btn, selectedRowKeys, selectedObjects, props.queryParam);
61
- if (lodash_1.default.isArray(btn.children) && btn.children.length > 0) {
62
- sub.children = [];
63
- btn.children.map(item => {
64
- sub.children.push(convertButton(item, selectedRowKeys, selectedObjects, props.queryParam));
65
- });
66
- }
67
- buttons.push(sub);
68
- });
52
+ const buttons = (0, react_1.useMemo)(() => {
53
+ const btns = [];
54
+ (props.buttons || []).map(btn => {
55
+ if (btn === false)
56
+ return;
57
+ if (btn === null) {
58
+ btns.push(null);
59
+ return;
60
+ }
61
+ let sub = convertButton(btn, selectedRowKeys, selectedObjects, props.queryParam);
62
+ if (lodash_1.default.isArray(btn.children) && btn.children.length > 0) {
63
+ sub.children = [];
64
+ btn.children.map(item => {
65
+ sub.children.push(convertButton(item, selectedRowKeys, selectedObjects, props.queryParam));
66
+ });
67
+ }
68
+ btns.push(sub);
69
+ });
70
+ return btns;
71
+ }, [selectedRowKeys, props.buttons, props.queryParam]);
69
72
  return react_1.default.createElement(ActionButtons_1.ActionButtons, { buttons: buttons });
70
73
  };
71
74
  exports.ActionBar = ActionBar;
@@ -3,10 +3,10 @@ import { ListInit } from '../../hooks/_list';
3
3
  import type { BaseTableProps } from './index';
4
4
  export type STableProps = BaseTableProps & ListInit & {
5
5
  /**
6
- * ˵�� pageSize : Ĭ��Ϊ false �� ����ҳ��
6
+ * 说明 pageSize : 默认为 false 不分页。
7
7
  *
8
- * Ϊ true ʱ����ϵͳĬ�Ϸ�ҳ�����з�ҳ
9
- * Ϊ ���� ʱ�� ��ָ���ķ�ҳ��С���з�ҳ
8
+ * true 时,以系统默认分页数进行分页
9
+ * 数字 时, 以指定的分页大小进行分页
10
10
  */
11
11
  pageSize?: true | number;
12
12
  };
@@ -201,7 +201,6 @@ const _VTable = (0, react_1.forwardRef)((props, ref) => {
201
201
  } }));
202
202
  });
203
203
  exports.VTable = (0, react_1.forwardRef)((props, ref) => {
204
- var _a;
205
204
  const { isQuerying, pageNo, pageSize, total, totalAcc, param, pageTo, query, cost } = props.model;
206
205
  // 通过 ref 方式交互,后续扩展方法实现定制联页选择
207
206
  const selectedRef = (0, react_1.useRef)({ selected: [[], []], onSelected: () => { }, });
@@ -215,7 +214,7 @@ exports.VTable = (0, react_1.forwardRef)((props, ref) => {
215
214
  return props.model.param;
216
215
  }
217
216
  };
218
- }, [(_a = props.model) === null || _a === void 0 ? void 0 : _a.param]);
217
+ }, [param]);
219
218
  let boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
220
219
  if (props.searchBar) {
221
220
  boxProps.searchBar = Object.assign(Object.assign({}, props.searchBar), { disabled: isQuerying, onSearch: (data) => {
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.1.9","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.0","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
@@ -19,5 +19,8 @@ interface DictRender extends Render {
19
19
  options: (config?: OptionConvertConfig) => BaseOption[];
20
20
  }
21
21
  export declare const DictRender: (options: string | DictRenderOptions) => DictRender;
22
+ /**
23
+ * 初始化字典,将字典接口的响应数组传入
24
+ */
22
25
  export declare const initDict: (dict: PlainObject[]) => void;
23
26
  export { _V_DICT as DICT };
@@ -166,22 +166,6 @@ const _DictRender = (props) => {
166
166
  return props.default || Const_2.NONE;
167
167
  return renderDictValue(dictInfo, dictInfo.nodes[idx]);
168
168
  };
169
- // if (config.valueFormat) {
170
- // switch (config.valueFormat) {
171
- // case 'string':
172
- // format = val => val + '';
173
- // break;
174
- // case 'number':
175
- // format = val => {
176
- // if (_.isNumber(val)) return val;
177
- // try {
178
- // return parseInt(val);
179
- // } catch {
180
- // return val;
181
- // }
182
- // }
183
- // }
184
- // }
185
169
  const putOptions = (arr, config) => {
186
170
  if (config === undefined)
187
171
  return arr;
@@ -221,14 +205,14 @@ const DictRender = (options) => {
221
205
  };
222
206
  fn.getText = (key, def) => {
223
207
  if (key === null)
224
- return def || '';
208
+ return lodash_1.default.isString(def) ? def : '';
225
209
  const dictInfo = DICT.get(props.dictType);
226
210
  if (dictInfo == null)
227
- return def || '';
211
+ return lodash_1.default.isString(def) ? def : '';
228
212
  const dictKey = key + '';
229
213
  let idx = lodash_1.default.findIndex(dictInfo.nodes, (item) => dictKey == item.value);
230
214
  if (idx < 0)
231
- return def || '';
215
+ return lodash_1.default.isString(def) ? def : '';
232
216
  return dictInfo.nodes[idx].label;
233
217
  };
234
218
  if (lodash_1.default.isString(options))
@@ -236,22 +220,30 @@ const DictRender = (options) => {
236
220
  return fn;
237
221
  };
238
222
  exports.DictRender = DictRender;
239
- // TODO ,目前结构只支持两层,多层等做
223
+ const initNodes = (parentType, dict, nodes) => {
224
+ let childs = lodash_1.default.filter(dict, item => item.parentType == parentType);
225
+ childs.map(item => {
226
+ let value = lodash_1.default.trim(item.code);
227
+ if (value.length > 0)
228
+ nodes.push({ label: item.codeValue, value });
229
+ let subChildren = lodash_1.default.filter(dict, sub => sub.parentType == item.type);
230
+ if (subChildren.length > 0) {
231
+ initNodes(item.type, dict, nodes);
232
+ }
233
+ });
234
+ };
235
+ /**
236
+ * 初始化字典,将字典接口的响应数组传入
237
+ */
240
238
  const initDict = (dict) => {
241
239
  const roots = lodash_1.default.filter(dict, item => item['parentType'] == '0' || item['parentType'] == '');
242
240
  _V_DICT.DICTS = [];
243
241
  roots.map(root => {
244
- let info = { code: root.type, nodes: [], };
245
- if (root.format && VALIDATE_FORMAT.has(root.format)) {
246
- info.format = root.format;
247
- }
242
+ const info = { code: root.type, nodes: [] };
248
243
  _V_DICT.DICTS.push({ label: root.codeValue, value: root.type });
249
- let childs = lodash_1.default.filter(dict, item => item.parentType == root.type);
250
- childs.map(item => {
251
- let value = lodash_1.default.trim(item.code);
252
- if (value.length > 0)
253
- info.nodes.push({ label: item.codeValue, value });
254
- });
244
+ if (root.format && VALIDATE_FORMAT.has(root.format))
245
+ info.format = root.format;
246
+ initNodes(root.type, dict, info.nodes);
255
247
  DICT.set(root.type, info);
256
248
  });
257
249
  };