No Description

addOrder.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /**
  2. * 新建工单
  3. * */
  4. $(function() {
  5. //获取 电话和姓名
  6. var tname = helper.request.queryString("tname");
  7. var ttel = helper.request.queryString("ttel");
  8. if(tname) {
  9. $('#order_name').val(decodeURI(tname)); //是 string 姓名/联系人
  10. }
  11. if(ttel) {
  12. $('#order_tel').val(ttel); //否 string 联系电话
  13. }
  14. //获取工单来源
  15. helper.getDropList.getlistDropByDic($('#order_source'), 'GDLY').then(function() {
  16. $('#order_source').selectpicker('val', '468').trigger('change');
  17. });
  18. autosize($('textarea'));
  19. //获取工单类型
  20. helper.getDropList.getOrderRadios($('#order_type'), 'GDLX', 'inlineRadioOptions').then(function() {
  21. //工单类型不同 表单内容不同
  22. $('#order_type').find('input[type="radio"]').on('change', function() {
  23. if($('#order_iseffective').find('input[type="radio"]:checked').val() === "1") { //无效
  24. $('.order_note').show();
  25. $('.order_transfer').hide();
  26. } else {
  27. $('.order_note').hide();
  28. if($(this).val() === "108") { //投诉
  29. $('.complaintOrder').show();
  30. }else{
  31. $('.complaintOrder').hide();
  32. }
  33. }
  34. });
  35. });
  36. // 区域 项目 期号三级联动
  37. helper.getDropList.getProLocations($('#order_rengin'), $('#order_pro'), $('#order_floor'));
  38. $('#order_rengin').on('change', function() {
  39. //清空房间号
  40. if($('#order_room_select')) {
  41. $('#order_room_select').empty();
  42. $('#order_room_input').show().siblings('.bootstrap-select').hide();
  43. }
  44. });
  45. $('#order_pro').on('change', function() {
  46. //清空房间号
  47. if($('#order_room_select')) {
  48. $('#order_room_select').empty();
  49. $('#order_room_input').show().siblings('.bootstrap-select').hide();
  50. }
  51. });
  52. //监听期号的改变 获取房间号 下拉或输入框
  53. $('#order_floor').on('change', getRoomNumber);
  54. //获取房主关系
  55. helper.getDropList.getlistDropByDic($('#ower_relationship'), 'FZGX');
  56. //获取客户反应
  57. helper.getDropList.getOrderRadios($('#order_response'), 'KHFY', 'inlineRadioOptions2');
  58. //工单有效性
  59. $('#order_iseffective').find('input[type="radio"]').on('change', function() {
  60. //是否有效工单项(0有效,1无效)
  61. if($(this).val() === "1") { //无效
  62. $('.order_note').show();
  63. $('.complaintOrder').hide();
  64. } else {
  65. $('.order_note').hide();
  66. if($('#order_type').find('input[type="radio"]:checked').val() === "108") { //投诉
  67. $('.complaintOrder').show();
  68. }else{
  69. $('.complaintOrder').hide();
  70. }
  71. }
  72. });
  73. //获取投诉类型
  74. // getDepts('reginsTreeView1', 'complaintOrder_type');
  75. //新增工单创建
  76. $('#save_order').on('click', orderSave);
  77. });
  78. //新建工单 保存
  79. function orderSave() {
  80. if(!regexs.userNameReg.test($.trim($('#order_name').val()))) {
  81. layer.confirm('请输入有效的客户姓名(2-20位汉字可以包含·•)!', {
  82. icon: 2,
  83. btn: ['确定']
  84. });
  85. return;
  86. }
  87. if(!regexs.phone.test($.trim($('#order_tel').val()))) {
  88. layer.confirm('请输入正确的电话!', {
  89. icon: 2,
  90. btn: ['确定']
  91. });
  92. return;
  93. }
  94. if($('#order_iseffective').find('input[type="radio"]:checked').val() === '1') {
  95. if(!$.trim($('#order_note').val())) {
  96. layer.confirm('请输入无效原因!', {
  97. icon: 2,
  98. btn: ['确定']
  99. });
  100. return;
  101. }
  102. }
  103. if($("#order_room_select").is(":hidden")) {
  104. $('#order_room').val($('#order_room_input').val()); //房间号
  105. } else {
  106. $('#order_room').val($('#order_room_select').val()); //房间号
  107. }
  108. $.post(huayi.config.callcenter_url + "CallInScreen/AddWorkOrder", {
  109. gdly: $('#order_source').val(), //否 int 工单来源
  110. gdlx: $('#order_type').find('input[type="radio"]:checked').val(), //否 int 工单类型
  111. callCustomer: $('#order_name').val(), //是 string 姓名/联系人
  112. tel: $('#order_tel').val(), //否 string 联系电话
  113. areaid: $('#order_rengin').val(), //否 int 区域
  114. proid: $('#order_pro').val(), //否 int 项目名称
  115. buildingid: $('#order_floor').val(), //否 string 期号
  116. buildingnum: $('#order_buildingnum').val(),// 否 string 楼号
  117. unitnum: $('#order_unitnum').val(),// 否 string 单元
  118. roomno: $('#order_room').val(), //否 string 房间号
  119. ownerrelationsid: $('#ower_relationship').val(), //否 int 房主关系
  120. customerresponseid: $('#order_response').find('input[type="radio"]:checked').val(), //否 int 客户反应
  121. fkcont: $('#order_reception').val(), //否 string 反馈内容 - 反馈内容
  122. // fkdep: $('#complaintOrder_type').attr('data-id'), //否 int 处理部门(投诉类型)
  123. // kfdepid: $('#serviceOrder_type').val(), //否int 客服类类型
  124. isquality: $('#is_quality_assurance').find('input[type="radio"]:checked').val(), //否 int 是,//否过质保
  125. // auditusercode: $('#order_responsible').val(), //否 string 接收人
  126. //callid: callId, //否 int 电话id
  127. iseffective: $('#order_iseffective').find('input[type="radio"]:checked').val(), // 否 int 是否有效工单项(0有效,1无效)
  128. note: $('#order_note').val(), // 无效原因 否 string 备注 (iseffective,1无效时填写备注)
  129. //clbm: $('#order_transfer_dept').attr('data-id'), // 否 int 咨询类工单指派部门id
  130. //clid: $('#order_receiveUser').val(), // 否 string 接收人id
  131. token: $.cookie("token")
  132. }, function(result) {
  133. result = $.parseJSON(result);
  134. if(result.state.toLowerCase() == "success") {
  135. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  136. parent.layer.close(index); //再执行关闭
  137. parent.$('#list').bootstrapTable('refresh');
  138. parent.layer.msg("创建工单成功");
  139. top.workcount();
  140. }
  141. })
  142. }
  143. //获取房间号 下拉或输入框
  144. function getRoomNumber() {
  145. if($('#order_floor').val() != "0") {
  146. $('#order_tel').off('blur', getRoomNumber);
  147. $('#order_tel').on('blur', getRoomNumber);
  148. if(!regexs.phone.test($.trim($('#order_tel').val()))) {
  149. layer.confirm('请输入正确的电话!', {
  150. icon: 2,
  151. btn: ['确定']
  152. });
  153. return;
  154. }
  155. $.ajax({
  156. url: huayi.config.callcenter_url + 'Customer/GetCustomerListByTel',
  157. type: 'get',
  158. data: {
  159. tel: $('#order_tel').val(), //否 string 来电电话 例如:13663801989
  160. areaid: $('#order_rengin').val(), //否 int 区域id
  161. categoryid: $('#order_pro').val(), //否 int 所购项目id
  162. buldingid: $('#order_floor').val(), //否 int 期号
  163. token: $.cookie("token")
  164. },
  165. dataType: "json",
  166. async: true,
  167. success: function(res) {
  168. if(res.state.toLowerCase() === "success") {
  169. res = res.rows;
  170. if(res && res.length >= 1) {
  171. $('#order_room_select').empty();
  172. res.forEach(function(v, i) {
  173. if(v.F_BusinessLicenseID != null) {
  174. $('#order_room_select').append('<option value="' + v.F_BusinessLicenseID + '">' + v.F_BusinessLicenseID + '</option>')
  175. }
  176. });
  177. $('#order_room_select').selectpicker('refresh');
  178. $('#order_room_input').hide().siblings('.bootstrap-select').css('display', 'inline-block');
  179. } else {
  180. $('#order_room_input').show().siblings('.bootstrap-select').hide();
  181. }
  182. }
  183. },
  184. });
  185. }
  186. }
  187. /**
  188. * 获取接收人下拉
  189. * obj 接收人的el
  190. * ctidval 部门id
  191. * */
  192. function getOrderResponsible(ctidval) {
  193. var dtd = $.Deferred();
  194. if($('#order_transfer_dept').val()) {
  195. if($('#order_rengin').val() === '0' && $('#order_pro').val() === '0') {
  196. layer.confirm('您还没有选择区域和项目,请先选择区域和项目。', {
  197. icon: 7,
  198. btn: ['确定']
  199. });
  200. return;
  201. }
  202. if($('#order_rengin').val() != '0' && $('#order_pro').val() === '0') {
  203. layer.confirm('请选择项目。', {
  204. icon: 7,
  205. btn: ['确定']
  206. });
  207. return;
  208. }
  209. }
  210. $.ajax({
  211. url: huayi.config.callcenter_url + 'CallInScreen/GetUserListByBuildingidDrop',
  212. type: 'get',
  213. data: {
  214. depid: ctidval, // 否 string 部门id
  215. arearid: $('#order_rengin').val(), // 否 string 区域id
  216. proid: $('#order_pro').val(), // 是 string 姓名/项目id
  217. buildingid: $('#order_floor').val(), // 否 string 期号id
  218. token: $.cookie("token")
  219. },
  220. dataType: "json",
  221. async: true,
  222. success: function(res) {
  223. $('#order_responsible').empty();
  224. if(res.state.toLowerCase() === "success") {
  225. res = res.data;
  226. if(res && res.length > 0) {
  227. $('#order_responsible').append('<option value="0">请选择接收人</option>')
  228. res.forEach(function(v, i) {
  229. $('#order_responsible').append('<option value="' + v.F_UserCode + '">' + v.F_UserName + '(' + v.F_UserCode + ')</option>');
  230. });
  231. $('#order_responsible').selectpicker('refresh');
  232. }
  233. }
  234. dtd.resolve();
  235. },
  236. });
  237. return dtd.promise();
  238. }
  239. /**
  240. * 获取接收部门 获取投诉类型
  241. * el1, 树形结构元素id名 reginsTreeView
  242. * el2, 搜索框元素id名 order_transfer_dept
  243. * */
  244. function getDepts(el1, el2) {
  245. //初始化 样式
  246. $('#' + el2).on('focus click', function() {
  247. $('#' + el1).removeClass('hidden').addClass('show');
  248. });
  249. $('#' + el2).on('keyup', function() {
  250. if($(this).val() == '') {
  251. $('#' + el1).treeview('uncheckAll', {
  252. silent: true
  253. });
  254. $(this).attr('data-id', '0');
  255. }
  256. });
  257. $('#' + el2 + ' .caret').on('click', function() {
  258. $('#' + el1).removeClass('hidden').addClass('show');
  259. });
  260. $('#' + el1).mouseleave(function() {
  261. $(this).removeClass('show').addClass('hidden');
  262. });
  263. $.getJSON(huayi.config.callcenter_url + 'Department/GetDeptList', {
  264. token: $.cookie("token")
  265. }, function(result) {
  266. if(result.state.toLowerCase() == "success") {
  267. var defaultDatas = helper.methods.buildTree(result.data);
  268. var sortChildrenArr = helper.methods.objToArray(defaultDatas[0].children);
  269. sortChildrenArr.sort(helper.methods.compare('sort'));
  270. var sortChildrenObj = helper.methods.arrayToObj(sortChildrenArr);
  271. defaultDatas[0].children = sortChildrenObj;
  272. if(defaultDatas) {
  273. var $sTree = $('#' + el1).treeview({
  274. color: "#1ab394",
  275. selectedBackColor: '#1ab394',
  276. expandIcon: 'glyphicon glyphicon-chevron-right',
  277. collapseIcon: 'glyphicon glyphicon-chevron-down',
  278. nodeIcon: 'fa fa-folder-o',
  279. //selectedIcon: "glyphicon glyphicon-stop",
  280. //icon: "glyphicon glyphicon-stop",
  281. //emptyIcon: 'glyphicon',
  282. //showCheckbox: true,
  283. selectable: true,
  284. state: {
  285. selected: true
  286. },
  287. data: defaultDatas,
  288. onNodeSelected: function(event, node) {
  289. $sTree.treeview('clearSearch');
  290. $('#' + el2).val(node.text);
  291. $('#' + el2).attr('data-id', node.id);
  292. $('#' + el1).removeClass('show').addClass('hidden');
  293. if(el1 === 'reginsTreeView'){
  294. //获取接收人员
  295. getReceiveUser($('#order_receiveUser'), node.id);
  296. }else{
  297. if(node.id === 561) { //工程类
  298. $('.is_quality_assurance').show();
  299. } else {
  300. $('.is_quality_assurance').hide();
  301. }
  302. //获取接收人下拉
  303. getOrderResponsible(node.id);
  304. }
  305. },
  306. onNodeUnselected: function(event, node) {
  307. if(el1 === 'reginsTreeView'){
  308. $('#' + el2).attr('data-id', 0);
  309. $('#' + el2).attr('placeholder', '请选择接收部门');
  310. $('#order_receiveUser').empty();
  311. $('#order_receiveUser').append('<option value="0">请选择接收人</option>');
  312. $('#order_receiveUser').selectpicker('refresh');
  313. }else{
  314. $('#complaintOrder_type').attr('placeholder', '请选择投诉类型');
  315. $('#complaintOrder_type').attr('data-id', 0);
  316. $('#order_responsible').empty();
  317. $('#order_responsible').append('<option value="0">请选择接收人</option>');
  318. $('#order_responsible').selectpicker('refresh');
  319. }
  320. }
  321. });
  322. // $('#' + el1).treeview('collapseAll', {
  323. // silent: true
  324. // });
  325. $('#' + el1).treeview('expandAll', { levels: 2, silent: true });
  326. var findSNodes = function() {
  327. return $sTree.treeview('search', [$('#' + el2).val(), {
  328. ignoreCase: false,
  329. exactMatch: false
  330. }]);
  331. };
  332. $('#' + el2).on('keyup focus', function(e) {
  333. var selectableNodes = findSNodes();
  334. //var m = $('#' + el1).treeview('getParent', selectableNodes);
  335. //$('#' + el1).treeview('selectNode', [ m, { silent: true } ]);
  336. });
  337. }
  338. }
  339. })
  340. }