project_contact.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <div class="p-3 bg-white">
  2. <table class="layui-hide" id="contact" lay-filter="contact"></table>
  3. </div>
  4. <div id="selectBox2" style="display: none;">
  5. <div id="companySelect2"></div>
  6. <button id="cc">1111</button>
  7. </div>
  8. <!-- <script type="text/html" id="toolbarcontact">
  9. <div class="layui-btn-container">
  10. <button class="layui-btn layui-btn-sm" lay-event="add">+ 新增联系函</button>
  11. </div>
  12. </script> -->
  13. <script>
  14. function contact() {
  15. let tool = layui.tool, table = layui.table;
  16. //项目任务
  17. var allcount;
  18. parent.layui.contactTable = table.render({
  19. elem: '#contact',
  20. title: '文档列表',
  21. toolbar: '#toolbarcontact',
  22. cellMinWidth: 80,
  23. parseData: function (res) { // 数据解析回调函数
  24. // 在这里可以获取数据总数
  25. allcount = res.data.length;
  26. return {
  27. code: res.code, // 数据状态码
  28. msg: res.msg, // 状态信息
  29. count: res.count, // 数据总数
  30. data: res.data // 当前页数据
  31. };
  32. },
  33. url: "/admin/project.contact/conlist",
  34. where: {'project_id': project_id},
  35. page: true, //开启分页
  36. limit: 20,
  37. cols: [[
  38. {field: 'id', title: '序号', width: 80, align: 'center',
  39. templet: function (d) {
  40. console.log(allcount,d.LAY_NUM)
  41. return allcount - (d.LAY_NUM - 1);
  42. }
  43. },
  44. {field: 'title', title: '联系函名称',align: 'center',
  45. templet: function (d) {
  46. var html = "";
  47. if (d.status == 5) {
  48. html = '<a class="side-a" lay-event="detail" style="color: grey;text-decoration:line-through" lay-event="detail">' + d.title + '</a>';
  49. } else {
  50. html = '<a class="side-a" lay-event="detail" lay-event="detail">' + d.title + '</a>';
  51. }
  52. return '<div style="text-align:left">' + html + '</div>'
  53. }
  54. },
  55. {
  56. field: 'audit_status',
  57. title: '审批状态',
  58. align: 'center',
  59. width: 150,
  60. templet: function (d) {
  61. var abc = '';
  62. if (d.status == 0) {
  63. abc = "<span>未审核(新建)</span>";
  64. } else if (d.status == 1) {
  65. abc = "<span>已通过(新建)</span>";
  66. } else if (d.status == 2) {
  67. abc = "<span>已拒绝(新建)</span>";
  68. } else if (d.status == 3) {
  69. abc = "<span>未审核(删除)</span>";
  70. } else if (d.status == 4) {
  71. abc = "<span>已通过(删除)</span>";
  72. } else if (d.status == 5) {
  73. abc = "<span>已拒绝(删除)</span>";
  74. } else if (d.status == 8) {
  75. abc = "<span>回复</span>";
  76. }
  77. return abc;
  78. }
  79. },
  80. {field: 'create_time', title: '创建时间', align: 'center', width: 150},
  81. {field: 'admin_name', title: '创建人', align: 'center', width: 100},
  82. {field: 'approver', title: '审批人', align: 'center', width: 100},
  83. {field: 'right', fixed: 'right', title: '操作', width: 100, align: 'center',
  84. templet: function (d) {
  85. var html = '<div class="layui-btn-group">';
  86. var btn1 = `<a class="layui-btn layui-btn-xs layui-bg-blue" href=${d.filepath} download=${d.name} lay-event="">下载</a>`;
  87. var btn2 = '';
  88. if (d.status == 0) {
  89. btn2 = '<span class="layui-btn layui-btn-xs" lay-event="agree_contact">同意</span><span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="un_contact">拒绝</span>';
  90. } else if (d.status == 3) {
  91. btn2 = '<span class="layui-btn layui-btn-xs" lay-event="agree_del">同意</span><span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="unagree_del">拒绝</span>';
  92. }
  93. return html + btn1 + btn2 + '</div>';
  94. }
  95. }
  96. ]]
  97. });
  98. //触发事件
  99. table.on('toolbar(contact)', function (obj) {
  100. var checkStatus = table.checkStatus(obj.config.id);
  101. switch (obj.event) {
  102. case 'add':
  103. parent.layui.tool.side('/admin/project.contact/add?project_id=' + project_id); // 项目id
  104. break;
  105. }
  106. });
  107. table.on('tool(contact)', function (obj) {
  108. var data = obj.data; //获得当前行数据
  109. if (obj.event === 'detail') { //查看
  110. let url = '/admin/project.contact/view?id=' + data.id;// 项目id
  111. parent.layui.tool.side(url);
  112. }
  113. if (obj.event === 'agree_contact') {
  114. let callback = function (e) {
  115. layer.msg(e.msg)
  116. parent.layui.reportTable.reload();
  117. }
  118. tool.post('/admin/project.contact/agree_contact', {id: data.id,else_id:data.else_id}, callback);
  119. }
  120. if (obj.event === 'un_contact') {
  121. var ttxx = layer.prompt({
  122. title: '请输入<span style="color: red">拒绝</span>原因',
  123. formType: 2,
  124. area: ['35vw', '15vw']
  125. }, function (text, index) {
  126. let callback = function (e) {
  127. layer.msg(e.msg)
  128. parent.layui.reportTable.reload();
  129. setTimeout(layer.close(index),1000);
  130. }
  131. tool.post('/admin/project.contact/un_contact', {id: data.id,else_id:data.else_id,audit_remark:text}, callback);
  132. });
  133. }
  134. if (obj.event === 'agree_del') {
  135. let callback = function (e) {
  136. layer.msg(e.msg)
  137. parent.layui.reportTable.reload();
  138. }
  139. tool.post('/admin/project.contact/agree_delete', {id: data.id,else_id:data.else_id}, callback);
  140. }
  141. if (obj.event === 'unagree_del') {
  142. var ttxx = layer.prompt({
  143. title: '请输入<span style="color: red">拒绝</span>原因',
  144. formType: 2,
  145. area: ['35vw', '15vw']
  146. }, function (text, index) {
  147. let callback = function (e) {
  148. layer.msg(e.msg)
  149. parent.layui.reportTable.reload();
  150. setTimeout(layer.close(index),1000);
  151. }
  152. tool.post('/admin/project.contact/un_delete', {id: data.id,else_id:data.else_id,audit_remark:text}, callback);
  153. });
  154. }
  155. })
  156. }
  157. </script>