@vtx/components 3.1.47 → 3.1.49
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/lib/_util/useColSize.js.map +1 -1
- package/lib/style/index.less +2 -2
- package/lib/style/themes/compact.less +1 -1
- package/lib/style/themes/dark.less +9 -9
- package/lib/style/themes/default.less +7 -7
- package/lib/style/themes/index.less +1 -1
- package/lib/style/themes/variable.less +5 -5
- package/lib/vtx-color-picker/index.js.map +1 -1
- package/lib/vtx-color-picker/style/css.js.map +1 -1
- package/lib/vtx-color-picker/style/index.js.map +1 -1
- package/lib/vtx-combogrid/Combogrid.js.map +1 -1
- package/lib/vtx-combogrid/index.js.map +1 -1
- package/lib/vtx-combogrid/style/css.js.map +1 -1
- package/lib/vtx-combogrid/style/index.js.map +1 -1
- package/lib/vtx-combogrid/style/index.less +29 -29
- package/lib/vtx-datagrid/Alert.js.map +1 -1
- package/lib/vtx-datagrid/ColumnSetting.js.map +1 -1
- package/lib/vtx-datagrid/index.js.map +1 -1
- package/lib/vtx-datagrid/renderColumnButtons.js.map +1 -1
- package/lib/vtx-datagrid/style/css.js.map +1 -1
- package/lib/vtx-datagrid/style/index.js.map +1 -1
- package/lib/vtx-date-picker/QdatePicker.js.map +1 -1
- package/lib/vtx-date-picker/generatePicker.js.map +1 -1
- package/lib/vtx-date-picker/index.js.map +1 -1
- package/lib/vtx-date-picker/style/css.js.map +1 -1
- package/lib/vtx-date-picker/style/index.js.map +1 -1
- package/lib/vtx-date-picker/style/index.less +39 -39
- package/lib/vtx-editor/index.js.map +1 -1
- package/lib/vtx-editor/style/css.js.map +1 -1
- package/lib/vtx-editor/style/index.js.map +1 -1
- package/lib/vtx-editor/style/index.less +8 -8
- package/lib/vtx-ellipsis-text/index.js.map +1 -1
- package/lib/vtx-ellipsis-text/style/css.js.map +1 -1
- package/lib/vtx-ellipsis-text/style/index.js.map +1 -1
- package/lib/vtx-ellipsis-text/style/index.less +13 -13
- package/lib/vtx-export/style/css.js.map +1 -1
- package/lib/vtx-export/style/index.js.map +1 -1
- package/lib/vtx-form-layout/Card.js.map +1 -1
- package/lib/vtx-form-layout/Divider.js.map +1 -1
- package/lib/vtx-form-layout/FormItem.js.map +1 -1
- package/lib/vtx-form-layout/Row.js.map +1 -1
- package/lib/vtx-form-layout/demo/Modal.less +43 -43
- package/lib/vtx-form-layout/index.js.map +1 -1
- package/lib/vtx-form-layout/style/css.js.map +1 -1
- package/lib/vtx-form-layout/style/index.js.map +1 -1
- package/lib/vtx-form-layout/style/index.less +216 -216
- package/lib/vtx-image/Preview.js.map +1 -1
- package/lib/vtx-image/PreviewGroup.js.map +1 -1
- package/lib/vtx-import/result.js.map +1 -1
- package/lib/vtx-import/style/css.js.map +1 -1
- package/lib/vtx-import/style/index.js.map +1 -1
- package/lib/vtx-import/style/index.less +8 -8
- package/lib/vtx-import2/CheckResult.js.map +1 -1
- package/lib/vtx-import2/Content.js.map +1 -1
- package/lib/vtx-import2/DownloadSvg.js.map +1 -1
- package/lib/vtx-import2/ImportResult.js.map +1 -1
- package/lib/vtx-import2/UploadSvg.js.map +1 -1
- package/lib/vtx-import2/style/css.js.map +1 -1
- package/lib/vtx-import2/style/index.js.map +1 -1
- package/lib/vtx-import2/style/index.less +102 -102
- package/lib/vtx-input/TextArea.js.map +1 -1
- package/lib/vtx-input/index.js.map +1 -1
- package/lib/vtx-input/style/css.js.map +1 -1
- package/lib/vtx-input/style/index.js.map +1 -1
- package/lib/vtx-input/style/index.less +24 -24
- package/lib/vtx-modal/index.js +2 -2
- package/lib/vtx-modal/index.js.map +1 -1
- package/lib/vtx-modal/style/css.js.map +1 -1
- package/lib/vtx-modal/style/index.js.map +1 -1
- package/lib/vtx-page-layout/Content.js.map +1 -1
- package/lib/vtx-page-layout/TableLayout.js +10 -10
- package/lib/vtx-page-layout/TableLayout.js.map +1 -1
- package/lib/vtx-page-layout/TableWrap.js.map +1 -1
- package/lib/vtx-page-layout/container.js.map +1 -1
- package/lib/vtx-page-layout/style/index.less +138 -138
- package/lib/vtx-rps-frame/index.js +18 -8
- package/lib/vtx-rps-frame/index.js.map +1 -1
- package/lib/vtx-scrollable-row/index.js.map +1 -1
- package/lib/vtx-scrollable-row/style/css.js.map +1 -1
- package/lib/vtx-scrollable-row/style/index.js.map +1 -1
- package/lib/vtx-scrollable-row/style/index.less +113 -113
- package/lib/vtx-search/VtxCol.js.map +1 -1
- package/lib/vtx-search/VtxRow.js.map +1 -1
- package/lib/vtx-search/index.js.map +1 -1
- package/lib/vtx-search/style/css.js.map +1 -1
- package/lib/vtx-search/style/index.js.map +1 -1
- package/lib/vtx-search/style/index.less +83 -83
- package/lib/vtx-search-map-input/index.js.map +1 -1
- package/lib/vtx-search-map-input/style/css.js.map +1 -1
- package/lib/vtx-search-map-input/style/index.js.map +1 -1
- package/lib/vtx-select/style/css.js.map +1 -1
- package/lib/vtx-select/style/index.js.map +1 -1
- package/lib/vtx-select/style/index.less +68 -68
- package/lib/vtx-signature/index.js.map +1 -1
- package/lib/vtx-signature/style/css.js.map +1 -1
- package/lib/vtx-signature/style/index.js.map +1 -1
- package/lib/vtx-signature/style/index.less +33 -33
- package/lib/vtx-split-pane/Resizer.js.map +1 -1
- package/lib/vtx-split-pane/SplitPane.js +4 -4
- package/lib/vtx-split-pane/SplitPane.js.map +1 -1
- package/lib/vtx-split-pane/style/css.js.map +1 -1
- package/lib/vtx-split-pane/style/index.js.map +1 -1
- package/lib/vtx-split-pane/style/index.less +76 -76
- package/lib/vtx-statistics-column/style/index.less +59 -59
- package/lib/vtx-time-picker/index.js.map +1 -1
- package/lib/vtx-time-picker/style/css.js.map +1 -1
- package/lib/vtx-time-picker/style/index.js.map +1 -1
- package/lib/vtx-upload/FilePreview.js.map +1 -1
- package/lib/vtx-upload/style/css.js.map +1 -1
- package/lib/vtx-upload/style/index.js.map +1 -1
- package/lib/vtx-upload/style/index.less +61 -61
- package/lib/vtx-wang-editor/style/css.js.map +1 -1
- package/lib/vtx-wang-editor/style/index.js.map +1 -1
- package/lib/vtx-wang-editor/style/index.less +12 -12
- package/lib/vtx-wang-editor/wangEditorUtil.js.map +1 -1
- package/lib/vtx-ztree/index.js +2 -2
- package/lib/vtx-ztree/index.js.map +1 -1
- package/lib/vtx-ztree/style/css.js.map +1 -1
- package/lib/vtx-ztree/style/index.js.map +1 -1
- package/lib/vtx-ztree/style/index.less +45 -45
- package/lib/vtx-ztree-select/index.js +85 -14
- package/lib/vtx-ztree-select/index.js.map +1 -1
- package/lib/vtx-ztree-select/style/css.js.map +1 -1
- package/lib/vtx-ztree-select/style/index.js.map +1 -1
- package/lib/vtx-ztree-select/style/index.less +99 -99
- package/package.json +126 -126
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
@import (reference) '~antd/lib/style/themes/index.less';
|
|
2
|
-
|
|
3
|
-
@prefix-cls: vtx-page;
|
|
4
|
-
@spacing-base: 10px;
|
|
5
|
-
@padding-default-base: @spacing-base;
|
|
6
|
-
|
|
7
|
-
.size(@width; @height) {
|
|
8
|
-
width: @width;
|
|
9
|
-
height: @height;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.relative(@height: 100%, @width: 100%) {
|
|
13
|
-
position: relative;
|
|
14
|
-
.size(@width, @height);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.absolute(@top: 0, @right: 0, @left: 0, @bottom: 0) {
|
|
18
|
-
position: absolute;
|
|
19
|
-
top: @top;
|
|
20
|
-
right: @right;
|
|
21
|
-
bottom: @bottom;
|
|
22
|
-
left: @left;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.overflow-y {
|
|
26
|
-
overflow: hidden;
|
|
27
|
-
overflow-y: auto;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.vtx-page {
|
|
31
|
-
position: relative;
|
|
32
|
-
width: 100%;
|
|
33
|
-
height: 100%;
|
|
34
|
-
overflow-x: hidden;
|
|
35
|
-
font-size: 14px;
|
|
36
|
-
.ant-table-footer {
|
|
37
|
-
padding: 0 !important;
|
|
38
|
-
}
|
|
39
|
-
.vtx-ui-date-normal {
|
|
40
|
-
width: 100%;
|
|
41
|
-
}
|
|
42
|
-
.vtx-ui-grid-normal {
|
|
43
|
-
z-index: 999;
|
|
44
|
-
}
|
|
45
|
-
.ant-tabs {
|
|
46
|
-
height: 100%;
|
|
47
|
-
}
|
|
48
|
-
.ant-tabs-content {
|
|
49
|
-
height: e('calc(100% - 56px)');
|
|
50
|
-
}
|
|
51
|
-
.ant-tabs-tabpane {
|
|
52
|
-
height: 100%;
|
|
53
|
-
}
|
|
54
|
-
.td {
|
|
55
|
-
position: relative;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.vtx-button-wrap {
|
|
60
|
-
button + button {
|
|
61
|
-
margin-left: 8px;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.vtx-content {
|
|
66
|
-
&-absolute {
|
|
67
|
-
.absolute();
|
|
68
|
-
}
|
|
69
|
-
&-relative {
|
|
70
|
-
.relative();
|
|
71
|
-
}
|
|
72
|
-
&-scroll-y {
|
|
73
|
-
.overflow-y();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.vtx-table-wrapper {
|
|
78
|
-
&-absolute {
|
|
79
|
-
.absolute();
|
|
80
|
-
padding: 0 @padding-default-base / 2;
|
|
81
|
-
}
|
|
82
|
-
&-relative {
|
|
83
|
-
.relative();
|
|
84
|
-
max-height: 500px;
|
|
85
|
-
padding: 0 @padding-default-base / 2;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@table-page-padding-left: 20px;
|
|
90
|
-
@table-page-padding-right: 20px;
|
|
91
|
-
@table-page-padding-bottom: 16px;
|
|
92
|
-
@table-page-padding-top: 16px;
|
|
93
|
-
|
|
94
|
-
.vtx-page--table {
|
|
95
|
-
position: relative;
|
|
96
|
-
width: 100%;
|
|
97
|
-
height: 100%;
|
|
98
|
-
padding: @table-page-padding-top @table-page-padding-right @table-page-padding-bottom
|
|
99
|
-
@table-page-padding-left;
|
|
100
|
-
overflow-x: hidden;
|
|
101
|
-
font-size: 14px;
|
|
102
|
-
background-color: @layout-body-background;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.vtx-table {
|
|
106
|
-
&-search {
|
|
107
|
-
margin-bottom: 16px;
|
|
108
|
-
background: @component-background;
|
|
109
|
-
border-radius: @border-radius-base;
|
|
110
|
-
}
|
|
111
|
-
&-content {
|
|
112
|
-
.absolute();
|
|
113
|
-
right: @table-page-padding-right;
|
|
114
|
-
bottom: @table-page-padding-bottom;
|
|
115
|
-
left: @table-page-padding-left;
|
|
116
|
-
transition-duration: 0.3s;
|
|
117
|
-
transition-property: top;
|
|
118
|
-
}
|
|
119
|
-
&-wrap {
|
|
120
|
-
.absolute();
|
|
121
|
-
padding: 0 24px;
|
|
122
|
-
background-color: @component-background;
|
|
123
|
-
}
|
|
124
|
-
&-card {
|
|
125
|
-
background: @component-background;
|
|
126
|
-
border-radius: @border-radius-base;
|
|
127
|
-
}
|
|
128
|
-
&-left,
|
|
129
|
-
&-right {
|
|
130
|
-
height: 100%;
|
|
131
|
-
overflow: hidden;
|
|
132
|
-
}
|
|
133
|
-
&-left {
|
|
134
|
-
.vtx-ztree-search {
|
|
135
|
-
right: 0;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
1
|
+
@import (reference) '~antd/lib/style/themes/index.less';
|
|
2
|
+
|
|
3
|
+
@prefix-cls: vtx-page;
|
|
4
|
+
@spacing-base: 10px;
|
|
5
|
+
@padding-default-base: @spacing-base;
|
|
6
|
+
|
|
7
|
+
.size(@width; @height) {
|
|
8
|
+
width: @width;
|
|
9
|
+
height: @height;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.relative(@height: 100%, @width: 100%) {
|
|
13
|
+
position: relative;
|
|
14
|
+
.size(@width, @height);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.absolute(@top: 0, @right: 0, @left: 0, @bottom: 0) {
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: @top;
|
|
20
|
+
right: @right;
|
|
21
|
+
bottom: @bottom;
|
|
22
|
+
left: @left;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.overflow-y {
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
overflow-y: auto;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.vtx-page {
|
|
31
|
+
position: relative;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
overflow-x: hidden;
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
.ant-table-footer {
|
|
37
|
+
padding: 0 !important;
|
|
38
|
+
}
|
|
39
|
+
.vtx-ui-date-normal {
|
|
40
|
+
width: 100%;
|
|
41
|
+
}
|
|
42
|
+
.vtx-ui-grid-normal {
|
|
43
|
+
z-index: 999;
|
|
44
|
+
}
|
|
45
|
+
.ant-tabs {
|
|
46
|
+
height: 100%;
|
|
47
|
+
}
|
|
48
|
+
.ant-tabs-content {
|
|
49
|
+
height: e('calc(100% - 56px)');
|
|
50
|
+
}
|
|
51
|
+
.ant-tabs-tabpane {
|
|
52
|
+
height: 100%;
|
|
53
|
+
}
|
|
54
|
+
.td {
|
|
55
|
+
position: relative;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.vtx-button-wrap {
|
|
60
|
+
button + button {
|
|
61
|
+
margin-left: 8px;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.vtx-content {
|
|
66
|
+
&-absolute {
|
|
67
|
+
.absolute();
|
|
68
|
+
}
|
|
69
|
+
&-relative {
|
|
70
|
+
.relative();
|
|
71
|
+
}
|
|
72
|
+
&-scroll-y {
|
|
73
|
+
.overflow-y();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.vtx-table-wrapper {
|
|
78
|
+
&-absolute {
|
|
79
|
+
.absolute();
|
|
80
|
+
padding: 0 @padding-default-base / 2;
|
|
81
|
+
}
|
|
82
|
+
&-relative {
|
|
83
|
+
.relative();
|
|
84
|
+
max-height: 500px;
|
|
85
|
+
padding: 0 @padding-default-base / 2;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@table-page-padding-left: 20px;
|
|
90
|
+
@table-page-padding-right: 20px;
|
|
91
|
+
@table-page-padding-bottom: 16px;
|
|
92
|
+
@table-page-padding-top: 16px;
|
|
93
|
+
|
|
94
|
+
.vtx-page--table {
|
|
95
|
+
position: relative;
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
padding: @table-page-padding-top @table-page-padding-right @table-page-padding-bottom
|
|
99
|
+
@table-page-padding-left;
|
|
100
|
+
overflow-x: hidden;
|
|
101
|
+
font-size: 14px;
|
|
102
|
+
background-color: @layout-body-background;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.vtx-table {
|
|
106
|
+
&-search {
|
|
107
|
+
margin-bottom: 16px;
|
|
108
|
+
background: @component-background;
|
|
109
|
+
border-radius: @border-radius-base;
|
|
110
|
+
}
|
|
111
|
+
&-content {
|
|
112
|
+
.absolute();
|
|
113
|
+
right: @table-page-padding-right;
|
|
114
|
+
bottom: @table-page-padding-bottom;
|
|
115
|
+
left: @table-page-padding-left;
|
|
116
|
+
transition-duration: 0.3s;
|
|
117
|
+
transition-property: top;
|
|
118
|
+
}
|
|
119
|
+
&-wrap {
|
|
120
|
+
.absolute();
|
|
121
|
+
padding: 0 24px;
|
|
122
|
+
background-color: @component-background;
|
|
123
|
+
}
|
|
124
|
+
&-card {
|
|
125
|
+
background: @component-background;
|
|
126
|
+
border-radius: @border-radius-base;
|
|
127
|
+
}
|
|
128
|
+
&-left,
|
|
129
|
+
&-right {
|
|
130
|
+
height: 100%;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
}
|
|
133
|
+
&-left {
|
|
134
|
+
.vtx-ztree-search {
|
|
135
|
+
right: 0;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -57,13 +57,18 @@ function VtxRpsFrame(props) {
|
|
|
57
57
|
var access_token = (0, _getUrlParam["default"])()['token'] || (0, _getUrlParam["default"])()['access_token']; // 获取公共参数
|
|
58
58
|
|
|
59
59
|
function commonParam() {
|
|
60
|
+
var header = {
|
|
61
|
+
'content-type': 'application/x-www-form-urlencoded'
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (access_token) {
|
|
65
|
+
header['Authorization'] = "Bearer ".concat(access_token);
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
return (0, _axios["default"])({
|
|
61
69
|
method: 'get',
|
|
62
70
|
url: "".concat(reportParamUrl, "?parameters={\"paramTypeCode\": \"").concat(paramCode, "\",\"tenantId\":\"").concat(tenantId, "\"}"),
|
|
63
|
-
headers:
|
|
64
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
65
|
-
Authorization: "Bearer ".concat(access_token)
|
|
66
|
-
}
|
|
71
|
+
headers: header
|
|
67
72
|
});
|
|
68
73
|
} // 获取报表code
|
|
69
74
|
|
|
@@ -76,13 +81,18 @@ function VtxRpsFrame(props) {
|
|
|
76
81
|
var formData = isParamEncode ? encodeURI(JSON.stringify(param)) : JSON.stringify(param);
|
|
77
82
|
|
|
78
83
|
function getReportInfoByCode() {
|
|
84
|
+
var header = {
|
|
85
|
+
'content-type': 'application/x-www-form-urlencoded'
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
if (access_token) {
|
|
89
|
+
header['Authorization'] = "Bearer ".concat(access_token);
|
|
90
|
+
}
|
|
91
|
+
|
|
79
92
|
return (0, _axios["default"])({
|
|
80
93
|
method: 'get',
|
|
81
94
|
url: "".concat(reportInfoUrl, "?parameters=").concat(formData),
|
|
82
|
-
headers:
|
|
83
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
84
|
-
Authorization: "Bearer ".concat(access_token)
|
|
85
|
-
}
|
|
95
|
+
headers: header
|
|
86
96
|
});
|
|
87
97
|
}
|
|
88
98
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["initReportParamUrl","initReportInfoUrl","initReportServerUrl","VtxRpsFrame","props","iframeName","useRef","Math","random","Date","getTime","useEffect","getReportInfoByCode","flag","report_param","data_param","paramTypeCode","tenantId","isParamEncode","reportParamUrl","reportInfoUrl","reportServerUrl","paramCode","report_code","getUrlParam","access_token","commonParam","axios","method","url","headers","Authorization","param","timestamp","valueOf","reqMethod","formData","encodeURI","JSON","stringify","all","then","spread","commonParamResult","reportInfoByCodeResult","data","result","commonParamData","obj","forEach","d","parmCode","parmName","reportInfoByCodeData","data_url","createForm","window","rpsPrefix","reportlet","current","err","console","log","propTypes","PropTypes","number","string","object","oneOfType","array","bool","reqURL","formDom","document","createElement","target","action","style","inputArray","k","Object","prototype","hasOwnProperty","call","input1","type","name","value","push","body","appendChild","i","len","length","append","submit","remove"],"sources":["vtx-rps-frame/index.jsx"],"sourcesContent":["/* eslint-disable camelcase */\r\n/*\r\n * @Author: chenxinyu\r\n * @Date: 2021-03-24 21:47:52\r\n * @LastEditors: your name\r\n * @LastEditTime: 2022-01-12 18:49:30\r\n * @Description: 报表容器\r\n * @FilePath: \\react-components\\components\\vtx-rps-frame\\index.jsx\r\n */\r\nimport React, { useEffect, useRef } from 'react';\r\nimport axios from 'axios';\r\nimport PropTypes from 'prop-types';\r\nimport getUrlParam from '@vtx/utils/lib/getUrlParam';\r\n\r\n\r\nconst initReportParamUrl = '/cloud/management/rest/np/param/getByParamTypeCode';\r\nconst initReportInfoUrl = '/cloud/rps/api/np/v101/report/getReportInfoByCode.smvc';\r\nconst initReportServerUrl = '/ReportServer';\r\nfunction VtxRpsFrame(props) {\r\n const iframeName = useRef(Math.random() + new Date().getTime());\r\n\r\n // flag改变,重新渲染报表\r\n useEffect(() => {\r\n getReportInfoByCode();\r\n }, [props.flag]);\r\n\r\n const getReportInfoByCode = () => {\r\n const {\r\n // report_code,\r\n report_param,\r\n data_param,\r\n paramTypeCode,\r\n tenantId,\r\n isParamEncode = false,\r\n reportParamUrl = initReportParamUrl,\r\n reportInfoUrl = initReportInfoUrl,\r\n reportServerUrl = initReportServerUrl,\r\n } = props;\r\n\r\n const paramCode = paramTypeCode || 'param_report_constant';\r\n // report_code 可配置,如果地址栏有report_code,则优先,否则根据props的report_code\r\n const report_code = getUrlParam().report_code\r\n ? getUrlParam().report_code\r\n : props.report_code;\r\n\r\n const access_token = getUrlParam()['token'] || getUrlParam()['access_token'];\r\n\r\n // 获取公共参数\r\n function commonParam() {\r\n return axios({\r\n method: 'get',\r\n url: `${reportParamUrl}?parameters={\"paramTypeCode\": \"${paramCode}\",\"tenantId\":\"${tenantId}\"}`,\r\n headers: {\r\n 'content-type': 'application/x-www-form-urlencoded',\r\n Authorization: `Bearer ${access_token}`,\r\n },\r\n });\r\n }\r\n\r\n // 获取报表code\r\n const param = {\r\n report_code,\r\n timestamp: new Date().valueOf(),\r\n reqMethod: 0,\r\n };\r\n const formData = isParamEncode ? encodeURI(JSON.stringify(param)) : JSON.stringify(param);\r\n function getReportInfoByCode() {\r\n return axios({\r\n method: 'get',\r\n url: `${reportInfoUrl}?parameters=${formData}`,\r\n headers: {\r\n 'content-type': 'application/x-www-form-urlencoded',\r\n Authorization: `Bearer ${access_token}`,\r\n },\r\n });\r\n }\r\n\r\n axios\r\n .all([commonParam(), getReportInfoByCode()])\r\n .then(\r\n axios.spread(function (commonParamResult, reportInfoByCodeResult) {\r\n if (!commonParamResult.data.result && !reportInfoByCodeResult.data.result) {\r\n // 报表公共参数\r\n const commonParamData = commonParamResult.data.data;\r\n const obj = {};\r\n commonParamData.forEach(d => {\r\n obj[d.parmCode] = d.parmName;\r\n });\r\n const reportInfoByCodeData = reportInfoByCodeResult.data.data;\r\n const param = {\r\n data_url: reportInfoByCodeData.data_url,\r\n data_param: JSON.stringify(data_param),\r\n ...report_param,\r\n ...obj,\r\n reqMethod: 0,\r\n };\r\n createForm(\r\n `${window.rpsPrefix || ''}${reportServerUrl}?report_code=${report_code}&reportlet=${reportInfoByCodeData.reportlet\r\n }&fr_locale=zh_CN×tamp=${new Date().valueOf()}`,\r\n param,\r\n `${iframeName.current}`,\r\n );\r\n }\r\n }),\r\n )\r\n // eslint-disable-next-line no-console\r\n .catch(err => console.log(err));\r\n };\r\n\r\n return (\r\n <div className=\"vtx-rps-frame\">\r\n <iframe\r\n className=\"vtx-rps-frame-wrapper\"\r\n width=\"100%\"\r\n height=\"100%\"\r\n name={`${iframeName.current}`}\r\n ></iframe>\r\n </div>\r\n );\r\n}\r\n\r\nVtxRpsFrame.propTypes = {\r\n flag: PropTypes.number,\r\n report_code: PropTypes.string,\r\n report_param: PropTypes.object,\r\n data_param: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),\r\n paramTypeCode: PropTypes.string,\r\n tenantId: PropTypes.string,\r\n reportParamUrl: PropTypes.string,\r\n reportInfoUrl: PropTypes.string,\r\n reportServerUrl: PropTypes.string,\r\n isParamEncode: PropTypes.bool,\r\n};\r\nexport default VtxRpsFrame;\r\n\r\nconst createForm = function (reqURL, param, iframeName) {\r\n // 定义一个form表单\r\n const formDom = document.createElement('form');\r\n formDom.method = 'post';\r\n formDom.target = iframeName;\r\n formDom.action = reqURL;\r\n formDom.style = 'display:none';\r\n const inputArray = [];\r\n for (const k in param) {\r\n if (Object.prototype.hasOwnProperty.call(param, k)) {\r\n const input1 = document.createElement('input');\r\n input1.type = 'hidden';\r\n input1.name = k;\r\n input1.value = param[k];\r\n inputArray.push(input1);\r\n }\r\n }\r\n document.body.appendChild(formDom); // 将表单放置在web中\r\n for (let i = 0, len = inputArray.length; i < len; i++) {\r\n formDom.append(inputArray[i]);\r\n }\r\n formDom.submit(); // 表单提交\r\n formDom.remove();\r\n};\r\n"],"mappings":";;;;;;;;;AASA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAGA,IAAMA,kBAAkB,GAAG,oDAA3B;A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["initReportParamUrl","initReportInfoUrl","initReportServerUrl","VtxRpsFrame","props","iframeName","useRef","Math","random","Date","getTime","useEffect","getReportInfoByCode","flag","report_param","data_param","paramTypeCode","tenantId","isParamEncode","reportParamUrl","reportInfoUrl","reportServerUrl","paramCode","report_code","getUrlParam","access_token","commonParam","header","axios","method","url","headers","param","timestamp","valueOf","reqMethod","formData","encodeURI","JSON","stringify","all","then","spread","commonParamResult","reportInfoByCodeResult","data","result","commonParamData","obj","forEach","d","parmCode","parmName","reportInfoByCodeData","data_url","createForm","window","rpsPrefix","reportlet","current","err","console","log","propTypes","PropTypes","number","string","object","oneOfType","array","bool","reqURL","formDom","document","createElement","target","action","style","inputArray","k","Object","prototype","hasOwnProperty","call","input1","type","name","value","push","body","appendChild","i","len","length","append","submit","remove"],"sources":["vtx-rps-frame/index.jsx"],"sourcesContent":["/* eslint-disable camelcase */\r\n/*\r\n * @Author: chenxinyu\r\n * @Date: 2021-03-24 21:47:52\r\n * @LastEditors: your name\r\n * @LastEditTime: 2022-01-12 18:49:30\r\n * @Description: 报表容器\r\n * @FilePath: \\react-components\\components\\vtx-rps-frame\\index.jsx\r\n */\r\nimport React, { useEffect, useRef } from 'react';\r\nimport axios from 'axios';\r\nimport PropTypes from 'prop-types';\r\nimport getUrlParam from '@vtx/utils/lib/getUrlParam';\r\n\r\n\r\nconst initReportParamUrl = '/cloud/management/rest/np/param/getByParamTypeCode';\r\nconst initReportInfoUrl = '/cloud/rps/api/np/v101/report/getReportInfoByCode.smvc';\r\nconst initReportServerUrl = '/ReportServer';\r\nfunction VtxRpsFrame(props) {\r\n const iframeName = useRef(Math.random() + new Date().getTime());\r\n\r\n // flag改变,重新渲染报表\r\n useEffect(() => {\r\n getReportInfoByCode();\r\n }, [props.flag]);\r\n\r\n const getReportInfoByCode = () => {\r\n const {\r\n // report_code,\r\n report_param,\r\n data_param,\r\n paramTypeCode,\r\n tenantId,\r\n isParamEncode = false,\r\n reportParamUrl = initReportParamUrl,\r\n reportInfoUrl = initReportInfoUrl,\r\n reportServerUrl = initReportServerUrl,\r\n } = props;\r\n\r\n const paramCode = paramTypeCode || 'param_report_constant';\r\n // report_code 可配置,如果地址栏有report_code,则优先,否则根据props的report_code\r\n const report_code = getUrlParam().report_code\r\n ? getUrlParam().report_code\r\n : props.report_code;\r\n\r\n const access_token = getUrlParam()['token'] || getUrlParam()['access_token'];\r\n\r\n // 获取公共参数\r\n function commonParam() {\r\n let header = {\r\n 'content-type': 'application/x-www-form-urlencoded',\r\n }\r\n if(access_token){\r\n header['Authorization']= `Bearer ${access_token}`;\r\n }\r\n return axios({\r\n method: 'get',\r\n url: `${reportParamUrl}?parameters={\"paramTypeCode\": \"${paramCode}\",\"tenantId\":\"${tenantId}\"}`,\r\n headers: header,\r\n });\r\n }\r\n\r\n // 获取报表code\r\n const param = {\r\n report_code,\r\n timestamp: new Date().valueOf(),\r\n reqMethod: 0,\r\n };\r\n const formData = isParamEncode ? encodeURI(JSON.stringify(param)) : JSON.stringify(param);\r\n function getReportInfoByCode() {\r\n let header = {\r\n 'content-type': 'application/x-www-form-urlencoded',\r\n }\r\n if(access_token){\r\n header['Authorization']= `Bearer ${access_token}`;\r\n }\r\n return axios({\r\n method: 'get',\r\n url: `${reportInfoUrl}?parameters=${formData}`,\r\n headers: header,\r\n });\r\n }\r\n\r\n axios\r\n .all([commonParam(), getReportInfoByCode()])\r\n .then(\r\n axios.spread(function (commonParamResult, reportInfoByCodeResult) {\r\n if (!commonParamResult.data.result && !reportInfoByCodeResult.data.result) {\r\n // 报表公共参数\r\n const commonParamData = commonParamResult.data.data;\r\n const obj = {};\r\n commonParamData.forEach(d => {\r\n obj[d.parmCode] = d.parmName;\r\n });\r\n const reportInfoByCodeData = reportInfoByCodeResult.data.data;\r\n const param = {\r\n data_url: reportInfoByCodeData.data_url,\r\n data_param: JSON.stringify(data_param),\r\n ...report_param,\r\n ...obj,\r\n reqMethod: 0,\r\n };\r\n createForm(\r\n `${window.rpsPrefix || ''}${reportServerUrl}?report_code=${report_code}&reportlet=${reportInfoByCodeData.reportlet\r\n }&fr_locale=zh_CN×tamp=${new Date().valueOf()}`,\r\n param,\r\n `${iframeName.current}`,\r\n );\r\n }\r\n }),\r\n )\r\n // eslint-disable-next-line no-console\r\n .catch(err => console.log(err));\r\n };\r\n\r\n return (\r\n <div className=\"vtx-rps-frame\">\r\n <iframe\r\n className=\"vtx-rps-frame-wrapper\"\r\n width=\"100%\"\r\n height=\"100%\"\r\n name={`${iframeName.current}`}\r\n ></iframe>\r\n </div>\r\n );\r\n}\r\n\r\nVtxRpsFrame.propTypes = {\r\n flag: PropTypes.number,\r\n report_code: PropTypes.string,\r\n report_param: PropTypes.object,\r\n data_param: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),\r\n paramTypeCode: PropTypes.string,\r\n tenantId: PropTypes.string,\r\n reportParamUrl: PropTypes.string,\r\n reportInfoUrl: PropTypes.string,\r\n reportServerUrl: PropTypes.string,\r\n isParamEncode: PropTypes.bool,\r\n};\r\nexport default VtxRpsFrame;\r\n\r\nconst createForm = function (reqURL, param, iframeName) {\r\n // 定义一个form表单\r\n const formDom = document.createElement('form');\r\n formDom.method = 'post';\r\n formDom.target = iframeName;\r\n formDom.action = reqURL;\r\n formDom.style = 'display:none';\r\n const inputArray = [];\r\n for (const k in param) {\r\n if (Object.prototype.hasOwnProperty.call(param, k)) {\r\n const input1 = document.createElement('input');\r\n input1.type = 'hidden';\r\n input1.name = k;\r\n input1.value = param[k];\r\n inputArray.push(input1);\r\n }\r\n }\r\n document.body.appendChild(formDom); // 将表单放置在web中\r\n for (let i = 0, len = inputArray.length; i < len; i++) {\r\n formDom.append(inputArray[i]);\r\n }\r\n formDom.submit(); // 表单提交\r\n formDom.remove();\r\n};\r\n"],"mappings":";;;;;;;;;AASA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAGA,IAAMA,kBAAkB,GAAG,oDAA3B;AACA,IAAMC,iBAAiB,GAAG,wDAA1B;AACA,IAAMC,mBAAmB,GAA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B,MAAR,GArBoD,CAqBlC;;EAClBvB,OAAO,CAACwB,MAAR;AACH,CAvBD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isTransformSupported","style","setTransform","v","transform","webkitTransform","mozTransform","VtxScrollableRow","props","useState","next","prev","state","setState","prefixCls","className","offset","useRef","containerRef","navWrapRef","navRef","useEffect","debouncedResize","debounce","setNextPrev","window","addEventListener","removeEventListener","navNodeW","current","scrollWidth","containerW","offsetWidth","navWrapNodeW","minOffset","setOffset","realOffset","os","checkNextPrev","target","Math","min","navOffset","navStyle","transformSupported","value","name","handlePrev","handleNext","showNextPrev","prevButton","classnames","nextButton","children","propTypes","PropTypes","string","object","node"],"sources":["vtx-scrollable-row/index.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\r\nimport classnames from 'classnames';\r\nimport debounce from 'lodash/debounce';\r\nimport PropTypes from 'prop-types';\r\nimport RightOutlined from '@ant-design/icons/RightOutlined';\r\nimport LeftOutlined from '@ant-design/icons/LeftOutlined';\r\n\r\nexport function isTransformSupported(style) {\r\n return 'transform' in style || 'webkitTransform' in style || 'MozTransform' in style;\r\n}\r\n\r\nexport function setTransform(style, v) {\r\n style.transform = v;\r\n style.webkitTransform = v;\r\n style.mozTransform = v;\r\n}\r\n\r\nfunction VtxScrollableRow(props) {\r\n const [state, setState] = useState({\r\n next: false,\r\n prev: false,\r\n });\r\n const { next, prev } = state;\r\n const { prefixCls = 'vtx-scrollable-row', className, style } = props;\r\n\r\n const offset = useRef(0);\r\n const containerRef = useRef();\r\n const navWrapRef = useRef();\r\n const navRef = useRef();\r\n\r\n useEffect(() => {\r\n const debouncedResize = debounce(() => {\r\n setNextPrev();\r\n }, 200);\r\n window.addEventListener('resize', debouncedResize);\r\n setNextPrev();\r\n return () => {\r\n window.removeEventListener('resize', debouncedResize);\r\n };\r\n }, []);\r\n\r\n function setNextPrev() {\r\n const navNodeW = navRef.current.scrollWidth;\r\n const containerW = containerRef.current.offsetWidth;\r\n const navWrapNodeW = navWrapRef.current.offsetWidth;\r\n\r\n const minOffset = containerW - navNodeW;\r\n let { next, prev } = state;\r\n if (minOffset >= 0) {\r\n next = false;\r\n setOffset(0, false);\r\n offset.current = 0;\r\n } else if (minOffset < offset.current) {\r\n next = true;\r\n } else {\r\n next = false;\r\n const realOffset = navWrapNodeW - navNodeW;\r\n setOffset(realOffset, false);\r\n offset.current = realOffset;\r\n }\r\n\r\n if (offset.current < 0) {\r\n prev = true;\r\n } else {\r\n prev = false;\r\n }\r\n setState({\r\n next, prev\r\n })\r\n return {\r\n next,\r\n prev,\r\n };\r\n }\r\n\r\n const setOffset = (os, checkNextPrev = true) => {\r\n const target = Math.min(0, os);\r\n if (offset.current !== target) {\r\n offset.current = target;\r\n let navOffset = {};\r\n const navStyle = navRef.current.style;\r\n const transformSupported = isTransformSupported(navStyle);\r\n if (transformSupported) {\r\n navOffset = {\r\n value: `translate3d(${target}px,0,0)`,\r\n };\r\n } else {\r\n navOffset = {\r\n name: 'left',\r\n value: `${target}px`,\r\n };\r\n }\r\n if (transformSupported) {\r\n setTransform(navStyle, navOffset.value);\r\n } else {\r\n navStyle[navOffset.name] = navOffset.value;\r\n }\r\n if (checkNextPrev) {\r\n setNextPrev();\r\n }\r\n }\r\n };\r\n\r\n // 上一页\r\n const handlePrev = () => {\r\n const navWrapNodeW = navWrapRef.current.offsetWidth;\r\n setOffset(offset.current + navWrapNodeW);\r\n };\r\n\r\n // 下一页\r\n const handleNext = () => {\r\n const navWrapNodeW = navWrapRef.current.offsetWidth;\r\n setOffset(offset.current - navWrapNodeW);\r\n };\r\n\r\n const showNextPrev = prev || next;\r\n\r\n const prevButton = (\r\n <span\r\n onClick={prev ? handlePrev : null}\r\n // eslint-disable-next-line react/no-unknown-property\r\n unselectable=\"on\"\r\n className={classnames({\r\n [`${prefixCls}-prev`]: true,\r\n [`${prefixCls}-btn-disabled`]: !prev,\r\n [`${prefixCls}-arrow-show`]: showNextPrev,\r\n })}\r\n >\r\n <span className={`${prefixCls}-prev-icon`}>\r\n <LeftOutlined />\r\n </span>\r\n </span>\r\n );\r\n const nextButton = (\r\n <span\r\n onClick={next ? handleNext : null}\r\n // eslint-disable-next-line react/no-unknown-property\r\n unselectable=\"on\"\r\n className={classnames({\r\n [`${prefixCls}-next`]: true,\r\n [`${prefixCls}-btn-disabled`]: !next,\r\n [`${prefixCls}-arrow-show`]: showNextPrev,\r\n })}\r\n >\r\n <span className={`${prefixCls}-next-icon`}>\r\n <RightOutlined />\r\n </span>\r\n </span>\r\n );\r\n\r\n return (\r\n <div\r\n className={classnames(`${prefixCls}-container`, className)}\r\n style={style}\r\n ref={containerRef}\r\n >\r\n {prevButton}\r\n {nextButton}\r\n <div className={`${prefixCls}-nav-wrap`} ref={navWrapRef}>\r\n <div className={`${prefixCls}-nav-scroll`}>\r\n <div className={`${prefixCls}-nav`} ref={navRef}>\r\n {props.children}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n\r\nexport default VtxScrollableRow;\r\n\r\nVtxScrollableRow.propTypes = {\r\n prefixCls: PropTypes.string,\r\n className: PropTypes.string,\r\n style: PropTypes.object,\r\n children: PropTypes.node,\r\n};\r\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;AAEO,SAASA,oBAAT,CAA8BC,KAA9B,EAAqC;EACxC,OAAO,eAAeA,KAAf,IAAwB,qBAAqBA,KAA7C,IAAsD,kBAAkBA,KAA/E;AACH;;AAEM,SAASC,YAAT,CAAsBD,KAAtB,EAA6BE,CAA7B,EAAgC;EACnCF,KAAK,CAACG,SAAN,GAAkBD,CAAlB;EACAF,KAAK,CAACI,eAAN,GAAwBF,CAAxB;EACAF,KAAK,CAACK,YAAN,GAAqBH,CAArB;AACH;;AAED,SAASI,gBAAT,CAA0BC,KAA1B,EAAiC;EAAA;;EAC7B,gBAA0B,IAAAC,eAAA,EAAS;IAC/BC,IAAI,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YACgB,IADhB,2CAEHA,SAFG,oBAEwB,CAACJ,IAFzB,2CAGHI,SAHG,kBAGsBmC,YAHtB;EAJf,gBAUI;IAAM,SAAS,YAAKnC,SAAL;EAAf,gBACI,gCAAC,yBAAD,OADJ,CAVJ,CADJ;;EAiBA,oBACI;IACI,SAAS,EAAE,IAAAqC,uBAAA,YAAcrC,SAAd,iBAAqCC,SAArC,CADf;IAEI,KAAK,EAAEd,KAFX;IAGI,GAAG,EAAEiB;EAHT,GAKKgC,UALL,EAMKE,UANL,eAOI;IAAK,SAAS,YAAKtC,SAAL,cAAd;IAAyC,GAAG,EAAEK;EAA9C,gBACI;IAAK,SAAS,YAAKL,SAAL;EAAd,gBACI;IAAK,SAAS,YAAKA,SAAL,SAAd;IAAoC,GAAG,EAAEM;EAAzC,GACKZ,KAAK,CAAC6C,QADX,CADJ,CADJ,CAPJ,CADJ;AAiBH;;eAEc9C,gB;;AAEfA,gBAAgB,CAAC+C,SAAjB,GAA6B;EACzBxC,SAAS,EAAEyC,qBAAA,CAAUC,MADI;EAEzBzC,SAAS,EAAEwC,qBAAA,CAAUC,MAFI;EAGzBvD,KAAK,EAAEsD,qBAAA,CAAUE,MAHQ;EAIzBJ,QAAQ,EAAEE,qBAAA,CAAUG;AAJK,CAA7B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isTransformSupported","style","setTransform","v","transform","webkitTransform","mozTransform","VtxScrollableRow","props","useState","next","prev","state","setState","prefixCls","className","offset","useRef","containerRef","navWrapRef","navRef","useEffect","debouncedResize","debounce","setNextPrev","window","addEventListener","removeEventListener","navNodeW","current","scrollWidth","containerW","offsetWidth","navWrapNodeW","minOffset","setOffset","realOffset","os","checkNextPrev","target","Math","min","navOffset","navStyle","transformSupported","value","name","handlePrev","handleNext","showNextPrev","prevButton","classnames","nextButton","children","propTypes","PropTypes","string","object","node"],"sources":["vtx-scrollable-row/index.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport classnames from 'classnames';\nimport debounce from 'lodash/debounce';\nimport PropTypes from 'prop-types';\nimport RightOutlined from '@ant-design/icons/RightOutlined';\nimport LeftOutlined from '@ant-design/icons/LeftOutlined';\n\nexport function isTransformSupported(style) {\n return 'transform' in style || 'webkitTransform' in style || 'MozTransform' in style;\n}\n\nexport function setTransform(style, v) {\n style.transform = v;\n style.webkitTransform = v;\n style.mozTransform = v;\n}\n\nfunction VtxScrollableRow(props) {\n const [state, setState] = useState({\n next: false,\n prev: false,\n });\n const { next, prev } = state;\n const { prefixCls = 'vtx-scrollable-row', className, style } = props;\n\n const offset = useRef(0);\n const containerRef = useRef();\n const navWrapRef = useRef();\n const navRef = useRef();\n\n useEffect(() => {\n const debouncedResize = debounce(() => {\n setNextPrev();\n }, 200);\n window.addEventListener('resize', debouncedResize);\n setNextPrev();\n return () => {\n window.removeEventListener('resize', debouncedResize);\n };\n }, []);\n\n function setNextPrev() {\n const navNodeW = navRef.current.scrollWidth;\n const containerW = containerRef.current.offsetWidth;\n const navWrapNodeW = navWrapRef.current.offsetWidth;\n\n const minOffset = containerW - navNodeW;\n let { next, prev } = state;\n if (minOffset >= 0) {\n next = false;\n setOffset(0, false);\n offset.current = 0;\n } else if (minOffset < offset.current) {\n next = true;\n } else {\n next = false;\n const realOffset = navWrapNodeW - navNodeW;\n setOffset(realOffset, false);\n offset.current = realOffset;\n }\n\n if (offset.current < 0) {\n prev = true;\n } else {\n prev = false;\n }\n setState({\n next, prev\n })\n return {\n next,\n prev,\n };\n }\n\n const setOffset = (os, checkNextPrev = true) => {\n const target = Math.min(0, os);\n if (offset.current !== target) {\n offset.current = target;\n let navOffset = {};\n const navStyle = navRef.current.style;\n const transformSupported = isTransformSupported(navStyle);\n if (transformSupported) {\n navOffset = {\n value: `translate3d(${target}px,0,0)`,\n };\n } else {\n navOffset = {\n name: 'left',\n value: `${target}px`,\n };\n }\n if (transformSupported) {\n setTransform(navStyle, navOffset.value);\n } else {\n navStyle[navOffset.name] = navOffset.value;\n }\n if (checkNextPrev) {\n setNextPrev();\n }\n }\n };\n\n // 上一页\n const handlePrev = () => {\n const navWrapNodeW = navWrapRef.current.offsetWidth;\n setOffset(offset.current + navWrapNodeW);\n };\n\n // 下一页\n const handleNext = () => {\n const navWrapNodeW = navWrapRef.current.offsetWidth;\n setOffset(offset.current - navWrapNodeW);\n };\n\n const showNextPrev = prev || next;\n\n const prevButton = (\n <span\n onClick={prev ? handlePrev : null}\n // eslint-disable-next-line react/no-unknown-property\n unselectable=\"on\"\n className={classnames({\n [`${prefixCls}-prev`]: true,\n [`${prefixCls}-btn-disabled`]: !prev,\n [`${prefixCls}-arrow-show`]: showNextPrev,\n })}\n >\n <span className={`${prefixCls}-prev-icon`}>\n <LeftOutlined />\n </span>\n </span>\n );\n const nextButton = (\n <span\n onClick={next ? handleNext : null}\n // eslint-disable-next-line react/no-unknown-property\n unselectable=\"on\"\n className={classnames({\n [`${prefixCls}-next`]: true,\n [`${prefixCls}-btn-disabled`]: !next,\n [`${prefixCls}-arrow-show`]: showNextPrev,\n })}\n >\n <span className={`${prefixCls}-next-icon`}>\n <RightOutlined />\n </span>\n </span>\n );\n\n return (\n <div\n className={classnames(`${prefixCls}-container`, className)}\n style={style}\n ref={containerRef}\n >\n {prevButton}\n {nextButton}\n <div className={`${prefixCls}-nav-wrap`} ref={navWrapRef}>\n <div className={`${prefixCls}-nav-scroll`}>\n <div className={`${prefixCls}-nav`} ref={navRef}>\n {props.children}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nexport default VtxScrollableRow;\n\nVtxScrollableRow.propTypes = {\n prefixCls: PropTypes.string,\n className: PropTypes.string,\n style: PropTypes.object,\n children: PropTypes.node,\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;AAEO,SAASA,oBAAT,CAA8BC,KAA9B,EAAqC;EACxC,OAAO,eAAeA,KAAf,IAAwB,qBAAqBA,KAA7C,IAAsD,kBAAkBA,KAA/E;AACH;;A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G,SAHG,kBAGsBmC,YAHtB;EAJf,gBAUI;IAAM,SAAS,YAAKnC,SAAL;EAAf,gBACI,gCAAC,wBAAD,OADJ,CAVJ,CADJ;;EAgBA,IAAMsC,UAAU,gBACZ;IACI,OAAO,EAAE1C,IAAI,GAAGsC,UAAH,GAAgB,IADjC,CAEI;IAFJ;IAGI,YAAY,EAAC,IAHjB;IAII,SAAS,EAAE,IAAAG,uBAAA,8DACHrC,SADG,YACgB,IADhB,2CAEHA,SAFG,oBAEwB,CAACJ,IAFzB,2CAGHI,SAHG,kBAGsBmC,YAHtB;EAJf,gBAUI;IAAM,SAAS,YAAKnC,SAAL;EAAf,gBACI,gCAAC,yBAAD,OADJ,CAVJ,CADJ;;EAiBA,oBACI;IACI,SAAS,EAAE,IAAAqC,uBAAA,YAAcrC,SAAd,iBAAqCC,SAArC,CADf;IAEI,KAAK,EAAEd,KAFX;IAGI,GAAG,EAAEiB;EAHT,GAKKgC,UALL,EAMKE,UANL,eAOI;IAAK,SAAS,YAAKtC,SAAL,cAAd;IAAyC,GAAG,EAAEK;EAA9C,gBACI;IAAK,SAAS,YAAKL,SAAL;EAAd,gBACI;IAAK,SAAS,YAAKA,SAAL,SAAd;IAAoC,GAAG,EAAEM;EAAzC,GACKZ,KAAK,CAAC6C,QADX,CADJ,CADJ,CAPJ,CADJ;AAiBH;;eAEc9C,gB;;AAEfA,gBAAgB,CAAC+C,SAAjB,GAA6B;EACzBxC,SAAS,EAAEyC,qBAAA,CAAUC,MADI;EAEzBzC,SAAS,EAAEwC,qBAAA,CAAUC,MAFI;EAGzBvD,KAAK,EAAEsD,qBAAA,CAAUE,MAHQ;EAIzBJ,QAAQ,EAAEE,qBAAA,CAAUG;AAJK,CAA7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","names":[],"sources":["vtx-scrollable-row/style/index.js"],"sourcesContent":["import './index.less';\
|
|
1
|
+
{"version":3,"file":"css.js","names":[],"sources":["vtx-scrollable-row/style/index.js"],"sourcesContent":["import './index.less';\n"],"mappings":";;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["vtx-scrollable-row/style/index.js"],"sourcesContent":["import './index.less';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["vtx-scrollable-row/style/index.js"],"sourcesContent":["import './index.less';\n"],"mappings":";;AAAA"}
|