edit_report.html 6.6 KB

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