ls-pro-common 1.0.19 → 1.0.22

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.
package/es/index.d.ts CHANGED
@@ -8,8 +8,9 @@ import * as utils from './utils';
8
8
  /** Hooks */
9
9
  import useSingle from './hooks/useSingle';
10
10
  import useDtl from './hooks/useDtl';
11
+ import usePermission from './hooks/usePermission';
11
12
  /** Type */
12
13
  import type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
13
14
  import type { DtlLyaoutProps } from './components/DtlLayout';
14
15
  export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps };
15
- export { DtlLayout, InputTable, Page404, Loading, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl };
16
+ export { DtlLayout, InputTable, Page404, Loading, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission };
package/es/index.js CHANGED
@@ -9,4 +9,5 @@ import * as utils from './utils';
9
9
 
10
10
  import useSingle from './hooks/useSingle';
11
11
  import useDtl from './hooks/useDtl';
12
- export { DtlLayout, InputTable, Page404, Loading, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl };
12
+ import usePermission from './hooks/usePermission';
13
+ export { DtlLayout, InputTable, Page404, Loading, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission };
@@ -11,5 +11,6 @@ declare class BaseService {
11
11
  save(data: Record<string, any>): Promise<any>;
12
12
  /** 批量删除对象方法,@param data id集合 */
13
13
  remove(data: any[]): Promise<any>;
14
+ audit(data: any[]): Promise<any>;
14
15
  }
15
16
  export default BaseService;
@@ -157,9 +157,9 @@ var BaseService = /*#__PURE__*/function () {
157
157
  break;
158
158
  }
159
159
 
160
- _message.error("加载方法没有配置api");
160
+ _message.error("删除方法没有配置api");
161
161
 
162
- return _context3.abrupt("return", Promise.reject("加载方法没有配置api"));
162
+ return _context3.abrupt("return", Promise.reject("删除方法没有配置api"));
163
163
 
164
164
  case 4:
165
165
  if (!(this.method.delete === 'post')) {
@@ -194,6 +194,49 @@ var BaseService = /*#__PURE__*/function () {
194
194
 
195
195
  return remove;
196
196
  }()
197
+ }, {
198
+ key: "audit",
199
+ value: function () {
200
+ var _audit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
201
+ var _this$api4;
202
+
203
+ var url;
204
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
205
+ while (1) {
206
+ switch (_context4.prev = _context4.next) {
207
+ case 0:
208
+ url = (_this$api4 = this.api) === null || _this$api4 === void 0 ? void 0 : _this$api4.audit;
209
+
210
+ if (url) {
211
+ _context4.next = 4;
212
+ break;
213
+ }
214
+
215
+ _message.error("审核方法没有配置api");
216
+
217
+ return _context4.abrupt("return", Promise.reject("审核方法没有配置api"));
218
+
219
+ case 4:
220
+ _context4.next = 6;
221
+ return httpPost(url, data);
222
+
223
+ case 6:
224
+ return _context4.abrupt("return", _context4.sent);
225
+
226
+ case 7:
227
+ case "end":
228
+ return _context4.stop();
229
+ }
230
+ }
231
+ }, _callee4, this);
232
+ }));
233
+
234
+ function audit(_x4) {
235
+ return _audit.apply(this, arguments);
236
+ }
237
+
238
+ return audit;
239
+ }()
197
240
  }]);
198
241
 
199
242
  return BaseService;
package/es/typing.d.ts CHANGED
@@ -15,6 +15,8 @@ export declare type TableToolbar = {
15
15
  remove?: boolean;
16
16
  export?: boolean;
17
17
  import?: boolean;
18
+ audit?: boolean;
19
+ config?: boolean;
18
20
  print?: boolean;
19
21
  };
20
22
  /** 基础模块接口类型 */
@@ -31,6 +33,8 @@ export declare type BaseApiType = {
31
33
  import?: string;
32
34
  /**导出数据api,如果跟加载数据api一致,可不指定 */
33
35
  export?: string;
36
+ /** 审核接口 */
37
+ audit?: string;
34
38
  };
