edit_contact.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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",
  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: 'audit_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: 150, align: 'center',
  80. templet: function (d) {
  81. console.log(d)
  82. var html = '<div class="layui-btn-group">';
  83. var btn1 = `<a class="layui-btn layui-btn-xs layui-bg-blue" href=${d.filepath} download=${d.name} lay-event="">下载</a>`;
  84. var btn2 = '';
  85. if (d.status == 0) {
  86. 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>';
  87. } else if (d.status == 3) {
  88. 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>';
  89. }
  90. return html + btn1 + btn2 + '</div>';
  91. }
  92. }
  93. ]]
  94. });
  95. //触发事件
  96. table.on('toolbar(contact)', function (obj) {
  97. var checkStatus = table.checkStatus(obj.config.id);
  98. switch (obj.event) {
  99. case 'add':
  100. parent.layui.tool.side('/admin/project.contact/add?project_id=' + project_id); // 项目id
  101. break;
  102. }
  103. });
  104. table.on('tool(contact)', function (obj) {
  105. var data = obj.data; //获得当前行数据
  106. if (obj.event === 'detail') { //查看
  107. let url = '/admin/project.contact/view?id=' + data.id;// 项目id
  108. parent.layui.tool.side(url);
  109. }
  110. if (obj.event === 'agree_contact') {
  111. let callback = function (e) {
  112. layer.msg(e.msg)
  113. parent.layui.contactTable.reload();
  114. }
  115. tool.post('/admin/project.contact/agree_contact', {id: data.id,else_id:data.else_id}, callback);
  116. }
  117. if (obj.event === 'un_contact') {
  118. layer.prompt({
  119. title: '请输入<span style="color: red">拒绝</span>原因',
  120. formType: 2,
  121. area: ['35vw', '15vw']
  122. }, function (text, index) {
  123. let callback = function (e) {
  124. layer.msg(e.msg)
  125. parent.layui.contactTable.reload();
  126. setTimeout(layer.close(index),1000);
  127. }
  128. tool.post('/admin/project.contact/un_contact', {
  129. id: data.id,
  130. else_id:data.else_id,
  131. project_id:data.project_id,
  132. audit_remark:text
  133. }, callback);
  134. });
  135. }
  136. if (obj.event === 'agree_del') {
  137. let callback = function (e) {
  138. layer.msg(e.msg)
  139. parent.layui.contactTable.reload();
  140. }
  141. tool.post('/admin/project.contact/agree_delete', {id: data.id,else_id:data.else_id}, callback);
  142. }
  143. if (obj.event === 'unagree_del') {
  144. layer.prompt({
  145. title: '请输入<span style="color: red">拒绝</span>原因',
  146. formType: 2,
  147. area: ['35vw', '15vw']
  148. }, function (text, index) {
  149. let callback = function (e) {
  150. layer.msg(e.msg)
  151. parent.layui.contactTable.reload();
  152. setTimeout(layer.close(index),1000);
  153. }
  154. tool.post('/admin/project.contact/un_delete', {id: data.id,else_id:data.else_id,audit_remark:text}, callback);
  155. });
  156. }
  157. })
  158. }
  159. </script>