project_report.html 5.3 KB

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