You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

103 lines
4.9 KiB

  1. var fileInfoId = request('fileInfoId');
  2. var bootstrap = function ($, learun) {
  3. "use strict";
  4. //1 查看 2上传 3 下载 4 删除 5 复原
  5. var btnName = {
  6. '1': '查看',
  7. '2': '上传',
  8. '3': '下载',
  9. '4': '删除',
  10. '5': '复原',
  11. '6': '彻底删除'
  12. }
  13. var page = {
  14. init: function () {
  15. $('#gridtable').jfGrid({
  16. url: top.$.rootUrl + '/LR_SystemModule/Files/GetHistoryList?fileInfoId=' + fileInfoId,
  17. headData: [
  18. {
  19. label: '文件名', name: 'F_Name', width: 300, align: 'left',
  20. formatter: function (cellvalue, row) {
  21. return "<div style='cursor:pointer;'><div style='float: left;'><img src='" + top.$.rootUrl + "/Content/images/filetype/" + row.F_FileType + ".png' style='width:30px;height:30px;padding:5px;margin-left:-5px;margin-right:5px;' /></div><div style='float: left;line-height:35px;'>" + cellvalue + "</div></div>";
  22. }
  23. },
  24. {
  25. label: '文件版本', name: 'F_Ver', width: 60, align: 'center'
  26. },
  27. {
  28. label: '大小', name: 'F_FileSize', width: 100, align: 'center',
  29. formatter: function (cellvalue) {
  30. return page.CountFileSize(cellvalue);
  31. }
  32. },
  33. {
  34. label: '操作', name: 'F_Id', width: 200, align: 'left',
  35. formatter: function (value, row, op, $cell) {
  36. var $div = $('<div></div>');
  37. var btnlist = row.F_AuthType.split(',');
  38. $.each(btnlist, function (_index, _item) {
  39. if (_item != '6' && _item != '5' && _item != '4' && _item != '2' && $div.find('[data-value="' + _item + '"]').length == 0) {
  40. var $btn = $('<span class=\"label label-info\" data-value="' + _item + '" style=\"cursor: pointer; margin-right:8px;\">' + btnName[_item] + '</span>');
  41. $btn[0]._row = row;
  42. $btn.on('click', function () {
  43. var $this = $(this);
  44. var btnValue = $this.attr('data-value');
  45. var btnRow = $this[0]._row;
  46. switch (btnValue) {
  47. case '1':// 查看
  48. learun.layerForm({
  49. id: 'PreviewForm',
  50. title: '文件预览',
  51. url: top.$.rootUrl + '/LR_SystemModule/Annexes/PreviewFile?fileId=' + btnRow.F_PFiled,
  52. width: 1080,
  53. height: 850,
  54. btn: null
  55. });
  56. break;
  57. case '3':// 下载
  58. learun.download({ url: top.$.rootUrl + '/LR_SystemModule/Annexes/DownAnnexesFile', param: { fileId: btnRow.F_FileId }, method: 'POST' });
  59. break;
  60. }
  61. });
  62. $div.append($btn);
  63. }
  64. });
  65. return $div;
  66. }
  67. }
  68. ],
  69. mainId: 'F_Id'
  70. });
  71. $('#gridtable').jfGridSet('reload');
  72. },
  73. CountFileSize: function (Size) {
  74. var m_strSize = "";
  75. var FactSize = 0;
  76. FactSize = Size;
  77. if (FactSize < 1024.00)
  78. m_strSize = page.ToDecimal(FactSize) + " 字节";
  79. else if (FactSize >= 1024.00 && FactSize < 1048576)
  80. m_strSize = page.ToDecimal(FactSize / 1024.00) + " KB";
  81. else if (FactSize >= 1048576 && FactSize < 1073741824)
  82. m_strSize = page.ToDecimal(FactSize / 1024.00 / 1024.00) + " MB";
  83. else if (FactSize >= 1073741824)
  84. m_strSize = page.ToDecimal(FactSize / 1024.00 / 1024.00 / 1024.00) + " GB";
  85. return m_strSize;
  86. },
  87. ToDecimal: function (x) {
  88. var f = parseFloat(x);
  89. if (isNaN(f)) {
  90. return 0;
  91. }
  92. f = Math.round(x * 100) / 100;
  93. return f;
  94. }
  95. };
  96. page.init();
  97. }