|
@@ -1,9 +1,13 @@
|
|
|
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
|
import styles from './index.less';
|
|
|
import { Input, message } from 'antd';
|
|
|
-import { companyInfo, companyUpdate } from '@/services/sagacare_service/infomation';
|
|
|
+import {
|
|
|
+ companyInfo,
|
|
|
+ companyUpdate,
|
|
|
+ importUsers,
|
|
|
+ getFileUrl,
|
|
|
+} from '@/services/sagacare_service/infomation';
|
|
|
export default () => {
|
|
|
- let showImgUrl = `/image-service/common/file_get?systemId=dataPlatform&key`;
|
|
|
const fileInputRef = useRef();
|
|
|
const [englishAbbreviation, setEnglishAbbreviation] = useState('');
|
|
|
const [abbreviation, setAbbreviation] = useState('');
|
|
@@ -11,37 +15,14 @@ export default () => {
|
|
|
const [companyName, setCompanyName] = useState('');
|
|
|
const [englishName, setEnglishName] = useState('');
|
|
|
const [logoUrl, setLogoUrl] = useState('');
|
|
|
+ const [imgUrl, setImgUrl] = useState('');
|
|
|
const handleFileSelected = useCallback(
|
|
|
(e) => {
|
|
|
const file = e.target.files[0];
|
|
|
- console.log(file, '-----文件11');
|
|
|
-
|
|
|
let fileName = file.name;
|
|
|
- let url = `/yongqi/oss/uploadOssFile`;
|
|
|
- // let url = `/image-service/duoduo-service/custom-service/oss/uploadOssFile`;
|
|
|
- let formData = new FormData();
|
|
|
- formData.append('file', file);
|
|
|
- // const reader = new FileReader();
|
|
|
- // // reader.readAsArrayBuffer(file);
|
|
|
- // reader.onload = () => {
|
|
|
- var xhr = new XMLHttpRequest();
|
|
|
- xhr.open('POST', url);
|
|
|
- xhr.setRequestHeader('Content-Type', 'application/form-data');
|
|
|
- xhr.send(formData);
|
|
|
-
|
|
|
- xhr.onreadystatechange = function () {
|
|
|
- if (xhr.readyState == 4) {
|
|
|
- if (xhr.status == 200) {
|
|
|
- message.success('文件上传成功');
|
|
|
- send('logoUrl', fileName);
|
|
|
- } else {
|
|
|
- message.error('文件上传失败');
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- console.log(xhr, '-------xhr-----');
|
|
|
- // };
|
|
|
+ importUsers(file).then((res) => {
|
|
|
+ send('logUrl', res.data.fileKey);
|
|
|
+ });
|
|
|
},
|
|
|
[abbreviation, englishAbbreviation, intro, logoUrl],
|
|
|
);
|
|
@@ -59,8 +40,7 @@ export default () => {
|
|
|
setIntro(resData.intro || '');
|
|
|
setCompanyName(resData.companyName || '');
|
|
|
setEnglishName(resData.englishName || '');
|
|
|
- // const logUrl = resData.logoUrl && `${showImgUrl}=${resData.logoUrl}`;
|
|
|
- // setLogoUrl(logUrl || '');
|
|
|
+ setLogoUrl(resData.logoUrl || '');
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -82,12 +62,17 @@ export default () => {
|
|
|
if (companyName == '') {
|
|
|
getData();
|
|
|
}
|
|
|
+ if (logoUrl) {
|
|
|
+ getFileUrl(logoUrl).then((res) => {
|
|
|
+ setImgUrl(res.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
}, [englishAbbreviation, abbreviation, intro, logoUrl, companyName]);
|
|
|
return (
|
|
|
<div className={styles.information}>
|
|
|
<div className={styles.left}>
|
|
|
<div className={styles.imgBox}>
|
|
|
- {logoUrl && <img className={styles.imgSt} src={logoUrl}></img>}
|
|
|
+ {imgUrl && <img className={styles.imgSt} src={imgUrl}></img>}
|
|
|
</div>
|
|
|
<input
|
|
|
type="file"
|