var id = helper.request.queryString("id"); var type = helper.request.queryString("type"); $(document).ready(function () { if (type === "1") { // 获取部门 getDepartment($("#customer_department")); // 获取提交人 $('#customer_department').on('change',function(){ getManager($('#customer_submitter')); }); //修改文本 $(".submitterTitle").text("提交人:"); $(".contentTitle").text("提交内容:") $(".comaddressSelect").css("width", "35%"); $(".submitterSelect").css("width", "35%") $(".wrapper-content").css("padding","3% 8% 0 0") } else if (type === "2"){ getSalesman($('#customer_submitter')); $(".comaddressTitle").hide(); $(".comaddressSelect").hide(); //修改文本 $(".submitterTitle").text("分派人:"); $(".contentTitle").text("分派内容:") $(".submitterSelect").css("width", "80%"); $(".wrapper-content").css("padding","3% 10% 0 0") } //保存 $('.customerSubmit').click(function() { saveCustomer(); }); }) //办事处 提交人 function getDepartment(obj) { obj.empty(); obj.append(''); $.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", { "token": $.cookie("token"), pid: 1, F_Layer: 1, }, function (data) { if (data.state.toLowerCase() == "success") { var content = data.data; $(content).each(function (i, n) { $("").appendTo(obj); }) } }) } //部门 //function getDepartment(obj) { // obj.empty(); // obj.append(''); // $.getJSON(huayi.config.callcenter_url + "Department/GetSubordinate", { // "token": $.cookie("token"), // }, function (data) { // if (data.state.toLowerCase() == "success") { // var content = data.data[0].children; // $(content).each(function (i, n) { // $("").appendTo(obj); // }) // } // }) //} //业务员 function getSalesman(obj) { obj.empty(); obj.append(''); $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", { "token": $.cookie("token"), type: 2, dptid: $("#customer_department").val(), pagesize: 100, }, function (data) { var content = data.rows; $(content).each(function (i, n) { $("").appendTo(obj); }) }) } //获取经理 function getManager(obj) { obj.empty(); obj.append(''); $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", { "token": $.cookie("token"), type: 1, dptid: $("#customer_department").val(), pagesize: 100, }, function (data) { var content = data.rows; $(content).each(function (i, n) { $("").appendTo(obj); }) }) } //保存 function saveCustomer() { $.ajax({ type: "post", url: huayi.config.callcenter_url + "WorkOrder/Submission", dataType: 'json', async: true, beforeSend: function() { //触发ajax请求开始时执行 $('.customerSubmit').attr("disabled", true); $('.customerSubmit').text('保存中...'); }, data: { token: $.cookie("token"), id: id, cont: $('#cont').val(), //提交内容 clid: $('#customer_submitter').val(), // 提交人 type: type, }, 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'); } else { $('.customerSubmit').attr("disabled", false); $('.customerSubmit').text('确定'); } } }); }