|
@@ -215,7 +215,7 @@ module.exports = app => {
|
|
|
}
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.code || data.code === '' || !data.name || data.name === '') {
|
|
|
- throw '提交数据错误';
|
|
|
+ throw '变更令名称不能为空';
|
|
|
}
|
|
|
|
|
|
const change = await ctx.service.change.add(tenderId, ctx.session.sessionUser.accountId, data.code, data.name);
|
|
@@ -596,9 +596,20 @@ module.exports = app => {
|
|
|
const fileInfo = await ctx.service.changeAtt.getDataById(id);
|
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
|
const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
+ // 解决中文无法下载问题
|
|
|
+ const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
|
|
|
+ let disposition = '';
|
|
|
+ if (userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) {
|
|
|
+ disposition = 'attachment; filename=' + encodeURIComponent(fileInfo.filename + fileInfo.fileext);
|
|
|
+ } else if (userAgent.indexOf('firefox') >= 0) {
|
|
|
+ disposition = 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileInfo.filename + fileInfo.fileext) + '"';
|
|
|
+ } else {
|
|
|
+ /* safari等其他非主流浏览器只能自求多福了 */
|
|
|
+ disposition = 'attachment; filename=' + new Buffer(fileInfo.filename + fileInfo.fileext).toString('binary');
|
|
|
+ }
|
|
|
ctx.response.set({
|
|
|
'Content-Type': 'application/octet-stream',
|
|
|
- 'Content-Disposition': 'attachment; filename=' + fileInfo.filename + fileInfo.fileext,
|
|
|
+ 'Content-Disposition': disposition,
|
|
|
'Content-Length': fileInfo.filesize,
|
|
|
});
|
|
|
ctx.body = await fs.createReadStream(fileName);
|