|
@@ -1,3 +1,168 @@
|
|
|
+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';
|
|
|
export default () => {
|
|
|
- return <div>企业信息页面</div>;
|
|
|
+ let showImgUrl = `/image-service/common/file_get?systemId=dataPlatform&key`;
|
|
|
+ const fileInputRef = useRef();
|
|
|
+ const [englishAbbreviation, setEnglishAbbreviation] = useState('');
|
|
|
+ const [abbreviation, setAbbreviation] = useState('');
|
|
|
+ const [intro, setIntro] = useState('');
|
|
|
+ const [companyName, setCompanyName] = useState('');
|
|
|
+ const [englishName, setEnglishName] = useState('');
|
|
|
+ const [logoUrl, setLogoUrl] = 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-----');
|
|
|
+ // };
|
|
|
+ },
|
|
|
+ [abbreviation, englishAbbreviation, intro, logoUrl],
|
|
|
+ );
|
|
|
+ const handleInfoChanged = useCallback(
|
|
|
+ (key, value) => {
|
|
|
+ send(key, value);
|
|
|
+ },
|
|
|
+ [abbreviation, englishAbbreviation, intro, logoUrl],
|
|
|
+ );
|
|
|
+ function getData() {
|
|
|
+ companyInfo().then((res) => {
|
|
|
+ const resData = res.data || {};
|
|
|
+ setEnglishAbbreviation(resData.englishAbbreviation || '');
|
|
|
+ setAbbreviation(resData.abbreviation || '');
|
|
|
+ setIntro(resData.intro || '');
|
|
|
+ setCompanyName(resData.companyName || '');
|
|
|
+ setEnglishName(resData.englishName || '');
|
|
|
+ // const logUrl = resData.logoUrl && `${showImgUrl}=${resData.logoUrl}`;
|
|
|
+ // setLogoUrl(logUrl || '');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const send = (key, value) => {
|
|
|
+ const params = {
|
|
|
+ abbreviation: abbreviation,
|
|
|
+ englishAbbreviation: englishAbbreviation,
|
|
|
+ intro: intro,
|
|
|
+ logoUrl: logoUrl,
|
|
|
+ };
|
|
|
+ params[key] = value;
|
|
|
+ companyUpdate(params).then((res) => {
|
|
|
+ message.success('修改成功');
|
|
|
+ getData();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (companyName == '') {
|
|
|
+ getData();
|
|
|
+ }
|
|
|
+ }, [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>}
|
|
|
+ </div>
|
|
|
+ <input
|
|
|
+ type="file"
|
|
|
+ hidden
|
|
|
+ accept="image/gif,image/jpeg,image/jpg,image/png"
|
|
|
+ ref={fileInputRef}
|
|
|
+ onChange={(e) => {
|
|
|
+ handleFileSelected(e);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <div className={styles.setLogo} onClick={() => fileInputRef.current.click()}>
|
|
|
+ 修改Logo
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className={styles.right}>
|
|
|
+ <div className={styles.contentLeft}>
|
|
|
+ <div className={styles.title}>{companyName}</div>
|
|
|
+ <div className={styles.slogan}>{englishName}</div>
|
|
|
+ <div className={styles.lableInput}>
|
|
|
+ <div className={styles.textLable} style={{ marginLeft: '75px', paddingTop: '84px' }}>
|
|
|
+ 公司口号
|
|
|
+ </div>
|
|
|
+ <div className={styles.inlineEditValue}>
|
|
|
+ <Input
|
|
|
+ value={intro}
|
|
|
+ bordered={false}
|
|
|
+ onChange={(e) => setIntro(e.target.value)}
|
|
|
+ onBlur={() => handleInfoChanged('intro', intro)}
|
|
|
+ onKeyUp={(e) => {
|
|
|
+ if (e.keyCode === 13) {
|
|
|
+ handleInfoChanged('intro', intro);
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {/* <Icon type="edit" /> */}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className={styles.contentRight}>
|
|
|
+ <div className={styles.lableInput}>
|
|
|
+ <div className={styles.textLable}>中文简称</div>
|
|
|
+ <div className={styles.inlineEditValue}>
|
|
|
+ <Input
|
|
|
+ value={abbreviation}
|
|
|
+ bordered={false}
|
|
|
+ onChange={(e) => setAbbreviation(e.target.value)}
|
|
|
+ onBlur={() => handleInfoChanged('abbreviation', abbreviation)}
|
|
|
+ onKeyUp={(e) => {
|
|
|
+ if (e.keyCode === 13) {
|
|
|
+ handleInfoChanged('abbreviation', abbreviation);
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {/* <Icon type="edit" /> */}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className={styles.lableInput} style={{ paddingTop: '68px' }}>
|
|
|
+ <div className={styles.textLable}>英文简称</div>
|
|
|
+ <div className={styles.inlineEditValue}>
|
|
|
+ <Input
|
|
|
+ value={englishAbbreviation}
|
|
|
+ bordered={false}
|
|
|
+ onChange={(e) => setEnglishAbbreviation(e.target.value)}
|
|
|
+ onBlur={() => handleInfoChanged('englishAbbreviation', englishAbbreviation)}
|
|
|
+ onKeyUp={(e) => {
|
|
|
+ if (e.keyCode === 13) {
|
|
|
+ handleInfoChanged('englishAbbreviation', englishAbbreviation);
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {/* <Icon type="edit" /> */}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
};
|