Nessuna descrizione

equipmentRepair.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. /**
  2. * 报修平台
  3. * */
  4. var $storages = window.localStorage;
  5. var state = ''; // state tab页的 data-index(工单状态参数);
  6. var f_State = ''
  7. $(document).ready(function() {
  8. $('.tool_bars').authorizeButton();
  9. //搜索
  10. $('#sc_btns').click(function() {
  11. initTable1();
  12. })
  13. $('#HY_seeMore').click(function() {
  14. $('.moreCondition').toggleClass('show');
  15. })
  16. //TAB切换
  17. $('#tab_head_left li').click(function() {
  18. $(this).addClass('tab_head_active').siblings().removeClass('tab_head_active');
  19. state = $(this).attr('data-index');
  20. f_State = state
  21. initTable1();
  22. })
  23. //时间
  24. laydate.render({
  25. elem: '#startTime',
  26. range: '~',
  27. theme: '#249fea'
  28. });
  29. //系统名称
  30. // helper.getDropList.getlistDropByDic($('#sysname'), 'XTMC');
  31. //项目类型
  32. // helper.getDropList.getlistDropByDic($('#protype'), 'XMLX');
  33. //报修地点
  34. // helper.getDropList.getlistDropByDic($('#replace'), 'BXDD');
  35. // GetEquipName($('#equipname')); //设备名称
  36. //省市
  37. // getProvinceCity($('#province'));
  38. helper.getDropList.getProlistDrop($('#proname'));
  39. helper.getDropList.getProUser('', $('#usercode'));
  40. $('#proname').on('change', function() {
  41. $('#usercode').empty();
  42. $('#usercode').append('<option value="">请选择维修工账号</option>');
  43. helper.getDropList.getProUser($(this).val(), $('#usercode'));
  44. });
  45. if ($('#startTime').val() == "") {
  46. function p(s) {
  47. return s < 10 ? '0' + s : s;
  48. }
  49. var currentYear = new Date().getFullYear();
  50. var currentMonth = new Date().getMonth() + 1;
  51. var currentDate = new Date().getDate();
  52. var prevCurrentYear = 0;
  53. var prevCurrentMonth = 0;
  54. if (currentMonth == 1) {
  55. prevCurrentYear = currentYear - 1;
  56. prevCurrentMonth = 12;
  57. } else {
  58. prevCurrentYear = currentYear;
  59. prevCurrentMonth = currentMonth - 1;
  60. }
  61. var current = currentYear + "-" + p(currentMonth) + "-" + p(currentDate);
  62. // var lastmonth = prevCurrentYear + "-" + p(prevCurrentMonth) + "-" + p(currentDate)
  63. var a = getPreDatetime(3600 * 1000 * 24 * 30);
  64. $('#startTime').val(getPreDatetime(3600 * 1000 * 24 * 30) + " ~ " + current)
  65. initTable1();
  66. }
  67. var t, n, count = 0;
  68. t = setInterval("showAuto()", 1000 * 60);
  69. refreshOrderDatas(huayi.config.repairPlatformTime); //刷新 工单数据
  70. });
  71. $(function() {
  72. getdept()
  73. })
  74. function getdept() {
  75. $("#Pwcode").html('');
  76. equipmentdata = []
  77. $("#Pwcode").append('<option value="">请选择维修班组</option>');
  78. $.ajax({
  79. type: "get",
  80. url: huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/getallbzcount",
  81. async: true,
  82. dataType: 'json',
  83. success: function(data) {
  84. var leveldata = []
  85. if (data.state.toLowerCase() == 'success') {
  86. leveldata = data.data
  87. $(leveldata).each(function(q, p) {
  88. console.log(p.role_name)
  89. $("<option value='" + p.role_name + "'>" + p.role_name + "</option>").appendTo("#Pwcode");
  90. $("#Pwcode").selectpicker('refresh');
  91. });
  92. } else {
  93. $("#Pwcode").empty();
  94. $("#Pwcode").selectpicker('refresh');
  95. }
  96. }
  97. });
  98. }
  99. function initTable1() {
  100. //先销毁表格
  101. $('#table1').bootstrapTable('destroy');
  102. //初始化表格,动态从服务器加载数据
  103. $('#table1').bootstrapTable({
  104. method: "get", //使用get请求到服务器获取数据
  105. url: huayi.config.callcenter_url + "equipmentapi/api/worepairbase/getlistbypage", //获取数据的Servlet地址
  106. contentType: "application/x-www-form-urlencoded",
  107. striped: true, //表格显示条纹
  108. pagination: true, //启动分页
  109. pageSize: 10, //每页显示的记录数
  110. pageNumber: 1, //当前第几页
  111. pageList: [10, 20, 50, 100], //记录数可选列表
  112. search: false, //是否启用查询
  113. showColumns: false, //显示下拉框勾选要显示的列
  114. showRefresh: false, //显示刷新按钮
  115. sidePagination: "server", //表示服务端请求
  116. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  117. //设置为limit可以获取limit, offset, search, sort, order
  118. queryParamsType: "undefined",
  119. queryParams: function queryParams(params) { //设置查询参数
  120. var param = {
  121. pageindex: params.pageNumber,
  122. pagesize: params.pageSize,
  123. phone: $("#phone").val(), //联系电话
  124. wocode: $("#wocode").val(), //工单编号
  125. province: $('#province').val(),
  126. city: $('#city').val(),
  127. protypeid: $('#protype').val(), //项目类型
  128. projectid: $('#proname').val(), //项目名称
  129. buildid: $('#build').val(), //楼名称
  130. floorid: $('#floor').val(), //楼层名称
  131. Pwcode: $('#Pwcode').val(), //维修班组
  132. systemid: $('#sysname').val(), //系统名称
  133. equipmentid: $('#equipname').val(), //设备名称
  134. usercode: $('#usercode').val(), //维修工账号
  135. channel: $('#channelSource').val(), //渠道来源
  136. stime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[0], //开始时间
  137. etime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[1], //结束时间
  138. //replace: getReplice(),//保修地点
  139. state: state //工单状态
  140. };
  141. return param;
  142. },
  143. responseHandler: function(res) {
  144. //格式化数据
  145. return {
  146. "total": res.data && res.data.total, //总页数
  147. "rows": res.data && res.data.rows, //数据
  148. "totalcounts": res.data && res.data.totalcounts,
  149. "wzpcounts": res.data && res.data.wzpcounts,
  150. "yjdcounts": res.data && res.data.yjdcounts,
  151. "dpjcounts": res.data && res.data.dpjcounts,
  152. "ywjcounts": res.data && res.data.ywjcounts,
  153. "ygqcounts": res.data && res.data.ygqcounts,
  154. "yqxcounts": res.data && res.data.yqxcounts,
  155. };
  156. },
  157. onPostBody: function() {
  158. //console.log("行数据渲染完成!");
  159. var totalPages = $('#table1').bootstrapTable("getOptions").totalPages;
  160. var pageNumber = $('#table1').bootstrapTable("getOptions").pageNumber;
  161. var goInputWidth = 45; //输入框默认宽度
  162. var maxLen = ("" + totalPages).length;
  163. //根据总页数设定跳转页面输入框宽度
  164. if (totalPages > 999)
  165. goInputWidth = maxLen * 10 + 15;
  166. var $pageGo = $('<span style="padding-left: 5px;">跳转到<input type="number" maxlength="' +
  167. maxLen + '" min="1" max="' + totalPages +
  168. '" class="input-box" id="c_jump-to-page" value="' +
  169. pageNumber + '" style="width: ' + goInputWidth + 'px;" />/' +
  170. totalPages + '页&nbsp;</span>');
  171. var $go = $("<a href=\"javascript:;\">Go</a>");
  172. var $shou = $("<a href=\"javascript:;\">首页</a>")
  173. var $wei = $("<a href=\"javascript:;\">尾页</a>")
  174. $pageGo.append($go);
  175. $pageGo.append($shou);
  176. $pageGo.append($wei);
  177. $(".pagination-detail").append($pageGo);
  178. //页码范围限定(部分浏览器min~max失效时)
  179. $pageGo.change(function() {
  180. var goPage = $('#c_jump-to-page').val();
  181. if (goPage < 1)
  182. $('#c_jump-to-page').val(1);
  183. if (goPage > totalPages)
  184. $('#c_jump-to-page').val(totalPages);
  185. });
  186. //跳转到
  187. $go.click(function() {
  188. var goPage = parseInt($('#c_jump-to-page').val());
  189. console.log(totalPages)
  190. if (goPage != pageNumber)
  191. $('#table1').bootstrapTable('selectPage', parseInt(goPage));
  192. });
  193. $shou.click(function() {
  194. $('#table1').bootstrapTable('selectPage', 1);
  195. });
  196. $wei.click(function() {
  197. $('#table1').bootstrapTable('selectPage', totalPages);
  198. });
  199. },
  200. onLoadSuccess: function(res) { //加载成功时执行
  201. if (res.totalcounts >= 100) {
  202. res.totalcounts = '99+';
  203. }
  204. if (res.wzpcounts >= 100) {
  205. res.wzpcounts = '99+';
  206. }
  207. if (res.yjdcounts >= 100) {
  208. res.yjdcounts = '99+';
  209. }
  210. if (res.dpjcounts >= 100) {
  211. res.dpjcounts = '99+';
  212. }
  213. if (res.ywjcounts >= 100) {
  214. res.ywjcounts = '99+';
  215. }
  216. if (res.ygqcounts >= 100) {
  217. res.ygqcounts = '99+';
  218. }
  219. if (res.yqxcounts >= 100) {
  220. res.yqxcounts = '99+';
  221. }
  222. $('.audit_all').text(res.totalcounts); //全部
  223. $('.audit_none').text(res.wzpcounts); //未指派
  224. $('.audit_order').text(res.yjdcounts); //已接单
  225. $('.audit_waitEvaluate').text(res.dpjcounts); //待评价
  226. $('.audit_complete').text(res.ywjcounts); //已完结
  227. $('.audit_ygqcounts').text(res.ygqcounts); //挂起
  228. $('.audit_yqxcounts').text(res.yqxcounts); //挂起
  229. $('.tool_down').authorizeOperateButton();
  230. //layer.msg("加载成功");
  231. // 判断满意度的显隐
  232. if ($storages.getItem('roleCode') == "YWYG") {
  233. $('#table1').bootstrapTable('hideColumn', 'score'); //隐藏上述score列
  234. }
  235. },
  236. onLoadError: function() { //加载失败时执行
  237. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  238. }
  239. });
  240. }
  241. //操作
  242. function formatterOperate(val, row) {
  243. var str = '';
  244. str = '<div class="task_tools" onclick = helper.methods.taskTools(this)>' +
  245. '<a title="操作"><i class="fa fa-cogs" aria-hidden="true"></i></a>' +
  246. '<ul class="tool_down">'
  247. switch (val + '') {
  248. case '0':
  249. str += '<li><a class="aBtn" authorize="yes" id="HY_assign_' + row.id + '" onclick="btn_assign(\'' + row.projectid +
  250. '\',\'' + row.wocode + '\')"><i class="fa icon-paidan tub"></i>派单</a><li>' +
  251. '<li><a class="aBtn" authorize="yes" id="HY_handle_' + row.id + '" onclick="btn_robbing(\'' + row.wocode +
  252. '\')"><i class="fa icon-qiangdan tub"></i>接收</a><li>' +
  253. '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id +
  254. '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  255. '<li><a class="aBtn" authorize="yes" id="HY_edit_' + row.id + '" onclick="btn_edit(\'' + row.id +
  256. '\')"><i class="fa icon-edit tub"></i>编辑</a><li>' +
  257. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id +
  258. '\')"><i class="fa icon-delete tub"></i>删除</a><li>'
  259. break;
  260. case '1':
  261. str += '<li><a class="aBtn" authorize="yes" id="HY_assign_' + row.id + '" onclick="btn_assign(\'' + row.projectid +
  262. '\',\'' + row.wocode + '\')"><i class="fa icon-paidan tub"></i>派单</a><li>' +
  263. '<li><a class="aBtn" authorize="yes" id="HY_deal' + row.id + '" onclick="btn_handle(\'' + row.wocode + '\',\'' +
  264. row.floorid + '\')"><i class="fa icon-msnui-audit tub"></i>处理</a><li>' +
  265. '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id +
  266. '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  267. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id +
  268. '\')"><i class="fa icon-delete tub"></i>删除</a><li>'
  269. break;
  270. case '2':
  271. str += '<li><a class="aBtn" authorize="yes" id="HY_evaluate_' + row.id + '" onclick="btn_evaluate(\'' + row.wocode +
  272. '\',\'' + row.id + '\')"><i class="fa icon-zan tub"></i>评价</a><li>' +
  273. '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id +
  274. '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  275. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id +
  276. '\')"><i class="fa icon-delete tub"></i>删除</a><li>'
  277. break;
  278. case '3':
  279. str += '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id +
  280. '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  281. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id +
  282. '\')"><i class="fa icon-delete tub"></i>删除</a><li>'
  283. break;
  284. case '7':
  285. str += '<li><a class="aBtn" authorize="yes" id="HY_assign_' + row.id + '" onclick="btn_assign(\'' + row.projectid +
  286. '\',\'' + row.wocode + '\')"><i class="fa icon-paidan tub"></i>派单</a><li>' +
  287. '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id +
  288. '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  289. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id +
  290. '\')"><i class="fa icon-delete tub"></i>删除</a><li>'
  291. break;
  292. case '8':
  293. str += '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id +
  294. '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  295. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id +
  296. '\')"><i class="fa icon-delete tub"></i>删除</a><li>'
  297. break;
  298. default:
  299. str += '<li><a class="aBtn">-</a><li>'
  300. break;
  301. }
  302. str += '</ul>';
  303. str += '</div>';
  304. return str;
  305. }
  306. //编号
  307. function Code(val, row, index) {
  308. return index + 1;
  309. }
  310. //渠道来源
  311. function formatterChannel(val, row) {
  312. var str = '';
  313. switch (val + '') {
  314. case '1':
  315. str = '电话';
  316. break;
  317. case '2':
  318. str = "安卓";
  319. break;
  320. case '3':
  321. str = "IOS";
  322. break;
  323. case '4':
  324. str = "PC端";
  325. break;
  326. default:
  327. str = "其他"
  328. }
  329. return str
  330. }
  331. function formatterCreateuser(val, row) {
  332. var str = '';
  333. if (row.channel == 4) {
  334. str = row.repairman + '<br>' + '(' + row.createusername + ')'
  335. } else {
  336. str = row.repairman + '<br>' + '(' + val + ')'
  337. }
  338. return '<span>' + str + '</span>'
  339. }
  340. //格式化接单人
  341. function formatterToUser(val, row) {
  342. var toUserStr = '';
  343. var touser = row.touser;
  344. var tousername = row.tousername;
  345. // var touser = ["AA000", "AA001", "AA002"];
  346. // var tousername = ["张山", "李四", "王五"];
  347. if (touser != null) {
  348. if (touser.length < 1) {
  349. toUserStr = '-';
  350. } else {
  351. var toUsers = touser.concat(tousername);
  352. var toUsersLength = toUsers.length;
  353. if (toUsersLength === 2) {
  354. toUserStr = toUsers[0] + '-' + toUsers[1];
  355. } else {
  356. for (var i = 0; i < toUsersLength; i++) {
  357. if (i < toUsersLength / 2) {
  358. toUserStr += toUsers[i] + '-' + toUsers[toUsersLength / 2 + i] + ','
  359. toUserStr.substring(0, toUserStr.length - 1);
  360. } else {
  361. break;
  362. }
  363. }
  364. }
  365. }
  366. }
  367. return toUserStr;
  368. }
  369. //格式化满意度
  370. function formatterScore(val) {
  371. //1 差、2 不满意、3 一般、4 满意、5 很满意
  372. var stateClass = 'timeout_default';
  373. var stateTxt = '-';
  374. switch (val) {
  375. case 1:
  376. stateClass = 'timeout_termination';
  377. stateTxt = '不满意';
  378. break;
  379. case 2:
  380. stateClass = 'timeout_refuse';
  381. stateTxt = '不满意';
  382. break;
  383. case 3:
  384. stateClass = 'timeout_wait';
  385. stateTxt = '基本满意';
  386. break;
  387. case 4:
  388. stateClass = 'timeout_doned';
  389. stateTxt = '满意';
  390. break;
  391. case 5:
  392. stateClass = 'timeout_success';
  393. stateTxt = '满意';
  394. break;
  395. default:
  396. stateClass = 'timeout_default';
  397. stateTxt = '-';
  398. break;
  399. }
  400. return '<span class="' + stateClass + '">' + stateTxt + '</span>';
  401. }
  402. // 格式化报修地点
  403. // function formatterRepairPlace(val, row) {
  404. // return val + ' ' + (row.repairoom || '')
  405. // }
  406. //故障说明
  407. function formatterDescripe(val) {
  408. if (val) {
  409. //var strD = decodeURIComponent(val);
  410. if (val.length > 12) {
  411. val = val.substring(0, 12) + '...';
  412. }
  413. return val;
  414. }
  415. }
  416. function timestampToTime(timestamp) {
  417. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  418. var Y = date.getFullYear() + '-';
  419. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
  420. var D = (date.getDate() < 10 ? '0'+(date.getDate()) : date.getDate()) + ' ';
  421. var h = (date.getHours() < 10 ? '0'+(date.getHours()) : date.getHours()) + ':';
  422. var m = (date.getMinutes() < 10 ? '0'+(date.getMinutes()) : date.getMinutes()) + ':';
  423. var s = (date.getSeconds() < 10 ? '0'+(date.getSeconds()) : date.getSeconds());
  424. return Y+M+D+h+m+s;
  425. };
  426. // 格式化超时时长
  427. function formatterdate(val, row) {
  428. console.log(row.tobztimes)
  429. var dateval = ''
  430. var dealdate = ''
  431. var lasttime = ''
  432. if (row.tobztimes != null && val != null && row.wxtimeleths != null && row.wxtimeid != null) {
  433. var beginTimes = row.tobztimes.replace(/-/g, '/') //班组时间
  434. var endTimes = val.replace(/-/g, '/') //处理时间
  435. var middletime = row.wxtimeleths //维修时效
  436. var dateone =new Date(beginTimes)
  437. var datetwo =new Date(endTimes)
  438. lasttime = timestampToTime(dateone.getTime()/1000+middletime*60*60)
  439. dealdate = lasttime.substr(0, 11).concat('23:59:59').replace(/-/g, '/') //
  440. var datethree =new Date(dealdate)
  441. var b = ( datetwo.getTime()/1000 - datethree.getTime()/1000) / 3600 //比价的差值
  442. console.log(b)
  443. if ( datetwo.getTime()/1000 - dateone.getTime()/1000 > middletime) {
  444. if (b > 0) {
  445. dateval = b.toFixed(2) + '小时'
  446. } else {
  447. dateval = ''
  448. }
  449. } else {
  450. dateval = ''
  451. }
  452. } else {
  453. dateval = ''
  454. }
  455. return dateval;
  456. }
  457. // 格式化维修时效
  458. function formatterwxtimeleths(val, row) {
  459. var wxtimeval = ''
  460. // console.log(val, row)
  461. if (val != null && val > 0) {
  462. wxtimeval = val
  463. } else {
  464. wxtimeval = ''
  465. }
  466. return wxtimeval;
  467. }
  468. //省市
  469. function formatterLocation(val, row) {
  470. return '<div>' + val + '' + row.city + '</div>'
  471. }
  472. //工单状态
  473. function formatterState(val, row) {
  474. var str = '',
  475. className = '';
  476. switch (val) {
  477. case 0:
  478. str = '新工单';
  479. className = 'state_audit_wait';
  480. break;
  481. case 1: //已接收
  482. str = "已接单";
  483. className = 'state_audit_doned';
  484. break;
  485. case 2:
  486. str = "已处理";
  487. className = 'state_audit_refuse';
  488. break;
  489. case 3:
  490. str = "已完结";
  491. className = 'state_audit_done';
  492. break;
  493. case 7:
  494. str = "挂起";
  495. className = 'state_audit_revoke';
  496. break;
  497. case 8:
  498. str = "已取消";
  499. className = 'state_audit_hang';
  500. break;
  501. default:
  502. str = "其他";
  503. className = 'state_audit_other';
  504. break;
  505. }
  506. return '<a href="javaScript:;" class="state_audit ' + className + '">' + str + '</a>'
  507. }
  508. // 导出
  509. $("#HY_export").click(function() {
  510. console.log(1)
  511. var phone = $("#phone").val() //联系电话
  512. var wocode = $("#wocode").val() //工单编号
  513. var province = $('#province').val()
  514. var city = $('#city').val()
  515. var protypeid = $('#protype').val() //项目类型
  516. var projectid = $('#proname').val() //项目名称
  517. var buildid = $('#build').val() //楼名称
  518. var Pwcode = $('#Pwcode').val() //楼名称
  519. var floorid = $('#floor').val() //班组名称
  520. var systemid = $('#sysname').val() //系统名称
  521. var equipmentid = $('#equipname').val() //设备名称
  522. var usercode = $('#usercode').val() //维修工账号
  523. var channel = $('#channelSource').val() //渠道来源
  524. var useraccount = $storages.getItem('userCode')
  525. var state = f_State //工单状态
  526. var stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0] //开始时间
  527. var etime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1] //结束时间
  528. console.log(state)
  529. if (wocode == 'undefined') {
  530. wocode = ''
  531. } else {
  532. wocode = ''
  533. }
  534. if (province == 'undefined') {
  535. } else {
  536. province = ''
  537. }
  538. if (city == 'undefined') {
  539. } else {
  540. city = ''
  541. }
  542. if (protypeid == 'undefined') {
  543. } else {
  544. protypeid = ''
  545. }
  546. if (projectid == 'undefined') {
  547. projectid = ''
  548. } else {
  549. }
  550. if (buildid == 'undefined') {
  551. } else {
  552. buildid = ''
  553. }
  554. if (Pwcode == 'undefined') {
  555. } else {
  556. Pwcode = ''
  557. }
  558. if (floorid == 'undefined') {
  559. } else {
  560. floorid = ''
  561. }
  562. if (systemid == 'undefined') {
  563. } else {
  564. systemid = ''
  565. }
  566. if (equipmentid == 'undefined') {
  567. } else {
  568. equipmentid = ''
  569. }
  570. if (equipmentid == 'undefined') {
  571. } else {
  572. equipmentid = ''
  573. }
  574. if (usercode == 'undefined') {
  575. } else {
  576. usercode = ''
  577. }
  578. if (channel == 'undefined') {
  579. } else {
  580. channel = ''
  581. }
  582. if (state == 'undefined') {
  583. state = ''
  584. } else {
  585. state = state
  586. }
  587. console.log(state)
  588. window.location.href = huayi.config.callcenter_url + "equipmentapi/api/worepairbase/excelwocodeinfo?useraccount=" +
  589. useraccount + "&stime=" + stime + "&etime=" + etime + "+&wocode=" + wocode + "&province=" + province + "&city=" +
  590. city + "&protypeid=" + protypeid + "&projectid=" + projectid + "&buildid=" + buildid + "&floorid=" + floorid +
  591. "&systemid=" + systemid + "&equipmentid=" + equipmentid + "&usercode=" + usercode + "&channel=" + channel +
  592. "&phone=" + phone + "&state=" + state + "&Pwcode=" + Pwcode
  593. })
  594. //添加
  595. function btn_add() {
  596. layer.open({
  597. type: 2,
  598. content: "template/addEquipmentRepair.html",
  599. title: '添加故障维修',
  600. area: ['70%', '80%'], //宽高
  601. });
  602. }
  603. //编辑
  604. function btn_edit(ids) {
  605. layer.open({
  606. type: 2,
  607. content: "template/addEquipmentRepair.html?ids=" + ids,
  608. title: '修改故障维修',
  609. area: ['70%', '80%'], //宽高
  610. });
  611. }
  612. //处理
  613. function btn_handle(code, floorId, sysId) {
  614. layer.open({
  615. type: 2,
  616. content: "template/HandleEquipmentRepair.html?code=" + code + "&floorId=" + floorId,
  617. title: '故障维修处理',
  618. area: ['70%', '80%'], //宽高
  619. });
  620. }
  621. //详情
  622. function btn_details(ids) {
  623. layer.open({
  624. type: 2,
  625. content: "template/seeEquipmentRepair.html?ids=" + ids,
  626. title: '故障维修详情',
  627. area: ['70%', '80%'], //宽高
  628. });
  629. }
  630. //派单
  631. function btn_assign(proId, wocode) {
  632. layer.open({
  633. type: 2,
  634. content: "template/assignEquipmentRepair.html?&proId=" + proId + "&code=" + wocode,
  635. title: '故障维修派单',
  636. area: ['70%', '80%'], //宽高
  637. });
  638. }
  639. //接收
  640. function btn_robbing(wocode) {
  641. layer.confirm('您确定接收吗?', {
  642. icon: 7,
  643. btn: ['是', '否'] //按钮
  644. }, function() {
  645. /*发送请求*/
  646. $.ajax({
  647. type: "post",
  648. url: huayi.config.callcenter_url + "equipmentapi/api/worepairbase/grab",
  649. async: true,
  650. dataType: 'json',
  651. data: {
  652. wocode: wocode,
  653. channel: 1
  654. },
  655. success: function(data) {
  656. if (data.state.toLowerCase() == 'success') {
  657. layer.msg("接收成功!");
  658. $('#table1').bootstrapTable('refresh');
  659. }
  660. }
  661. });
  662. });
  663. }
  664. //评价
  665. function btn_evaluate(wocode, ids) {
  666. layer.open({
  667. type: 2,
  668. content: "template/EvaluateEquipmentRepair.html?code=" + wocode + "&id=" + ids,
  669. title: '工单评价',
  670. area: ['70%', '80%'], //宽高
  671. });
  672. }
  673. //获取楼层楼的文本
  674. function getReplice() {
  675. var str = "";
  676. if ($("#build option:selected").val() == '') {
  677. $("#build option:selected").text('')
  678. }
  679. if ($("#floor option:selected").val() == '') {
  680. $("#floor option:selected").text('')
  681. }
  682. str = $("#build option:selected").text() + " " + $("#floor option:selected").text();
  683. return str
  684. }
  685. //刷新弹出框
  686. function sendmsg() {
  687. $.ajax({
  688. type: "get",
  689. url: huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/getnewmassage", //获取数据的Servlet地址
  690. async: true,
  691. dataType: 'json',
  692. data: {},
  693. success: function(data) {
  694. if (data.data.data == 1) {
  695. $('audio').remove();
  696. audioElementHovertree = document.createElement('audio');
  697. audioElementHovertree.setAttribute('src', './video/Sound.mp3');
  698. audioElementHovertree.setAttribute('autoplay', 'autoplay'); //打开自动播放
  699. layer.confirm('来新工单了', {
  700. icon: 7,
  701. btn: ['确定'], //按钮
  702. shade: 0,
  703. offset: "rb"
  704. });
  705. }
  706. }
  707. });
  708. }
  709. function showAuto() {
  710. sendmsg()
  711. }
  712. /**
  713. * 刷新 工单数据
  714. * repairPlatformTime 刷新时间的间隔;
  715. *
  716. * */
  717. function refreshOrderDatas(repairPlatformTime) {
  718. var objTime = {
  719. init: 0,
  720. time: function() {
  721. if (top.$("iframe:visible").contents().find('.layui-layer').length < 2) {
  722. objTime.init += 1000;
  723. //console.log(objTime.init);
  724. //当页面没有click、keydown、mousemove、mousewheel 并且没有layer 弹窗时;每间隔 huayi.config.repairPlatformTime 刷新数据;
  725. if (objTime.init == repairPlatformTime) {
  726. $('#table1').bootstrapTable('refresh');
  727. objTime.init = 0;
  728. }
  729. }
  730. },
  731. eventFun: function() {
  732. clearInterval(testUser);
  733. objTime.init = 0;
  734. testUser = setInterval(objTime.time, 1000 * 60);
  735. }
  736. }
  737. var testUser = setInterval(objTime.time, 1000 * 60);
  738. var body = document.querySelector('html');
  739. body.addEventListener("click", objTime.eventFun);
  740. body.addEventListener("keydown", objTime.eventFun);
  741. body.addEventListener("mousemove", objTime.eventFun);
  742. body.addEventListener("mousewheel", objTime.eventFun);
  743. }
  744. //批量删除
  745. function btn_deletes() {
  746. var ids = $.map($('#table1').bootstrapTable('getSelections'),
  747. function(row) {
  748. return row.id;
  749. });
  750. /*判断长度*/
  751. if (ids.length <= 0) {
  752. layer.confirm('请选择要删除的选项', {
  753. icon: 7,
  754. btn: ['确定'] //按钮
  755. });
  756. return;
  757. }
  758. btn_delete(ids);
  759. }
  760. //删除
  761. function btn_delete(del_id) {
  762. /*发送请求*/
  763. layer.confirm('您确定要删除当前报修工单吗?', {
  764. icon: 7,
  765. btn: ['确定', '取消'],
  766. yes: function(index, layero) {
  767. $.post(huayi.config.callcenter_url + "equipmentapi/api/worepairbase/delete", {
  768. ids: del_id,
  769. }, function(result) {
  770. result = JSON.parse(result);
  771. if (result.state.toLowerCase() == "success") {
  772. layer.msg("删除成功");
  773. $('#table1').bootstrapTable('refresh');
  774. }
  775. })
  776. },
  777. });
  778. }
  779. function getPreDatetime(pdate) {
  780. var start = new Date()
  781. start.setTime(start.getTime() - pdate)
  782. start.getYear(); // 获取当前年份(2位)
  783. var YY = start.getFullYear() // 获取完整的年份(4位,1970-????)
  784. var MM = start.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
  785. MM = MM > 9 ? MM : ('0' + MM);
  786. var DD = start.getDate() // 获取当前日(1-31)
  787. DD = DD > 9 ? DD : ('0' + DD)
  788. var lastmonth = YY + '-' + MM + '-' + DD;
  789. return lastmonth;
  790. }