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;
|
|
@@ -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 =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (props.onSave) {
|
|
52
|
+
return props.onSave();
|
|
53
|
+
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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:
|
|
150
|
+
labelWidth: labelWidth
|
|
149
151
|
},
|
|
150
152
|
options: {
|
|
151
153
|
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;
|
|
@@ -51,7 +51,9 @@ function useDtl(dtlParam) {
|
|
|
51
51
|
beforeRemove = dtlParam.beforeRemove,
|
|
52
52
|
afterSave = dtlParam.afterSave,
|
|
53
53
|
afterRemove = dtlParam.afterRemove,
|
|
54
|
-
btnStatus = dtlParam.btnStatus
|
|
54
|
+
btnStatus = dtlParam.btnStatus,
|
|
55
|
+
beforeAudit = dtlParam.beforeAudit,
|
|
56
|
+
afterAudit = dtlParam.afterAudit;
|
|
55
57
|
/** @name 选中行数据 */
|
|
56
58
|
|
|
57
59
|
var _useState = (0, _react.useState)([]),
|
|
@@ -202,73 +204,82 @@ function useDtl(dtlParam) {
|
|
|
202
204
|
return _context2.abrupt("return", false);
|
|
203
205
|
|
|
204
206
|
case 2:
|
|
205
|
-
|
|
207
|
+
if (!isAudit()) {
|
|
208
|
+
_context2.next = 5;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
(0, _utils.showWarn)('当前单据已审核,不能删除');
|
|
213
|
+
return _context2.abrupt("return", false);
|
|
214
|
+
|
|
215
|
+
case 5:
|
|
216
|
+
_context2.next = 7;
|
|
206
217
|
return (0, _utils.showConfirm)('确认要删除当前数据?');
|
|
207
218
|
|
|
208
|
-
case
|
|
219
|
+
case 7:
|
|
209
220
|
if (!beforeRemove) {
|
|
210
|
-
_context2.next =
|
|
221
|
+
_context2.next = 13;
|
|
211
222
|
break;
|
|
212
223
|
}
|
|
213
224
|
|
|
214
|
-
_context2.next =
|
|
225
|
+
_context2.next = 10;
|
|
215
226
|
return beforeRemove([masterObject]);
|
|
216
227
|
|
|
217
|
-
case
|
|
228
|
+
case 10:
|
|
218
229
|
ids = _context2.sent;
|
|
219
230
|
|
|
220
231
|
if (!(ids === false)) {
|
|
221
|
-
_context2.next =
|
|
232
|
+
_context2.next = 13;
|
|
222
233
|
break;
|
|
223
234
|
}
|
|
224
235
|
|
|
225
236
|
return _context2.abrupt("return", false);
|
|
226
237
|
|
|
227
|
-
case
|
|
238
|
+
case 13:
|
|
228
239
|
if (!ids) {
|
|
229
240
|
ids = [masterObject[mstKeyField]];
|
|
230
241
|
}
|
|
231
242
|
|
|
232
|
-
_context2.next =
|
|
243
|
+
_context2.next = 16;
|
|
233
244
|
return mstService.remove(ids);
|
|
234
245
|
|
|
235
|
-
case
|
|
246
|
+
case 16:
|
|
236
247
|
result = _context2.sent;
|
|
237
248
|
_context2.t0 = afterRemove;
|
|
238
249
|
|
|
239
250
|
if (!_context2.t0) {
|
|
240
|
-
_context2.next =
|
|
251
|
+
_context2.next = 23;
|
|
241
252
|
break;
|
|
242
253
|
}
|
|
243
254
|
|
|
244
|
-
_context2.next =
|
|
255
|
+
_context2.next = 21;
|
|
245
256
|
return afterRemove(result, masterObject);
|
|
246
257
|
|
|
247
|
-
case
|
|
258
|
+
case 21:
|
|
248
259
|
_context2.t1 = _context2.sent;
|
|
249
260
|
_context2.t0 = _context2.t1 === false;
|
|
250
261
|
|
|
251
|
-
case
|
|
262
|
+
case 23:
|
|
252
263
|
if (!_context2.t0) {
|
|
253
|
-
_context2.next =
|
|
264
|
+
_context2.next = 25;
|
|
254
265
|
break;
|
|
255
266
|
}
|
|
256
267
|
|
|
257
268
|
return _context2.abrupt("return");
|
|
258
269
|
|
|
259
|
-
case
|
|
270
|
+
case 25:
|
|
260
271
|
if (!((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0')) {
|
|
261
|
-
_context2.next =
|
|
272
|
+
_context2.next = 28;
|
|
262
273
|
break;
|
|
263
274
|
}
|
|
264
275
|
|
|
265
276
|
(0, _utils.showSuccess)(result.flag.retMsg);
|
|
266
277
|
return _context2.abrupt("return", true);
|
|
267
278
|
|
|
268
|
-
case
|
|
279
|
+
case 28:
|
|
269
280
|
return _context2.abrupt("return", false);
|
|
270
281
|
|
|
271
|
-
case
|
|
282
|
+
case 29:
|
|
272
283
|
case "end":
|
|
273
284
|
return _context2.stop();
|
|
274
285
|
}
|
|
@@ -777,6 +788,105 @@ function useDtl(dtlParam) {
|
|
|
777
788
|
return _ref8.apply(this, arguments);
|
|
778
789
|
};
|
|
779
790
|
}();
|
|
791
|
+
/** 审核按钮事件 */
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
var onAudit = /*#__PURE__*/function () {
|
|
795
|
+
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
796
|
+
var obj, _result$flag8, result;
|
|
797
|
+
|
|
798
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
799
|
+
while (1) {
|
|
800
|
+
switch (_context9.prev = _context9.next) {
|
|
801
|
+
case 0:
|
|
802
|
+
if (!isAudit()) {
|
|
803
|
+
_context9.next = 3;
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
(0, _utils.showWarn)('当前数据已审核,不能再做审核操作!');
|
|
808
|
+
return _context9.abrupt("return");
|
|
809
|
+
|
|
810
|
+
case 3:
|
|
811
|
+
obj = (0, _objectSpread2.default)({}, masterObject); // beforeAudit 强式终止
|
|
812
|
+
|
|
813
|
+
_context9.t0 = beforeAudit;
|
|
814
|
+
|
|
815
|
+
if (!_context9.t0) {
|
|
816
|
+
_context9.next = 10;
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
_context9.next = 8;
|
|
821
|
+
return beforeAudit(obj);
|
|
822
|
+
|
|
823
|
+
case 8:
|
|
824
|
+
_context9.t1 = _context9.sent;
|
|
825
|
+
_context9.t0 = _context9.t1 === false;
|
|
826
|
+
|
|
827
|
+
case 10:
|
|
828
|
+
if (!_context9.t0) {
|
|
829
|
+
_context9.next = 12;
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
return _context9.abrupt("return");
|
|
834
|
+
|
|
835
|
+
case 12:
|
|
836
|
+
_context9.prev = 12;
|
|
837
|
+
_context9.next = 15;
|
|
838
|
+
return mstService.audit([obj]);
|
|
839
|
+
|
|
840
|
+
case 15:
|
|
841
|
+
result = _context9.sent;
|
|
842
|
+
_context9.t2 = afterAudit;
|
|
843
|
+
|
|
844
|
+
if (!_context9.t2) {
|
|
845
|
+
_context9.next = 22;
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
_context9.next = 20;
|
|
850
|
+
return afterAudit(result, [obj]);
|
|
851
|
+
|
|
852
|
+
case 20:
|
|
853
|
+
_context9.t3 = _context9.sent;
|
|
854
|
+
_context9.t2 = _context9.t3 === false;
|
|
855
|
+
|
|
856
|
+
case 22:
|
|
857
|
+
if (!_context9.t2) {
|
|
858
|
+
_context9.next = 24;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
return _context9.abrupt("return");
|
|
863
|
+
|
|
864
|
+
case 24:
|
|
865
|
+
if ((result === null || result === void 0 ? void 0 : (_result$flag8 = result.flag) === null || _result$flag8 === void 0 ? void 0 : _result$flag8.retCode) === '0') {
|
|
866
|
+
(0, _utils.showSuccess)(result.flag.retMsg);
|
|
867
|
+
Object.assign(masterObject, result.data);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
_context9.next = 30;
|
|
871
|
+
break;
|
|
872
|
+
|
|
873
|
+
case 27:
|
|
874
|
+
_context9.prev = 27;
|
|
875
|
+
_context9.t4 = _context9["catch"](12);
|
|
876
|
+
console.log(_context9.t4);
|
|
877
|
+
|
|
878
|
+
case 30:
|
|
879
|
+
case "end":
|
|
880
|
+
return _context9.stop();
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}, _callee9, null, [[12, 27]]);
|
|
884
|
+
}));
|
|
885
|
+
|
|
886
|
+
return function onAudit() {
|
|
887
|
+
return _ref9.apply(this, arguments);
|
|
888
|
+
};
|
|
889
|
+
}();
|
|
780
890
|
|
|
781
891
|
var btnDisabled = function btnDisabled(key) {
|
|
782
892
|
if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
|
|
@@ -793,6 +903,28 @@ function useDtl(dtlParam) {
|
|
|
793
903
|
}
|
|
794
904
|
};
|
|
795
905
|
|
|
906
|
+
var onExport = function onExport() {
|
|
907
|
+
var _tableRef$current, _tableRef$current$sho;
|
|
908
|
+
|
|
909
|
+
if (!masterObject[mstKeyField]) {
|
|
910
|
+
(0, _utils.showWarn)('主表没保存,无法导出数据');
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
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);
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
var onImport = function onImport() {
|
|
918
|
+
var _tableRef$current2, _tableRef$current2$sh;
|
|
919
|
+
|
|
920
|
+
if (!masterObject[mstKeyField]) {
|
|
921
|
+
(0, _utils.showWarn)('主表没保存,无法导入数据');
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
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);
|
|
926
|
+
};
|
|
927
|
+
|
|
796
928
|
var tableTools = (0, _react.useMemo)(function () {
|
|
797
929
|
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
798
930
|
key: "add",
|
|
@@ -818,17 +950,13 @@ function useDtl(dtlParam) {
|
|
|
818
950
|
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
819
951
|
key: "import",
|
|
820
952
|
onClick: function onClick() {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
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);
|
|
953
|
+
onImport();
|
|
824
954
|
},
|
|
825
955
|
icon: /*#__PURE__*/_react.default.createElement(_icons.ImportOutlined, null)
|
|
826
956
|
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
827
957
|
key: "export",
|
|
828
958
|
onClick: function onClick() {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
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);
|
|
959
|
+
onExport();
|
|
832
960
|
},
|
|
833
961
|
icon: /*#__PURE__*/_react.default.createElement(_icons.ExportOutlined, null)
|
|
834
962
|
}, "\u5BFC\u51FA") : false].filter(function (o) {
|
|
@@ -854,7 +982,8 @@ function useDtl(dtlParam) {
|
|
|
854
982
|
onSaveMst: onSaveMst,
|
|
855
983
|
onRemoveMst: onRemoveMst,
|
|
856
984
|
onExportDtl: onExportDtl,
|
|
857
|
-
isAudit: isAudit
|
|
985
|
+
isAudit: isAudit,
|
|
986
|
+
onAudit: onAudit
|
|
858
987
|
};
|
|
859
988
|
}
|
|
860
989
|
|
|
@@ -212,6 +212,11 @@ function useSingle(inParam) {
|
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
if (isAudit(row)) {
|
|
216
|
+
(0, _utils.showWarn)('选择中数据中有已审核,不能删除!');
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
215
220
|
(0, _utils.showConfirm)('确认要删除选择的数据?').then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
216
221
|
var rows, ids, _result$flag, result;
|
|
217
222
|
|
|
@@ -319,48 +324,61 @@ function useSingle(inParam) {
|
|
|
319
324
|
return _context4.abrupt("return");
|
|
320
325
|
|
|
321
326
|
case 3:
|
|
327
|
+
if (!isAudit(row)) {
|
|
328
|
+
_context4.next = 6;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
(0, _utils.showWarn)('选择中数据中有已审核,不能再次进行操作!');
|
|
333
|
+
return _context4.abrupt("return");
|
|
334
|
+
|
|
335
|
+
case 6:
|
|
322
336
|
rows = (row ? [row] : selectedRows).map(function (o) {
|
|
323
|
-
|
|
324
|
-
|
|
337
|
+
var obj = (0, _objectSpread2.default)({}, o); //@ts-ignore
|
|
338
|
+
|
|
339
|
+
obj[statusField] = auditStatus;
|
|
340
|
+
return obj;
|
|
341
|
+
}); // beforeAudit 强式终止
|
|
342
|
+
|
|
325
343
|
_context4.t0 = beforeAudit;
|
|
326
344
|
|
|
327
345
|
if (!_context4.t0) {
|
|
328
|
-
_context4.next =
|
|
346
|
+
_context4.next = 13;
|
|
329
347
|
break;
|
|
330
348
|
}
|
|
331
349
|
|
|
332
|
-
_context4.next =
|
|
350
|
+
_context4.next = 11;
|
|
333
351
|
return beforeAudit(rows);
|
|
334
352
|
|
|
335
|
-
case
|
|
353
|
+
case 11:
|
|
336
354
|
_context4.t1 = _context4.sent;
|
|
337
355
|
_context4.t0 = _context4.t1 === false;
|
|
338
356
|
|
|
339
|
-
case
|
|
357
|
+
case 13:
|
|
340
358
|
if (!_context4.t0) {
|
|
341
|
-
_context4.next =
|
|
359
|
+
_context4.next = 15;
|
|
342
360
|
break;
|
|
343
361
|
}
|
|
344
362
|
|
|
345
363
|
return _context4.abrupt("return");
|
|
346
364
|
|
|
347
|
-
case
|
|
348
|
-
_context4.prev =
|
|
349
|
-
_context4.next =
|
|
365
|
+
case 15:
|
|
366
|
+
_context4.prev = 15;
|
|
367
|
+
_context4.next = 18;
|
|
350
368
|
return service.audit(rows);
|
|
351
369
|
|
|
352
|
-
case
|
|
370
|
+
case 18:
|
|
353
371
|
result = _context4.sent;
|
|
354
372
|
|
|
355
373
|
if (!afterAudit) {
|
|
356
|
-
_context4.next =
|
|
374
|
+
_context4.next = 22;
|
|
357
375
|
break;
|
|
358
376
|
}
|
|
359
377
|
|
|
360
378
|
afterAudit(result, rows);
|
|
361
379
|
return _context4.abrupt("return");
|
|
362
380
|
|
|
363
|
-
case
|
|
381
|
+
case 22:
|
|
364
382
|
if ((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0') {
|
|
365
383
|
(0, _utils.showSuccess)(result.flag.retMsg);
|
|
366
384
|
|
|
@@ -369,20 +387,20 @@ function useSingle(inParam) {
|
|
|
369
387
|
}
|
|
370
388
|
}
|
|
371
389
|
|
|
372
|
-
_context4.next =
|
|
390
|
+
_context4.next = 28;
|
|
373
391
|
break;
|
|
374
392
|
|
|
375
|
-
case
|
|
376
|
-
_context4.prev =
|
|
377
|
-
_context4.t2 = _context4["catch"](
|
|
393
|
+
case 25:
|
|
394
|
+
_context4.prev = 25;
|
|
395
|
+
_context4.t2 = _context4["catch"](15);
|
|
378
396
|
console.log(_context4.t2);
|
|
379
397
|
|
|
380
|
-
case
|
|
398
|
+
case 28:
|
|
381
399
|
case "end":
|
|
382
400
|
return _context4.stop();
|
|
383
401
|
}
|
|
384
402
|
}
|
|
385
|
-
}, _callee4, null, [[
|
|
403
|
+
}, _callee4, null, [[15, 25]]);
|
|
386
404
|
}));
|
|
387
405
|
|
|
388
406
|
return function onAudit(_x3) {
|
|
@@ -643,14 +661,23 @@ function useSingle(inParam) {
|
|
|
643
661
|
return false;
|
|
644
662
|
}
|
|
645
663
|
};
|
|
664
|
+
/** 判断是否已审核,只有传入审核状态和状态字段才进行判断 */
|
|
665
|
+
|
|
646
666
|
|
|
647
667
|
var isAudit = (0, _react.useCallback)(function () {
|
|
668
|
+
var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
648
669
|
if (!auditStatus || !statusField) return false;
|
|
649
|
-
if (!selectedRows.length) return false;
|
|
670
|
+
if (!row && !selectedRows.length) return false;
|
|
671
|
+
|
|
672
|
+
if (row) {
|
|
673
|
+
return Number(row[statusField] || 0) >= auditStatus;
|
|
674
|
+
}
|
|
675
|
+
|
|
650
676
|
return selectedRows.findIndex(function (o) {
|
|
651
677
|
return Number(o[statusField] || 0) >= auditStatus;
|
|
652
678
|
}) > -1;
|
|
653
|
-
}, [auditStatus, statusField, selectedRows]);
|
|
679
|
+
}, [auditStatus, statusField, selectedRows]); // 处理内置 table 按钮,新增,编辑,删除,审核,导入,导出
|
|
680
|
+
|
|
654
681
|
var tableTools = (0, _react.useMemo)(function () {
|
|
655
682
|
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && checkRight(2) ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
656
683
|
key: "add",
|
package/lib/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/lib/index.js
CHANGED
|
@@ -85,6 +85,12 @@ Object.defineProperty(exports, "useDtl", {
|
|
|
85
85
|
return _useDtl.default;
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
+
Object.defineProperty(exports, "usePermission", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function get() {
|
|
91
|
+
return _usePermission.default;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
88
94
|
Object.defineProperty(exports, "useSingle", {
|
|
89
95
|
enumerable: true,
|
|
90
96
|
get: function get() {
|
|
@@ -111,4 +117,6 @@ exports.utils = utils;
|
|
|
111
117
|
|
|
112
118
|
var _useSingle = _interopRequireDefault(require("./hooks/useSingle"));
|
|
113
119
|
|
|
114
|
-
var _useDtl = _interopRequireDefault(require("./hooks/useDtl"));
|
|
120
|
+
var _useDtl = _interopRequireDefault(require("./hooks/useDtl"));
|
|
121
|
+
|
|
122
|
+
var _usePermission = _interopRequireDefault(require("./hooks/usePermission"));
|
|
@@ -171,9 +171,9 @@ var BaseService = /*#__PURE__*/function () {
|
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
_message2.default.error("
|
|
174
|
+
_message2.default.error("删除方法没有配置api");
|
|
175
175
|
|
|
176
|
-
return _context3.abrupt("return", Promise.reject("
|
|
176
|
+
return _context3.abrupt("return", Promise.reject("删除方法没有配置api"));
|
|
177
177
|
|
|
178
178
|
case 4:
|
|
179
179
|
if (!(this.method.delete === 'post')) {
|
|
@@ -208,6 +208,49 @@ var BaseService = /*#__PURE__*/function () {
|
|
|
208
208
|
|
|
209
209
|
return remove;
|
|
210
210
|
}()
|
|
211
|
+
}, {
|
|
212
|
+
key: "audit",
|
|
213
|
+
value: function () {
|
|
214
|
+
var _audit = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(data) {
|
|
215
|
+
var _this$api4;
|
|
216
|
+
|
|
217
|
+
var url;
|
|
218
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
219
|
+
while (1) {
|
|
220
|
+
switch (_context4.prev = _context4.next) {
|
|
221
|
+
case 0:
|
|
222
|
+
url = (_this$api4 = this.api) === null || _this$api4 === void 0 ? void 0 : _this$api4.audit;
|
|
223
|
+
|
|
224
|
+
if (url) {
|
|
225
|
+
_context4.next = 4;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
_message2.default.error("审核方法没有配置api");
|
|
230
|
+
|
|
231
|
+
return _context4.abrupt("return", Promise.reject("审核方法没有配置api"));
|
|
232
|
+
|
|
233
|
+
case 4:
|
|
234
|
+
_context4.next = 6;
|
|
235
|
+
return (0, _http.httpPost)(url, data);
|
|
236
|
+
|
|
237
|
+
case 6:
|
|
238
|
+
return _context4.abrupt("return", _context4.sent);
|
|
239
|
+
|
|
240
|
+
case 7:
|
|
241
|
+
case "end":
|
|
242
|
+
return _context4.stop();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}, _callee4, this);
|
|
246
|
+
}));
|
|
247
|
+
|
|
248
|
+
function audit(_x4) {
|
|
249
|
+
return _audit.apply(this, arguments);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return audit;
|
|
253
|
+
}()
|
|
211
254
|
}]);
|
|
212
255
|
return BaseService;
|
|
213
256
|
}();
|
package/lib/typing.d.ts
CHANGED
package/lib/utils/index.js
CHANGED