Commit 6fec6bc8 authored by chase's avatar chase

fix bug

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