Commit e3456e49 authored by chase's avatar chase

merge档案管理

parent 8aed3bca
...@@ -311,16 +311,9 @@ public class TaxDocumentServiceImpl { ...@@ -311,16 +311,9 @@ public class TaxDocumentServiceImpl {
public boolean editFilesType(TaxDocument taxDocument) { public boolean editFilesType(TaxDocument taxDocument) {
try { try {
//更新上传时间和文件名称
TaxDocumentExample taxDocumentExample = new TaxDocumentExample();
taxDocumentExample.createCriteria().andFileNameEqualTo(taxDocument.getFileName());
List<TaxDocument> list = taxDocumentMapper.selectByExample(taxDocumentExample);
if (list.size() > 0) {
return false;
}
taxDocument.setUpdateTime(new Date()); taxDocument.setUpdateTime(new Date());
taxDocument.setUploadTime(new Date());
int num = taxDocumentMapper.updateByPrimaryKey(taxDocument); int num = taxDocumentMapper.updateByPrimaryKey(taxDocument);
if (num > 0) { if (num > 0) {
OperationLogTaxDocument actionEntity = buildOperationLogTaxDocument(); OperationLogTaxDocument actionEntity = buildOperationLogTaxDocument();
......
...@@ -341,7 +341,7 @@ taxDocumentManageModule.controller('taxDocumentListController', ...@@ -341,7 +341,7 @@ taxDocumentManageModule.controller('taxDocumentListController',
var row_height = $("table").find("tr").height(); var row_height = $("table").find("tr").height();
if (row_height) { if (row_height) {
return { return {
height: (row_height * 12) + "px" height:(row_height*12+18)+"px"
} }
} }
}; };
...@@ -1576,13 +1576,13 @@ taxDocumentManageModule.directive('pdfPreview', function () { ...@@ -1576,13 +1576,13 @@ taxDocumentManageModule.directive('pdfPreview', function () {
restrict: 'EA', restrict: 'EA',
controller: ['$scope','taxDocumentListService', function ($scope,taxDocumentListService) { controller: ['$scope','taxDocumentListService', function ($scope,taxDocumentListService) {
window.PDFJS.workerSrc = './bundles/pdf.worker.js'; window.PDFJS.workerSrc = './bundles/pdf.worker.js';
var canvas = document.getElementById('the-canvas'); // var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d'); // var context = canvas.getContext('2d');
var pdfCurPageIndex = 1; // var pdfCurPageIndex = 1;
var pdfSumPages = 1; // var pdfSumPages = 1;
var container = document.getElementById("pdfLayoutDialog"); var container = document.getElementById("pdfLayoutDialog");
var pdfPromise = null; // var pdfPromise = null;
var cacheUrl = null; // var cacheUrl = null;
$scope.openPdfPreviewPop_bak = function (url) { $scope.openPdfPreviewPop_bak = function (url) {
container.style.display = "block"; container.style.display = "block";
if (cacheUrl !== url) { if (cacheUrl !== url) {
...@@ -1593,37 +1593,32 @@ taxDocumentManageModule.directive('pdfPreview', function () { ...@@ -1593,37 +1593,32 @@ taxDocumentManageModule.directive('pdfPreview', function () {
renderPdf(pdf) renderPdf(pdf)
}) })
}; };
$scope.openPdfPreviewPop = function (url) { $scope.openPdfPreviewPop = function (url)
container.style.display = "block"; {
function start() { var params={path:url};
return new Promise(function (resolve, reject){ taxDocumentListService.readPDF(params).then(function (data, status, headers) {
resolve('start'); if(status===204){
}); SweetAlert.warning("没有数据可以下载");
} return;
start().then(function(data) {
console.log('result of start: ', data);
return taxDocumentListService.readPDF({path:url});
}).then(function(dataURL) {
var pdfData=null;
if(typeof dataURL =="string"){
pdfData = convertDataURIToBinary(dataURL);
} }
console.log(pdfData); container.style.display = "block";
return window.PDFJS.getDocument({data:pdfData}); var blob=data;
}).then(function(data) { var img = document.createElement('img');
pdfSumPages = data.numPages; var myBlob = new window.Blob([blob], {type: 'image/png'});
return data.getPage(pdfCurPageIndex); console.log(myBlob);
}).then(function(page){ var qrUrl = window.URL.createObjectURL(myBlob);
var scale = 1.5; img.src = qrUrl;
var viewport = page.getViewport(scale); img.onload = function () {
canvas.height = viewport.height; window.URL.revokeObjectURL(qrUrl);
canvas.width = viewport.width; $("div.busy-indicator-container").removeClass("busy-indicator-container");
var renderContext = { $(".TDL-content-container")[0].style.display="none";
canvasContext: context, $(".TDL-header")[0].style.display="none";
viewport: viewport $(".navbar-custom-top")[0].style.display="none";
container.append(img);
}; };
page.render(renderContext); },function () {
}); SweetAlert.error($translate.instant('PleaseContactAdministrator'));
})
}; };
function convertDataURIToBinary(dataURI) { //将encodeBase64解码 function convertDataURIToBinary(dataURI) { //将encodeBase64解码
var raw = window.atob(dataURI); var raw = window.atob(dataURI);
......
...@@ -306,6 +306,8 @@ ...@@ -306,6 +306,8 @@
} }
.TDL-pdf-layout-dialog { .TDL-pdf-layout-dialog {
text-align: center;
float: top;
display: none; display: none;
} }
...@@ -1462,14 +1464,10 @@ ...@@ -1462,14 +1464,10 @@
</div> </div>
</div> </div>
<div class="TDL-pdf-layout-dialog" id="pdfLayoutDialog" pdf-preview> <div class="TDL-pdf-layout-dialog" id="pdfLayoutDialog" pdf-preview>
<div class="wrapper TDL-pdf-preview-pop" id="pdfContainer"> <div id="pdfContainer" style="width:0px;height:0px;overflow: hidden;">
<canvas id="the-canvas"></canvas> <canvas id="the-canvas"></canvas>
</div> </div>
<button class="TDL-pdf-preview-pop-close-btn" ng-click="closePdfPop()">×</button>
<button class="TDL-pdf-paging-btn TDL-pdf-paging-btn-prev" ng-click="prevPaging()" title="上一页">&lt;</button>
<button class="TDL-pdf-paging-btn TDL-pdf-paging-btn-next" ng-click="nextPaging()" title="下一页">&gt;</button>
</div> </div>
<div class="modal fade" id="imgLayoutDialog" img-preview tabindex="-1" role="dialog" aria-labelledby="myModal" <div class="modal fade" id="imgLayoutDialog" img-preview tabindex="-1" role="dialog" aria-labelledby="myModal"
......
...@@ -134,7 +134,21 @@ taxDocumentManageModule.factory('taxDocumentListService', ...@@ -134,7 +134,21 @@ taxDocumentManageModule.factory('taxDocumentListService',
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/previewExcelToJson', params); return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/previewExcelToJson', params);
}, },
readPDF:function(params){ readPDF:function(params){
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/previewPDF', params); $('#busy-indicator-container').show();
var defer = $q.defer();
var xhr = new XMLHttpRequest();
xhr.onload = function(result) {
if (this.status == 200) {
var blob = this.response;
defer.resolve(blob,xhr.status,xhr.getAllResponseHeaders());
}
};
xhr.open("post", apiInterceptor.webApiHostUrl + "/taxDoc/previewPDF", true);
xhr.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
xhr.setRequestHeader("Content-Type", 'application/json;charset=UTF-8');
xhr.responseType="blob";
xhr.send(JSON.stringify(params));
return defer.promise;
}, },
getBinaryData:function(url){ getBinaryData:function(url){
var defer = $q.defer(); var defer = $q.defer();
......
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