| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- /**
- * 新建工单
- * */
- $(function() {
- //获取 电话和姓名
- var tname = helper.request.queryString("tname");
- var ttel = helper.request.queryString("ttel");
-
- if(tname) {
- $('#order_name').val(decodeURI(tname)); //是 string 姓名/联系人
- }
- if(ttel) {
- $('#order_tel').val(ttel); //否 string 联系电话
- }
-
-
- //获取工单来源
- helper.getDropList.getlistDropByDic($('#order_source'), 'GDLY').then(function() {
- $('#order_source').selectpicker('val', '468').trigger('change');
- });
- autosize($('textarea'));
- //获取工单类型
- helper.getDropList.getOrderRadios($('#order_type'), 'GDLX', 'inlineRadioOptions').then(function() {
- //工单类型不同 表单内容不同
- $('#order_type').find('input[type="radio"]').on('change', function() {
- if($('#order_iseffective').find('input[type="radio"]:checked').val() === "1") { //无效
- $('.order_note').show();
- $('.order_transfer').hide();
- } else {
- $('.order_note').hide();
- if($(this).val() === "108") { //投诉
- $('.complaintOrder').show();
- }else{
- $('.complaintOrder').hide();
- }
- }
- });
- });
- // 区域 项目 期号三级联动
- helper.getDropList.getProLocations($('#order_rengin'), $('#order_pro'), $('#order_floor'));
- $('#order_rengin').on('change', function() {
- //清空房间号
- if($('#order_room_select')) {
- $('#order_room_select').empty();
- $('#order_room_input').show().siblings('.bootstrap-select').hide();
- }
- });
- $('#order_pro').on('change', function() {
- //清空房间号
- if($('#order_room_select')) {
- $('#order_room_select').empty();
- $('#order_room_input').show().siblings('.bootstrap-select').hide();
- }
- });
- //监听期号的改变 获取房间号 下拉或输入框
- $('#order_floor').on('change', getRoomNumber);
- //获取房主关系
- helper.getDropList.getlistDropByDic($('#ower_relationship'), 'FZGX');
- //获取客户反应
- helper.getDropList.getOrderRadios($('#order_response'), 'KHFY', 'inlineRadioOptions2');
-
- //工单有效性
- $('#order_iseffective').find('input[type="radio"]').on('change', function() {
- //是否有效工单项(0有效,1无效)
- if($(this).val() === "1") { //无效
- $('.order_note').show();
- $('.complaintOrder').hide();
- } else {
- $('.order_note').hide();
- if($('#order_type').find('input[type="radio"]:checked').val() === "108") { //投诉
- $('.complaintOrder').show();
- }else{
- $('.complaintOrder').hide();
- }
- }
- });
- //获取投诉类型
- // getDepts('reginsTreeView1', 'complaintOrder_type');
- //新增工单创建
- $('#save_order').on('click', orderSave);
- });
- //新建工单 保存
- function orderSave() {
- if(!regexs.userNameReg.test($.trim($('#order_name').val()))) {
- layer.confirm('请输入有效的客户姓名(2-20位汉字可以包含·•)!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
-
- if(!regexs.phone.test($.trim($('#order_tel').val()))) {
- layer.confirm('请输入正确的电话!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
- if($('#order_iseffective').find('input[type="radio"]:checked').val() === '1') {
- if(!$.trim($('#order_note').val())) {
- layer.confirm('请输入无效原因!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
- }
- if($("#order_room_select").is(":hidden")) {
- $('#order_room').val($('#order_room_input').val()); //房间号
- } else {
- $('#order_room').val($('#order_room_select').val()); //房间号
- }
- $.post(huayi.config.callcenter_url + "CallInScreen/AddWorkOrder", {
- gdly: $('#order_source').val(), //否 int 工单来源
- gdlx: $('#order_type').find('input[type="radio"]:checked').val(), //否 int 工单类型
- callCustomer: $('#order_name').val(), //是 string 姓名/联系人
- tel: $('#order_tel').val(), //否 string 联系电话
- areaid: $('#order_rengin').val(), //否 int 区域
- proid: $('#order_pro').val(), //否 int 项目名称
- buildingid: $('#order_floor').val(), //否 string 期号
- buildingnum: $('#order_buildingnum').val(),// 否 string 楼号
- unitnum: $('#order_unitnum').val(),// 否 string 单元
- roomno: $('#order_room').val(), //否 string 房间号
- ownerrelationsid: $('#ower_relationship').val(), //否 int 房主关系
- customerresponseid: $('#order_response').find('input[type="radio"]:checked').val(), //否 int 客户反应
- fkcont: $('#order_reception').val(), //否 string 反馈内容 - 反馈内容
- // fkdep: $('#complaintOrder_type').attr('data-id'), //否 int 处理部门(投诉类型)
- // kfdepid: $('#serviceOrder_type').val(), //否int 客服类类型
- isquality: $('#is_quality_assurance').find('input[type="radio"]:checked').val(), //否 int 是,//否过质保
- // auditusercode: $('#order_responsible').val(), //否 string 接收人
- //callid: callId, //否 int 电话id
- iseffective: $('#order_iseffective').find('input[type="radio"]:checked').val(), // 否 int 是否有效工单项(0有效,1无效)
- note: $('#order_note').val(), // 无效原因 否 string 备注 (iseffective,1无效时填写备注)
- //clbm: $('#order_transfer_dept').attr('data-id'), // 否 int 咨询类工单指派部门id
- //clid: $('#order_receiveUser').val(), // 否 string 接收人id
- token: $.cookie("token")
- }, function(result) {
- result = $.parseJSON(result);
- if(result.state.toLowerCase() == "success") {
- var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
- parent.layer.close(index); //再执行关闭
- parent.$('#list').bootstrapTable('refresh');
- parent.layer.msg("创建工单成功");
- top.workcount();
- }
- })
- }
- //获取房间号 下拉或输入框
- function getRoomNumber() {
- if($('#order_floor').val() != "0") {
- $('#order_tel').off('blur', getRoomNumber);
- $('#order_tel').on('blur', getRoomNumber);
- if(!regexs.phone.test($.trim($('#order_tel').val()))) {
- layer.confirm('请输入正确的电话!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
- $.ajax({
- url: huayi.config.callcenter_url + 'Customer/GetCustomerListByTel',
- type: 'get',
- data: {
- tel: $('#order_tel').val(), //否 string 来电电话 例如:13663801989
- areaid: $('#order_rengin').val(), //否 int 区域id
- categoryid: $('#order_pro').val(), //否 int 所购项目id
- buldingid: $('#order_floor').val(), //否 int 期号
- token: $.cookie("token")
- },
- dataType: "json",
- async: true,
- success: function(res) {
- if(res.state.toLowerCase() === "success") {
- res = res.rows;
- if(res && res.length >= 1) {
- $('#order_room_select').empty();
- res.forEach(function(v, i) {
- if(v.F_BusinessLicenseID != null) {
- $('#order_room_select').append('<option value="' + v.F_BusinessLicenseID + '">' + v.F_BusinessLicenseID + '</option>')
- }
- });
- $('#order_room_select').selectpicker('refresh');
- $('#order_room_input').hide().siblings('.bootstrap-select').css('display', 'inline-block');
- } else {
- $('#order_room_input').show().siblings('.bootstrap-select').hide();
- }
- }
- },
- });
- }
- }
- /**
- * 获取接收人下拉
- * obj 接收人的el
- * ctidval 部门id
- * */
- function getOrderResponsible(ctidval) {
- var dtd = $.Deferred();
- if($('#order_transfer_dept').val()) {
- if($('#order_rengin').val() === '0' && $('#order_pro').val() === '0') {
- layer.confirm('您还没有选择区域和项目,请先选择区域和项目。', {
- icon: 7,
- btn: ['确定']
- });
- return;
- }
- if($('#order_rengin').val() != '0' && $('#order_pro').val() === '0') {
- layer.confirm('请选择项目。', {
- icon: 7,
- btn: ['确定']
- });
- return;
- }
- }
- $.ajax({
- url: huayi.config.callcenter_url + 'CallInScreen/GetUserListByBuildingidDrop',
- type: 'get',
- data: {
- depid: ctidval, // 否 string 部门id
- arearid: $('#order_rengin').val(), // 否 string 区域id
- proid: $('#order_pro').val(), // 是 string 姓名/项目id
- buildingid: $('#order_floor').val(), // 否 string 期号id
- token: $.cookie("token")
- },
- dataType: "json",
- async: true,
- success: function(res) {
- $('#order_responsible').empty();
- if(res.state.toLowerCase() === "success") {
- res = res.data;
- if(res && res.length > 0) {
- $('#order_responsible').append('<option value="0">请选择接收人</option>')
- res.forEach(function(v, i) {
- $('#order_responsible').append('<option value="' + v.F_UserCode + '">' + v.F_UserName + '(' + v.F_UserCode + ')</option>');
- });
- $('#order_responsible').selectpicker('refresh');
- }
- }
- dtd.resolve();
- },
- });
- return dtd.promise();
- }
- /**
- * 获取接收部门 获取投诉类型
- * el1, 树形结构元素id名 reginsTreeView
- * el2, 搜索框元素id名 order_transfer_dept
- * */
- function getDepts(el1, el2) {
- //初始化 样式
- $('#' + el2).on('focus click', function() {
- $('#' + el1).removeClass('hidden').addClass('show');
- });
- $('#' + el2).on('keyup', function() {
- if($(this).val() == '') {
- $('#' + el1).treeview('uncheckAll', {
- silent: true
- });
- $(this).attr('data-id', '0');
- }
- });
- $('#' + el2 + ' .caret').on('click', function() {
- $('#' + el1).removeClass('hidden').addClass('show');
- });
- $('#' + el1).mouseleave(function() {
- $(this).removeClass('show').addClass('hidden');
- });
-
- $.getJSON(huayi.config.callcenter_url + 'Department/GetDeptList', {
- token: $.cookie("token")
- }, function(result) {
- if(result.state.toLowerCase() == "success") {
- var defaultDatas = helper.methods.buildTree(result.data);
- var sortChildrenArr = helper.methods.objToArray(defaultDatas[0].children);
- sortChildrenArr.sort(helper.methods.compare('sort'));
- var sortChildrenObj = helper.methods.arrayToObj(sortChildrenArr);
- defaultDatas[0].children = sortChildrenObj;
- if(defaultDatas) {
- var $sTree = $('#' + el1).treeview({
- color: "#1ab394",
- selectedBackColor: '#1ab394',
- expandIcon: 'glyphicon glyphicon-chevron-right',
- collapseIcon: 'glyphicon glyphicon-chevron-down',
- nodeIcon: 'fa fa-folder-o',
- //selectedIcon: "glyphicon glyphicon-stop",
- //icon: "glyphicon glyphicon-stop",
- //emptyIcon: 'glyphicon',
- //showCheckbox: true,
- selectable: true,
- state: {
- selected: true
- },
- data: defaultDatas,
- onNodeSelected: function(event, node) {
- $sTree.treeview('clearSearch');
- $('#' + el2).val(node.text);
- $('#' + el2).attr('data-id', node.id);
- $('#' + el1).removeClass('show').addClass('hidden');
-
- if(el1 === 'reginsTreeView'){
- //获取接收人员
- getReceiveUser($('#order_receiveUser'), node.id);
- }else{
- if(node.id === 561) { //工程类
- $('.is_quality_assurance').show();
- } else {
- $('.is_quality_assurance').hide();
- }
- //获取接收人下拉
- getOrderResponsible(node.id);
- }
- },
- onNodeUnselected: function(event, node) {
- if(el1 === 'reginsTreeView'){
- $('#' + el2).attr('data-id', 0);
- $('#' + el2).attr('placeholder', '请选择接收部门');
- $('#order_receiveUser').empty();
- $('#order_receiveUser').append('<option value="0">请选择接收人</option>');
- $('#order_receiveUser').selectpicker('refresh');
- }else{
- $('#complaintOrder_type').attr('placeholder', '请选择投诉类型');
- $('#complaintOrder_type').attr('data-id', 0);
- $('#order_responsible').empty();
- $('#order_responsible').append('<option value="0">请选择接收人</option>');
- $('#order_responsible').selectpicker('refresh');
- }
- }
- });
- // $('#' + el1).treeview('collapseAll', {
- // silent: true
- // });
- $('#' + el1).treeview('expandAll', { levels: 2, silent: true });
- var findSNodes = function() {
- return $sTree.treeview('search', [$('#' + el2).val(), {
- ignoreCase: false,
- exactMatch: false
- }]);
- };
- $('#' + el2).on('keyup focus', function(e) {
- var selectableNodes = findSNodes();
- //var m = $('#' + el1).treeview('getParent', selectableNodes);
- //$('#' + el1).treeview('selectNode', [ m, { silent: true } ]);
- });
- }
- }
- })
- }
|