check.js 39 KB

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