$scope.submitFile = function (){
//判断参数
var fileName = document.getElementById("file").value;
if(StringUtil.isBlank(fileName)){
toaster.pop("warning", "", "请选择文件");
return;
}
$scope.loading = true;
$scope.loadText = "正在上传中...";
$.ajaxFileUpload({
url: './question/XXXX', //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议,一般设置为false
fileElementId: 'file', //文件上传域的ID
dataType: 'json', //返回值类型 一般设置为json
success: function (data, status){ //服务器成功响应处理函数
$scope.loading = false;
if(data.header.statusCode == 'success' && !$scope.loading) {
if(StringUtil.isNotBlank(data.body) && StringUtil.isNotBlank(data.body.outPath)) {
outPath = data.body.outPath;
toaster.pop(data.header.statusCode.toLowerCase(), "", "文件上传成功,请选择题目分类");
return;
}
}else{
toaster.pop(data.header.statusCode.toLowerCase(), "", data.header.msgArray[0].desc);
return;
}
},
error: function (data, status, e){//服务器响应失败处理函数
$scope.loading = false;
toaster.pop(CommonUtil.TOASTER_WARNING, "", e);
return;
}
});
}
$scope.submitCode = function(){
if(StringUtil.isNotBlank(outPath)){
if(StringUtil.isBlank($scope.question_title)){
toaster.pop("warning", "", "请选择题目分类");
return;
}
if(StringUtil.isBlank($scope.question_category)){
toaster.pop("warning", "", "请选择题目类型");
return;
}
if($scope.question_category == "课文跟读"){//课文跟读
$scope.path = "./question/XXXX";
}else if($scope.question_category == "单词拼写"){//单词拼写
$scope.path = "./question/XXXX";
}else if($scope.question_category == "听音选词"){//听音选词
$scope.path = "./question/XXXX";
}else if($scope.question_category == "趣配音"){//趣配音
$scope.path = "./question/XXXX";
}
$scope.loading = true;
$scope.loadText = "正在上录入数据...";
$http.get($scope.path+"/?outPath="+outPath+"&title="+$scope.question_title).success(function(response) { //查找当前ID的分类信息
$scope.loading = false;
if(!$scope.loading){
if(StringUtil.isNotBlank(response.body) && StringUtil.isNotBlank(response.body.createdNum)) {
$scope.createdNum = response.body.createdNum;
}else {
$scope.createdNum = 0;
}
toaster.pop(response.header.statusCode.toLowerCase(), "", "成功录入或更新 "+$scope.createdNum+" 行数据");
$modalInstance.close(); //关闭模态框
refresh();
}
}).error(function(response) {
$scope.loading = false;
toaster.pop(response.header.statusCode.toLowerCase(), "", response.header.msgArray[0].desc);
});
}else{
toaster.pop("warning", "", "请先上传文件");
return;
}
}
$scope.cancelCodeCreate = function() { //取消
$modalInstance.dismiss('cancel');
}
}
});
}