35
39
  /**请求后端接口方法 */
36
40
  export declare type MethodType = {
package/es/utils/index.js CHANGED
@@ -52,7 +52,7 @@ export var setCookie = function setCookie(key, value) {
52
52
  */
53
53
 
54
54
  export var isLogin = function isLogin() {
55
- return !!getCookie('inline');
55
+ return !!getCookie('online');
56
56
  };
57
57
  /**
58
58
  * 设置本地缓存
@@ -2,18 +2,33 @@ import React from 'react';
2
2
  import type { ProFormInstance } from 'ls-pro-form';
3
3
  import './common.less';
4
4
  export declare type DtlLyaoutProps = Record<string, any> & {
5
+ /** 返回方法 */
5
6
  onExit: (visible?: boolean) => void;
7
+ /** 保存方法 */
6
8
  onSave?: () => void;
9
+ /** 自定义按钮方法 */
7
10
  renderButton?: (defaultBtn: JSX.Element[]) => JSX.Element[];
11
+ /** 审核方法 */
12
+ onAudit?: () => void;
13
+ /** 保存按钮文本 */
8
14
  btnSaveText?: string;
15
+ /** 返回按钮文本 */
9
16
  btnExitText?: string;
17
+ /** 标题 */
10
18
  title?: string;
19
+ /** 主表对象 */
11
20
  masterObject?: any;
21
+ /** 主表主键字段 */
12
22
  keyField?: string;
23
+ /** body类 */
13
24
  bodyClass?: string;
25
+ /** header 类 */
14
26
  headerClass?: string;
27
+ /** body样式 */
15
28
  bodyStyle?: React.CSSProperties;
29
+ /** header样式 */
16
30
  headerStyle?: React.CSSProperties;
31
+ /** 表单ref */
17
32
  formRef?: React.MutableRefObject<ProFormInstance | undefined>;
18
33
  };
19
34
  declare function DtlLayout(props: DtlLyaoutProps): JSX.Element;
@@ -42,25 +42,36 @@ function DtlLayout(props) {
42
42
  if (!masterObject) return '';
43
43
  return masterObject[keyField] ? '编辑' : '新增';
44
44
  }, [title, masterObject, keyField]);
45
- var btns = [/*#__PURE__*/_react.default.createElement(_button.default, {
46
- key: "btnSave",
47
- onClick: function onClick() {
48
- var _formRef$current;
45
+ var btns = (0, _react.useMemo)(function () {
46
+ var b = [/*#__PURE__*/_react.default.createElement(_button.default, {
47
+ key: "btnSave",
48
+ onClick: function onClick() {
49
+ var _formRef$current;
49
50
 
50
- if (props.onSave) {
51
- return props.onSave();
52
- }
51
+ if (props.onSave) {
52
+ return props.onSave();
53
+ }
53
54
 
54
- formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
55
- },
56
- icon: /*#__PURE__*/_react.default.createElement(_icons.SaveOutlined, null)
57
- }, " ", btnSaveText, " "), /*#__PURE__*/_react.default.createElement(_button.default, {
58
- key: "btnBack",
59
- onClick: function onClick() {
60
- return props.onExit(false);
61
- },
62
- icon: /*#__PURE__*/_react.default.createElement(_icons.ArrowLeftOutlined, null)
63
- }, " ", btnExitText, " ")];
55
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
56
+ },
57
+ icon: /*#__PURE__*/_react.default.createElement(_icons.SaveOutlined, null)
58
+ }, btnSaveText), /*#__PURE__*/_react.default.createElement(_button.default, {
59
+ key: "btnBack",
60
+ onClick: function onClick() {
61
+ return props.onExit(false);
62
+ },
63
+ icon: /*#__PURE__*/_react.default.createElement(_icons.ArrowLeftOutlined, null)
64
+ }, btnExitText)];
65
+
66
+ if (props.onAudit) {
67
+ b.unshift( /*#__PURE__*/_react.default.createElement(_button.default, {
68
+ key: "btnAudit",
69
+ icon: /*#__PURE__*/_react.default.createElement(_icons.CheckOutlined, null)
70
+ }, "\u5BA1\u6838"));
71
+ }
72
+
73
+ return b;
74
+ }, [props]);
64
75
  var buttons = renderButton ? renderButton(btns) : btns;
