vap1 0.1.9 → 0.2.1

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.1","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
@@ -1,12 +1,12 @@
1
- import React from 'react';
2
1
  import type { FormSchema } from './schema';
3
- import type { UModalProps, PlainObject } from '../index';
2
+ import type { RefAttributes, ForwardRefExoticComponent, FC } from 'react';
3
+ import type { UModalProps, UFormRef, PlainObject } from '../index';
4
4
  type ModalProps = Pick<UModalProps, 'open' | 'onOk' | 'onCancel' | 'title' | 'data'>;
5
5
  type FormViewProps = {
6
6
  schema: FormSchema | string;
7
7
  data?: PlainObject;
8
8
  };
9
9
  export declare const initSchama: (data: string | FormSchema) => FormSchema;
10
- export declare const FormViewer: React.FC<FormViewProps>;
11
- export declare const FormModal: React.FC<FormViewProps & ModalProps>;
10
+ export declare const FormViewer: ForwardRefExoticComponent<FormViewProps & RefAttributes<UFormRef>>;
11
+ export declare const FormModal: FC<FormViewProps & ModalProps>;
12
12
  export {};
@@ -49,21 +49,20 @@ const initSchama = (data) => {
49
49
  return DEFAULT;
50
50
  };
51
51
  exports.initSchama = initSchama;
52
- const _FormRender = props => {
52
+ const _FormRender = (0, react_1.forwardRef)((props, ref) => {
53
53
  const uformProps = (0, react_1.useMemo)(() => (0, Convert_1.schemaToForm)(props.schema), [props]);
54
- return react_1.default.createElement(index_1.UForm, Object.assign({}, uformProps, { data: props.data }));
55
- };
54
+ return react_1.default.createElement(index_1.UForm, Object.assign({}, uformProps, { data: props.data, ref: ref }));
55
+ });
56
56
  const _ModalRender = props => {
57
57
  const uformProps = (0, react_1.useMemo)(() => (0, Convert_1.schemaToForm)(props.schema), [props]);
58
58
  let modalProps = {};
59
59
  modalProps.title = props.title || props.schema.title || '';
60
60
  return react_1.default.createElement(index_1.UFormModal, Object.assign({}, uformProps, modalProps, { data: props.data, open: props.open, onOk: props.onOk, onCancel: props.onCancel }));
61
61
  };
62
- const FormViewer = props => {
62
+ exports.FormViewer = (0, react_1.forwardRef)((props, ref) => {
63
63
  const schema = (0, react_1.useMemo)(() => (0, exports.initSchama)(props.schema), [props.schema]);
64
- return react_1.default.createElement(_FormRender, { schema: schema, data: props.data });
65
- };
66
- exports.FormViewer = FormViewer;
64
+ return react_1.default.createElement(_FormRender, { schema: schema, data: props.data, ref: ref });
65
+ });
67
66
  const FormModal = props => {
68
67
  const schema = (0, react_1.useMemo)(() => (0, exports.initSchama)(props.schema), [props.schema]);
69
68
  return react_1.default.createElement(_ModalRender, Object.assign({}, props, { schema: schema }));
package/utils/Global.d.ts CHANGED
@@ -16,8 +16,20 @@ export type GlobalSetting = {
16
16
  * 应用相关参数:
17
17
  */
18
18
  APP: {
19
+ /**
20
+ * 默认语言,默认简体中文
21
+ */
19
22
  LANG: Language;
23
+ /**
24
+ * 显示:回到首页,默认为 true
25
+ */
26
+ USER_MENU_HOMEPAGE: boolean;
20
27
  };
28
+ /**
29
+ * 基础API设置,
30
+ * 说明,如果只是前缀与通用版不同,则只需设置 PREFIX 即可,
31
+ * 其它还有不同的可单独设置
32
+ */
21
33
  BASIC: {
22
34
  PREFIX: string;
23
35
  SYSTEM: string;
package/utils/Global.js CHANGED
@@ -20,6 +20,7 @@ var LOG_LEVEL;
20
20
  const DEFAULT = {
21
21
  APP: {
22
22
  LANG: _Support_1.Language.ZH_CN,
23
+ USER_MENU_HOMEPAGE: true,
23
24
  },
24
25
  BASIC: {
25
26
  PREFIX: '/api-common',
@@ -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
  };