Browse Source

(*)文件导出,七牛返回400,待查看; api请求401,待排查

master
周沫沫历险记 2 years ago
parent
commit
eaea7fbd59
  1. 6
      web/client/src/sections/business/actions/reserve-item.js
  2. 23
      web/client/src/sections/business/containers/reserveItemsPeriodicStatistics.jsx
  3. 7
      web/client/src/utils/webapi.js
  4. 2
      web/package.json
  5. 22
      web/routes/attachment/index.js

6
web/client/src/sections/business/actions/reserve-item.js

@ -1,13 +1,13 @@
'use strict'; 'use strict';
import { RouteTable, RouteRequest, ApiTable, basicAction } from '$utils' import { RouteTable, RouteRequest, ApiTable, basicAction } from '$utils';
export function getReserveItemReport(type) { export function getReserveItemReport(type) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_RESERVEITEM_REPORT', actionType: 'GET_RESERVEITEM_REPORT',
url: `${ApiTable.getReserveItemReport.replace('{type}', type)}`, url: `${ApiTable.getReserveItemReport.replace('{type}', type)}?token=9c62cd15-967f-42dc-a2fd-f79411dfad55`,
msg: { error: '获取储备项目统计信息失败' }, msg: { error: '获取储备项目统计信息失败' },
reducer: { name: 'reserveItemReport' } reducer: { name: 'reserveItemReport' }
}); });
} }

23
web/client/src/sections/business/containers/reserveItemsPeriodicStatistics.jsx

