Ver a proveniência

企业LOGO更新

tags/小炒逻辑变更前
yangwenhua há 2 anos
ascendente
cometimento
8c25f29e59
2 ficheiros alterados com 41 adições e 20 eliminações
  1. +18
    -18
      src/pages/sys/sysSettings/components/EnterpriseLog.jsx
  2. +23
    -2
      src/pages/sys/sysSettings/index.jsx

+ 18
- 18
src/pages/sys/sysSettings/components/EnterpriseLog.jsx Ver ficheiro

@@ -23,10 +23,10 @@ const AvatarView = ({ avatar, url, uploadProp }) => (
</>
);

const EnterpriseLog = () => {
const { data: CompanyInfo, loading } = useRequest(() => {
return GetCompanyInfo();
});
const EnterpriseLog = (props) => {
// const { data: CompanyInfo, loading } = useRequest(() => {
// return GetCompanyInfo();
// });
const [url, setUrl] = useState();
const [cosInfo, SetCosInfo] = useState({
domain: '',
@@ -77,11 +77,15 @@ const EnterpriseLog = () => {
onProgress({ percent: Math.round(loaded / total * 100).toFixed(2) }, file);
},
}).then(response => {
console.log('onSuccess', response, file);
// console.log('onSuccess', response, file);
if (response.status == 200 || response.statusText == 'OK') {
setUrl(r.seeUrl);
CompanyInfo.logo = r.seeUrl;
updateCompany(CompanyInfo);
// setUrl(r.seeUrl);
const company = JSON.parse(JSON.stringify(props.fetchCompanyInfo));
company.logo = r.seeUrl;
// console.log('LOGO变更', company.logo)
props.onUpdateCompanyInfo(company);
// CompanyInfo.logo = r.seeUrl;
// updateCompany(CompanyInfo);
}
// onSuccess(response, file);
})
@@ -99,16 +103,12 @@ const EnterpriseLog = () => {
};
return (
<div className={styles.baseView}>
{loading ? null : (
<>
<div className={styles.right}>
<AvatarView
url={CompanyInfo.logo ? CompanyInfo.logo:'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png' }
uploadProp={uploadProps}
/>
</div>
</>
)}
<div className={styles.right}>
<AvatarView
url={props.fetchCompanyInfo.logo ? props.fetchCompanyInfo.logo : 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'}
uploadProp={uploadProps}
/>
</div>
</div>
);
};


+ 23
- 2
src/pages/sys/sysSettings/index.jsx Ver ficheiro

@@ -1,9 +1,10 @@
import React, { useState, useRef, useLayoutEffect } from 'react';
import React, { useState, useRef, useLayoutEffect, useEffect } from 'react';
import { GridContent } from '@ant-design/pro-layout';
import { Menu } from 'antd';
import BaseView from './components/base';
import EnterpriseLog from './components/EnterpriseLog';
import styles from './style.less';
import { GetCompanyInfo, GetCosRequestURL, updateCompany } from './components/service';
const { Item } = Menu;

const Settings = () => {
@@ -16,6 +17,9 @@ const Settings = () => {
selectKey: 'EnterpriseLog',
});
const dom = useRef();
const [fetchCompanyInfo, setFetchCompanyInfo] = useState({
logo: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'
});

const resize = () => {
requestAnimationFrame(() => {
@@ -61,13 +65,30 @@ const Settings = () => {
// return <BaseView />;

case 'EnterpriseLog':
return <EnterpriseLog />;
return <EnterpriseLog fetchCompanyInfo={fetchCompanyInfo} onUpdateCompanyInfo={onUpdateCompanyInfo} />;

default:
return null;
}
};

const onUpdateCompanyInfo = (companyInfo) => {
updateCompany(companyInfo).then(() => {
onFetchCompanyInfo();
});
}

const onFetchCompanyInfo = async () => {
const response = await GetCompanyInfo();
if (response.statusCode === 200) {
setFetchCompanyInfo(response.data);
}
}

useEffect(() => {
onFetchCompanyInfo();
}, []);

return (
<GridContent>
<div


Carregando…
Cancelar
Guardar