Browse Source

测试阶段 --下载4

sophieChenyx 6 năm trước cách đây
mục cha
commit
b7ad5f469d

+ 2 - 1
src/components/AXList/StandardTableList.js

@@ -123,7 +123,8 @@ export default class StandardTableList extends PureComponent {
               {campusAmount !== undefined && (
                 <span
                   style={{ marginLeft: 5, marginRight: 10, }}
-                >当前共有<span style={{fontWeight:600, color:'#5E8732'}}>{campusAmount}</span>个校区
+                >当前共有<span style={{fontWeight:600, color:'#5E8732'}}>{campusAmount}</span>个校区&nbsp;&nbsp;
+                <span style={{fontWeight:600, color:'#5E8732'}}>{pagination.totalSize}</span>个终端用户
                 </span>
               )}
               <Button icon="sync" onClick={this.handleRefreshBtnClick}>刷新</Button>

+ 2 - 1
src/routes/Dashboard/Accounts/AccountsCampus.js

@@ -29,7 +29,8 @@ export default class CampusAccountsPage extends Component {
   handleDownloadOperation = () => {
     console.log('press download');
     this.props.dispatch({
-      type: 'accounts/fetchCampusExcel'
+      type: 'accounts/fetchCampusExcel',
+      payload: 'download',
     })
   };
   handleFilterOperation = (params, states) => {

+ 3 - 6
src/routes/Dashboard/Accounts/AccountsTotalList.js

@@ -23,11 +23,11 @@ export default class TotalListAccountsPage extends Component {
     this.props.dispatch({
       type: 'accounts/fetchCampusAmount',
       payload: {}
-    })
+    });
     this.props.dispatch({
       type: 'accounts/fetchTotalList',
       payload: { ...this.state.Queryers }
-    })
+    });
   }
   handleFilterOperation = (params, states) => {
     this.setState({
@@ -41,15 +41,12 @@ export default class TotalListAccountsPage extends Component {
       },
     });
   };
-
+  
   render() {
     const { loading,accounts } = this.props;
     const { list, totalSize, pageSize, pageNo,  campusAmount} = accounts;
     const basicSearch = {
       keys: [{
-        name: '校区名称',
-        field: 'campusName',
-      }, {
         name: '终端编号',
         field: 'code',
       }],

+ 7 - 2
src/services/accounts.js

@@ -11,7 +11,11 @@ export async function queryCampusList(params) {
 }
 
 export async function downloadCampusExcel() {
-  return request(`${api.accountsCampusDownload}`);
+  console.log('service download')
+  return request(`${api.accountsCampusDownload}`, {
+    DOWNLOAD: true,
+  });
+  // return request(`${api.accountsCampusDownload}`);
 }
 
 export async function queryTerminalsList(params) {
@@ -21,10 +25,10 @@ export async function queryTerminalsList(params) {
   };
   return request(`${api.accountsTerminalsList}?${stringify(newParams)}`);
 }
+
 export async function downloadTerminalsExcel() {
   return request(`${api.accountsTerminalsDownload}`);
 }
-
 export async function queryTotalList(params) {
   const newParams = {
     pageSize: Hotax.PAGE_SIZE,
@@ -32,6 +36,7 @@ export async function queryTotalList(params) {
   };
   return request(`${api.acconutsTotalList}?${stringify(newParams)}`);
 }
+
 export async function queryCampusAmount() {
   return request(`${api.acconutsCampusAmount}`);
 }

+ 11 - 4
src/utils/request.js

@@ -58,6 +58,7 @@ export default function request(url, options) {
     credentials: 'include',
   };
   const newOptions = { ...defaultOptions, ...options };
+  console.log('>>>>>>>>>> 01newOptions',newOptions)
   if (newOptions.method === 'POST' || newOptions.method === 'PUT' || newOptions.method === 'DELETE') {
     if (!(newOptions.body instanceof FormData)) {
       newOptions.headers = {
@@ -70,16 +71,22 @@ export default function request(url, options) {
         newOptions.body = JSON.stringify(newOptions.body);
       }
     } else {
-      // newOptions.body is FormData
       newOptions.headers = {
         Accept: 'application/json',
         'Content-Type': 'multipart/form-data',
         ...newOptions.headers,
       };
-    }
+    } 
   }
-  // window.open 的情况
-  
+  // download excel
+  if ( newOptions.DOWNLOAD ) {
+    console.log('download request');
+    newOptions.headers = {
+      Accept: 'application/binary',
+      'Content-Type': 'multipart/x-www-form-urlencoded',
+      ...newOptions.headers,
+    };
+  } 
 
   return fetch(url, newOptions)
     .then(checkHttpStatus)