project_report.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <div class="p-3 bg-white">
  2. <table class="layui-hide" id="report" lay-filter="report"></table>
  3. </div>
  4. <script>
  5. function report() {
  6. if ($('#projectTab').find('li').eq(2).data('load') == 'true') {
  7. return false;
  8. }
  9. $('#projectTab').find('li').eq(2).data('load', 'true');
  10. let tool = layui.tool, table = layui.table;
  11. //项目任务
  12. parent.layui.reportTable = table.render({
  13. elem: '#report',
  14. title: '文档列表',
  15. toolbar: '#toolbarreport',
  16. cellMinWidth: 80,
  17. url: "/admin/project.report/datalist",
  18. where: {'project_id': project_id},
  19. page: true, //开启分页
  20. limit: 20,
  21. cols: [[
  22. {field: 'id', title: '序号', width: 80, align: 'center'},
  23. {field: 'title', title: '报告名称',align: 'center',
  24. templet: function (d) {
  25. var html = "";
  26. if(d.status == 1){
  27. html = '<a class="side-a" lay-event="detail" lay-event="detail">' + d.title + '</a>';
  28. }else{
  29. html = '<a class="side-a" lay-event="detail" style="color: grey;text-decoration:line-through" lay-event="detail">' + d.title + '</a>';
  30. }
  31. return '<div style="text-align:left">' + html + '</div>'
  32. }
  33. },
  34. {field: 'type', title: '报告类型', align: 'center', width: 100,templet:function (item){
  35. var html = '';
  36. if(item.type === 0){
  37. html = "<span>初审报告</span>";
  38. }else if(item.type === 1){
  39. html = "<span>对数报告</span>";
  40. }else if(item.type === 2){
  41. html = "<span>审定报告</span>";
  42. }
  43. return html;
  44. }},
  45. {field: 'create_time', title: '创建时间', align: 'center', width: 150},
  46. {field: 'admin_name', title: '创建人', align: 'center', width: 100},
  47. {field: 'right', fixed: 'right', title: '操作', width: 100, align: 'center',
  48. templet: function (d) {
  49. var html = '<div class="layui-btn-group">';
  50. var btn1 = `<a class="layui-btn layui-btn-xs" href=${d.filepath} download=${d.name} lay-event="">下载</a>`;
  51. return html + btn1 + '</div>';
  52. }
  53. }
  54. ]]
  55. });
  56. //触发事件
  57. table.on('toolbar(report)', function (obj) {
  58. var checkStatus = table.checkStatus(obj.config.id);
  59. switch (obj.event) {
  60. case 'add':
  61. parent.layui.tool.side('/admin/project.report/add?project_id=' + project_id); // 项目id
  62. break;
  63. }
  64. });
  65. table.on('tool(report)', function (obj) {
  66. var data = obj.data; //获得当前行数据
  67. if (obj.event === 'detail') { //查看
  68. let url = '/admin/project.report/view?id=' + data.id;// 项目id
  69. parent.layui.tool.side(url);
  70. }
  71. if (obj.event === 'del') {
  72. layer.prompt({title: '请输入<span style="color: red">删除</span>原因', formType: 2,area: ['35vw', '15vw']}, function(text, index){
  73. let callback = function (e) {
  74. window.location.reload()
  75. layer.msg(e.msg);
  76. setTimeout(function (){
  77. layer.close(index);
  78. },2000)
  79. }
  80. tool.post("/admin/project.report/delete", {id: data.id ,remark:text}, callback);// 项目id
  81. });
  82. }
  83. })
  84. }
  85. </script>