new.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. var cur_status;
  2. var cur_page;
  3. var is_save;
  4. var updateid = null;
  5. var user = $.zui.store.get("user");
  6. var recordId = '';
  7. var recordVideos = '';
  8. function initTaskPage() {
  9. initQueryParams();
  10. initTableRowBtn();
  11. queryTask();
  12. getRecord();
  13. }
  14. function initQueryParams() {
  15. // 仅选择日期
  16. $.jeDate("#start_time", {
  17. isinitVal: true,
  18. format: 'YYYY/MM' // 分隔符可以任意定义,该例子表示只显示年月
  19. });
  20. $("#start_time").val(getCurrentTimeFormat());
  21. var page_params = $.zui.store.get("page_params");
  22. if (page_params && page_params.status) {
  23. cur_status = page_params.status;
  24. }
  25. var checked_dept = null;
  26. if (roleContains("WRECKER")) {
  27. checked_dept = getCurrentUser().organid;
  28. }
  29. if (checked_dept) {
  30. var optStr = '<option value="' + checked_dept + '" selected="selected">' + getCurrentUser().organname + '</option>';
  31. $("#deptlist").html('');
  32. $("#deptlist").html(optStr);
  33. $("#deptlist").attr('disabled', 'disabled')
  34. } else {
  35. setWreckerGroupAllSelect("#deptlist");
  36. }
  37. setWreckerGroupSelect("#dept", checked_dept);
  38. if (hasRole(ROLE_JICHA_ADMIN) && cur_status == 4) {
  39. $("#dispatchPatchBtn").show();
  40. $("#dispatchAllNoScoreBtn").show();
  41. }
  42. if (roleContains("STATION") && cur_status == 5) {
  43. $("#confirmPatchBtn").show();
  44. }
  45. $("#checkPersonDiv").show();
  46. if (cur_status == 4 || cur_status == 5 || cur_status == 6) {
  47. $("#hasScoreDiv").show();
  48. }
  49. }
  50. //初始化表行按钮
  51. function initTableRowBtn() {
  52. $.zui.store.set("task_table_btn_1", [{ func: 'checkUpdate', text: '修改', icon_class: '' },
  53. { func: 'deleteRecord', text: '删除', icon_class: 'text-center' }
  54. ]);
  55. $.zui.store.set("task_table_btn_2", [{ func: 'checkUpdate', text: '修改', icon_class: '' }]);
  56. // $.zui.store.set("task_table_btn_2", [{ func: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  57. // $.zui.store.set("task_table_btn_3", [{ func: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  58. // $.zui.store.set("task_table_btn_7", [{ func: 'showContinueCheck', text: '继续稽查', icon_class: 'icon-eye-open' }]);
  59. // $.zui.store.set("task_table_btn_4", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' },
  60. // { func: 'dispatchTaskById', text: '下发', icon_class: 'icon-signin' }
  61. // ]);
  62. // $.zui.store.set("task_table_btn_5", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' }]);
  63. // $.zui.store.set("task_table_btn_6", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' }]);
  64. // $.zui.store.set("task_table_btn_21", [{ func: 'showApplyDetail', text: '处理', icon_class: 'icon-hand-up' }]);
  65. }
  66. //查询任务
  67. function queryTask() {
  68. var t = getTimeByMonth(GV("#start_time"));
  69. var data = {
  70. "startTime": getMomentTimeFormat(t.starttime),
  71. "endTime": getMomentTimeFormat(t.endtime),
  72. "dept": $("#deptlist").val(),
  73. "isComplete": $("#isComplete").val(),
  74. // "check_status": cur_status
  75. };
  76. var hide = false;
  77. if (hasRole(ROLE_WRECKER_MANAGER) || hasRole(ROLE_WRECKER) || hasRole(ROLE_JICHA) || roleContains('ROLE_WRECKER')) {
  78. hide = true;
  79. }
  80. var cols = [
  81. { width: 80, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  82. { width: 80, text: '清障队', type: 'string', flex: true, colClass: 'text-center', sort: 'down', field: 'deptName' },
  83. { width: 80, text: '桩号', type: 'string', flex: true, colClass: 'text-center', sort: 'down', field: 'addr' },
  84. { width: 80, text: '客户信息', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'car_user_info' },
  85. { width: 120, text: '接警时间', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'received_time' },
  86. // { width: 160, text: '最后时间', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'last_time' },
  87. { width: 120, text: '出勤人员', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'userNames' },
  88. // {width: 120, text: '状态', type: 'string', flex: true, colClass: '',field: 'check_status_name'}
  89. ];
  90. if (hasRole(ROLE_DDZS_ADMIN) || hasRole(ROLE_DDZS)) {
  91. var colFunc = { width: 160, text: '操作', type: 'string', flex: true, field: 'id', colClass: 'text-center' };
  92. var colStr = { width: 160, text: '最后时间', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'last_time' };
  93. colFunc.oper = $.zui.store.get("task_table_btn_1");
  94. cols.push(colStr);
  95. cols.push(colFunc);
  96. $("#saveButton").show();
  97. } else if (hasRole(ROLE_WRECKER_MANAGER) || hasRole(ROLE_WRECKER_NQ) || hasRole(ROLE_WRECKER)) {
  98. setMonitor();
  99. cols = [
  100. { width: 80, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  101. // { width: 80, text: '清障队', type: 'string', flex: true, colClass: 'text-center', sort: 'down', field: 'deptName' },
  102. { width: 80, text: '桩号', type: 'string', flex: true, colClass: 'text-center', sort: 'down', field: 'addr' },
  103. // { width: 80, text: '客户信息', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'car_user_info' },
  104. { width: 120, text: '接警时间', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'received_time' },
  105. // { width: 160, text: '最后时间', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'last_time' },
  106. { width: 120, text: '出勤人员', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'userNames' },
  107. // {width: 120, text: '状态', type: 'string', flex: true, colClass: '',field: 'check_status_name'}
  108. ];
  109. var colFunc3 = { width: 160, text: '正副班长', type: 'monitor', flex: true, field: 'id', colClass: 'text-center' };
  110. // var colFunc5 = { width: 160, text: '正副班长', type: 'monitor', flex: true, field: 'id', colClass: 'text-center' };
  111. //var colFunc3 = { width: 160, text: '视频上传', type: 'imagebutton', flex: true, field: 'videos', colClass: 'text-center' };
  112. // var colFunc4 = { width: 160, text: '是否按时到达', type: 'arrive', flex: true, field: 'id', colClass: 'text-center' };
  113. var colFunc1 = { width: 160, text: '视频上传', type: 'imagebutton', flex: true, field: 'videos', colClass: 'text-center' };
  114. var colFunc2 = { width: 160, text: '图片上传', type: 'imagebutton', flex: true, field: 'pics', colClass: 'text-center' };
  115. var colFunc = { width: 40, text: '操作', type: 'string', flex: true, field: 'id', colClass: 'text-center' };
  116. colFunc.oper = $.zui.store.get("task_table_btn_2");
  117. cols.push(colFunc3);
  118. cols.push(colFunc1);
  119. cols.push(colFunc2);
  120. // cols.push(colFunc3);
  121. //cols.push(colFunc5);
  122. cols.push(colFunc);
  123. $("#isCompleteDiv").hide();
  124. $("#isComplete").val(1);
  125. data.isComplete = 1;
  126. data.isApply = 0;
  127. }
  128. //只有下发才显示复选框
  129. var checkable = false;
  130. // if ((hasRole(ROLE_JICHA_ADMIN) && cur_status == 4) || (roleContains("STATION") && cur_status == 5)) {
  131. // checkable = true;
  132. // }
  133. // console.log("checkable:" + checkable);
  134. // if (cur_status == 2 || cur_status == 3) {
  135. // data.check_status_arr = [2, 3];
  136. // data.check_status = null;
  137. // }
  138. taskTableObj = $('#task_list_table').mytable({
  139. 'cols': cols,
  140. 'checkable': checkable,
  141. 'url': "/q/record/getall/",
  142. 'param': data,
  143. 'pager': {
  144. 'p_cur': cur_page
  145. },
  146. renderfunction: function() {
  147. $(".uploadervideo").each(function() {
  148. var type = this.id.split("_")[2];
  149. var title = '';
  150. var extensions = '';
  151. if (type == "videos") {
  152. title = "视频";
  153. extensions = 'mp4,avi';
  154. } else {
  155. title = '图片',
  156. extensions = 'jpg,gif,png'
  157. }
  158. $(this).uploader({
  159. autoUpload: true, // 当选择文件后立即自动进行上传操作
  160. url: base_image_server_url + 'fileServer/file/upload', // 文件上传提交地址
  161. chunk_size: 0,
  162. filters: {
  163. mime_types: [{
  164. title: title,
  165. extensions: extensions
  166. }],
  167. // 不允许上传重复文件
  168. prevent_duplicates: true
  169. },
  170. onFileUploaded: function(file, responseObject) {
  171. var id = this.$.attr("id").split("_")[1];
  172. var file_src = recordVideos;
  173. var datas = eval('(' + responseObject.response + ')');
  174. if (file_src != '' && file_src != null && file_src != undefined) {
  175. file_src += "," + datas.result_data.path;
  176. } else {
  177. file_src += datas.result_data.path;
  178. }
  179. var data = {
  180. "id": id,
  181. "isComplete": 1
  182. };
  183. if (file.type.indexOf('image') === 0) {
  184. data.pics = file_src;
  185. } else {
  186. data.videos = file_src;
  187. }
  188. recordVideos = file_src;
  189. post_common_service('q/record/update', data, function(redata) {
  190. cur_page = taskTableObj.options.pager.p_cur;
  191. queryTask();
  192. });
  193. },
  194. onFilesRemoved: function(files) {
  195. // alert(files);
  196. }
  197. });
  198. });
  199. }
  200. });
  201. $.zui.store.set('store_param_' + current_url, data);
  202. }
  203. function addTask() {
  204. is_save = 0;
  205. resert();
  206. // var contenthtml = base_ui_url+'qzd/view/task/addtask.html';
  207. // document.getElementById("addrecord").href = contenthtml;
  208. $('#addModal').modal('show');
  209. }
  210. function openUpload() {
  211. return $("#fileupload").click();
  212. }
  213. function checkUpdate(id) {
  214. resert();
  215. is_save = "_" + id;
  216. var data = {
  217. "id": id
  218. };
  219. post_common_service('q/record/one', data, function(redata) {
  220. $('#addModal').modal('show');
  221. $("#type").val(redata.type);
  222. $("#carinfo").val(redata.car_info);
  223. if (redata.arrive_time != null) {
  224. var time = moment(redata.arrive_time).format("YYYY-MM-DD HH:mm");
  225. $("#arrive_time").val(time);
  226. }
  227. if (redata.received_time != null) {
  228. time = moment(redata.received_time).format("YYYY-MM-DD HH:mm");
  229. $("#received_time").val(time);
  230. }
  231. if (redata.start_time != null) {
  232. time = moment(redata.start_time).format("YYYY-MM-DD HH:mm");
  233. $("#startTime").val(time);
  234. }
  235. if (redata.back_time != null) {
  236. time = moment(redata.back_time).format("YYYY-MM-DD HH:mm");
  237. $("#back_time").val(time);
  238. }
  239. if (redata.backfield_time != null) {
  240. time = moment(redata.backfield_time).format("YYYY-MM-DD HH:mm");
  241. $("#backfield_time").val(time);
  242. }
  243. if (redata.delivery_time != null) {
  244. time = moment(redata.delivery_time).format("YYYY-MM-DD HH:mm");
  245. $("#delivery_time").val(time);
  246. }
  247. if (redata.accept_time != null) {
  248. time = moment(redata.accept_time).format("YYYY-MM-DD HH:mm");
  249. $("#accept_time").val(time);
  250. }
  251. if (redata.rescue_time != null) {
  252. time = moment(redata.rescue_time).format("YYYY-MM-DD HH:mm");
  253. $("#rescue_time").val(time);
  254. }
  255. if (redata.relief_time != null) {
  256. time = moment(redata.relief_time).format("YYYY-MM-DD HH:mm");
  257. $("#relief_time").val(time);
  258. }
  259. $("#carUserinfo").val(redata.car_user_info);
  260. $("#dept").val(redata.dept);
  261. var userids = redata.users.split(",");
  262. setRecordUserID(userids);
  263. $("#carUserSatisfaction").val(redata.car_user_satisfaction);
  264. // var userids = redata.users.split(",");
  265. // setTimeout(function() {
  266. // for (var i in userids) {
  267. // $('span[data-id="' + userids[i] + '"] input').click();
  268. // }
  269. // }, 500);
  270. $("#recordUser").val(redata.userNames);
  271. $("#addr").val(redata.addr);
  272. })
  273. }
  274. function deleteRecord(id) {
  275. var data = {
  276. "id": id
  277. };
  278. post_common_service('q/record/delete', data, function(redata) {
  279. queryTask();
  280. });
  281. }
  282. function resert() {
  283. $("#type").val('1');
  284. $("#carinfo").val('');
  285. $("#arrive_time").val('');
  286. $("#received_time").val('');
  287. $("#startTime").val('');
  288. $("#back_time").val('');
  289. $("#backfield_time").val('');
  290. $("#delivery_time").val('');
  291. $("#accept_time").val('');
  292. $("#rescue_time").val('');
  293. $("#carUserinfo").val('');
  294. $("#dept").val('');
  295. $("#carUserSatisfaction").val('');
  296. $(".ComboTreeItemChlid").find("input").prop('checked', false);
  297. $("#recordUser").val('');
  298. $("#addr").val('');
  299. }
  300. function getRecord() {
  301. // var t = getTimeByMonth(GV("#start_time"));
  302. // var data = {
  303. // "startTime": getMomentTimeFormat(t.starttime),
  304. // "endTime": getMomentTimeFormat(t.endtime),
  305. // "dept": $("#deptlist").val(),
  306. // // "check_status": cur_status
  307. // };
  308. // post_common_service('q/record/getall/0/0', data, function(redata) {
  309. // console.log(redata);
  310. // for (var index in redata.records) {
  311. // var obj = redata.records[index];
  312. // var file_src = recordVideos;
  313. // $("#uploaderExample_" + obj.id).uploader({
  314. // autoUpload: true, // 当选择文件后立即自动进行上传操作
  315. // url: base_image_server_url + 'fileServer/file/upload', // 文件上传提交地址
  316. // chunk_size: 0,
  317. // filters: {
  318. // mime_types: [{
  319. // title: '视频',
  320. // extensions: 'mp4,avi'
  321. // }],
  322. // // 不允许上传重复文件
  323. // prevent_duplicates: true
  324. // },
  325. // onFileUploaded: function(file, responseObject) {
  326. // var datas = eval('(' + responseObject.response + ')');
  327. // if (file_src != '' && file_src != null) {
  328. // file_src += "," + datas.result_data.path;
  329. // } else {
  330. // file_src += datas.result_data.path;
  331. // }
  332. // var data = {
  333. // "videos": file_src,
  334. // "id": recordId
  335. // };
  336. // post_common_service('q/record/update', data, function(redata) {
  337. // queryTask();
  338. // });
  339. // },
  340. // onFilesRemoved: function(files) {
  341. // // alert(files);
  342. // }
  343. // });
  344. // }
  345. // });
  346. }
  347. function setRecordId(id, videos) {
  348. recordVideos = videos;
  349. recordId = id;
  350. }
  351. function removeVideo(id, videos, field, index) {
  352. var p = "";
  353. var recordVideos = videos;
  354. var recordId = id;
  355. var vvs = recordVideos.split(",");
  356. for (var i = 0; i < vvs.length; i++) {
  357. if (vvs[i] == undefined || vvs[i] == "undefined") { continue; }
  358. if (vvs[i].length > 0 && i != index) {
  359. p += vvs[i] + ",";
  360. }
  361. }
  362. p = p.substring(0, p.length - 1);
  363. var data = {
  364. "id": recordId
  365. };
  366. if (field == "videos") {
  367. data.videos = p;
  368. } else {
  369. data.pics = p;
  370. }
  371. post_common_service('q/record/update', data, function(redata) {
  372. queryTask();
  373. });
  374. }
  375. function saveMonitor(id){
  376. var data = {
  377. "id":id,
  378. "monitor": $("#select"+id).val(),
  379. "vice_monitor":$("#vselect"+id).val(),
  380. "isComplete":1
  381. }
  382. post_common_service('q/record/update', data, function(redata) {
  383. layer.msg('已添加', { icon: 1 });
  384. });
  385. }
  386. function setMonitor(){
  387. var dept = $("#dept").val();
  388. var userData = {
  389. "organid": dept
  390. }
  391. UserGetList(userData, function(data) {
  392. var monitor = new Array();
  393. var vice_monitor = new Array();
  394. for(var index in data){
  395. var u = data[index];
  396. if(u.positionid == 13){
  397. monitor.push(u);
  398. }else if(u.positionid == 14){
  399. vice_monitor.push(u);
  400. }
  401. }
  402. $.zui.store.set("monitor", monitor);
  403. $.zui.store.set("vice_monitor", vice_monitor);
  404. console.log($.zui.store.get("monitor"));
  405. console.log($.zui.store.get("vice_monitor"));
  406. });
  407. }