edit_contact.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <div class="p-3 bg-white">
  2. <table class="layui-hide" id="contact" lay-filter="contact"></table>
  3. </div>
  4. <script type="text/html" id="toolbarcontact">
  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 contact() {
  11. let tool = layui.tool, table = layui.table;
  12. //项目任务
  13. var allcount;
  14. parent.layui.contactTable = table.render({
  15. elem: '#contact',
  16. title: '文档列表',
  17. toolbar: '#toolbarcontact',
  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.contact/conlist_company",
  30. where: {'project_id': project_id},
  31. page: true, //开启分页
  32. limit: 20,
  33. cols: [[
  34. {field: 'id', title: '序号', width: 80, 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 == 5){
  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. {
  52. field: 'status',
  53. title: '审批状态',
  54. align: 'center',
  55. width: 150,
  56. templet:function (d){
  57. var abc = '';
  58. if(d.status==0){
  59. abc = "<span>未审核(新建)</span>";
  60. }else if(d.status==1){
  61. abc = "<span>已通过(新建)</span>";
  62. }else if(d.status==2){
  63. abc = "<span>已拒绝(新建)</span>";
  64. }else if(d.status==3){
  65. abc = "<span>未审核(删除)</span>";
  66. }else if(d.status==4){
  67. abc = "<span>已通过(删除)</span>";
  68. }else if(d.status==5){
  69. abc = "<span>已拒绝(删除)</span>";
  70. } else if (d.status == 8) {
  71. abc = "<span>回复</span>";
  72. }
  73. return abc;
  74. }
  75. },
  76. {field: 'create_time', title: '创建时间', align: 'center', width: 150},
  77. {field: 'admin_name', title: '创建人', align: 'center', width: 100},
  78. {field: 'approver', title: '审批人', align: 'center', width: 100},
  79. {field: 'right', fixed: 'right', title: '操作', width: 100, align: 'center',
  80. templet: function (d) {
  81. var html = '<div class="layui-btn-group">';
  82. var btn1 = `<a class="layui-btn layui-btn-xs" href=${d.filepath} download=${d.name} lay-event="">下载</a>`;
  83. var btn2 = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span>';
  84. return html + btn1 + btn2 + '</div>';
  85. }
  86. }
  87. ]]
  88. });
  89. //触发事件
  90. table.on('toolbar(contact)', function (obj) {
  91. var checkStatus = table.checkStatus(obj.config.id);
  92. switch (obj.event) {
  93. case 'add':
  94. let callback = function (e) {
  95. window.location.reload()
  96. layer.msg(e.msg);
  97. setTimeout(function (){
  98. layer.close(index);
  99. },2000)
  100. }
  101. parent.layui.tool.side('/admin/project.contact/add_company?project_id=' + project_id,callback); // 项目id
  102. break;
  103. }
  104. });
  105. table.on('tool(contact)', function (obj) {
  106. var data = obj.data; //获得当前行数据
  107. console.log(data.status);
  108. if (obj.event === 'detail') { //查看
  109. let url = '/admin/project.contact/view_company?id=' + data.id;// 项目id
  110. parent.layui.tool.side(url);
  111. }
  112. if (obj.event === 'del') {
  113. if(data.status==1){
  114. layer.prompt({title: '请输入<span style="color: red">删除</span>原因', formType: 2,area: ['35vw', '15vw']}, function(text, index){
  115. let callback = function (e) {
  116. parent.layui.contactTable.reload()
  117. layer.msg(e.msg);
  118. setTimeout(function (){
  119. layer.close(index);
  120. },2000)
  121. }
  122. tool.post("/admin/project.contact/delete_company", {id: data.id ,project_id:data.project_id,remark:text}, callback);// 项目id
  123. });
  124. }else {
  125. layer.msg("不可操作");
  126. }
  127. }
  128. })
  129. }
  130. </script>