check.js 38 KB

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