index.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <style>
  2. </style>
  3. <div class="layui-fluid">
  4. <div class="layui-card">
  5. <div class="layui-form layui-form-pane layui-card-header layuiadmin-card-header-auto">
  6. <div class="layui-form-item">
  7. <div class="layui-inline">
  8. <label class="layui-form-label">考生号</label>
  9. <div class="layui-input-block">
  10. <input type="text" name="no" placeholder="请输入考生号" autocomplete="off" class="layui-input">
  11. </div>
  12. </div>
  13. <div class="layui-inline">
  14. <label class="layui-form-label">姓名</label>
  15. <div class="layui-input-block">
  16. <input type="text" name="name" placeholder="请输入姓名" autocomplete="off" class="layui-input">
  17. </div>
  18. </div>
  19. <div class="layui-inline">
  20. <label class="layui-form-label">单位</label>
  21. <div class="layui-input-block">
  22. <input type="text" name="company" placeholder="请输入单位" autocomplete="off" class="layui-input">
  23. </div>
  24. </div>
  25. <div class="layui-inline">
  26. <label class="layui-form-label">是否决赛</label>
  27. <div class="layui-input-block">
  28. <select name="status">
  29. <option value="">全部</option>
  30. {volist name="is_final_list" id="v"}
  31. <option value="{$key}">{$v}</option>
  32. {/volist}
  33. </select>
  34. </div>
  35. </div>
  36. <div class="layui-inline">
  37. <button class="layui-btn" lay-submit lay-filter="{$lay_btn}">
  38. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  39. </button>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  44. <button class="layui-btn layuiadmin-btn" data-type="add">添加</button>
  45. <button class="layui-btn layuiadmin-btn" data-type="import">批量导入</button>
  46. <button class="layui-btn layui-btn-normal layuiadmin-btn" data-type="qrcode">二维码</button>
  47. </div>
  48. <div class="layui-card-body">
  49. <table id="{$lay_table}" lay-filter="{$lay_table}"></table>
  50. <script type="text/html" id="setTpl">
  51. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  52. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  53. </script>
  54. </div>
  55. </div>
  56. </div>
  57. <script>
  58. layui.use(['index', 'admin', 'form', 'table'], function () {
  59. const $ = layui.$;
  60. const admin = layui.admin;
  61. const form = layui.form;
  62. const table = layui.table;
  63. form.render();
  64. table.render({
  65. elem: '#{$lay_table}',
  66. url: "{:url('grade/listGrade')}",
  67. cols: [
  68. [
  69. {field: 'no', title: '考生号' ,width: 100},
  70. {field: 'name', title: '姓名' ,width: 100},
  71. {field: 'company', title: '单位', width: 300},
  72. {field: 'theory_score', title: '理论得分' ,width: 150},
  73. {field: 'computer_score', title: '机操得分' ,width: 150},
  74. {field: 'total_score', title: '初赛得分' ,width: 150},
  75. {field: 'rank', title: '排名' ,width: 100},
  76. {field: 'is_final_text', title: '是否进入决赛' ,width: 200},
  77. {title: '操作', align: 'center', fixed: 'right', toolbar: '#setTpl'}
  78. ]
  79. ],
  80. page: true,
  81. limit: 50,
  82. cellMinWidth: 150,
  83. text: '对不起,加载出现异常!'
  84. });
  85. form.on('submit({$lay_btn})', function (data) {
  86. table.reload('{$lay_table}', {
  87. where: data.field,
  88. page: {
  89. curr: 1
  90. }
  91. });
  92. });
  93. //事件
  94. const active = {
  95. add: function () {
  96. const index = layer.open({
  97. type: 2,
  98. title: '添加成绩',
  99. content: "{:url('grade/gradeForm')}",
  100. maxmin: true,
  101. area: ['550px', '550px']
  102. });
  103. layer.full(index);
  104. },
  105. import: function() {
  106. layer.open({
  107. type: 2,
  108. title: '批量导入',
  109. content: "{:url('grade/import')}",
  110. maxmin: true,
  111. area: ['750px', '300px']
  112. });
  113. },
  114. qrcode: function () {
  115. layer.photos({
  116. photos: {
  117. "title": "", //相册标题
  118. "id": 123, //相册id
  119. "start": 0, //初始显示的图片序号,默认0
  120. "data": [ //相册包含的图片,数组格式
  121. {
  122. "alt": "图片名",
  123. "pid": 666, //图片id
  124. "src": "{$file_url}", //原图地址
  125. "thumb": "" //缩略图地址
  126. }
  127. ]
  128. }
  129. ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  130. });
  131. },
  132. };
  133. //监听工具条
  134. table.on('tool({$lay_table})', function (obj) {
  135. const data = obj.data;
  136. if (obj.event === 'del') {
  137. layer.confirm('确定删除此成绩吗?', function (index) {
  138. admin.req({
  139. url: "{:url('grade/delGrade')}",
  140. data: {
  141. id: data.id
  142. },
  143. done: function (res) {
  144. obj.del();
  145. layer.msg('已删除');
  146. }
  147. });
  148. layer.close(index);
  149. });
  150. } else if (obj.event === 'edit') {
  151. const index = layer.open({
  152. type: 2,
  153. title: '编辑成绩',
  154. content: "{:url('grade/gradeForm')}?id=" + data.id,
  155. maxmin: true,
  156. area: ['550px', '550px']
  157. });
  158. layer.full(index);
  159. }
  160. });
  161. $('.layui-btn.layuiadmin-btn').on('click', function () {
  162. const type = $(this).data('type');
  163. active[type] ? active[type].call(this) : '';
  164. });
  165. });
  166. </script>