check.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. function initCheck() {
  2. $('#ex1').slider({tooltip: 'hide'});
  3. $("#ex1").on("slideStop", function(slideEvt) {
  4. setVideoProcess(slideEvt.value);
  5. });
  6. event = document.createEvent('MessageEvent');
  7. var origin = window.location.protocol + '//' + window.location.host;
  8. event.initMessageEvent('setvideoposition', true, true, getVideoPosition(), origin, 1234, window, null);
  9. document.dispatchEvent(event);
  10. // 仅选择日期
  11. $("#start-time").datetimepicker({
  12. language: "zh-CN",
  13. weekStart: 1,
  14. todayBtn: 1,
  15. autoclose: 1,
  16. todayHighlight: 1,
  17. startView: 2,
  18. minView: 2,
  19. forceParse: 0,
  20. format: "yyyy-mm-dd"
  21. });
  22. // 仅选择日期
  23. $("#end-time").datetimepicker({
  24. language: "zh-CN",
  25. weekStart: 1,
  26. todayBtn: 1,
  27. autoclose: 1,
  28. todayHighlight: 1,
  29. startView: 2,
  30. minView: 2,
  31. forceParse: 0,
  32. format: "yyyy-mm-dd"
  33. });
  34. if ($.checkTask) {
  35. initCheckAppealBtns();
  36. setFeSelect("#fsList", $.checkTask.checked_dept);
  37. // $("#fsList").on("change",function(){
  38. // $.checkTask.checked_dept = this.value;
  39. // })
  40. $("#lane").val($.checkTask.checked_location);
  41. // setLaneSelect("#lane", $.checkTask.checked_location);
  42. get_common_service('user/getUserById/' + $.checkTask.checked_person, null, function (data) {
  43. changePersonContent(data);
  44. })
  45. //查询评分情况
  46. queryCheckScores();
  47. //查询录像播放列表
  48. var videos = $.checkTask.video_id.split(',');
  49. if(videos[0]){
  50. curVideo = videos[0];
  51. queryVideoList();
  52. }else{
  53. callFunc("showvideoview", "false");
  54. layer.msg('该处暂无视屏!', {
  55. time: 2000, //20s后自动关闭
  56. });
  57. callFunc("stop", "");
  58. }
  59. }
  60. $("select#video_list").change(function(){
  61. playVideo($(this).val());
  62. });
  63. }
  64. function initInfo() {
  65. }
  66. function initCheckAppealBtns(){
  67. if($.checkTask.appeal) {
  68. $("#btn_appeal_task").show();
  69. $("#btn_task").hide();
  70. $("#appeal_div").show();
  71. $("#appeal_time").html($.checkTask.appeal.appeal_time);
  72. $("#appeal_reason").html($.checkTask.appeal.appeal_reason);
  73. $("#appeal_file_list").html(genAppeaFiles($.checkTask.appeal.file_src));
  74. layer.open({
  75. type: 1,
  76. title: "申诉详情",
  77. closeBtn: 1,
  78. shade: false,
  79. shadeClose: true,
  80. offset:'rb',
  81. content: $('#appeal_div'), //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
  82. yes: function(index){
  83. layer.close(index);
  84. }
  85. });
  86. }else{
  87. $("#appeal_div").hide();
  88. $("#btn_appeal_task").hide();
  89. $("#btn_task").show();
  90. }
  91. }
  92. // 使用data参数更新数据:
  93. function queryCheckScores() {
  94. //$('#score_datatable').score_datatable("");
  95. console.log("任务id:"+$.checkTask.id);
  96. var data = {
  97. "task_id": $.checkTask.id
  98. }
  99. // alert("ff");
  100. var cols = [
  101. { width: 80, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  102. { width: 160, text: '评分记录', type: 'string', flex: true, sort: 'down', field: 'content' },
  103. { width: 80, text: '分数', type: 'string', flex: true, colClass: '', field: 'check_item_score' },
  104. // {width: 80, text: '图片', type: 'imagedd', flex: true, colClass: '',field: 'pics'},
  105. {
  106. width: 160, text: '操作', type: 'string', flex: true, field: 'id',
  107. oper: [
  108. { func: 'showEditCheckScore', text: '修改', icon_class: 'icon-edit' },
  109. { func: 'deleteCheckScore', text: '删除', icon_class: 'icon-remove-circle' }
  110. ]
  111. }
  112. ];
  113. // var pager = {
  114. // page_size:10
  115. // }
  116. $('#score_datatable').mytable({
  117. 'cols': cols,
  118. 'url': "/score/getScoreList/",
  119. 'param': data
  120. }
  121. );
  122. }
  123. function showEditCheckScore(id) {
  124. // deleteItem4Common(id,"/score/delete/",queryCheckScores);
  125. var rowData = getItemByIdFromArr(id, $('#score_datatable').mytable('getTableData'));
  126. // scoreDetailLayer = showPopup4Common('修改考核项',null,['600px','500px'],'#score-detail-div');
  127. // var rowData=getItemByIdFromArr(id,$('#score_datatable').mytable('getTableData'));
  128. showPics(rowData.pics);
  129. // $("#scoreContent").val(rowData.content);
  130. $("#saveEditBtn").show();
  131. editScoreId = id;
  132. }
  133. var editScoreId;
  134. function saveEdit(){
  135. if(editScoreId) {
  136. var imgArr = $("#img_container .pic-class");
  137. var picsStr = "";
  138. if (imgArr && imgArr.length > 0) {
  139. for (var i = 0; i < imgArr.length; i++) {
  140. picsStr += imgArr[i].src + ","
  141. }
  142. picsStr = picsStr.substr(0, picsStr.length - 1);
  143. }
  144. var param = {
  145. 'id': editScoreId,
  146. 'pics': picsStr
  147. };
  148. editScoreId = null;
  149. $("#saveEditBtn").hide();
  150. no_return_common_service("/score/update", param, function (data) {
  151. if (scoreLayer) layer.close(scoreLayer);
  152. //查询评分情况
  153. queryCheckScores();
  154. layer.msg(data, {
  155. time: 2000//20s后自动关闭
  156. });
  157. });
  158. }
  159. }
  160. function deleteCheckScore(id) {
  161. deleteItem4Common(id, "/score/delete/", queryCheckScores, 'r');
  162. }
  163. function setVideoList(videos){
  164. var videoArr;
  165. if(videos){
  166. videoArr = videos.split("|");
  167. var selectStr="";
  168. for(var i in videoArr){
  169. if(i==0)
  170. selectStr += '<option value="'+videoArr[i]+'" selected="selected">视频'+videoArr[i]+'</option>'
  171. else
  172. selectStr += '<option value="'+videoArr[i]+'">视频'+videoArr[i]+'</option>';
  173. }
  174. }
  175. $('#video_list').html(selectStr);
  176. }
  177. function addPic(pic) {
  178. if (pic) {
  179. var i=0;
  180. var imgArr = $("#img_container .pic-class");
  181. if(imgArr && imgArr.length>0) i = imgArr.length;
  182. var picStr = genPicstr(pic);
  183. $('#img_container').append(picStr);
  184. $('a.lightbox-toggle').lightbox();
  185. }
  186. }
  187. function showPics(pics, divId) {
  188. var picStr = '';
  189. if (!divId) divId = '#img_container';
  190. $(divId).html(picStr);
  191. if (pics) {
  192. var picArr = pics.split(',');
  193. for (var i in picArr) {
  194. var pic = genPicstr(picArr[i]);
  195. picStr += pic;
  196. }
  197. $(divId).html(picStr);
  198. $('a.lightbox-toggle').lightbox();
  199. }
  200. }
  201. function genPicstr(src){
  202. var pic = '<div class="img_item" style="width:100px;height:90px;float:left;">'
  203. + '<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>'
  204. + '<a class="card lightbox-toggle" data-group="image-group-1" data-lightbox-group="example-3" href="' + src + '" style="position:absolute">'
  205. + '<img class="pic-class img-thumbnail" style="width:100px;height:70px;" src="' + src + '" alt="">'
  206. + '</a>'
  207. + '</div>';
  208. if(ISCLIENT) {
  209. pic = '<div class="img_item" style="width:100px;height:90px;float:left;">'
  210. + '<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>'
  211. + '<a class="card" onclick="showClientImg(\''+src +'\')" href="javascript:void(0)" style="position:absolute">'
  212. + '<img class="pic-class img-thumbnail" style="width:100px;height:70px;" src="' + src + '" alt="">'
  213. + '</a>'
  214. + '</div>';
  215. }
  216. return pic;
  217. }
  218. function removeImg(this1) {
  219. $(this1).parent('.img_item').remove();
  220. }
  221. function clearAllImg() {
  222. $('#img_container').empty();
  223. }
  224. var changePersonLayer;
  225. function showChangeUser() {
  226. var param = {
  227. 'organid': $.checkTask.checked_dept
  228. };
  229. post_common_service("/user/getUserList/", param, function (data) {
  230. changePersonLayer = showPopup4Common('更改人员', null, ['550px','600px'],null,'r');
  231. $("#user_container").empty();
  232. var userStr = "";
  233. for (var i in data) {
  234. var name = data[i].truename;
  235. if (data[i].workno) name = name+" "+data[i].workno.substr(data[i].workno.length-3);
  236. var pic = "../../images/body-bg.png";
  237. if (data[i].pic) pic = base_image_server_url+data[i].pic;
  238. str = '<div style="width:90px;float:left;margin:5px;">'
  239. + '<a class="card" href="javascript:void(0)" onclick="changePerson(\'' + data[i].id + '\')">'
  240. + '<img src="' + pic + '" alt="" style="height:100px;width:90px;">'
  241. + '<div class="card-heading"><strong>' + name + '</strong></div>'
  242. + '</a>'
  243. + '</div>';
  244. userStr += str;
  245. }
  246. $("#user_container").html(userStr);
  247. })
  248. }
  249. function changePerson(id) {
  250. // $('#checked_person').html(id);
  251. var param = {"id": $.checkTask.id,
  252. "checked_person": id,
  253. }
  254. no_return_common_service("task/update/", param, function(data) {
  255. get_common_service('user/getUserById/' + id, null, function (data) {
  256. changePersonContent(data);
  257. })
  258. layer.close(changePersonLayer);
  259. }, function(error) {
  260. alert(error);
  261. });
  262. }
  263. function resetUserImgInfo() {
  264. $("#user_img_container").empty();
  265. var str = '<a id="person_img" href="../../images/img4.jpg" class="lightbox-toggle">'
  266. +'<img src="../../images/img4.jpg" class="img-thumbnail" style="width:50px;height:50px;margin-top:-10px;"></a>'
  267. + '<label id="checked_person"></label>';
  268. $("#user_img_container").html(str);
  269. }
  270. function changePersonContent(data) {
  271. resetUserImgInfo();
  272. var name = data.truename;
  273. if (data.workno) name = data.workno + " " + data.truename;
  274. $("#checked_person").html(name);
  275. var imgSrc = base_image_server_url+data.pic;
  276. $("#person_img > img").attr("src", imgSrc);
  277. if(ISCLIENT) {
  278. $("#person_img").attr("href", "javascript:void(0)");
  279. $("#person_img").removeClass("lightbox-toggle");
  280. $("#person_img").click(function(){
  281. showClientImg(imgSrc);
  282. });
  283. $("#person_img > img").attr("src", imgSrc);
  284. return;
  285. }else {
  286. $("#person_img").attr("href", imgSrc);
  287. $('a.lightbox-toggle').lightbox();
  288. }
  289. }
  290. var scoreLayer;
  291. function showScore() {
  292. scoreLayer = showPopup4Common('选择考核项', null, ['400px', '500px'], '#items-div','r');
  293. buildTree();
  294. }
  295. function buildTree() {
  296. var zTreeObj;
  297. var zNodes = [];
  298. check_item_tree = $.fn.zTree.init($("#items_tree"), {}, zNodes);
  299. getCheckItems();
  300. }
  301. function getCheckItems() {
  302. function zTreeOnRename(event, treeId, treeNode, isCancel) {
  303. alert(treeNode.tId + ", " + treeNode.name);
  304. }
  305. function zTreeOnRemove(event, treeId, treeNode) {
  306. alert(treeNode.tId + ", " + treeNode.name);
  307. }
  308. var setting = {
  309. data: {
  310. simpleData: {
  311. enable: true,
  312. idKey: "id",
  313. pIdKey: "pId",
  314. rootPId: null
  315. }
  316. },
  317. view: { //表示tree的显示状态
  318. selectMulti: false //表示禁止多选
  319. },
  320. check: { //表示tree的节点在点击时的相关设置
  321. enable: false, //是否显示radio/checkbox
  322. chkStyle: "checkbox", //值为checkbox或者radio表示
  323. checkboxType: { p: "", s: "" }, //表示父子节点的联动效果
  324. radioType: "level" //设置tree的分组
  325. },
  326. callback: {
  327. onDblClick: zTreeOnClick
  328. },
  329. edit: {
  330. enable: true,
  331. drag: {
  332. autoExpandTrigger: true,
  333. isMove: true,
  334. prev: false,
  335. next: true,
  336. inner: true,
  337. autoOpenTime: 0
  338. },
  339. showRenameBtn: false,
  340. showRemoveBtn: false
  341. }
  342. };
  343. get_common_service('checkItem/getAll', null, function (data) {
  344. zdata = [];
  345. for (var i = 0; i < data.length; i++) {
  346. var m = data[i];
  347. zdata.push(genNode(m));
  348. }
  349. menu_tree = $.fn.zTree.init($("#items_tree"), setting, zdata)
  350. }, function (error) {
  351. });
  352. }
  353. function addobj(data) {
  354. var zdata = [];
  355. if (typeof (data.subCheckItem) != "undefinde" && data.subCheckItem != null &&
  356. data.subCheckItem.length > 0) {
  357. for (var i = 0; i < data.subCheckItem.length; i++) {
  358. var m = data.subCheckItem[i];
  359. zdata.push(genNode(m));
  360. }
  361. return zdata;
  362. } else {
  363. return [];
  364. }
  365. }
  366. function genNode(m) {
  367. var zdataItem = {};
  368. zdataItem["id"] = m.id;
  369. zdataItem["value"] = m.name;
  370. zdataItem["pId"] = m.parent_id;
  371. zdataItem["score"] = m.score;
  372. zdataItem["icon"] = "";
  373. zdataItem["name"] = m.name;
  374. //zdataItem["content"] = m.name;
  375. if (m.score) zdataItem["name"] = m.name + '(' + m.score + ')';
  376. zdataItem["open"] = true;
  377. zdataItem["children"] = addobj(m);
  378. return zdataItem;
  379. }
  380. function zTreeOnClick(event, treeId, treeNode) {
  381. //alert(treeNode.name);
  382. var imgArr = $("#img_container .pic-class");
  383. var picsStr = "";
  384. if (imgArr && imgArr.length > 0) {
  385. for (var i = 0; i < imgArr.length; i++) {
  386. picsStr += imgArr[i].src + ","
  387. }
  388. picsStr = picsStr.substr(0, picsStr.length - 1);
  389. }
  390. var param = {
  391. 'task_id': $.checkTask.id,
  392. 'pics': picsStr,
  393. 'name': treeNode.value,
  394. 'content': treeNode.value,
  395. 'check_item_id': treeNode.id,
  396. 'checkman': treeNode.id,
  397. 'checked_person': $.checkTask.checked_person,
  398. 'checked_dept': $.checkTask.checked_dept
  399. };
  400. no_return_common_service("/score/add", param, function (data) {
  401. if (scoreLayer) layer.close(scoreLayer);
  402. clearAllImg();
  403. //查询评分情况
  404. queryCheckScores();
  405. layer.msg(data, {
  406. time: 2000//20s后自动关闭
  407. });
  408. });
  409. }
  410. function submitCheck() {
  411. var param = {
  412. "id": $.checkTask.id,
  413. "check_status": 4
  414. }
  415. no_return_common_service("/task/taskEnd/", param, function (data) {
  416. layer.msg("提交成功", {
  417. time: 2000//20s后自动关闭
  418. });
  419. changePage("/view/mytask/task_list.html?status=2");
  420. });
  421. }
  422. function showPre(id) {
  423. // $('#myModal').modal({name:"dd"});
  424. changePage("/view/mytask/taskDetail.html");
  425. }
  426. function showInvalid() {
  427. invalidLayer = showPopup4Common('申请无效', function () {
  428. saveValidReason();
  429. }, ['400px', '500px'], '#invalid_div','r');
  430. }
  431. function submitCheck4Appeal() {
  432. var param = {
  433. "id": $.checkTask.id,
  434. "check_status": 14
  435. }
  436. no_return_common_service("/task/taskEnd/", param, function (data) {
  437. layer.msg("提交成功", {
  438. time: 2000//20s后自动关闭
  439. });
  440. changePage("/view/mytask/task_list.html?status=2");
  441. });
  442. }
  443. function showPre4Appeal(id) {
  444. // $('#myModal').modal({name:"dd"});
  445. changePage("/view/mytask/taskDetail.html");
  446. }
  447. function saveValidReason() {
  448. var param = {
  449. "task_id": $.checkTask.id,
  450. "apply_reason": $("#apply_reason").val()
  451. }
  452. no_return_common_service("/checkApply/add/", param, function (data) {
  453. layer.msg("申请提交成功", {
  454. time: 2000//20s后自动关闭
  455. });
  456. changePage("/view/mytask/task_list.html?status=2");
  457. });
  458. }
  459. function score(score) {
  460. alert("扣分:" + score);
  461. $('#scoreWin').modal('toggle');
  462. }
  463. function refuseApply() {
  464. alert("拒绝申请");
  465. $('#refuseApplyWin').modal('toggle');
  466. }
  467. function agreeApply() {
  468. alert("同意申请");
  469. }
  470. function getVideoPosition() {
  471. var X = $('#tabcontent').offset().top;
  472. var Y = $('#tabcontent').offset().left;
  473. var width = $('#tabcontent').width();
  474. var height = $('#tabcontent').height();
  475. return parseInt(Y) + "|" + parseInt(X) + "|" + parseInt(width) + "|" + parseInt(height);
  476. }
  477. function initUpLoad(){
  478. var uploader = WebUploader.create({
  479. // swf文件路径
  480. swf: 'lib/webuploader/js/Uploader.swf',
  481. // 文件接收服务端。
  482. server: base_image_server_url+'/filesSrver/'+FILE_UPLOAD,
  483. // 选择文件的按钮。可选。
  484. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  485. pick: '#picker',
  486. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  487. resize: false
  488. });
  489. }