Commit fb049e40 authored by chase's avatar chase

merge 档案管理

parent 33578ccf
package pwc.taxtech.atms.controller;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import pwc.taxtech.atms.dto.ReturnData;
......@@ -24,7 +26,7 @@ public class OperationLogTaxDocController {
@RequestMapping("selectList")
@ResponseBody
public ReturnData selectTaxDocumentList(){
public ReturnData selectTaxDocumentList() {
List<OperationLogTaxDocument> operationLogTaxDocuments = operationLogTaxDocService.selectTaxDocumentList();
ReturnData returnData = new ReturnData();
returnData.setItems(operationLogTaxDocuments);
......@@ -34,13 +36,15 @@ public class OperationLogTaxDocController {
/**
* 根据 id 数组来查询相关日志
* @param taxDocumentIds
*
* @param operationLogTaxDocument
* @return
*/
@RequestMapping("/selectListForLog")
@ResponseBody
public ReturnData selectListForLog(List<String> taxDocumentIds){
List<OperationLogTaxDocument> operationLogTaxDocuments = operationLogTaxDocService.selectListForLog(taxDocumentIds);
public ReturnData selectListForLog(@RequestBody OperationLogTaxDocument operationLogTaxDocument) {
List<String> ids = operationLogTaxDocument.getIds() == null ? Lists.newArrayList() : operationLogTaxDocument.getIds();
List<OperationLogTaxDocument> operationLogTaxDocuments = operationLogTaxDocService.selectListForLog(ids);
ReturnData returnData = new ReturnData();
returnData.setItems(operationLogTaxDocuments);
returnData.setTotalCount(operationLogTaxDocuments.size());
......@@ -49,25 +53,25 @@ public class OperationLogTaxDocController {
@RequestMapping("add")
@ResponseBody
public boolean addTaxDocuments(OperationLogTaxDocument operationLogTaxDocument){
public boolean addTaxDocuments(OperationLogTaxDocument operationLogTaxDocument) {
return operationLogTaxDocService.addTaxDocumentList(operationLogTaxDocument);
}
@RequestMapping("delete")
@ResponseBody
public boolean deleteTaxDocuments(String id){
public boolean deleteTaxDocuments(String id) {
return operationLogTaxDocService.deleteTaxDocument(id);
}
@RequestMapping("edit")
@ResponseBody
public boolean editTaxDocuments(OperationLogTaxDocument operationLogTaxDocument){
public boolean editTaxDocuments(OperationLogTaxDocument operationLogTaxDocument) {
return operationLogTaxDocService.editFilesType(operationLogTaxDocument);
}
@RequestMapping("exportExcel")
@ResponseBody
public void exportExcelFile (HttpServletResponse response){
public void exportExcelFile(HttpServletResponse response) {
try {
Map<String, String> headers = new HashMap<String, String>();
headers.put("id", "id");
......@@ -86,7 +90,7 @@ public class OperationLogTaxDocController {
response.setHeader("Content-Disposition", "attachment;fileName=" + new String("".getBytes("GB2312"), "ISO-8859-1"));
OutputStream ouputStream = response.getOutputStream();
ExcelUtil.exportExcel(headers, TaxDocuments, ouputStream);
}catch(Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
......
......@@ -246,6 +246,13 @@ public class TaxDocumentController {
}
}
/**
* 下载全部附件
*/
@PostMapping(value = "/downloadAllFile")
public void downloadAllFile(HttpServletResponse response, @RequestBody TaxDocumentDto taxDocumentDto) {
taxDocumentService.downloadAllFile(response,taxDocumentDto.getIds());
}
/**
* 解析json
......
......@@ -51,7 +51,9 @@ public class OperationLogTaxDocServiceImpl {
public List<OperationLogTaxDocument> selectListForLog(List<String> taxDocumentIds) {
OperationLogTaxDocumentExample example = new OperationLogTaxDocumentExample();
OperationLogTaxDocumentExample.Criteria criteria = example.createCriteria();
criteria.andIdIn(taxDocumentIds);
if (taxDocumentIds.size()>0){
criteria.andIdIn(taxDocumentIds);
}
return operationLogTaxDocumentMapper.selectByExample(example);
}
}
......@@ -22,8 +22,16 @@ import pwc.taxtech.atms.vat.entity.FileUpload;
import pwc.taxtech.atms.vat.entity.ReportFileUpload;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* 查询
......@@ -47,8 +55,6 @@ public class TaxDocumentServiceImpl {
@Autowired
DidiFileUploadService didiFileUploadService;
@Autowired
private BusinessUnitServiceImpl businessUnitService;
@Autowired
private OrganizationServiceImpl organizationService;
......@@ -340,4 +346,127 @@ public class TaxDocumentServiceImpl {
return false;
}
}
public void downloadAllFile(HttpServletResponse response, List<Long> ids) {
String downloadName = "多选附件.zip";
try {
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(downloadName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("下载文件名编码时出现错误.", e);
}
OutputStream outputStream = null;
ZipOutputStream zos = null;
try {
outputStream = response.getOutputStream();
zos = new ZipOutputStream(outputStream);
// 将文件流写入zip中
downloadTolocal(zos, ids);
} catch (IOException e) {
log.error("downloadAllFile-xxx下载全部附件失败,ids=[{}],错误信息=[{}]", ids, e);
} finally {
if (zos != null) {
try {
zos.close();
} catch (Exception e2) {
log.info("关闭输入流时出现错误", e2);
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (Exception e2) {
log.info("关闭输入流时出现错误", e2);
}
}
}
}
/**
* // 将文件流写入zip中
*
* @param zos
* @param ids
*/
private void downloadTolocal(ZipOutputStream zos, List<Long> ids) {
TaxDocumentExample example = new TaxDocumentExample();
TaxDocumentExample.Criteria criteria = example.createCriteria();
if (null == ids || ids.size() < 1) {
throw new RuntimeException("传入参数错误:空参数数组");
}
criteria.andIdIn(ids);
List<TaxDocument> taxDocuments = taxDocumentMapper.selectByExample(example);
for (TaxDocument item : taxDocuments) {
//文件url
String urlPath = item.getFilePositionUrl();
//如果url为null或空字符串而抛出异常
if (StringUtils.isBlank(urlPath)) {
throw new RuntimeException("文件url为空,id为:" + item.getId());
}
//文件名称(带后缀)
String fileName = StringUtils.isBlank(item.getFileOriginalName()) ? "未知文件(请修改后缀名).xlsx" : item.getFileOriginalName();
InputStream is = null;
BufferedInputStream in = null;
byte[] buffer = new byte[1024];
int len;
//创建zip实体(一个文件对应一个ZipEntry)
ZipEntry entry = new ZipEntry(fileName);
try {
//获取需要下载的文件流
URL httpurl = new URL(URLDecoder.decode(urlPath, "UTF-8"));
HttpURLConnection httpConn = (HttpURLConnection) httpurl.openConnection();
httpConn.setDoOutput(true);// 使用 URL 连接进行输出
httpConn.setDoInput(true);// 使用 URL 连接进行输入
httpConn.setUseCaches(false);// 忽略缓存
httpConn.setRequestMethod("GET");// 设置URL请求方法
//可设置请求头
httpConn.setRequestProperty("Content-Type", "application/octet-stream");
httpConn.setRequestProperty("Connection", "Keep-Alive");// 维持长连接
httpConn.setRequestProperty("Charset", "UTF-8");
httpConn.connect();
if (httpConn.getResponseCode() >= 400) {
is = httpConn.getErrorStream();
} else {
is = httpConn.getInputStream();
}
in = new BufferedInputStream(is);
zos.putNextEntry(entry);
//文件流循环写入ZipOutputStream
while ((len = in.read(buffer)) != -1) {
zos.write(buffer, 0, len);
}
} catch (Exception e) {
log.info("xxx--下载全部附件--压缩文件出错", e);
} finally {
if (entry != null) {
try {
zos.closeEntry();
} catch (Exception e2) {
log.info("xxx下载全部附件--zip实体关闭失败", e2);
}
}
if (in != null) {
try {
in.close();
} catch (Exception e2) {
log.info("xxx下载全部附件--文件输入流关闭失败", e2);
}
}
if (is != null) {
try {
is.close();
} catch (Exception e) {
log.info("xxx下载全部附件--输入缓冲流关闭失败", e);
}
}
}
}
}
}
......@@ -2,6 +2,7 @@ package pwc.taxtech.atms.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*
......@@ -110,6 +111,8 @@ public class OperationLogTaxDocument implements Serializable {
*/
private Date createTime;
List<String> ids;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table operation_log_tax_document
......@@ -118,6 +121,14 @@ public class OperationLogTaxDocument implements Serializable {
*/
private static final long serialVersionUID = 1L;
public List<String> getIds() {
return ids;
}
public void setIds(List<String> ids) {
this.ids = ids;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column operation_log_tax_document.id
......
......@@ -45,16 +45,19 @@
.select-simulator-option-menu ul li{
padding:0 8px;
list-style: none;
color: #000;
font-size: 13px;
line-height: 1;
}
.select-simulator-option-menu ul li:hover{
background-color: #e7e8e0;
}
.select-simulator-option-menu ul li:nth-child(odd){
background-color: #efefef;
background-color: #F2F2F2;;
}
.select-simulator-option-menu ul li > label{
padding-bottom:5px;
margin:0;
padding: 8px 0;
}
.input-reset-button {
......@@ -93,6 +96,13 @@
position: relative;
background: inherit;
}
.select-simulator-option-name{
float:left;
}
.select-simulator-option-check-icon{
float:right;
color:#0db4ff;
}
</style>
<div class="select-simulator">
<input class="for-fake-input"
......@@ -120,10 +130,11 @@
<label style="width: 100%;" ng-click="checksOption()">
<input type="{{optionType}}"
name="simulatorOptionMenu"
value="{{value}}"
value="{{value}}" ng-hide="true"
ng-checked="selected.indexOf(optionValues[$index]) > -1"
data-key="{{optionKeys[$index]}}"/>
<span>{{value}}</span>
<span class="select-simulator-option-name">{{value}}</span>
<i ng-if="selected.indexOf(optionValues[$index]) > -1" class="fa fa-check select-simulator-option-check-icon"></i>
</label>
</li>
</ul>
......
......@@ -11,9 +11,9 @@ frameworkModule.controller('appUsrOperateLogController',
$scope.loadMainData = function () {
$scope.thisModuleId = $scope.thisModuleId ? $scope.thisModuleId : [];
var config = {
params: {
taxDocumentIds:JSON.stringify($scope.thisModuleId)
}
// params: {
"ids":$scope.thisModuleId
// }
};
usrOperateLogService[$scope.thisModuleName](config).then(function (data) {
if (status === 204) {
......
......@@ -10,7 +10,7 @@ function ($q, apiConfig, jqFetch,apiInterceptor) {
return jqFetch.get(apiInterceptor.webApiHostUrl + '/operLogFileTypes/selectList', params);
},
docManageListLog: function (params) {
return jqFetch.get(apiInterceptor.webApiHostUrl + '/operLogTaxDoc/selectListForLog', params);
return jqFetch.post(apiInterceptor.webApiHostUrl + '/operLogTaxDoc/selectListForLog', params);
}
};
}]);
\ No newline at end of file
......@@ -9,15 +9,6 @@ taxDocumentManageModule.controller('taxDocumentListController',
$scope.queryFieldModel = {};
$scope.editFieldModel = {};
$scope.resetQueryField = function () {
$scope.queryFieldModel = {};
$("#period-picker1").val("");
$("#period-picker2").val("");
$("#period-picker3").val("");
$("#period-picker4").val("");
};
$scope.pagingOptions = {};
$scope.localData = null;
$scope.loadMainData = function () {
......@@ -31,28 +22,30 @@ taxDocumentManageModule.controller('taxDocumentListController',
params.ownTime = params.ownTime ? params.ownTime : "";
var splitMark = params.ownTime.indexOf("-") > -1 ? "-" : "/";
params.ownTime = parseInt(params.ownTime.split(splitMark).join(""));
// if($scope.queryOwnTime)params.ownTime = $scope.queryOwnTime(params.ownTime,"int");
params.fileBeginTime ? params.fileBeginTime += "-01" : "";
if(params.fileEndTTime){
var fileEndTTimeDate = $scope.getMonthLastDate(params.fileEndTTime.split("-")[0],params.fileEndTTime.split("-")[1]);
if (params.fileEndTTime) {
var fileEndTTimeDate = $scope.getMonthLastDate(params.fileEndTTime.split("-")[0], params.fileEndTTime.split("-")[1]);
params.fileEndTTime += "-" + fileEndTTimeDate;
}
params.ownBeginTime ? params.ownBeginTime += "-01" : "";
if(params.ownEndTime){
var ownEndTimeDate = $scope.getMonthLastDate(params.ownEndTime.split("-")[0],params.ownEndTime.split("-")[1]);
if (params.ownEndTime) {
var ownEndTimeDate = $scope.getMonthLastDate(params.ownEndTime.split("-")[0], params.ownEndTime.split("-")[1]);
params.ownEndTime += "-" + ownEndTimeDate;
}
params.effectiveBeginTime ? params.effectiveBeginTime += "-01" : "";
if(params.effectiveEndTime){
var effectiveEndTimeDate = $scope.getMonthLastDate(params.effectiveEndTime.split("-")[0],params.effectiveEndTime.split("-")[1]);
if (params.effectiveEndTime) {
var effectiveEndTimeDate = $scope.getMonthLastDate(params.effectiveEndTime.split("-")[0], params.effectiveEndTime.split("-")[1]);
params.effectiveEndTime += "-" + effectiveEndTimeDate;
}
params.uploadBeginTime ? params.uploadBeginTime += "-01" : "";
if(params.uploadEndTime){
var uploadEndTimeDate = $scope.getMonthLastDate(params.uploadEndTime.split("-")[0],params.uploadEndTime.split("-")[1]);
if (params.uploadEndTime) {
var uploadEndTimeDate = $scope.getMonthLastDate(params.uploadEndTime.split("-")[0], params.uploadEndTime.split("-")[1]);
params.uploadEndTime += "-" + uploadEndTimeDate;
}
......@@ -170,10 +163,10 @@ taxDocumentManageModule.controller('taxDocumentListController',
try {
if (options.data.ownTime) {
// 这是所属时间返回的是int类型
var ownTimeString = options.data.ownTime + "";
var year = ownTimeString.substr(0, 4);
var mon = ownTimeString.substr(4, 2);
$('<span>').text(year + "/" + mon).appendTo(container);
// var ownTimeString = options.data.ownTime + "";
// var year = ownTimeString.substr(0, 4);
// var mon = ownTimeString.substr(4, 2);
$('<span>').text($scope.queryOwnTime(options.data.ownTime, "/")).appendTo(container);
} else {
$('<span>').text('').appendTo(container);
}
......@@ -263,12 +256,12 @@ taxDocumentManageModule.controller('taxDocumentListController',
// var eventTarget = $(prevTargetString + editTargetString);
// $compile(eventTarget)($scope);
// container.append(eventTarget);
var prevTarget = $('<a style="color:#506bf7;margin-right:1rem;" href="javascript:void(0)"><span>'+$translate.instant('Preview')+'</span></a>');
prevTarget.off('click').on('click',function(){
$scope.viewRemoteFile(options.data.fileName,options.data.filePositionUrl);
var prevTarget = $('<a style="color:#506bf7;margin-right:1rem;" href="javascript:void(0)"><span>' + $translate.instant('Preview') + '</span></a>');
prevTarget.off('click').on('click', function () {
$scope.viewRemoteFile(options.data.fileName, options.data.filePositionUrl);
});
var editTarget = $('<a style="color:#506bf7;" href="javascript:void(0)"><span>'+$translate.instant('Edit')+'</span></a>');
editTarget.off('click').on('click',function(){
var editTarget = $('<a style="color:#506bf7;" href="javascript:void(0)"><span>' + $translate.instant('Edit') + '</span></a>');
editTarget.off('click').on('click', function () {
$scope.openSimpleUploadPop(options.data.id);
});
......@@ -292,12 +285,14 @@ taxDocumentManageModule.controller('taxDocumentListController',
$scope.localData.forEach(function (item) {
if (item.id == rowId) {
$scope.editFieldModel = angular.copy(item);
var ownTimeString = item.ownTime + "";
var year = ownTimeString.substr(0, 4);
var mon = ownTimeString.substr(4, 2);
$scope.editFieldModel.ownTime = year + "/" + mon;
$scope.editFieldModel.fileTime = $scope.queryDate(item.fileTime,"/");
$scope.editFieldModel.effectiveTime = $scope.queryDate(item.effectiveTime,"/");
// var ownTimeString = item.ownTime + "";
// var year = ownTimeString.substr(0, 4);
// var mon = ownTimeString.substr(4, 2);
// $scope.editFieldModel.ownTime = year + "/" + mon;
$scope.editFieldModel.ownTime = $scope.queryOwnTime(item.ownTime, "/");
$scope.editFieldModel.fileTime = $scope.queryDate(item.fileTime, "/");
$scope.editFieldModel.effectiveTime = $scope.queryDate(item.effectiveTime, "/");
$scope.syncFileType($scope.editFieldModel.fileAttr);
$scope.matchFieldTypeId($scope.editFieldModel);
}
......@@ -318,11 +313,13 @@ taxDocumentManageModule.controller('taxDocumentListController',
var simpleUploadSubmit = function () {
var params = angular.copy($scope.editFieldModel);
params.ownTime = params.ownTime ? params.ownTime : "";
var splitMark = params.ownTime.indexOf("-") > -1 ? "-" : "/";
params.ownTime = parseInt(params.ownTime.split(splitMark).join(""));
params.fileTime = $scope.queryDate(params.fileTime,"-");
params.effectiveTime = $scope.queryDate(params.effectiveTime,"-");
// params.ownTime = params.ownTime ? params.ownTime : "";
// var splitMark = params.ownTime.indexOf("-") > -1 ? "-" : "/";
// params.ownTime = parseInt(params.ownTime.split(splitMark).join(""));
params.ownTime = $scope.queryOwnTime(params.ownTime, "int");
params.fileTime = $scope.queryDate(params.fileTime, "-");
params.effectiveTime = $scope.queryDate(params.effectiveTime, "-");
params.filePositionUrl = encodeURIComponent(params.filePositionUrl);
taxDocumentListService.verifyDuplicate(params).then(function (data) {
// 先设置上传参数
......@@ -335,14 +332,14 @@ taxDocumentManageModule.controller('taxDocumentListController',
var fields = {};
var curItemValue = $scope.editFieldModel[key] ? $scope.editFieldModel[key] : "";
if (/ownTime/.test(key)) {
// var splitMark = curItemValue.indexOf("-") > -1 ? "-" : "/";
// fields[key] = parseInt(curItemValue.split(splitMark).join(""));
fields[key] = $scope.queryOwnTime(curItemValue, "int");
} else {
var splitMark = curItemValue.indexOf("-") > -1 ? "-" : "/";
fields[key] = parseInt(curItemValue.split(splitMark).join(""));
}else{
if(/(createTime|updateTime|uploadTime)/.test(key)){
fields[key] = $scope.queryDate(fields[key],"/");
}else fields[key] = curItemValue;
if (/(createTime|updateTime|uploadTime)/.test(key)) {
fields[key] = $scope.queryDate(curItemValue, "/");
} else fields[key] = curItemValue;
}
uploadItem.formData.push(fields);
......@@ -382,9 +379,10 @@ taxDocumentManageModule.controller('taxDocumentListController',
var addLogicAfterUploadFile = function (editFieldModel, type) {
var params = angular.copy(editFieldModel);
params.ownTime = params.ownTime ? params.ownTime : "";
var splitMark = params.ownTime.indexOf("-") > -1 ? "-" : "/";
params.ownTime = parseInt(params.ownTime.split(splitMark).join(""));
// params.ownTime = params.ownTime ? params.ownTime : "";
// var splitMark = params.ownTime.indexOf("-") > -1 ? "-" : "/";
// params.ownTime = parseInt(params.ownTime.split(splitMark).join(""));
params.ownTime = $scope.queryOwnTime(params.ownTime, "int");
taxDocumentListService.addNewRecord(params).then(function (data) {
if (data == true) {
if (type == 'simp') {
......@@ -421,15 +419,16 @@ taxDocumentManageModule.controller('taxDocumentListController',
var editDocFileRecord = function (fieldModel, type) {
var params = angular.copy(fieldModel);
params.ownTime = params.ownTime ? params.ownTime : "";
var splitMark = params.ownTime.indexOf("-") > -1 ? "-" : "/";
params.ownTime = parseInt(params.ownTime.split(splitMark).join(""));
params.effectiveTime = $scope.queryDate(params.effectiveTime,"/");
params.fileTime = $scope.queryDate(params.fileTime,"/");
params.createTime = $scope.queryDate(params.createTime,"/");
params.updateTime = $scope.queryDate(params.updateTime,"/");
params.uploadTime = $scope.queryDate(params.uploadTime,"/");
// params.ownTime = params.ownTime ? params.ownTime : "";
// var splitMark = params.ownTime.indexOf("-") > -1 ? "-" : "/";
// params.ownTime = parseInt(params.ownTime.split(splitMark).join(""));
params.ownTime = $scope.queryOwnTime(params.ownTime, "int");
params.effectiveTime = $scope.queryDate(params.effectiveTime, "/");
params.fileTime = $scope.queryDate(params.fileTime, "/");
params.createTime = $scope.queryDate(params.createTime, "/");
params.updateTime = $scope.queryDate(params.updateTime, "/");
params.uploadTime = $scope.queryDate(params.uploadTime, "/");
params.filePositionUrl = encodeURIComponent(params.filePositionUrl);
taxDocumentListService.editRecord(params).then(function (data) {
if (data == true) {
if (type == 'simple') {
......@@ -469,16 +468,18 @@ taxDocumentManageModule.controller('taxDocumentListController',
};
var delRecord = function () {
var delItems = {};
delItems.ids = [];
var delIDs = [];
// delItems.ids = [];
$("input[name='dataGridCheckBox']").each(function (index, tdCell) {
if (tdCell.checked) {
var cellId = $(tdCell).attr('data-id');
delItems.ids.push(cellId);
delIDs.push(cellId);
}
});
taxDocumentListService.delFileRecordItems(delItems).then(function (data) {
taxDocumentListService.delFileRecordItems({
"ids":delIDs
}).then(function (data) {
if (data) {
SweetAlert.swal({
title: $translate.instant("Deleted"),
......@@ -493,37 +494,6 @@ taxDocumentManageModule.controller('taxDocumentListController',
});
};
var downloadAttachment = function () {
var checkedURLs = [
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
];
$("input[name='dataGridCheckBox']").each(function (index, item) {
if (item.checked) {
var cellUrl = $(item).attr("data-url");
checkedURLs.push(cellUrl);
}
});
if (!checkedURLs.length) return SweetAlert.warning($translate.instant("NeedChecked"));
var triggerDelay = 100;
var removeDelay = 1000;
checkedURLs.forEach(function (item, index) {
_createIFrame(item, index * triggerDelay, removeDelay);
});
function _createIFrame(url, _triggerDelay, _removeDelay) {
setTimeout(function () {
var frame = $('<iframe style="display: none;" class="multi-download"></iframe>');
frame.attr('src', url);
document.body.appendChild(frame[0]);
setTimeout(function () {
frame.remove();
}, _removeDelay);
}, _triggerDelay);
}
};
$scope.loadSelectMap = function () {
taxDocumentListService.getFileInfoOptions().then(function (data) {
// console.log(data);
......@@ -550,6 +520,12 @@ taxDocumentManageModule.controller('taxDocumentListController',
});
};
$scope.businessLineOptions = [];
$scope.loadBusinessList = function(){
taxDocumentListService.getBusinessList().then(function(resData){
$scope.businessLineOptions = resData;
});
};
(function initialize() {
$scope.typeAndAttrMap = {};
$scope.fileTypeOptions = {};
......@@ -562,10 +538,10 @@ taxDocumentManageModule.controller('taxDocumentListController',
$scope.multiUploader = {};
$scope.loadMainData();
$scope.loadSelectMap();
$scope.loadBusinessList();
//注册方法
$scope.openSimpleUploadPop = openSimpleUploadPop;
$scope.delRecord = delRecord;
$scope.downloadAttachment = downloadAttachment;
$scope.addLogicAfterUploadFile = addLogicAfterUploadFile;
$scope.simpleUploadSubmit = simpleUploadSubmit;
$scope.coverDocFileRecord = editDocFileRecord;
......@@ -589,8 +565,8 @@ taxDocumentManageModule.directive('dateTimePicker', function () {
$element.datepicker({
startDate: new Date(year - 20, 1, 1),
endDate: new Date(year + 20, 1, 1),
viewMode: $attrs["viewMode"] ? parseInt($attrs["viewMode"]):0,
minViewMode: $attrs["minViewMode"] ? parseInt($attrs["minViewMode"]):0,
viewMode: $attrs["viewMode"] ? parseInt($attrs["viewMode"]) : 0,
minViewMode: $attrs["minViewMode"] ? parseInt($attrs["minViewMode"]) : 0,
autoclose: true,
language: region,
todayBtn: true,
......@@ -655,8 +631,8 @@ taxDocumentManageModule.directive('dateTimePicker', function () {
taxDocumentManageModule.directive('fileUploader', function () {
return {
restrict: "EA",
controller: ['$scope', 'FileUploader', 'apiInterceptor', 'taxDocumentListService', '$translate', 'SweetAlert','$compile',
function ($scope, FileUploader, apiInterceptor, taxDocumentListService, $translate, SweetAlert,$compile) {
controller: ['$scope', 'FileUploader', 'apiInterceptor', 'taxDocumentListService', '$translate', 'SweetAlert', '$compile',
function ($scope, FileUploader, apiInterceptor, taxDocumentListService, $translate, SweetAlert, $compile) {
$scope.uploadFile = function () {
$("#uploadFilePlugin").click();
};
......@@ -669,19 +645,19 @@ taxDocumentManageModule.directive('fileUploader', function () {
$scope.uploader.filters.push({//xls限制
name: 'fileTypeFilter',
fn: function (item, options) {
if(item.name.indexOf("_") === -1) {
SweetAlert.warning("文件名格式不符合规则,请重新选择(正确格式必须包含'公司名称'和'档案类型',并用下划线'_'分隔)");
return false;
}
// if(item.name.indexOf("_") === -1) {
// SweetAlert.warning("文件名格式不符合规则,请重新选择(正确格式必须包含'公司名称'和'档案类型',并用下划线'_'分隔)");
// return false;
// }
var fileNativePath = $("#uploadFilePlugin")[0].value || "";
fileNativePath = fileNativePath.replace(/fakepath/img,"******");
fileNativePath = fileNativePath.replace(/fakepath/img, "******");
var splitMark = /\//.test(fileNativePath) ? "/" : "\\";
var prevPath = fileNativePath.split(splitMark);
prevPath.pop();
fileNativePath = prevPath.join(splitMark) + splitMark;
$scope.editFieldModel.fileNativePath = fileNativePath;
$scope.editFieldModel.fileName = item.name;
$scope.autoMatchAttrAndType(item.name,$scope.editFieldModel);
$scope.autoMatchAttrAndType(item.name, $scope.editFieldModel);
return true;
}
});
......@@ -721,7 +697,7 @@ taxDocumentManageModule.directive('fileUploader', function () {
taxDocumentManageModule.directive('multiFileUploader', function () {
return {
restrict: "EA",
controller: ['$scope', 'FileUploader', 'apiInterceptor', 'taxDocumentListService', '$translate', 'SweetAlert','$compile',
controller: ['$scope', 'FileUploader', 'apiInterceptor', 'taxDocumentListService', '$translate', 'SweetAlert', '$compile',
function ($scope, FileUploader, apiInterceptor, taxDocumentListService, $translate, SweetAlert, $compile) {
var timer = null;
$scope.activeTab = function (activeIndex) {
......@@ -760,12 +736,12 @@ taxDocumentManageModule.directive('multiFileUploader', function () {
$scope.multiUploader.filters.push({//xls限制
name: 'fileTypeFilter',
fn: function (item, options) {
if(item.name.indexOf("_") === -1) {
if (item.name.indexOf("_") === -1) {
SweetAlert.warning("文件名格式不符合规则,请重新选择(正确格式必须包含'公司名称''档案类型',并用下划线'_'分隔)");
return false;
}
var fileNativePath = $("#multiUploadFilePlugin")[0].value || "";
fileNativePath = fileNativePath.replace(/fakepath/img,"******");
fileNativePath = fileNativePath.replace(/fakepath/img, "******");
var splitMark = /\//.test(fileNativePath) ? "/" : "\\";
var prevPath = fileNativePath.split(splitMark);
prevPath.pop();
......@@ -776,7 +752,7 @@ taxDocumentManageModule.directive('multiFileUploader', function () {
iShow: $scope.editFieldModel_multi.length == 0
};
$scope.editFieldModel_multi.push(thisModel);
$scope.autoMatchAttrAndType(item.name,thisModel);
$scope.autoMatchAttrAndType(item.name, thisModel);
// 根据需求,改为不做类型限制
return true;
}
......@@ -824,12 +800,14 @@ taxDocumentManageModule.directive('multiFileUploader', function () {
var fields = {};
var curItemValue = editFieldModel[key] ? editFieldModel[key] : "";
if (/ownTime/.test(key)) {
var splitMark = curItemValue.indexOf("-") > -1 ? "-" : "/";
fields[key] = parseInt(curItemValue.split(splitMark).join(""));
}else {
if(/(createTime|updateTime|uploadTime)/.test(key)){
fields[key] = $scope.queryDate(fields[key],"/");
}else fields[key] = curItemValue;
// var splitMark = curItemValue.indexOf("-") > -1 ? "-" : "/";
// fields[key] = parseInt(curItemValue.split(splitMark).join(""));
fields[key] = $scope.queryOwnTime(curItemValue, "int");
} else {
if (/(createTime|updateTime|uploadTime)/.test(key)) {
fields[key] = $scope.queryDate(curItemValue, "/");
} else fields[key] = curItemValue;
}
fileItem.formData.push(fields);
});
......@@ -838,15 +816,16 @@ taxDocumentManageModule.directive('multiFileUploader', function () {
(function (_i, _fileItem, _editFieldModel, _taxDocumentListService, _multiUploader) {
var params = angular.copy(_editFieldModel);
params.ownTime = params.ownTime ? params.ownTime : "";
params.ownTime = parseInt(_editFieldModel.ownTime.split("-").join(""));
params.fileTime = $scope.queryDate(params.fileTime,"-");
params.effectiveTime = $scope.queryDate(params.effectiveTime,"-");
// params.ownTime = params.ownTime ? params.ownTime : "";
// params.ownTime = parseInt(_editFieldModel.ownTime.split("-").join(""));
params.ownTime = $scope.queryOwnTime(params.ownTime, "int");
params.fileTime = $scope.queryDate(params.fileTime, "-");
params.effectiveTime = $scope.queryDate(params.effectiveTime, "-");
_taxDocumentListService.verifyDuplicate(params).then(function (data) {
if (data == true) {
_fileItem.url = apiInterceptor.webApiHostUrl + "/taxDoc/add";
_fileItem.url = "http://etms.longi-silicon.com:8180//api/v1/taxDoc/add";
} else {
_fileItem.url = apiInterceptor.webApiHostUrl + "/taxDoc/edit";
_fileItem.url = "http://etms.longi-silicon.com:8180//api/v1/taxDoc/edit";
}
_multiUploader.uploadItem(_i);
});
......@@ -932,7 +911,7 @@ taxDocumentManageModule.directive('filePreview', function () {
function renderXLS(resData) {
try {
if(!resData || !resData.length) return SweetAlert.warning("Empty File");
if (!resData || !resData.length) return SweetAlert.warning("Empty File");
var _resData = JSON.parse(resData);
sheetSumPages = _resData.length;
var curSheet = _resData[sheetCurPageIndex];
......@@ -1133,8 +1112,8 @@ taxDocumentManageModule.directive('pdfPreview', function () {
taxDocumentManageModule.directive('helpPop', function () {
return {
restrict: 'EA',
controller: ['$scope', 'taxDocumentListService', '$translate', '$compile',
function ($scope, taxDocumentListService, $translate, $compile) {
controller: ['$scope', 'taxDocumentListService', '$translate', '$compile','SweetAlert',
function ($scope, taxDocumentListService, $translate, $compile,SweetAlert) {
$scope.openHelpPop = function () {
$scope.help_loadData();
};
......@@ -1191,7 +1170,9 @@ taxDocumentManageModule.directive('helpPop', function () {
],
};
};
$scope.openHelpPopForEntityStorage = function () {
window.swal($translate.instant('EntityStorageDescription'));
}
}]
}
});
......@@ -1223,10 +1204,10 @@ taxDocumentManageModule.directive('watchGroup', function () {
// 3,文档属性
// 4,文档类型
// 5,文档类型ID
$scope.autoMatchAttrAndType = function (fileName,fieldModel) {
$scope.autoMatchAttrAndType = function (fileName, fieldModel) {
fileName = fileName ? fileName : "";
var fieldsAttrs = fileName.split("_");
fieldModel.companyName = fieldsAttrs[0];
fieldModel.fileName = fieldsAttrs[0];
fieldModel.fileType = fieldsAttrs[1];
// 根据Type来匹配Attr;
......@@ -1241,10 +1222,10 @@ taxDocumentManageModule.directive('watchGroup', function () {
};
// 选了类型之后,就自动匹配必填字段
$scope.syncRequiredFields = function(fieldModel){
$scope.syncRequiredFields = function (fieldModel) {
$scope.FileAttrAndTypeCache.forEach(function (FATItem) {
if(FATItem.fileType === fieldModel.fileType
&& FATItem.fileAttr === fieldModel.fileAttr){
if (FATItem.fileType === fieldModel.fileType
&& FATItem.fileAttr === fieldModel.fileAttr) {
$scope.requiredField = FATItem.requiredField;
}
});
......@@ -1253,24 +1234,24 @@ taxDocumentManageModule.directive('watchGroup', function () {
$scope.matchFieldTypeId(fieldModel);
};
$scope.isRequired = function(IT8nField){
$scope.isRequired = function (IT8nField) {
return $scope.requiredField.indexOf($translate.instant(IT8nField)) > -1;
};
$scope.matchFieldTypeId = function(fieldModel){
$scope.matchFieldTypeId = function (fieldModel) {
// 根据Type来匹配TypeId;
$scope.FileAttrAndTypeCache.forEach(function (FATItem) {
if(FATItem.fileType === fieldModel.fileType
&& FATItem.fileAttr === fieldModel.fileAttr){
if (FATItem.fileType === fieldModel.fileType
&& FATItem.fileAttr === fieldModel.fileAttr) {
fieldModel.fileTypeId = FATItem.id;
}
});
};
// 选了公司之后,就自动匹配公司ID
$scope.matchCompanyId = function(fieldModel){
$scope.matchCompanyId = function (fieldModel) {
Object.keys($scope.companyNameOptionsMap).forEach(function (key) {
if($scope.companyNameOptionsMap[key] === fieldModel.companyName){
if ($scope.companyNameOptionsMap[key] === fieldModel.companyName) {
fieldModel.companyId = key;
}
})
......@@ -1283,15 +1264,13 @@ taxDocumentManageModule.directive('watchGroup', function () {
taxDocumentManageModule.directive('tempModule', function () {
return {
restrict: 'EA',
controller: ['$scope','taxDocumentListService','$translate',
function ($scope,taxDocumentListService,$translate) {
controller: ['$scope', 'taxDocumentListService', '$translate',
function ($scope, taxDocumentListService, $translate) {
//税种
$scope.taxTypeSelects = ["纳税申报表","税票"];
// updateTime: null
// uploadTime: "2019-03-13T12:05:03.000+08:00"
$scope.taxTypeSelects = ["纳税申报表", "税票"];
$scope.queryDate = function(time,mark){
if(!time) return "";
$scope.queryDate = function (time, mark) {
if (!time) return "";
var theDate = new Date(time);
var year = theDate.getFullYear();
var mm = theDate.getMonth() + 1;
......@@ -1302,7 +1281,7 @@ taxDocumentManageModule.directive('tempModule', function () {
};
$scope.checkedItemIds = [];
$scope.sniffCheckbox = function(){
$scope.sniffCheckbox = function () {
$scope.checkedItemIds.length = 0;
$("input[name='dataGridCheckBox']").each(function (index, item) {
if (item.checked) {
......@@ -1313,21 +1292,94 @@ taxDocumentManageModule.directive('tempModule', function () {
console.info($scope.checkedItemIds.join(","));
};
$scope.getMonthLastDate = function(year,month){
$scope.getMonthLastDate = function (year, month) {
year = year ? year : new Date().getFullYear();
month = month ? month : (new Date().getMonth() + 1);
var nextMoth = null;
if(month==12){
if (month == 12) {
year += 1;
nextMoth = 1;
}else{
} else {
nextMoth = month + 1;
}
var curMothLastDayObj = new Date(new Date(year,nextMoth,1).getTime() - 1000*60*60*24);
var curMothLastDayObj = new Date(new Date(year, nextMoth, 1).getTime() - 1000 * 60 * 60 * 24);
var date = curMothLastDayObj.getDate();
date = (date + "").length < 2 ? "0" + date : date;
return date;
}
};
$scope.queryOwnTime = function (target, type) {
if (!target) return "";
var result = "";
try {
if (type === "int") {
if (typeof target === "number") {
result = target;
} else {
var date = new Date(target);
var year = date.getFullYear() + "";
var mon = (date.getMonth() + 1) + "";
year = year.length < 2 ? "0" + year : year;
mon = mon.length < 2 ? "0" + mon : mon;
result = parseInt(year + "" + mon);
}
} else {
var newMark = type;
if (typeof target === "number") {
var ownTimeString = target + "";
var year = ownTimeString.substr(0, 4);
var mon = ownTimeString.substr(4, 2);
result = year + newMark + mon;
} else {
var date = new Date(target);
var year = date.getFullYear() + "";
var mon = (date.getMonth() + 1) + "";
year = year.length < 2 ? "0" + year : year;
mon = mon.length < 2 ? "0" + mon : mon;
result = year + newMark + mon;
}
}
} catch (e) {
console.info(e.message);
result = "";
}
return result;
};
$scope.resetQueryField = function () {
$scope.queryFieldModel = {};
$("#period-picker1").val("");
$("#period-picker2").val("");
$("#period-picker3").val("");
$("#period-picker4").val("");
};
}]
}
});
taxDocumentManageModule.directive('downLoadModule', function () {
return {
restrict: 'EA',
controller: ['$scope', 'taxDocumentListService', '$translate',
function ($scope, taxDocumentListService, $translate) {
$scope.downloadAttachment = function () {
var checkedIDs = [
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
// 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=',
];
$("input[name='dataGridCheckBox']").each(function (index, item) {
if (item.checked) {
var cellId = $(item).attr("data-id");
checkedIDs.push(cellId);
}
});
taxDocumentListService.downloadAllFile({
"ids":checkedIDs
});
};
}]
}
});
\ No newline at end of file
<div class="land-manage-page" watch-group temp-module>
<div class="land-manage-page" watch-group temp-module down-load-module>
<style>
ul {
margin: 0;
......@@ -344,7 +344,7 @@
<div class="TDL-query-val">
<select ng-model="queryFieldModel.fileAttr"
class="form-control radius3"
required placeholder="{{'PleaseSelected' | translate}}">
placeholder="{{'PleaseSelected' | translate}}">
<option ng-repeat="fileAttr in fileAttrOptions track by $index"
value="{{fileAttr}}">{{fileAttr}}
</option>
......@@ -360,8 +360,7 @@
<div class="TDL-query-val">
<select ng-model="queryFieldModel.fileType"
class="form-control radius3"
required placeholder="{{'PleaseSelected' | translate}}">
<option selected></option>
placeholder="{{'PleaseSelected' | translate}}">
<option ng-repeat="fileType in fileTypeOptions track by $index" value="{{fileType}}">
{{fileType}}
</option>
......@@ -424,8 +423,15 @@
<span translate="BusinessLine"></span>
</div>
<div class="TDL-query-val">
<input type="text" class="form-control radius3"
ng-model="queryFieldModel.businessLine"/>
<select ng-model="queryFieldModel.businessLine"
class="form-control radius3"
placeholder="{{'PleaseSelected' | translate}}">
<option ng-repeat="businessLine in businessLineOptions track by $index" value="{{businessLine.name}}">
{{businessLine.name}}
</option>
</select>
<!--<input type="text" class="form-control radius3"-->
<!--ng-model="queryFieldModel.businessLine"/>-->
</div>
</div>
<div class="TDL-query-block">
......@@ -779,13 +785,16 @@
</label>
<div class="col-sm-11" style="width:61.67%">
<input class="form-control"
placeholder="{{'PleaseType' | translate}}"
placeholder="{{'PleaseType'|translate}}"
ng-required="isRequired('EntityStorageLocation')"
ng-model="editFieldModel.storageArea"
/>
</div>
<div class="DTL-special-external-btn" title="{{'EntityStorageDescription' | translate}}">
<i class="fa fake-exclamatory-circle"></i>
<a href="javascript:void(0)" ng-click="openHelpPopForEntityStorage()">
<i class="fa fake-exclamatory-circle" aria-hidden="true"></i>
</a>
</div>
</div>
<div class="col-sm-6 form-group">
......@@ -807,7 +816,7 @@
{{'EntityIndex' | translate}}
</label>
<div class="col-sm-11" style="width:61.67%">
<input class="form-control" title="{{editFieldModel.storageArea}}"
<input class="form-control"
placeholder="{{'PleaseType' | translate}}"
ng-required="isRequired('EntityIndex')"
ng-model="editFieldModel.physicalIndexNumber"
......@@ -822,7 +831,7 @@
<textarea class="form-control"
placeholder="{{'PleaseType' | translate}}"
ng-required="isRequired('Remarks')"
ng-model="editFieldModel.remarks">
ng-model="editFieldModel.remark">
</textarea>
</div>
</div>
......@@ -1014,7 +1023,7 @@
</label>
<div class="col-sm-11" style="width:61.67%">
<input class="form-control"
placeholder="{{'PleaseType' | translate}}"
placeholder="{{'EntityStorageDescription'|translate}}"
ng-model="editFieldItem.storageArea"
ng-required="isRequired('EntityStorageLocation')"
/>
......
......@@ -2,54 +2,143 @@
* Created by Administrator on 2019/3/1 0001.
*/
taxDocumentManageModule.factory('taxDocumentListService',
['$q', 'apiConfig', 'jqFetch', 'apiInterceptor',
function ($q, apiConfig, jqFetch, apiInterceptor) {
['$q', 'apiConfig', 'jqFetch','apiInterceptor',
function ($q, apiConfig, jqFetch,apiInterceptor) {
'use strict';
return {
fetchMainList: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/selectList', params);
},
addNewRecord: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/add', params);
var defer = $q.defer();
window.$.ajax({
type: 'POST',
url: apiInterceptor.webApiHostUrl + '/v1/taxDoc/add',
data: params,
dataType: "json",
beforeSend: function(request) {
request.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
request.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
request.setRequestHeader("Accept", "*/*");
},
success: function(result) {
$('#busy-indicator-container').hide();
defer.resolve(result);
},
error:function(result){
$('#busy-indicator-container').hide();
defer.reject(result);
}
});
return defer.promise;
},
editRecord: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/edit', params);
$('#busy-indicator-container').show();
var defer = $q.defer();
window.$.ajax({
type: 'POST',
url: apiInterceptor.webApiHostUrl + '/v1/taxDoc/edit',
data: params,
dataType: "json",
beforeSend: function(request) {
request.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
// request.setRequestHeader("Content-Type", 'multipart/form-data; boundary=----WebKitFormBoundaryNBBkL3vAiuTDbAZP');
request.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
request.setRequestHeader("Accept", "*/*");
},
success: function(result) {
$('#busy-indicator-container').hide();
defer.resolve(result);
},
error:function(result){
$('#busy-indicator-container').hide();
defer.reject(result);
}
});
return defer.promise;
},
verifyDuplicate: function (params) {
verifyDuplicate:function(params){
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/queryWhetherData', params);
},
getFileInfoOptions: function (params) {
getFileInfoOptions:function(params){
return jqFetch.post(apiInterceptor.webApiHostUrl + '/fileTypes/query4SelectionBox', params);
},
getCompanyNameOptions: function (params) {
return jqFetch.get(apiInterceptor.webApiHostUrl + '/org/getMyOrgList', params);
getCompanyNameOptions:function(params){
return jqFetch.post(apiInterceptor.webApiHostUrl + '/org/query4SelectionBox', params);
},
delFileRecordItems: function (params) {
delFileRecordItems:function(params){
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/batchDelete', params);
},
getDocumentsAttrAndType:function(params){
return jqFetch.post(apiInterceptor.webApiHostUrl + '/fileTypes/selectList', params);
return jqFetch.post(apiInterceptor.webApiHostUrl + '/v1/fileTypes/selectList', params);
},
getBusinessList:function(params){
return jqFetch.get(apiInterceptor.webApiHostUrl + '/v1/businessunit/getlist', params);
},
downloadAllFile:function(params){
var xhr = new XMLHttpRequest();
var fileName = 'files.zip'; // 文件名称
xhr.open('POST', apiInterceptor.webApiHostUrl + "/taxDoc/downloadAllFile", true);
xhr.responseType = 'arraybuffer';
// xhr.setRequestHeader(token, 'xxxxx') ;// 请求头中的验证信息等(如果有)
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 blob = new Blob([this.response], {type: "arraybuffer"});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
/*
* IE workaround for "HTML7007: One or more blob URLs were revoked by closing
* the blob for which they were created. These URLs will no longer resolve as
* the data backing the URL has been freed."
*/
window.navigator.msSaveBlob(blob, fileName)
} else {
var URL = window.URL || window.webkitURL;
var objectUrl = URL.createObjectURL(blob);
if (fileName) {
var a = document.createElement('a');
// safari doesn't support this yet
if (typeof a.download === 'undefined') {
window.location = objectUrl
} else {
a.href = objectUrl;
a.download = fileName;
document.body.appendChild(a);
a.click();
a.remove();
}
} else {
window.location = objectUrl;
}
}
}
};
xhr.send(JSON.stringify(params));
},
readXLSX:function(params){
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/previewExcelToJson', params);
},
getBinaryData: function (url) {
getBinaryData:function(url){
var defer = $q.defer();
var oReq = new XMLHttpRequest();
oReq.onload = function (e) {
oReq.onload = function(e) {
var arraybuffer = oReq.response;
console.info("arraybuffer:", arraybuffer);
console.info("arraybuffer:",arraybuffer);
defer.resolve(arraybuffer);
};
// oReq.open("GET", 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=', true);
oReq.open("GET", url, true);
oReq.responseType = "arraybuffer";
oReq.send();
// return jqFetch.get(url,{},'arraybuffer');
return defer.promise;
}
};
}]);
\ No newline at end of file
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