| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- var id = helper.request.queryString("id");
- var type = helper.request.queryString("type");
- $(document).ready(function () {
- // 获取部门
- getDepartment($("#customer_department"));
- //保存
- $('.customerSubmit').click(function() {
- saveCustomer();
- });
-
- })
- //办事处 提交人
- function getDepartment(obj) {
- obj.empty();
- obj.append('<option selected="selected" value="">请选择</option>');
- $.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) {
- $("<option value='" + n.F_DeptId + "'>" + n.F_DeptName + "</option>").appendTo(obj);
- })
- }
- })
- }
- //部门
- //function getDepartment(obj) {
- // obj.empty();
- // obj.append('<option selected="selected" value="">请选择</option>');
- // $.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) {
- // $("<option value='" + n.id + "'>" + n.text + "</option>").appendTo(obj);
- // })
- // }
- // })
- //}
- //业务员
- function getSalesman(obj) {
- obj.empty();
- obj.append('<option selected="selected" value="" deptId="">请选择</option>');
- $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
- "token": $.cookie("token"),
- type: 2,
- dptid: $("#customer_department").val(),
- }, function (data) {
- var content = data.rows;
- $(content).each(function (i, n) {
- $("<option value='" + n.F_UserId + "'deptId='" + n.F_DeptId + "'>" + n.F_UserName + "</option>").appendTo(obj);
- })
- })
- }
- //获取经理
- function getManager(obj) {
- obj.empty();
- obj.append('<option selected="selected" value="" deptId="">请选择</option>');
- $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
- "token": $.cookie("token"),
- type: 1,
- dptid: $("#customer_department").val(),
- }, function (data) {
- var content = data.rows;
- $(content).each(function (i, n) {
- $("<option value='" + n.F_UserId + "'deptId='" + n.F_DeptId + "'>" + n.F_UserName + "</option>").appendTo(obj);
- })
- })
- }
- // 获取提交人
- $('#customer_department').on('change',function(){
- console.log('type',type,typeof(type))
- if (type === "1") {
- getManager($('#customer_submitter'));
- } else if (type === "2") {
- getSalesman($('#customer_submitter'));
- }
- });
- //保存
- 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');
- parent.initTable();
- } else {
- $('.customerSubmit').attr("disabled", false);
- $('.customerSubmit').text('确定');
- }
- }
- });
- }
|