task_list.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. var cur_status;
  2. var cur_page;
  3. function initTaskPage() {
  4. initQueryParams();
  5. initTableRowBtn();
  6. queryTask();
  7. }
  8. function initQueryParams() {
  9. $("#start_time").datetimepicker({
  10. language: "zh-CN",
  11. weekStart: 1,
  12. todayBtn: 1,
  13. autoclose: 1,
  14. todayHighlight: 1,
  15. startView: 2,
  16. minView: 2,
  17. forceParse: 0,
  18. format: "yyyy-mm-dd"
  19. });
  20. // 仅选择日期
  21. $("#end_time").datetimepicker({
  22. language: "zh-CN",
  23. weekStart: 1,
  24. todayBtn: 1,
  25. autoclose: 1,
  26. todayHighlight: 1,
  27. startView: 2,
  28. minView: 2,
  29. forceParse: 0,
  30. format: "yyyy-mm-dd"
  31. });
  32. var store_params = $.zui.store.get('store_param_' + current_url);
  33. var checked_dept = null;
  34. if (store_params) {
  35. checked_dept = store_params.checked_dept;
  36. // $("#start_time").val(store_params.end_time.substr(0, 7));
  37. $("#start_time").val(store_params.start_time.substr(0, 11));
  38. $("#end_time").val(store_params.end_time.substr(0, 11));
  39. $("#hasScoreList").val(store_params.hasScore);
  40. cur_page = store_params.currentpage;
  41. } else {
  42. var cm = getCurrentRealTimeFormat();
  43. var tyt = getTimeByMonth(cm);
  44. $("#start_time").val((tyt.starttime.add(1, "d")).format("YYYY-MM-DD"));
  45. $("#end_time").val(tyt.endtime.format("YYYY-MM-DD"));
  46. // $("#start_time").val(getCurrentRealTimeFormat());
  47. }
  48. var page_params = $.zui.store.get("page_params");
  49. if (page_params && page_params.status) {
  50. cur_status = page_params.status;
  51. }
  52. if (roleContains("FWQ")) {
  53. checked_dept = getCurrentUser().organid;
  54. }
  55. setWreckerGroupSelect("#qzd", checked_dept);
  56. if (hasRole(ROLE_JICHA_ADMIN) && cur_status == 4) {
  57. $("#dispatchPatchBtn").show();
  58. $("#dispatchAllNoScoreBtn").show();
  59. }
  60. if (roleContains("STATION") && cur_status == 5) {
  61. $("#confirmPatchBtn").show();
  62. }
  63. $("#checkPersonDiv").show();
  64. if (cur_status == 4 || cur_status == 5 || cur_status == 6) {
  65. $("#hasScoreDiv").show();
  66. }
  67. }
  68. //初始化表行按钮
  69. function initTableRowBtn() {
  70. $.zui.store.set("task_table_btn_2", [{ func: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  71. $.zui.store.set("task_table_btn_3", [{ func: 'showCheck', text: '开始稽查', icon_class: 'icon-eye-open' }]);
  72. $.zui.store.set("task_table_btn_7", [{ func: 'showContinueCheck', text: '继续稽查', icon_class: 'icon-eye-open' }]);
  73. $.zui.store.set("task_table_btn_4", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' },
  74. { func: 'dispatchTaskById', text: '下发', icon_class: 'icon-signin' }
  75. ]);
  76. $.zui.store.set("task_table_btn_5", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' }]);
  77. $.zui.store.set("task_table_btn_6", [{ func: 'showTaskDetail', text: '详情', icon_class: 'icon-tasks' }]);
  78. $.zui.store.set("task_table_btn_21", [{ func: 'showApplyDetail', text: '处理', icon_class: 'icon-hand-up' }]);
  79. }
  80. //查询任务
  81. function queryTask() {
  82. var start_time = "";
  83. if ($("#start_time").val()) start_time = (moment($("#start_time").val()).subtract(1, "d")).format("YYYY-MM-DD") + " 23:00:00";
  84. var end_time = "";
  85. if ($("#end_time").val()) end_time = $("#end_time").val() + " 23:00:00";
  86. var data = {
  87. "start_time": (start_time),
  88. "end_time": (end_time),
  89. "checked_dept": $("#qzd").val(),
  90. "check_status": cur_status
  91. };
  92. console.log(data);
  93. var hide = false;
  94. if (hasRole(ROLE_QZD_ADMIN) || hasRole(ROLE_QZD) || hasRole(ROLE_JICHA) || roleContains('QZD')) {
  95. hide = true;
  96. }
  97. var cols = [
  98. { width: 80, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  99. { width: 160, text: '任务名称', type: 'string', flex: true, sort: 'down', field: 'name' },
  100. { width: 160, text: '考核部门', type: 'string', flex: true, sort: 'down', field: 'checked_dept_name' },
  101. { width: 80, text: '稽查人员', type: 'string', flex: true, hide: hide, colClass: '', field: 'checkman_name' },
  102. { width: 160, text: '稽查时间段', type: 'string', flex: true, sort: 'down', field: 'check_period' },
  103. // {width: 120, text: '状态', type: 'string', flex: true, colClass: '',field: 'check_status_name'}
  104. ];
  105. var colFunc = { width: 120, text: '操作', type: 'string', flex: true, field: 'id' };
  106. colFunc.oper = $.zui.store.get("task_table_btn_" + cur_status);
  107. cols.push(colFunc);
  108. //只有下发才显示复选框
  109. var checkable = false;
  110. if ((hasRole(ROLE_JICHA_ADMIN) && cur_status == 4) || (roleContains("STATION") && cur_status == 5)) {
  111. checkable = true;
  112. }
  113. // console.log("checkable:" + checkable);
  114. if (cur_status == 2 || cur_status == 3) {
  115. data.check_status_arr = [2, 3];
  116. data.check_status = null;
  117. }
  118. taskTableObj = $('#task_list_table').mytable({
  119. 'cols': cols,
  120. 'checkable': checkable,
  121. 'url': "/q/task/getall/",
  122. 'param': data,
  123. 'pager': {
  124. 'p_cur': cur_page
  125. }
  126. });
  127. $.zui.store.set('store_param_' + current_url, data);
  128. }
  129. //进入稽查页面
  130. function showCheck(id) {
  131. // $('#myModal').modal({name:"dd"});
  132. $.checkTask = getItemByIdFromArr(id, $('#task_list_table').mytable('getTableData'));
  133. $.checkTask.appeal = null;
  134. //开始稽查
  135. no_return_common_service('/q/task/update', { "id": $.checkTask.id, "check_status": 3 });
  136. changePage("/qzd/view/task/check.html", taskTableObj);
  137. }
  138. //任务详情页面
  139. function showTaskDetail(id) {
  140. var rowData = getItemByIdFromArr(id, $('#task_list_table').mytable('getTableData'));
  141. $.checkTask = rowData;
  142. if (typeof($.checkTask) != "undefined" && typeof($.checkTask.appeal) != "undefined") {
  143. $.checkTask.appeal = null;
  144. }
  145. changePage("/qzd/view/task/taskDetail.html", taskTableObj);
  146. }
  147. //进入继续稽查页面
  148. function showContinueCheck(id) {
  149. // $('#myModal').modal({name:"dd"});
  150. $.checkTask = getItemByIdFromArr(id, $('#task_list_table').mytable('getTableData'));
  151. $.checkTask.appeal = null;
  152. changePage("/qzd/view/task/check.html", taskTableObj);
  153. }
  154. //下发所有任务
  155. function dispatchTaskPatch() {
  156. var param = {
  157. "check_status": 4,
  158. "dispatch_ids": $('#task_list_table').mytable('getTableCheckedIds')
  159. }
  160. // console.log("放假啦:"+param.dispatch_ids);
  161. if (!param.dispatch_ids || param.dispatch_ids.length == 0) {
  162. layer.msg('请选择下发任务!', {
  163. time: 2000 //20s后自动关闭
  164. });
  165. return;
  166. }
  167. layer.confirm('确定下发选中任务?', {
  168. btn: ['确定', '取消'] //按钮
  169. }, function() {
  170. no_return_common_service('/f/task/dispatch', param, function(data) {
  171. queryTask();
  172. layer.msg(data, {
  173. time: 2000 //20s后自动关闭
  174. });
  175. });
  176. }, function(index) {
  177. layer.close(index);
  178. });
  179. var datas = $('#task_list_table').mytable('getTableData');
  180. // console.log(datas);
  181. }
  182. //下发单条任务
  183. function dispatchTaskById(id) {
  184. alert(id);
  185. layer.confirm('确定下发任务?', {
  186. btn: ['确定', '取消'] //按钮
  187. }, function() {
  188. var param = {
  189. "id": id,
  190. "check_status": 5
  191. }
  192. no_return_common_service('/q/task/dispatchById', param, function(data) {
  193. queryTask();
  194. layer.msg(data, {
  195. time: 2000 //20s后自动关闭
  196. });
  197. });
  198. }, function(index) {
  199. layer.close(index);
  200. });
  201. }
  202. function dispatchAllNoScoreTask() {
  203. layer.confirm('确定下发选择时间内所有无扣分任务?', {
  204. btn: ['确定', '取消'] //按钮
  205. }, function() {
  206. var t = getTimeByMonth(GV("#start_time"));
  207. var param = {
  208. "start_time": getMomentTimeFormat(t.starttime),
  209. "end_time": getMomentTimeFormat(t.endtime),
  210. };
  211. no_return_common_service('/f/task/dispatchAllNoScoreTask', param, function(data) {
  212. queryTask();
  213. layer.msg(data, {
  214. time: 2000 //20s后自动关闭
  215. });
  216. });
  217. }, function(index) {
  218. layer.close(index);
  219. });
  220. }
  221. function confirmTaskPatch() {
  222. var param = {
  223. "check_status": 5,
  224. "dispatch_ids": $('#task_list_table').mytable('getTableCheckedIds')
  225. }
  226. if (!param.dispatch_ids) {
  227. layer.msg("请选择需确认任务!", {
  228. time: 2000 //20s后自动关闭
  229. });
  230. return;
  231. }
  232. layer.confirm('确定确认选中任务?', {
  233. btn: ['确定', '取消'] //按钮
  234. }, function() {
  235. no_return_common_service('/q/task/confirm', param, function(data) {
  236. queryTask();
  237. layer.msg(data, {
  238. time: 2000 //20s后自动关闭
  239. });
  240. });
  241. }, function(index) {
  242. layer.close(index);
  243. });
  244. }
  245. function gettask(){
  246. param={"check_status":2};
  247. post_common_service('/q/task/getall/0/0', param, function(redata) {
  248. console.log(redata);
  249. //inittAreaable($("#month_date").val(), $("#qzd").val());
  250. });
  251. }