Commit 6fec6bc8 authored by chase's avatar chase

fix bug

parent cc905c6b
...@@ -648,205 +648,205 @@ taxDocumentManageModule.directive('fileUploader', function () { ...@@ -648,205 +648,205 @@ taxDocumentManageModule.directive('fileUploader', function () {
}] }]
} }
}); });
taxDocumentManageModule.directive('multiFileUploader_bak', function () { // taxDocumentManageModule.directive('multiFileUploader_bak', function () {
restrict: "EA", // 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) { // function ($scope, FileUploader, apiInterceptor, taxDocumentListService, $translate, SweetAlert, $compile) {
var timer = null; // var timer = null;
$scope.activeTab = function (activeIndex) { // $scope.activeTab = function (activeIndex) {
$scope.editFieldModel_multi.forEach(function (item) { // $scope.editFieldModel_multi.forEach(function (item) {
item.iShow = false; // item.iShow = false;
}); // });
$scope.editFieldModel_multi[activeIndex].iShow = true; // $scope.editFieldModel_multi[activeIndex].iShow = true;
}; // };
//
$scope.openMultiUploadPop = function () { // $scope.openMultiUploadPop = function () {
timer = null; // timer = null;
$("#multiUploadFilePlugin").click(); // $("#multiUploadFilePlugin").click();
$scope.multiUploader.clearQueue(); // $scope.multiUploader.clearQueue();
$("#multiUploadFilePlugin").val(null); // $("#multiUploadFilePlugin").val(null);
$scope.editFieldModel_multi.length = 0; // $scope.editFieldModel_multi.length = 0;
// timer = setInterval(function () { // // timer = setInterval(function () {
// if ($scope.multiUploader.queue && $scope.multiUploader.queue.length > 0) { // // if ($scope.multiUploader.queue && $scope.multiUploader.queue.length > 0) {
// $("#multiUploadPopDialog").modal("show"); // // $("#multiUploadPopDialog").modal("show");
// console.log("is run times"); // // console.log("is run times");
// } // // }
// }, 500); // // }, 500);
}; // };
//
// 由于$watch无法监听$scope.multiUploader,暂时用循环来做 // // 由于$watch无法监听$scope.multiUploader,暂时用循环来做
// setInterval(function () { // // setInterval(function () {
// if ($("#multiUploadPopDialog").is(":visible")) { // // if ($("#multiUploadPopDialog").is(":visible")) {
// clearInterval(timer); // // clearInterval(timer);
// } // // }
// }, 500); // // }, 500);
//
$scope.multiUploader = new FileUploader({ // $scope.multiUploader = new FileUploader({
// url: "http://etms.longi-silicon.com:8180/api/v1/taxDoc/upload", // // url: "http://etms.longi-silicon.com:8180/api/v1/taxDoc/upload",
// autoUpload: true,//添加后,自动上传 // // autoUpload: true,//添加后,自动上传
headers: {"Authorization": apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken()}, // headers: {"Authorization": apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken()},
// removeAfterUpload: true, // // removeAfterUpload: true,
}); // });
$scope.multiUploader.filters.push({//xls限制 // $scope.multiUploader.filters.push({//xls限制
name: 'fileTypeFilter', // name: 'fileTypeFilter',
fn: function (item, options) { // fn: function (item, options) {
if (item.name.indexOf("_") === -1) { // if (item.name.indexOf("_") === -1) {
SweetAlert.warning("文件名格式不符合规则,请重新选择(正确格式必须包含'公司名称'和'档案类型',并用下划线'_'分隔)"); // SweetAlert.warning("文件名格式不符合规则,请重新选择(正确格式必须包含'公司名称'和'档案类型',并用下划线'_'分隔)");
return false; // return false;
} // }
var fileNativePath = $("#multiUploadFilePlugin")[0].value || ""; // var fileNativePath = $("#multiUploadFilePlugin")[0].value || "";
fileNativePath = fileNativePath.replace(/fakepath/img, "******"); // fileNativePath = fileNativePath.replace(/fakepath/img, "******");
fileNativePath = fileNativePath.replace(item.name, ""); // fileNativePath = fileNativePath.replace(item.name, "");
// var splitMark = /\//.test(fileNativePath) ? "/" : "\\"; // // var splitMark = /\//.test(fileNativePath) ? "/" : "\\";
// var prevPath = fileNativePath.split(splitMark); // // var prevPath = fileNativePath.split(splitMark);
// prevPath.pop(); // // prevPath.pop();
// fileNativePath = prevPath.join(splitMark) + splitMark; // // fileNativePath = prevPath.join(splitMark) + splitMark;
var thisModel = { // var thisModel = {
fileNativePath: fileNativePath, // fileNativePath: fileNativePath,
fileName: item.name, // fileName: item.name,
iShow: $scope.editFieldModel_multi.length === 0 // iShow: $scope.editFieldModel_multi.length === 0
}; // };
$scope.autoMatchAttrAndType(item.name, thisModel); // $scope.autoMatchAttrAndType(item.name, thisModel);
$scope.editFieldModel_multi.push(thisModel); // $scope.editFieldModel_multi.push(thisModel);
// 根据需求,改为不做类型限制 // // 根据需求,改为不做类型限制
return true; // return true;
} // }
}); // });
//
$scope.multiUploader.onAfterAddingFile = function (item) { // $scope.multiUploader.onAfterAddingFile = function (item) {
console.info("is added!", item); // console.info("is added!", item);
if($scope.editFieldModel_multi.length > 0){ // if($scope.editFieldModel_multi.length > 0){
$("#multiUploadPopDialog").modal("show"); // $("#multiUploadPopDialog").modal("show");
} // }
}; // };
//
$scope.multiUploadErrorItems = []; // $scope.multiUploadErrorItems = [];
$scope.multiUploader.onErrorItem = function (fileItem) { // $scope.multiUploader.onErrorItem = function (fileItem) {
$scope.multiUploadErrorItems.push(fileItem); // $scope.multiUploadErrorItems.push(fileItem);
console.info('onErrorItem', fileItem); // console.info('onErrorItem', fileItem);
}; // };
// $scope.multiUploader.onCancelItem = function(fileItem, response, status, headers) { // // $scope.multiUploader.onCancelItem = function(fileItem, response, status, headers) {
// console.info('onCancelItem', fileItem, response, status, headers); // // console.info('onCancelItem', fileItem, response, status, headers);
// }; // // };
//
$scope.multiUploadSuccessItems = []; // $scope.multiUploadSuccessItems = [];
$scope.multiUploader.onCompleteAll = function () { // $scope.multiUploader.onCompleteAll = function () {
//
$("#uploadResultPop").modal("show"); // $("#uploadResultPop").modal("show");
//
$('#multiUploadPopDialog').modal('hide'); // $('#multiUploadPopDialog').modal('hide');
//
$('#busy-indicator-container').hide(); // $('#busy-indicator-container').hide();
//
//
}; // };
//
$scope.multiUploader.onSuccessItem = function (fileItem, response) { // $scope.multiUploader.onSuccessItem = function (fileItem, response) {
// fileItem.filePositionUrl = response; // // fileItem.filePositionUrl = response;
$scope.multiUploadSuccessItems.push(fileItem); // $scope.multiUploadSuccessItems.push(fileItem);
//
$('#busy-indicator-container').show(); // $('#busy-indicator-container').show();
}; // };
//
$scope.multiUploadSubmit = function () { // $scope.multiUploadSubmit = function () {
$scope.multiUploadErrorItems = []; // $scope.multiUploadErrorItems = [];
$scope.multiUploadSuccessItems = []; // $scope.multiUploadSuccessItems = [];
//
var alertContent = verifyRequiredFields($scope.editFieldModel_multi); // var alertContent = verifyRequiredFields($scope.editFieldModel_multi);
//
if(!alertContent){ // if(!alertContent){
multiUpload(); // multiUpload();
}else{ // }else{
swal(alertContent); // swal(alertContent);
} // }
//
function verifyRequiredFields(editFieldModel_multi){ // function verifyRequiredFields(editFieldModel_multi){
//
var alertText = ""; // var alertText = "";
//
for(var i = 0; i < editFieldModel_multi.length; i++){ // for(var i = 0; i < editFieldModel_multi.length; i++){
var modelItem = editFieldModel_multi[i]; // var modelItem = editFieldModel_multi[i];
if(!modelItem.companyName){ // if(!modelItem.companyName){
alertText += "【"+$translate.instant("CompanyName")+"】" // alertText += "【"+$translate.instant("CompanyName")+"】"
} // }
if(!modelItem.fileType){ // if(!modelItem.fileType){
alertText += "【"+$translate.instant("DocumentType")+"】" // alertText += "【"+$translate.instant("DocumentType")+"】"
} // }
if(!modelItem.fileAttr){ // if(!modelItem.fileAttr){
alertText += "【"+$translate.instant("DocumentAttr")+"】" // alertText += "【"+$translate.instant("DocumentAttr")+"】"
} // }
if(!modelItem.taxType){ // if(!modelItem.taxType){
alertText += "【"+$translate.instant("DocumentType")+"】" // alertText += "【"+$translate.instant("DocumentType")+"】"
} // }
if(!modelItem.ownTime){ // if(!modelItem.ownTime){
alertText += "【"+$translate.instant("Duration")+"】" // alertText += "【"+$translate.instant("Duration")+"】"
} // }
if(!modelItem.fileTime){ // if(!modelItem.fileTime){
alertText += "【"+$translate.instant("AvailabilityDate")+"】" // alertText += "【"+$translate.instant("AvailabilityDate")+"】"
} // }
//
if(alertText.length > 0){ // if(alertText.length > 0){
alertText = "档案" + (i + 1) + "," + alertText + "为必填字段,不能为空,请检查"; // alertText = "档案" + (i + 1) + "," + alertText + "为必填字段,不能为空,请检查";
break; // break;
} // }
} // }
//
return alertText; // return alertText;
} // }
//
function multiUpload(){ // function multiUpload(){
for (var i = 0; i < $scope.multiUploader.queue.length; i++) { // for (var i = 0; i < $scope.multiUploader.queue.length; i++) {
//
// 先设置uploader队列里每个文件的请求参数:fileOriginalName // // 先设置uploader队列里每个文件的请求参数:fileOriginalName
var fileItem = $scope.multiUploader.queue[i]; // var fileItem = $scope.multiUploader.queue[i];
fileItem.formData = [{ // fileItem.formData = [{
fileOriginName: fileItem.name ? fileItem.name : fileItem._file.name // fileOriginName: fileItem.name ? fileItem.name : fileItem._file.name
}]; // }];
//
// 过滤参数格式,并把参数推进上传队列 // // 过滤参数格式,并把参数推进上传队列
var editFieldModel = $scope.editFieldModel_multi[i]; // var editFieldModel = $scope.editFieldModel_multi[i];
Object.keys(editFieldModel).forEach(function (key) { // Object.keys(editFieldModel).forEach(function (key) {
var fields = {}; // var fields = {};
var curItemValue = editFieldModel[key] ? editFieldModel[key] : ""; // var curItemValue = editFieldModel[key] ? editFieldModel[key] : "";
if (/ownTime/.test(key)) { // if (/ownTime/.test(key)) {
fields[key] = $scope.queryOwnTime(curItemValue, "int"); // fields[key] = $scope.queryOwnTime(curItemValue, "int");
} else { // } else {
if (/(createTime|updateTime|uploadTime)/.test(key)) { // if (/(createTime|updateTime|uploadTime)/.test(key)) {
fields[key] = $scope.getQueryDate(curItemValue, "/"); // fields[key] = $scope.getQueryDate(curItemValue, "/");
} else fields[key] = curItemValue; // } else fields[key] = curItemValue;
} // }
fileItem.formData.push(fields); // fileItem.formData.push(fields);
}); // });
//
//
(function (_i, _fileItem, _editFieldModel, _taxDocumentListService, _multiUploader) { // (function (_i, _fileItem, _editFieldModel, _taxDocumentListService, _multiUploader) {
//
var params = angular.copy(_editFieldModel); // var params = angular.copy(_editFieldModel);
// params.ownTime = params.ownTime ? params.ownTime : ""; // // params.ownTime = params.ownTime ? params.ownTime : "";
// params.ownTime = parseInt(_editFieldModel.ownTime.split("-").join("")); // // params.ownTime = parseInt(_editFieldModel.ownTime.split("-").join(""));
params.ownTime = $scope.queryOwnTime(params.ownTime, "int"); // params.ownTime = $scope.queryOwnTime(params.ownTime, "int");
params.fileTime = $scope.getQueryDate(params.fileTime, "-"); // params.fileTime = $scope.getQueryDate(params.fileTime, "-");
params.effectiveTime = $scope.getQueryDate(params.effectiveTime, "-"); // params.effectiveTime = $scope.getQueryDate(params.effectiveTime, "-");
_taxDocumentListService.verifyDuplicate(params).then(function (data) { // _taxDocumentListService.verifyDuplicate(params).then(function (data) {
if (data == true) { // if (data == true) {
_fileItem.url = "http://etms.longi-silicon.com:8180//api/v1/taxDoc/add"; // _fileItem.url = "http://etms.longi-silicon.com:8180//api/v1/taxDoc/add";
} else { // } else {
_fileItem.url = "http://etms.longi-silicon.com:8180//api/v1/taxDoc/edit"; // _fileItem.url = "http://etms.longi-silicon.com:8180//api/v1/taxDoc/edit";
} // }
_multiUploader.uploadItem(_i); // _multiUploader.uploadItem(_i);
}); // });
})(i, fileItem, editFieldModel, taxDocumentListService, $scope.multiUploader); // })(i, fileItem, editFieldModel, taxDocumentListService, $scope.multiUploader);
//
} // }
} // }
}; // };
//
$scope.confirmUploadResult = function () { // $scope.confirmUploadResult = function () {
$('#uploadResultPop').modal('hide'); // $('#uploadResultPop').modal('hide');
$scope.loadMainData(); // $scope.loadMainData();
}; // };
}] // }]
}); // });
taxDocumentManageModule.directive('multiFileUploader', function () { taxDocumentManageModule.directive('multiFileUploader', function () {
return { return {
restrict: "EA", restrict: "EA",
......
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