cloud-b2b 1.0.0 → 1.0.1
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/Card/Card.js +20 -0
- package/es/Card/package.json +6 -0
- package/es/Control/Control.js +402 -0
- package/es/Control/event.js +57 -0
- package/es/Control/package.json +6 -0
- package/es/Enhance/Dialogs.js +67 -0
- package/es/Enhance/Loading.js +151 -0
- package/es/Enhance/index.js +8 -0
- package/es/Enhance/package.json +6 -0
- package/es/Header/Header.js +194 -0
- package/es/Header/Header.less +94 -0
- package/es/Header/Vertical.js +129 -0
- package/es/Header/Vertical.less +60 -0
- package/es/Header/package.json +6 -0
- package/es/HomeHeader/Header.js +75 -0
- package/es/HomeHeader/Header.less +73 -0
- package/es/HomeHeader/package.json +6 -0
- package/es/ImageView/ImageView.js +117 -0
- package/es/ImageView/ImageView.less +14 -0
- package/es/ImageView/package.json +6 -0
- package/es/InpurCascader/InputCascader.js +135 -0
- package/es/InpurCascader/package.json +6 -0
- package/es/InputEditor/InputEditor.js +118 -0
- package/es/InputEditor/inputEditor.less +8 -0
- package/es/InputEditor/package.json +6 -0
- package/es/InputSearch/InputSearch.js +306 -0
- package/es/InputSearch/package.json +6 -0
- package/es/InputSelect/InputSelect.js +185 -0
- package/es/InputSelect/package.json +6 -0
- package/es/InputWriting/InputWriting.js +107 -0
- package/es/InputWriting/package.json +6 -0
- package/es/Layout/Layout.js +232 -0
- package/es/Layout/Layout.less +28 -0
- package/es/Layout/package.json +6 -0
- package/es/LayoutLink/LayoutLink.js +82 -0
- package/es/LayoutLink/LayoutLink.less +53 -0
- package/es/LayoutLink/package.json +6 -0
- package/es/Link/Link.js +108 -0
- package/es/Link/package.json +6 -0
- package/es/Loading/Loading.js +15 -0
- package/es/Loading/Loading.less +13 -0
- package/es/Loading/package.json +6 -0
- package/es/Loading2/Loading2.js +11 -0
- package/es/Loading2/Loading2.less +19 -0
- package/es/Loading2/package.json +6 -0
- package/es/ModalWithDrag/ModalWithDrag.js +34 -0
- package/es/ModalWithDrag/ModalWithDrag.less +6 -0
- package/es/ModalWithDrag/drag.js +133 -0
- package/es/ModalWithDrag/package.json +6 -0
- package/es/NumberInput/NumberInput.js +237 -0
- package/es/NumberInput/package.json +6 -0
- package/es/Search/Search.js +581 -0
- package/es/Search/Search.less +63 -0
- package/es/Search/package.json +6 -0
- package/es/Sidebar/Sidebar.js +165 -0
- package/es/Sidebar/Sidebar.less +77 -0
- package/es/Sidebar/package.json +6 -0
- package/es/Sidebar2/Sidebar.js +192 -0
- package/es/Sidebar2/Sidebar.less +153 -0
- package/es/Sidebar2/package.json +6 -0
- package/es/SuperForm/SuperForm.js +641 -0
- package/es/SuperForm/SuperForm.less +52 -0
- package/es/SuperForm/package.json +6 -0
- package/es/SuperIcon/SuperIcon.js +30 -0
- package/es/SuperIcon/package.json +6 -0
- package/es/SuperPagination/SuperPagination.js +126 -0
- package/es/SuperPagination/package.json +6 -0
- package/es/SuperToolbar/SuperToolbar.js +223 -0
- package/es/SuperToolbar/SuperToolbar.less +17 -0
- package/es/SuperToolbar/package.json +6 -0
- package/es/SuperUpload/SuperUpload.js +282 -0
- package/es/SuperUpload/SuperUpload.less +27 -0
- package/es/SuperUpload/package.json +6 -0
- package/es/Viewer/ImageViews.js +311 -0
- package/es/Viewer/Viewer.js +149 -0
- package/es/Viewer/Viewer.less +67 -0
- package/es/Viewer/imgView.less +59 -0
- package/es/Viewer/package.json +7 -0
- package/es/WingBlank/WingBlank.js +20 -0
- package/es/WingBlank/WingBlank.less +12 -0
- package/es/WingBlank/package.json +6 -0
- package/es/helper.js +118 -0
- package/es/history.js +5 -0
- package/es/index.js +24 -1
- package/es/variables.less +73 -73
- package/lib/Card/Card.js +38 -0
- package/lib/Card/package.json +6 -0
- package/lib/Control/Control.js +449 -0
- package/lib/Control/event.js +68 -0
- package/lib/Control/package.json +6 -0
- package/lib/Enhance/Dialogs.js +87 -0
- package/lib/Enhance/Loading.js +175 -0
- package/lib/Enhance/index.js +35 -0
- package/lib/Enhance/package.json +6 -0
- package/lib/Header/Header.js +215 -0
- package/lib/Header/Header.less +94 -0
- package/lib/Header/Vertical.js +150 -0
- package/lib/Header/Vertical.less +60 -0
- package/lib/Header/package.json +6 -0
- package/lib/HomeHeader/Header.js +95 -0
- package/lib/HomeHeader/Header.less +73 -0
- package/lib/HomeHeader/package.json +6 -0
- package/lib/ImageView/ImageView.js +134 -0
- package/lib/ImageView/ImageView.less +14 -0
- package/lib/ImageView/package.json +6 -0
- package/lib/InpurCascader/InputCascader.js +156 -0
- package/lib/InpurCascader/package.json +6 -0
- package/lib/InputEditor/InputEditor.js +136 -0
- package/lib/InputEditor/inputEditor.less +8 -0
- package/lib/InputEditor/package.json +6 -0
- package/lib/InputSearch/InputSearch.js +322 -0
- package/lib/InputSearch/package.json +6 -0
- package/lib/InputSelect/InputSelect.js +208 -0
- package/lib/InputSelect/package.json +6 -0
- package/lib/InputWriting/InputWriting.js +123 -0
- package/lib/InputWriting/package.json +6 -0
- package/lib/Layout/Layout.js +258 -0
- package/lib/Layout/Layout.less +28 -0
- package/lib/Layout/package.json +6 -0
- package/lib/LayoutLink/LayoutLink.js +114 -0
- package/lib/LayoutLink/LayoutLink.less +53 -0
- package/lib/LayoutLink/package.json +6 -0
- package/lib/Link/Link.js +130 -0
- package/lib/Link/package.json +6 -0
- package/lib/Loading/Loading.js +30 -0
- package/lib/Loading/Loading.less +13 -0
- package/lib/Loading/package.json +6 -0
- package/lib/Loading2/Loading2.js +26 -0
- package/lib/Loading2/Loading2.less +19 -0
- package/lib/Loading2/package.json +6 -0
- package/lib/ModalWithDrag/ModalWithDrag.js +53 -0
- package/lib/ModalWithDrag/ModalWithDrag.less +6 -0
- package/lib/ModalWithDrag/drag.js +147 -0
- package/lib/ModalWithDrag/package.json +6 -0
- package/lib/NumberInput/NumberInput.js +259 -0
- package/lib/NumberInput/package.json +6 -0
- package/lib/Search/Search.js +603 -0
- package/lib/Search/Search.less +63 -0
- package/lib/Search/package.json +6 -0
- package/lib/Sidebar/Sidebar.js +186 -0
- package/lib/Sidebar/Sidebar.less +77 -0
- package/lib/Sidebar/package.json +6 -0
- package/lib/Sidebar2/Sidebar.js +213 -0
- package/lib/Sidebar2/Sidebar.less +153 -0
- package/lib/Sidebar2/package.json +6 -0
- package/lib/SuperForm/SuperForm.js +657 -0
- package/lib/SuperForm/SuperForm.less +52 -0
- package/lib/SuperForm/package.json +6 -0
- package/lib/SuperIcon/SuperIcon.js +47 -0
- package/lib/SuperIcon/package.json +6 -0
- package/lib/SuperPagination/SuperPagination.js +145 -0
- package/lib/SuperPagination/package.json +6 -0
- package/lib/SuperToolbar/SuperToolbar.js +248 -0
- package/lib/SuperToolbar/SuperToolbar.less +17 -0
- package/lib/SuperToolbar/package.json +6 -0
- package/lib/SuperUpload/SuperUpload.js +324 -0
- package/lib/SuperUpload/SuperUpload.less +27 -0
- package/lib/SuperUpload/package.json +6 -0
- package/lib/Viewer/ImageViews.js +323 -0
- package/lib/Viewer/Viewer.js +167 -0
- package/lib/Viewer/Viewer.less +67 -0
- package/lib/Viewer/imgView.less +59 -0
- package/lib/Viewer/package.json +7 -0
- package/lib/WingBlank/WingBlank.js +37 -0
- package/lib/WingBlank/WingBlank.less +12 -0
- package/lib/WingBlank/package.json +6 -0
- package/lib/helper.js +147 -0
- package/lib/history.js +18 -0
- package/lib/index.js +208 -1
- package/lib/index.less +20 -1
- package/lib/variables.less +73 -73
- package/package.json +3 -2
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import _Upload from "antd/es/upload";
|
|
2
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
3
|
+
import _Button from "antd/es/button";
|
|
4
|
+
import _Icon from "antd/es/icon";
|
|
5
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
6
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
7
|
+
|
|
8
|
+
var _this = this;
|
|
9
|
+
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
11
|
+
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
|
|
16
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
17
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
18
|
+
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
19
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
20
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
21
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
22
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
23
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
24
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
25
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
26
|
+
import React, { useState, useEffect } from 'react';
|
|
27
|
+
import PropTypes from 'prop-types';
|
|
28
|
+
import helper from '../helper';
|
|
29
|
+
import Title from '../Title';
|
|
30
|
+
import variables from '../variables';
|
|
31
|
+
var FORMATS = ['image/jpeg', 'image/gif', 'image/bmp', 'image/jpg', 'image/png', 'image/tiff', 'image/gif', 'image/pcx', 'image/tga', 'image/exif', 'image/fpx', 'image/svg', 'image/psd', 'image/cdr', 'image/pcd', 'image/dxf', 'image/ufo', 'image/eps', 'image/ai', 'image/raw', 'image/WMF'];
|
|
32
|
+
var FORMATS1 = ['.jpeg', '.gif', '.bmp', '.jpg', '.png', '.tiff', '.pcx', '.tga', '.exif', '.fpx', '.svg', '.psd', '.cdr', '.pcd', '.dxf', '.ufo', '.eps', '.ai', '.raw', '.WMF']; //组件属性定义
|
|
33
|
+
|
|
34
|
+
var propTypes = {
|
|
35
|
+
fileList: PropTypes.array,
|
|
36
|
+
//文件列表
|
|
37
|
+
fileDeleteList: PropTypes.array,
|
|
38
|
+
//需要在页面关闭时删除的服务端文件
|
|
39
|
+
title: PropTypes.string,
|
|
40
|
+
//附件组的标题
|
|
41
|
+
required: PropTypes.bool,
|
|
42
|
+
//是否必须上传,默认false
|
|
43
|
+
listType: PropTypes.oneOf[('text', 'picture', 'picture-card')],
|
|
44
|
+
//上传列表的内建样式,支持三种,默认text
|
|
45
|
+
readonly: PropTypes.bool,
|
|
46
|
+
//所在页面是否只读,默认false
|
|
47
|
+
multiple: PropTypes.bool,
|
|
48
|
+
//可否多选文件上传,默认true
|
|
49
|
+
limitNumber: PropTypes.number,
|
|
50
|
+
//附件限制个数,默认10
|
|
51
|
+
limitText: PropTypes.any,
|
|
52
|
+
//附件个数达到时的文本,或者设置为false则不显示,为true时显示默认文本,默认值true
|
|
53
|
+
limitSize: PropTypes.number,
|
|
54
|
+
//单个附件限制大小,单位M,默认5
|
|
55
|
+
buttonTitle: PropTypes.string,
|
|
56
|
+
//上传按钮的标题,默认‘上传’
|
|
57
|
+
onFileChange: PropTypes.func //文件变更的回掉函数,func({fileList, fileDeleteList})
|
|
58
|
+
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var convertFileList = function convertFileList(fileList) {
|
|
62
|
+
return _mapInstanceProperty(fileList).call(fileList, function (item) {
|
|
63
|
+
return {
|
|
64
|
+
fileFormat: item.fileFormat || 'id',
|
|
65
|
+
fileName: item.name,
|
|
66
|
+
fileUrl: item.response ? item.response.result : ''
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
var getUploadProps = function getUploadProps(props, onPreview, fileList, setFileList) {
|
|
72
|
+
var _props$readonly = props.readonly,
|
|
73
|
+
readonly = _props$readonly === void 0 ? false : _props$readonly,
|
|
74
|
+
_props$multiple = props.multiple,
|
|
75
|
+
multiple = _props$multiple === void 0 ? true : _props$multiple,
|
|
76
|
+
_props$limitSize = props.limitSize,
|
|
77
|
+
limitSize = _props$limitSize === void 0 ? 5 : _props$limitSize,
|
|
78
|
+
_props$listType = props.listType,
|
|
79
|
+
listType = _props$listType === void 0 ? 'picture-card' : _props$listType,
|
|
80
|
+
_props$fileDeleteList = props.fileDeleteList,
|
|
81
|
+
fileDeleteList = _props$fileDeleteList === void 0 ? [] : _props$fileDeleteList,
|
|
82
|
+
onFileChange = props.onFileChange;
|
|
83
|
+
|
|
84
|
+
var onChange = function onChange(_ref) {
|
|
85
|
+
var file = _ref.file,
|
|
86
|
+
fileList = _ref.fileList;
|
|
87
|
+
if (!file) return; //过滤掉不符合条件的响应
|
|
88
|
+
|
|
89
|
+
var newList = [];
|
|
90
|
+
|
|
91
|
+
if (file.response && file.response.returnCode !== 0) {
|
|
92
|
+
//检查是否上传到文件服务器成功
|
|
93
|
+
helper.showError("\u4E0A\u4F20\u5931\u8D25\uFF0C".concat(file.response.returnMsg || ''));
|
|
94
|
+
newList = _filterInstanceProperty(fileList).call(fileList, function (item) {
|
|
95
|
+
return item.uid !== file.uid;
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
var _context;
|
|
99
|
+
|
|
100
|
+
newList = _mapInstanceProperty(_context = _filterInstanceProperty(fileList).call(fileList, function (item) {
|
|
101
|
+
return item.status;
|
|
102
|
+
})).call(_context, function (item) {
|
|
103
|
+
return _indexOfInstanceProperty(FORMATS).call(FORMATS, item.type) === -1 ? _objectSpread(_objectSpread({}, item), {}, {
|
|
104
|
+
thumbUrl: '/default.png'
|
|
105
|
+
}) : item;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
file.response && onFileChange && onFileChange({
|
|
110
|
+
fileList: convertFileList(newList),
|
|
111
|
+
fileDeleteList: fileDeleteList
|
|
112
|
+
});
|
|
113
|
+
setFileList(newList);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var onRemove = /*#__PURE__*/function () {
|
|
117
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fileRemove) {
|
|
118
|
+
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
119
|
+
while (1) {
|
|
120
|
+
switch (_context2.prev = _context2.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
case "end":
|
|
123
|
+
return _context2.stop();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}, _callee);
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
return function onRemove(_x) {
|
|
130
|
+
return _ref2.apply(this, arguments);
|
|
131
|
+
};
|
|
132
|
+
}();
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
action: _this.props.action || '/api/proxy/zuul/ict-service/file/upload/document',
|
|
136
|
+
fileList: fileList,
|
|
137
|
+
listType: listType,
|
|
138
|
+
multiple: multiple,
|
|
139
|
+
onChange: onChange,
|
|
140
|
+
onRemove: onRemove,
|
|
141
|
+
onPreview: listType === 'text' ? undefined : onPreview,
|
|
142
|
+
beforeUpload: function beforeUpload(currentFile) {
|
|
143
|
+
var isLt = currentFile.size / 1024 / 1024 < limitSize; // 附件大小限制,单位M
|
|
144
|
+
|
|
145
|
+
if (!isLt) {
|
|
146
|
+
helper.showError("\u9644\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(limitSize, "M"));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return isLt;
|
|
150
|
+
},
|
|
151
|
+
showUploadList: {
|
|
152
|
+
showPreviewIcon: listType !== 'text',
|
|
153
|
+
showRemoveIcon: !readonly,
|
|
154
|
+
showDownloadIcon: true
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
function UploadButton(_ref3) {
|
|
160
|
+
var _ref3$buttonLabel = _ref3.buttonLabel,
|
|
161
|
+
buttonLabel = _ref3$buttonLabel === void 0 ? '上传' : _ref3$buttonLabel,
|
|
162
|
+
_ref3$title = _ref3.title,
|
|
163
|
+
title = _ref3$title === void 0 ? '附件' : _ref3$title,
|
|
164
|
+
_ref3$required = _ref3.required,
|
|
165
|
+
required = _ref3$required === void 0 ? false : _ref3$required,
|
|
166
|
+
_ref3$fileList = _ref3.fileList,
|
|
167
|
+
fileList = _ref3$fileList === void 0 ? [] : _ref3$fileList,
|
|
168
|
+
_ref3$limitText = _ref3.limitText,
|
|
169
|
+
limitText = _ref3$limitText === void 0 ? true : _ref3$limitText,
|
|
170
|
+
_ref3$limitNumber = _ref3.limitNumber,
|
|
171
|
+
limitNumber = _ref3$limitNumber === void 0 ? 10 : _ref3$limitNumber,
|
|
172
|
+
_ref3$listType = _ref3.listType,
|
|
173
|
+
listType = _ref3$listType === void 0 ? 'picture-card' : _ref3$listType;
|
|
174
|
+
var canUpload = fileList.length < limitNumber;
|
|
175
|
+
return canUpload ? listType === 'picture-card' ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Icon, {
|
|
176
|
+
type: "plus"
|
|
177
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
className: "ant-upload-text"
|
|
179
|
+
}, "Upload")) : /*#__PURE__*/React.createElement(Title, {
|
|
180
|
+
title: title,
|
|
181
|
+
required: required
|
|
182
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
|
183
|
+
size: "small",
|
|
184
|
+
style: {
|
|
185
|
+
display: 'block',
|
|
186
|
+
margin: '8px'
|
|
187
|
+
}
|
|
188
|
+
}, buttonLabel)) : listType === 'picture-card' ? null : /*#__PURE__*/React.createElement(Title, {
|
|
189
|
+
title: title,
|
|
190
|
+
required: required
|
|
191
|
+
}, !limitText ? null : /*#__PURE__*/React.createElement("span", null, limitText === true ? "\u9644\u4EF6\u4E2A\u6570\u82E5\u5927\u4E8E".concat(limitNumber, "\u4E2A\u8BF7\u538B\u7F29\u540E\u4E0A\u4F20") : limitText));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function SuperUpload(props) {
|
|
195
|
+
var _this2 = this;
|
|
196
|
+
|
|
197
|
+
var _useState = useState(true),
|
|
198
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
199
|
+
loading = _useState2[0],
|
|
200
|
+
setLoading = _useState2[1];
|
|
201
|
+
|
|
202
|
+
var _useState3 = useState([]),
|
|
203
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
204
|
+
fileList = _useState4[0],
|
|
205
|
+
setFileList = _useState4[1];
|
|
206
|
+
|
|
207
|
+
var getFileList = this.props.getFileList;
|
|
208
|
+
useEffect(function () {
|
|
209
|
+
function fetchImgData() {
|
|
210
|
+
return _fetchImgData.apply(this, arguments);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function _fetchImgData() {
|
|
214
|
+
_fetchImgData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
215
|
+
var initFileList;
|
|
216
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
217
|
+
while (1) {
|
|
218
|
+
switch (_context3.prev = _context3.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
_context3.next = 2;
|
|
221
|
+
return getFileList(props.fileList);
|
|
222
|
+
|
|
223
|
+
case 2:
|
|
224
|
+
initFileList = _context3.sent;
|
|
225
|
+
setFileList(initFileList);
|
|
226
|
+
setLoading(false);
|
|
227
|
+
|
|
228
|
+
case 5:
|
|
229
|
+
case "end":
|
|
230
|
+
return _context3.stop();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}, _callee2);
|
|
234
|
+
}));
|
|
235
|
+
return _fetchImgData.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
fetchImgData();
|
|
239
|
+
}, []);
|
|
240
|
+
|
|
241
|
+
var onPreview = /*#__PURE__*/function () {
|
|
242
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(file) {
|
|
243
|
+
var onPreview;
|
|
244
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
245
|
+
while (1) {
|
|
246
|
+
switch (_context4.prev = _context4.next) {
|
|
247
|
+
case 0:
|
|
248
|
+
onPreview = _this2.props.onPreview;
|
|
249
|
+
onPreview && onPreview(file);
|
|
250
|
+
|
|
251
|
+
case 2:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context4.stop();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}, _callee3);
|
|
257
|
+
}));
|
|
258
|
+
|
|
259
|
+
return function onPreview(_x2) {
|
|
260
|
+
return _ref4.apply(this, arguments);
|
|
261
|
+
};
|
|
262
|
+
}();
|
|
263
|
+
|
|
264
|
+
var uploadProps = getUploadProps(props, onPreview, fileList, setFileList);
|
|
265
|
+
var _props$listType2 = props.listType,
|
|
266
|
+
listType = _props$listType2 === void 0 ? 'picture-card' : _props$listType2,
|
|
267
|
+
_props$limitNumber = props.limitNumber,
|
|
268
|
+
limitNumber = _props$limitNumber === void 0 ? 10 : _props$limitNumber,
|
|
269
|
+
readonly = props.readonly,
|
|
270
|
+
title = props.title;
|
|
271
|
+
var className = listType === 'picture-card' && fileList.length < limitNumber ? variables('SuperUpload') : variables('SuperUpload2');
|
|
272
|
+
return loading ? /*#__PURE__*/React.createElement("div", null, "loading...") : /*#__PURE__*/React.createElement("div", {
|
|
273
|
+
className: className
|
|
274
|
+
}, (listType === 'picture-card' || readonly) && title ? /*#__PURE__*/React.createElement(Title, {
|
|
275
|
+
title: props.title || '附件',
|
|
276
|
+
required: props.required
|
|
277
|
+
}) : null, /*#__PURE__*/React.createElement(_Upload, uploadProps, readonly ? null : /*#__PURE__*/React.createElement(UploadButton, _objectSpread(_objectSpread({}, props), {}, {
|
|
278
|
+
fileList: fileList
|
|
279
|
+
}))));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export default SuperUpload;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@import '../variables.less';
|
|
2
|
+
|
|
3
|
+
.@{cloudlink-prefix}-SuperUpload{
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
|
|
6
|
+
:global(.ant-upload-list-item) {
|
|
7
|
+
display: inline-block;
|
|
8
|
+
margin: 10px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:global(.ant-upload-select-picture-card) {
|
|
12
|
+
margin: 10px;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.@{cloudlink-prefix}-SuperUpload2 {
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
|
|
19
|
+
:global(.ant-upload-list-item) {
|
|
20
|
+
display: inline-block;
|
|
21
|
+
margin: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:global(.ant-upload-select-picture-card) {
|
|
25
|
+
display: block !important;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import _Reflect$construct from "@babel/runtime-corejs3/core-js-stable/reflect/construct";
|
|
2
|
+
import _Icon from "antd/es/icon";
|
|
3
|
+
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime-corejs3/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime-corejs3/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
10
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
11
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
12
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
13
|
+
|
|
14
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
|
+
|
|
16
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17
|
+
|
|
18
|
+
import React from "react";
|
|
19
|
+
import variables from '../variables';
|
|
20
|
+
|
|
21
|
+
var addEvent = function addEvent(el, event, handler) {
|
|
22
|
+
if (!el) return;
|
|
23
|
+
|
|
24
|
+
if (el.attachEvent) {
|
|
25
|
+
el.attachEvent('on' + event, handler);
|
|
26
|
+
} else if (el.addEventListener) {
|
|
27
|
+
el.addEventListener(event, handler, false);
|
|
28
|
+
} else {
|
|
29
|
+
el['on' + event] = handler;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var removeEvent = function removeEvent(el, event, handler) {
|
|
34
|
+
if (!el) return;
|
|
35
|
+
|
|
36
|
+
if (el.detachEvent) {
|
|
37
|
+
el.detachEvent('on' + event, handler);
|
|
38
|
+
} else if (el.removeEventListener) {
|
|
39
|
+
el.removeEventListener(event, handler, false);
|
|
40
|
+
} else {
|
|
41
|
+
el['on' + event] = null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var getCss = function getCss(o, key) {
|
|
46
|
+
return o.currentStyle ? o.currentStyle[key] : document.defaultView.getComputedStyle(o)[key];
|
|
47
|
+
}; // 获取元素旋转的角度
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
var getRotateDeg = function getRotateDeg(target) {
|
|
51
|
+
var rotateMatrix = getCss(target, 'transform');
|
|
52
|
+
|
|
53
|
+
var _rotateMatrix$split$ = rotateMatrix.split('(')[1].split(')')[0].split(','),
|
|
54
|
+
_rotateMatrix$split$2 = _slicedToArray(_rotateMatrix$split$, 2),
|
|
55
|
+
a = _rotateMatrix$split$2[0],
|
|
56
|
+
b = _rotateMatrix$split$2[1];
|
|
57
|
+
|
|
58
|
+
return Math.round(Math.atan2(b, a) * (180 / Math.PI));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var ImageViews = /*#__PURE__*/function (_React$Component) {
|
|
62
|
+
_inherits(ImageViews, _React$Component);
|
|
63
|
+
|
|
64
|
+
var _super = _createSuper(ImageViews);
|
|
65
|
+
|
|
66
|
+
function ImageViews(props) {
|
|
67
|
+
var _this;
|
|
68
|
+
|
|
69
|
+
_classCallCheck(this, ImageViews);
|
|
70
|
+
|
|
71
|
+
_this = _super.call(this, props);
|
|
72
|
+
|
|
73
|
+
_defineProperty(_assertThisInitialized(_this), "_onwheel", function (e) {
|
|
74
|
+
var zoom = _this.state.zoom;
|
|
75
|
+
/*事件兼容*/
|
|
76
|
+
|
|
77
|
+
var event = e || window.event;
|
|
78
|
+
var imageDOM = _this.imgRef;
|
|
79
|
+
var delta;
|
|
80
|
+
|
|
81
|
+
if (event.nativeEvent.wheelDelta) {
|
|
82
|
+
delta = event.nativeEvent.wheelDelta / 1200;
|
|
83
|
+
} else if (event.nativeEvent.deltaY) {
|
|
84
|
+
delta = -event.nativeEvent.deltaY / 1200;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var zoomVal = zoom + delta;
|
|
88
|
+
|
|
89
|
+
if (zoomVal >= 0.2) {
|
|
90
|
+
imageDOM.style.transform = "translate(-50%,-50%) scale(".concat(zoomVal, ")");
|
|
91
|
+
} else {
|
|
92
|
+
zoomVal = 0.2;
|
|
93
|
+
imageDOM.style.transform = "translate(-50%,-50%) scale(".concat(zoomVal, ")");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_this.setState({
|
|
97
|
+
zoom: zoomVal
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "_onMouseDown", function (e) {
|
|
102
|
+
/*事件兼容*/
|
|
103
|
+
var event = e || window.event;
|
|
104
|
+
var imageDOM = _this.imgRef;
|
|
105
|
+
event.preventDefault(); //阻止浏览器的默认事件
|
|
106
|
+
|
|
107
|
+
var startTouch = {};
|
|
108
|
+
startTouch.initiated = true; //initiated为true表示开始滑动
|
|
109
|
+
|
|
110
|
+
/*获取鼠标按下的地方距离元素左侧和上侧的距离*/
|
|
111
|
+
|
|
112
|
+
startTouch.startX = event.nativeEvent.clientX - imageDOM.offsetLeft;
|
|
113
|
+
startTouch.startY = event.nativeEvent.clientY - imageDOM.offsetTop;
|
|
114
|
+
|
|
115
|
+
_this.setState({
|
|
116
|
+
startTouch: startTouch
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
addEvent(document, 'mousemove', _this._onMouseMove);
|
|
120
|
+
addEvent(document, 'mouseup', _this._onMouseUp);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
_defineProperty(_assertThisInitialized(_this), "_onMouseMove", function (e) {
|
|
124
|
+
var event = e || window.event;
|
|
125
|
+
var imageDOM = _this.imgRef;
|
|
126
|
+
var startTouch = _this.state.startTouch;
|
|
127
|
+
if (!startTouch.initiated) return; //滑动距离
|
|
128
|
+
|
|
129
|
+
var deltaX = event.clientX - startTouch.startX;
|
|
130
|
+
var deltaY = event.clientY - startTouch.startY;
|
|
131
|
+
imageDOM.style.left = "".concat(deltaX, "px");
|
|
132
|
+
imageDOM.style.top = "".concat(deltaY, "px");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
_defineProperty(_assertThisInitialized(_this), "_onMouseUp", function () {
|
|
136
|
+
var startTouch = _this.state.startTouch;
|
|
137
|
+
if (!startTouch.initiated) return;
|
|
138
|
+
var endTouch = JSON.parse(_JSON$stringify(startTouch));
|
|
139
|
+
endTouch.initiated = false;
|
|
140
|
+
|
|
141
|
+
_this.setState({
|
|
142
|
+
startTouch: startTouch
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
removeEvent(document, 'mousemove', _this._onMouseMove);
|
|
146
|
+
removeEvent(document, 'mouseup', _this._onMouseDown);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
_defineProperty(_assertThisInitialized(_this), "_onPlus", function (event) {
|
|
150
|
+
var zoom = _this.state.zoom;
|
|
151
|
+
var imageDOM = _this.imgRef;
|
|
152
|
+
var zoomVal = zoom + 0.1;
|
|
153
|
+
var originDeg = getRotateDeg(imageDOM);
|
|
154
|
+
event.stopPropagation();
|
|
155
|
+
|
|
156
|
+
if (zoomVal >= 0.2) {
|
|
157
|
+
var _context;
|
|
158
|
+
|
|
159
|
+
imageDOM.style.transform = _concatInstanceProperty(_context = "translate(-50%,-50%) scale(".concat(zoomVal, ") rotate(")).call(_context, originDeg, "deg)");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_this.setState({
|
|
163
|
+
zoom: zoomVal
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
_defineProperty(_assertThisInitialized(_this), "_onMinus", function () {
|
|
168
|
+
var _context2;
|
|
169
|
+
|
|
170
|
+
var zoom = _this.state.zoom;
|
|
171
|
+
var imageDOM = _this.imgRef;
|
|
172
|
+
var zoomVal = zoom - 0.1;
|
|
173
|
+
var originDeg = getRotateDeg(imageDOM);
|
|
174
|
+
|
|
175
|
+
if (zoomVal < 0.2) {
|
|
176
|
+
zoomVal = 0.2;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
imageDOM.style.transform = _concatInstanceProperty(_context2 = "translate(-50%,-50%) scale(".concat(zoomVal, ") rotate(")).call(_context2, originDeg, "deg)");
|
|
180
|
+
|
|
181
|
+
_this.setState({
|
|
182
|
+
zoom: zoomVal
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
_defineProperty(_assertThisInitialized(_this), "_reload", function () {
|
|
187
|
+
var imageDOM = _this.imgRef;
|
|
188
|
+
imageDOM.style.transform = "translate(-50%,-50%) scale(1) rotate(0deg)";
|
|
189
|
+
imageDOM.style.left = "50%";
|
|
190
|
+
imageDOM.style.top = "50%";
|
|
191
|
+
|
|
192
|
+
_this.setState({
|
|
193
|
+
zoom: 1
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
_defineProperty(_assertThisInitialized(_this), "_arrowLeft", function () {
|
|
198
|
+
var onLeft = _this.props.onLeft;
|
|
199
|
+
onLeft && onLeft();
|
|
200
|
+
var imageDOM = _this.imgRef;
|
|
201
|
+
imageDOM.style.transform = "translate(-50%,-50%) scale(1) rotate(0deg)";
|
|
202
|
+
imageDOM.style.left = "50%";
|
|
203
|
+
imageDOM.style.top = "50%";
|
|
204
|
+
|
|
205
|
+
_this.setState({
|
|
206
|
+
zoom: 1
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
_defineProperty(_assertThisInitialized(_this), "_arrowRight", function () {
|
|
211
|
+
var onRight = _this.props.onRight;
|
|
212
|
+
onRight && onRight();
|
|
213
|
+
var imageDOM = _this.imgRef;
|
|
214
|
+
imageDOM.style.transform = "translate(-50%,-50%) scale(1) rotate(0deg)";
|
|
215
|
+
imageDOM.style.left = "50%";
|
|
216
|
+
imageDOM.style.top = "50%";
|
|
217
|
+
|
|
218
|
+
_this.setState({
|
|
219
|
+
zoom: 1
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
_defineProperty(_assertThisInitialized(_this), "rotate", function (isLeft) {
|
|
224
|
+
return function () {
|
|
225
|
+
var _context3;
|
|
226
|
+
|
|
227
|
+
var imageDOM = _this.imgRef;
|
|
228
|
+
var originDeg = getRotateDeg(imageDOM);
|
|
229
|
+
var zoom = _this.state.zoom;
|
|
230
|
+
var rotateDeg = isLeft ? originDeg - 90 : originDeg + 90;
|
|
231
|
+
imageDOM.style.transform = _concatInstanceProperty(_context3 = "translate(-50%,-50%) rotate(".concat(rotateDeg, "deg) scale(")).call(_context3, zoom, ")");
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
_this.state = {
|
|
236
|
+
zoom: 1,
|
|
237
|
+
startTouch: {}
|
|
238
|
+
};
|
|
239
|
+
return _this;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
_createClass(ImageViews, [{
|
|
243
|
+
key: "render",
|
|
244
|
+
value: function render() {
|
|
245
|
+
var _this2 = this;
|
|
246
|
+
|
|
247
|
+
var image = this.props.image;
|
|
248
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
249
|
+
className: variables('ImageViews')
|
|
250
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
251
|
+
role: "imgWrapper"
|
|
252
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
253
|
+
src: image.src,
|
|
254
|
+
alt: image.alt,
|
|
255
|
+
ref: function ref(imgRef) {
|
|
256
|
+
_this2.imgRef = imgRef;
|
|
257
|
+
},
|
|
258
|
+
onWheel: this._onwheel //缩放事件
|
|
259
|
+
,
|
|
260
|
+
onMouseDown: this._onMouseDown //拖拽事件
|
|
261
|
+
|
|
262
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
263
|
+
className: variables('ImageViews').footer
|
|
264
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
265
|
+
className: variables('ImageViews').toolBar
|
|
266
|
+
}, /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
|
|
267
|
+
title: "\u653E\u5927",
|
|
268
|
+
onClick: this._onPlus,
|
|
269
|
+
onDoubleClick: function onDoubleClick(event) {
|
|
270
|
+
return event.preventDefault();
|
|
271
|
+
}
|
|
272
|
+
}, /*#__PURE__*/React.createElement(_Icon, {
|
|
273
|
+
type: "plus"
|
|
274
|
+
})), /*#__PURE__*/React.createElement("li", {
|
|
275
|
+
title: "\u7F29\u5C0F",
|
|
276
|
+
onClick: this._onMinus
|
|
277
|
+
}, /*#__PURE__*/React.createElement(_Icon, {
|
|
278
|
+
type: "minus"
|
|
279
|
+
})), /*#__PURE__*/React.createElement("li", {
|
|
280
|
+
title: "\u4E0A\u4E00\u5F20",
|
|
281
|
+
onClick: this._arrowLeft
|
|
282
|
+
}, /*#__PURE__*/React.createElement(_Icon, {
|
|
283
|
+
type: "arrow-left"
|
|
284
|
+
})), /*#__PURE__*/React.createElement("li", {
|
|
285
|
+
title: "\u4E0B\u4E00\u5F20",
|
|
286
|
+
onClick: this._arrowRight
|
|
287
|
+
}, /*#__PURE__*/React.createElement(_Icon, {
|
|
288
|
+
type: "arrow-right"
|
|
289
|
+
})), /*#__PURE__*/React.createElement("li", {
|
|
290
|
+
title: "\u5411\u5DE6\u65CB\u8F6C",
|
|
291
|
+
onClick: this.rotate(true)
|
|
292
|
+
}, /*#__PURE__*/React.createElement(_Icon, {
|
|
293
|
+
type: "pld-rotateleft"
|
|
294
|
+
})), /*#__PURE__*/React.createElement("li", {
|
|
295
|
+
title: "\u5411\u53F3\u65CB\u8F6C",
|
|
296
|
+
onClick: this.rotate(false)
|
|
297
|
+
}, /*#__PURE__*/React.createElement(_Icon, {
|
|
298
|
+
type: "pld-rotateright"
|
|
299
|
+
})), /*#__PURE__*/React.createElement("li", {
|
|
300
|
+
title: "\u590D\u539F",
|
|
301
|
+
onClick: this._reload
|
|
302
|
+
}, /*#__PURE__*/React.createElement(_Icon, {
|
|
303
|
+
type: "delete"
|
|
304
|
+
}))))));
|
|
305
|
+
}
|
|
306
|
+
}]);
|
|
307
|
+
|
|
308
|
+
return ImageViews;
|
|
309
|
+
}(React.Component);
|
|
310
|
+
|
|
311
|
+
export default ImageViews;
|