@ -2,14 +2,25 @@ import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Select, Input, Spin, Button, RadioGroup, Radio, Table } from '@douyinfe/semi-ui'; import { Select, Input, Spin, Button, RadioGroup, Radio, Table } from '@douyinfe/semi-ui';
import { IconSearch } from '@douyinfe/semi-icons'; import { IconSearch } from '@douyinfe/semi-icons';
import { RESERVEITEM_TYPE } from '../constants' import { RouteRequest, RouteTable } from '$utils';
import { RESERVEITEM_TYPE } from '../constants';
import '../style.less' import '../style.less'
const ReserveItemsPeriodicStatistics = (props) => { const ReserveItemsPeriodicStatistics = (props) => {
const { dispatch, actions, isRequesting, reserveItemReport } = props; const { dispatch, actions, isRequesting, reserveItemReport } = props;
useEffect(() => { useEffect(() => {
dispatch(actions.businessManagement.getReserveItemReport(RESERVEITEM_TYPE.periodicStatistics)); dispatch(actions.businessManagement.getReserveItemReport(RESERVEITEM_TYPE.periodicStatistics));
}, []) }, []);
const exportReport = () => {
RouteRequest.get(RouteTable.qnDownload).then(res => {
debugger;
console.log(res);
// setDownloadUrl(`members/export?token=${user.token}&state=${typeChoose}&keywordTarget=${keywordTarget}&keyword=${keyword}&keys=overtimeStatistic,vacateStatistic`)
})
}
const columns = [ const columns = [
{ {
title: '序号', title: '序号',
@ -18,7 +29,7 @@ const ReserveItemsPeriodicStatistics = (props) => {
}, },
{ {
title: '时间', title: '时间',
dataIndex: 'year', dataIndex: 'date',
}, },
{ {
title: '名称', title: '名称',
@ -27,7 +38,7 @@ const ReserveItemsPeriodicStatistics = (props) => {
{ {
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
render: (text, record, indexe) => (<Button theme='solid' type='secondary'>导出</Button>) render: (text, record, indexe) => (<Button theme='solid' type='secondary' onClick={() => exportReport()} > 导出</Button >)
}, },
]; ];
@ -50,7 +61,9 @@ const ReserveItemsPeriodicStatistics = (props) => {
</div> </div>
</div> </div>
<div style={{ borderBottom: '1px solid #F2F3F5', marginLeft: '-20px', marginBottom: 16 }}></div> <div style={{ borderBottom: '1px solid #F2F3F5', marginLeft: '-20px', marginBottom: 16 }}></div>
{/* {
downloadUrl ? <iframe src={`/_api/${downloadUrl}`} style={{ display: 'none' }} /> : ''
} */}
<div style={{ marginBottom: 22 }}> <div style={{ marginBottom: 22 }}>
<Spin spinning={isRequesting}> <Spin spinning={isRequesting}>
<Table <Table

7
web/client/src/utils/webapi.js

@ -5,7 +5,7 @@ export const AxyRequest = new ProxyRequest("_axy");
export const EmisRequest = new ProxyRequest("_emis") export const EmisRequest = new ProxyRequest("_emis")
export const webUtils = new customWebUtils({ export const webUtils = new customWebUtils({
userKey: 'hrUser' userKey: 'dcUser'
}); });
const { basicAction, RouteRequest } = webUtils const { basicAction, RouteRequest } = webUtils
export { export {
@ -17,12 +17,13 @@ export const ApiTable = {
logout: "logout", logout: "logout",
//项目报表 //项目报表
getReserveItemReport: "/reserveItem/report/{type}" getReserveItemReport: "reserveItem/report/{type}"
}; };
export const RouteTable = { export const RouteTable = {
apiRoot: "/api/root", apiRoot: "/api/root",
fileUpload: "/_upload/new", fileUpload: "/_upload/new",
cleanUpUploadTrash: "/_upload/cleanup", cleanUpUploadTrash: "/_upload/cleanup",
getWeeklyService: '/_service/weekly' getWeeklyService: '/_service/weekly',
qnDownload:'/file/qiniu/download'
}; };

2
web/package.json

@ -7,7 +7,7 @@
"test": "mocha", "test": "mocha",
"start-vite": "cross-env NODE_ENV=developmentVite npm run start-params", "start-vite": "cross-env NODE_ENV=developmentVite npm run start-params",
"start": "cross-env NODE_ENV=development npm run start-params", "start": "cross-env NODE_ENV=development npm run start-params",
"start-params": "node server -p 5700 -u http://localhost:4700 --apiHrUrl http://localhost:4700 --qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5 --qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa --qnbkt dev-hr --qndmn http://rjkwed13l.hn-bkt.clouddn.com --wkys http://10.8.30.109:14000", "start-params": "node server -p 5700 -u http://localhost:4700 --apiHrUrl http://localhost:4700 --qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu --qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5 --qnbkt pep-process-report --qndmn https://pepsource.anxinyun.cn --wkys http://10.8.30.109:14000",
"deploy": "export NODE_ENV=production&& npm run build && node server", "deploy": "export NODE_ENV=production&& npm run build && node server",
"build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js", "build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js",
"build": "cross-env NODE_ENV=production&&webpack --config webpack.config.prod.js" "build": "cross-env NODE_ENV=production&&webpack --config webpack.config.prod.js"

22
web/routes/attachment/index.js

@ -82,6 +82,27 @@ module.exports = {
} }
} }
} }
let qnDownload = async function (ctx, next) {
try {
const { src, filename } = ctx.query;
const fkey = src.replace(/\.json$/, '.js');
console.log("qnDownload->fkey: ", fkey);
const publicDownloadUrl = await ctx.app.fs.attachment.download(fkey);
if (filename) {
// download
ctx.attachment(filename);
} else {
// display
if (/\.(png)|(jpg)|(jpeg)|(gif)$/g.test(src.toLowerCase())) ctx.type = 'image/png';
}
ctx.status = 200;
ctx.body = request.get(publicDownloadUrl);
} catch (err) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`);
ctx.status = 400;
ctx.body = { name: 'FindError', message: '附件下载失败' };
}
}
let remove = async function (ctx, next) { let remove = async function (ctx, next) {
try { try {
@ -109,6 +130,7 @@ module.exports = {
router.use(download); router.use(download);
router.get('/api/root', getApiRoot); router.get('/api/root', getApiRoot);
router.post('/file/qiniu/upload', upload); router.post('/file/qiniu/upload', upload);
router.get('/file/qiniu/download', qnDownload);
router.post('/file/qiniu/remove', remove); router.post('/file/qiniu/remove', remove);
} }
}; };

Loading…
Cancel
Save