app.controller('simImportCtrl', ['$scope', '$http', '$state', 'FileUploader', 'toaster', function ($scope, $http, $state, FileUploader, toaster) { $scope.simBrand = '' $scope.simBrandName = '请选择卡商' $scope.changeCardBrand = function ($event, value, name) { $scope.simBrand = value $scope.simBrandName = name } $scope.file = '' /***********excel上传工具*******************/ //文件提交控件 var uploader2 = $scope.uploader2 = new FileUploader({ url: '/common/upload?type=simCardImport', queueLimit: 1, //文件个数 removeAfterUpload: true //上传后删除文件 }); //注册上传事件 uploader2.onCompleteItem = function (fileItem, response, status, headers) { if (response.payload) { toaster.pop("success", "提示", "上传成功!"); $scope.file = response.payload } clearUploader2(); }; uploader2.onErrorItem = function (fileItem, response, status, headers) { toaster.pop("error", "提示", "上传失败,请重试"); clearUploader2(); }; /*恢复上传框初始状态*/ function clearUploader2() { $("#fileUpload2").val(""); uploader2.clearQueue(); uploader2.cancelAll(); } $scope.saveCardMission = function () { if (!$scope.simBrand) { toaster.pop("warning", "提示", "请选择卡商"); return } if (!$scope.file) { toaster.pop("warning", "提示", "请上传文件"); return } $http({ method: 'POST', url: '/superadmin/importSim', data: { file: $scope.file, source: $scope.simBrand } }).then(function (response) { toaster.pop("success", "提示", "保存成功!"); $state.go('app.tool.offlineTask', { searchKey: response.data.payload }); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } }]);