staffManage.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. {% load staticfiles %}
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>人员管理</title>
  7. <meta name="renderer" content="webkit">
  8. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  10. <link rel="stylesheet" href="{% static '/lib/css/ace.min.css' %}" />
  11. <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
  12. <style>
  13. html,body{
  14. background: #fff;
  15. }
  16. .searchTable {
  17. position: absolute;
  18. right: 15px;
  19. top: 0;
  20. }
  21. .searchTable input {
  22. height: 30px;
  23. line-height: 33px;
  24. }
  25. .addData {
  26. /* text-align: right; */
  27. }
  28. /* 表格样式 */
  29. .layui-table thead tr {
  30. /* background-color: #e0f6ea; */
  31. }
  32. .layui-table th,
  33. .layui-table tr {
  34. text-align: center;
  35. }
  36. .editBtn,
  37. .delBtn {
  38. cursor: pointer;
  39. margin: 0 5px;
  40. }
  41. .green {
  42. color: #5FB878;
  43. }
  44. .red {
  45. color: #e01515;
  46. }
  47. .delBtn:hover {
  48. color: #e01515;
  49. text-decoration: underline;
  50. }
  51. .editBtn:hover {
  52. color: #5FB878;
  53. text-decoration: underline;
  54. }
  55. </style>
  56. </head>
  57. <body>
  58. <div class="layui-fluid">
  59. <div class="layui-row layui-col-space15">
  60. <div class="layui-col-md12">
  61. <div class="layui-card">
  62. <div class="layui-card-header">
  63. <div class="searchTable">
  64. <div class="layui-inline">
  65. <input class="layui-input" name="id" id="companyInp" placeholder="请输入设备ID" autocomplete="off">
  66. </div>
  67. <button class="btn btn-sm btn-primary" data-type="reload">搜索</button>
  68. </div>
  69. <div class="addData">
  70. <button class="btn btn-sm btn-primary" data-type="reload" onclick="addData()"> 新建 </button>
  71. </div>
  72. </div>
  73. <div class="layui-card-body">
  74. <table class="layui-hide baseTable" id="conpanyList" lay-filter="conpanyList"></table>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <script type="text/html" id="barDemo">
  81. <a class="editBtn green" lay-event="edit">编辑</a>
  82. |
  83. <a class="delBtn red" lay-event="del">删除</a>
  84. <!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"></a> -->
  85. </script>
  86. <script src="{% static '/lib/layui/layui.all.js' %}"></script>
  87. <script>
  88. var table, layer;
  89. layui.use(['table', 'layer'], function () {
  90. table = layui.table;
  91. layer = layui.layer;
  92. var data = [
  93. {
  94. "id": 10000,
  95. "basename": "基地1",
  96. "basearea": "33",
  97. "basesite": "城市-0",
  98. "remark": "签名-0"
  99. },
  100. {
  101. "id": 10000,
  102. "basename": "基地1",
  103. "basearea": "33",
  104. "basesite": "城市-0",
  105. "remark": "签名-0"
  106. },
  107. {
  108. "id": 10000,
  109. "basename": "基地1",
  110. "basearea": "33",
  111. "basesite": "城市-0",
  112. "remark": "签名-0"
  113. },
  114. {
  115. "id": 10000,
  116. "basename": "基地1",
  117. "basearea": "33",
  118. "basesite": "城市-0",
  119. "remark": "签名-0"
  120. },
  121. {
  122. "id": 10000,
  123. "basename": "基地1",
  124. "basearea": "33",
  125. "basesite": "城市-0",
  126. "remark": "签名-0"
  127. },
  128. {
  129. "id": 10000,
  130. "basename": "基地1",
  131. "basearea": "33",
  132. "basesite": "城市-0",
  133. "remark": "签名-0"
  134. },
  135. {
  136. "id": 10000,
  137. "basename": "基地1",
  138. "basearea": "33",
  139. "basesite": "城市-0",
  140. "remark": "签名-0"
  141. },
  142. {
  143. "id": 10000,
  144. "basename": "基地1",
  145. "basearea": "33",
  146. "basesite": "城市-0",
  147. "remark": "签名-0"
  148. },
  149. {
  150. "id": 10000,
  151. "basename": "基地1",
  152. "basearea": "33",
  153. "basesite": "城市-0",
  154. "remark": "签名-0"
  155. }, {
  156. "id": 10001,
  157. "basename": "基地2",
  158. "basearea": "54",
  159. "basesite": "城市-1",
  160. "remark": "签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1"
  161. }
  162. ];
  163. // 方法渲染表格
  164. table.render({
  165. elem: '#conpanyList'
  166. // , url: 'list'
  167. , data: data
  168. ,skin: 'line' //行边框风格
  169. ,even: true //开启隔行背景
  170. , method: 'post' //如果无需自定义HTTP类型,可不加该参数
  171. , title: '用户数据表'
  172. , cols: [[
  173. { type: 'checkbox' }
  174. , { field: 'basename', title: '姓名', }
  175. , { field: 'basearea', title: '联系电话', }
  176. , { field: 'basesite', title: '负责基地', }
  177. , { field: 'remark', title: '备注', }
  178. , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 200 }
  179. ]]
  180. , id: 'tableReload'
  181. , page: {
  182. layout: ['prev', 'page', 'next', 'count']
  183. , groups: 3 //只显示 1 个连续页码
  184. , first: true //不显示首页
  185. , last: true //不显示尾页
  186. , theme: '#428bca'
  187. }
  188. });
  189. // table.on('checkbox(conpanyList)', function (obj) {
  190. // console.log(obj.checked); //当前是否选中状态
  191. // console.log(obj.data); //选中行的相关数据
  192. // console.log(obj.type); //如果触发的是全选,则为:all,如果触发的是单选,则为:one
  193. // });
  194. //监听行工具事件
  195. table.on('tool(conpanyList)', function (obj) {
  196. var data = obj.data;
  197. console.log(obj)
  198. id = obj.data.id
  199. if (obj.event === 'edit') {
  200. var index = layer.open({
  201. type: 2,
  202. title: '添加单位信息',
  203. shadeClose: false,
  204. shade: [0.5, '#000'],
  205. area: ['50%', '60%'],
  206. content: '/user_add?id=' + id //iframe的url
  207. });
  208. } else if (obj.event === 'del') {
  209. var userid = [];
  210. userid.push(id)
  211. layer.confirm('是否删除“ ' + obj.data.name + ' ”!', {
  212. title: '删除'
  213. , icon: 3
  214. , btn: ['确定', '取消']
  215. }, function (index, layero) {
  216. $.ajax({
  217. url: 'dele',
  218. type: 'get',
  219. async: true,
  220. data: {
  221. id: JSON.stringify(userid)
  222. },
  223. // dataType: 'json',
  224. success: function (data) {
  225. if (data == 0) {
  226. //执行重载
  227. var companyInp = $('#companyInp');
  228. table.reload('tableReload', {
  229. where: {
  230. id: companyInp.val()
  231. }
  232. }, 'data');
  233. //无法关闭这个消息框
  234. layer.closeAll('dialog'); //加入这个信息点击确定 会关闭这个消息框
  235. layer.msg("删除成功!", { icon: 1, time: 1000 });
  236. }
  237. },
  238. error: function (type) {
  239. }
  240. })
  241. }
  242. );
  243. } else if (obj.event === 'upImg') {
  244. var index = layer.open({
  245. type: 2,
  246. title: '添加单位图像',
  247. shadeClose: false,
  248. shade: [0.5, '#000'],
  249. area: ['50%', '90%'],
  250. content: '/addCompanyImg?id=' + id //iframe的url
  251. });
  252. }
  253. });
  254. var $ = layui.$, active = {
  255. reload: function () {
  256. var companyInp = $('#companyInp');
  257. //执行重载
  258. table.reload('tableReload', {
  259. page: {
  260. curr: 1 //重新从第 1 页开始
  261. }
  262. , where: {
  263. id: companyInp.val()
  264. }
  265. }, 'data');
  266. }
  267. };
  268. // 搜索
  269. $('.searchTable .layui-btn').on('click', function () {
  270. var type = $(this).data('type');
  271. active[type] ? active[type].call(this) : '';
  272. });
  273. $('.searchTable #companyInp').on('keyup', function (event) {
  274. if (event.keyCode == 13) {
  275. active.reload()
  276. }
  277. });
  278. });
  279. function addData() {
  280. var index = layer.open({
  281. type: 2,
  282. title: '添加单位信息',
  283. shadeClose: false,
  284. shade: [0.5, '#000'],
  285. area: ['800px', '60%'],
  286. content: 'user_add' //iframe的url
  287. });
  288. }
  289. </script>
  290. </body>
  291. </html>