new.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  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. console.log(user.roles[0]);
  69. var t = getTimeByMonth(GV("#start_time"));
  70. var data = {
  71. "startTime": getMomentTimeFormat(t.starttime),
  72. "endTime": getMomentTimeFormat(t.endtime),
  73. "dept": $("#deptlist").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, hide: hide, colClass: 'text-center', field: 'car_info' },
  85. { width: 80, text: '客户信息', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'car_user_info' },
  86. { width: 120, text: '接警时间', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'received_time' },
  87. { width: 160, 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 (user.roles[0].id == 20 || user.roles[0].id == 21) {
  91. var colFunc = { width: 160, text: '操作', type: 'string', flex: true, field: 'id', colClass: 'text-center' };
  92. colFunc.oper = $.zui.store.get("task_table_btn_1");
  93. cols.push(colFunc);
  94. $("#saveButton").show();
  95. } else if (user.roles[0].id == 16 || user.roles[0].id == 17) {
  96. var colFunc = { width: 160, text: '操作', type: 'imagebutton', flex: true, field: 'videos', colClass: 'text-center' };
  97. colFunc.oper = $.zui.store.get("task_table_btn_1");
  98. cols.push(colFunc);
  99. }
  100. //只有下发才显示复选框
  101. var checkable = false;
  102. if ((hasRole(ROLE_JICHA_ADMIN) && cur_status == 4) || (roleContains("STATION") && cur_status == 5)) {
  103. checkable = true;
  104. }
  105. // console.log("checkable:" + checkable);
  106. // if (cur_status == 2 || cur_status == 3) {
  107. // data.check_status_arr = [2, 3];
  108. // data.check_status = null;
  109. // }
  110. taskTableObj = $('#task_list_table').mytable({
  111. 'cols': cols,
  112. 'checkable': checkable,
  113. 'url': "/q/record/getall/",
  114. 'param': data,
  115. 'pager': {
  116. 'p_cur': cur_page
  117. },
  118. renderfunction: function() {
  119. // console.log("-------------------------")
  120. $(".uploadervideo").each(function() {
  121. $(this).uploader({
  122. autoUpload: true, // 当选择文件后立即自动进行上传操作
  123. url: base_image_server_url + 'fileServer/file/upload', // 文件上传提交地址
  124. chunk_size: 0,
  125. filters: {
  126. mime_types: [{
  127. title: '视频',
  128. extensions: 'mp4,avi'
  129. }],
  130. // 不允许上传重复文件
  131. prevent_duplicates: true
  132. },
  133. onFileUploaded: function(file, responseObject) {
  134. var file_src = recordVideos;
  135. var datas = eval('(' + responseObject.response + ')');
  136. if (file_src != '' && file_src != null && file_src != undefined) {
  137. file_src += "," + datas.result_data.path;
  138. } else {
  139. file_src += datas.result_data.path;
  140. }
  141. var data = {
  142. "videos": file_src,
  143. "id": recordId
  144. };
  145. post_common_service('q/record/update', data, function(redata) {
  146. queryTask();
  147. });
  148. },
  149. onFilesRemoved: function(files) {
  150. // alert(files);
  151. }
  152. });
  153. });
  154. }
  155. });
  156. $.zui.store.set('store_param_' + current_url, data);
  157. }
  158. function addTask() {
  159. is_save = 0;
  160. resert();
  161. // var contenthtml = base_ui_url+'qzd/view/task/addtask.html';
  162. // document.getElementById("addrecord").href = contenthtml;
  163. $('#addModal').modal('show');
  164. }
  165. function openUpload() {
  166. return $("#fileupload").click();
  167. }
  168. function checkUpdate(id) {
  169. resert();
  170. is_save = "_" + id;
  171. var data = {
  172. "id": id
  173. };
  174. post_common_service('q/record/one', data, function(redata) {
  175. $('#addModal').modal('show');
  176. $("#type").val(redata.type);
  177. $("#carinfo").val(redata.car_info);
  178. var time = moment(redata.arrive_time).format("YYYY-MM-DD HH:mm:ss");
  179. $("#arrive_time").val(time);
  180. time = moment(redata.received_time).format("YYYY-MM-DD HH:mm:ss");
  181. $("#received_time").val(time);
  182. time = moment(redata.start_time).format("YYYY-MM-DD HH:mm:ss");
  183. $("#startTime").val(time);
  184. time = moment(redata.back_time).format("YYYY-MM-DD HH:mm:ss");
  185. $("#back_time").val(time);
  186. time = moment(redata.backfield_time).format("YYYY-MM-DD HH:mm:ss");
  187. $("#backfield_time").val(time);
  188. time = moment(redata.delivery_time).format("YYYY-MM-DD HH:mm:ss");
  189. $("#delivery_time").val(time);
  190. time = moment(redata.accept_time).format("YYYY-MM-DD HH:mm:ss");
  191. $("#accept_time").val(time);
  192. time = moment(redata.rescue_time).format("YYYY-MM-DD HH:mm:ss");
  193. $("#rescue_time").val(time);
  194. time = moment(redata.relief_time).format("YYYY-MM-DD HH:mm:ss");
  195. $("#relief_time").val(time);
  196. $("#carUserinfo").val(redata.car_user_info);
  197. $("#dept").val(redata.dept);
  198. $("#carUserSatisfaction").val(redata.car_user_satisfaction);
  199. var userids = redata.users.split(",");
  200. for (var i in userids) {
  201. $('span[data-id="' + userids[i] + '"] input').click();
  202. }
  203. $("#recordUser").val(redata.userNames);
  204. $("#addr").val(redata.addr);
  205. })
  206. }
  207. function deleteRecord(id) {
  208. var data = {
  209. "id": id
  210. };
  211. post_common_service('q/record/delete', data, function(redata) {
  212. queryTask();
  213. });
  214. }
  215. function resert() {
  216. $("#type").val('1');
  217. $("#carinfo").val('');
  218. $("#arrive_time").val('');
  219. $("#received_time").val('');
  220. $("#startTime").val('');
  221. $("#back_time").val('');
  222. $("#backfield_time").val('');
  223. $("#delivery_time").val('');
  224. $("#accept_time").val('');
  225. $("#rescue_time").val('');
  226. $("#carUserinfo").val('');
  227. $("#dept").val('');
  228. $("#carUserSatisfaction").val('');
  229. $(".ComboTreeItemChlid").find("input").prop('checked', false);
  230. $("#recordUser").val('');
  231. $("#addr").val('');
  232. }
  233. function getRecord() {
  234. // var t = getTimeByMonth(GV("#start_time"));
  235. // var data = {
  236. // "startTime": getMomentTimeFormat(t.starttime),
  237. // "endTime": getMomentTimeFormat(t.endtime),
  238. // "dept": $("#deptlist").val(),
  239. // // "check_status": cur_status
  240. // };
  241. // post_common_service('q/record/getall/0/0', data, function(redata) {
  242. // console.log(redata);
  243. // for (var index in redata.records) {
  244. // var obj = redata.records[index];
  245. // var file_src = recordVideos;
  246. // $("#uploaderExample_" + obj.id).uploader({
  247. // autoUpload: true, // 当选择文件后立即自动进行上传操作
  248. // url: base_image_server_url + 'fileServer/file/upload', // 文件上传提交地址
  249. // chunk_size: 0,
  250. // filters: {
  251. // mime_types: [{
  252. // title: '视频',
  253. // extensions: 'mp4,avi'
  254. // }],
  255. // // 不允许上传重复文件
  256. // prevent_duplicates: true
  257. // },
  258. // onFileUploaded: function(file, responseObject) {
  259. // var datas = eval('(' + responseObject.response + ')');
  260. // if (file_src != '' && file_src != null) {
  261. // file_src += "," + datas.result_data.path;
  262. // } else {
  263. // file_src += datas.result_data.path;
  264. // }
  265. // var data = {
  266. // "videos": file_src,
  267. // "id": recordId
  268. // };
  269. // post_common_service('q/record/update', data, function(redata) {
  270. // queryTask();
  271. // });
  272. // },
  273. // onFilesRemoved: function(files) {
  274. // // alert(files);
  275. // }
  276. // });
  277. // }
  278. // });
  279. }
  280. function setRecordId(id, videos) {
  281. recordVideos = videos;
  282. recordId = id;
  283. }
  284. function removeVideo(id, videos, index) {
  285. var p = "";
  286. var recordVideos = videos;
  287. var recordId = id;
  288. var vvs = recordVideos.split(",");
  289. for (var i = 0; i < vvs.length; i++) {
  290. console.log(vvs)
  291. if (vvs[i].length > 0 && i != index) {
  292. p += vvs[i] + ",";
  293. }
  294. }
  295. p = p.substring(0, p.length - 1);
  296. var data = {
  297. "videos": p,
  298. "id": recordId
  299. };
  300. post_common_service('q/record/update', data, function(redata) {
  301. queryTask();
  302. });
  303. }