check.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  1. var videoPlayer;
  2. var isfullscreen = false;
  3. var videoid;
  4. function dbclick() {
  5. if (isfullscreen) {
  6. if (layer_full) {
  7. layer.close(layer_full)
  8. }
  9. isfullscreen = false;
  10. $("#tabcontent").css("height", '400px');
  11. } else {
  12. fullscreen();
  13. }
  14. }
  15. var startTimec = 0;
  16. var endTimec = 0;
  17. function videorecordstart(type) {
  18. if (type == "video_start") {
  19. $("#video_btn_start").addClass("hidden");
  20. $("#video_btn_stop").removeClass("hidden");
  21. startTimec = currentTime;
  22. }
  23. if (type == "video_stop") {
  24. $("#video_btn_stop").addClass("hidden");
  25. $("#video_btn_start").removeClass("hidden");
  26. endTimec = currentTime;
  27. var idss = videoid.split("/");
  28. var filename = idss[idss.length - 1];
  29. //开始截取视屏
  30. post_common_service_nohead(base_image_server_url + 'fileServer/file/videocut', {
  31. "targetfilename": filename,
  32. "filename": filename.split(".")[0],
  33. "startTime": startTimec,
  34. "endtime": endTimec
  35. }, function(data) {
  36. addPic(data.path)
  37. });
  38. }
  39. if (type == "screenshot") {
  40. var idss = videoid.split("/");
  41. var filename = idss[idss.length - 1];
  42. //开始截取视屏
  43. post_common_service_nohead(base_image_server_url + 'fileServer/file/videopiccut', {
  44. "targetfilename": filename,
  45. "filename": filename.split(".")[0],
  46. "startTime": currentTime,
  47. }, function(data) {
  48. addPic(data.path)
  49. });
  50. }
  51. }
  52. var currentTime = 0;
  53. function timeHandler(time) {
  54. //'当前播放时间(秒):' + time;
  55. // console.log(time)
  56. currentTime = time;
  57. }
  58. function initCheck() {
  59. addBreadMenu("/qzd/view/task/check.html", "清障队视频稽查");
  60. $("#tabcontent").css("height", ($("#video_content").height() - 80) + "px");
  61. $("#score_datatable").css("height", ($("#video_content").height() - 120) + "px");
  62. //设置视屏位置
  63. // if (ISCLIENT) {
  64. // event = document.createEvent('MessageEvent');
  65. // var origin = window.location.protocol + '//' + window.location.host;
  66. // event.initMessageEvent('setvideoposition', true, true, getVideoPosition(null), origin, 1234, window, null);
  67. // document.dispatchEvent(event);
  68. // }
  69. if ($.checkTask) {
  70. // console.log($.checkTask);
  71. getAreaCheckCount();
  72. initCheckAppealBtns();
  73. $("#taskName").html($.checkTask.name);
  74. $("#ex1_span").html($.checkTask.start_time)
  75. $("#full_ex1_span").html($.checkTask.start_time)
  76. $("#lane").val($.checkTask.checked_location);
  77. $("#check_time").html($.checkTask.check_period);
  78. //TODO 获取分数
  79. queryCheckScores();
  80. videos = $.checkTask.recordVideos;
  81. if (videos.split(",").length > 0) {
  82. var vlist = videos.split(",");
  83. var htmlo = "";
  84. for (var v in vlist) {
  85. var vv = vlist[v];
  86. console.log(vv.split("/")[0]);
  87. var o = "<option val='" + vv + "' " + (v == 0 ? "selected" : "") + " >" + vv.split("/")[0] + "</option>"
  88. htmlo += o;
  89. }
  90. $("#videoslist").html(htmlo);
  91. }
  92. videoid = videos.split(",")[0];
  93. var videoObject = {
  94. container: '.video', //“#”代表容器的ID,“.”或“”代表容器的class
  95. variable: 'player', //该属性必需设置,值等于下面的new chplayer()的对象
  96. //poster: 'pic/wdm.jpg', //封面图片
  97. autoplay: true,
  98. video: base_image_server_url + videoid //视频地址
  99. };
  100. videoPlayer = new ckplayer(videoObject);
  101. videoPlayer.addListener('time', timeHandler);
  102. }
  103. }
  104. function onvideoselect(obj) {
  105. videoid = (obj.value);
  106. var videoObject = {
  107. container: '.video', //“#”代表容器的ID,“.”或“”代表容器的class
  108. variable: 'player', //该属性必需设置,值等于下面的new chplayer()的对象
  109. //poster: 'pic/wdm.jpg', //封面图片
  110. autoplay: true,
  111. video: base_image_server_url + videoid //视频地址
  112. };
  113. videoPlayer = new ckplayer(videoObject);
  114. videoPlayer.addListener('time', timeHandler);
  115. }
  116. function setfastorslow(type, speed) {
  117. if (type == 0) {
  118. $("#fast_info").html("");
  119. $("#slow_info").html("");
  120. if ($("#full_fast_info")) {
  121. $("#full_fast_info").html("");
  122. $("#full_slow_info").html("");
  123. }
  124. }
  125. if (type == 1) {
  126. $("#fast_info").html(speed + "x");
  127. $("#slow_info").html("");
  128. if ($("#full_fast_info")) {
  129. $("#full_fast_info").html(speed + "x");
  130. $("#full_slow_info").html("");
  131. }
  132. }
  133. if (type == 2) {
  134. $("#slow_info").html(speed + "x");
  135. $("#fast_info").html("");
  136. if ($("#full_fast_info")) {
  137. $("#full_fast_info").html("");
  138. $("#full_slow_info").html(speed + "x");
  139. }
  140. }
  141. }
  142. function normalscreen() {
  143. if (layer_full) {
  144. layer.close(layer_full)
  145. $("#video_pos").val($("#full_video_pos").val());
  146. }
  147. }
  148. var layer_full = null;
  149. function fullscreen() {
  150. var height = window.innerWidth * 0.8 * 1 / 2.0 + 110
  151. var contenthtml = $('#video_content');
  152. layer_full = layer.open({
  153. area: ['80%', height + "px"],
  154. type: 1,
  155. title: false,
  156. anim: -1,
  157. closeBtn: 0,
  158. shadeClose: false,
  159. content: contenthtml,
  160. success: function(layero, index) {
  161. isfullscreen = true;
  162. $("#tabcontent").css("height", (height - 60) + 'px');
  163. }
  164. });
  165. }
  166. function getAreaCheckCount() {
  167. var index = layer.load(1, {
  168. shade: [0.1, '#fff'] //0.1透明度的白色背景
  169. });
  170. //var html = '';
  171. var userids = $.checkTask.checked_users.split(",");
  172. var usernames = $.checkTask.checked_users_name.split(",");
  173. var param = {
  174. "period_id": $.checkTask.period_id,
  175. "checked_users": $.checkTask.checked_users
  176. };
  177. var url = base_server_url + "/q/task/getTasks/0/0";
  178. ajaxPost(url, param, function(response) {
  179. for (var i in userids) {
  180. // console.log(response);
  181. var html = '<label id="' + userids[i] + '"></label>' + usernames[i] + '(次数:' +
  182. '<a href="javascript:void(0)" onclick="showCheckDetailCount(\'' + userids[i] + '\')"><span class="label label-primary" id="">' + response[i].length + '</span></a>)';
  183. $("#checked_area").append(html);
  184. }
  185. }, function(error) {
  186. if (fail)
  187. fail("网络错误");
  188. else
  189. console.log("网络错误");
  190. });
  191. }
  192. //显示考核次数
  193. function showCheckDetailCount(id) {
  194. scoreDetailLayer = showPopup4Common('本周期已考核任务', null, ['450px', '350px'], '#checked_task_list_div', 'r', '确定');
  195. var param = {
  196. "period_id": $.checkTask.period_id,
  197. "checked_users": id
  198. };
  199. var cols = [
  200. { width: 40, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  201. { width: 80, text: '任务名称', type: 'string', flex: true, sort: 'down', field: 'name' },
  202. { width: 50, text: '考核对象', type: 'string', flex: true, colClass: '', field: 'checked_users_name' },
  203. { width: 80, text: '扣分情况', type: 'string', flex: true, sort: 'down', field: 'score_details' },
  204. { width: 70, text: '稽查时间段', type: 'string', flex: true, sort: 'down', field: 'check_period' }
  205. ];
  206. $('#checked_user_task_datatable').mytable({
  207. 'cols': cols,
  208. 'url': "/q/task/getall/",
  209. 'param': param,
  210. 'isShoWPager': false
  211. });
  212. }
  213. function initCheckAppealBtns() {
  214. if ($.checkTask.appeal) {
  215. $("#btn_appeal_task").show();
  216. $("#btn_task").hide();
  217. // $("#appeal_div").show();
  218. $("#appeal_time").html($.checkTask.appeal.appeal_time);
  219. $("#appeal_reason").html($.checkTask.appeal.appeal_reason);
  220. $("#appeal_file_list").html(genAppeaFiles($.checkTask.appeal.file_src));
  221. $("#recheck_result").html($.checkTask.appeal.recheck_result);
  222. showAppealLayer();
  223. } else {
  224. // $("#appeal_div").hide();
  225. $("#btn_appeal_task").hide();
  226. $("#btn_task").show();
  227. }
  228. }
  229. function showAppealLayer() {
  230. layer.open({
  231. type: 1,
  232. area: ['400px', "400px"],
  233. title: "申诉详情",
  234. closeBtn: 1,
  235. shade: false,
  236. maxmin: false,
  237. shadeClose: true,
  238. offset: 'rb',
  239. content: $('#appeal_div'), //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
  240. cancel: function(index) {
  241. layer.close(index);
  242. layer.open({
  243. type: 1,
  244. title: "",
  245. closeBtn: 0,
  246. shade: false,
  247. maxmin: false,
  248. shadeClose: true,
  249. content: $('#hide_div'),
  250. offset: 'rb',
  251. btn: ['申诉详情'],
  252. yes: function(index) {
  253. layer.close(index);
  254. showAppealLayer();
  255. }
  256. });
  257. return false;
  258. }
  259. });
  260. }
  261. // 使用data参数更新数据:
  262. function queryCheckScores() {
  263. //$('#score_datatable').score_datatable("");
  264. // console.log("任务id:" + $.checkTask.id);
  265. var data = {
  266. "task_id": $.checkTask.id
  267. }
  268. // alert("ff");
  269. var cols = [
  270. { width: 40, text: '序号', type: 'number', flex: true, colClass: 'text-center', field: 'num' },
  271. { width: 100, text: '评分记录', type: 'string', flex: true, sort: 'down', field: 'content' },
  272. { width: 40, text: '分数', type: 'string', flex: true, colClass: '', field: 'check_item_score' },
  273. { width: 100, text: '备注', type: 'string', flex: true, colClass: '', field: 'remark' },
  274. { width: 50, text: '考核人', type: 'string', flex: true, colClass: '', field: 'checked_area_name' },
  275. // {width: 80, text: '图片', type: 'imagedd', flex: true, colClass: '',field: 'pics'},
  276. // {
  277. // width: 150,
  278. // text: '操作',
  279. // type: 'string',
  280. // flex: true,
  281. // field: 'id',
  282. // oper: [
  283. // { func: 'showEditCheckScore', text: '修改', icon_class: 'icon-edit' },
  284. // { func: 'showEditPic', text: '图片', icon_class: 'icon-edit' },
  285. // { func: 'deleteCheckScore', text: '删除', icon_class: 'icon-remove-circle' }
  286. // ]
  287. // }
  288. ];
  289. var colFunc = { width: 170, text: '操作', type: 'string', flex: true, field: 'id' };
  290. colFunc.oper = [
  291. { func: 'showEditCheckScore', text: '修改', icon_class: 'icon-edit' },
  292. { func: 'showEditPic', text: '图片', icon_class: 'icon-edit' }
  293. ];
  294. if ($.checkTask.appeal) {
  295. colFunc.oper.push({ func: 'backoutCheckScore', text: '撤销', icon_class: 'icon-reply' });
  296. } else {
  297. colFunc.oper.push({ func: 'deleteCheckScore', text: '删除', icon_class: 'icon-remove-circle' });
  298. }
  299. cols.push(colFunc);
  300. // var pager = {
  301. // page_size:10
  302. // }
  303. $('#score_datatable').mytable({
  304. 'cols': cols,
  305. 'url': "/q/score/getScoreList/",
  306. 'param': data
  307. });
  308. }
  309. function showEditPic(id) {
  310. var rowData = getItemByIdFromArr(id, $('#score_datatable').mytable('getTableData'));
  311. showPics(rowData.pics);
  312. $("#saveEditBtn").show();
  313. editScoreId = id;
  314. }
  315. function showEditCheckScore(id) {
  316. // deleteItem4Common(id,"/score/delete/",queryCheckScores);
  317. var rowData = getItemByIdFromArr(id, $('#score_datatable').mytable('getTableData'));
  318. scoreDetailLayer = showPopup4Common('修改考核项', function(data) {
  319. saveScoreEdit();
  320. }, ['350px', '550px'], '#score-detail-div', 'r');
  321. var list = new Array();
  322. var userids = $.checkTask.checked_users.split(",");
  323. var usernames = $.checkTask.checked_users_name.split(",");
  324. console.log(rowData);
  325. var optStr = '';
  326. for (var i in userids) {
  327. if (userids[i] == rowData.checked_area)
  328. optStr += '<option value="' + userids[i] + '" selected="selected">' + usernames[i] + '</option>';
  329. else
  330. optStr += '<option value="' + userids[i] + '">' + usernames[i] + '</option>';
  331. }
  332. $("#check_checked_person_select").html('');
  333. $("#check_checked_person_select").html(optStr);
  334. $("#score_id_text").val(rowData.id);
  335. $("#check_item_text").val(rowData.content);
  336. $("#check_score_text").val(rowData.check_item_score);
  337. // setFeeUserSelect("#check_checked_person_select", rowData.checked_person);
  338. // $("#check_checked_person_select").val(rowData.checked_person);
  339. $("#check_remark_text").tagsInput({ 'defaultText': '添加备注', 'width': '240px' });
  340. $("#check_remark_text").importTags('');
  341. $("#check_remark_text").addTag(rowData.remark);
  342. getTags("/q/score/getTopRemark", '#score_remark_div', '#check_remark_text', 'remark');
  343. }
  344. function setFeeUserSelect(div, selectId) {
  345. var param = {
  346. 'organid': $.checkTask.checked_dept
  347. };
  348. post_common_service("/user/getUserList/", param, function(userList) {
  349. // setFeeUserSelect("#check_checked_person_select",rowData.checked_person,data);
  350. var optStr = '';
  351. for (var i in userList) {
  352. if (userList[i].id == selectId)
  353. optStr += '<option value="' + userList[i].id + '" selected="selected">' + userList[i].truename + '</option>';
  354. else
  355. optStr += '<option value="' + userList[i].id + '">' + userList[i].truename + '</option>';
  356. }
  357. $(div).html('');
  358. $(div).html(optStr);
  359. $('#check_checked_person_select').chosen({
  360. // width:'200px',
  361. height: '100px',
  362. no_results_text: '没有找到', // 当检索时没有找到匹配项时显示的提示文本
  363. disable_search_threshold: 10, // 10 个以下的选择项则不显示检索框
  364. search_contains: true // 从任意位置开始检索
  365. });
  366. });
  367. }
  368. function saveScoreEdit() {
  369. var param = {
  370. 'id': $("#score_id_text").val(),
  371. 'content': $("#check_item_text").val(),
  372. 'check_item_score': $("#check_score_text").val(),
  373. 'remark': $("#check_remark_text").val(),
  374. 'checked_area': $("#check_checked_person_select").val(),
  375. };
  376. editScoreId = null;
  377. $("#saveEditBtn").hide();
  378. console.log(param);
  379. no_return_common_service("/q/score/update", param, function(data) {
  380. if (scoreLayer) layer.close(scoreLayer);
  381. //查询评分情况
  382. queryCheckScores();
  383. // layer.msg(data, {
  384. // time: 2000//20s后自动关闭
  385. // });
  386. });
  387. }
  388. var editScoreId;
  389. function saveEdit() {
  390. if (editScoreId) {
  391. var imgArr = $("#img_container .pic-class");
  392. var picsStr = "";
  393. if (imgArr && imgArr.length > 0) {
  394. for (var i = 0; i < imgArr.length; i++) {
  395. picsStr += imgArr[i].attributes.getNamedItem("path").textContent + ","
  396. }
  397. picsStr = picsStr.substr(0, picsStr.length - 1);
  398. }
  399. var param = {
  400. 'id': editScoreId,
  401. 'pics': picsStr
  402. };
  403. editScoreId = null;
  404. $("#saveEditBtn").hide();
  405. no_return_common_service("/q/score/update", param, function(data) {
  406. if (scoreLayer) layer.close(scoreLayer);
  407. //查询评分情况
  408. queryCheckScores();
  409. layer.msg(data, {
  410. offset: 'r',
  411. time: 2000 //20s后自动关闭
  412. });
  413. });
  414. }
  415. }
  416. function deleteCheckScore(id) {
  417. deleteItem4Common(id, "/q/score/delete/", queryCheckScores, 'r');
  418. }
  419. function backoutCheckScore(id) {
  420. layer.confirm('是否要撤销扣分?', {
  421. btn: ['是', '否'], //按钮
  422. shadeClose: true,
  423. shade: 0, //不显示遮罩
  424. offset: 'r'
  425. }, function() {
  426. var param = {
  427. "id": id,
  428. "check_item_score": 0
  429. };
  430. post_common_service("/q/score/backoutScore/", param, function(data) {
  431. layer.msg('撤销成功!', {
  432. offset: 'r',
  433. time: 2000, //20s后自动关闭
  434. });
  435. queryCheckScores();
  436. });
  437. }, function() {
  438. });
  439. }
  440. function setVideoList(videos) {
  441. var videoArr;
  442. if (videos) {
  443. videoArr = videos.split("|");
  444. var selectStr = "";
  445. for (var i in videoArr) {
  446. if (i == 0)
  447. selectStr += '<option value="' + videoArr[i] + '" selected="selected">视频' + (videoArr[i] + 1) + '</option>'
  448. else
  449. selectStr += '<option value="' + videoArr[i] + '">视频' + (videoArr[i] + 1) + '</option>';
  450. }
  451. }
  452. $('#video_list').html(selectStr);
  453. }
  454. function addPic(pic) {
  455. if (pic) {
  456. var i = 0;
  457. // var imgArr = $("#img_container .pic-class");
  458. // if(imgArr && imgArr.length>0) i = imgArr.length;
  459. if (pic.startWith("http"))
  460. pic = pic.replace(base_image_server_url, "/");
  461. var picStr = genPicstr(pic);
  462. $('#img_container').append(picStr);
  463. $('a.lightbox-toggle').lightbox();
  464. }
  465. }
  466. function showPics(pics, divId) {
  467. var picStr = '';
  468. if (!divId) divId = '#img_container';
  469. $(divId).html(picStr);
  470. if (pics) {
  471. var picArr = pics.split(',');
  472. for (var i in picArr) {
  473. var pic = genPicstr(picArr[i]);
  474. picStr += pic;
  475. }
  476. $(divId).html(picStr);
  477. $('a.lightbox-toggle').lightbox();
  478. }
  479. }
  480. function genPicstr(imgSrc) {
  481. var src = imgSrc;
  482. if (!src.startWith("http"))
  483. src = base_image_server_url + src;
  484. var ispic = true;
  485. var videosrc = src;
  486. if (src.indexOf('.avi') != -1) {
  487. src = src.split('.avi')[0] + "_screen_0.png"
  488. ispic = false;
  489. }
  490. if (src.indexOf('.mov') != -1) {
  491. src = src.split('.mov')[0] + "_screen_0.png"
  492. ispic = false;
  493. }
  494. if (src.indexOf('.mp4') != -1) {
  495. src = src.split('.mp4')[0] + "_screen_0.png"
  496. ispic = false;
  497. }
  498. var pic = '<div class="img_item" style="width:100px;height:90px;float:left;">' +
  499. '<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>' +
  500. (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">') +
  501. '<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>') +
  502. '</a>' +
  503. '</div>';
  504. if (ISCLIENT) {
  505. pic = '<div class="img_item" style="width:100px;height:90px;float:left;">' +
  506. '<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>' +
  507. '<a class="card" onclick="' + (ispic ? 'showClientImg(\'' + src + '\')' : 'showClientVideo(\'' + videosrc + '\')') + '" href="javascript:void(0)" style="position:absolute">' +
  508. '<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>') +
  509. '</a>' +
  510. '</div>';
  511. }
  512. return pic;
  513. }
  514. function removeImg(this1) {
  515. $(this1).parent('.img_item').remove();
  516. }
  517. function clearAllImg() {
  518. $('#img_container').empty();
  519. }
  520. var changePersonLayer;
  521. function checkHasScore(id, old_person) {
  522. var param = {
  523. "task_id": $.checkTask.id,
  524. "checked_person": old_person
  525. };
  526. post_common_service("/score/getScoreList/1/10", param, function(data) {
  527. if (data.list && data.list.length > 0) {
  528. layer.confirm('是否要同步更改扣分人?', {
  529. btn: ['是', '否'], //按钮
  530. shadeClose: true,
  531. shade: 0, //不显示遮罩
  532. offset: 'r'
  533. }, function() {
  534. var param = {
  535. "task_id": $.checkTask.id,
  536. "checked_person": old_person,
  537. "new_checked_person": id
  538. };
  539. post_common_service("/score/updateByTaskIdAndPerson/", param, function(data) {
  540. layer.msg('更改成功!', {
  541. offset: 'r',
  542. time: 2000, //20s后自动关闭
  543. });
  544. queryCheckScores();
  545. });
  546. }, function() {
  547. });
  548. }
  549. });
  550. }
  551. function changePersonContent(data) {
  552. resetUserImgInfo();
  553. var name = data.truename;
  554. if (data.workno) name = data.workno + " " + data.truename;
  555. $("#checked_person").html(name);
  556. var imgSrc = base_image_server_url + data.pic;
  557. $("#person_img > img").attr("src", imgSrc);
  558. if (ISCLIENT) {
  559. $("#person_img").attr("href", "javascript:void(0)");
  560. $("#person_img").removeClass("lightbox-toggle");
  561. $("#person_img").click(function() {
  562. showClientImg(imgSrc);
  563. });
  564. $("#person_img > img").attr("src", imgSrc);
  565. return;
  566. } else {
  567. $("#person_img").attr("href", imgSrc);
  568. $('a.lightbox-toggle').lightbox();
  569. }
  570. getUserCheckCount();
  571. }
  572. var scoreLayer;
  573. function showScore() {
  574. scoreLayer = showPopup4Common('选择考核项', function(data) {
  575. var nodes = check_item_tree.getSelectedNodes()[0];
  576. console.log(nodes);
  577. var data = {
  578. "content": nodes.value,
  579. "check_item_score": nodes.score,
  580. "checked_person_name": $.checkTask.checkman_name
  581. }
  582. console.log(data);
  583. }, ['400px', '500px'], '#items-div', 'r');
  584. buildTree();
  585. }
  586. function buildTree() {
  587. var zTreeObj;
  588. var zNodes = [];
  589. check_item_tree = $.fn.zTree.init($("#items_tree"), {}, zNodes);
  590. getCheckItems();
  591. }
  592. function getCheckItems() {
  593. function zTreeOnRename(event, treeId, treeNode, isCancel) {
  594. alert(treeNode.tId + ", " + treeNode.name);
  595. }
  596. function zTreeOnRemove(event, treeId, treeNode) {
  597. alert(treeNode.tId + ", " + treeNode.name);
  598. }
  599. var setting = {
  600. data: {
  601. simpleData: {
  602. enable: true,
  603. idKey: "id",
  604. pIdKey: "pId",
  605. rootPId: null
  606. }
  607. },
  608. view: { //表示tree的显示状态
  609. selectMulti: false //表示禁止多选
  610. },
  611. check: { //表示tree的节点在点击时的相关设置
  612. enable: false, //是否显示radio/checkbox
  613. chkStyle: "checkbox", //值为checkbox或者radio表示
  614. checkboxType: { p: "", s: "" }, //表示父子节点的联动效果
  615. radioType: "level" //设置tree的分组
  616. },
  617. callback: {
  618. onDblClick: zTreeOnClick
  619. },
  620. edit: {
  621. enable: true,
  622. drag: {
  623. autoExpandTrigger: true,
  624. isMove: true,
  625. prev: false,
  626. next: true,
  627. inner: true,
  628. autoOpenTime: 0
  629. },
  630. showRenameBtn: false,
  631. showRemoveBtn: false
  632. }
  633. };
  634. var param = { "rule_type": 6 };
  635. post_common_service('checkRule/getItemListByRuleType', param, function(data) {
  636. // console.log(data);
  637. zdata = [];
  638. for (var i = 0; i < data.length; i++) {
  639. var m = data[i];
  640. zdata.push(genNode(m));
  641. }
  642. // console.log(zdata);
  643. menu_tree = $.fn.zTree.init($("#items_tree"), setting, zdata)
  644. }, function(error) {
  645. });
  646. }
  647. function addobj_checkitem(data) {
  648. // console.log(data.subCheckItem);
  649. var zdata = [];
  650. if (typeof(data.subCheckItem) != "undefined" && data.subCheckItem != null &&
  651. data.subCheckItem.length > 0) {
  652. for (var i = 0; i < data.subCheckItem.length; i++) {
  653. var m = data.subCheckItem[i];
  654. zdata.push(genNode(m));
  655. }
  656. return zdata;
  657. } else {
  658. return [];
  659. }
  660. }
  661. function genNode(m) {
  662. var zdataItem = {};
  663. zdataItem["id"] = m.id;
  664. zdataItem["value"] = m.name;
  665. zdataItem["pId"] = m.parent_id;
  666. zdataItem["score"] = m.score;
  667. zdataItem["icon"] = "";
  668. zdataItem["name"] = m.name;
  669. //zdataItem["content"] = m.name;
  670. if (m.score) zdataItem["name"] = m.name + '(' + m.score + ')';
  671. zdataItem["open"] = true;
  672. // console.log(m.subCheckItem);
  673. zdataItem["children"] = addobj_checkitem(m);
  674. return zdataItem;
  675. }
  676. function zTreeOnClick(event, treeId, treeNode) {
  677. var imgArr = $("#img_container .pic-class");
  678. var picsStr = "";
  679. if (imgArr && imgArr.length > 0) {
  680. for (var i = 0; i < imgArr.length; i++) {
  681. picsStr += $(imgArr[i]).attr("path") + ","
  682. }
  683. picsStr = picsStr.substr(0, picsStr.length - 1);
  684. }
  685. var param = {
  686. 'task_id': $.checkTask.id,
  687. 'pics': picsStr,
  688. 'name': treeNode.value,
  689. 'check_item_score': treeNode.score,
  690. 'content': treeNode.value,
  691. 'check_item_id': treeNode.id,
  692. 'checkman': $.checkTask.checkman,
  693. 'checked_area': $.checkTask.checked_users.split(",")[0],
  694. 'checked_dept': $.checkTask.checked_dept
  695. };
  696. no_return_common_service("/q/score/add", param, function(data) {
  697. if (scoreLayer) layer.close(scoreLayer);
  698. clearAllImg();
  699. //查询评分情况
  700. queryCheckScores();
  701. layer.msg(data, {
  702. offset: 'r',
  703. time: 2000 //20s后自动关闭
  704. });
  705. });
  706. }
  707. function submitCheck() {
  708. var param = {
  709. "id": $.checkTask.id,
  710. "check_status": 4
  711. }
  712. no_return_common_service("/q/task/update/", param, function(data) {
  713. layer.msg("提交成功", {
  714. offset: 'r',
  715. time: 2000 //20s后自动关闭
  716. });
  717. redirectLastPage();
  718. });
  719. }
  720. function showPre(id) {
  721. // $('#myModal').modal({name:"dd"});
  722. //预览提交把任务状态改为待提交
  723. no_return_common_service('/q/task/update', { "id": $.checkTask.id, "check_status": 7 })
  724. changePage("/qzd/view/task/taskDetail.html");
  725. }
  726. var isappeal = false;
  727. function appeal_showInvalid() {
  728. isappeal = true;
  729. showInvalidView();
  730. }
  731. function showInvalid() {
  732. isappeal = false;
  733. showInvalidView();
  734. }
  735. function showInvalidView() {
  736. invalidLayer = showPopup4Common('申请无效', function() {
  737. saveValidReason();
  738. }, ['400px', '500px'], '#invalid_div', 'r');
  739. $('#apply_reason').tagsInput({ 'defaultText': '添加原因' });
  740. getTags("/q/checkApply/getTopReason", "#top_reason_div", '#apply_reason', 'apply_reason');
  741. }
  742. function submitCheck4AppealDirect() {
  743. var appeal_result = 1;
  744. //询问框
  745. layer.confirm('该申诉是否成功?', {
  746. offset: 'r',
  747. btn: ['成功', '失败'], //按钮
  748. // shadeClose: true,
  749. shade: 0 //不显示遮罩
  750. }, function() {
  751. appeal_result = 1;
  752. submitCheck4AppealResult(appeal_result);
  753. }, function() {
  754. appeal_result = 2;
  755. submitCheck4AppealResult(appeal_result);
  756. });
  757. }
  758. function submitCheck4AppealResult(appeal_result) {
  759. var param = {
  760. "id": $.checkTask.id,
  761. "check_status": 14,
  762. "appeal_id": $.checkTask.appeal.id,
  763. "appeal_result": appeal_result
  764. }
  765. no_return_common_service("/q/task/update/", param, function(data) {
  766. layer.msg("提交成功", {
  767. offset: 'r',
  768. time: 2000 //20s后自动关闭
  769. });
  770. redirectLastPage();
  771. });
  772. }
  773. function showPre4Appeal(id) {
  774. // $('#myModal').modal({name:"dd"});
  775. //预览提交把任务状态改为待提交
  776. no_return_common_service('/q/task/update', { "id": $.checkTask.id, "check_status": 17 })
  777. changePage("/qzd/view/task/taskDetail.html");
  778. }
  779. function saveValidReason() {
  780. var param = {
  781. "task_id": $.checkTask.id,
  782. "apply_reason": $('#apply_reason').val(),
  783. "isappeal": isappeal
  784. };
  785. no_return_common_service("/q/checkApply/add/", param, function(data) {
  786. layer.msg("申请提交成功", {
  787. offset: 'r',
  788. time: 2000 //20s后自动关闭
  789. });
  790. redirectLastPage();
  791. });
  792. }
  793. function score(score) {
  794. alert("扣分:" + score);
  795. $('#scoreWin').modal('toggle');
  796. }
  797. function refuseApply() {
  798. alert("拒绝申请");
  799. $('#refuseApplyWin').modal('toggle');
  800. }
  801. function agreeApply() {
  802. alert("同意申请");
  803. }
  804. // function getVideoPosition(obj) {
  805. // if (obj == null) obj = $('#tabcontent');
  806. // var X = obj.offset().top;
  807. // var Y = obj.offset().left;
  808. // var width = obj.width();
  809. // var height = obj.height();
  810. // return parseInt(Y) + "|" + parseInt(X) + "|" + parseInt(width) + "|" + parseInt(height);
  811. // }
  812. function initUpLoad() {
  813. var uploader = WebUploader.create({
  814. // swf文件路径
  815. swf: 'lib/webuploader/js/Uploader.swf',
  816. // 文件接收服务端。
  817. server: base_image_server_url + '/filesSrver/' + FILE_UPLOAD,
  818. // 选择文件的按钮。可选。
  819. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  820. pick: '#picker',
  821. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  822. resize: false
  823. });
  824. }
  825. function saveRecheckResult() {
  826. var param = {
  827. "id": $.checkTask.appeal.id,
  828. "recheck_result": $("#recheck_result").val()
  829. }
  830. post_common_service("/q/checkAppeal/update", param, function(data) {
  831. layer.msg("保存成功", {
  832. offset: 'r',
  833. time: 2000 //20s后自动关闭
  834. });
  835. $.checkTask.appeal = data;
  836. });
  837. }
  838. function addTag(text, tagDiv) {
  839. if (!$(tagDiv).tagExist(text)) {
  840. $(tagDiv).addTag(text);
  841. }
  842. }
  843. // function getTags(){
  844. // post_common_service("/checkApply/getTopReason", null, function(data) {
  845. // if(data){
  846. // var str="";
  847. // for(var i=0;i<data.length;i++){
  848. // 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>';
  849. // }
  850. // $("#top_reason_div").html(str);
  851. // }
  852. // });
  853. // }