Commit d21bfb54 authored by chase's avatar chase

merge 档案管理

parent 376af30c
......@@ -96,6 +96,7 @@ public class FileTypesController {
headers.put("id", "id");
headers.put("file_attr", "档案属性");
headers.put("file_type", "档案类型");
headers.put("file_type", "必填字段");
headers.put("description", "说明");
headers.put("creator", "办事人");
headers.put("create_time", "创建时间");
......
......@@ -96,7 +96,7 @@ public class TaxDocumentController {
headers.put("business_line", "业务线");
headers.put("company_name", "公司名称");
headers.put("tax_type", "税种");
headers.put("file_time", "文件日期");
headers.put("file_time", "文件生效日期");
headers.put("effective_time", "有效日期");
headers.put("creator", "创建人");
headers.put("create_time", "创建时间");
......@@ -105,9 +105,10 @@ public class TaxDocumentController {
headers.put("keeper", "保管人");
headers.put("remark", "档案备注");
headers.put("file_position_url", "文件存储的位置");
headers.put("own_time", "所属期间");
List<TaxDocument> TaxDocument = taxDocumentService.selectTaxDocumentList(taxDocumentDto);
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + new String("".getBytes("GB2312"), "ISO-8859-1"));
response.setHeader("Content-Disposition", "attachment;fileName=" + new String("taxDocument.xlsx".getBytes("GB2312"), "ISO-8859-1"));
OutputStream ouputStream = response.getOutputStream();
ExcelUtil.exportExcel(headers, TaxDocument, ouputStream);
} catch (Exception e) {
......
package pwc.taxtech.atms.dto;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.dto;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.dto.organization;
import com.fasterxml.jackson.annotation.JsonProperty;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
public class OrgBasicDto {
//@JsonProperty("ID")
......
package pwc.taxtech.atms.dto.organization;
import com.fasterxml.jackson.annotation.JsonProperty;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.util.Date;
......
package pwc.taxtech.atms.dto.previewData;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import pwc.taxtech.atms.entity.BaseEntity;
import pwc.taxtech.atms.anno.ExcelCell;
import pwc.taxtech.atms.entity.CustomDateSerializer;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.io.Serializable;
import java.math.BigDecimal;
......
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.io.Serializable;
import java.math.BigDecimal;
......
package pwc.taxtech.atms.dto.vatdto;
import com.fasterxml.jackson.annotation.JsonProperty;
import pwc.taxtech.atms.constant.enums.EnumOutputInvoiceType;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.dto.vatdto.dd;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import pwc.taxtech.atms.common.util.PwCIdSerialize;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import java.io.Serializable;
import pwc.taxtech.atms.anno.ExcelCell;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.dto.vatdto.dd;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import pwc.taxtech.atms.common.util.PwCIdSerialize;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.dto.vatdto.dd;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import pwc.taxtech.atms.common.util.PwCIdSerialize;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.dto.vatdto.dd;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import pwc.taxtech.atms.anno.ExcelCell;
import java.math.BigDecimal;
import java.util.Date;
......
package pwc.taxtech.atms.thirdparty;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.ComparatorUtils;
import org.apache.commons.collections.comparators.ComparableComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.anno.ExcelCell;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* The <code>ExcelUtil</code> 与 {@link ExcelCell}搭配使用
......@@ -112,34 +96,34 @@ public class ExcelUtil {
return null;
}
CellType cellType = cell.getCellTypeEnum();
if(cellType == CellType.BLANK)
return null;
else if(cellType == CellType.BOOLEAN)
return cell.getBooleanCellValue();
else if(cellType == CellType.ERROR)
return cell.getErrorCellValue();
else if(cellType == CellType.FORMULA) {
try {
if (HSSFDateUtil.isCellDateFormatted(cell)) {
return cell.getDateCellValue();
} else {
return cell.getNumericCellValue();
}
} catch (IllegalStateException e) {
return cell.getRichStringCellValue();
}
}
else if(cellType == CellType.NUMERIC){
if (DateUtil.isCellDateFormatted(cell)) {
if(cellType == CellType.BLANK)
return null;
else if(cellType == CellType.BOOLEAN)
return cell.getBooleanCellValue();
else if(cellType == CellType.ERROR)
return cell.getErrorCellValue();
else if(cellType == CellType.FORMULA) {
try {
if (HSSFDateUtil.isCellDateFormatted(cell)) {
return cell.getDateCellValue();
} else {
return cell.getNumericCellValue();
}
} catch (IllegalStateException e) {
return cell.getRichStringCellValue();
}
}
else if(cellType == CellType.NUMERIC){
if (DateUtil.isCellDateFormatted(cell)) {
return cell.getDateCellValue();
} else {
return cell.getNumericCellValue();
}
else if(cellType == CellType.STRING)
return cell.getStringCellValue();
else
return null;
}
else if(cellType == CellType.STRING)
return cell.getStringCellValue();
else
return null;
}
/**
......@@ -415,7 +399,7 @@ public class ExcelUtil {
* @throws RuntimeException
*/
@SuppressWarnings("unchecked")
public static <T> Collection<T> importExcel(Class<T> clazz, Workbook workBook, String sheetName,
public static <T> Collection<T> importExcel(Class<T> clazz, Workbook workBook, String sheetName,
String pattern, ExcelLogs logs, Integer... arrayCount) {
//Workbook workBook;
/*try {
......@@ -432,11 +416,11 @@ public class ExcelUtil {
else {
sheet = workBook.getSheet(sheetName);
}
if(sheet == null) {
return null;
}
Iterator<Row> rowIterator = sheet.rowIterator();
try {
List<ExcelLog> logList = new ArrayList<>();
......@@ -570,7 +554,7 @@ public class ExcelUtil {
}
return list;
}
/**
* 读取Excel的Header行, 并封装成Map<String, int)
*
......@@ -588,7 +572,7 @@ public class ExcelUtil {
LG.error("load excel file error",e);
return null;
}*/
Sheet sheet;
if(null == sheetName || sheetName.isEmpty()) {
sheet = workBook.getSheetAt(0);
......@@ -596,7 +580,7 @@ public class ExcelUtil {
else {
sheet = workBook.getSheet(sheetName);
}
if(sheet == null) {
return null;
}
......
......@@ -9,7 +9,6 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import java.math.BigDecimal;
import java.util.HashMap;
......
......@@ -14,6 +14,11 @@
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
......
package pwc.taxtech.atms.thirdparty;
package pwc.taxtech.atms.anno;
import org.apache.commons.lang3.StringUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apache.commons.lang3.StringUtils;
/**
* The <code>ExcelCell</code><br>
......
......@@ -2,6 +2,7 @@ package pwc.taxtech.atms.entity;
import com.alibaba.fastjson.JSONArray;
import org.springframework.util.StringUtils;
import pwc.taxtech.atms.anno.ExcelCell;
import java.io.Serializable;
import java.util.Date;
......@@ -24,6 +25,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=1)
private Long id;
/**
......@@ -35,6 +37,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=2)
private String fileAttr;
/**
......@@ -57,6 +60,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=3)
private String fileType;
......@@ -69,6 +73,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=4)
private List<String> requiredField;
......@@ -85,6 +90,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=5)
private String description;
/**
......@@ -105,6 +111,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=6)
private String creator;
/**
......@@ -116,6 +123,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=7)
private Date createTime;
/**
......@@ -127,6 +135,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=8)
private Date updateTime;
/**
......@@ -138,6 +147,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=9)
private String status;
/**
......@@ -149,6 +159,7 @@ public class FileTypes implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=10)
private String remarks;
/**
......
package pwc.taxtech.atms.entity;
import pwc.taxtech.atms.anno.ExcelCell;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -19,6 +21,7 @@ public class OperationLogFileType implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=1)
private String id;
/**
......@@ -55,6 +58,7 @@ public class OperationLogFileType implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=2)
private String operationAction;
/**
......@@ -73,6 +77,7 @@ public class OperationLogFileType implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=3)
private String updateState;
/**
......@@ -82,6 +87,7 @@ public class OperationLogFileType implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=4)
private String operationUser;
/**
......@@ -91,6 +97,7 @@ public class OperationLogFileType implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=5)
private String ip;
/**
......@@ -100,6 +107,7 @@ public class OperationLogFileType implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=5)
private String comment;
/**
......@@ -109,6 +117,7 @@ public class OperationLogFileType implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=6)
private Date createTime;
private List<String> fileTypeIds;
......
package pwc.taxtech.atms.entity;
import pwc.taxtech.atms.anno.ExcelCell;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -19,6 +21,7 @@ public class OperationLogTaxDocument implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=1)
private String id;
/**
......@@ -55,6 +58,7 @@ public class OperationLogTaxDocument implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=2)
private String operationAction;
/**
......@@ -73,6 +77,7 @@ public class OperationLogTaxDocument implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=3)
private String updateState;
/**
......@@ -82,6 +87,7 @@ public class OperationLogTaxDocument implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=4)
private String operationUser;
/**
......@@ -91,6 +97,7 @@ public class OperationLogTaxDocument implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=5)
private String ip;
/**
......@@ -100,6 +107,7 @@ public class OperationLogTaxDocument implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=6)
private String comment;
/**
......@@ -109,6 +117,7 @@ public class OperationLogTaxDocument implements Serializable {
*
* @mbg.generated
*/
@ExcelCell(index=7)
private Date createTime;
List<String> ids;
......
......@@ -386,4 +386,127 @@
$scope.cancelDocFileType = cancelDocFileType;
})();
}]);
\ No newline at end of file
}]);
infrastructureModule.directive('exportPlugin',function(){
return{
restrict:"EA",
controller:['$scope','SweetAlert','$translate','docManageService','$q','$log',
function($scope,SweetAlert,$translate,docManageService,$q,$log){
$scope.exportTableData = function ()
{
docManageService.exportTableData().then(function (data, status, headers) {
if(status===204){
SweetAlert.warning("没有数据可以下载");
return;
}
exportToExcel(data, 'docType.xls');
},function () {
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
})
};
//下载服务器上的xls文件
var exportToExcel = function (data, filename) {
$('#busy-indicator-container').show();
var defer = $q.defer();
// var octetStreamMime = 'application/vnd.ms-excel';
var success = false;
// Get the headers
// headers = headers();
// Get the filename from the x-filename header or default to "download.bin"
// var filename = decodeURI(headers['x-file-name']) + defaultFileName;
// Determine the content type from the header or default to "application/octet-stream"
// var contentType = headers['content-type'] || octetStreamMime;
try {
// Try using msSaveBlob if supported
//console.log("Trying saveBlob method ...");
var blob = new Blob([data], { type: "arraybuffer" });
if (navigator.msSaveBlob)
navigator.msSaveBlob(blob, filename);
else {
// Try using other saveBlob implementations, if available
var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
if (saveBlob === undefined) throw "Not supported";
saveBlob(blob, filename);
}
//console.log("saveBlob succeeded");
success = true;
} catch (ex) {
$log.debug("saveBlob method failed with the following exception:");
$log.debug(ex);
}
if (!success) {
// Get the blob url creator
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
// Try to use a download link
var link = document.createElement('a');
if ('download' in link) {
// Try to simulate a click
try {
// Prepare a blob URL
//console.log("Trying download link method with simulated click ...");
var blobdownload = new Blob([data], { type: "arraybuffer" });
var urldownload = urlCreator.createObjectURL(blobdownload);
link.setAttribute('href', urldownload);
// Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
link.setAttribute("download", filename);
// Simulate clicking the download link
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
//console.log("Download link method with simulated click succeeded");
success = true;
} catch (ex) {
$log.debug("Download link method with simulated click failed with the following exception:");
$log.debug(ex);
$q.reject();
}
}
if (!success) {
// Fallback to window.location method
try {
// Prepare a blob URL
// Use application/octet-stream when using window.location to force download
//console.log("Trying download link method with window.location ...");
var blobsuccess = new Blob([data], { type: "arraybuffer" });
var urlsuccess = urlCreator.createObjectURL(blobsuccess);
window.location = urlsuccess;
//console.log("Download link method with window.location succeeded");
success = true;
} catch (ex) {
//console.log("Download link method with window.location failed with the following exception:");
$log.debug(ex);
$q.reject();
}
}
}
}
if (!success) {
// Fallback to window.open method
$log.debug("No methods worked for saving the arraybuffer, using last resort window.open");
window.open(httpPath, '_blank', '');
}
//Delete the file
// deleteFile(encodeURI(filename));
defer.resolve('success');
$('#busy-indicator-container').hide();
return defer.promise;
};
}]
}
});
\ No newline at end of file

