new.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. var cur_status;
  2. var cur_page;
  3. var is_save;
  4. var updateid = null;
  5. var user = $.zui.store.get("user")
  6. $("#fileupload").change(function() {
  7. UpladFile();
  8. });
  9. function initTaskPage() {
  10. initQueryParams();
  11. initTableRowBtn();
  12. queryTask();
  13. // getRecord();
  14. }
  15. function initQueryParams() {
  16. // 仅选择日期
  17. $.jeDate("#start_time", {
  18. isinitVal: true,
  19. format: 'YYYY/MM' // 分隔符可以任意定义,该例子表示只显示年月
  20. });
  21. $("#start_time").val(getCurrentTimeFormat());
  22. var page_params = $.zui.store.get("page_params");
  23. if (page_params && page_params.status) {
  24. cur_status = page_params.status;
  25. }
  26. var checked_dept = null;
  27. if (roleContains("FWQ")) {
  28. checked_dept = getCurrentUser().organid;
  29. }
  30. setWreckerGroupSelect("#deptlist", checked_dept);
  31. setWreckerGroupSelect("#dept", checked_dept);
  32. if (hasRole(ROLE_JICHA_ADMIN) && cur_status == 4) {
  33. $("#dispatchPatchBtn").show();
  34. $("#dispatchAllNoScoreBtn").show();
  35. }
  36. if (roleContains("STATION") && cur_status == 5) {
  37. $("#confirmPatchBtn").show();
  38. }
  39. $("#checkPersonDiv").show();
  40. if (cur_status == 4 || cur_status == 5 || cur_status == 6) {
  41. $("#hasScoreDiv").show();
  42. }
  43. }
  44. //初始化表行按钮
  45. function initTableRowBtn() {
  46. $.zui.store.set("task_table_btn_1", [{ func: 'checkUpdate', text: '修改', icon_class: '' },
  47. { func: 'deleteRecord', text: '删除', icon_class: 'text-center' }
  48. ]);
  49. $.zui.store.set("task_table_btn_2", [{ func: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  50. // $.zui.store.set("task_table_btn_2", [{ func: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  51. // $.zui.store.set("task_table_btn_3", [{ func: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  52. // $.zui.store.set("task_table_btn_7", [{ func: 'showContinueCheck', text: '继续稽查', icon_class: 'icon-eye-open' }]);
  53. // $.zui.store.set("task_table_btn_4", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' },
  54. // { func: 'dispatchTaskById', text: '下发', icon_class: 'icon-signin' }
  55. // ]);
  56. // $.zui.store.set("task_table_btn_5", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' }]);
  57. // $.zui.store.set("task_table_btn_6", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' }]);
  58. // $.zui.store.set("task_table_btn_21", [{ func: 'showApplyDetail', text: '处理', icon_class: 'icon-hand-up' }]);
  59. }
  60. //查询任务
  61. function queryTask() {
  62. console.log(user.roles[0]);
  63. var t = getTimeByMonth(GV("#start_time"));
  64. var data = {
  65. "startTime": getMomentTimeFormat(t.starttime),
  66. "endTime": getMomentTimeFormat(t.endtime),
  67. "dept": $("#deptlist").val(),
  68. // "check_status": cur_status
  69. };
  70. var hide = false;
  71. if (hasRole(ROLE_QZD_ADMIN) || hasRole(ROLE_QZD) || hasRole(ROLE_JICHA) || roleContains('QZD')) {
  72. hide = true;
  73. }
  74. var cols = [
  75. { width: 80, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  76. { width: 80, text: '清障队', type: 'string', flex: true, colClass: 'text-center', sort: 'down', field: 'deptName' },
  77. { width: 80, text: '桩号', type: 'string', flex: true, colClass: 'text-center', sort: 'down', field: 'addr' },
  78. { width: 80, text: '车牌号', type: 'string', flex: true, hide: hide, colClass: 'text-center', field: 'car_info' },
  79. { width: 80, text: '客户信息', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'car_user_info' },
  80. { width: 120, text: '接警时间', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'received_time' },
  81. { width: 160, text: '出勤人员', type: 'string', flex: true, sort: 'down', colClass: 'text-center', field: 'userNames' },
  82. // {width: 120, text: '状态', type: 'string', flex: true, colClass: '',field: 'check_status_name'}
  83. ];
  84. user.roles[0].id = 1;
  85. if (user.roles[0].id == 1) {
  86. var colFunc = { width: 160, text: '操作', type: 'string', flex: true, field: 'id', colClass: 'text-center' };
  87. colFunc.oper = $.zui.store.get("task_table_btn_1");
  88. cols.push(colFunc);
  89. $("#saveButton").show();
  90. } else if (user.roles[0].id == 16 || user.roles[0].id == 17) {
  91. var colFunc = { width: 160, text: '操作', type: 'imagebutton', flex: true, field: 'pics', colClass: 'text-center' };
  92. colFunc.oper = $.zui.store.get("task_table_btn_1");
  93. cols.push(colFunc);
  94. }
  95. //只有下发才显示复选框
  96. var checkable = false;
  97. if ((hasRole(ROLE_JICHA_ADMIN) && cur_status == 4) || (roleContains("STATION") && cur_status == 5)) {
  98. checkable = true;
  99. }
  100. // console.log("checkable:" + checkable);
  101. // if (cur_status == 2 || cur_status == 3) {
  102. // data.check_status_arr = [2, 3];
  103. // data.check_status = null;
  104. // }
  105. taskTableObj = $('#task_list_table').mytable({
  106. 'cols': cols,
  107. 'checkable': checkable,
  108. 'url': "/q/record/getall/",
  109. 'param': data,
  110. 'pager': {
  111. 'p_cur': cur_page
  112. },
  113. });
  114. $.zui.store.set('store_param_' + current_url, data);
  115. }
  116. function addTask() {
  117. is_save = 0;
  118. resert();
  119. // var contenthtml = base_ui_url+'qzd/view/task/addtask.html';
  120. // document.getElementById("addrecord").href = contenthtml;
  121. $('#addModal').modal('show');
  122. }
  123. function openUpload() {
  124. return $("#fileupload").click();
  125. }
  126. function UpladFile() {
  127. var fileObj = document.getElementById("fileupload").files[0]; // 获取文件对象
  128. // var FileController = base_image_server_url +'fileServer/file/upload';// 接收上传文件的后台地址
  129. // FormData 对象
  130. // var form = new FormData();
  131. // form.append("name", "hooyes"); // 可以增加表单数据
  132. // form.append("file", fileObj); // 文件对象
  133. uploadFile(fileObj, "file", function(data) {
  134. addPic(base_image_server_url + data.path);
  135. }, function(error) {
  136. console.log(error)
  137. }, "task");
  138. }
  139. function checkUpdate(id) {
  140. is_save = "_" + id;
  141. var data = {
  142. "id": id
  143. };
  144. post_common_service('q/record/one', data, function(redata) {
  145. $('#addModal').modal('show');
  146. $("#type").val(redata.type);
  147. $("#carinfo").val(redata.car_info);
  148. var time = moment(redata.arrive_time).format("YYYY-MM-DD HH:mm:ss");
  149. $("#arrive_time").val(time);
  150. time = moment(redata.received_time).format("YYYY-MM-DD HH:mm:ss");
  151. $("#received_time").val(time);
  152. time = moment(redata.start_time).format("YYYY-MM-DD HH:mm:ss");
  153. $("#startTime").val(time);
  154. time = moment(redata.back_time).format("YYYY-MM-DD HH:mm:ss");
  155. $("#back_time").val(time);
  156. time = moment(redata.backfield_time).format("YYYY-MM-DD HH:mm:ss");
  157. $("#backfield_time").val(time);
  158. time = moment(redata.delivery_time).format("YYYY-MM-DD HH:mm:ss");
  159. $("#delivery_time").val(time);
  160. time = moment(redata.accept_time).format("YYYY-MM-DD HH:mm:ss");
  161. $("#accept_time").val(time);
  162. time = moment(redata.rescue_time).format("YYYY-MM-DD HH:mm:ss");
  163. $("#rescue_time").val(time);
  164. time = moment(redata.relief_time).format("YYYY-MM-DD HH:mm:ss");
  165. $("#relief_time").val(time);
  166. $("#carUserinfo").val(redata.car_user_info);
  167. $("#dept").val(redata.dept);
  168. $("#carUserSatisfaction").val(redata.car_user_satisfaction);
  169. var userids = redata.users.split(",");
  170. for (var i in userids) {
  171. $('span[data-id="' + userids[i] + '"] input').click();
  172. }
  173. $("#recordUser").val(redata.userNames);
  174. $("#addr").val(redata.addr);
  175. })
  176. }
  177. function deleteRecord(id) {
  178. var data = {
  179. "id": id
  180. };
  181. post_common_service('q/record/delete', data, function(redata) {
  182. queryTask();
  183. });
  184. }
  185. function resert() {
  186. $("#type").val('1');
  187. $("#carinfo").val('');
  188. $("#startTime").val('');
  189. $("#carUserinfo").val('');
  190. $("#dept").val('');
  191. $("#carUserSatisfaction").val('');
  192. $(".ComboTreeItemChlid").find("input").prop('checked', false);
  193. $("#recordUser").val('');
  194. $("#addr").val('');
  195. }
  196. function getRecord() {
  197. var data = {
  198. // "startTime": new Date(getMomentTimeFormat(t.starttime)),
  199. // "endTime":new Date(getMomentTimeFormat(t.endtime)),
  200. "dept": $("#deptlist").val(),
  201. // "check_status": cur_status
  202. };
  203. post_common_service('q/record/getall/0/0', data, function(redata) {
  204. console.log(redata);
  205. });
  206. }