郑州颐和随访系统UI

AddWorkOrder.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /**
  2. * 新增或编辑工单
  3. * */
  4. //通话记录跳转过来的
  5. var callId = helper.request.queryString("cid");
  6. $(function() {
  7. //通话记录跳转过来的
  8. var cphone = helper.request.queryString("cphone");
  9. var cCustomerName = decodeURIComponent(helper.request.queryString("cCustomerName"));
  10. if(cphone) {
  11. $('#order_tel').val(cphone); //否 string 联系电话
  12. }
  13. if(cCustomerName) {
  14. $('#order_name').val(cCustomerName); //是 string 姓名/联系人
  15. }
  16. autosize($('textarea'));
  17. //获取工单来源
  18. helper.getDropList.getlistDropByDic($('#order_source'), 'GDLY').then(function() {
  19. $('#order_source').selectpicker('val', '468').trigger('change');
  20. });
  21. //获取业务办理
  22. helper.getDropList.getlistDropByDic($('#order_handle'), 'YWLX');
  23. //获取工单类型
  24. helper.getDropList.getOrderRadios($('#order_'), 'GDLX', 'inlineRadioOptions').then(function() {
  25. $('#order_').find('input[type="radio"]').on('change', function() {
  26. if($(this).val() === "107") { // 业务办理
  27. $('#order_handles').show();
  28. }else{
  29. $('#order_handles').hide();
  30. }
  31. });
  32. });
  33. $('#order_type').find('input[type="radio"]').on('change', function() {
  34. if($(this).val() === "1") { //业务办理 dispatch
  35. $('#order_pointment').hide();
  36. $('#Tousik').hide();
  37. $('#Tojon').hide();
  38. $("#insurance").hide();
  39. $("#dispatch").hide();
  40. $("#zhujkeshi").hide();
  41. $("#yukshi").hide();
  42. $("#yusjian").hide();
  43. $("#yubzhu").hide();
  44. $("#tration").hide();
  45. }else if($(this).val() === "2"){
  46. $('#order_pointment').show();
  47. $('#Tousik').hide();
  48. $('#Tojon').hide();
  49. $("#insurance").hide();
  50. $("#dispatch").hide();
  51. $("#zhujkeshi").hide();
  52. $("#yukshi").hide();
  53. $("#yusjian").hide();
  54. $("#yubzhu").hide();
  55. $("#tration").hide();
  56. }else if($(this).val() === "3"){
  57. $('#order_pointment').hide();
  58. $('#Tousik').show();
  59. $('#Tojon').show();
  60. $("#dispatch").hide();
  61. $("#insurance").hide();
  62. $("#zhujkeshi").show(); //tration insurance yubzhu
  63. $("#yukshi").hide();
  64. $("#yusjian").hide();
  65. $("#yubzhu").show();
  66. $("#tration").hide();
  67. }else if($(this).val() === "4"){
  68. $('#order_pointment').hide();
  69. $('#Tousik').hide();
  70. $('#Tojon').show();
  71. $("#insurance").hide();
  72. $("#dispatch").hide();
  73. $("#zhujkeshi").hide();
  74. $("#yukshi").hide();
  75. $("#yusjian").hide();
  76. $("#yubzhu").show();
  77. $("#tration").hide();
  78. }
  79. });
  80. // });
  81. //预约类别 显示内容
  82. $("#order_category").change(function(){
  83. if($("#order_category").find("option:selected").val()=="预约挂号"){
  84. $("#tration").show();
  85. $("#insurance").hide();
  86. $("#bunk").hide();
  87. $("#dispatch").hide();
  88. $("#yukshi").show();
  89. $("#yusjian").show();
  90. $("#yubzhu").show();
  91. $("#zhujkeshi").hide();
  92. }else if($("#order_category").find("option:selected").text()=="预约检查"){
  93. $("#tration").hide();
  94. $("#insurance").show();
  95. $("#bunk").hide();
  96. $("#dispatch").hide();
  97. $("#zhujkeshi").show();
  98. $("#yukshi").hide();
  99. $("#yusjian").hide();
  100. $("#yubzhu").show();
  101. }else if($("#order_category").find("option:selected").text()=="预约床位"){
  102. $("#tration").hide(); //bunk dispatch zhujkeshi
  103. $("#insurance").hide();
  104. $("#bunk").show();
  105. $("#dispatch").hide();
  106. $("#yukshi").show();
  107. $("#yusjian").hide();
  108. $("#yubzhu").show();
  109. $("#zhujkeshi").show();
  110. }else if($("#order_category").find("option:selected").text()=="预约车辆"){
  111. $("#tration").hide();
  112. $("#insurance").hide();
  113. $("#bunk").hide();
  114. $("#dispatch").show();
  115. $("#yukshi").show();
  116. $("#yusjian").hide();
  117. $("#yubzhu").show();
  118. $("#zhujkeshi").hide();
  119. }
  120. })
  121. //工单有效性
  122. $('#order_iseffective').find('input[type="radio"]').on('change', function() {
  123. //是否有效工单项(0有效,1无效)
  124. if($(this).val() === "1") { //无效
  125. $('.order_note').show();
  126. $('#order_isover_box').hide();
  127. $('#order_isover').find('input[type="radio"][value="1"]').prop('checked', true).trigger('change');
  128. } else {
  129. $('.order_note').hide();
  130. $('#order_isover_box').show();
  131. $('#order_isover').find('input[type="radio"][value="0"]').prop('checked', true).trigger('change');
  132. }
  133. });
  134. //立即处理
  135. $(".order_reception_wrapper").hide()
  136. $("#order_isover_box").find("input[type='radio']").on("change", function(){
  137. if($(this).val() === "1") {
  138. $(".order_reception_wrapper").show()
  139. } else if ($(this).val() === "0") {
  140. $(".order_reception_wrapper").hide()
  141. }
  142. })
  143. //获取接收部门
  144. getDepts('reginsTreeView', 'order_transfer_dept');
  145. // 立即处理
  146. $('#order_isover').find('input[type="radio"]').on('change', function(){
  147. if($(this).val() === '1'){
  148. $('#order_transfer_depts').hide();
  149. }else{
  150. $('#order_transfer_depts').show();
  151. }
  152. });
  153. //新增工单创建
  154. $('#save_order').on('click', orderSave);
  155. });
  156. //新建工单 保存
  157. function orderSave() {
  158. var order_handle = $('#order_handles').is(':visible') ? $('#order_handle').val() : 0,
  159. order_transfer_dept = $('#order_transfer_dept').attr('data-id'),//int 接收部门
  160. order_receiveUser = $('#order_receiveUser').val();//int 接收人
  161. if($('#order_isover').find('input[type="radio"]:checked').val() === '1'){
  162. order_transfer_dept = 0;
  163. order_receiveUser = 0;
  164. }
  165. $.post(huayi.config.callcenter_url + 'WorkOrderNew/Add', {
  166. TypeClass:$('#order_type').find('input[type="radio"]:checked').val(), //反馈类型
  167. CustomerName:$('#order_name').val(), //客户姓名
  168. CustomerTel:$('#order_tel').val(), //客户电话
  169. Gender:$('#order_sexte').find('input[type="radio"]:checked').val(), //性别
  170. Location:$('#order_company').val(), //客户地址
  171. IsOver:$('#order_isover').find('input[type="radio"]:checked').val(), //是否处理
  172. DealContents:$('#order_conduct').val(), //处理内容
  173. Problem:$('#order_reception').val(), //问题描述
  174. Reservation:$('#order_category').val(), //预约类型
  175. IDnumber:$('#order_number').val(), //身份证
  176. Expert:$('#order_expert').val(), //预约专家
  177. IsMedical:$('#order_advice').find('input[type="radio"]:checked').val(), //是否来院就医
  178. Project:$('#order_utilities').val(), //预约项目
  179. AboutcarMan:$('#order_About').val(), //约车人
  180. CarTel:$('#order_lephone').val(), //约车电话
  181. TreatmentAddress:$('#order_ocation').val(), //接诊地址
  182. IsCar:$('#order_chuch').find('input[type="radio"]:checked').val(), //是否出车
  183. Condition:$('#order_Huebig').val(), //患者病情
  184. Department:$('#order_office').val(), //预约科室 1111111111111111111111111111111111111
  185. TranDepartment:$('#order_strtil').val(), //转接科室 222222222222222222222222222
  186. Remarks:$('#order_strative').val(),//备注
  187. AppointmentTime:$('#order_time').val(),//预约时间
  188. DriveoutTime:$('#order_chucetime').val(),//出车时间
  189. ComplaintDepartment:$('#order_Betou').val(), //被投诉科室
  190. ComplaintTarget:$('#order_Betxia').val(), //被投诉对象
  191. IsRelevant:$('#order_xibum').find('input[type="radio"]:checked').val(), //是否转相关部门
  192. isover: $('#order_isover').find('input[type="radio"]:checked').val(), //int 是否立即处理(默认为0,立即处理为1,立即处理的工单无法指派接收人和接受部门)
  193. token: $.cookie("token")
  194. }, function(result) {
  195. result = $.parseJSON(result);
  196. if(result.state.toLowerCase() == "success") {
  197. cleanOrderForm();
  198. top.workcount();
  199. layer.msg("保存成功");
  200. }
  201. })
  202. }
  203. //清空表单
  204. function cleanOrderForm() {
  205. $('#order_form').find('input.form-control').val('');
  206. $('#order_form').find('textarea.form-control').val('');
  207. $('#order_form').find('select.form-control').val('0');
  208. $('#order_type').find("input[type='radio'][value='107']").prop("checked", true).trigger('change');
  209. $('#order_iseffective').find("input[type='radio'][value='0']").prop("checked", true).trigger('change');
  210. $('#order_transfer_dept').val('').trigger('keyup');
  211. $('#order_transfer_dept').attr('placeholder', '请选择部门');
  212. $('#order_transfer_dept').attr('data-id', 0);
  213. $('#order_receiveUser').selectpicker('destroy');
  214. $('#order_receiveUser').empty();
  215. $('#order_receiveUser').append('<option value="0">请选择接收人</option>');
  216. $('#order_receiveUser').selectpicker('refresh');
  217. $('#order_form').find('.selectpicker.form-control').selectpicker('val', '0').trigger('change');
  218. $('#order_source').selectpicker('val', '468').trigger('change');
  219. $('#order_isover').find("input[type='radio'][value='0']").prop("checked", true);
  220. }
  221. /**
  222. * 获取接收部门 获取投诉类型
  223. * el1, 树形结构元素id名 reginsTreeView
  224. * el2, 搜索框元素id名 order_transfer_dept
  225. * */
  226. function getDepts(el1, el2) {
  227. //初始化 样式
  228. $('#' + el2).on('focus click', function() {
  229. $('#' + el1).removeClass('hidden').addClass('show');
  230. });
  231. $('#' + el2).on('keyup', function() {
  232. if($(this).val() == '') {
  233. $('#' + el1).treeview('uncheckAll', {
  234. silent: true
  235. });
  236. $(this).attr('data-id', '0');
  237. }
  238. });
  239. $('#' + el2 + ' .caret').on('click', function() {
  240. $('#' + el1).removeClass('hidden').addClass('show');
  241. });
  242. $('#' + el1).mouseleave(function() {
  243. $(this).removeClass('show').addClass('hidden');
  244. });
  245. $.getJSON(huayi.config.callcenter_url + 'Department/GetDeptList', {
  246. token: $.cookie("token")
  247. }, function(result) {
  248. if(result.state.toLowerCase() == "success") {
  249. var defaultDatas = helper.methods.buildTree(result.data);
  250. var sortChildrenArr = helper.methods.objToArray(defaultDatas[0].children);
  251. sortChildrenArr.sort(helper.methods.compare('sort'));
  252. var sortChildrenObj = helper.methods.arrayToObj(sortChildrenArr);
  253. defaultDatas[0].children = sortChildrenObj;
  254. if(defaultDatas) {
  255. var $sTree = $('#' + el1).treeview({
  256. color: "#1ab394",
  257. selectedBackColor: '#1ab394',
  258. expandIcon: 'glyphicon glyphicon-chevron-right',
  259. collapseIcon: 'glyphicon glyphicon-chevron-down',
  260. nodeIcon: 'fa fa-folder-o',
  261. //selectedIcon: "glyphicon glyphicon-stop",
  262. //icon: "glyphicon glyphicon-stop",
  263. //emptyIcon: 'glyphicon',
  264. //showCheckbox: true,
  265. selectable: true,
  266. state: {
  267. selected: true
  268. },
  269. data: defaultDatas,
  270. onNodeSelected: function(event, node) {
  271. $sTree.treeview('clearSearch');
  272. $('#' + el2).val(node.text);
  273. $('#' + el2).attr('data-id', node.id);
  274. $('#' + el1).removeClass('show').addClass('hidden');
  275. //获取接收人员
  276. getReceiveUser($('#order_receiveUser'), node.id);
  277. },
  278. onNodeUnselected: function(event, node) {
  279. $('#' + el2).attr('data-id', 0);
  280. $('#' + el2).attr('placeholder', '请选择接收部门');
  281. $('#order_receiveUser').empty();
  282. $('#order_receiveUser').append('<option value="0">请选择接收人</option>');
  283. $('#order_receiveUser').selectpicker('refresh');
  284. }
  285. });
  286. // $('#' + el1).treeview('collapseAll', {
  287. // silent: true
  288. // });
  289. $('#' + el1).treeview('expandAll', { levels: 2, silent: true });
  290. var findSNodes = function() {
  291. return $sTree.treeview('search', [$('#' + el2).val(), {
  292. ignoreCase: false,
  293. exactMatch: false
  294. }]);
  295. };
  296. $('#' + el2).on('keyup focus', function(e) {
  297. var selectableNodes = findSNodes();
  298. //var m = $('#' + el1).treeview('getParent', selectableNodes);
  299. //$('#' + el1).treeview('selectNode', [ m, { silent: true } ]);
  300. });
  301. }
  302. }
  303. })
  304. }
  305. //获取接收人员
  306. function getReceiveUser(obj, deptid) {
  307. $.ajax({
  308. url: huayi.config.callcenter_url + 'UserAccount/GetDeptUserList',
  309. type: 'get',
  310. data: {
  311. deptid: deptid,
  312. token: $.cookie("token")
  313. },
  314. dataType: "json",
  315. async: true,
  316. success: function(res) {
  317. obj.empty();
  318. if(res.state.toLowerCase() === "success") {
  319. res = res.data;
  320. if(res && res.length > 0) {
  321. obj.append('<option value="0">请选择接收人</option>');
  322. res.forEach(function(v, i) {
  323. obj.append('<option value="' + v.F_UserId + '" data-code="'+ v.F_UserCode +'">' + v.F_UserName + '('+ v.F_UserCode +')</option>');
  324. });
  325. obj.selectpicker('refresh');
  326. }
  327. }
  328. },
  329. });
  330. }