Commit 376f0d3a authored by Memorydoc's avatar Memorydoc

#

parent aab60a50
package pwc.taxtech.atms.common; package pwc.taxtech.atms.common;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -8,7 +9,12 @@ import org.apache.commons.io.IOUtils; ...@@ -8,7 +9,12 @@ import org.apache.commons.io.IOUtils;
import org.nutz.lang.Lang; import org.nutz.lang.Lang;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.dpo.EnterpriseAccountSetOrgDto; import pwc.taxtech.atms.dpo.EnterpriseAccountSetOrgDto;
import pwc.taxtech.atms.exception.ServiceException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
public class CommonUtils { public class CommonUtils {
public static final int BATCH_NUM = 500; public static final int BATCH_NUM = 500;
...@@ -155,4 +161,34 @@ public class CommonUtils { ...@@ -155,4 +161,34 @@ public class CommonUtils {
} }
/**
* 输出文件流 下载
*/
public static void FileOut(HttpServletResponse response, InputStream inputStream, String fileName){
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".xlsx");
ServletOutputStream out = null;
try {
out = response.getOutputStream();
int b = 0;
byte[] buffer = new byte[512];
while ((b = inputStream.read(buffer)) > 0) {
out.write(buffer, 0, b);
}
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace();
throw new ServiceException(ErrorMessage.SystemError);
} finally {
try {
out.close();
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }
...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.controller; ...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.controller;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -371,16 +372,17 @@ public class ReportController { ...@@ -371,16 +372,17 @@ public class ReportController {
* 批量导出利润表 * 批量导出利润表
*/ */
@RequestMapping("manyExport") @RequestMapping("manyExport")
public OperationResultDto manyExport(@RequestBody RequestParameterDto requestParameterDto, HttpServletResponse response, HttpServletRequest request) throws Exception { public ResponseEntity manyExport(@RequestBody RequestParameterDto requestParameterDto, HttpServletResponse response, HttpServletRequest request) throws Exception {
OperationResultDto operationResultDto = new OperationResultDto(); OperationResultDto operationResultDto = new OperationResultDto();
try { try {
reportService.manyExport(requestParameterDto, request, response); reportService.manyExport(requestParameterDto, request, response);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
operationResultDto.error(e.getMessage()); operationResultDto.error(e.getMessage());
return operationResultDto; return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
return operationResultDto.success(); return new ResponseEntity(HttpStatus.OK);
} }
@Autowired @Autowired
......
...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.message.ErrorMessage; import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.util.MyAsserts; import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.constant.enums.EnumAnalysisImportType; import pwc.taxtech.atms.constant.enums.EnumAnalysisImportType;
...@@ -513,35 +514,18 @@ public class TemplateController extends BaseController { ...@@ -513,35 +514,18 @@ public class TemplateController extends BaseController {
@RequestMapping(value = "file/downloadAnalysisTemplate", method = RequestMethod.GET) @RequestMapping(value = "file/downloadAnalysisTemplate", method = RequestMethod.GET)
public void analysisFileDownload(@RequestParam Integer fileType, HttpServletResponse response) { public void analysisFileDownload(@RequestParam Integer fileType, HttpServletResponse response) {
//获取网站部署路径(通过ServletContext对象),用于确定下载文件位置,从而实现下载 //获取网站部署路径(通过ServletContext对象),用于确定下载文件位置,从而实现下载
String fileName = ""; String fileName = EnumAnalysisImportType.getNameByCode(fileType);
fileName = EnumAnalysisImportType.getNameByCode(fileType);
if (StringUtils.isEmpty(fileName)) { if (StringUtils.isEmpty(fileName)) {
throw new ServiceException(ErrorMessage.SystemError); throw new ServiceException(ErrorMessage.SystemError);
} }
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".xlsx");
ServletOutputStream out;
try {
InputStream inputStream = this.getClass().getResourceAsStream("/document/AnalysisImport/" + fileName + ".xlsx"); InputStream inputStream = this.getClass().getResourceAsStream("/document/AnalysisImport/" + fileName + ".xlsx");
out = response.getOutputStream(); CommonUtils.FileOut(response, inputStream, fileName);
int b = 0;
byte[] buffer = new byte[512];
while (b != -1) {
b = inputStream.read(buffer);
out.write(buffer, 0, b);
}
inputStream.close();
out.close();
out.flush();
} catch (Exception e) {
logger.error(String.format("下载分析导入模板异常:%s", e.getMessage()));
throw new ServiceException(ErrorMessage.SystemError);
}
} }
@ResponseBody @ResponseBody
@RequestMapping(value = "upload", method = RequestMethod.POST) @RequestMapping(value = "upload", method = RequestMethod.POST)
public OperationResultDto upload(@RequestParam MultipartFile file, @RequestParam String projectId, @RequestParam Integer period) { public OperationResultDto upload(@RequestParam MultipartFile file, @RequestParam String
projectId, @RequestParam Integer period) {
try { try {
ReportUpload data = new ReportUpload(); ReportUpload data = new ReportUpload();
data.setProjectId(projectId); data.setProjectId(projectId);
......
...@@ -1249,8 +1249,13 @@ public class ReportServiceImpl extends BaseService { ...@@ -1249,8 +1249,13 @@ public class ReportServiceImpl extends BaseService {
cellData = getCellData(Long.parseLong(reportId), getProjId(orgId, period)); cellData = getCellData(Long.parseLong(reportId), getProjId(orgId, period));
} }
if(ebitDataDto != null){ if(ebitDataDto != null){
if(reportId == null){
reportDataDto.setEbitData(ebitDataDto);
cellData.setData(reportDataDto);
}else{
cellData.getData().setEbitData(ebitDataDto); cellData.getData().setEbitData(ebitDataDto);
} }
}
return cellData; return cellData;
} }
...@@ -1532,7 +1537,11 @@ public class ReportServiceImpl extends BaseService { ...@@ -1532,7 +1537,11 @@ public class ReportServiceImpl extends BaseService {
ebitDataDto.setSpecialFactors(subtract.add(spec)); ebitDataDto.setSpecialFactors(subtract.add(spec));
ebitDataDto.setEbitRate(String.valueOf(rate)); ebitDataDto.setEbitRate(String.valueOf(rate));
ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate()))); ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate())));
if(ebitRate.indexOf("%") != -1){
ebitDataDto.setEbitRate(ebitRate);
}else{
ebitDataDto.setEbitRate(ebitRate + "%"); ebitDataDto.setEbitRate(ebitRate + "%");
}
ebitDataDto.setSixAddTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06))); ebitDataDto.setSixAddTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06)));
ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.16))); ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.16)));
ebitDataDto.setSpecialConsiderations(specialConsiderations); ebitDataDto.setSpecialConsiderations(specialConsiderations);
...@@ -2342,31 +2351,12 @@ public class ReportServiceImpl extends BaseService { ...@@ -2342,31 +2351,12 @@ public class ReportServiceImpl extends BaseService {
InputStream inputStream = httpFileService.getUserTemplate(path); InputStream inputStream = httpFileService.getUserTemplate(path);
if (i == 0) { if (i == 0) {
workbook1 = new XSSFWorkbook(inputStream); workbook1 = new XSSFWorkbook(inputStream);
;
sheetAt = workbook1.getSheetAt(0); sheetAt = workbook1.getSheetAt(0);
List<Integer> cols = Lists.newArrayList(); List<Integer> cols = Lists.newArrayList();
/*for (int m = 0; m <= 5; m++) {
cols.add(m);
}*/
FileExcelUtil.deleteColumn(sheetAt, 1, cols); FileExcelUtil.deleteColumn(sheetAt, 1, cols);
sheetAt.setColumnWidth(1, 22 * 256); sheetAt.setColumnWidth(1, 22 * 256);
sheetAt.setColumnWidth(2, 22 * 256); sheetAt.setColumnWidth(2, 22 * 256);
/*for (int m = 0; m <3; m++) {
FileExcelUtil.cloneCell(sheetAt.getRow(m).getCell(1), sheetAt.getRow(m).getCell(2));
}*/
/* CellStyle style = workbook1.createCellStyle();
CellStyle style1 = workbook1.createCellStyle();
Font font = workbook1.createFont();
font.setFontHeightInPoints((short)14);
style.setFont(font);
font.setBold(true);
CellStyle style1 = workbook1.createCellStyle();
style1.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
sheetAt.getRow(0).getCell(2).setCellStyle(style);
sheetAt.getRow(2).getCell(2).setCellStyle(style1);*/
} else { } else {
Workbook workbook2 = new XSSFWorkbook(inputStream); Workbook workbook2 = new XSSFWorkbook(inputStream);
Sheet sheetAt1 = workbook2.getSheetAt(0); Sheet sheetAt1 = workbook2.getSheetAt(0);
...@@ -2389,13 +2379,6 @@ public class ReportServiceImpl extends BaseService { ...@@ -2389,13 +2379,6 @@ public class ReportServiceImpl extends BaseService {
insertExcelOne(sheetAt, ebitSpreadData, workbook1); insertExcelOne(sheetAt, ebitSpreadData, workbook1);
FileExcelUtil.setExcelHeadInfo(response, request, requestParameterDto.getPeriod() + "-汇总利润表.xlsx"); FileExcelUtil.setExcelHeadInfo(response, request, requestParameterDto.getPeriod() + "-汇总利润表.xlsx");
FileExcelUtil.downloadExcel(request, response, requestParameterDto.getPeriod() + "-汇总利润表.xlsx", workbook1); FileExcelUtil.downloadExcel(request, response, requestParameterDto.getPeriod() + "-汇总利润表.xlsx", workbook1);
//以下代码是导出zip的,后来需求改为导出一个Excel
/* fileName = zipPath + "/" + getOrgName(ebitSpreadData.get(i).getOrganizationId()) +requestParameterDto.getPeriod() + ".xlsx";
fileList.add(FileExcelUtil.generateExcelToPath(workbook1, fileName));*/
/* String zipPath1 = zipPath + "/sizegang.zip";
FileExcelUtil.downloadZip(request, response, zipFileName, fileList, zipPath1);*/
//将workbook转成流 //将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream(); /* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos); workbook.write(bos);
......
...@@ -49,8 +49,6 @@ ...@@ -49,8 +49,6 @@
$scope.selectCountry = ''; $scope.selectCountry = '';
$scope.internationalDataList = constant.internationalDataList; $scope.internationalDataList = constant.internationalDataList;
$scope.countryCNNAMEList = constant.countryCNList;
var date = new Date(); var date = new Date();
var year = date.getFullYear(); var year = date.getFullYear();
var month = date.getMonth() + 1; var month = date.getMonth() + 1;
...@@ -133,30 +131,10 @@ ...@@ -133,30 +131,10 @@
constant.anlTemplateNameList.forEach(function (m) { constant.anlTemplateNameList.forEach(function (m) {
if (m.code === $scope.importType) { if (m.code === $scope.importType) {
fileName = m.name; fileName = m.name;
PWC.downloadCallBack(data, status, headers, fileName)
} }
}); });
var octetStreamMime = 'application/octet-stream';
var contentType = headers('content-type') || octetStreamMime;
if (window.navigator.msSaveBlob) {
var blob = new Blob([data], {
type: contentType
});
navigator.msSaveBlob(blob, fileName);
} else {
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
var a = document.createElement('a');
var blob = new Blob([data], {
type: contentType
});
var url = urlCreator.createObjectURL(blob);
a.href = url;
a.target = '_blank';
a.download = fileName + ".xlsx";
document.body.appendChild(a);
a.click();
}
}
}).error(function () { }).error(function () {
SweetAlert.error($translate.instant('PleaseContactAdministrator')); SweetAlert.error($translate.instant('PleaseContactAdministrator'));
}); });
...@@ -563,14 +541,6 @@ ...@@ -563,14 +541,6 @@
$scope.setGridStyle = setGridStyle; $scope.setGridStyle = setGridStyle;
}; };
var initCompanyList = function () {
orgService.getOrgListByUserId().success(function (data) {
if (data) {
$scope.companyList = data;
}
});
};
$scope.selectCompanyEvent = function (i) { $scope.selectCompanyEvent = function (i) {
$scope.selectCompany = i.name; $scope.selectCompany = i.name;
refreshGrid(); refreshGrid();
...@@ -651,62 +621,39 @@ ...@@ -651,62 +621,39 @@
}; };
/*------------------------------kevin insert ----------------------------------------------------------------*/ /*------------------------------kevin insert ----------------------------------------------------------------*/
var initCompanyList = function () {
orgService.getOrgListByUserId().success(function (data) {
//机构下拉设置 var joinText = "";
$scope.selectOrgOptionsContry = { if (data) {
displayExpr: 'name', if (data) {
valueExpr: 'id', for (var a = 0; a < data.length; a++) {
bindingOptions: { joinText += "<option value =" + data[a].id + " style ='text-align: left;' >" + data[a].name + "</option>";
value: '_selectCountry',
dataSource: 'countryCNNAMEList'
},
height: '30px',
placeholder: $translate.instant('PleaseSelected'),
showClearButton: true,
searchEnabled: true,
noDataText: $translate.instant('RevenueNoOrgData'),
showSelectionControls: false,
onInitialized : function(e){
},
onItemClick: function (e) {
$scope.selectCountryEvent();
} }
$('#orgList').html(joinText);
$('#orgList').selectpicker('refresh');
}
}
});
}; };
$('#orgList').on('changed.bs.select', function (e, clickedIndex, isSelected, value) {
$scope.selectCompany = e.currentTarget[clickedIndex].value;
});
$('#contryList').on('changed.bs.select', function (e, clickedIndex, isSelected, value) {
$scope.selectCountry = e.currentTarget[clickedIndex].value;
});
var initContryList = function(){
$scope.selectOrgOptionsComany = { var joinText = "";
displayExpr: 'name', if(constant.countryCNList){
valueExpr: 'id', for(var i =0; i< constant.countryCNList.length; i++){
bindingOptions: { joinText += "<option value =" + constant.countryCNList[i]+ " style ='text-align: left;' >" + constant.countryCNList[i] + "</option>";
value: '_selectCompany', }
dataSource: 'companyList' $('#contryList').html(joinText);
}, $('#contryList').selectpicker('refresh');
height: '30px',
placeholder: $translate.instant('PleaseSelected'),
showClearButton: true,
searchEnabled: true,
noDataText: $translate.instant('RevenueNoOrgData'),
showSelectionControls: false,
onInitialized : function(e){
},
onItemClick: function (e) {
$scope.selectCompanyEvent(e.itemData);
/* loadCellData($scope.relation.period, e.itemData.id,function(){
$scope.selectCompany = e.itemData.name;
});*/
} }
}; };
$('#orgList').on('shown.bs.select', function(){
$scope._selectCountry = null; $(this).find('.dropdown-menu').width("200px");
$scope.$watch('_selectCountry', function(n, o){
if(n != undefined )
$scope.selectCountry = n.pop();
});
$scope._selectCompany = null;
$scope.$watch('_selectCompany', function(n, o){
if(n != undefined )
$scope.selectCompany = n.pop();
}); });
/*------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------*/
...@@ -718,6 +665,7 @@ ...@@ -718,6 +665,7 @@
getUserPermission(); getUserPermission();
initDatePicker(); initDatePicker();
initCompanyList(); initCompanyList();
initContryList();
$scope.$watch('importExcelFile', function (newValue, oldValue) { $scope.$watch('importExcelFile', function (newValue, oldValue) {
if (newValue !== null && newValue !== oldValue) { if (newValue !== null && newValue !== oldValue) {
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
</div> </div>
<div class="row" style="margin-top: 10px;"> <div class="row" style="margin-top: 10px;">
<span class="text-bold" translate="Country" style="position: relative; top: -7px;">:</span> <span class="text-bold" translate="Country">:</span>
<!-- <div class="dropdown" style="margin-left:10px"> <!-- <div class="dropdown" style="margin-left:10px">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu3" <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu3"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 150px;margin-left: 28px;"> data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 150px;margin-left: 28px;">
...@@ -76,9 +76,33 @@ ...@@ -76,9 +76,33 @@
</li> </li>
</ul> </ul>
</div>--> </div>-->
<div dx-tag-box="selectOrgOptionsContry" style="width: 287px;display: inline-block"></div> <!-- <div dx-tag-box="selectOrgOptionsContry" style="width: 287px;display: inline-block"></div>-->
<span class="text-bold" translate="Company" style="position: relative; top: -7px;">:</span>
<div dx-tag-box="selectOrgOptionsComany" style="width: 287px;display: inline-block"></div> <select class="selectpicker show-tick dropup" multiple data-live-search="true"
data-max-options="1"
data-size="10"
data-style="btn-primary" id ="contryList"
data-header="国家列表"
data-content = "true"
data-none-selected-text = "选择国家"
data-dropdown-align-right ="false"
data-icon-base = "tickIcon"
data-none-results-text ="没有匹配的国家">
</select>
<span class="text-bold" translate="Company">:</span>
<!--<div dx-tag-box="selectOrgOptionsComany" style="width: 287px;display: inline-block"></div>-->
<select class="selectpicker show-tick dropup" multiple data-live-search="true"
data-width="auto" data-max-options="1"
data-size="10"
data-style="btn-primary" id ="orgList"
data-header="公司列表"
data-content = "true"
data-icon-base = "tickIcon"
data-none-selected-text = "选择公司"
data-dropdown-align-right =false
data-none-results-text ="没有匹配的公司">
</select>
<!-- <div class="dropdown" style="margin-left:38px"> <!-- <div class="dropdown" style="margin-left:38px">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu4" <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu4"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 320px;"> data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 320px;">
......
...@@ -1105,23 +1105,21 @@ ...@@ -1105,23 +1105,21 @@
return; return;
} }
vatReportService.getReportEbitData($scope.reportId, $scope.relation.orgId, period != undefined ? period : ($scope.relation.period == undefined ? period : $scope.relation.period)).success(function (reportData) { vatReportService.getReportEbitData($scope.reportId, $scope.relation.orgId, period != undefined ? period : ($scope.relation.period == undefined ? period : $scope.relation.period)).success(function (reportData) {
if (reportData && reportData.data && reportData.data.cellData) { if (reportData && reportData.data) {
_.each(reportData.data.cellData, function (x) { _.each(reportData.data.cellData, function (x) {
x.value = x.cellValue; x.value = x.cellValue;
delete x.cellValue; delete x.cellValue;
}); });
$scope.relation.data = reportData.data.ebitData;
$scope.reportData = reportData.data.cellData; $scope.reportData = reportData.data.cellData;
$scope.formulaBlocks = reportData.data.formulaBlocks; $scope.formulaBlocks = reportData.data.formulaBlocks;
$scope.manualDataSources = reportData.data.manualDataSources; $scope.manualDataSources = reportData.data.manualDataSources;
if (reportData.data)
$scope.relation.data = reportData.data.ebitData;
$scope.relation.loadSheet($scope.templateId); $scope.relation.loadSheet($scope.templateId);
} else { } else {
$scope.reportData = []; $scope.reportData = [];
$scope.formulaBlocks = []; $scope.formulaBlocks = [];
$scope.manualDataSources = []; $scope.manualDataSources = [];
if (reportData.data) $scope.relation.data = [];
$scope.relation.data = reportData.data.ebitData;
$scope.relation.loadSheet($scope.templateId); $scope.relation.loadSheet($scope.templateId);
} }
}); });
...@@ -3063,7 +3061,14 @@ ...@@ -3063,7 +3061,14 @@
excelIo.open(file, function (json) { excelIo.open(file, function (json) {
var workbookObj = json; var workbookObj = json;
$scope.spread.fromJSON(workbookObj); $scope.spread.fromJSON(workbookObj);
vatReportService.saveAndRefresh($scope.relation.orgId, $scope.relation.period, 0, "1").success(function (res) {
if (res.resultMsg == "success") {
if (res.data) $scope.relation.data = res.data;
$scope.relation.setData(true); $scope.relation.setData(true);
}
}).error(function (error) {
});
}, function (e) { }, function (e) {
// process error // process error
alert(e.errorMessage); alert(e.errorMessage);
...@@ -3140,7 +3145,7 @@ ...@@ -3140,7 +3145,7 @@
});*/ });*/
var initCompanyList = function () { var initCompanyList = function () {
var joinText = " <option value=''>请选择机构</option>"; var joinText = "";
vatReportService.getOrgLists().success(function (data) { vatReportService.getOrgLists().success(function (data) {
if (data) { if (data) {
/*$scope.companyList = data.data;*/ /*$scope.companyList = data.data;*/
......
...@@ -1160,5 +1160,30 @@ ...@@ -1160,5 +1160,30 @@
}; };
/------------------------------------------------kevin insert -----------------------------------/ /------------------------------------------------kevin insert -----------------------------------/
PWC.downloadCallBack = function(data,status, headers, fileName){
var octetStreamMime = 'application/octet-stream';
var contentType = headers('content-type') || octetStreamMime;
if (window.navigator.msSaveBlob) {
var blob = new Blob([data], {
type: contentType
});
navigator.msSaveBlob(blob, fileName);
} else {
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
var a = document.createElement('a');
var blob = new Blob([data], {
type: contentType
});
var url = urlCreator.createObjectURL(blob);
a.href = url;
a.target = '_blank';
a.download = fileName + ".xlsx";
document.body.appendChild(a);
a.click();
}
}
}
/*-----------------------------------------------------------------------------------------*/
})(window) })(window)
\ No newline at end of file
...@@ -72,6 +72,10 @@ ...@@ -72,6 +72,10 @@
manyExport: function (param) { manyExport: function (param) {
var toParam = JSON.stringify(param); var toParam = JSON.stringify(param);
return $http.post('/Report/manyExport', toParam, apiConfig.createVat({responseType: 'arraybuffer'})).then(function (response) { return $http.post('/Report/manyExport', toParam, apiConfig.createVat({responseType: 'arraybuffer'})).then(function (response) {
if(response.status == 204){
SweetAlert.error("当前期间没有可导出的数据");
return
}
var a = document.createElement('a'); var a = document.createElement('a');
var data = new Blob([response.data], {type: response.headers('Content-Type')}); var data = new Blob([response.data], {type: response.headers('Content-Type')});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment