@ccs-ui/rc-pro 1.1.2 → 1.1.4
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/dialog/HookDrawer.js +7 -5
- package/es/dialog/HookModal.d.ts +3 -1
- package/es/dialog/HookModal.js +14 -17
- package/es/dialog/hook.d.ts +4 -0
- package/package.json +1 -1
package/es/dialog/HookDrawer.js
CHANGED
|
@@ -19,7 +19,7 @@ import { DialogContentContext } from "./context";
|
|
|
19
19
|
import DialogForm from "./form";
|
|
20
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
21
|
var HookDrawer = function HookDrawer(_ref, ref) {
|
|
22
|
-
var _config$form, _innerConfig$styles;
|
|
22
|
+
var _config$form, _config$form2, _innerConfig$styles;
|
|
23
23
|
var hookAfterClose = _ref.afterClose,
|
|
24
24
|
config = _ref.config;
|
|
25
25
|
var _useState = useState(function () {
|
|
@@ -101,11 +101,13 @@ var HookDrawer = function HookDrawer(_ref, ref) {
|
|
|
101
101
|
position: 'absolute'
|
|
102
102
|
} : {}), innerConfig.rootStyle),
|
|
103
103
|
getContainer: isCrInProp ? innerConfig.getContainer : onGetContainer,
|
|
104
|
-
extra:
|
|
105
|
-
request:
|
|
104
|
+
extra: config.request ? /*#__PURE__*/_jsx(DialogSelfButton, {
|
|
105
|
+
request: config.request,
|
|
106
106
|
onCancel: close,
|
|
107
107
|
formRef: formRef,
|
|
108
|
-
onRequestBefore:
|
|
108
|
+
onRequestBefore: config.onRequestBefore,
|
|
109
|
+
auth: config.auth,
|
|
110
|
+
formInitialValues: (_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.initialValues
|
|
109
111
|
}) : /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
110
112
|
ref: buttonRef
|
|
111
113
|
}),
|
|
@@ -118,7 +120,7 @@ var HookDrawer = function HookDrawer(_ref, ref) {
|
|
|
118
120
|
buttonType: 'drawer',
|
|
119
121
|
closeDialog: close,
|
|
120
122
|
drawerFooterRef: footerRef,
|
|
121
|
-
formInitialValues: ((_config$
|
|
123
|
+
formInitialValues: ((_config$form2 = config.form) === null || _config$form2 === void 0 ? void 0 : _config$form2.initialValues) || {}
|
|
122
124
|
},
|
|
123
125
|
children: config.form ? /*#__PURE__*/_jsx(DialogForm, {
|
|
124
126
|
ref: formRef,
|
package/es/dialog/HookModal.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { FormProps } from 'antd';
|
|
2
3
|
import { DialogFormRef } from './form';
|
|
3
4
|
import { CcsDialogModal, CcsDialogModalProps } from './hook';
|
|
4
|
-
export declare const DialogSelfButton: ({ formRef, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "request" | "onCancel" | "onRequestBefore"> & {
|
|
5
|
+
export declare const DialogSelfButton: ({ auth, formRef, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "request" | "onCancel" | "onRequestBefore"> & {
|
|
5
6
|
formRef: React.RefObject<DialogFormRef>;
|
|
7
|
+
formInitialValues: FormProps['initialValues'];
|
|
6
8
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
9
|
export interface HookModalProps {
|
|
8
10
|
afterClose: () => void;
|
package/es/dialog/HookModal.js
CHANGED
|
@@ -14,7 +14,7 @@ import { Button, Modal } from 'antd';
|
|
|
14
14
|
import classNames from 'classnames';
|
|
15
15
|
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
16
16
|
import Draggable from 'react-draggable';
|
|
17
|
-
import { CcsDialog, CcsUtils } from '..';
|
|
17
|
+
import { CcsAuth, CcsDialog, CcsUtils } from '..';
|
|
18
18
|
import { DialogButtonHolder } from "./button";
|
|
19
19
|
import { DialogContentContext } from "./context";
|
|
20
20
|
import DialogForm from "./form";
|
|
@@ -59,7 +59,10 @@ var DragModal = function DragModal(_ref) {
|
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
export var DialogSelfButton = function DialogSelfButton(_ref2) {
|
|
62
|
-
var
|
|
62
|
+
var auth = _ref2.auth,
|
|
63
|
+
formRef = _ref2.formRef,
|
|
64
|
+
_ref2$formInitialValu = _ref2.formInitialValues,
|
|
65
|
+
formInitialValues = _ref2$formInitialValu === void 0 ? {} : _ref2$formInitialValu,
|
|
63
66
|
request = _ref2.request,
|
|
64
67
|
onCancel = _ref2.onCancel,
|
|
65
68
|
onRequestBefore = _ref2.onRequestBefore;
|
|
@@ -75,7 +78,7 @@ export var DialogSelfButton = function DialogSelfButton(_ref2) {
|
|
|
75
78
|
}
|
|
76
79
|
formRef.current.formInstance.validateFields().then(function (values) {
|
|
77
80
|
setLoading(true);
|
|
78
|
-
var params = onRequestBefore ? onRequestBefore(values) : values;
|
|
81
|
+
var params = _objectSpread(_objectSpread({}, formInitialValues), onRequestBefore ? onRequestBefore(values) : values);
|
|
79
82
|
request(params).then(function (d) {
|
|
80
83
|
setLoading(false);
|
|
81
84
|
if (d !== null && d !== void 0 && d.success && onCancel) {
|
|
@@ -87,15 +90,13 @@ export var DialogSelfButton = function DialogSelfButton(_ref2) {
|
|
|
87
90
|
console.log('e', err);
|
|
88
91
|
});
|
|
89
92
|
});
|
|
90
|
-
|
|
91
|
-
// request
|
|
92
93
|
};
|
|
93
|
-
|
|
94
94
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
95
95
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
96
96
|
onClick: onCancel,
|
|
97
97
|
children: "\u53D6\u6D88"
|
|
98
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
98
|
+
}), /*#__PURE__*/_jsx(CcsAuth.Button, {
|
|
99
|
+
auth: auth || '',
|
|
99
100
|
type: "primary",
|
|
100
101
|
onClick: onOk,
|
|
101
102
|
loading: loading,
|
|
@@ -104,7 +105,7 @@ export var DialogSelfButton = function DialogSelfButton(_ref2) {
|
|
|
104
105
|
});
|
|
105
106
|
};
|
|
106
107
|
var HookModal = function HookModal(_ref3, ref) {
|
|
107
|
-
var _config$form;
|
|
108
|
+
var _config$form, _config$form2;
|
|
108
109
|
var hookAfterClose = _ref3.afterClose,
|
|
109
110
|
config = _ref3.config;
|
|
110
111
|
var _useState3 = useState(function () {
|
|
@@ -186,20 +187,16 @@ var HookModal = function HookModal(_ref3, ref) {
|
|
|
186
187
|
padding: '8px 16px'
|
|
187
188
|
},
|
|
188
189
|
children: /*#__PURE__*/_jsx(DialogSelfButton, {
|
|
189
|
-
|
|
190
|
+
auth: config.auth,
|
|
191
|
+
request: config.request,
|
|
190
192
|
onCancel: close,
|
|
191
193
|
formRef: formRef,
|
|
192
|
-
onRequestBefore:
|
|
194
|
+
onRequestBefore: config.onRequestBefore,
|
|
195
|
+
formInitialValues: (_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.initialValues
|
|
193
196
|
})
|
|
194
197
|
}) : /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
195
198
|
ref: buttonRef
|
|
196
199
|
}),
|
|
197
|
-
onOk: function onOk() {
|
|
198
|
-
// 传入request,onOk触发请求
|
|
199
|
-
if (innerConfig.request) {
|
|
200
|
-
console.log(111);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
200
|
title: /*#__PURE__*/_jsx("div", {
|
|
204
201
|
style: {
|
|
205
202
|
width: '100%',
|
|
@@ -235,7 +232,7 @@ var HookModal = function HookModal(_ref3, ref) {
|
|
|
235
232
|
buttonRef: buttonRef,
|
|
236
233
|
buttonType: 'modal',
|
|
237
234
|
closeDialog: close,
|
|
238
|
-
formInitialValues: ((_config$
|
|
235
|
+
formInitialValues: ((_config$form2 = config.form) === null || _config$form2 === void 0 ? void 0 : _config$form2.initialValues) || {}
|
|
239
236
|
},
|
|
240
237
|
children: config.form ? /*#__PURE__*/_jsx(DialogForm, {
|
|
241
238
|
ref: formRef,
|
package/es/dialog/hook.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ type DrawerFunc = (props: DrawerProps) => {
|
|
|
20
20
|
export type CcsDialogModalProps = ModalFuncProps & {
|
|
21
21
|
/** antd form */
|
|
22
22
|
form?: FormProps;
|
|
23
|
+
/** 表单接口请求权限 */
|
|
24
|
+
auth?: string;
|
|
23
25
|
/** 表单接口请求 */
|
|
24
26
|
request?: (values: any) => Promise<CCS.HttpResult>;
|
|
25
27
|
/** request执行前参数处理 */
|
|
@@ -34,6 +36,8 @@ export type CcsDialogModalProps = ModalFuncProps & {
|
|
|
34
36
|
export type CcsDialogDrawerProps = Omit<DrawerProps, 'extra'> & {
|
|
35
37
|
/** antd form */
|
|
36
38
|
form?: FormProps;
|
|
39
|
+
/** 表单接口请求权限 */
|
|
40
|
+
auth?: string;
|
|
37
41
|
/** 抽屉内容 */
|
|
38
42
|
content?: ReactNode;
|
|
39
43
|
/** 表单接口请求 */
|