<div class="land-manage-page">
<div class="land-manage-page" export-plugin>
<style>
.DM-state-label{
margin: 0;
......@@ -12,6 +12,12 @@
display: none;
}
.required-tip{
color: red;
position: absolute;
left: 2rem;
top: 0.7rem;
}
</style>
<div class="menu-header">
<div class="menu-title" translate="DocumentTypeSets"></div>
......@@ -22,7 +28,7 @@
</div>
<div class="content-container">
<div class="row" style="margin-top:15px; text-align:right;padding:1rem;background: #fff">
<button style="width: 150px;" class="btn btn-in-panel-big" ng-click="exportEventTrigger()">
<button style="width: 150px;" class="btn btn-in-panel-big" ng-click="exportTableData()">
<i class="fa fa-file-excel-o"></i>
{{'ExportTable' | translate}}
</button>
......@@ -68,8 +74,8 @@
<!--档案属性-->
<div class="form-group">
<label for="DocumentAttr" class="col-sm-3 control-label">
<span style="color:red"> * </span>
<span translate="DocumentAttr"></span>
<span class="required-tip"> * </span>
<span translate="DocumentAttr"></span>
</label>
<div class="col-sm-11" style="width:61.67%">
<input class="form-control"
......@@ -86,7 +92,7 @@
<div class="form-group">
<label for="DocumentType" class="col-sm-3 control-label">
<span style="color:red"> * </span>
<span class="required-tip"> * </span>
<span translate="DocumentType"></span>
</label>
<div class="col-sm-11" style="width:61.67%">
......@@ -116,7 +122,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">
<span style="color:red"> * </span>
<span class="required-tip"> * </span>
<span translate="RequiredFields"></span>
</label>
<div class="col-sm-11" style="width:61.67%" id="appMultiSelectContainer">
......
......@@ -15,6 +15,24 @@ function ($http, $q, apiConfig, apiInterceptor,jqFetch) {
editFileType: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/fileTypes/edit', params);
},
exportTableData:function(params){
$('#busy-indicator-container').show();
var defer = $q.defer();
var xhr = new XMLHttpRequest();
xhr.onload = function(e) {
var arraybuffer = xhr.response;
console.info("arraybuffer:",arraybuffer);
defer.resolve(arraybuffer,xhr.status,xhr.getAllResponseHeaders());
};
xhr.open("POST", apiInterceptor.webApiHostUrl + '/fileTypes/exportExcel', true);
xhr.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
xhr.setRequestHeader("Content-Type", 'application/json;charset=UTF-8');
xhr.responseType = "arraybuffer";
xhr.send(JSON.stringify(params));
return defer.promise;
},
};
}]);
......@@ -70,16 +70,16 @@ frameworkModule.controller('appUsrOperateLogController',
descendingText: "Sort Descending",
mode: "single"
},
'export': {
allowExportSelectedData: false,//允许选择导出
customizeExcelCell: null,
enabled: true,//允许导出
excelFilterEnabled: false,
excelWrapTextEnabled: false,
fileName: "usrlog",//名字
ignoreExcelErrors: true,
},
// 'export': {
// allowExportSelectedData: false,//允许选择导出
// customizeExcelCell: null,
// enabled: true,//允许导出
// excelFilterEnabled: false,
// excelWrapTextEnabled: false,
// fileName: "usrlog",//名字
// ignoreExcelErrors: true,
//
// },
showRowLines: true,
columnAutoWidth: true,
allowColumnReordering: true,
......@@ -165,4 +165,125 @@ frameworkModule.controller('appUsrOperateLogController',
};
}]);
\ No newline at end of file
}]);
frameworkModule.directive('usrLogExportPlugin',function(){
return{
restrict:"EA",
controller:['$scope','SweetAlert','$translate','usrOperateLogService','$q','$log',
function($scope,SweetAlert,$translate,usrOperateLogService,$q,$log){
$scope.exportTableData = function ()
{
usrOperateLogService[$scope.thisModuleName + "Export"]().then(function (data, status, headers) {
if(status===204){
SweetAlert.warning("没有数据可以下载");
return;
}
exportToExcel(data, $scope.thisModuleName + '.xls');
},function () {
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
})
};
//下载服务器上的xls文件
var exportToExcel = function (data, filename) {
var defer = $q.defer();
// var octetStreamMime = 'application/vnd.ms-excel';
var success = false;
// Get the headers
// headers = headers();
// Get the filename from the x-filename header or default to "download.bin"
// var filename = decodeURI(headers['x-file-name']) + defaultFileName;
// Determine the content type from the header or default to "application/octet-stream"
// var contentType = headers['content-type'] || octetStreamMime;
try {
// Try using msSaveBlob if supported
//console.log("Trying saveBlob method ...");
var blob = new Blob([data], { type: "arraybuffer" });
if (navigator.msSaveBlob)
navigator.msSaveBlob(blob, filename);
else {
// Try using other saveBlob implementations, if available
var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
if (saveBlob === undefined) throw "Not supported";
saveBlob(blob, filename);
}
//console.log("saveBlob succeeded");
success = true;
} catch (ex) {
$log.debug("saveBlob method failed with the following exception:");
$log.debug(ex);
}
if (!success) {
// Get the blob url creator
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
// Try to use a download link
var link = document.createElement('a');
if ('download' in link) {
// Try to simulate a click
try {
// Prepare a blob URL
//console.log("Trying download link method with simulated click ...");
var blobdownload = new Blob([data], { type: "arraybuffer" });
var urldownload = urlCreator.createObjectURL(blobdownload);
link.setAttribute('href', urldownload);
// Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
link.setAttribute("download", filename);
// Simulate clicking the download link
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
//console.log("Download link method with simulated click succeeded");
success = true;
} catch (ex) {
$log.debug("Download link method with simulated click failed with the following exception:");
$log.debug(ex);
$q.reject();
}
}
if (!success) {
// Fallback to window.location method
try {
// Prepare a blob URL
// Use application/octet-stream when using window.location to force download
//console.log("Trying download link method with window.location ...");
var blobsuccess = new Blob([data], { type: "arraybuffer" });
var urlsuccess = urlCreator.createObjectURL(blobsuccess);
window.location = urlsuccess;
//console.log("Download link method with window.location succeeded");
success = true;
} catch (ex) {
//console.log("Download link method with window.location failed with the following exception:");
$log.debug(ex);
$q.reject();
}
}
}
}
if (!success) {
// Fallback to window.open method
$log.debug("No methods worked for saving the arraybuffer, using last resort window.open");
window.open(httpPath, '_blank', '');
}
//Delete the file
// deleteFile(encodeURI(filename));
defer.resolve('success');
$('#busy-indicator-container').hide();
return defer.promise;
};
}]
}
});
\ No newline at end of file
<div class="operate-log-wrapper">
<div class="operate-log-wrapper" usr-log-export-plugin>
<style>
.log-export-btn{
position: absolute;
right: 550px;
z-index: 2;
top: 1.3rem;
background: #fff;
}
.log-export-btn:hover{
background: #E6E6E6;
}
</style>
<button class="btn btn-not-important" ng-click="openUsrOperateLogPop()"><i class="material-icons">description</i><span translate="log">日志</span></button>
<script type="text/html" id="usrOperateLogPopContainer">
<div class="modal fade" id="usrOperateLogPop" tabindex="-1" role="dialog" aria-labelledby="myModal" data-backdrop="static" data-keyboard="false">
......@@ -19,6 +31,11 @@
<!--<div ui-grid="operateLogGridOptions" ui-grid-selection style="width:1140px; height:510px;margin:0px;"></div>-->
<div class="dx-viewport demo-container">
<button class="btn log-export-btn" ng-click="exportTableData()">
<i class="fa fa-file-excel-o"></i>
<span translate="ExportTable"></span>
</button>
<div dx-data-grid="dataGridOptions"></div>
</div>
......
......@@ -2,15 +2,47 @@
* Created by Administrator on 2019/2/28 0028.
*/
frameworkModule.factory('usrOperateLogService',
['$q', 'apiConfig', 'jqFetch','apiInterceptor',
function ($q, apiConfig, jqFetch,apiInterceptor) {
'use strict';
return {
docManageTypeLog: function (params) {
return jqFetch.get(apiInterceptor.webApiHostUrl + '/operLogFileTypes/selectList', params);
},
docManageListLog: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/operLogTaxDoc/selectListForLog', params);
}
};
}]);
\ No newline at end of file
['$q', 'apiConfig', 'jqFetch','apiInterceptor',
function ($q, apiConfig, jqFetch,apiInterceptor) {
'use strict';
return {
docManageTypeLog: function (params) {
return jqFetch.get(apiInterceptor.webApiHostUrl + '/operLogFileTypes/selectList', params);
},
docManageListLog: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/operLogTaxDoc/selectListForLog', params);
},
docManageListLogExport:function(){
$('#busy-indicator-container').show();
return exportFn(apiInterceptor.webApiHostUrl + '/operLogTaxDoc/exportExcel');
},
docManageTypeLogExport:function(){
$('#busy-indicator-container').show();
return exportFn(apiInterceptor.webApiHostUrl + '/operLogFileTypes/exportExcel');
// http://etms.longi-silicon.com:8180//api/v1/operLogFileTypes/exportExcel
}
};
function exportFn(url) {
var defer = $q.defer();
var xhr = new XMLHttpRequest();
xhr.onload = function(e) {
var arraybuffer = xhr.response;
console.info("arraybuffer:",arraybuffer);
defer.resolve(arraybuffer,xhr.status,xhr.getAllResponseHeaders());
};
xhr.open("POST", url, true);
xhr.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
xhr.setRequestHeader("Content-Type", 'application/json;charset=UTF-8');
xhr.responseType = "arraybuffer";
xhr.send();
return defer.promise;
}
}]);
\ No newline at end of file
......@@ -79,8 +79,8 @@ taxDocumentManageModule.factory('taxDocumentListService',
return jqFetch.get(apiInterceptor.webApiHostUrl + '/businessunit/getlist', params);
},
downloadAllFile:function(params){
//post请求会自带http://etms.longi-silicon.com:8180//api/v1的前缀路径,get请求不会
var xhr = new XMLHttpRequest();
var fileName = 'files.zip'; // 文件名称
xhr.open('POST', apiInterceptor.webApiHostUrl + "/taxDoc/downloadAllFile", true);
xhr.responseType = 'arraybuffer';
// xhr.setRequestHeader(token, 'xxxxx') ;// 请求头中的验证信息等(如果有)
......@@ -88,9 +88,11 @@ taxDocumentManageModule.factory('taxDocumentListService',
xhr.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
xhr.setRequestHeader("Content-Type", 'application/json;charset=UTF-8');
xhr.onload = function() {
if (this.status === 200) {
// let type = xhr.getResponseHeader('Content-Type');
var fileName = 'files.zip'; // 文件名称
var headers = xhr.getAllResponseHeaders();
fileName = headers['x-file-name'] ? headers['x-file-name'] : fileName;
if (this.status === 200) {
var blob = new Blob([this.response], {type: "arraybuffer"});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
/*
......@@ -138,6 +140,25 @@ taxDocumentManageModule.factory('taxDocumentListService',
oReq.responseType = "arraybuffer";
oReq.send();
return defer.promise;
},
exportTableData:function(params){
$('#busy-indicator-container').show();
var defer = $q.defer();
var xhr = new XMLHttpRequest();
xhr.onload = function(e) {
var arraybuffer = xhr.response;
console.info("arraybuffer:",arraybuffer);
defer.resolve(arraybuffer,xhr.status,xhr.getAllResponseHeaders());
};
xhr.open("POST", apiInterceptor.webApiHostUrl + '/taxDoc/exportExcel', true);
xhr.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
xhr.setRequestHeader("Content-Type", 'application/json;charset=UTF-8');
xhr.responseType = "arraybuffer";
xhr.send(JSON.stringify(params));
return defer.promise;
}
};
......
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