暫無描述

equipmentRepair.js 34KB

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