project_report.html 5.4 KB

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