var id = helper.request.queryString("id");
$(document).ready(function () {
//获取工单详情
getWorkOrderdetails();
//保存
$('.customerSubmit').click(function() {
saveCustomer();
});
//重要级别
getDealTimely();
//普通工单禁止选择原因
$('#reason').attr("disabled", "disabled");
})
// 重要级别
function getDealTimely() {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "GDDJ"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#dealTimely"));
})
}
});
}
// 重要级别原因(Ⅰ级)
function getReasonOne() {
$("#reason").empty();
$("#reason").append("");
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "YJYY"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#reason"));
})
}
});
}
// 重要级别原因(Ⅱ级)
function getReasonTwo() {
$("#reason").empty();
$("#reason").append("");
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "EJYY"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#reason"));
})
}
});
}
// 重要级别显示原因
$('#dealTimely').on('change',function(){
if ($('#dealTimely').val() === 'Ⅰ级'){
$('#reason').val('');
$('#reason').removeAttr("disabled");
getReasonOne();
} else if ($('#dealTimely').val() === 'Ⅱ级' ){
$('#reason').val('');
$('#reason').removeAttr("disabled");
getReasonTwo();
} else {
$('#reason').val('');
$('#reason').attr("disabled", "disabled");
}
})
//获取工单详情
function getWorkOrderdetails() {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "WorkOrder/GetDetails",
dataType: 'json',
async: true,
cache: false,
data: {
id: id,
token: $.cookie("token")
},
success: function(result) {
if (result.rows.length > 0) {
var data = result.rows[0];
// 重要级别
$("#dealTimely option:selected").text(data.F_DealTimely);
$("#dealTimely option:selected").val(data.F_DealTimely);
// 重要级别原因
$("#reason option:selected").text(data.F_Reason);
$("#reason option:selected").val(data.F_Reason);
}
}
});
}
//保存
function saveCustomer() {
$.ajax({
type: "post",
url: huayi.config.callcenter_url + "WorkOrder/Sing",
dataType: 'json',
async: true,
beforeSend: function() { //触发ajax请求开始时执行
$('.customerSubmit').attr("disabled", true);
$('.customerSubmit').text('确定中...');
},
data: {
token: $.cookie("token"),
id: id,
dealTimely: $('#dealTimely').val(), //重要级别内容
reason: $('#reason').val(), //重要级别原因
},
success: function(data) {
if (data.state.toLowerCase() == 'success') {
$('.customerSubmit').attr("disabled", false);
$('.customerSubmit').text('确定');
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
parent.layer.msg("保存成功!");
// parent.$('#workorderlist').bootstrapTable('refresh');
parent.initTable();
} else {
$('.customerSubmit').attr("disabled", false);
$('.customerSubmit').text('确定');
}
}
});
}