index.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app">
  5. <!-- 搜索条件(状态筛选,无名称搜索) -->
  6. <div class="layui-col-md12">
  7. <div class="layui-card">
  8. <div class="layui-card-header">搜索条件</div>
  9. <div class="layui-card-body">
  10. <form class="layui-form layui-form-pane" action="">
  11. <div class="layui-form-item">
  12. <div class="layui-inline">
  13. <label class="layui-form-label">处理状态</label>
  14. <div class="layui-input-block">
  15. <select name="status">
  16. <option value="-1" {if $status == -1}selected{/if}>全部状态</option>
  17. <option value="0" {if $status == 0}selected{/if}>未处理</option>
  18. <option value="1" {if $status == 1}selected{/if}>已处理</option>
  19. </select>
  20. </div>
  21. </div>
  22. <div class="layui-inline">
  23. <div class="layui-input-inline">
  24. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  25. <i class="layui-icon layui-icon-search"></i>筛选</button>
  26. </div>
  27. </div>
  28. </div>
  29. </form>
  30. </div>
  31. </div>
  32. </div>
  33. <!-- 报修列表 -->
  34. <div class="layui-col-md12">
  35. <div class="layui-card">
  36. <div class="layui-card-header">设备报修列表</div>
  37. <div class="layui-card-body">
  38. <!-- 无添加按钮(报修由用户提交,后台仅管理) -->
  39. <table class="layui-hide" id="List" lay-filter="List"></table>
  40. <!-- 状态列模板(同步status字段) -->
  41. <script type="text/html" id="status">
  42. {{# if(d.status == 0) { }}
  43. <span class="layui-badge layui-badge-danger">未处理</span>
  44. {{# } else { }}
  45. <span class="layui-badge layui-badge-normal">已处理</span>
  46. {{# } }}
  47. </script>
  48. <!-- 操作列模板(下拉框,包含下载、标记处理、删除) -->
  49. <script type="text/html" id="act">
  50. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
  51. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  52. <li>
  53. <a href="javascript:void(0)" lay-event="download">
  54. <i class="fa fa-download"></i> 下载表单
  55. </a>
  56. </li>
  57. {{# if(d.status == 0) { }}
  58. <li>
  59. <a href="javascript:void(0)" lay-event="mark_handle">
  60. <i class="fa fa-check"></i> 标记已处理
  61. </a>
  62. </li>
  63. {{# } }}
  64. <li>
  65. <a href="javascript:void(0)" lay-event="delete">
  66. <i class="fa fa-times"></i> 删除报修单
  67. </a>
  68. </li>
  69. </ul>
  70. </script>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  77. {/block}
  78. {block name="script"}
  79. <script>
  80. // 实例化form(渲染下拉框)
  81. layList.form.render();
  82. // 加载报修列表(接口对应后台repair_list方法)
  83. layList.tableList('List', "{:Url('repair_list')}", function () {
  84. return [
  85. {field: 'id', title: '编号', sort: true, event: 'id', width: '6%', align: "center"},
  86. {field: 'repair_sn', title: '报修单号', width: '15%', align: "center"},
  87. {field: 'device_name', title: '设备名称', width: '12%', align: "center"},
  88. {field: 'device_number', title: '数量', width: '6%', align: "center"},
  89. {field: 'contact_name', title: '联系人', width: '8%', align: "center"},
  90. {field: 'contact_phone', title: '联系电话', width: '10%', align: "center"},
  91. {field: 'create_time', title: '提交时间', width: '15%', align: "center",
  92. templet: function(d) { return layList.date(d.create_time); }}, // 用layList自带时间格式化
  93. {field: 'status', title: '处理状态', templet: '#status', width: '10%', align: "center"},
  94. {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '12%'},
  95. ];
  96. });
  97. // 状态筛选回调(传递status参数)
  98. layList.search('search', function (where) {
  99. // 处理筛选参数:默认-1为全部,0=未处理,1=已处理
  100. where.status = where.status || -1;
  101. layList.reload(where, true);
  102. });
  103. // 行工具事件(下载、标记处理、删除)
  104. layList.tool(function (event, data, obj) {
  105. switch (event) {
  106. // 下载表单
  107. case 'download':
  108. window.location.href = "{:Url('download')}?id=" + data.id;
  109. break;
  110. // 标记为已处理(调用set_status接口)
  111. case 'mark_handle':
  112. $eb.$swal('confirm', '确定标记为已处理吗?', function () {
  113. layList.baseGet(layList.Url({
  114. a: 'set_status',
  115. q: {status: 1, id: data.id} // 传递status=1(已处理)和报修单ID
  116. }), function (res) {
  117. if (res.code == 200) {
  118. $eb.$swal('success', res.msg);
  119. layList.reload(); // 刷新列表
  120. } else {
  121. $eb.$swal('error', res.msg);
  122. }
  123. });
  124. });
  125. break;
  126. // 删除报修单
  127. case 'delete':
  128. $eb.$swal('delete', function () {
  129. layList.baseGet(layList.Url({
  130. a: 'delete',
  131. q: {id: data.id}
  132. }), function (res) {
  133. if (res.code == 200) {
  134. $eb.$swal('success', res.msg);
  135. obj.del(); // 删除当前行
  136. } else {
  137. $eb.$swal('error', res.msg);
  138. }
  139. });
  140. });
  141. break;
  142. }
  143. });
  144. // 下拉操作框-点击收起(完全复用参考样式逻辑)
  145. $(document).click(function (e) {
  146. $('.layui-nav-child').hide();
  147. });
  148. // 下拉操作框-位置计算(完全复用参考样式逻辑)
  149. function dropdown(that) {
  150. var oEvent = arguments.callee.caller.arguments[0] || event;
  151. oEvent.stopPropagation();
  152. var offset = $(that).offset();
  153. var top = offset.top - $(window).scrollTop();
  154. var index = $(that).parents('tr').data('index');
  155. $('.layui-nav-child').each(function (key) {
  156. if (key != index) {
  157. $(this).hide();
  158. }
  159. });
  160. if ($(document).height() < top + $(that).next('ul').height()) {
  161. $(that).next('ul').css({
  162. 'padding': 10,
  163. 'top': -($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height() / 2),
  164. 'min-width': 'inherit',
  165. 'position': 'absolute'
  166. }).toggle();
  167. } else {
  168. $(that).next('ul').css({
  169. 'padding': 10,
  170. 'top': $(that).parent('td').height() / 2 + $(that).height(),
  171. 'min-width': 'inherit',
  172. 'position': 'absolute'
  173. }).toggle();
  174. }
  175. }
  176. </script>
  177. {/block}