project_contact.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <div class="p-3 bg-white">
  2. <table class="layui-hide" id="contact" lay-filter="contact"></table>
  3. </div>
  4. <script>
  5. function contact() {
  6. let tool = layui.tool, table = layui.table;
  7. //项目任务
  8. var allcount;
  9. parent.layui.contactTable = table.render({
  10. elem: '#contact',
  11. title: '文档列表',
  12. toolbar: '#toolbarcontact',
  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.contact/conlist_company",
  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.audit_status == 0 || d.audit_status == 2){
  39. html = '<a class="side-a" lay-event="detail" lay-event="detail">' + d.title + '</a>';
  40. }else{
  41. html = '<a class="side-a" lay-event="detail" style="color: grey;text-decoration:line-through" lay-event="detail">' + d.title + '</a>';
  42. }
  43. return '<div style="text-align:left">' + html + '</div>'
  44. }
  45. },
  46. {
  47. field: 'audit_status',
  48. title: '审批状态',
  49. align: 'center',
  50. width: 150,
  51. templet:function (d){
  52. var html = '';
  53. if(d.audit_status == 0){
  54. html = '<span class="layui-badge layui-bg-orange" style="background-color: #ffb800">未审核</span> ';
  55. }else if(d.audit_status == 1){
  56. html = '<span class="layui-badge layui-bg-red" style="background-color: #5825aa">未通过</span> ';
  57. }else{
  58. html = '<span class="layui-badge layui-bg-green" style="background-color: #d37000">已通过</span> ';
  59. }
  60. return html;
  61. }
  62. },
  63. {field: 'create_time', title: '创建时间', align: 'center', width: 150},
  64. {field: 'admin_name', title: '创建人', align: 'center', width: 100},
  65. {field: 'approver', title: '审批人', align: 'center', width: 100},
  66. {field: 'right', fixed: 'right', title: '操作', width: 100, align: 'center',
  67. templet: function (d) {
  68. var html = '<div class="layui-btn-group">';
  69. var btn1 = `<a class="layui-btn layui-btn-xs layui-bg-blue" lay-event="detail">查看</a>`;
  70. var btn3 = `<a class="layui-btn layui-btn-xs" href=${d.filepath} download=${d.name} lay-event="">下载</a>`;
  71. return html + btn1 + btn3 + '</div>';
  72. }
  73. }
  74. ]]
  75. });
  76. //触发事件
  77. table.on('toolbar(contact)', function (obj) {
  78. var checkStatus = table.checkStatus(obj.config.id);
  79. switch (obj.event) {
  80. case 'add':
  81. parent.layui.tool.side('/admin/project.contact/add_company?project_id=' + project_id); // 项目id
  82. break;
  83. }
  84. });
  85. table.on('tool(contact)', function (obj) {
  86. var data = obj.data; //获得当前行数据
  87. if (obj.event === 'detail') { //查看
  88. let url = '/admin/project.contact/view_company?id=' + data.id;// 项目id
  89. parent.layui.tool.side(url);
  90. }
  91. if (obj.event === 'edit') { //查看
  92. let url = '/admin/project.contact/edit_company?id=' + data.id;// 项目id
  93. parent.layui.tool.side(url);
  94. }
  95. if (obj.event === 'del') {
  96. layer.prompt({title: '请输入<span style="color: red">删除</span>原因', formType: 2,area: ['35vw', '15vw']}, function(text, index){
  97. let callback = function (e) {
  98. parent.layui.contactTable.reload()
  99. layer.msg(e.msg);
  100. setTimeout(function (){
  101. layer.close(index);
  102. },2000)
  103. }
  104. tool.post("/admin/project.contact/delete_company", {id: data.id ,remark:text}, callback);// 项目id
  105. });
  106. }
  107. })
  108. }
  109. </script>