ls-pro-common 1.0.20 → 1.0.23
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/dist/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/DtlLayout.d.ts +15 -0
- package/es/components/DtlLayout.js +29 -18
- package/es/components/InputTable.d.ts +1 -0
- package/es/components/InputTable.js +4 -2
- package/es/hooks/useDtl/index.d.ts +1 -0
- package/es/hooks/useDtl/index.js +155 -26
- package/es/hooks/useSingle/index.d.ts +1 -1
- package/es/hooks/useSingle/index.js +49 -21
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/service/BaseService.d.ts +1 -0
- package/es/service/BaseService.js +45 -2
- package/es/typing.d.ts +2 -0
- package/es/utils/index.js +1 -1
- package/lib/components/DtlLayout.d.ts +15 -0
- package/lib/components/DtlLayout.js +28 -17
- package/lib/components/InputTable.d.ts +1 -0
- package/lib/components/InputTable.js +4 -2
- package/lib/hooks/useDtl/index.d.ts +1 -0
- package/lib/hooks/useDtl/index.js +155 -26
- package/lib/hooks/useSingle/index.d.ts +1 -1
- package/lib/hooks/useSingle/index.js +48 -21
- package/lib/index.d.ts +2 -1
- package/lib/index.js +9 -1
- package/lib/service/BaseService.d.ts +1 -0
- package/lib/service/BaseService.js +45 -2
- package/lib/typing.d.ts +2 -0
- package/lib/utils/index.js +1 -1
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -2,7 +2,7 @@ import "antd/es/button/style";
|
|
|
2
2
|
import _Button from "antd/es/button";
|
|
3
3
|
import React, { useMemo } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons';
|
|
5
|
+
import { ArrowLeftOutlined, SaveOutlined, CheckOutlined } from '@ant-design/icons';
|
|
6
6
|
import './common.less';
|
|
7
7
|
|
|
8
8
|
function DtlLayout(props) {
|
|
@@ -26,25 +26,36 @@ function DtlLayout(props) {
|
|
|
26
26
|
if (!masterObject) return '';
|
|
27
27
|
return masterObject[keyField] ? '编辑' : '新增';
|
|
28
28
|
}, [title, masterObject, keyField]);
|
|
29
|
-
var btns =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
var btns = useMemo(function () {
|
|
30
|
+
var b = [/*#__PURE__*/React.createElement(_Button, {
|
|
31
|
+
key: "btnSave",
|
|
32
|
+
onClick: function onClick() {
|
|
33
|
+
var _formRef$current;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (props.onSave) {
|
|
36
|
+
return props.onSave();
|
|
37
|
+
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
|
|
40
|
+
},
|
|
41
|
+
icon: /*#__PURE__*/React.createElement(SaveOutlined, null)
|
|
42
|
+
}, btnSaveText), /*#__PURE__*/React.createElement(_Button, {
|
|
43
|
+
key: "btnBack",
|
|
44
|
+
onClick: function onClick() {
|
|
45
|
+
return props.onExit(false);
|
|
46
|
+
},
|
|
47
|
+
icon: /*#__PURE__*/React.createElement(ArrowLeftOutlined, null)
|
|
48
|
+
}, btnExitText)];
|
|
49
|
+
|
|
50
|
+
if (props.onAudit) {
|
|
51
|
+
b.unshift( /*#__PURE__*/React.createElement(_Button, {
|
|
52
|
+
key: "btnAudit",
|
|
53
|
+
icon: /*#__PURE__*/React.createElement(CheckOutlined, null)
|
|
54
|
+
}, "\u5BA1\u6838"));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return b;
|
|
58
|
+
}, [props]);
|
|
48
59
|
var buttons = renderButton ? renderButton(btns) : btns;
|
|
49
60
|
return /*#__PURE__*/React.createElement("div", {
|
|
50
61
|
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;
|
|
@@ -10,7 +10,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
10
10
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
11
11
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
12
12
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
13
|
-
var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "textField", "onSelectChange"],
|
|
13
|
+
var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "labelWidth", "textField", "onSelectChange"],
|
|
14
14
|
_excluded2 = ["current", "pageSize"];
|
|
15
15
|
import React from "react";
|
|
16
16
|
import { useRef, useState, useEffect, useContext } from 'react';
|
|
@@ -54,6 +54,8 @@ function InputTable(prop) {
|
|
|
54
54
|
readonly = _prop$readonly === void 0 ? true : _prop$readonly,
|
|
55
55
|
multiple = prop.multiple,
|
|
56
56
|
valueField = prop.valueField,
|
|
57
|
+
_prop$labelWidth = prop.labelWidth,
|
|
58
|
+
labelWidth = _prop$labelWidth === void 0 ? 70 : _prop$labelWidth,
|
|
57
59
|
textField = prop.textField,
|
|
58
60
|
onSelectChange = prop.onSelectChange,
|
|
59
61
|
rest = _objectWithoutProperties(prop, _excluded);
|
|
@@ -118,7 +120,7 @@ function InputTable(prop) {
|
|
|
118
120
|
manualRequest: false,
|
|
119
121
|
actionRef: tableRef,
|
|
120
122
|
search: {
|
|
121
|
-
labelWidth:
|
|
123
|
+
labelWidth: labelWidth
|
|
122
124
|
},
|
|
123
125
|
options: {
|
|
124
126
|
density: false,
|
|
@@ -28,5 +28,6 @@ declare function useDtl(dtlParam: DtlParamType): {
|
|
|
28
28
|
onRemoveMst: () => Promise<boolean | undefined>;
|
|
29
29
|
onExportDtl: (url: string, param: exportParam) => Promise<boolean>;
|
|
30
30
|
isAudit: () => boolean;
|
|
31
|
+
onAudit: () => Promise<void>;
|
|
31
32
|
};
|
|
32
33
|
export default useDtl;
|
package/es/hooks/useDtl/index.js
CHANGED
|
@@ -30,7 +30,9 @@ function useDtl(dtlParam) {
|
|
|
30
30
|
beforeRemove = dtlParam.beforeRemove,
|
|
31
31
|
afterSave = dtlParam.afterSave,
|
|
32
32
|
afterRemove = dtlParam.afterRemove,
|
|
33
|
-
btnStatus = dtlParam.btnStatus
|
|
33
|
+
btnStatus = dtlParam.btnStatus,
|
|
34
|
+
beforeAudit = dtlParam.beforeAudit,
|
|
35
|
+
afterAudit = dtlParam.afterAudit;
|
|
34
36
|
/** @name 选中行数据 */
|
|
35
37
|
|
|
36
38
|
var _useState = useState([]),
|
|
@@ -181,73 +183,82 @@ function useDtl(dtlParam) {
|
|
|
181
183
|
return _context2.abrupt("return", false);
|
|
182
184
|
|
|
183
185
|
case 2:
|
|
184
|
-
|
|
186
|
+
if (!isAudit()) {
|
|
187
|
+
_context2.next = 5;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
showWarn('当前单据已审核,不能删除');
|
|
192
|
+
return _context2.abrupt("return", false);
|
|
193
|
+
|
|
194
|
+
case 5:
|
|
195
|
+
_context2.next = 7;
|
|
185
196
|
return showConfirm('确认要删除当前数据?');
|
|
186
197
|
|
|
187
|
-
case
|
|
198
|
+
case 7:
|
|
188
199
|
if (!beforeRemove) {
|
|
189
|
-
_context2.next =
|
|
200
|
+
_context2.next = 13;
|
|
190
201
|
break;
|
|
191
202
|
}
|
|
192
203
|
|
|
193
|
-
_context2.next =
|
|
204
|
+
_context2.next = 10;
|
|
194
205
|
return beforeRemove([masterObject]);
|
|
195
206
|
|
|
196
|
-
case
|
|
207
|
+
case 10:
|
|
197
208
|
ids = _context2.sent;
|
|
198
209
|
|
|
199
210
|
if (!(ids === false)) {
|
|
200
|
-
_context2.next =
|
|
211
|
+
_context2.next = 13;
|
|
201
212
|
break;
|
|
202
213
|
}
|
|
203
214
|
|
|
204
215
|
return _context2.abrupt("return", false);
|
|
205
216
|
|
|
206
|
-
case
|
|
217
|
+
case 13:
|
|
207
218
|
if (!ids) {
|
|
208
219
|
ids = [masterObject[mstKeyField]];
|
|
209
220
|
}
|
|
210
221
|
|
|
211
|
-
_context2.next =
|
|
222
|
+
_context2.next = 16;
|
|
212
223
|
return mstService.remove(ids);
|
|
213
224
|
|
|
214
|
-
case
|
|
225
|
+
case 16:
|
|
215
226
|
result = _context2.sent;
|
|
216
227
|
_context2.t0 = afterRemove;
|
|
217
228
|
|
|
218
229
|
if (!_context2.t0) {
|
|
219
|
-
_context2.next =
|
|
230
|
+
_context2.next = 23;
|
|
220
231
|
break;
|
|
221
232
|
}
|
|
222
233
|
|
|
223
|
-
_context2.next =
|
|
234
|
+
_context2.next = 21;
|
|
224
235
|
return afterRemove(result, masterObject);
|
|
225
236
|
|
|
226
|
-
case
|
|
237
|
+
case 21:
|
|
227
238
|
_context2.t1 = _context2.sent;
|
|
228
239
|
_context2.t0 = _context2.t1 === false;
|
|
229
240
|
|
|
230
|
-
case
|
|
241
|
+
case 23:
|
|
231
242
|
if (!_context2.t0) {
|
|
232
|
-
_context2.next =
|
|
243
|
+
_context2.next = 25;
|
|
233
244
|
break;
|
|
234
245
|
}
|
|
235
246
|
|
|
236
247
|
return _context2.abrupt("return");
|
|
237
248
|
|
|
238
|
-
case
|
|
249
|
+
case 25:
|
|
239
250
|
if (!((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0')) {
|
|
240
|
-
_context2.next =
|
|
251
|
+
_context2.next = 28;
|
|
241
252
|
break;
|
|
242
253
|
}
|
|
243
254
|
|
|
244
255
|
showSuccess(result.flag.retMsg);
|
|
245
256
|
return _context2.abrupt("return", true);
|
|
246
257
|
|
|
247
|
-
case
|
|
258
|
+
case 28:
|
|
248
259
|
return _context2.abrupt("return", false);
|
|
249
260
|
|
|
250
|
-
case
|
|
261
|
+
case 29:
|
|
251
262
|
case "end":
|
|
252
263
|
return _context2.stop();
|
|
253
264
|
}
|
|
@@ -756,6 +767,105 @@ function useDtl(dtlParam) {
|
|
|
756
767
|
return _ref8.apply(this, arguments);
|
|
757
768
|
};
|
|
758
769
|
}();
|
|
770
|
+
/** 审核按钮事件 */
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
var onAudit = /*#__PURE__*/function () {
|
|
774
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
775
|
+
var obj, _result$flag8, result;
|
|
776
|
+
|
|
777
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
778
|
+
while (1) {
|
|
779
|
+
switch (_context9.prev = _context9.next) {
|
|
780
|
+
case 0:
|
|
781
|
+
if (!isAudit()) {
|
|
782
|
+
_context9.next = 3;
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
showWarn('当前数据已审核,不能再做审核操作!');
|
|
787
|
+
return _context9.abrupt("return");
|
|
788
|
+
|
|
789
|
+
case 3:
|
|
790
|
+
obj = _objectSpread({}, masterObject); // beforeAudit 强式终止
|
|
791
|
+
|
|
792
|
+
_context9.t0 = beforeAudit;
|
|
793
|
+
|
|
794
|
+
if (!_context9.t0) {
|
|
795
|
+
_context9.next = 10;
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
_context9.next = 8;
|
|
800
|
+
return beforeAudit(obj);
|
|
801
|
+
|
|
802
|
+
case 8:
|
|
803
|
+
_context9.t1 = _context9.sent;
|
|
804
|
+
_context9.t0 = _context9.t1 === false;
|
|
805
|
+
|
|
806
|
+
case 10:
|
|
807
|
+
if (!_context9.t0) {
|
|
808
|
+
_context9.next = 12;
|
|
809
|
+
break;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
return _context9.abrupt("return");
|
|
813
|
+
|
|
814
|
+
case 12:
|
|
815
|
+
_context9.prev = 12;
|
|
816
|
+
_context9.next = 15;
|
|
817
|
+
return mstService.audit([obj]);
|
|
818
|
+
|
|
819
|
+
case 15:
|
|
820
|
+
result = _context9.sent;
|
|
821
|
+
_context9.t2 = afterAudit;
|
|
822
|
+
|
|
823
|
+
if (!_context9.t2) {
|
|
824
|
+
_context9.next = 22;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
_context9.next = 20;
|
|
829
|
+
return afterAudit(result, [obj]);
|
|
830
|
+
|
|
831
|
+
case 20:
|
|
832
|
+
_context9.t3 = _context9.sent;
|
|
833
|
+
_context9.t2 = _context9.t3 === false;
|
|
834
|
+
|
|
835
|
+
case 22:
|
|
836
|
+
if (!_context9.t2) {
|
|
837
|
+
_context9.next = 24;
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return _context9.abrupt("return");
|
|
842
|
+
|
|
843
|
+
case 24:
|
|
844
|
+
if ((result === null || result === void 0 ? void 0 : (_result$flag8 = result.flag) === null || _result$flag8 === void 0 ? void 0 : _result$flag8.retCode) === '0') {
|
|
845
|
+
showSuccess(result.flag.retMsg);
|
|
846
|
+
Object.assign(masterObject, result.data);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
_context9.next = 30;
|
|
850
|
+
break;
|
|
851
|
+
|
|
852
|
+
case 27:
|
|
853
|
+
_context9.prev = 27;
|
|
854
|
+
_context9.t4 = _context9["catch"](12);
|
|
855
|
+
console.log(_context9.t4);
|
|
856
|
+
|
|
857
|
+
case 30:
|
|
858
|
+
case "end":
|
|
859
|
+
return _context9.stop();
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}, _callee9, null, [[12, 27]]);
|
|
863
|
+
}));
|
|
864
|
+
|
|
865
|
+
return function onAudit() {
|
|
866
|
+
return _ref9.apply(this, arguments);
|
|
867
|
+
};
|
|
868
|
+
}();
|
|
759
869
|
|
|
760
870
|
var btnDisabled = function btnDisabled(key) {
|
|
761
871
|
if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
|
|
@@ -772,6 +882,28 @@ function useDtl(dtlParam) {
|
|
|
772
882
|
}
|
|
773
883
|
};
|
|
774
884
|
|
|
885
|
+
var onExport = function onExport() {
|
|
886
|
+
var _tableRef$current, _tableRef$current$sho;
|
|
887
|
+
|
|
888
|
+
if (!masterObject[mstKeyField]) {
|
|
889
|
+
showWarn('主表没保存,无法导出数据');
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$sho = _tableRef$current.showExport) === null || _tableRef$current$sho === void 0 ? void 0 : _tableRef$current$sho.call(_tableRef$current);
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
var onImport = function onImport() {
|
|
897
|
+
var _tableRef$current2, _tableRef$current2$sh;
|
|
898
|
+
|
|
899
|
+
if (!masterObject[mstKeyField]) {
|
|
900
|
+
showWarn('主表没保存,无法导入数据');
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$sh = _tableRef$current2.showImport) === null || _tableRef$current2$sh === void 0 ? void 0 : _tableRef$current2$sh.call(_tableRef$current2);
|
|
905
|
+
};
|
|
906
|
+
|
|
775
907
|
var tableTools = useMemo(function () {
|
|
776
908
|
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
|
|
777
909
|
key: "add",
|
|
@@ -797,17 +929,13 @@ function useDtl(dtlParam) {
|
|
|
797
929
|
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/React.createElement(_Button, {
|
|
798
930
|
key: "import",
|
|
799
931
|
onClick: function onClick() {
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$sho = _tableRef$current.showImport) === null || _tableRef$current$sho === void 0 ? void 0 : _tableRef$current$sho.call(_tableRef$current);
|
|
932
|
+
onImport();
|
|
803
933
|
},
|
|
804
934
|
icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
|
|
805
935
|
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/React.createElement(_Button, {
|
|
806
936
|
key: "export",
|
|
807
937
|
onClick: function onClick() {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$sh = _tableRef$current2.showExport) === null || _tableRef$current2$sh === void 0 ? void 0 : _tableRef$current2$sh.call(_tableRef$current2);
|
|
938
|
+
onExport();
|
|
811
939
|
},
|
|
812
940
|
icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
|
|
813
941
|
}, "\u5BFC\u51FA") : false].filter(function (o) {
|
|
@@ -833,7 +961,8 @@ function useDtl(dtlParam) {
|
|
|
833
961
|
onSaveMst: onSaveMst,
|
|
834
962
|
onRemoveMst: onRemoveMst,
|
|
835
963
|
onExportDtl: onExportDtl,
|
|
836
|
-
isAudit: isAudit
|
|
964
|
+
isAudit: isAudit,
|
|
965
|
+
onAudit: onAudit
|
|
837
966
|
};
|
|
838
967
|
}
|
|
839
968
|
|
|
@@ -190,6 +190,11 @@ function useSingle(inParam) {
|
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
if (isAudit(row)) {
|
|
194
|
+
showWarn('选择中数据中有已审核,不能删除!');
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
193
198
|
showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
194
199
|
var rows, ids, _result$flag, result;
|
|
195
200
|
|
|
@@ -297,48 +302,62 @@ function useSingle(inParam) {
|
|
|
297
302
|
return _context4.abrupt("return");
|
|
298
303
|
|
|
299
304
|
case 3:
|
|
305
|
+
if (!isAudit(row)) {
|
|
306
|
+
_context4.next = 6;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
showWarn('选择中数据中有已审核,不能再次进行操作!');
|
|
311
|
+
return _context4.abrupt("return");
|
|
312
|
+
|
|
313
|
+
case 6:
|
|
300
314
|
rows = (row ? [row] : selectedRows).map(function (o) {
|
|
301
|
-
|
|
302
|
-
|
|
315
|
+
var obj = _objectSpread({}, o); //@ts-ignore
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
obj[statusField] = auditStatus;
|
|
319
|
+
return obj;
|
|
320
|
+
}); // beforeAudit 强式终止
|
|
321
|
+
|
|
303
322
|
_context4.t0 = beforeAudit;
|
|
304
323
|
|
|
305
324
|
if (!_context4.t0) {
|
|
306
|
-
_context4.next =
|
|
325
|
+
_context4.next = 13;
|
|
307
326
|
break;
|
|
308
327
|
}
|
|
309
328
|
|
|
310
|
-
_context4.next =
|
|
329
|
+
_context4.next = 11;
|
|
311
330
|
return beforeAudit(rows);
|
|
312
331
|
|
|
313
|
-
case
|
|
332
|
+
case 11:
|
|
314
333
|
_context4.t1 = _context4.sent;
|
|
315
334
|
_context4.t0 = _context4.t1 === false;
|
|
316
335
|
|
|
317
|
-
case
|
|
336
|
+
case 13:
|
|
318
337
|
if (!_context4.t0) {
|
|
319
|
-
_context4.next =
|
|
338
|
+
_context4.next = 15;
|
|
320
339
|
break;
|
|
321
340
|
}
|
|
322
341
|
|
|
323
342
|
return _context4.abrupt("return");
|
|
324
343
|
|
|
325
|
-
case
|
|
326
|
-
_context4.prev =
|
|
327
|
-
_context4.next =
|
|
344
|
+
case 15:
|
|
345
|
+
_context4.prev = 15;
|
|
346
|
+
_context4.next = 18;
|
|
328
347
|
return service.audit(rows);
|
|
329
348
|
|
|
330
|
-
case
|
|
349
|
+
case 18:
|
|
331
350
|
result = _context4.sent;
|
|
332
351
|
|
|
333
352
|
if (!afterAudit) {
|
|
334
|
-
_context4.next =
|
|
353
|
+
_context4.next = 22;
|
|
335
354
|
break;
|
|
336
355
|
}
|
|
337
356
|
|
|
338
357
|
afterAudit(result, rows);
|
|
339
358
|
return _context4.abrupt("return");
|
|
340
359
|
|
|
341
|
-
case
|
|
360
|
+
case 22:
|
|
342
361
|
if ((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0') {
|
|
343
362
|
showSuccess(result.flag.retMsg);
|
|
344
363
|
|
|
@@ -347,20 +366,20 @@ function useSingle(inParam) {
|
|
|
347
366
|
}
|
|
348
367
|
}
|
|
349
368
|
|
|
350
|
-
_context4.next =
|
|
369
|
+
_context4.next = 28;
|
|
351
370
|
break;
|
|
352
371
|
|
|
353
|
-
case
|
|
354
|
-
_context4.prev =
|
|
355
|
-
_context4.t2 = _context4["catch"](
|
|
372
|
+
case 25:
|
|
373
|
+
_context4.prev = 25;
|
|
374
|
+
_context4.t2 = _context4["catch"](15);
|
|
356
375
|
console.log(_context4.t2);
|
|
357
376
|
|
|
358
|
-
case
|
|
377
|
+
case 28:
|
|
359
378
|
case "end":
|
|
360
379
|
return _context4.stop();
|
|
361
380
|
}
|
|
362
381
|
}
|
|
363
|
-
}, _callee4, null, [[
|
|
382
|
+
}, _callee4, null, [[15, 25]]);
|
|
364
383
|
}));
|
|
365
384
|
|
|
366
385
|
return function onAudit(_x3) {
|
|
@@ -621,14 +640,23 @@ function useSingle(inParam) {
|
|
|
621
640
|
return false;
|
|
622
641
|
}
|
|
623
642
|
};
|
|
643
|
+
/** 判断是否已审核,只有传入审核状态和状态字段才进行判断 */
|
|
644
|
+
|
|
624
645
|
|
|
625
646
|
var isAudit = useCallback(function () {
|
|
647
|
+
var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
626
648
|
if (!auditStatus || !statusField) return false;
|
|
627
|
-
if (!selectedRows.length) return false;
|
|
649
|
+
if (!row && !selectedRows.length) return false;
|
|
650
|
+
|
|
651
|
+
if (row) {
|
|
652
|
+
return Number(row[statusField] || 0) >= auditStatus;
|
|
653
|
+
}
|
|
654
|
+
|
|
628
655
|
return selectedRows.findIndex(function (o) {
|
|
629
656
|
return Number(o[statusField] || 0) >= auditStatus;
|
|
630
657
|
}) > -1;
|
|
631
|
-
}, [auditStatus, statusField, selectedRows]);
|
|
658
|
+
}, [auditStatus, statusField, selectedRows]); // 处理内置 table 按钮,新增,编辑,删除,审核,导入,导出
|
|
659
|
+
|
|
632
660
|
var tableTools = useMemo(function () {
|
|
633
661
|
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && checkRight(2) ? /*#__PURE__*/React.createElement(_Button, {
|
|
634
662
|
key: "add",
|
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
|
-
|
|
12
|
+
import usePermission from './hooks/usePermission';
|
|
13
|
+
export { DtlLayout, InputTable, Page404, Loading, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission };
|
|
@@ -157,9 +157,9 @@ var BaseService = /*#__PURE__*/function () {
|
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
_message.error("
|
|
160
|
+
_message.error("删除方法没有配置api");
|
|
161
161
|
|
|
162
|
-
return _context3.abrupt("return", Promise.reject("
|
|
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