Нет описания

Workdeal.js 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /**
  2. * 工单处理
  3. * */
  4. var openid = helper.cookies.get("openid");
  5. var id = helper.request.queryString("id");
  6. var countyPicker; //乡镇
  7. if(id) {
  8. //获取信息分类 、乡镇 及交办单位后获取 详情信息
  9. $.when(getTypeList(), getCounty()).then(function() {
  10. getWorkDetails(); //获取工单详情
  11. });
  12. var userCode = helper.cookies.get("usercode");
  13. $('#h_inquser').val(userCode);
  14. //获取当前日期
  15. var nowDate = helper.DateFormat.getNowDate();
  16. $('#h_inqtime').val(nowDate);
  17. $("#submit").on('tap', submitHandle);
  18. }
  19. function getWorkDetails() {
  20. $.ajax({
  21. type: "get",
  22. url: huayi.config.callcenter_url + 'WxLogin/GetWorkOrder',
  23. async: true,
  24. data: {
  25. openid: openid,
  26. workorderid: id
  27. },
  28. success: function(data) {
  29. if($('#hy_loading')){
  30. $('#hy_loading').fadeOut();
  31. $('#hy_loading').remove();
  32. }
  33. data = JSON.parse(data);
  34. if(data.state.toLowerCase() == "success") {
  35. var con = data.data;
  36. if(con) {
  37. if(con.data && con.data.length > 0) {
  38. var res = con.data[0];
  39. $('#h_userName').val(res.Customer); //string 是 客户姓名
  40. countyPicker.pickers[0].setSelectedValue(res.County); //int 否 乡镇
  41. var sItems = countyPicker.getSelectedItems();
  42. $('#h_county').val(sItems[0].text);
  43. $('#h_county').attr('data-index', sItems[0].value);
  44. $('#h_address').val(res.Address); //string 否 住址
  45. $('#h_contents').val(res.Detail); //string 是 反映问题
  46. // $('#h_inquser').val(res.Inquser); //string 否 调查员
  47. // $('#h_inqtime').val(res.Inqtime); //string 否 调查时间
  48. // $('#h_infoType').val(res.InfoTypeID); //int 否 信息分类id,默认为0
  49. // $('#h_unit').val(res.UnitID); //int 否 交办单位id,默认为0
  50. // $('#h_cont').val(res.clcontent); //string 否 问题处理情况
  51. // $('#h_answer').val(res.Answer); //string 否 回访反馈情况
  52. // $('#h_remark').val(res.Remark); //string 否 备注
  53. //图片展示
  54. // var Files = res.File;
  55. // if(Files) {
  56. // $(Files).each(function(i, n) {
  57. // $('<div class="img-box"><img src="' + n.F_FileUrl + '" alt="" class="image-item" data-preview-src="" data-preview-group="1" /><div>').appendTo("#image-list");
  58. // })
  59. // }
  60. }
  61. }
  62. }
  63. }
  64. });
  65. }
  66. function submitHandle() {
  67. var that = this;
  68. if(!$.trim($("#h_userName").val())) {
  69. mui.toast("请您输入姓名后再提交");
  70. return;
  71. }
  72. if(!$.trim($("#h_contents").val())) {
  73. mui.toast("请您输入反映问题后再提交");
  74. return;
  75. }
  76. $.ajax({
  77. type: "post",
  78. url: huayi.config.callcenter_url + 'WxLogin/DealWorkOrder',
  79. async: true,
  80. beforeSend: function() {
  81. mui(that).button('loading');
  82. },
  83. data: {
  84. openid: openid, //string 是
  85. orderid: id, //string 是 工单编号
  86. cusname: $('#h_userName').val(), //string 是 客户姓名
  87. country: $('#h_county').attr('data-index'), //int 否 乡镇
  88. address: $('#h_address').val(), //string 否 住址
  89. content: $('#h_contents').val(), //string 是 反映问题
  90. issend: $('#h_resut').find('input[type="radio"]:checked').val(),
  91. inquser: $('#h_inquser').val(), //string 否 调查员
  92. inqtime: $('#h_inqtime').val(), //string 否 调查时间
  93. infotypeid: $('#h_infoType').attr('data-index'), //int 否 信息分类id,默认为0
  94. unitid: $('#h_unit').attr('data-index'), //int 否 交办单位id,默认为0
  95. cont: $('#h_cont').val(), //string 否 问题处理情况
  96. answer: $('#h_answer').val(), //string 否 回访反馈情况
  97. remark: $('#h_remark').val(), //string 否 备注
  98. },
  99. dataType: 'json',
  100. success: function(data) {
  101. mui(that).button('reset');
  102. if(data.state.toLowerCase() == "success") {
  103. mui.alert("提交成功", ' ', function() {
  104. window.location.href = 'WorkCL.html';
  105. });
  106. }
  107. },
  108. error: function(textStatus) {
  109. mui(that).button('reset');
  110. mui.toast('网络繁忙,请稍后再试...');
  111. },
  112. complete: function(XMLHttpRequest, textStatus) {
  113. mui(that).button('reset');
  114. if(textStatus == 'timeout') {
  115. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  116. xmlhttp.abort();
  117. mui.toast('网络超时,请稍后再试...');
  118. }
  119. },
  120. });
  121. }
  122. //信息分类
  123. function getTypeList() {
  124. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  125. $.ajax({
  126. type: "get",
  127. url: huayi.config.callcenter_url + 'WxLogin/GetTypeList',
  128. async: false,
  129. data: {
  130. openid: openid,
  131. },
  132. dataType: 'json',
  133. success: function(data) {
  134. if(data.state.toLowerCase() == "success") {
  135. var res = data.data;
  136. if(res.length > 0) {
  137. //下拉弹出
  138. (function($, doc) {
  139. $.init();
  140. $.ready(function() {
  141. var t_countyDatas = [{
  142. value: 0,
  143. text: '请选择信息分类'
  144. }];
  145. res.forEach(function(item, index) {
  146. t_countyDatas.push({
  147. value: item.F_DictionaryValueId,
  148. text: item.F_Name
  149. });
  150. });
  151. var infoTypesPicker = new $.PopPicker();
  152. infoTypesPicker.setData(t_countyDatas);
  153. //信息分类
  154. var showInfoTypebtn = doc.getElementById('showInfoTypePicker');
  155. var infotypeRes = doc.getElementById('h_infoType');
  156. showInfoTypebtn.addEventListener('tap', function(event) {
  157. infoTypesPicker.show(function(items) {
  158. infotypeRes.value = items[0].text;
  159. infotypeRes.setAttribute("data-index", items[0].value);
  160. });
  161. }, false);
  162. });
  163. })(mui, document);
  164. }
  165. dtd.resolve(); // 改变Deferred对象的执行状态
  166. }
  167. }
  168. });
  169. return dtd.promise(); // 返回promise对象
  170. }
  171. //获取乡镇 及交办单位
  172. function getCounty() {
  173. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  174. $.ajax({
  175. type: "get",
  176. url: huayi.config.callcenter_url + "WxLogin/GetAreaList",
  177. dataType: 'json',
  178. async: true,
  179. data: {
  180. openid: openid,
  181. },
  182. success: function(data) {
  183. if(data.state.toLowerCase() == "success") {
  184. var res = data.data;
  185. if(res.length > 0) {
  186. //下拉弹出
  187. (function($, doc) {
  188. $.init();
  189. $.ready(function() {
  190. var t_countyDatas = [{
  191. value: 0,
  192. text: '请选择乡镇'
  193. }];
  194. res.forEach(function(item, index) {
  195. t_countyDatas.push({
  196. value: item.F_DictionaryValueId,
  197. text: item.F_Name
  198. });
  199. });
  200. var t_unitDatas = [{
  201. value: 0,
  202. text: '请选择交办单位'
  203. }];
  204. res.forEach(function(item, index) {
  205. t_unitDatas.push({
  206. value: item.F_DictionaryValueId,
  207. text: item.F_Name
  208. });
  209. });
  210. countyPicker = new $.PopPicker();
  211. countyPicker.setData(t_countyDatas);
  212. var unitPicker = new $.PopPicker();
  213. unitPicker.setData(t_unitDatas);
  214. //乡镇
  215. var showCountybtn = doc.getElementById('showCountyPicker');
  216. var countyRes = doc.getElementById('h_county');
  217. showCountybtn.addEventListener('tap', function(event) {
  218. countyPicker.show(function(items) {
  219. countyRes.value = items[0].text;
  220. countyRes.setAttribute("data-index", items[0].value);
  221. });
  222. }, false);
  223. //交办单位
  224. var showUnitbtn = doc.getElementById('showUnitPicker');
  225. var unitRes = doc.getElementById('h_unit');
  226. showUnitbtn.addEventListener('tap', function(event) {
  227. unitPicker.show(function(items) {
  228. unitRes.value = items[0].text;
  229. unitRes.setAttribute("data-index", items[0].value);
  230. });
  231. }, false);
  232. });
  233. })(mui, document);
  234. }
  235. dtd.resolve(); // 改变Deferred对象的执行状态
  236. }
  237. }
  238. });
  239. return dtd.promise(); // 返回promise对象
  240. }
  241. //时间控件
  242. (function($, doc) {
  243. $.init();
  244. var btns = $('.btn');
  245. btns.each(function(i, btn) {
  246. btn.addEventListener('tap', function() {
  247. var _self = this;
  248. if(_self.picker) {
  249. _self.picker.show(function(rs) {
  250. _self.picker.dispose();
  251. _self.picker = null;
  252. });
  253. } else {
  254. var optionsJson = this.getAttribute('data-options') || '{}';
  255. var options = JSON.parse(optionsJson);
  256. var id = this.getAttribute('id');
  257. _self.picker = new $.DtPicker(options);
  258. _self.picker.show(function(rs) {
  259. document.getElementById("h_inqtime").value = rs.text;
  260. _self.picker.dispose();
  261. _self.picker = null;
  262. });
  263. }
  264. }, false);
  265. });
  266. })(mui, document);