//异步查询[业务类型]
function ajaxFindBizTypeList(){
if (!bizTypeFlag) {
bizTypeFlag = true;//标志已提取业务记录
$( "#loading2").css("display" , "block");
$( "#div_typeList").css("display" ,"none");
var url = "WorksheetViewById!ajaxFindBizTypeList.action" ;
var worksheetId = $("#hidden_worksheetId" ).val();
var worksheetNo = $("#hidden_worksheetNo" ).val();
try{
$.ajax({
url:url,
dataType: "html",
data: { "id":worksheetId , "no" :worksheetNo},
success: function(data, status) {
$( "#div_typeList").empty();
$( "#div_typeList").append(data);
$( "#div_typeList").css("display" ,"block");
},
error: function(xhr, desc, err) {
if(desc != null && desc!= '' && desc == 'timeout'){
alert( "查询业务类型超时,请重试..." );
} else{
alert( "查询业务类型失败,请重试..."
+ "\n失败描述: " + desc + "\n异常信息:" + err);
}
},
complete: function(){
$( "#loading2").css("display" , "none");
}
});
} catch(e){
alert(e.message);
}
}
}
//异步保存质检结果
function ajaxSaveAuditResult(){
if (!confirm("确认要保存吗?" )) {
return;
}
var url = "WorksheetViewById!ajaxSaveAuditResult.action" ;
var worksheetId = $("#hidden_worksheetId" ).val();
var auditState = $.trim($("#text_auditState" ).val());
var auditTruth = $("#text_auditTruth" ).val();
var auditImprove = $.trim($("#text_auditImprove" ).val());
var auditResult = $.trim($("#text_auditResult" ).val());
if (auditState != null && auditState != ''){
if(auditState.length > 200){
alert( "录音情况最多只能输入200个字符" );
return false;
}
}
if (auditImprove != null && auditImprove != ''){
if(auditImprove.length > 150){
alert( "改进方案&负责人最多只能输入150个字符" );
return false;
}
}
if (auditResult != null && auditResult != ''){
if(auditResult.length > 100){
alert( "修改结果&完成日期最多只能输入100个字符" );
return false;
}
}
try{
$.ajax({
url:url,
dataType: "json",
data: { "id":worksheetId,"auditState" :auditState,
"auditTruth" :auditTruth,"auditImprove":auditImprove, "auditResult":auditResult},
success: function(data, status) {
if (data != null && data != '') {
var logObj = data[data.length - 1];
var d = new Date();
d.setTime(logObj.opTime);
var dateVal = d.getFullYear()
+ "-"+(d.getMonth()>8?(d.getMonth()+1).toString():'0' + (d.getMonth()+1))
+ "-"+(d.getDate()>9?d.getDate().toString():'0' + d.getDate())
+ " "+(d.getHours()>9?d.getHours().toString(): '0' + d.getHours())
+ ":"+(d.getMinutes()>9?d.getMinutes().toString():'0' + d.getMinutes())
+ ":"+(d.getSeconds()>9?d.getSeconds().toString():'0' + d.getSeconds());
var content = "<tr class='odd'><td>"+logObj.opTypeVal+ "</td><td>"
+logObj.op.name+ "</td><td>"
+logObj.op.employeeNo+ "</td><td>"
+logObj.op.ctiAccount+ "</td><td>"
+ dateVal + "</td></tr>" ;
$( "#log2").append(content);
}
},
error: function(xhr, desc, err) {
if(desc != null && desc!= '' && desc == 'timeout' ){
alert( "保存质检结果超时,请重试..." );
} else{
alert( "保存质检结果失败,请重试..."
+ "\n失败描述: " + desc + "\n异常信息:" + err);
}
},
complete: function(){
$( "#text_auditState" ).attr("readonly", true);
$( "#text_auditResult" ).attr("readonly", true);
$( "#text_auditImprove" ).attr("readonly", true);
$( "#text_auditTruth" ).attr("disabled", true);
$( "#btn_save").attr("disabled" ,true);
$( "#btn_modify").attr("disabled" ,false);
}
});
} catch(e){
alert(e.message);
}
}
public void ajaxSaveAuditResult() {
try {
if (StringUtils.isNotBlank( id)) {
String auditState = ServletActionContext.getRequest().getParameter( "auditState");
String auditTruth = ServletActionContext.getRequest().getParameter( "auditTruth");
String auditImprove = ServletActionContext.getRequest().getParameter( "auditImprove");
String auditResult = ServletActionContext.getRequest().getParameter( "auditResult");
Worksheet auditWrk = new Worksheet();
auditWrk.setId(id);
auditWrk.setAuditImprove(auditImprove);
auditWrk.setAuditResult(auditResult);
auditWrk.setAuditState(auditState);
auditWrk.setAuditTruth(auditTruth);
orderService.updateWorksheet(auditWrk, "AUDIT", getUser());
//保存成功之后立马查询一次操作日志
//质检操作记录查询
worksheetLogList = orderService.findWorksheetLogListByWrkid(id);
String logJson = JSON. toJSONString(worksheetLogList);
ServletActionContext. getResponse().getWriter().print(logJson);
}
} catch (Exception e) {
LOGGER.error("异步保存工单质检结果失败:工单主键:[" + id+ "] " + e.getMessage() , e);
try {
ServletActionContext. getResponse().getWriter().print("异步保存工单质检结果失败:工单主键:[" + id+ "] " + e.getMessage());
} catch (IOException e1) {
e1.printStackTrace();
}
}
}