65
76
  return /*#__PURE__*/_react.default.createElement("div", {
66
77
  className: "dtl-layout"
@@ -12,6 +12,7 @@ export declare type InputTableProps = ProFormItemProps<InputProps> & {
12
12
  textField?: string;
13
13
  textName?: string;
14
14
  tableConfig?: any;
15
+ labelWidth?: number;
15
16
  onSelectChange?: (item: any) => void;
16
17
  };
17
18
  declare function InputTable(prop: InputTableProps): JSX.Element;
@@ -43,7 +43,7 @@ var _icons = require("@ant-design/icons");
43
43
 
44
44
  var _http = require("../http");
45
45
 
46
- var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "textField", "onSelectChange"],
46
+ var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "labelWidth", "textField", "onSelectChange"],
47
47
  _excluded2 = ["current", "pageSize"];
48
48
 
49
49
  function InputTable(prop) {
@@ -81,6 +81,8 @@ function InputTable(prop) {
81
81
  readonly = _prop$readonly === void 0 ? true : _prop$readonly,
82
82
  multiple = prop.multiple,
83
83
  valueField = prop.valueField,
84
+ _prop$labelWidth = prop.labelWidth,
85
+ labelWidth = _prop$labelWidth === void 0 ? 70 : _prop$labelWidth,
84
86
  textField = prop.textField,
85
87
  onSelectChange = prop.onSelectChange,
86
88
  rest = (0, _objectWithoutProperties2.default)(prop, _excluded);
@@ -145,7 +147,7 @@ function InputTable(prop) {
145
147
  manualRequest: false,
146
148
  actionRef: tableRef,
147
149
  search: {
148
- labelWidth: 70
150
+ labelWidth: labelWidth
149
151
  },
150
152
  options: {
151
153
  density: false,
@@ -155,7 +157,8 @@ function InputTable(prop) {
155
157
  form: {
156
158
  submitter: {
157
159
  resetButtonProps: false
158
- }
160
+ },
161
+ btnInline: true
159
162
  },
160
163
  height: 'full',
161
164
  rowSelection: {
@@ -15,17 +15,19 @@ declare function useDtl(dtlParam: DtlParamType): {
15
15
  selectedRows: any;
16
16
  showEdit: boolean;
17
17
  editItem: any;
18
- tableTools: JSX.Element[];
18
+ tableTools: (boolean | JSX.Element)[];
19
19
  setSelectedRows: import("react").Dispatch<any>;
20
20
  setShowEdit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
21
21
  setEditItem: import("react").Dispatch<any>;
22
- onRemoveDtl: () => void;
22
+ onRemoveDtl: (rows?: any) => void;
23
23
  onSaveDtl: (formData: any) => Promise<boolean>;
24
24
  onLoadDtl: (params: Record<string, any>, sort: Record<string, any>, filter: Record<string, any>) => Promise<any>;
25
- onAddDtl: () => Promise<boolean>;
26
- onEditDtl: () => Promise<boolean>;
25
+ onAddDtl: (item?: any) => Promise<boolean>;
26
+ onEditDtl: (item?: any) => Promise<boolean>;
27
27
  onSaveMst: (values: any) => Promise<boolean>;
28
28
  onRemoveMst: () => Promise<boolean | undefined>;
29
29
  onExportDtl: (url: string, param: exportParam) => Promise<boolean>;
30
+ isAudit: () => boolean;
31
+ onAudit: () => Promise<void>;
30
32
  };
31
33
  export default useDtl;