From b673ce07b6d649d94367ded12a7989cbdcc7bd4b Mon Sep 17 00:00:00 2001 From: red-deng-deng <1924913374@qq.com> Date: Sun, 28 Nov 2021 11:58:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9B=BE=E7=89=87=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=B4=E6=9C=AA=E5=B8=A6token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 8 +++++++- .../system/account/add/adduserinfo/adduserinfo.js | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index 633c6519..46b6585f 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -5,6 +5,9 @@ window.baseurl = 'http://192.168.6.75'; const upload = (method, url, params, responseType) => { let obj = { method: method, + headers: new Headers({ + 'authorization': sessionStorage.getItem("authorization") + }), body: params, } let http = fetch(url, obj).then(res =>{ @@ -15,7 +18,10 @@ const upload = (method, url, params, responseType) => { const derive = (method, url, params, responseType) => { var obj = { - responseType: 'blob' + responseType: 'blob', + headers: new Headers({ + 'authorization': sessionStorage.getItem("authorization") + }) }; if (method == "get") { if (params) { diff --git a/src/pages/system/account/add/adduserinfo/adduserinfo.js b/src/pages/system/account/add/adduserinfo/adduserinfo.js index c30134ed..ade1ce40 100644 --- a/src/pages/system/account/add/adduserinfo/adduserinfo.js +++ b/src/pages/system/account/add/adduserinfo/adduserinfo.js @@ -39,13 +39,17 @@ export default class adduserinfo extends React.Component{ componentDidMount(e){ } componentWillMount(){ - console.log(this.state); let _self=this; + this.getCompanyFn();//获取公司 let companys=JSON.parse(sessionStorage.getItem('company')); + if(!companys){ this.getCompanyFn();//获取公司 + } + + this.getRoleFn();//获取角色 let formInfo=this.props; - if(formInfo.enumer==1){ + if(formInfo&&formInfo.enumer==1){ let acceptData=_.cloneDeep(formInfo.rowData); let data={ user_name:acceptData.user_name, @@ -62,7 +66,7 @@ export default class adduserinfo extends React.Component{ img.src=acceptData.head; this.setState({model:data,disabled:true,defaultFileList:[img],id:acceptData.id,headImg:acceptData.head}); //若有公司id,静默获取部门 - if(data.company.key){ + if(data.company&&data.company.key){ getDepartment({company_id:data.company.key}).then(res=>{ handelResponse(res,(response,msg)=>{ let departmentList=response.map(item=>{