vap1 0.1.1 → 0.1.2

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.
@@ -15,6 +15,10 @@ const _SearchBar = props => {
15
15
  if (utils_1.GLOBAL.CONFIG.SEARCHBAR.REVERSE)
16
16
  clazz.push('c-searchbar-reverse');
17
17
  if (!lodash_1.default.isArray(props.fields) || props.fields.length == 0) {
18
+ if (lodash_1.default.has(props, 'keyword'))
19
+ return react_1.default.createElement("div", { className: utils_1.StringUtil.className(clazz, props.className) },
20
+ react_1.default.createElement(ByKeyword_1.SearchBarByKeyword, Object.assign({}, props)),
21
+ react_1.default.createElement("div", { className: 'c-searchbar-actions' }, props.children));
18
22
  if (!lodash_1.default.has(props, 'children'))
19
23
  return react_1.default.createElement(react_1.default.Fragment, null);
20
24
  return react_1.default.createElement("div", { className: utils_1.StringUtil.className(clazz, props.className) },
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
- import type { BaseTableProps } from './index';
2
+ import type { BaseTableProps, TableColumn } from './index';
3
3
  import type { ListModel } from '../../hooks/_list';
4
+ import type { PlainObject, Key } from '../../basetype';
5
+ export type VTableRef = {
6
+ getSelected: () => [Key[], PlainObject[]];
7
+ getParams: () => PlainObject;
8
+ };
4
9
  export declare const getHeightByTagName: (root: HTMLElement, tagName: string) => number;
5
10
  /**
6
11
  * VTable 支持多种模型,内置模型有 API/DATA/STATIC,也支持模型规范的自定义模型
@@ -8,4 +13,18 @@ export declare const getHeightByTagName: (root: HTMLElement, tagName: string) =>
8
13
  export type VTableProps = BaseTableProps & {
9
14
  model: ListModel;
10
15
  };
11
- export declare const VTable: React.FC<VTableProps>;
16
+ export declare const VTable: React.ForwardRefExoticComponent<import("./index").TableDefine & {
17
+ mode?: import("../Box/Box").BoxMode;
18
+ columns: TableColumn[];
19
+ showIndex?: string | false;
20
+ rowKey?: string;
21
+ select?: true | "DEFAULT" | "QUERY";
22
+ selectDisabled?: (record: any) => boolean;
23
+ actionBar?: React.ReactNode | import("./Components/ActionBar").TableActionButton[];
24
+ selectBar?: import("../Box/SelectBar").SelectBarProps;
25
+ searchBar?: Omit<import("../SearchBar").SearchBarProps, "onChange" | "onSearch">;
26
+ default?: PlainObject;
27
+ autoLoad?: false;
28
+ } & {
29
+ model: ListModel;
30
+ } & React.RefAttributes<VTableRef>>;
@@ -37,6 +37,7 @@ const Util_1 = require("./Util");
37
37
  const HighLight_1 = require("../_common/HighLight");
38
38
  const hooks_1 = require("../../hooks");
39
39
  const Box_1 = require("../Box/Box");
40
+ ;
40
41
  const getHeightByTagName = (root, tagName) => {
41
42
  if (root == null)
42
43
  return 0;
@@ -122,7 +123,6 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
122
123
  (0, react_1.useEffect)(() => {
123
124
  if (props.autoLoad === false)
124
125
  return;
125
- console.log(props.model);
126
126
  // @ts-ignore
127
127
  if (props.model.mode == 'api-global' && total > 0)
128
128
  return;
@@ -183,7 +183,8 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
183
183
  },
184
184
  };
185
185
  }
186
- return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey: props.rowKey || rowKey, scroll: scroll, tableLayout: "fixed",
186
+ return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey: props.rowKey || rowKey, scroll: scroll,
187
+ // tableLayout="fixed"
187
188
  // showSorterTooltip={false}
188
189
  size: utils_1.GLOBAL.CONFIG.TABLE.SIZE }, props, tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns, locale: { emptyText: react_1.default.createElement(antd_1.Empty, { style: { marginTop: 24 } }) }, dataSource: list, loading: isQuerying, onChange: (x, y, field) => {
189
190
  if (field.column) {
@@ -194,10 +195,21 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
194
195
  }
195
196
  } }));
196
197
  });
197
- const VTable = (props) => {
198
+ exports.VTable = react_1.default.forwardRef((props, ref) => {
198
199
  const { isQuerying, pageNo, pageSize, total, totalAcc, param, pageTo, query, cost } = props.model;
199
200
  // 通过 ref 方式交互,后续扩展方法实现定制联页选择
200
201
  const selectedRef = (0, react_1.useRef)({ selected: [[], []], onSelected: () => { }, });
202
+ // 对外提供getSelected方法获取当前选择的数据
203
+ (0, react_1.useImperativeHandle)(ref, () => {
204
+ return {
205
+ getSelected() {
206
+ return selectedRef.current.selected;
207
+ },
208
+ getParams: () => {
209
+ return props.model.param;
210
+ }
211
+ };
212
+ });
201
213
  let boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
202
214
  if (props.searchBar) {
203
215
  boxProps.searchBar = Object.assign(Object.assign({}, props.searchBar), { disabled: isQuerying, onSearch: (data) => {
@@ -238,5 +250,4 @@ const VTable = (props) => {
238
250
  }
239
251
  return react_1.default.createElement(Box_1.Box, Object.assign({}, boxProps),
240
252
  react_1.default.createElement(_VTable, Object.assign({}, lodash_1.default.omit(props, ['className', 'style']), { ref: selectedRef })));
241
- };
242
- exports.VTable = VTable;
253
+ });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { TableDefined } from './Components';
3
- import type { ForwardRefExoticComponent, ExoticComponent } from 'react';
3
+ import type { ForwardRefExoticComponent, ExoticComponent, RefAttributes } from 'react';
4
4
  import type { TableProps } from '../_adapt/Table';
5
5
  import type { ColumnProps } from 'antd/es/table/interface';
6
6
  import type { SearchBarProps } from '../SearchBar/index';
@@ -66,10 +66,10 @@ export type BaseTableProps = TableDefine & {
66
66
  autoLoad?: false;
67
67
  };
68
68
  import type { ApiTableProps } from './ApiTable';
69
- export type ApiTable = ForwardRefExoticComponent<ApiTableProps & React.RefAttributes<ApiModel>> & TableDefined;
69
+ export type ApiTable = ForwardRefExoticComponent<ApiTableProps & RefAttributes<ApiModel>> & TableDefined;
70
70
  export declare const ApiTable: ApiTable;
71
- import type { VTableProps } from './VTable';
72
- export type VTable = ExoticComponent<VTableProps> & TableDefined;
71
+ import type { VTableProps, VTableRef } from './VTable';
72
+ export type VTable = ForwardRefExoticComponent<VTableProps & RefAttributes<VTableRef>> & TableDefined;
73
73
  export declare const VTable: VTable;
74
74
  import type { STableProps } from './STable';
75
75
  export type STable = ExoticComponent<STableProps> & TableDefined;
@@ -125,7 +125,6 @@ const _Dtree = (props) => {
125
125
  // 如果根节点只有一个,则自动展开这个根结点
126
126
  treeProps.defaultExpandedKeys = [treeState.treeData[0][treeState.keyField]];
127
127
  }
128
- // loadData?: (node: AntTreeNode) => PromiseLike<void>;
129
128
  const loadData = (evt) => __awaiter(void 0, void 0, void 0, function* () {
130
129
  const { node, position } = evt.props.data;
131
130
  const children = yield props.getChildren(node[treeState.keyField]);
@@ -43,13 +43,13 @@ const antd_1 = require("antd");
43
43
  const Row_1 = require("../_adapt/Row");
44
44
  const Col_1 = require("../_adapt/Col");
45
45
  const Popconfirm_1 = require("../_adapt/Popconfirm");
46
+ const Popover_1 = require("../_adapt/Popover");
46
47
  const Button_1 = require("../_adapt/Button");
47
48
  const FormWrapper_1 = require("./FormWrapper");
48
49
  const useUpdate_1 = require("../../hooks/useUpdate");
49
50
  const Icon_1 = require("../_adapt/Icon");
50
51
  const _FormUtils_1 = require("./_FormUtils");
51
52
  const _register_1 = require("./_register");
52
- const Popover_1 = require("../_adapt/Popover");
53
53
  const onChangeEvent = (state, field, form, update, values, extra) => {
54
54
  const { multipleFields, requireFields, disableFields, hiddenFields, optionFields, } = state;
55
55
  if (!lodash_1.default.isArray(field.link) || field.link.length == 0)
@@ -28,10 +28,13 @@ const _Button = props => {
28
28
  icon,
29
29
  " ",
30
30
  react_1.default.createElement("span", null, utils_1.i18n.txt(props.ik)));
31
- return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps),
32
- icon,
33
- " ",
34
- react_1.default.createElement("span", null, props.children));
31
+ if (props.children) {
32
+ return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps),
33
+ icon,
34
+ " ",
35
+ react_1.default.createElement("span", null, props.children));
36
+ }
37
+ return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps), icon);
35
38
  }
36
39
  if (props.ik)
37
40
  return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps), utils_1.i18n.txt(props.ik));
@@ -16,8 +16,6 @@ const Row = (props) => {
16
16
  if (props.direction != 'column')
17
17
  return react_1.default.createElement(antd_1.Row, Object.assign({ type: "flex", gutter: Global_1.CONFIG.GRID.GUTTER }, props, { className: clazz.join(' ') }));
18
18
  clazz.push('v-row-direction-column');
19
- return react_1.default.createElement(antd_1.Row, Object.assign({ type: "flex", gutter: Global_1.CONFIG.GRID.GUTTER }, props, {
20
- // wrap={props.wrap || false}
21
- className: clazz.join(' ') }));
19
+ return react_1.default.createElement(antd_1.Row, Object.assign({ type: "flex", gutter: Global_1.CONFIG.GRID.GUTTER }, props, { className: clazz.join(' ') }));
22
20
  };
23
21
  exports.Row = Row;
@@ -1,6 +1,7 @@
1
1
  declare global {
2
2
  const PNXGWClient: any;
3
3
  interface Window {
4
+ APP_ROOT: string;
4
5
  ActiveXObject: any;
5
6
  }
6
7
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.1.1","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.1.2","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
@@ -11,6 +11,14 @@ export declare const paramToUri: (param: PlainObject, baseUrl?: string) => strin
11
11
  * 将一个ip4地址转换成数字
12
12
  */
13
13
  export declare const IpToInt: (ip: string) => number;
14
+ /**
15
+ * 兼容二级目录-转化URL
16
+ */
17
+ export declare const resolveURL: ((url: string) => string);
18
+ /**
19
+ * 兼容二级目录-恢复URL
20
+ */
21
+ export declare const clearURL: ((url: string) => string);
14
22
  /**
15
23
  * 判断是否有权限
16
24
  */
package/utils/PageUtil.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOptions = exports.currentApp = exports.hasRole = exports.IpToInt = exports.paramToUri = exports.stopEvent = void 0;
6
+ exports.getOptions = exports.currentApp = exports.hasRole = exports.clearURL = exports.resolveURL = exports.IpToInt = exports.paramToUri = exports.stopEvent = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const StringUtil_1 = require("./StringUtil");
9
9
  const _Support_1 = require("./_Support");
@@ -46,6 +46,25 @@ const IpToInt = (ip) => {
46
46
  return ip.split('.').reduce((ipInt, octet) => (ipInt << 8) + parseInt(octet, 10), 0) >>> 0;
47
47
  };
48
48
  exports.IpToInt = IpToInt;
49
+ /**
50
+ * 兼容二级目录-转化URL
51
+ */
52
+ exports.resolveURL = (window.APP_ROOT == null || window.APP_ROOT == '') ? (val => val) : (url) => {
53
+ if (!url.startsWith('/'))
54
+ return url;
55
+ if (url.startsWith(window.APP_ROOT))
56
+ return url;
57
+ return window.APP_ROOT + url;
58
+ };
59
+ const len = window.APP_ROOT ? window.APP_ROOT.length : 0;
60
+ /**
61
+ * 兼容二级目录-恢复URL
62
+ */
63
+ exports.clearURL = (len == 0) ? (val => val) : (url) => {
64
+ if (!url.startsWith(window.APP_ROOT))
65
+ return url;
66
+ return url.substring(len);
67
+ };
49
68
  /**
50
69
  * 判断是否有权限
51
70
  */