check.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. function initCheck() {
  2. addBreadMenu("/view/mytask/check.html", "视频稽查");
  3. $('#ex1').slider({ tooltip: 'hide' });
  4. $("#ex1").on("slideStop", function(slideEvt) {
  5. setVideoProcess(slideEvt.value);
  6. });
  7. $("#tabcontent").css("height", ($("#video_content").height() - 80) + "px");
  8. if (ISCLIENT) {
  9. event = document.createEvent('MessageEvent');
  10. var origin = window.location.protocol + '//' + window.location.host;
  11. event.initMessageEvent('setvideoposition', true, true, getVideoPosition(null), origin, 1234, window, null);
  12. document.dispatchEvent(event);
  13. }
  14. // 仅选择日期
  15. $("#start-time").datetimepicker({
  16. language: "zh-CN",
  17. weekStart: 1,
  18. todayBtn: 1,
  19. autoclose: 1,
  20. todayHighlight: 1,
  21. startView: 2,
  22. minView: 2,
  23. forceParse: 0,
  24. format: "yyyy-mm-dd"
  25. });
  26. // 仅选择日期
  27. $("#end-time").datetimepicker({
  28. language: "zh-CN",
  29. weekStart: 1,
  30. todayBtn: 1,
  31. autoclose: 1,
  32. todayHighlight: 1,
  33. startView: 2,
  34. minView: 2,
  35. forceParse: 0,
  36. format: "yyyy-mm-dd"
  37. });
  38. if ($.checkTask) {
  39. getUserCheckCount();
  40. initCheckAppealBtns();
  41. setFeSelect("#fsList", $.checkTask.checked_dept);
  42. // setFeeUserSelect("#check_checked_person_select", $.checkTask.checked_person);
  43. // $("#fsList").on("change",function(){
  44. // $.checkTask.checked_dept = this.value;
  45. // })
  46. $("#lane").val($.checkTask.checked_location);
  47. // setLaneSelect("#lane", $.checkTask.checked_location);
  48. get_common_service('user/getUserById/' + $.checkTask.checked_person, null, function(data) {
  49. changePersonContent(data);
  50. })
  51. //查询评分情况
  52. queryCheckScores();
  53. //查询录像播放列表
  54. var videos = $.checkTask.video_id.split(',');
  55. if (videos[0]) {
  56. curVideo = videos[0];
  57. queryVideoList();
  58. } else {
  59. callFunc("showvideoview", "false");
  60. layer.msg('该处暂无视屏!', {
  61. time: 2000, //20s后自动关闭
  62. });
  63. callFunc("stop", "");
  64. }
  65. }
  66. $("select#video_list").change(function() {
  67. playVideo($(this).val());
  68. });
  69. }
  70. function setfastorslow(type, speed) {
  71. if (type == 0) {
  72. $("#fast_info").html("");
  73. $("#slow_info").html("");
  74. if ($("#full_fast_info")) {
  75. $("#full_fast_info").html("");
  76. $("#full_slow_info").html("");
  77. }
  78. }
  79. if (type == 1) {
  80. $("#fast_info").html(speed + "x");
  81. $("#slow_info").html("");
  82. if ($("#full_fast_info")) {
  83. $("#full_fast_info").html(speed + "x");
  84. $("#full_slow_info").html("");
  85. }
  86. }
  87. if (type == 2) {
  88. $("#slow_info").html(speed + "x");
  89. $("#fast_info").html("");
  90. if ($("#full_fast_info")) {
  91. $("#full_fast_info").html("");
  92. $("#full_slow_info").html(speed + "x");
  93. }
  94. }
  95. }
  96. function normalscreen() {
  97. if (layer_full) {
  98. layer.close(layer_full)
  99. }
  100. }
  101. var layer_full = null;
  102. function fullscreen() {
  103. var height = window.innerWidth * 0.8 * 1 / 2.0 + 90
  104. var contenthtml = ' <div class="tab-content" id="full_tabcontent" style="height:400px;text-align: center;background:black;">' +
  105. ' <p style="padding-top:180px;font-size:20px">加载中...</p>' +
  106. ' <!--<i class="icon icon-spin icon-spinner icon-5x" style="margin-top:100px"></i>-->' +
  107. ' </div>' +
  108. ' <div class="row" class="col-md-12" style="padding:5px 10px 5px 10px;text-align:center;margin:0px">' +
  109. ' <input id="full_ex1" class="col-md-12" type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="0"' +
  110. ' />' +
  111. ' </div>' +
  112. ' <div class="row" style="padding:0px 5px 0px 5px;text-align:center;margin:0px">' +
  113. ' <select class="form-control" id="full_video_list" style="width:200px;float:left;display:none;"></select>' +
  114. ' <div class="col-md-4 hidden" style="padding-left:0">' +
  115. ' <div class="input-group" style="padding-left:0">' +
  116. ' <input type="text" id="full_video_pos" style="height:42px" class="form-control" placeholder="时间偏移值">' +
  117. ' <span class="input-group-btn">' +
  118. ' <button class="btn btn-default" onclick="setVideoPos()" style="height:42px" type="button">校正</button>' +
  119. ' </span>' +
  120. ' </div>' +
  121. ' </div>' +
  122. ' <div class="btn-group" style="float:right;">' +
  123. ' <button type="button" class="btn btn-info" onclick="doAction(\'start\')"><i class="icon icon-play-circle icon-2x"></i></button>' +
  124. ' <button type="button" class="btn btn-info" onclick="doAction(\'stop\')"><i class="icon icon-pause icon-2x"></i></button>' +
  125. ' <button type="button" class="btn btn-info" onclick="doAction(\'fast\')"><i class="icon icon-forward icon-2x"></i><span id=\"full_fast_info\"></span></button>' +
  126. ' <button type="button" class="btn btn-info" onclick="doAction(\'slow\')"><span id=\"full_slow_info\"></span><i class="icon icon-backward icon-2x"></i></button>' +
  127. ' <button type="button" class="btn btn-danger hidden" style="width:51px;height:42px" id="full_video_btn_start" onclick="doAction(\'video_start\')"><img style="width:30px" src="/images/movie.png"></img></i></button>' +
  128. ' <button type="button" class="btn btn-danger hidden" style="width:51px;height:42px" id="full_video_btn_stop" onclick="doAction(\'video_stop\')"><i class="icon icon-stop icon-2x"></i></button>' +
  129. ' <button type="button" class="btn btn-success" onclick="doAction(\'screenshot\')"><i class="icon icon-camera icon-2x"></i></button>' +
  130. ' </div>' +
  131. ' </div>';
  132. layer_full = layer.open({
  133. area: ['80%', height + "px"],
  134. type: 1,
  135. title: false,
  136. anim: -1,
  137. closeBtn: 0,
  138. shadeClose: false,
  139. content: "<div id='layer_content' >" + contenthtml + "</div>",
  140. success: function(layero, index) {
  141. $("#full_video_pos").val($("#video_pos").val());
  142. $('#full_ex1').slider({ tooltip: 'hide' });
  143. $("#full_ex1").on("slideStop", function(slideEvt) {
  144. setVideoProcess(slideEvt.value);
  145. });
  146. $("#full_ex1").val($("#ex1").value)
  147. $("#full_ex1").slider({ step: 5, min: 0, max: maxVV });
  148. $("#full_fast_info").html($("#fast_info").html());
  149. $("#full_slow_info").html($("#slow_info").html());
  150. $("#full_tabcontent").css("height", (height - 90) + "px");
  151. $("#full_tabcontent").css("width", "100%");
  152. setTimeout(function() {
  153. callFunc("setvideoposition", getVideoPosition($("#full_tabcontent")))
  154. }, 800)
  155. }
  156. });
  157. }
  158. function getUserCheckCount() {
  159. var param = {
  160. "id": $.checkTask.id,
  161. "checked_person": $.checkTask.checked_person
  162. };
  163. post_common_service("/task/getUserCount/", param, function (userList) {
  164. if(userList){
  165. $("#checked_count").html(userList.length);
  166. }else{
  167. $("#checked_count").html(0);
  168. }
  169. });
  170. }
  171. function checkUserCount() {
  172. var param = {
  173. "id":$.checkTask.id,
  174. "checked_person":$.checkTask.checked_person,
  175. "class_type":$.checkTask.class_type
  176. };
  177. post_common_service("/task/getUserCount/", param, function(data){
  178. if(data>=2){
  179. layer.msg("本周期稽查次数已满,不能再被稽查!", {
  180. time: 2000//20s后自动关闭
  181. });
  182. return false;
  183. }
  184. return true;
  185. });
  186. }
  187. function showCheckDetailCount(){
  188. }
  189. function initCheckAppealBtns() {
  190. if ($.checkTask.appeal) {
  191. $("#btn_appeal_task").show();
  192. $("#btn_task").hide();
  193. $("#appeal_div").show();
  194. $("#appeal_time").html($.checkTask.appeal.appeal_time);
  195. $("#appeal_reason").html($.checkTask.appeal.appeal_reason);
  196. $("#appeal_file_list").html(genAppeaFiles($.checkTask.appeal.file_src));
  197. $("#recheck_result").html($.checkTask.appeal.recheck_result);
  198. layer.open({
  199. type: 1,
  200. title: "申诉详情",
  201. closeBtn: 0,
  202. shade: false,
  203. maxmin: false,
  204. shadeClose: true,
  205. offset: 'rb',
  206. content: $('#appeal_div'), //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
  207. // min: function (index) {
  208. // // layer.close(index);
  209. // layer.style(index,{width: 50,height:50});
  210. // return false;
  211. // },
  212. // cancel:function(index){
  213. // layer.style(index,{width: 50,height:50,offset:'r'});
  214. // return false;
  215. // }
  216. });
  217. } else {
  218. $("#appeal_div").hide();
  219. $("#btn_appeal_task").hide();
  220. $("#btn_task").show();
  221. }
  222. }
  223. // 使用data参数更新数据:
  224. function queryCheckScores() {
  225. //$('#score_datatable').score_datatable("");
  226. console.log("任务id:" + $.checkTask.id);
  227. var data = {
  228. "task_id": $.checkTask.id
  229. }
  230. // alert("ff");
  231. var cols = [
  232. { width: 40, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  233. { width: 160, text: '评分记录', type: 'string', flex: true, sort: 'down', field: 'content' },
  234. { width: 50, text: '分数', type: 'string', flex: true, colClass: '', field: 'check_item_score' },
  235. { width: 100, text: '备注', type: 'string', flex: true, colClass: '', field: 'remark' },
  236. { width: 55, text: '考核人', type: 'string', flex: true, colClass: '', field: 'checked_person_name' },
  237. // {width: 80, text: '图片', type: 'imagedd', flex: true, colClass: '',field: 'pics'},
  238. {
  239. width: 110,
  240. text: '操作',
  241. type: 'string',
  242. flex: true,
  243. field: 'id',
  244. oper: [
  245. { func: 'showEditCheckScore', text: '修改', icon_class: 'icon-edit' },
  246. { func: 'showEditPic', text: '修改图片', icon_class: 'icon-edit' },
  247. { func: 'deleteCheckScore', text: '删除', icon_class: 'icon-remove-circle' }
  248. ]
  249. }
  250. ];
  251. // var pager = {
  252. // page_size:10
  253. // }
  254. $('#score_datatable').mytable({
  255. 'cols': cols,
  256. 'url': "/score/getScoreList/",
  257. 'param': data
  258. });
  259. }
  260. function showEditPic(id) {
  261. var rowData = getItemByIdFromArr(id, $('#score_datatable').mytable('getTableData'));
  262. showPics(rowData.pics);
  263. $("#saveEditBtn").show();
  264. editScoreId = id;
  265. }
  266. function showEditCheckScore(id) {
  267. // deleteItem4Common(id,"/score/delete/",queryCheckScores);
  268. var rowData = getItemByIdFromArr(id, $('#score_datatable').mytable('getTableData'));
  269. scoreDetailLayer = showPopup4Common('修改考核项', function(data) {
  270. saveScoreEdit();
  271. }, ['350px', '550px'], '#score-detail-div', 'r');
  272. $("#score_id_text").val(rowData.id);
  273. $("#check_item_text").val(rowData.content);
  274. $("#check_score_text").val(rowData.check_item_score);
  275. $("#check_remark_text").val(rowData.remark);
  276. setFeeUserSelect("#check_checked_person_select", rowData.checked_person);
  277. // $("#check_checked_person_select").val(rowData.checked_person);
  278. }
  279. function setFeeUserSelect(div, selectId) {
  280. var param = {
  281. 'organid': $.checkTask.checked_dept
  282. };
  283. post_common_service("/user/getUserList/", param, function(userList) {
  284. // setFeeUserSelect("#check_checked_person_select",rowData.checked_person,data);
  285. var optStr = '';
  286. for (var i in userList) {
  287. if (userList[i].id == selectId)
  288. optStr += '<option value="' + userList[i].id + '" selected="selected">' + userList[i].truename + '</option>';
  289. else
  290. optStr += '<option value="' + userList[i].id + '">' + userList[i].truename + '</option>';
  291. }
  292. $(div).html('');
  293. $(div).html(optStr);
  294. $('#check_checked_person_select').chosen({
  295. // width:'200px',
  296. height: '100px',
  297. no_results_text: '没有找到', // 当检索时没有找到匹配项时显示的提示文本
  298. disable_search_threshold: 10, // 10 个以下的选择项则不显示检索框
  299. search_contains: true // 从任意位置开始检索
  300. });
  301. });
  302. }
  303. function saveScoreEdit() {
  304. var param = {
  305. 'id': $("#score_id_text").val(),
  306. 'content': $("#check_item_text").val(),
  307. 'check_item_score': $("#check_score_text").val(),
  308. 'remark': $("#check_remark_text").val(),
  309. 'checked_person': $("#check_checked_person_select").val(),
  310. };
  311. editScoreId = null;
  312. $("#saveEditBtn").hide();
  313. no_return_common_service("/score/update", param, function(data) {
  314. if (scoreLayer) layer.close(scoreLayer);
  315. //查询评分情况
  316. queryCheckScores();
  317. // layer.msg(data, {
  318. // time: 2000//20s后自动关闭
  319. // });
  320. });
  321. }
  322. var editScoreId;
  323. function saveEdit() {
  324. if (editScoreId) {
  325. var imgArr = $("#img_container .pic-class");
  326. var picsStr = "";
  327. if (imgArr && imgArr.length > 0) {
  328. for (var i = 0; i < imgArr.length; i++) {
  329. picsStr += imgArr[i].src + ","
  330. }
  331. picsStr = picsStr.substr(0, picsStr.length - 1);
  332. }
  333. var param = {
  334. 'id': editScoreId,
  335. 'pics': picsStr
  336. };
  337. editScoreId = null;
  338. $("#saveEditBtn").hide();
  339. no_return_common_service("/score/update", param, function(data) {
  340. if (scoreLayer) layer.close(scoreLayer);
  341. //查询评分情况
  342. queryCheckScores();
  343. layer.msg(data, {
  344. time: 2000 //20s后自动关闭
  345. });
  346. });
  347. }
  348. }
  349. function deleteCheckScore(id) {
  350. deleteItem4Common(id, "/score/delete/", queryCheckScores, 'r');
  351. }
  352. function setVideoList(videos) {
  353. var videoArr;
  354. if (videos) {
  355. videoArr = videos.split("|");
  356. var selectStr = "";
  357. for (var i in videoArr) {
  358. if (i == 0)
  359. selectStr += '<option value="' + videoArr[i] + '" selected="selected">视频' + (videoArr[i] + 1) + '</option>'
  360. else
  361. selectStr += '<option value="' + videoArr[i] + '">视频' + (videoArr[i] + 1) + '</option>';
  362. }
  363. }
  364. $('#video_list').html(selectStr);
  365. }
  366. function addPic(pic) {
  367. if (pic) {
  368. var i = 0;
  369. // var imgArr = $("#img_container .pic-class");
  370. // if(imgArr && imgArr.length>0) i = imgArr.length;
  371. if (pic.startWith("http"))
  372. pic = pic.replace(base_image_server_url, "/");
  373. var picStr = genPicstr(pic);
  374. $('#img_container').append(picStr);
  375. $('a.lightbox-toggle').lightbox();
  376. }
  377. }
  378. function showPics(pics, divId) {
  379. var picStr = '';
  380. if (!divId) divId = '#img_container';
  381. $(divId).html(picStr);
  382. if (pics) {
  383. var picArr = pics.split(',');
  384. for (var i in picArr) {
  385. var pic = genPicstr(picArr[i]);
  386. picStr += pic;
  387. }
  388. $(divId).html(picStr);
  389. $('a.lightbox-toggle').lightbox();
  390. }
  391. }
  392. function genPicstr(imgSrc) {
  393. var src = imgSrc;
  394. if (!src.startWith("http"))
  395. src = base_image_server_url + src;
  396. var pic = '<div class="img_item" style="width:100px;height:90px;float:left;">' +
  397. '<a href="javascript:void(0)" onclick="removeImg(this)" style="float:right;position:relative;z-index:100;"><span class="label label-danger"><i class="icon icon-remove-circle"></i> 删除</span></a>' +
  398. '<a class="card lightbox-toggle" data-group="image-group-1" data-lightbox-group="example-3" href="' + src + '" style="position:absolute">' +
  399. '<img class="pic-class img-thumbnail" path="' + imgSrc + '" style="width:100px;height:70px;" src="' + src + '" alt="">' +
  400. '</a>' +
  401. '</div>';
  402. if (ISCLIENT) {
  403. pic = '<div class="img_item" style="width:100px;height:90px;float:left;">' +
  404. '<a href="javascript:void(0)" onclick="removeImg(this)" style="float:right;position:relative;z-index:100;"><span class="label label-danger"><i class="icon icon-remove-circle"></i> 删除</span></a>' +
  405. '<a class="card" onclick="showClientImg(\'' + src + '\')" href="javascript:void(0)" style="position:absolute">' +
  406. '<img class="pic-class img-thumbnail" path="' + imgSrc + '" style="width:100px;height:70px;" src="' + src + '" alt="">' +
  407. '</a>' +
  408. '</div>';
  409. }
  410. return pic;
  411. }
  412. function removeImg(this1) {
  413. $(this1).parent('.img_item').remove();
  414. }
  415. function clearAllImg() {
  416. $('#img_container').empty();
  417. }
  418. var changePersonLayer;
  419. function showChangeUser() {
  420. var param = {
  421. 'organid': $.checkTask.checked_dept
  422. };
  423. post_common_service("/user/getUserList/", param, function(data) {
  424. changePersonLayer = showPopup4Common('更改人员', null, ['550px', '600px'], null, 'r');
  425. $("#user_container").empty();
  426. var userStr = "";
  427. for (var i in data) {
  428. var name = data[i].truename;
  429. if (data[i].workno) name = name + " " + data[i].workno.substr(data[i].workno.length - 3);
  430. var pic = "../../images/body-bg.png";
  431. if (data[i].pic) pic = base_image_server_url + data[i].pic;
  432. str = '<div style="width:90px;float:left;margin:5px;">' +
  433. '<a class="card" href="javascript:void(0)">' +
  434. '<img src="' + pic + '" alt="" style="height:100px;width:90px;" onclick="showBigImg(\'' + pic + '\')">' +
  435. '<div class="card-heading"><strong>' + name + '</strong></div>' +
  436. '<div class="card-actions">' +
  437. '<button type="button" class="btn btn-mini btn-danger" onclick="changePerson(\'' + data[i].id + '\')">选择</button>' +
  438. '</div>' +
  439. '</a>' +
  440. '</div>';
  441. userStr += str;
  442. }
  443. $("#user_container").html(userStr);
  444. })
  445. }
  446. function changePerson(id) {
  447. var flag=true;
  448. var param = {
  449. "id":$.checkTask.id,
  450. "checked_person":id,
  451. "class_type":$.checkTask.class_type
  452. };
  453. post_common_service("/task/getUserCount/", param, function(data){
  454. if(data && data.length>=2){
  455. layer.msg("本周期稽查次数已满,不能再被稽查!", {
  456. time: 2000,//20s后自动关闭
  457. offset:'r'
  458. });
  459. }else{
  460. // $('#checked_person').html(id);
  461. var param1 = {
  462. "id": $.checkTask.id,
  463. "checked_person": id,
  464. }
  465. post_common_service("task/update/", param1, function (task_data) {
  466. //重置当前任务
  467. $.checkTask = task_data;
  468. //获取用户信息
  469. get_common_service('user/getUserById/' + id, null, function (data) {
  470. changePersonContent(data);
  471. })
  472. //更新用户次数表
  473. no_return_common_service('task/updateUserCount/', param, function (data) {
  474. // changePersonContent(data);
  475. })
  476. layer.close(changePersonLayer);
  477. }, function (error) {
  478. alert(error);
  479. });
  480. }
  481. });
  482. }
  483. function showBigImg(src) {
  484. $('#userBigImg').attr("src", src);
  485. layer.open({
  486. offset: 'r',
  487. type: 1,
  488. title: false,
  489. closeBtn: 1,
  490. area: '450px',
  491. skin: 'layui-layer-nobg', //没有背景色
  492. shadeClose: true,
  493. shade: 0,
  494. content: $('#userBigImg')
  495. });
  496. }
  497. function resetUserImgInfo() {
  498. $("#user_img_container").empty();
  499. var str = '<a id="person_img" href="../../images/img4.jpg" class="lightbox-toggle">' +
  500. '<img src="../../images/img4.jpg" class="img-thumbnail" style="width:50px;height:50px;margin-top:-10px;"></a>' +
  501. '<label id="checked_person"></label>' +
  502. '(次数:<a href="#"><label id="checked_count"></label></a>)';
  503. $("#user_img_container").html(str);
  504. }
  505. function changePersonContent(data) {
  506. resetUserImgInfo();
  507. var name = data.truename;
  508. if (data.workno) name = data.workno + " " + data.truename;
  509. $("#checked_person").html(name);
  510. var imgSrc = base_image_server_url + data.pic;
  511. $("#person_img > img").attr("src", imgSrc);
  512. if (ISCLIENT) {
  513. $("#person_img").attr("href", "javascript:void(0)");
  514. $("#person_img").removeClass("lightbox-toggle");
  515. $("#person_img").click(function() {
  516. showClientImg(imgSrc);
  517. });
  518. $("#person_img > img").attr("src", imgSrc);
  519. return;
  520. } else {
  521. $("#person_img").attr("href", imgSrc);
  522. $('a.lightbox-toggle').lightbox();
  523. }
  524. getUserCheckCount();
  525. }
  526. var scoreLayer;
  527. function showScore() {
  528. scoreLayer = showPopup4Common('选择考核项', null, ['400px', '500px'], '#items-div', 'r');
  529. buildTree();
  530. }
  531. function buildTree() {
  532. var zTreeObj;
  533. var zNodes = [];
  534. check_item_tree = $.fn.zTree.init($("#items_tree"), {}, zNodes);
  535. getCheckItems();
  536. }
  537. function getCheckItems() {
  538. function zTreeOnRename(event, treeId, treeNode, isCancel) {
  539. alert(treeNode.tId + ", " + treeNode.name);
  540. }
  541. function zTreeOnRemove(event, treeId, treeNode) {
  542. alert(treeNode.tId + ", " + treeNode.name);
  543. }
  544. var setting = {
  545. data: {
  546. simpleData: {
  547. enable: true,
  548. idKey: "id",
  549. pIdKey: "pId",
  550. rootPId: null
  551. }
  552. },
  553. view: { //表示tree的显示状态
  554. selectMulti: false //表示禁止多选
  555. },
  556. check: { //表示tree的节点在点击时的相关设置
  557. enable: false, //是否显示radio/checkbox
  558. chkStyle: "checkbox", //值为checkbox或者radio表示
  559. checkboxType: { p: "", s: "" }, //表示父子节点的联动效果
  560. radioType: "level" //设置tree的分组
  561. },
  562. callback: {
  563. onDblClick: zTreeOnClick
  564. },
  565. edit: {
  566. enable: true,
  567. drag: {
  568. autoExpandTrigger: true,
  569. isMove: true,
  570. prev: false,
  571. next: true,
  572. inner: true,
  573. autoOpenTime: 0
  574. },
  575. showRenameBtn: false,
  576. showRemoveBtn: false
  577. }
  578. };
  579. get_common_service('checkItem/getAll', null, function(data) {
  580. zdata = [];
  581. for (var i = 0; i < data.length; i++) {
  582. var m = data[i];
  583. zdata.push(genNode(m));
  584. }
  585. menu_tree = $.fn.zTree.init($("#items_tree"), setting, zdata)
  586. }, function(error) {
  587. });
  588. }
  589. function addobj(data) {
  590. var zdata = [];
  591. if (typeof(data.subCheckItem) != "undefinde" && data.subCheckItem != null &&
  592. data.subCheckItem.length > 0) {
  593. for (var i = 0; i < data.subCheckItem.length; i++) {
  594. var m = data.subCheckItem[i];
  595. zdata.push(genNode(m));
  596. }
  597. return zdata;
  598. } else {
  599. return [];
  600. }
  601. }
  602. function genNode(m) {
  603. var zdataItem = {};
  604. zdataItem["id"] = m.id;
  605. zdataItem["value"] = m.name;
  606. zdataItem["pId"] = m.parent_id;
  607. zdataItem["score"] = m.score;
  608. zdataItem["icon"] = "";
  609. zdataItem["name"] = m.name;
  610. //zdataItem["content"] = m.name;
  611. if (m.score) zdataItem["name"] = m.name + '(' + m.score + ')';
  612. zdataItem["open"] = true;
  613. zdataItem["children"] = addobj(m);
  614. return zdataItem;
  615. }
  616. function zTreeOnClick(event, treeId, treeNode) {
  617. var imgArr = $("#img_container .pic-class");
  618. var picsStr = "";
  619. if (imgArr && imgArr.length > 0) {
  620. for (var i = 0; i < imgArr.length; i++) {
  621. picsStr += $(imgArr[i]).attr("path") + ","
  622. }
  623. picsStr = picsStr.substr(0, picsStr.length - 1);
  624. }
  625. var param = {
  626. 'task_id': $.checkTask.id,
  627. 'pics': picsStr,
  628. 'name': treeNode.value,
  629. 'check_item_score': treeNode.score,
  630. 'content': treeNode.value,
  631. 'check_item_id': treeNode.id,
  632. 'checkman': treeNode.id,
  633. 'checked_person': $.checkTask.checked_person,
  634. 'checked_dept': $.checkTask.checked_dept
  635. };
  636. no_return_common_service("/score/add", param, function(data) {
  637. if (scoreLayer) layer.close(scoreLayer);
  638. clearAllImg();
  639. //查询评分情况
  640. queryCheckScores();
  641. layer.msg(data, {
  642. time: 2000 //20s后自动关闭
  643. });
  644. });
  645. }
  646. function submitCheck() {
  647. var param = {
  648. "id": $.checkTask.id,
  649. "check_status": 4
  650. }
  651. no_return_common_service("/task/taskEnd/", param, function(data) {
  652. layer.msg("提交成功", {
  653. time: 2000 //20s后自动关闭
  654. });
  655. changePage("/view/mytask/task_list.html?status=2");
  656. });
  657. }
  658. function showPre(id) {
  659. // $('#myModal').modal({name:"dd"});
  660. //预览提交把任务状态改为待提交
  661. no_return_common_service('/task/update', { "id": $.checkTask.id, "check_status": 7 })
  662. changePage("/view/mytask/taskDetail.html");
  663. }
  664. function showInvalid() {
  665. invalidLayer = showPopup4Common('申请无效', function() {
  666. saveValidReason();
  667. }, ['400px', '500px'], '#invalid_div', 'r');
  668. }
  669. function submitCheck4Appeal() {
  670. var param = {
  671. "id": $.checkTask.id,
  672. "check_status": 14
  673. }
  674. no_return_common_service("/task/taskEnd/", param, function(data) {
  675. layer.msg("提交成功", {
  676. time: 2000 //20s后自动关闭
  677. });
  678. changePage("/view/mytask/task_list.html?status=2");
  679. });
  680. }
  681. function showPre4Appeal(id) {
  682. // $('#myModal').modal({name:"dd"});
  683. //预览提交把任务状态改为待提交
  684. no_return_common_service('/task/update', { "id": $.checkTask.id, "check_status": 17 })
  685. changePage("/view/mytask/taskDetail.html");
  686. }
  687. function saveValidReason() {
  688. var param = {
  689. "task_id": $.checkTask.id,
  690. "apply_reason": $("#apply_reason").val()
  691. }
  692. no_return_common_service("/checkApply/add/", param, function(data) {
  693. layer.msg("申请提交成功", {
  694. time: 2000 //20s后自动关闭
  695. });
  696. changePage("/view/mytask/task_list.html?status=2");
  697. });
  698. }
  699. function score(score) {
  700. alert("扣分:" + score);
  701. $('#scoreWin').modal('toggle');
  702. }
  703. function refuseApply() {
  704. alert("拒绝申请");
  705. $('#refuseApplyWin').modal('toggle');
  706. }
  707. function agreeApply() {
  708. alert("同意申请");
  709. }
  710. function getVideoPosition(obj) {
  711. if (obj == null) obj = $('#tabcontent');
  712. var X = obj.offset().top;
  713. var Y = obj.offset().left;
  714. var width = obj.width();
  715. var height = obj.height();
  716. return parseInt(Y) + "|" + parseInt(X) + "|" + parseInt(width) + "|" + parseInt(height);
  717. }
  718. function initUpLoad() {
  719. var uploader = WebUploader.create({
  720. // swf文件路径
  721. swf: 'lib/webuploader/js/Uploader.swf',
  722. // 文件接收服务端。
  723. server: base_image_server_url + '/filesSrver/' + FILE_UPLOAD,
  724. // 选择文件的按钮。可选。
  725. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  726. pick: '#picker',
  727. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  728. resize: false
  729. });
  730. }
  731. function saveRecheckResult() {
  732. var param = {
  733. "id": $.checkTask.appeal.id,
  734. "recheck_result": $("#recheck_result").val()
  735. }
  736. post_common_service("/checkAppeal/update", param, function(data) {
  737. layer.msg("保存成功", {
  738. offset: 'r',
  739. time: 2000 //20s后自动关闭
  740. });
  741. });
  742. }