@titaui/pc 1.8.1 → 1.8.5
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/components/form/form-fields/input/index.js +1 -1
- package/lib/components/table/index.css +1 -0
- package/lib/components/upload-photo-modal/constant.js +10 -4
- package/lib/components/upload-photo-modal/index.js +17 -116
- package/package.json +1 -1
- package/src/components/form/form-fields/input/index.tsx +2 -2
- package/src/components/table/index.scss +1 -0
- package/src/components/upload-photo-modal/constant.ts +7 -1
- package/src/components/upload-photo-modal/index.tsx +14 -101
|
@@ -159,7 +159,7 @@ var _default = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
159
159
|
});
|
|
160
160
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
161
161
|
className: (0, _classnames["default"])(preCls, _defineProperty({}, "".concat(preCls, "-row"), layout === 'row'), className)
|
|
162
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
162
|
+
}, !!label && /*#__PURE__*/_react["default"].createElement("div", {
|
|
163
163
|
className: (0, _classnames["default"])("".concat(preCls, "__label"))
|
|
164
164
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
165
165
|
className: (0, _classnames["default"])("".concat(preCls, "__label-text"))
|
|
@@ -7,23 +7,29 @@ exports.List = void 0;
|
|
|
7
7
|
var List = [{
|
|
8
8
|
id: 'person',
|
|
9
9
|
accept: '.jpg,.jpeg,.gif,.png',
|
|
10
|
-
autoCropArea:
|
|
10
|
+
autoCropArea: 1,
|
|
11
11
|
initialAspectRatio: 1,
|
|
12
12
|
tips: '仅支持 jpg、jpeg、gif、png 格式 建议图片最小尺寸 150*150px',
|
|
13
|
-
previewTitle: '预览'
|
|
13
|
+
previewTitle: '预览',
|
|
14
|
+
minCropBoxHeight: 200,
|
|
15
|
+
minCropBoxWidth: 200
|
|
14
16
|
}, {
|
|
15
17
|
id: 'enterprise',
|
|
16
18
|
accept: '.jpg,.jpeg,.gif,.png',
|
|
17
19
|
autoCropArea: 1,
|
|
18
20
|
initialAspectRatio: 5,
|
|
19
21
|
tips: '建议 logo 尺寸 400*80 logo 最佳适配颜色为白色 仅支持 jpg、jpeg、gif、png 格式',
|
|
20
|
-
previewTitle: 'logo 预览'
|
|
22
|
+
previewTitle: 'logo 预览',
|
|
23
|
+
minCropBoxHeight: 20,
|
|
24
|
+
minCropBoxWidth: 20
|
|
21
25
|
}, {
|
|
22
26
|
id: 'browser',
|
|
23
27
|
accept: '',
|
|
24
28
|
autoCropArea: 0.5,
|
|
25
29
|
initialAspectRatio: 1,
|
|
26
30
|
tips: '图标尺寸 18*18,超过将被浏览器压缩',
|
|
27
|
-
previewTitle: '浏览器图标预览'
|
|
31
|
+
previewTitle: '浏览器图标预览',
|
|
32
|
+
minCropBoxHeight: 20,
|
|
33
|
+
minCropBoxWidth: 20
|
|
28
34
|
}];
|
|
29
35
|
exports.List = List;
|
|
@@ -27,8 +27,6 @@ var _constant = require("./constant");
|
|
|
27
27
|
|
|
28
28
|
require("./index.css");
|
|
29
29
|
|
|
30
|
-
var _uuid = _interopRequireDefault(require("uuid"));
|
|
31
|
-
|
|
32
30
|
var _bsGlobal = require("../../utils/bs-global");
|
|
33
31
|
|
|
34
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -37,10 +35,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
37
35
|
|
|
38
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
37
|
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
-
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
|
-
|
|
44
38
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
39
|
|
|
46
40
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -82,23 +76,21 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
82
76
|
cropData = _useState6[0],
|
|
83
77
|
setCropData = _useState6[1];
|
|
84
78
|
|
|
85
|
-
var _useState7 = (0, _react.useState)({
|
|
86
|
-
Avatar: ''
|
|
87
|
-
}),
|
|
88
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
89
|
-
userInfo = _useState8[0],
|
|
90
|
-
setUserInfo = _useState8[1];
|
|
91
|
-
|
|
92
|
-
var _useState9 = (0, _react.useState)(_constant.List.find(function (item) {
|
|
79
|
+
var _useState7 = (0, _react.useState)(_constant.List.find(function (item) {
|
|
93
80
|
return item.id === type;
|
|
94
81
|
})),
|
|
95
|
-
|
|
96
|
-
item =
|
|
82
|
+
_useState8 = _slicedToArray(_useState7, 1),
|
|
83
|
+
item = _useState8[0];
|
|
97
84
|
|
|
98
|
-
var
|
|
85
|
+
var _useState9 = (0, _react.useState)(false),
|
|
86
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
87
|
+
isEnter = _useState10[0],
|
|
88
|
+
setIsEnter = _useState10[1];
|
|
89
|
+
|
|
90
|
+
var _useState11 = (0, _react.useState)(''),
|
|
99
91
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
fileName = _useState12[0],
|
|
93
|
+
setFileName = _useState12[1];
|
|
102
94
|
|
|
103
95
|
var cropperRef = (0, _react.useRef)(null);
|
|
104
96
|
|
|
@@ -112,6 +104,7 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
112
104
|
files = e.target.files;
|
|
113
105
|
}
|
|
114
106
|
|
|
107
|
+
setFileName(files[0].name);
|
|
115
108
|
var reader = new FileReader();
|
|
116
109
|
|
|
117
110
|
reader.onload = function () {
|
|
@@ -141,19 +134,14 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
141
134
|
var imageElement = cropperRef.current;
|
|
142
135
|
var cropper = imageElement.cropper;
|
|
143
136
|
setCropData(cropper.getCroppedCanvas().toDataURL());
|
|
144
|
-
setUserInfo(cropper.getCroppedCanvas().toDataURL());
|
|
145
137
|
var base64Url = cropper.getCroppedCanvas().toDataURL();
|
|
146
|
-
var newFile = dataURLtoFile(base64Url,
|
|
147
|
-
console.log(newFile);
|
|
138
|
+
var newFile = dataURLtoFile(base64Url, fileName);
|
|
148
139
|
var formData = new FormData();
|
|
149
140
|
formData.append('file', newFile);
|
|
150
|
-
console.log(formData);
|
|
151
141
|
setCropper(formData);
|
|
152
142
|
};
|
|
153
143
|
|
|
154
144
|
var handleSaveInfo = function handleSaveInfo() {
|
|
155
|
-
var timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
156
|
-
|
|
157
145
|
if (!image) {
|
|
158
146
|
return;
|
|
159
147
|
} else {
|
|
@@ -172,7 +160,6 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
172
160
|
}
|
|
173
161
|
});
|
|
174
162
|
} else if (type === "enterprise") {
|
|
175
|
-
// console.log(cropper);
|
|
176
163
|
(0, _requestApi.saveTenantLogo)(cropper).then(function (resp) {
|
|
177
164
|
if (resp.Code === 1) {
|
|
178
165
|
_toast["default"].Success('保存成功', {
|
|
@@ -185,13 +172,7 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
185
172
|
canClose: false
|
|
186
173
|
});
|
|
187
174
|
}
|
|
188
|
-
});
|
|
189
|
-
// 'Content-Type': 'multipart/form-data',
|
|
190
|
-
// },
|
|
191
|
-
// method: 'post',
|
|
192
|
-
// data: cropper,
|
|
193
|
-
// url: `${apiServer}/api/v1/${tenantId}/${userid}/tenant/update/logo?format=json×tamp=${timestamp}`})
|
|
194
|
-
// dealSelectFiles(image)
|
|
175
|
+
});
|
|
195
176
|
} else {
|
|
196
177
|
(0, _requestApi.saveBrowserIcon)(cropper).then(function (resp) {
|
|
197
178
|
if (resp.Code === 1) {
|
|
@@ -210,83 +191,6 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
210
191
|
}
|
|
211
192
|
};
|
|
212
193
|
|
|
213
|
-
var _useState13 = (0, _react.useState)(),
|
|
214
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
215
|
-
uploadSuccessFile = _useState14[0],
|
|
216
|
-
setUploadSuccessFile = _useState14[1];
|
|
217
|
-
|
|
218
|
-
var dealSelectFiles = function dealSelectFiles(uploadSelectFile) {
|
|
219
|
-
var uploadStartFiles = []; // 开始上传的文件
|
|
220
|
-
|
|
221
|
-
var formData = new FormData(); // FormData 对象
|
|
222
|
-
|
|
223
|
-
var uploadStartFile;
|
|
224
|
-
var timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
225
|
-
// let uploadFileType = uploadSelectFile.name.substring(uploadSelectFile.name.lastIndexOf('.') + 1);
|
|
226
|
-
|
|
227
|
-
uploadStartFile = {
|
|
228
|
-
FileName: uploadSelectFile.name,
|
|
229
|
-
// FileType: _dealAttachmentType(uploadFileType).FileType,
|
|
230
|
-
FileSize: uploadSelectFile.size,
|
|
231
|
-
FileLastModified: uploadSelectFile.lastModified,
|
|
232
|
-
// IsImage: _dealAttachmentType(uploadFileType).IsImage,
|
|
233
|
-
percentComplete: 0,
|
|
234
|
-
uploadStatus: 1,
|
|
235
|
-
// 开始上传
|
|
236
|
-
IsSuccess: false,
|
|
237
|
-
uid: (0, _uuid["default"])(),
|
|
238
|
-
_smallImageUrl: '',
|
|
239
|
-
_bigImageUrl: '',
|
|
240
|
-
MediaType: '',
|
|
241
|
-
UserId: 0,
|
|
242
|
-
MaxDocCount: 0,
|
|
243
|
-
DfsPath: '',
|
|
244
|
-
ClientUrl: '',
|
|
245
|
-
SmallImageUrl: '',
|
|
246
|
-
BigImageUrl: '',
|
|
247
|
-
DownloadUrl: '',
|
|
248
|
-
Msg: '',
|
|
249
|
-
AllowUploadAttachmentSize: 50,
|
|
250
|
-
Deleteable: true,
|
|
251
|
-
requestXHR: new XMLHttpRequest() //在这创建是为了取消用
|
|
252
|
-
|
|
253
|
-
}; // uploadStartFiles.push(uploadStartFile);
|
|
254
|
-
// _dealUploadStart(uploadStartFiles); // 处理开始上传的文件
|
|
255
|
-
|
|
256
|
-
formData.append('file', uploadSelectFile);
|
|
257
|
-
var url = "".concat(apiServer, "/api/v1/").concat(tenantId, "/").concat(userid, "/tenant/update/logo");
|
|
258
|
-
|
|
259
|
-
_dealUploadXHRRequest(formData, url, uploadStartFile);
|
|
260
|
-
};
|
|
261
|
-
/**
|
|
262
|
-
* 处理文件上传请求
|
|
263
|
-
*
|
|
264
|
-
* @formData
|
|
265
|
-
* @url 上传文件请求地址
|
|
266
|
-
* @uploadStartFile 上传的文件
|
|
267
|
-
*
|
|
268
|
-
* @memberof Upload
|
|
269
|
-
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
var _dealUploadXHRRequest = function _dealUploadXHRRequest(formData, url, uploadStartFile) {
|
|
273
|
-
var xhr = uploadStartFile.requestXHR;
|
|
274
|
-
|
|
275
|
-
xhr.onreadystatechange = function () {
|
|
276
|
-
if (xhr.readyState == 4 && xhr.status == 200) {
|
|
277
|
-
var result = Object.assign({}, _objectSpread({}, JSON.parse(xhr.responseText).Result[0])); // 上传成功接口返回数据
|
|
278
|
-
|
|
279
|
-
result.percentComplete = 100;
|
|
280
|
-
result.IsSuccess = !!result.IsSuccess;
|
|
281
|
-
result.uploadStatus = result.IsSuccess ? 3 : 4; // 3上传成功;4上传失败
|
|
282
|
-
// _dealUploadSuccess({ ...uploadStartFile, ...result });
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
xhr.open('POST', url, true);
|
|
287
|
-
xhr.send(formData); //开始上传,发送form数据
|
|
288
|
-
};
|
|
289
|
-
|
|
290
194
|
var handleEnterAgain = function handleEnterAgain() {
|
|
291
195
|
setIsEnter(true);
|
|
292
196
|
};
|
|
@@ -372,15 +276,12 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
372
276
|
responsive: true,
|
|
373
277
|
autoCropArea: item === null || item === void 0 ? void 0 : item.autoCropArea,
|
|
374
278
|
checkOrientation: true,
|
|
375
|
-
minCropBoxHeight:
|
|
376
|
-
minCropBoxWidth:
|
|
279
|
+
minCropBoxHeight: item === null || item === void 0 ? void 0 : item.minCropBoxHeight,
|
|
280
|
+
minCropBoxWidth: item === null || item === void 0 ? void 0 : item.minCropBoxWidth,
|
|
377
281
|
initialAspectRatio: item === null || item === void 0 ? void 0 : item.initialAspectRatio,
|
|
378
282
|
guides: true,
|
|
379
283
|
preview: ".img-preview",
|
|
380
|
-
ref: cropperRef
|
|
381
|
-
// setCropper(instance);
|
|
382
|
-
// }}
|
|
383
|
-
,
|
|
284
|
+
ref: cropperRef,
|
|
384
285
|
crop: onCrop
|
|
385
286
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
386
287
|
className: (0, _classnames["default"])("".concat(preCls, "__preview-box"), _defineProperty({}, "".concat(preCls, "__preview-box-bgc"), type === "enterprise"), _defineProperty({}, "".concat(preCls, "__preview-box-browser"), type === "browser"))
|
package/package.json
CHANGED
|
@@ -110,10 +110,10 @@ export default forwardRef((props: Props, ref) => {
|
|
|
110
110
|
}))
|
|
111
111
|
|
|
112
112
|
return <div className={classNames(preCls,{[`${preCls}-row`]:layout==='row'},className)}>
|
|
113
|
-
<div className={classNames(`${preCls}__label`)}>
|
|
113
|
+
{!!label && <div className={classNames(`${preCls}__label`)}>
|
|
114
114
|
<span className={classNames(`${preCls}__label-text`)}>{label}</span>
|
|
115
115
|
{require && <span className={classNames(`${preCls}__label-require`)}>*</span>}
|
|
116
|
-
</div>
|
|
116
|
+
</div>}
|
|
117
117
|
<div className={classNames(`${preCls}__border`, {
|
|
118
118
|
[`${preCls}__border--error`]: hasError,
|
|
119
119
|
[`${preCls}__border--active`]: hasActive,
|
|
@@ -3,10 +3,12 @@ export const List = [
|
|
|
3
3
|
{
|
|
4
4
|
id: 'person',
|
|
5
5
|
accept: '.jpg,.jpeg,.gif,.png',
|
|
6
|
-
autoCropArea:
|
|
6
|
+
autoCropArea: 1,
|
|
7
7
|
initialAspectRatio: 1,
|
|
8
8
|
tips: '仅支持 jpg、jpeg、gif、png 格式 建议图片最小尺寸 150*150px',
|
|
9
9
|
previewTitle: '预览',
|
|
10
|
+
minCropBoxHeight: 200,
|
|
11
|
+
minCropBoxWidth: 200,
|
|
10
12
|
},
|
|
11
13
|
{
|
|
12
14
|
id: 'enterprise',
|
|
@@ -15,6 +17,8 @@ export const List = [
|
|
|
15
17
|
initialAspectRatio: 5,
|
|
16
18
|
tips: '建议 logo 尺寸 400*80 logo 最佳适配颜色为白色 仅支持 jpg、jpeg、gif、png 格式',
|
|
17
19
|
previewTitle: 'logo 预览',
|
|
20
|
+
minCropBoxHeight: 20,
|
|
21
|
+
minCropBoxWidth: 20,
|
|
18
22
|
},
|
|
19
23
|
{
|
|
20
24
|
id: 'browser',
|
|
@@ -23,5 +27,7 @@ export const List = [
|
|
|
23
27
|
initialAspectRatio: 1,
|
|
24
28
|
tips: '图标尺寸 18*18,超过将被浏览器压缩',
|
|
25
29
|
previewTitle: '浏览器图标预览',
|
|
30
|
+
minCropBoxHeight: 20,
|
|
31
|
+
minCropBoxWidth: 20,
|
|
26
32
|
}
|
|
27
33
|
];
|
|
@@ -4,13 +4,11 @@ import Cropper from 'react-cropper';
|
|
|
4
4
|
import 'cropperjs/dist/cropper.css';
|
|
5
5
|
import Toast from '../../components/toast';
|
|
6
6
|
import ConditionRender from '../condition-render';
|
|
7
|
-
import {
|
|
7
|
+
import { saveTenantLogo, saveBrowserIcon, saveUserPhoto } from './request-api';
|
|
8
8
|
import Dialog from '../../components/dialog';
|
|
9
9
|
import { List } from './constant'
|
|
10
10
|
import './index.scss';
|
|
11
11
|
import uuid from 'uuid';
|
|
12
|
-
import { rput, rpost } from "../../utils/request";
|
|
13
|
-
import axios from 'axios';
|
|
14
12
|
import { getBSGlobal, getUserInfo, getTenantInfo } from '../../utils/bs-global';
|
|
15
13
|
const apiServer = getBSGlobal("apiPath")
|
|
16
14
|
const userid = getUserInfo().Id;
|
|
@@ -33,23 +31,24 @@ const ChangePhoto = (props: Props) => {
|
|
|
33
31
|
const [ image, setImage ] = useState('');
|
|
34
32
|
const [ cropper, setCropper ] = useState<any>();
|
|
35
33
|
const [ cropData, setCropData ] = useState('#');
|
|
36
|
-
const [ userInfo, setUserInfo ] = useState({ Avatar: '' });
|
|
37
34
|
const [item] = useState(List.find(item => item.id === type));
|
|
38
35
|
const [isEnter, setIsEnter] = useState(false);
|
|
36
|
+
const [fileName, setFileName] = useState('')
|
|
39
37
|
|
|
40
38
|
const cropperRef = useRef<HTMLImageElement>(null);
|
|
41
39
|
|
|
42
|
-
const onChange = (e: any) => {
|
|
40
|
+
const onChange = (e: any) => {
|
|
43
41
|
e.preventDefault();
|
|
44
42
|
let files;
|
|
45
43
|
if (e.dataTransfer) {
|
|
46
44
|
files = e.dataTransfer.files;
|
|
47
45
|
} else if (e.target) {
|
|
48
46
|
files = e.target.files;
|
|
49
|
-
}
|
|
50
|
-
|
|
47
|
+
}
|
|
48
|
+
setFileName(files[0].name)
|
|
49
|
+
const reader = new FileReader();
|
|
51
50
|
reader.onload = () => {
|
|
52
|
-
setImage(reader.result as any);
|
|
51
|
+
setImage(reader.result as any);
|
|
53
52
|
};
|
|
54
53
|
reader.readAsDataURL(files[0]);
|
|
55
54
|
};
|
|
@@ -65,30 +64,24 @@ const ChangePhoto = (props: Props) => {
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
|
|
68
|
-
const onCrop = () => {
|
|
69
|
-
|
|
67
|
+
const onCrop = () => {
|
|
70
68
|
const imageElement: any = cropperRef.current;
|
|
71
|
-
const cropper: any = imageElement.cropper;
|
|
69
|
+
const cropper: any = imageElement.cropper;
|
|
72
70
|
|
|
73
71
|
setCropData(cropper.getCroppedCanvas().toDataURL());
|
|
74
|
-
setUserInfo(cropper.getCroppedCanvas().toDataURL());
|
|
75
|
-
|
|
76
|
-
let base64Url = cropper.getCroppedCanvas().toDataURL();
|
|
77
|
-
|
|
78
|
-
const newFile = dataURLtoFile(base64Url, 'test1234');
|
|
79
|
-
console.log(newFile);
|
|
80
72
|
|
|
73
|
+
let base64Url = cropper.getCroppedCanvas().toDataURL();
|
|
74
|
+
|
|
75
|
+
const newFile = dataURLtoFile(base64Url, fileName);
|
|
81
76
|
|
|
82
77
|
let formData = new FormData();
|
|
83
78
|
|
|
84
79
|
formData.append('file', newFile);
|
|
85
80
|
|
|
86
|
-
console.log(formData);
|
|
87
81
|
setCropper(formData);
|
|
88
82
|
};
|
|
89
83
|
|
|
90
84
|
const handleSaveInfo = () => {
|
|
91
|
-
let timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
92
85
|
if (!image) {
|
|
93
86
|
return;
|
|
94
87
|
} else {
|
|
@@ -102,8 +95,6 @@ const ChangePhoto = (props: Props) => {
|
|
|
102
95
|
}
|
|
103
96
|
});
|
|
104
97
|
} else if(type === "enterprise") {
|
|
105
|
-
// console.log(cropper);
|
|
106
|
-
|
|
107
98
|
saveTenantLogo( cropper ).then((resp) => {
|
|
108
99
|
if (resp.Code === 1) {
|
|
109
100
|
Toast.Success('保存成功', { canClose: false });
|
|
@@ -112,13 +103,6 @@ const ChangePhoto = (props: Props) => {
|
|
|
112
103
|
Toast.Error(resp.Message, { canClose: false });
|
|
113
104
|
}
|
|
114
105
|
});
|
|
115
|
-
// axios({headers: {
|
|
116
|
-
// 'Content-Type': 'multipart/form-data',
|
|
117
|
-
// },
|
|
118
|
-
// method: 'post',
|
|
119
|
-
// data: cropper,
|
|
120
|
-
// url: `${apiServer}/api/v1/${tenantId}/${userid}/tenant/update/logo?format=json×tamp=${timestamp}`})
|
|
121
|
-
// dealSelectFiles(image)
|
|
122
106
|
} else {
|
|
123
107
|
saveBrowserIcon( cropper ).then((resp) => {
|
|
124
108
|
if (resp.Code === 1) {
|
|
@@ -132,74 +116,6 @@ const ChangePhoto = (props: Props) => {
|
|
|
132
116
|
}
|
|
133
117
|
};
|
|
134
118
|
|
|
135
|
-
const [uploadSuccessFile, setUploadSuccessFile] = useState();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const dealSelectFiles = (uploadSelectFile) => {
|
|
139
|
-
|
|
140
|
-
let uploadStartFiles = []; // 开始上传的文件
|
|
141
|
-
let formData = new FormData(); // FormData 对象
|
|
142
|
-
let uploadStartFile;
|
|
143
|
-
let timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
144
|
-
// let uploadFileType = uploadSelectFile.name.substring(uploadSelectFile.name.lastIndexOf('.') + 1);
|
|
145
|
-
|
|
146
|
-
uploadStartFile = {
|
|
147
|
-
FileName: uploadSelectFile.name,
|
|
148
|
-
// FileType: _dealAttachmentType(uploadFileType).FileType,
|
|
149
|
-
FileSize: uploadSelectFile.size,
|
|
150
|
-
FileLastModified: uploadSelectFile.lastModified,
|
|
151
|
-
// IsImage: _dealAttachmentType(uploadFileType).IsImage,
|
|
152
|
-
percentComplete: 0,
|
|
153
|
-
uploadStatus: 1, // 开始上传
|
|
154
|
-
IsSuccess: false,
|
|
155
|
-
uid: uuid(),
|
|
156
|
-
_smallImageUrl: '',
|
|
157
|
-
_bigImageUrl: '',
|
|
158
|
-
MediaType: '',
|
|
159
|
-
UserId: 0,
|
|
160
|
-
MaxDocCount: 0,
|
|
161
|
-
DfsPath: '',
|
|
162
|
-
ClientUrl: '',
|
|
163
|
-
SmallImageUrl: '',
|
|
164
|
-
BigImageUrl: '',
|
|
165
|
-
DownloadUrl: '',
|
|
166
|
-
Msg: '',
|
|
167
|
-
AllowUploadAttachmentSize: 50,
|
|
168
|
-
Deleteable: true,
|
|
169
|
-
requestXHR: new XMLHttpRequest(), //在这创建是为了取消用
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// uploadStartFiles.push(uploadStartFile);
|
|
173
|
-
// _dealUploadStart(uploadStartFiles); // 处理开始上传的文件
|
|
174
|
-
formData.append('file', uploadSelectFile);
|
|
175
|
-
let url = `${apiServer}/api/v1/${tenantId}/${userid}/tenant/update/logo`;
|
|
176
|
-
_dealUploadXHRRequest(formData, url, uploadStartFile);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 处理文件上传请求
|
|
181
|
-
*
|
|
182
|
-
* @formData
|
|
183
|
-
* @url 上传文件请求地址
|
|
184
|
-
* @uploadStartFile 上传的文件
|
|
185
|
-
*
|
|
186
|
-
* @memberof Upload
|
|
187
|
-
*/
|
|
188
|
-
const _dealUploadXHRRequest = (formData: any, url: string, uploadStartFile) => {
|
|
189
|
-
let xhr = uploadStartFile.requestXHR;
|
|
190
|
-
xhr.onreadystatechange = () => {
|
|
191
|
-
if (xhr.readyState == 4 && xhr.status == 200) {
|
|
192
|
-
let result = Object.assign({}, { ...JSON.parse(xhr.responseText).Result[0] }); // 上传成功接口返回数据
|
|
193
|
-
result.percentComplete = 100;
|
|
194
|
-
result.IsSuccess = !!result.IsSuccess;
|
|
195
|
-
result.uploadStatus = result.IsSuccess ? 3 : 4; // 3上传成功;4上传失败
|
|
196
|
-
// _dealUploadSuccess({ ...uploadStartFile, ...result });
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
xhr.open('POST', url, true);
|
|
200
|
-
xhr.send(formData); //开始上传,发送form数据
|
|
201
|
-
};
|
|
202
|
-
|
|
203
119
|
const handleEnterAgain = () => {
|
|
204
120
|
setIsEnter(true);
|
|
205
121
|
}
|
|
@@ -277,15 +193,12 @@ const ChangePhoto = (props: Props) => {
|
|
|
277
193
|
responsive={true}
|
|
278
194
|
autoCropArea={item?.autoCropArea}
|
|
279
195
|
checkOrientation={true}
|
|
280
|
-
minCropBoxHeight={
|
|
281
|
-
minCropBoxWidth={
|
|
196
|
+
minCropBoxHeight={item?.minCropBoxHeight}
|
|
197
|
+
minCropBoxWidth={item?.minCropBoxWidth}
|
|
282
198
|
initialAspectRatio={item?.initialAspectRatio}
|
|
283
199
|
guides={true}
|
|
284
200
|
preview=".img-preview"
|
|
285
201
|
ref={cropperRef}
|
|
286
|
-
// onInitialized={(instance) => {
|
|
287
|
-
// setCropper(instance);
|
|
288
|
-
// }}
|
|
289
202
|
crop={onCrop}
|
|
290
203
|
/>
|
|
291
204
|
<div className={classNames(`${preCls}__preview-box`, {[`${preCls}__preview-box-bgc`]:type === "enterprise"}, {[`${preCls}__preview-box-browser`]:type === "browser"})}>
|