@titaui/pc 1.8.4 → 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 +15 -120
- 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 +11 -99
|
@@ -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,28 +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
|
|
99
|
-
|
|
100
|
-
isEnter =
|
|
101
|
-
setIsEnter =
|
|
85
|
+
var _useState9 = (0, _react.useState)(false),
|
|
86
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
87
|
+
isEnter = _useState10[0],
|
|
88
|
+
setIsEnter = _useState10[1];
|
|
102
89
|
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
fileName =
|
|
106
|
-
setFileName =
|
|
90
|
+
var _useState11 = (0, _react.useState)(''),
|
|
91
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
92
|
+
fileName = _useState12[0],
|
|
93
|
+
setFileName = _useState12[1];
|
|
107
94
|
|
|
108
95
|
var cropperRef = (0, _react.useRef)(null);
|
|
109
96
|
|
|
@@ -147,19 +134,14 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
147
134
|
var imageElement = cropperRef.current;
|
|
148
135
|
var cropper = imageElement.cropper;
|
|
149
136
|
setCropData(cropper.getCroppedCanvas().toDataURL());
|
|
150
|
-
setUserInfo(cropper.getCroppedCanvas().toDataURL());
|
|
151
137
|
var base64Url = cropper.getCroppedCanvas().toDataURL();
|
|
152
138
|
var newFile = dataURLtoFile(base64Url, fileName);
|
|
153
|
-
console.log(newFile);
|
|
154
139
|
var formData = new FormData();
|
|
155
140
|
formData.append('file', newFile);
|
|
156
|
-
console.log(formData);
|
|
157
141
|
setCropper(formData);
|
|
158
142
|
};
|
|
159
143
|
|
|
160
144
|
var handleSaveInfo = function handleSaveInfo() {
|
|
161
|
-
var timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
162
|
-
|
|
163
145
|
if (!image) {
|
|
164
146
|
return;
|
|
165
147
|
} else {
|
|
@@ -178,7 +160,6 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
178
160
|
}
|
|
179
161
|
});
|
|
180
162
|
} else if (type === "enterprise") {
|
|
181
|
-
// console.log(cropper);
|
|
182
163
|
(0, _requestApi.saveTenantLogo)(cropper).then(function (resp) {
|
|
183
164
|
if (resp.Code === 1) {
|
|
184
165
|
_toast["default"].Success('保存成功', {
|
|
@@ -191,13 +172,7 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
191
172
|
canClose: false
|
|
192
173
|
});
|
|
193
174
|
}
|
|
194
|
-
});
|
|
195
|
-
// 'Content-Type': 'multipart/form-data',
|
|
196
|
-
// },
|
|
197
|
-
// method: 'post',
|
|
198
|
-
// data: cropper,
|
|
199
|
-
// url: `${apiServer}/api/v1/${tenantId}/${userid}/tenant/update/logo?format=json×tamp=${timestamp}`})
|
|
200
|
-
// dealSelectFiles(image)
|
|
175
|
+
});
|
|
201
176
|
} else {
|
|
202
177
|
(0, _requestApi.saveBrowserIcon)(cropper).then(function (resp) {
|
|
203
178
|
if (resp.Code === 1) {
|
|
@@ -216,83 +191,6 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
216
191
|
}
|
|
217
192
|
};
|
|
218
193
|
|
|
219
|
-
var _useState15 = (0, _react.useState)(),
|
|
220
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
221
|
-
uploadSuccessFile = _useState16[0],
|
|
222
|
-
setUploadSuccessFile = _useState16[1];
|
|
223
|
-
|
|
224
|
-
var dealSelectFiles = function dealSelectFiles(uploadSelectFile) {
|
|
225
|
-
var uploadStartFiles = []; // 开始上传的文件
|
|
226
|
-
|
|
227
|
-
var formData = new FormData(); // FormData 对象
|
|
228
|
-
|
|
229
|
-
var uploadStartFile;
|
|
230
|
-
var timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
231
|
-
// let uploadFileType = uploadSelectFile.name.substring(uploadSelectFile.name.lastIndexOf('.') + 1);
|
|
232
|
-
|
|
233
|
-
uploadStartFile = {
|
|
234
|
-
FileName: uploadSelectFile.name,
|
|
235
|
-
// FileType: _dealAttachmentType(uploadFileType).FileType,
|
|
236
|
-
FileSize: uploadSelectFile.size,
|
|
237
|
-
FileLastModified: uploadSelectFile.lastModified,
|
|
238
|
-
// IsImage: _dealAttachmentType(uploadFileType).IsImage,
|
|
239
|
-
percentComplete: 0,
|
|
240
|
-
uploadStatus: 1,
|
|
241
|
-
// 开始上传
|
|
242
|
-
IsSuccess: false,
|
|
243
|
-
uid: (0, _uuid["default"])(),
|
|
244
|
-
_smallImageUrl: '',
|
|
245
|
-
_bigImageUrl: '',
|
|
246
|
-
MediaType: '',
|
|
247
|
-
UserId: 0,
|
|
248
|
-
MaxDocCount: 0,
|
|
249
|
-
DfsPath: '',
|
|
250
|
-
ClientUrl: '',
|
|
251
|
-
SmallImageUrl: '',
|
|
252
|
-
BigImageUrl: '',
|
|
253
|
-
DownloadUrl: '',
|
|
254
|
-
Msg: '',
|
|
255
|
-
AllowUploadAttachmentSize: 50,
|
|
256
|
-
Deleteable: true,
|
|
257
|
-
requestXHR: new XMLHttpRequest() //在这创建是为了取消用
|
|
258
|
-
|
|
259
|
-
}; // uploadStartFiles.push(uploadStartFile);
|
|
260
|
-
// _dealUploadStart(uploadStartFiles); // 处理开始上传的文件
|
|
261
|
-
|
|
262
|
-
formData.append('file', uploadSelectFile);
|
|
263
|
-
var url = "".concat(apiServer, "/api/v1/").concat(tenantId, "/").concat(userid, "/tenant/update/logo");
|
|
264
|
-
|
|
265
|
-
_dealUploadXHRRequest(formData, url, uploadStartFile);
|
|
266
|
-
};
|
|
267
|
-
/**
|
|
268
|
-
* 处理文件上传请求
|
|
269
|
-
*
|
|
270
|
-
* @formData
|
|
271
|
-
* @url 上传文件请求地址
|
|
272
|
-
* @uploadStartFile 上传的文件
|
|
273
|
-
*
|
|
274
|
-
* @memberof Upload
|
|
275
|
-
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
var _dealUploadXHRRequest = function _dealUploadXHRRequest(formData, url, uploadStartFile) {
|
|
279
|
-
var xhr = uploadStartFile.requestXHR;
|
|
280
|
-
|
|
281
|
-
xhr.onreadystatechange = function () {
|
|
282
|
-
if (xhr.readyState == 4 && xhr.status == 200) {
|
|
283
|
-
var result = Object.assign({}, _objectSpread({}, JSON.parse(xhr.responseText).Result[0])); // 上传成功接口返回数据
|
|
284
|
-
|
|
285
|
-
result.percentComplete = 100;
|
|
286
|
-
result.IsSuccess = !!result.IsSuccess;
|
|
287
|
-
result.uploadStatus = result.IsSuccess ? 3 : 4; // 3上传成功;4上传失败
|
|
288
|
-
// _dealUploadSuccess({ ...uploadStartFile, ...result });
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
xhr.open('POST', url, true);
|
|
293
|
-
xhr.send(formData); //开始上传,发送form数据
|
|
294
|
-
};
|
|
295
|
-
|
|
296
194
|
var handleEnterAgain = function handleEnterAgain() {
|
|
297
195
|
setIsEnter(true);
|
|
298
196
|
};
|
|
@@ -378,15 +276,12 @@ var ChangePhoto = function ChangePhoto(props) {
|
|
|
378
276
|
responsive: true,
|
|
379
277
|
autoCropArea: item === null || item === void 0 ? void 0 : item.autoCropArea,
|
|
380
278
|
checkOrientation: true,
|
|
381
|
-
minCropBoxHeight:
|
|
382
|
-
minCropBoxWidth:
|
|
279
|
+
minCropBoxHeight: item === null || item === void 0 ? void 0 : item.minCropBoxHeight,
|
|
280
|
+
minCropBoxWidth: item === null || item === void 0 ? void 0 : item.minCropBoxWidth,
|
|
383
281
|
initialAspectRatio: item === null || item === void 0 ? void 0 : item.initialAspectRatio,
|
|
384
282
|
guides: true,
|
|
385
283
|
preview: ".img-preview",
|
|
386
|
-
ref: cropperRef
|
|
387
|
-
// setCropper(instance);
|
|
388
|
-
// }}
|
|
389
|
-
,
|
|
284
|
+
ref: cropperRef,
|
|
390
285
|
crop: onCrop
|
|
391
286
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
392
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,25 +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);
|
|
39
36
|
const [fileName, setFileName] = useState('')
|
|
40
37
|
|
|
41
38
|
const cropperRef = useRef<HTMLImageElement>(null);
|
|
42
39
|
|
|
43
|
-
const onChange = (e: any) => {
|
|
40
|
+
const onChange = (e: any) => {
|
|
44
41
|
e.preventDefault();
|
|
45
42
|
let files;
|
|
46
43
|
if (e.dataTransfer) {
|
|
47
44
|
files = e.dataTransfer.files;
|
|
48
45
|
} else if (e.target) {
|
|
49
46
|
files = e.target.files;
|
|
50
|
-
}
|
|
47
|
+
}
|
|
51
48
|
setFileName(files[0].name)
|
|
52
49
|
const reader = new FileReader();
|
|
53
50
|
reader.onload = () => {
|
|
54
|
-
setImage(reader.result as any);
|
|
51
|
+
setImage(reader.result as any);
|
|
55
52
|
};
|
|
56
53
|
reader.readAsDataURL(files[0]);
|
|
57
54
|
};
|
|
@@ -67,30 +64,24 @@ const ChangePhoto = (props: Props) => {
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
|
|
70
|
-
const onCrop = () => {
|
|
71
|
-
|
|
67
|
+
const onCrop = () => {
|
|
72
68
|
const imageElement: any = cropperRef.current;
|
|
73
|
-
const cropper: any = imageElement.cropper;
|
|
69
|
+
const cropper: any = imageElement.cropper;
|
|
74
70
|
|
|
75
71
|
setCropData(cropper.getCroppedCanvas().toDataURL());
|
|
76
|
-
setUserInfo(cropper.getCroppedCanvas().toDataURL());
|
|
77
|
-
|
|
78
|
-
let base64Url = cropper.getCroppedCanvas().toDataURL();
|
|
79
|
-
|
|
80
|
-
const newFile = dataURLtoFile(base64Url, fileName);
|
|
81
|
-
console.log(newFile);
|
|
82
72
|
|
|
73
|
+
let base64Url = cropper.getCroppedCanvas().toDataURL();
|
|
74
|
+
|
|
75
|
+
const newFile = dataURLtoFile(base64Url, fileName);
|
|
83
76
|
|
|
84
77
|
let formData = new FormData();
|
|
85
78
|
|
|
86
79
|
formData.append('file', newFile);
|
|
87
80
|
|
|
88
|
-
console.log(formData);
|
|
89
81
|
setCropper(formData);
|
|
90
82
|
};
|
|
91
83
|
|
|
92
84
|
const handleSaveInfo = () => {
|
|
93
|
-
let timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
94
85
|
if (!image) {
|
|
95
86
|
return;
|
|
96
87
|
} else {
|
|
@@ -104,7 +95,6 @@ const ChangePhoto = (props: Props) => {
|
|
|
104
95
|
}
|
|
105
96
|
});
|
|
106
97
|
} else if(type === "enterprise") {
|
|
107
|
-
// console.log(cropper);
|
|
108
98
|
saveTenantLogo( cropper ).then((resp) => {
|
|
109
99
|
if (resp.Code === 1) {
|
|
110
100
|
Toast.Success('保存成功', { canClose: false });
|
|
@@ -113,13 +103,6 @@ const ChangePhoto = (props: Props) => {
|
|
|
113
103
|
Toast.Error(resp.Message, { canClose: false });
|
|
114
104
|
}
|
|
115
105
|
});
|
|
116
|
-
// axios({headers: {
|
|
117
|
-
// 'Content-Type': 'multipart/form-data',
|
|
118
|
-
// },
|
|
119
|
-
// method: 'post',
|
|
120
|
-
// data: cropper,
|
|
121
|
-
// url: `${apiServer}/api/v1/${tenantId}/${userid}/tenant/update/logo?format=json×tamp=${timestamp}`})
|
|
122
|
-
// dealSelectFiles(image)
|
|
123
106
|
} else {
|
|
124
107
|
saveBrowserIcon( cropper ).then((resp) => {
|
|
125
108
|
if (resp.Code === 1) {
|
|
@@ -133,74 +116,6 @@ const ChangePhoto = (props: Props) => {
|
|
|
133
116
|
}
|
|
134
117
|
};
|
|
135
118
|
|
|
136
|
-
const [uploadSuccessFile, setUploadSuccessFile] = useState();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const dealSelectFiles = (uploadSelectFile) => {
|
|
140
|
-
|
|
141
|
-
let uploadStartFiles = []; // 开始上传的文件
|
|
142
|
-
let formData = new FormData(); // FormData 对象
|
|
143
|
-
let uploadStartFile;
|
|
144
|
-
let timestamp = new Date().getTime(); // 给每个文件加一个时间戳
|
|
145
|
-
// let uploadFileType = uploadSelectFile.name.substring(uploadSelectFile.name.lastIndexOf('.') + 1);
|
|
146
|
-
|
|
147
|
-
uploadStartFile = {
|
|
148
|
-
FileName: uploadSelectFile.name,
|
|
149
|
-
// FileType: _dealAttachmentType(uploadFileType).FileType,
|
|
150
|
-
FileSize: uploadSelectFile.size,
|
|
151
|
-
FileLastModified: uploadSelectFile.lastModified,
|
|
152
|
-
// IsImage: _dealAttachmentType(uploadFileType).IsImage,
|
|
153
|
-
percentComplete: 0,
|
|
154
|
-
uploadStatus: 1, // 开始上传
|
|
155
|
-
IsSuccess: false,
|
|
156
|
-
uid: uuid(),
|
|
157
|
-
_smallImageUrl: '',
|
|
158
|
-
_bigImageUrl: '',
|
|
159
|
-
MediaType: '',
|
|
160
|
-
UserId: 0,
|
|
161
|
-
MaxDocCount: 0,
|
|
162
|
-
DfsPath: '',
|
|
163
|
-
ClientUrl: '',
|
|
164
|
-
SmallImageUrl: '',
|
|
165
|
-
BigImageUrl: '',
|
|
166
|
-
DownloadUrl: '',
|
|
167
|
-
Msg: '',
|
|
168
|
-
AllowUploadAttachmentSize: 50,
|
|
169
|
-
Deleteable: true,
|
|
170
|
-
requestXHR: new XMLHttpRequest(), //在这创建是为了取消用
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
// uploadStartFiles.push(uploadStartFile);
|
|
174
|
-
// _dealUploadStart(uploadStartFiles); // 处理开始上传的文件
|
|
175
|
-
formData.append('file', uploadSelectFile);
|
|
176
|
-
let url = `${apiServer}/api/v1/${tenantId}/${userid}/tenant/update/logo`;
|
|
177
|
-
_dealUploadXHRRequest(formData, url, uploadStartFile);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* 处理文件上传请求
|
|
182
|
-
*
|
|
183
|
-
* @formData
|
|
184
|
-
* @url 上传文件请求地址
|
|
185
|
-
* @uploadStartFile 上传的文件
|
|
186
|
-
*
|
|
187
|
-
* @memberof Upload
|
|
188
|
-
*/
|
|
189
|
-
const _dealUploadXHRRequest = (formData: any, url: string, uploadStartFile) => {
|
|
190
|
-
let xhr = uploadStartFile.requestXHR;
|
|
191
|
-
xhr.onreadystatechange = () => {
|
|
192
|
-
if (xhr.readyState == 4 && xhr.status == 200) {
|
|
193
|
-
let result = Object.assign({}, { ...JSON.parse(xhr.responseText).Result[0] }); // 上传成功接口返回数据
|
|
194
|
-
result.percentComplete = 100;
|
|
195
|
-
result.IsSuccess = !!result.IsSuccess;
|
|
196
|
-
result.uploadStatus = result.IsSuccess ? 3 : 4; // 3上传成功;4上传失败
|
|
197
|
-
// _dealUploadSuccess({ ...uploadStartFile, ...result });
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
xhr.open('POST', url, true);
|
|
201
|
-
xhr.send(formData); //开始上传,发送form数据
|
|
202
|
-
};
|
|
203
|
-
|
|
204
119
|
const handleEnterAgain = () => {
|
|
205
120
|
setIsEnter(true);
|
|
206
121
|
}
|
|
@@ -278,15 +193,12 @@ const ChangePhoto = (props: Props) => {
|
|
|
278
193
|
responsive={true}
|
|
279
194
|
autoCropArea={item?.autoCropArea}
|
|
280
195
|
checkOrientation={true}
|
|
281
|
-
minCropBoxHeight={
|
|
282
|
-
minCropBoxWidth={
|
|
196
|
+
minCropBoxHeight={item?.minCropBoxHeight}
|
|
197
|
+
minCropBoxWidth={item?.minCropBoxWidth}
|
|
283
198
|
initialAspectRatio={item?.initialAspectRatio}
|
|
284
199
|
guides={true}
|
|
285
200
|
preview=".img-preview"
|
|
286
201
|
ref={cropperRef}
|
|
287
|
-
// onInitialized={(instance) => {
|
|
288
|
-
// setCropper(instance);
|
|
289
|
-
// }}
|
|
290
202
|
crop={onCrop}
|
|
291
203
|
/>
|
|
292
204
|
<div className={classNames(`${preCls}__preview-box`, {[`${preCls}__preview-box-bgc`]:type === "enterprise"}, {[`${preCls}__preview-box-browser`]:type === "browser"})}>
|