add.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. var selectedData = { cols: [], array: [] };
  2. var checkusersselect = null;
  3. var checkuserlist = new Array();
  4. var tabledatagride = null;
  5. var rowsDate;
  6. $(document).ready(function() {
  7. $.jeDate("#month_date", {
  8. isinitVal: true,
  9. format: 'YYYY/MM' // 分隔符可以任意定义,该例子表示只显示年月
  10. });
  11. $("#month_date").val(getCurrentTimeFormat());
  12. var checked_dept = null;
  13. if (roleContains("ROLE_WRECKER")) {
  14. checked_dept = getCurrentUser().organid;
  15. }
  16. setWreckerGroupSelect("#qzd", checked_dept);
  17. getpeople();
  18. //默认值 $("#qzd").val()
  19. var dd = 89;
  20. if ($("#qzd").val() != "") {
  21. dd = $("#qzd").val();
  22. }
  23. inittAreaable($("#month_date").val(), $("#qzd").val());
  24. initselecttable();
  25. laydate.render({
  26. elem: '#starttime',
  27. type: 'time'
  28. });
  29. laydate.render({
  30. elem: '#endtime',
  31. type: 'time'
  32. });
  33. });
  34. var recordlist = null;
  35. var stimemonth = null;
  36. function initselecttable() {
  37. selectedData = { cols: [], array: [], cache: false };
  38. selectedData.cols.push({ width: 0.3, name: "usernames", label: '人员', style: { 'text-align': 'center', 'line-height': '34px' } });
  39. selectedData.cols.push({ width: 0.5, name: "taskname", label: '任务名称', style: { 'text-align': 'center', 'line-height': '34px' } });
  40. selectedData.cols.push({ width: 0.1, name: "option", label: '操作', html: true, style: { 'text-align': 'center', 'line-height': '34px' } });
  41. reloadtable();
  42. }
  43. function reloadtable() {
  44. $('#selected_table').datagrid({
  45. dataSource: selectedData,
  46. states: { fixedTopUntil: 0 },
  47. rowDefaultHeight: 50,
  48. height: 200,
  49. });
  50. }
  51. var layindex = null;
  52. var taskMap = new HashMap();
  53. function inittAreaable(time, dept) {
  54. layindex = layer.load(0, { shade: false });
  55. var t = time.replace("/", "-") + "";
  56. var endtime = moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss");
  57. var starttime = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  58. var param1 = { "startTime": getMomentTimeFormat(starttime), "endTime": getMomentTimeFormat(endtime), "checked_dept": dept,"isComplete":1 }
  59. console.log(param1);
  60. //获取排班情况
  61. post_common_service("/q/record/getall/0/0", param1, function(redatatemp) {
  62. // console.log(redatatemp)
  63. var recodedata = redatatemp.records;
  64. //获取任务情况
  65. post_common_service("/q/task/getall/0/0", param1, function(taskdata) {
  66. taskMap = new HashMap();
  67. console.log(recodedata);
  68. recodedata.forEach(r => {
  69. taskdata.forEach(t => {
  70. if (r.id == t.record_id) {
  71. //该记录的任务
  72. r["task"] = t;
  73. }
  74. });
  75. var user = r.users.split(",");
  76. for (var i = 0; i < user.length; i++) {
  77. var key = user[i] + "_" + "" + moment(r.received_time).format("YYYY-MM-DD");
  78. if (taskMap.get(key) != null) {
  79. var list = taskMap.get(key);
  80. list.push(r);
  81. taskMap.set(key, list);
  82. } else {
  83. var list = [];
  84. list.push(r);
  85. taskMap.set(key, list);
  86. }
  87. }
  88. });
  89. });
  90. checkuserlist = redatatemp.checkusers;
  91. var userData = {
  92. "organid": dept
  93. };
  94. UserGetList(userData, function(redata) {
  95. layer.close(layer.index);
  96. var data = redata;
  97. datatemp = {
  98. data: data,
  99. t: t,
  100. starttime: starttime,
  101. endtime: endtime,
  102. time: time,
  103. records: recodedata
  104. };
  105. reloadtableData();
  106. $(".completec").mouseover(function() {
  107. var ids = this.id.split("_");
  108. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  109. var currentday = temp.add(ids[1], "day");
  110. var key = ids[0] + "_" + currentday.format("YYYY-MM-DD");
  111. var temphtml = '';
  112. for(var i in taskMap.get(key)){
  113. if(taskMap.get(key)[i].id == ids[2]){
  114. var typename = '';
  115. if(taskMap.get(key)[i].type == 1){
  116. typename="抛锚";
  117. }else if(taskMap.get(key)[i].type == 2){
  118. typename="事故";
  119. }
  120. temphtml = '<tr><th>'+typename+'</th><th>'+taskMap.get(key)[i].addr+'</th><th>'+taskMap.get(key)[i].task.check_status_name+'</th></tr>';
  121. }
  122. }
  123. var titlehtml = '<table border=1 style="border:solid 1px;width:180px;"><tr><th>事件</th><th>桩号</th><th>状态</th></tr>' + temphtml + '</table>';
  124. layer.tips(titlehtml, "#" + this.id, {
  125. tips: [1, '#8e8e8e'],
  126. time: 0,
  127. width: '240px'
  128. });
  129. });
  130. $(".doingc").mouseover(function() {
  131. var ids = this.id.split("_");
  132. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  133. var currentday = temp.add(ids[1], "day");
  134. var key = ids[0] + "_" + currentday.format("YYYY-MM-DD");
  135. for(var i in taskMap.get(key)){
  136. if(taskMap.get(key)[i].id == ids[2]){
  137. var typename = '';
  138. if(taskMap.get(key)[i].type == 1){
  139. typename="抛锚";
  140. }else if(taskMap.get(key)[i].type == 2){
  141. typename="事故";
  142. }
  143. temphtml = '<tr><th>'+typename+'</th><th>'+taskMap.get(key)[i].addr+'</th><th>'+taskMap.get(key)[i].task.check_status_name+'</th></tr>';
  144. }
  145. }
  146. var titlehtml = '<table border=1 style="border:solid 1px;width:180px;"><tr><th>事件</th><th>桩号</th><th>状态</th></tr>' + temphtml + '</table>';
  147. layer.tips(titlehtml, "#" + this.id, {
  148. tips: [1, '#8e8e8e'],
  149. time: 0,
  150. width: '240px'
  151. });
  152. });
  153. $(".unusec").mouseover(function() {
  154. var ids = this.id.split("_");
  155. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  156. var currentday = temp.add(ids[1], "day");
  157. var key = ids[0] + "_" + currentday.format("YYYY-MM-DD");
  158. for(var i in taskMap.get(key)){
  159. if(taskMap.get(key)[i].id == ids[2]){
  160. var typename = '';
  161. if(taskMap.get(key)[i].type == 1){
  162. typename="抛锚";
  163. }else if(taskMap.get(key)[i].type == 2){
  164. typename="事故";
  165. }
  166. temphtml = '<tr><th>'+typename+'</th><th>'+taskMap.get(key)[i].addr+'</th><th>'+'无效'+'</th></tr>';
  167. }
  168. }
  169. var titlehtml = '<table border=1 style="border:solid 1px;width:180px;"><tr><th>事件</th><th>桩号</th><th>状态</th></tr>' + temphtml + '</table>';
  170. layer.tips(titlehtml, "#" + this.id, {
  171. tips: [1, '#8e8e8e'],
  172. time: 0,
  173. width: '240px'
  174. });
  175. });
  176. $(".novideoc").mouseover(function() {
  177. var ids = this.id.split("_");
  178. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  179. var currentday = temp.add(ids[1], "day");
  180. var key = ids[0] + "_" + currentday.format("YYYY-MM-DD");
  181. for(var i in taskMap.get(key)){
  182. if(taskMap.get(key)[i].id == ids[2]){
  183. var typename = '';
  184. if(taskMap.get(key)[i].type == 1){
  185. typename="抛锚";
  186. }else if(taskMap.get(key)[i].type == 2){
  187. typename="事故";
  188. }
  189. temphtml = '<tr><th>'+typename+'</th><th>'+taskMap.get(key)[i].addr+'</th><th>'+'未上传视频'+'</th></tr>';
  190. }
  191. }
  192. var titlehtml = '<table border=1 style="border:solid 1px;width:180px;"><tr><th>事件</th><th>桩号</th><th>状态</th></tr>' + temphtml + '</table>';
  193. layer.tips(titlehtml, "#" + this.id, {
  194. tips: [1, '#8e8e8e'],
  195. time: 0,
  196. width: '240px'
  197. });
  198. });
  199. $(".btn,.btc").mouseout(function() {
  200. layer.close(layer.index);
  201. });
  202. $('#myTable05').fixedHeaderTable({ altClass: 'odd', footer: false, fixedColumns: 1 });
  203. for (var index in checkuserlist) {
  204. var p = checkuserlist[index];
  205. p.title = p.truename;
  206. }
  207. if (checkusersselect != null) {
  208. reset();
  209. checkusersselect = null;
  210. }
  211. checkusersselect = $('#check_users').comboTree({
  212. source: checkuserlist,
  213. isMultiple: true
  214. });
  215. });
  216. });
  217. }
  218. function setdatagrid() {
  219. }
  220. function reset() {
  221. initselecttable();
  222. var myDataGrid = $('#selected_table').data('zui.datagrid');
  223. myDataGrid.dataSource.data = null;
  224. myDataGrid.setDataSource(selectedData);
  225. myDataGrid.setPager(1, selectedData.array.length, selectedData.array.length);
  226. myDataGrid.render();
  227. if (checkusersselect != null) {
  228. $("#check_users").val("");
  229. checkusersselect.destroy();
  230. checkusersselect = null;
  231. }
  232. }
  233. function selectedTask(obj) {
  234. changeListItem(obj.id);
  235. }
  236. function removeListItem(obj) {
  237. var ids = obj.id.split("delete_");
  238. $("#" + ids[1]).parent().removeClass("active");
  239. $("#" + ids[1]).prop("checked", false);
  240. changeListItem(ids[1]);
  241. }
  242. function changeListItem(id) {
  243. var cobj;
  244. var tempids = id.split("_");
  245. var t = stimemonth.replace("/", "-") + "";
  246. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  247. var currentday = temp.add(tempids[1], "day");
  248. var taskMapid = tempids[0] + "_" + currentday.format("YYYY-MM-DD");
  249. var cpeople;
  250. for (var index in datatemp.data) {
  251. var user = datatemp.data[index];
  252. if (user.id == tempids[0]) {
  253. cpeople = user;
  254. }
  255. }
  256. for (var i in taskMap.get(taskMapid)) {
  257. if (taskMap.get(taskMapid)[i].id == tempids[2]) {
  258. cobj = taskMap.get(taskMapid)[i];
  259. }
  260. }
  261. if ($("#" + id).prop('checked')) {
  262. activteChange(cobj, tempids);
  263. addlisttable(cobj, id);
  264. } else {
  265. activteRemove(cobj, tempids);
  266. removelisttable(cobj);
  267. }
  268. }
  269. function addlisttable(record, id) {
  270. var tempids = id.split("_");
  271. var t = stimemonth.replace("/", "-") + "";
  272. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  273. var currentday = temp.add(tempids[1], "day");
  274. var typename;
  275. var stime = moment(record.received_time).format("HH:mm");
  276. var etime = moment(record.back_time).format("HH:mm");
  277. if(record.type == 1){
  278. typename="抛锚";
  279. }else if(record.type == 2){
  280. typename="事故";
  281. }
  282. var taskname = currentday.format("YYYY-MM-DD") + " " + stime + "~" + etime + " " + record.addr+"号桩" + typename+"清障任务";
  283. record.rname = taskname;
  284. var feeList = $.zui.store.get("cache_wrecker_group_list");
  285. var dept_info = null;
  286. for (var index in feeList) {
  287. var dept = feeList[index];
  288. if (record.dept == dept.deptid) {
  289. dept_info = dept;
  290. }
  291. }
  292. id = trim(id);
  293. var btn = '<button class="btn btn-primary" type="button" onclick="removeListItem(this)" id="delete_' + id + '">删除</button>';
  294. selectedData.array.push({ "usernames": record.userNames, "time": currentday.format("YYYY-MM-DD"), "dept_name": dept_info.name, "taskname": taskname, "option": btn, recordInfo: record, deptInfo: dept_info });
  295. var myDataGrid = $('#selected_table').data('zui.datagrid');
  296. myDataGrid.dataSource.data = null;
  297. myDataGrid.setDataSource(selectedData);
  298. myDataGrid.setPager(1, selectedData.array.length, selectedData.array.length);
  299. myDataGrid.render();
  300. }
  301. function removelisttable(record) {
  302. // console.log(record)
  303. for (var index in selectedData.array) {
  304. var o = selectedData.array[index];
  305. if (o != null && o.recordInfo.id == record.id) {
  306. selectedData.array.splice(index, 1);
  307. }
  308. }
  309. var myDataGrid = $('#selected_table').data('zui.datagrid');
  310. myDataGrid.dataSource.data = null;
  311. myDataGrid.setDataSource(selectedData);
  312. myDataGrid.setPager(1, selectedData.array.length, selectedData.array.length);
  313. myDataGrid.render();
  314. //reloadtable();
  315. }
  316. function search() {
  317. inittAreaable($("#month_date").val(), $("#qzd").val());
  318. }
  319. function addTask() {
  320. //获取列表
  321. var tasklist = selectedData.array;
  322. if (tasklist.length < 1) {
  323. layer.msg('未选择清障记录!', {
  324. time: 2000, //20s后自动关闭
  325. });
  326. return;
  327. }
  328. var check_user_list = checkusersselect.getSelectedItemsId();
  329. // var param = {
  330. // "name": obj.car,
  331. // "check_status": 2,
  332. // "start_time": moment(obj.peopleinfo.received_time).format("YYYY-MM-DD HH:mm:ss"),
  333. // "end_time": moment(obj.peopleinfo.back_time).format("YYYY-MM-DD HH:mm:ss"),
  334. // "checked_dept": obj.peopleinfo.dept,
  335. // "checkman": parseInt(check_user_list[u_index]),
  336. // "record_id": parseInt(obj.peopleinfo.id),
  337. // "checked_users": obj.peopleinfo.users,
  338. // "rule_id": 6
  339. // }
  340. // console.log(param);
  341. var plist = []
  342. tasklist.forEach(t => {
  343. plist.push(t.recordInfo);
  344. });
  345. // console.log(plist)
  346. var param = { "userids": check_user_list, "qzdRecord": plist };
  347. post_common_service('/q/task/add', param, function(redata) {
  348. layer.msg('已添加', { icon: 1 });
  349. inittAreaable($("#month_date").val(), $("#qzd").val());
  350. });
  351. // post_common_service('/f/task/add', param, function(redata) {
  352. // // layer.msg('已添加', { icon: 1 });
  353. // inittAreaable($("#month_date").val(), $("#qzd").val());
  354. // });
  355. }
  356. function getpeople() {
  357. // var orginid = $("#qzd").val();
  358. // var userData = {
  359. // "organid": orginid
  360. // }
  361. }
  362. function activteChange(cobj, tempids) {
  363. var usersids = cobj.users.split(",");
  364. if (usersids.length > 1) {
  365. for (var j in usersids) {
  366. var objid = usersids[j] + "_" + tempids[1] + "_" + tempids[2];
  367. if ($("#" + objid).prop('checked') == false) {
  368. $("#" + objid).parent().addClass("active");
  369. $("#" + objid).prop("checked", true);
  370. }
  371. }
  372. }
  373. }
  374. function activteRemove(cobj, tempids) {
  375. var usersids = cobj.users.split(",");
  376. if (usersids.length > 1) {
  377. for (var j in usersids) {
  378. var objid = usersids[j] + "_" + tempids[1] + "_" + tempids[2];
  379. if ($("#" + objid).prop('checked')) {
  380. $("#" + objid).parent().removeClass("active");
  381. $("#" + objid).prop("checked", false);
  382. }
  383. }
  384. }
  385. }
  386. var userlist = null;
  387. var stimemonth = null;
  388. var datatemp = {};
  389. function reloadtableData() {
  390. var data = datatemp.data;
  391. var t = datatemp.t;
  392. var starttime = datatemp.starttime;
  393. var endtime = datatemp.endtime;
  394. var time = datatemp.time;
  395. datac = { cols: [], array: [] };
  396. var days = endtime.diff(starttime, 'days');
  397. datac.cols.push({ width: 200, name: 'type', label: "", });
  398. var tbhtml = "";
  399. var thhtml = "<thead><tr>";
  400. var tbodyhtml = "<tbody>";
  401. thhtml += "<th>" + "<button class='datatime' onclick='selectedall(this)' id='datatimebtn_" + i + "' style='width:100px;height:100%;background:rgba(0,0,0,0)'></button>" + "</th>";
  402. for (var i = 1; i <= days; i++) {
  403. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  404. var currentday = temp.add(i, "day");
  405. var day = currentday.date();
  406. thhtml += "<th>" + "<button class='datatime' onclick='selectedall(this)' id='datatimebtn_" + i + "' style='width:100px;height:100%;background:rgba(0,0,0,0)'>" + currentday.format("MM-DD") + "</button>" + "</th>";
  407. // datac.cols.push({ width: 80, name: "day_" + i, label: "<button class='datatime' onclick='selectedall(this)' id='datatimebtn_" + i + "' style='width:100%;height:100%;background:rgba(0,0,0,0)'>" + currentday.format("MM-DD") + "</button>", html: true, className: "table_content" });
  408. }
  409. thhtml += "</tr></thead>";
  410. tbhtml += thhtml;
  411. userlist = data;
  412. stimemonth = time;
  413. for (var index in data) {
  414. var user = data[index];
  415. tbodyhtml += "<tr>";
  416. tbodyhtml += "<td style='vertical-align:middle'><label style='width:100px;margin:0'>" + user.truename + "</label></td>";
  417. for (var i = 1; i <= days; i++) {
  418. //内容
  419. var temp = moment(moment(t + "-25T23:00:00", "YYYY-MM-DD HH:mm:ss").subtract(1, 'month'));
  420. var currentday = temp.add(i, "day");
  421. var key = user.id + "_" + currentday.format("YYYY-MM-DD");
  422. var temphtml = "";
  423. tbodyhtml += "<td>";
  424. if (taskMap.get(key) != null) {
  425. //存在稽查记录
  426. var list = taskMap.get(key);
  427. list.forEach(r => {
  428. var t = r.task;
  429. //未生成任务
  430. if (t == null) {
  431. // if(r.isApply == 1){
  432. // temphtml += '<button data-toggle="button" class="btc noAppy" style="margin:10px;background:#FFDEAD;border-color:#FFDEAD;color:#fff" type="button" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "放空任务" + '</button>';
  433. // }else{
  434. if (r.videos == null || r.videos == undefined || r.videos == "") {
  435. if(r.pics == null || r.pics == undefined || r.pics == ""){
  436. temphtml += '<button data-toggle="button" class="btc novideoc" style="margin:10px;background:#fff;border-color:#fff;color:#03b8cf" type="button" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "~" + moment(r.back_time).format("HH:mm") + '</button>';
  437. }else{
  438. temphtml += '<div class="btn-group normal" style="margin:10px;" data-toggle="buttons" id="btn_u_' + user.id + '_r_' + r.id + '"> <label class="btn btn-info7 "> <input type="checkbox" onchange="selectedTask(this)" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "~" + moment(r.back_time).format("HH:mm") + '</label></div>';
  439. }
  440. } else {
  441. temphtml += '<div class="btn-group normal" style="margin:10px;" data-toggle="buttons" id="btn_u_' + user.id + '_r_' + r.id + '"> <label class="btn btn-info2 "> <input type="checkbox" onchange="selectedTask(this)" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "~" + moment(r.back_time).format("HH:mm") + '</label></div>';
  442. //temphtml += '<button data-toggle="button" class="btc normal" style="margin:10px" onclick="selectedTask(this)" type="button" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "~" + moment(r.back_time).format("HH:mm") + '</button>';
  443. }
  444. // }
  445. } else
  446. if (t.check_status == 2 || t.check_status == 7) {
  447. //考核进行中
  448. temphtml += '<button data-toggle="button" class="btc doingc" style="margin:10px" type="button" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "~" + moment(r.back_time).format("HH:mm") + '</button>';
  449. } else
  450. if (t.check_status == 22) {
  451. //存在无效任务
  452. temphtml += '<button data-toggle="button" class="btc unusec" style="margin:10px" type="button" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "~" + moment(r.back_time).format("HH:mm") + '</button>';
  453. } else {
  454. //完成稽查
  455. temphtml += '<button data-toggle="button" class="btc completec" style="margin:10px;" type="button" id="' + user.id + '_' + i + '_' + r.id + '">' + moment(r.received_time).format("HH:mm") + "~" + moment(r.back_time).format("HH:mm") + '</button>';
  456. }
  457. });
  458. }
  459. tbodyhtml += temphtml;
  460. tbodyhtml += "</td>";
  461. }
  462. tbodyhtml += "</tr>";
  463. }
  464. tbodyhtml += "</tbody>";
  465. tbhtml += tbodyhtml;
  466. $("#table_html").html('<table class="fancyTable" id="myTable05" cellpadding="0" cellspacing="0"> </table>');
  467. $("#myTable05").html(tbhtml)
  468. }