list.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6. <title>临时人员</title>
  7. <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
  8. <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
  9. <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
  10. </head>
  11. <body>
  12. <div class="layuimini-container">
  13. <div class="layuimini-main">
  14. <fieldset class="table-search-fieldset">
  15. <legend>搜索信息(<b>收起-展开</b>)</legend>
  16. <div id="search-div" style="margin: 5px 10px -10px 0px">
  17. <form class="layui-form" action="" lay-filter="search-form">
  18. <div class="layui-form-item">
  19. <div class="layui-inline">
  20. <label class="layui-form-label" style="width: 40px">姓名</label>
  21. <div class="layui-input-inline">
  22. <input type="text" name="xm" autocomplete="off" class="layui-input">
  23. </div>
  24. </div>
  25. <div class="layui-inline">
  26. <div class="layui-inline">
  27. <label class="layui-form-label " style="width: 40px;">学历</label>
  28. <div class="layui-input-inline" style="width: 130px;">
  29. <select name="xl" id="xl" lay-search>
  30. <option value="">请选择</option>
  31. <option th:each="item:${xlList}" th:text="${item.name}"
  32. th:value="${item.name}"></option>
  33. </select>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="layui-inline">
  38. <label class="layui-form-label" style="width: 80px">身份证号</label>
  39. <div class="layui-input-inline">
  40. <input type="text" name="sfzh" autocomplete="off" class="layui-input">
  41. </div>
  42. </div>
  43. <div class="layui-inline">
  44. <div class="layui-inline">
  45. <label class="layui-form-label " style="width: 40px;">状态</label>
  46. <div class="layui-input-inline" style="width: 130px;">
  47. <select name="zt" id="zt">
  48. <option value="">[请选择]</option>
  49. <option value="0">可用</option>
  50. <option value="1">禁用</option>
  51. </select>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="layui-inline" style="margin-left: 0px">
  56. <button type="submit" class="layui-btn" lay-submit lay-filter="data-search-btn">
  57. <i class="layui-icon"></i> 搜 索
  58. </button>
  59. <button type="submit" class="layui-btn layui-btn-primary" lay-submit
  60. lay-filter="data-reset-btn">
  61. <i class="layui-icon layui-icon-refresh"></i> 重 置
  62. </button>
  63. </div>
  64. </div>
  65. </form>
  66. </div>
  67. </fieldset>
  68. <script type="text/html" id="toolbarDemo">
  69. <div class="layui-btn-container">
  70. <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add" style="background-color: #00a2d4">
  71. <i class="layui-icon layui-icon-addition" style="font-size: 10px;"></i>新增
  72. </button>
  73. <button class="layui-btn layui-btn-sm" lay-event="export" >
  74. <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>批量导出
  75. </button>
  76. <button class="layui-btn layui-btn-sm" lay-event="download" style="background-color: purple">
  77. <i class="layui-icon layui-icon-download-circle" style="font-size: 10px;"></i>模板下载
  78. </button>
  79. <button type="button" class="layui-btn layui-btn-sm" id="test3">
  80. <i class="layui-icon"></i>批量导入
  81. </button>
  82. </div>
  83. </script>
  84. <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
  85. <script type="text/html" id="optBtn">
  86. <button class="layui-btn layui-btn-sm" style="background-color: #1E9FFF" lay-event="update">编辑</button>
  87. <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delFlag">删除</button>
  88. </script>
  89. <script type="text/html" id="statusTemps">
  90. <!-- “ d ”表示当前行数据对象 -->
  91. {{# if(d.zt === 0 ){ }}
  92. <button class="layui-btn layui-btn-sm" style="background-color: #5FB878">可用</button>
  93. {{# }else{ }}
  94. <button class="layui-btn layui-btn-sm layui-btn-warm">禁用</button>
  95. {{# } }}
  96. </script>
  97. </div>
  98. </div>
  99. <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
  100. <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
  101. <script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
  102. <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
  103. <script type="text/javascript" th:inline="javascript">
  104. AjaxUtil.ctx = /*[[@{/}]]*/'';
  105. var updateflag = 0;
  106. layui.use(['form', 'table','upload'], function () {
  107. var form = layui.form,
  108. table = layui.table,
  109. layer = layui.layer,
  110. upload = layui.upload;
  111. var currTable = table.render({
  112. elem: '#currentTableId',
  113. url: AjaxUtil.ctx + 'lsUser/all',
  114. method: 'get',
  115. where: {sortName: 'ID', sortOrder: 'asc'},
  116. toolbar: '#toolbarDemo',
  117. // defaultToolbar: ['filter', 'exports', 'print'],
  118. cols: [
  119. [
  120. {type: "radio", width: '3%', fixed: 'left',title:'😊'},
  121. {type: 'numbers', align: 'center', title: '序号'},
  122. {field: 'xm', width: '7%', title: '姓名', align: 'left'},
  123. {field: 'xb', width: '5%', title: '性别', align: 'left'},
  124. {field: 'phone', width: '10%', title: '电话', align: 'left'},
  125. {field: 'sfzh', width: '10%', title: '身份证号', align: 'left'},
  126. {field: 'xl', width: '10%', title: '学历', align: 'left'},
  127. {field: 'byxy', width: '10%', title: '毕业院校', align: 'left'},
  128. {field: 'zy', width: '10%', title: '专业', align: 'left'},
  129. {field: 'zq', width: '10%', title: '聘用周期(年)', align: 'center'},
  130. {field: 'qpsj', width: '10%', title: '起聘时间', align: 'center'},
  131. {field: 'dqsj', width: '15%', title: '合同到期时间', align: 'center'},
  132. {field: 'gznr', width: '20%', title: '工作内容', align: 'left'},
  133. {field: 'zt', width: '5%', title: '状态', templet: '#statusTemps', fixed: 'right'},
  134. {title: '操作', fixed: 'right', width: '10%', toolbar: "#optBtn", align: 'center'}
  135. ]
  136. ],
  137. autoSort: false,
  138. limits: [10, 15, 20, 25, 50, 100],
  139. limit: 10,
  140. page: true,
  141. skin: 'grid',
  142. parseData: function (res) { //res 即为原始返回的数据
  143. return {
  144. "code": res.code, //解析接口状态
  145. "msg": res.message, //解析提示文本
  146. "count": res.data.total, //解析数据长度
  147. "data": res.data.rows //解析数据列表
  148. };
  149. },
  150. done: function (res, curr, count) { // done为数据渲染完的回调
  151. // 测试打印出后端返回的权限列表
  152. let permissionSet = [[${permissionSet}]];
  153. console.log(JSON.stringify(permissionSet));
  154. }
  155. });
  156. //指定允许上传的文件类型
  157. upload.render({
  158. elem: '#test3'
  159. , url: AjaxUtil.ctx + 'lsUser/file'
  160. , method: 'post'
  161. , accept: 'file' //普通文件
  162. , done: function (res) {
  163. console.log(res);
  164. console.log(res.code);
  165. if (res.code === 43) {
  166. layer.msg(res.message);
  167. }else {
  168. if (res.data && Array.isArray(res.data) && res.data.length > 0) {
  169. // 安全访问数组元素或对象属性
  170. layer.msg(res.message);
  171. table.reload('currentTableId');
  172. }
  173. console.log(res);
  174. // 将 JSON 数据转换成 HTML 表格格式
  175. var tableHtml = '<table class="layui-table"><thead><tr>' +
  176. '<th>姓名</th>' +
  177. '<th>身份证号</th>' +
  178. '<th>起聘时间</th>' +
  179. '<th>到期时间</th>' +
  180. '<th>原因</th>' +
  181. '</tr></thead><tbody>';
  182. for(var i = 0; i < res.data.length; i++) {
  183. var xm = res.data[i].xm || 'N/A';
  184. var sfzh = res.data[i].sfzh || 'N/A';
  185. var qpsj = res.data[i].qpsj || 'N/A';
  186. var dqsj = res.data[i].dqsj || 'N/A';
  187. var xmfzr = res.data[i].xmfzr || 'N/A';
  188. tableHtml += '<tr>' +
  189. '<td>' + xm + '</td>' +
  190. '<td>' + sfzh + '</td>' +
  191. '<td>' + qpsj + '</td>' +
  192. '<td>' + dqsj + '</td>' +
  193. '<td>' + xmfzr + '</td>' +
  194. '</tr>';
  195. };
  196. tableHtml += '</tbody></table>';
  197. layer.open({
  198. type: 1,
  199. title: '问题数据', // 弹框标题
  200. content: tableHtml, // 弹框内容为生成的表格 HTML
  201. area: ['1000px', '600px'] // 设置弹框大小
  202. });
  203. table.reload('currentTableId');
  204. }
  205. },
  206. });
  207. // 监听搜索操作
  208. form.on('submit(data-search-btn)', function (data) {
  209. // 执行搜索重载
  210. currTable.reload({
  211. page: {
  212. curr: 1 // 页码从1开始
  213. },
  214. where: form.val("search-form")
  215. });
  216. return false;
  217. });
  218. // 监听重置操作
  219. form.on('submit(data-reset-btn)', function () {
  220. // 表格重载
  221. table.reload('currentTableId', {
  222. data: data, // 更新后的数据源
  223. page: false, // 不分页处理
  224. limit: data.length // 限制数据条数,取数据源长度
  225. }, true);
  226. });
  227. // 监听行工具事件
  228. table.on('toolbar(currentTableFilter)', function (obj) {
  229. if (obj.event === 'add') { // 监听添加操作
  230. var index = layer.open({
  231. title: '新建人员',
  232. type: 2,
  233. shade: 0.3,
  234. maxmin: true,
  235. area: ['1000px', layerheight + 'px'],
  236. content: AjaxUtil.ctx + 'lsUser/forAdd',
  237. success: function (res) {
  238. }
  239. });
  240. } else if (obj.event == 'view') {
  241. var checkStatus = table.checkStatus('currentTableId')
  242. , data = checkStatus.data;
  243. if (data == null || data.length === 0) {
  244. Message.warning("请选择要查看的人员!", 1500);
  245. } else if (data.length > 1) {
  246. Message.warning("请选择一条记录进行查看!", 1500);
  247. } else {
  248. var index = layer.open({
  249. title: '浏览人员',
  250. type: 2,
  251. shade: 0.2,
  252. maxmin: true,
  253. area: ['1000px', layerheight + 'px'],
  254. content: AjaxUtil.ctx + 'lsUser/forView/' + data[0].id,
  255. end: function (index) {
  256. layer.close(index);
  257. }
  258. });
  259. }
  260. } else if (obj.event === 'delete') { // 监听删除操作
  261. var checkStatus = table.checkStatus('currentTableId')
  262. , data = checkStatus.data;
  263. if (data == null || data.length === 0) {
  264. Message.warning("请选择要删除的人员!", 1000);
  265. return;
  266. }
  267. layer.confirm('确定删除人员吗?', function (index) {
  268. layer.close(index);
  269. AjaxUtil.post({
  270. url: AjaxUtil.ctx + "lsUser/batchDelete",
  271. contentType: "application/json",
  272. data: JSON.stringify(data),
  273. success: function (res) {
  274. if (res.code === 0) {
  275. Message.success(1500, res.message);
  276. table.reload('currentTableId');
  277. } else {
  278. Message.error(res.message, 1000);
  279. }
  280. },
  281. error: function (error) {
  282. }
  283. });
  284. });
  285. // layer.alert(JSON.stringify(data));
  286. }else if(obj.event ==='export'){ // 监听导出按钮
  287. AjaxUtil.get({
  288. url:AjaxUtil.ctx +'lsUser/getAll',
  289. success: function(res){
  290. table.exportFile('currentTableId',res.data,'xlsx');
  291. },
  292. error:function (error) {
  293. Message.error(error,2000)
  294. }
  295. });
  296. }else if (obj.event === 'download'){
  297. window.location.href = 'http://10.208.114.107:8082/202407/Template.xlsx';
  298. }
  299. });
  300. // 监听行工具事件
  301. table.on('tool(currentTableFilter)', function (obj) {
  302. console.log(obj);
  303. var data = obj.data;
  304. if (obj.event === 'view') {
  305. var index = layer.open({
  306. title: '浏览人员',
  307. type: 2,
  308. shade: 0.2,
  309. maxmin: true,
  310. area: ['1000px', layerheight + 'px'],
  311. content: AjaxUtil.ctx + 'lsUser/forView/' + data.id,
  312. end: function (index) {
  313. layer.close(index);
  314. }
  315. });
  316. } else if (obj.event === 'update') {
  317. console.log(data.id);
  318. var index = layer.open({
  319. title: '编辑人员',
  320. type: 2,
  321. shade: 0.2,
  322. maxmin: true,
  323. area: ['1000px', layerheight + 'px'],
  324. content: AjaxUtil.ctx + 'lsUser/up/' + data.id,
  325. end: function (index) {
  326. }
  327. });
  328. } else if (obj.event === 'delFlag') {
  329. layer.confirm('确定删除该人员吗?', function (index) {
  330. layer.close(index);
  331. AjaxUtil.post({
  332. url: AjaxUtil.ctx + "lsUser/delete/" + data.id,
  333. success: function (res) {
  334. if (res.code === 0) {
  335. layer.msg(res.message);
  336. table.reload('currentTableId');
  337. } else {
  338. layer.msg(res.message);
  339. table.reload('currentTableId');
  340. }
  341. },
  342. error: function (error) {
  343. layer.alert('服务器睡着了', {icon: 5});
  344. console.log(error);
  345. table.reload('currentTableId');
  346. }
  347. });
  348. });
  349. }
  350. return false;
  351. });
  352. });
  353. </script>
  354. </body>
  355. </html>