project_report.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <div className="p-3 bg-white">
  2. <table className="layui-hide" id="reports" lay-filter="reports"></table>
  3. </div>
  4. <script>
  5. function report() {
  6. console.log("我已经执行了")
  7. let tool = layui.tool, table = layui.table;
  8. //项目任务
  9. var allcount;
  10. parent.layui.reportTable = table.render({
  11. elem: '#reports',
  12. title: '文档列表',
  13. toolbar: '#toolbarreports',
  14. cellMinWidth: 80,
  15. parseData: function (res) { // 数据解析回调函数
  16. // 在这里可以获取数据总数
  17. allcount = res.data.length;
  18. return {
  19. code: res.code, // 数据状态码
  20. msg: res.msg, // 状态信息
  21. count: res.count, // 数据总数
  22. data: res.data // 当前页数据
  23. };
  24. },
  25. url: "/admin/project.report/datalist_company",
  26. where: {'project_id': project_id},
  27. page: true, //开启分页
  28. limit: 20,
  29. cols: [[
  30. {field: 'id', title: '序号', width: 80, align: 'center',
  31. templet: function (d) {
  32. console.log(allcount,d.LAY_NUM)
  33. return allcount - (d.LAY_NUM - 1);
  34. }
  35. },
  36. {
  37. field: 'title', title: '报告名称', align: 'center',
  38. templet: function (d) {
  39. var html = "";
  40. if (d.status == 4 || d.status == 7) {
  41. html = '<a class="side-a" lay-event="detail" style="color: grey;text-decoration:line-through" lay-event="detail">' + d.title + '</a>';
  42. } else {
  43. html = '<a class="side-a" lay-event="detail" lay-event="detail">' + d.title + '</a>';
  44. }
  45. return '<div style="text-align:left">' + html + '</div>'
  46. }
  47. },
  48. {
  49. field: 'type', title: '报告类型', align: 'center', width: 100, templet: function (item) {
  50. var html = '';
  51. if (item.type === 0) {
  52. html = "<span>初审报告</span>";
  53. } else if (item.type === 1) {
  54. html = "<span>对数报告</span>";
  55. } else if (item.type === 2) {
  56. html = "<span>审定报告</span>";
  57. }
  58. return html;
  59. }
  60. },
  61. {
  62. field: 'status', title: '审批状态', align: 'center', width: 150, templet: function (d) {
  63. var abc = '';
  64. if (d.status == 0) {
  65. abc = "<span>未审核(新建)</span>";
  66. } else if (d.status == 1) {
  67. abc = "<span>已通过(新建)</span>";
  68. } else if (d.status == 2) {
  69. abc = "<span>已拒绝(新建)</span>";
  70. } else if (d.status == 3) {
  71. abc = "<span>未审核(删除)</span>";
  72. } else if (d.status == 4) {
  73. abc = "<span>已通过(删除)</span>";
  74. } else if (d.status == 5) {
  75. abc = "<span>已拒绝(删除)</span>";
  76. } else if (d.status == 6) {
  77. abc = "<span>未审核(内部)</span>";
  78. } else if (d.status == 7) {
  79. abc = "<span>已拒绝(内部)</span>";
  80. }
  81. return abc;
  82. }
  83. },
  84. {field: 'create_time', title: '创建时间', align: 'center', width: 150},
  85. {field: 'admin_name', title: '创建人', align: 'center', width: 100},
  86. {
  87. field: 'right', fixed: 'right', title: '操作', width: 150, align: 'center',
  88. templet: function (d) {
  89. var html = '<div class="layui-btn-group">';
  90. var btn3 = `<a class="layui-btn layui-btn-xs" lay-event="progress">进度</a>`;
  91. var btn1 = `<a class="layui-btn layui-btn-xs" href=${d.filepath} download=${d.name} lay-event="">下载</a>`;
  92. return html + btn1 + btn3 + '</div>';
  93. }
  94. }
  95. ]]
  96. });
  97. //触发事件
  98. table.on('toolbar(reports)', function (obj) {
  99. var checkStatus = table.checkStatus(obj.config.id);
  100. switch (obj.event) {
  101. case 'add':
  102. parent.layui.tool.side('/admin/project.report/add?project_id=' + project_id); // 项目id
  103. break;
  104. }
  105. });
  106. table.on('tool(reports)', function (obj) {
  107. var data = obj.data; //获得当前行数据
  108. if (obj.event === 'detail') { //查看
  109. let url = '/admin/project.report/view_company?id=' + data.id;// 项目id
  110. parent.layui.tool.side(url);
  111. }
  112. if (obj.event === 'del') {
  113. layer.prompt({
  114. title: '请输入<span style="color: red">删除</span>原因',
  115. formType: 2,
  116. area: ['35vw', '15vw']
  117. }, function (text, index) {
  118. let callback = function (e) {
  119. window.location.reload()
  120. layer.msg(e.msg);
  121. setTimeout(function () {
  122. layer.close(index);
  123. }, 2000)
  124. }
  125. tool.post("/admin/project.report/delete", {id: data.id, remark: text}, callback);// 项目id
  126. });
  127. }
  128. if (obj.event === 'progress') { //查看
  129. let url = '/admin/project.report/progress?id=' + data.id;
  130. parent.layui.tool.side(url);
  131. }
  132. })
  133. }
  134. </script>