yinshi.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. function queryYinshiList(page,pagesize,begindate,enddate) {
  2. //拼请求内容
  3. d.show();
  4. var params = {};
  5. params.page = page;
  6. params.pagesize = pagesize;
  7. params.start = begindate+" 00:00:00";
  8. params.end = enddate+" 23:59:59";
  9. //发送ajax请求
  10. sendPost("patient/health_record/list_diet", params, "json", "post", queryListFailed, queryYinshiListSuccesss);
  11. }
  12. /**
  13. * 健康指标图表查询成功处理方法
  14. */
  15. function queryYinshiListSuccesss(res) {
  16. if (res.status == 200) {
  17. d.close();
  18. if (res.list.length > 0) {
  19. showYinshiList(res.list);
  20. if(res.list.length<10){
  21. $("#view_more_yinshi").hide();
  22. }else{
  23. $("#view_more_yinshi").show();
  24. }
  25. }else{
  26. $("#view_more_yinshi").hide();
  27. }
  28. } else {
  29. queryListFailed(res);
  30. }
  31. }
  32. /**
  33. * 显示查询结果
  34. * @param {Object} list
  35. */
  36. function showYinshiList(list) {
  37. page = page+1;
  38. for (var i = 0; i < list.length; i++) {
  39. var data = list[i];
  40. if (!data) {
  41. continue;
  42. }
  43. //data.date.substr(5, 5) --只有月-日
  44. addRowYinshi(data.record_date, data.content,data.images);
  45. }
  46. setTimeout(function () {
  47. scroller1.myScroll.refresh();
  48. }, 1000);
  49. }
  50. /**
  51. * 清空tbody
  52. */
  53. function clearHTML() {
  54. $("#diet_list").html("");
  55. }
  56. /**
  57. * tbody添加一行tr
  58. * @param {Object} dateStr
  59. * @param {Object} value1
  60. * @param {Object} value2
  61. */
  62. function addRowYinshi(record_date, content,images) {
  63. // if(dateStr.length > 5){
  64. // dateStr = dateStr.substr(5, 5);
  65. // }
  66. var tb = document.querySelector("#diet_list");
  67. var tr = document.createElement("tr");
  68. if(record_date.length > 5){
  69. record_date = record_date.substr(5, 5);
  70. }
  71. if(record_date){
  72. record_date = record_date.replace("-",".");
  73. }
  74. var pict= new Array(); //定义一数组
  75. pict=images.split(","); //字符分割
  76. var img_html="";
  77. for (i=0;i<pict.length ;i++ )
  78. {
  79. // document.write(+"<br/>"); //分割后的字符输出
  80. img_html+="<img src='"+getImgUrl(pict[i])+"' width='40' height='40' style='display:inline-block; vertical-align:middle; margin-right:10px;' onclick='viewImg(this)'/>"
  81. }
  82. var html ="";
  83. html+="<tr>"
  84. html+= "<td class='width-40 c-color'>"+record_date+"</td>"
  85. html+= "<td class='width-60 c-color' style='text-align:left;'>"+img_html+content+"</td>"
  86. html+="</tr>"
  87. tr.innerHTML = html;
  88. tb.appendChild(tr);
  89. }
  90. //查看图片
  91. function viewImg(dom) {
  92. var $img = $(dom);
  93. var thissrc = $img.attr("src");
  94. var mWid = $(window).width();
  95. var mHei = $(window).height();
  96. var nHtml = '<div class="delimgpop"><div class="del-img-box"><div class="del-img-con"><img class="del-pop-img" src="' + thissrc + '" style="max-width:' + mWid + 'px; max-height:' + mHei + 'px;"></div></div></div>';
  97. $("body").append(nHtml);
  98. $(".delimgpop").click(function() {
  99. $(this).remove()
  100. });
  101. };