recordDetaile.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. Infos();
  2. function Infos() {
  3. var info = [];
  4. var name,value;
  5. var str=location.href;
  6. var num=str.indexOf("?");
  7. str=str.substr(num+1);
  8. var arr=str.split("&");
  9. for(var i=0;i < arr.length;i++){
  10. num=arr[i].indexOf("=");
  11. if(num>0){
  12. name=arr[i].substring(0,num);
  13. value=arr[i].substr(num+1);
  14. this[name]=value;
  15. info.push(value)
  16. }
  17. }
  18. $.ajax({
  19. url:Url+'/record/v1/getRecordInstanceDetailList',
  20. type:'get',
  21. data:{
  22. recordParentId:info[0],
  23. departmentId:JSON.parse(getItem('UserQrcode')).organizationIds
  24. },
  25. success:function (res) {
  26. console.log(res,'reswwww');
  27. if (res.code === '200') {
  28. if (res.data.pageRecord != null) {
  29. $('.submitBtn').show();
  30. $('.note').addClass('margin08').removeClass('noneMargin');
  31. }else {
  32. $('.submitBtn').hide();
  33. $('.note').addClass('noneMargin').removeClass('margin08');
  34. }
  35. var recordInstanceList = res.data.recordInstanceList;
  36. for (var r= 0; r< recordInstanceList.length;r++) {
  37. var str = `<div class="note ">
  38. </div>`;
  39. $('.g-flexview').append(str);
  40. var str1 = `<div class="top recordInfo">
  41. <div class="icon"><img src="img/0001.png"></div>
  42. <div class="note-name">${recordInstanceList[r].templateName}</div>
  43. <div class="note-time">${recordInstanceList[r].createDate}</div>
  44. <div class="name">${recordInstanceList[r].createName}</div>
  45. </div>`;
  46. $('.note').append(str1);
  47. // 状态
  48. if (recordInstanceList[r].recordStatusInstanceList != null) {
  49. var strs = `<div class="m-card">
  50. <div class="header"><span>状态</span></div>
  51. <div class="content">
  52. <div class="m-cell statusItem">
  53. </div>
  54. </div>
  55. </div>`;
  56. $('.note').append(strs);
  57. for (var u = 0; u < recordInstanceList[r].recordStatusInstanceList.length; u++) {
  58. var str2 = `<div class="cell-item">
  59. <div class="cell-left">${recordInstanceList[r].recordStatusInstanceList[u].statusName}</div>
  60. <div class="cell-right" id="statusP${u}">
  61. </div>
  62. </div> `;
  63. $('.statusItem').append(str2);
  64. var colors = recordInstanceList[r].recordStatusInstanceList[u].recordStatusInstanceItemList;
  65. console.log(colors,'colors')
  66. for (var c = 0; c < colors.length; c++) {
  67. var statu = `<span style="color:${colors[c].statusColor};margin-left: 3px">${colors[c].statusContent}</span>`;
  68. $('#statusP'+u).append(statu)
  69. }
  70. }
  71. }else {
  72. var str2 = `<div class="m-card">
  73. <div class="header"><span>状态</span></div>
  74. <div class="content">
  75. <div class="m-cell">
  76. <div class="cell-item">
  77. <div class="cell-left">${recordInstanceList[r].statusName}</div>
  78. <div class="cell-right"><span class="blue">${recordInstanceList[r].statusContent}</span></div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>`;
  83. $('.note').append(str2);
  84. }
  85. var m_card =`<div class="m-card fileP">
  86. <div class="header">
  87. <span>记录项</span>
  88. </div>
  89. <div class="content contents">
  90. </div>
  91. </div>`;
  92. $('.note').append(m_card);
  93. if (recordInstanceList[r].inputList != null) {
  94. // 记录项
  95. var record = `
  96. <div class="m-cell recordItem">
  97. </div>
  98. `;
  99. $('.fileP .contents').append(record);
  100. for (var i = 0; i < recordInstanceList[r].inputList.length; i++) {
  101. if (recordInstanceList[r].inputList[i].inputType != 'file' && recordInstanceList[r].inputList[i].inputType != "mp3" && recordInstanceList[r].inputList[i].inputType != "photo" && recordInstanceList[r].inputList[i].inputType != "video" && recordInstanceList[r].inputList[i].values != ""){
  102. var recordItem = `<div class="cell-item">
  103. <div class="cell-title">${recordInstanceList[r].inputList[i].inputName}:</div>
  104. <div class="cell-content"><span class="normal">${recordInstanceList[r].inputList[i].values[0]}</span></div>
  105. </div>`;
  106. $('.recordItem').append(recordItem);
  107. }
  108. }
  109. }
  110. // 检查项
  111. if (recordInstanceList[r].checkItemMap != null) {
  112. var inspectItems =`<div class="m-card inspectItems">
  113. <div class="header">
  114. <span>检查项</span>
  115. </div>
  116. <div class="content">
  117. </div>
  118. </div>`;
  119. $('.note').append(inspectItems);
  120. var inspect = `
  121. <div class="m-cell inspectItem">
  122. </div>
  123. `;
  124. $('.inspectItems .content').append(inspect);
  125. $.each(recordInstanceList[r].checkItemMap,function(key,value){
  126. var text = [];
  127. for (var r = 0; r < value.length; r++) {
  128. text.push(value[r].itemValue)
  129. }
  130. var trem = `<div class="cell-item">
  131. <div class="cell-title">${key}:</div>
  132. <div class="cell-content"><span class="normal">${text.join(',')}</span></div>
  133. </div>`
  134. $('.inspectItem').append(trem);
  135. });
  136. }
  137. // 图片
  138. if (recordInstanceList[r].inputList != null) {
  139. for (var p = 0; p < recordInstanceList[r].inputList.length; p++) {
  140. // 图片
  141. if (recordInstanceList[r].inputList[p].inputType === "photo") {
  142. if (recordInstanceList[r].inputList[p].values !="") {
  143. var photo = `<div class="card-box">
  144. <div class="title">图片:</div>
  145. <div class="content">
  146. <div class="my-gallery img-list" data-pswp-uid="1">
  147. </div>
  148. </div>
  149. </div>`;
  150. $('.fileP .contents').append(photo);
  151. for (var j = 0; j < recordInstanceList[r].inputList[p].values.length; j++) {
  152. var photoTrem = ` <figure>
  153. <div class="img-dv img-item">
  154. <a href="${recordInstanceList[r].inputList[p].values[j]}" data-size="1920x1080">
  155. <img src="${recordInstanceList[r].inputList[p].values[j]}">
  156. </a>
  157. </div>
  158. </figure>`;
  159. $('.img-list ').append(photoTrem);
  160. setTimeout( photoFun,500);
  161. }
  162. }
  163. }
  164. }
  165. // 文件
  166. for (var t = 0; t < recordInstanceList[r].inputList.length; t++) {
  167. if (recordInstanceList[r].inputList[t].inputType === "file") {
  168. if (recordInstanceList[r].inputList[t].values !="") {
  169. var files = `<div class="card-box">
  170. <div class="title">文件:</div>
  171. <div class="content">
  172. <div class="file-list">
  173. </div>
  174. </div>
  175. </div>`;
  176. $('.fileP .contents').append(files);
  177. for (var j = 0; j<recordInstanceList[r].inputList[t].values.length; j++) {
  178. var type = recordInstanceList[r].inputList[t].values[j].substring(recordInstanceList[r].inputList[t].values[j].lastIndexOf(".")+1);
  179. var name =recordInstanceList[r].inputList[t].values[j].substring(recordInstanceList[r].inputList[t].values[j].lastIndexOf("-")+1);
  180. var Urls =recordInstanceList[r].inputList[t].values[j].substring(recordInstanceList[r].inputList[t].values[j],recordInstanceList[r].inputList[t].values[j].lastIndexOf("-"));
  181. var fileTrem = ` <div class="file-item" file-Url="${Urls}">
  182. <a href="javascript:;">
  183. <img src="img/office-icon/${type}.png">
  184. <p>${name}</p>
  185. </a>
  186. </div>`;
  187. $('.file-list ').append(fileTrem);
  188. }
  189. }
  190. }
  191. }
  192. // 录音
  193. for (var a = 0; a < recordInstanceList[r].inputList.length; a++) {
  194. if (recordInstanceList[r].inputList[a].inputType === "mp3") {
  195. if (recordInstanceList[r].inputList[a].values != "") {
  196. var audio = `
  197. <div class="card-box">
  198. <div class="title titleAudio">录音:</div>
  199. </div>
  200. </div>`;
  201. $('.fileP .contents').append(audio);
  202. var audioItem = `
  203. <div class="audio_a" style="position: relative;height: 30px;">
  204. <audio id="audio_src" controls style="height: 30px;">
  205. <source src="${recordInstanceList[r].inputList[a].values[0]}">
  206. </audio>
  207. </div>`;
  208. $('.titleAudio').after(audioItem);
  209. }
  210. }
  211. }
  212. // 视频
  213. for (var v = 0; v < recordInstanceList[r].inputList.length; v++) {
  214. if (recordInstanceList[r].inputList[v].inputType === "video") {
  215. if (recordInstanceList[r].inputList[v].values != "") {
  216. var vedio = `
  217. <div class="card-box">
  218. <div class="title">视频:</div>
  219. <div class="content vedios">
  220. </div>
  221. </div>`;
  222. $('.fileP .contents').append(vedio);
  223. var vedioItem = `
  224. <video controls webkit-playsinline="true" class="video" style="width: 100%;height: 200px;">
  225. <source src="${recordInstanceList[r].inputList[v].values[0]}">
  226. </video>`;
  227. $('.vedios').append(vedioItem);
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }
  235. })
  236. }
  237. function photoFun() {
  238. auto_data_size();
  239. var initPhotoSwipeFromDOM = function(gallerySelector) {
  240. var parseThumbnailElements = function(el) {
  241. var thumbElements = el.childNodes,
  242. numNodes = thumbElements.length,
  243. items = [],
  244. figureEl,
  245. linkEl,
  246. size,
  247. item,
  248. divEl;
  249. for(var i = 0; i < numNodes; i++) {
  250. figureEl = thumbElements[i]; // <figure> element
  251. // 仅包括元素节点
  252. if(figureEl.nodeType !== 1) {
  253. continue;
  254. }
  255. divEl = figureEl.children[0];
  256. linkEl = divEl.children[0]; // <a> element
  257. size = linkEl.getAttribute('data-size').split('x');
  258. // 创建幻灯片对象
  259. item = {
  260. src: linkEl.getAttribute('href'),
  261. w: parseInt(size[0], 10),
  262. h: parseInt(size[1], 10)
  263. };
  264. if(figureEl.children.length > 1) {
  265. item.title = figureEl.children[1].innerHTML;
  266. }
  267. if(linkEl.children.length > 0) {
  268. // <img> 缩略图节点, 检索缩略图网址
  269. item.msrc = linkEl.children[0].getAttribute('src');
  270. }
  271. item.el = figureEl; // 保存链接元素 for getThumbBoundsFn
  272. items.push(item);
  273. }
  274. return items;
  275. };
  276. // 查找最近的父节点
  277. var closest = function closest(el, fn) {
  278. return el && ( fn(el) ? el : closest(el.parentNode, fn) );
  279. };
  280. // 当用户点击缩略图触发
  281. var onThumbnailsClick = function(e) {
  282. e = e || window.event;
  283. e.preventDefault ? e.preventDefault() : e.returnValue = false;
  284. var eTarget = e.target || e.srcElement;
  285. var clickedListItem = closest(eTarget, function(el) {
  286. return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
  287. });
  288. if(!clickedListItem) {
  289. return;
  290. }
  291. var clickedGallery = clickedListItem.parentNode,
  292. childNodes = clickedListItem.parentNode.childNodes,
  293. numChildNodes = childNodes.length,
  294. nodeIndex = 0,
  295. index;
  296. for (var i = 0; i < numChildNodes; i++) {
  297. if(childNodes[i].nodeType !== 1) {
  298. continue;
  299. }
  300. if(childNodes[i] === clickedListItem) {
  301. index = nodeIndex;
  302. break;
  303. }
  304. nodeIndex++;
  305. }
  306. if(index >= 0) {
  307. openPhotoSwipe( index, clickedGallery );
  308. }
  309. return false;
  310. };
  311. var photoswipeParseHash = function() {
  312. var hash = window.location.hash.substring(1),
  313. params = {};
  314. if(hash.length < 5) {
  315. return params;
  316. }
  317. var vars = hash.split('&');
  318. for (var i = 0; i < vars.length; i++) {
  319. if(!vars[i]) {
  320. continue;
  321. }
  322. var pair = vars[i].split('=');
  323. if(pair.length < 2) {
  324. continue;
  325. }
  326. params[pair[0]] = pair[1];
  327. }
  328. if(params.gid) {
  329. params.gid = parseInt(params.gid, 10);
  330. }
  331. return params;
  332. };
  333. var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
  334. var pswpElement = document.querySelectorAll('.pswp')[0],
  335. gallery,
  336. options,
  337. items;
  338. items = parseThumbnailElements(galleryElement);
  339. // 这里可以定义参数
  340. options = {
  341. barsSize: {
  342. top: 100,
  343. bottom: 100
  344. },
  345. fullscreenEl : false,
  346. shareButtons: [
  347. {id:'wechat', label:'分享微信', url:'#'},
  348. {id:'weibo', label:'新浪微博', url:'#'},
  349. {id:'download', label:'保存图片', url:'{{raw_image_url}}', download:true}
  350. ],
  351. galleryUID: galleryElement.getAttribute('data-pswp-uid'),
  352. getThumbBoundsFn: function(index) {
  353. var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
  354. pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
  355. rect = thumbnail.getBoundingClientRect();
  356. return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
  357. }
  358. };
  359. if(fromURL) {
  360. if(options.galleryPIDs) {
  361. for(var j = 0; j < items.length; j++) {
  362. if(items[j].pid == index) {
  363. options.index = j;
  364. break;
  365. }
  366. }
  367. } else {
  368. options.index = parseInt(index, 10) - 1;
  369. }
  370. } else {
  371. options.index = parseInt(index, 10);
  372. }
  373. if( isNaN(options.index) ) {
  374. return;
  375. }
  376. if(disableAnimation) {
  377. options.showAnimationDuration = 0;
  378. }
  379. gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
  380. gallery.init();
  381. };
  382. var galleryElements = document.querySelectorAll( gallerySelector );
  383. for(var i = 0, l = galleryElements.length; i < l; i++) {
  384. galleryElements[i].setAttribute('data-pswp-uid', i+1);
  385. galleryElements[i].onclick = onThumbnailsClick;
  386. }
  387. var hashData = photoswipeParseHash();
  388. if(hashData.pid && hashData.gid) {
  389. openPhotoSwipe( hashData.pid , galleryElements[ hashData.gid - 1 ], true, true );
  390. }
  391. };
  392. initPhotoSwipeFromDOM('.my-gallery');
  393. }
  394. function auto_data_size(){
  395. $("figure img").each(function() {
  396. var imgs = new Image();
  397. imgs.src=$(this).attr("src");
  398. var w = imgs.width,
  399. h = imgs.height;
  400. $(this).parent("a").attr("data-size","").attr("data-size",w+"x"+h);
  401. })
  402. };
  403. $('body').on('click','.file-list>.file-item',function () {
  404. var url = $(this).attr('file-Url');
  405. var type = url.substring(url.lastIndexOf(".")+1);
  406. console.log(type,'type')
  407. if (type == 'zip' || type == 'rar') {
  408. window.location.href = url;
  409. } else if(type == 'ppt' || type == 'pptx'){
  410. window.open('https://view.officeapps.live.com/op/view.aspx?src='+url)
  411. }else {
  412. window.open('https://view.officeapps.live.com/op/view.aspx?src='+url)
  413. }
  414. });
  415. $('.submitBtn').on("click",function () {
  416. location.href = 'addRecord.html'
  417. });
  418. // $('body').on('click','.seeDoc',function () {
  419. // var url = $(this).attr('file-Url');
  420. // window.open('https://view.officeapps.live.com/op/view.aspx?src='+url)
  421. // });
  422. // $('body').on('click','.downloadPDF',function () {
  423. // var url = $(this).attr('file-Url');
  424. // window.location.href = url;
  425. //
  426. // });
  427. // $('body').on('click','.seePdf',function () {
  428. // var url = $(this).attr('file-Url');
  429. // setItem('pdfUrl',url);
  430. // window.open('http://apptest.jieweizhineng.com/assets/html/QRcoddetails/pdf.html');
  431. // });
  432. // $('body').on('click','.seePpt',function () {
  433. // var url = $(this).attr('file-Url');
  434. // window.open('https://view.officeapps.live.com/op/view.aspx?src='+url)
  435. // });