detectionGroup.html 8.5 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. , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 200 }
  178. ]]
  179. , id: 'tableReload'
  180. , page: {
  181. layout: ['prev', 'page', 'next', 'count']
  182. , groups: 3 //只显示 1 个连续页码
  183. , first: true //不显示首页
  184. , last: true //不显示尾页
  185. , theme: '#428bca'
  186. }
  187. });
  188. // table.on('checkbox(conpanyList)', function (obj) {
  189. // console.log(obj.checked); //当前是否选中状态
  190. // console.log(obj.data); //选中行的相关数据
  191. // console.log(obj.type); //如果触发的是全选,则为:all,如果触发的是单选,则为:one
  192. // });
  193. //监听行工具事件
  194. table.on('tool(conpanyList)', function (obj) {
  195. var data = obj.data;
  196. console.log(obj)
  197. id = obj.data.id
  198. if (obj.event === 'edit') {
  199. var index = layer.open({
  200. type: 2,
  201. title: '添加单位信息',
  202. shadeClose: false,
  203. shade: [0.5, '#000'],
  204. area: ['50%', '60%'],
  205. content: '/detection_add?id=' + id //iframe的url
  206. });
  207. } else if (obj.event === 'del') {
  208. var userid = [];
  209. userid.push(id)
  210. layer.confirm('是否删除“ ' + obj.data.name + ' ”!', {
  211. title: '删除'
  212. , icon: 3
  213. , btn: ['确定', '取消']
  214. }, function (index, layero) {
  215. $.ajax({
  216. url: 'dele',
  217. type: 'get',
  218. async: true,
  219. data: {
  220. id: JSON.stringify(userid)
  221. },
  222. // dataType: 'json',
  223. success: function (data) {
  224. if (data == 0) {
  225. //执行重载
  226. var companyInp = $('#companyInp');
  227. table.reload('tableReload', {
  228. where: {
  229. id: companyInp.val()
  230. }
  231. }, 'data');
  232. //无法关闭这个消息框
  233. layer.closeAll('dialog'); //加入这个信息点击确定 会关闭这个消息框
  234. layer.msg("删除成功!", { icon: 1, time: 1000 });
  235. }
  236. },
  237. error: function (type) {
  238. }
  239. })
  240. }
  241. );
  242. } else if (obj.event === 'upImg') {
  243. var index = layer.open({
  244. type: 2,
  245. title: '添加单位图像',
  246. shadeClose: false,
  247. shade: [0.5, '#000'],
  248. area: ['50%', '90%'],
  249. content: '/addCompanyImg?id=' + id //iframe的url
  250. });
  251. }
  252. });
  253. var $ = layui.$, active = {
  254. reload: function () {
  255. var companyInp = $('#companyInp');
  256. //执行重载
  257. table.reload('tableReload', {
  258. page: {
  259. curr: 1 //重新从第 1 页开始
  260. }
  261. , where: {
  262. id: companyInp.val()
  263. }
  264. }, 'data');
  265. }
  266. };
  267. // 搜索
  268. $('.searchTable .layui-btn').on('click', function () {
  269. var type = $(this).data('type');
  270. active[type] ? active[type].call(this) : '';
  271. });
  272. $('.searchTable #companyInp').on('keyup', function (event) {
  273. if (event.keyCode == 13) {
  274. active.reload()
  275. }
  276. });
  277. });
  278. function addData() {
  279. var index = layer.open({
  280. type: 2,
  281. title: '添加单位信息',
  282. shadeClose: false,
  283. shade: [0.5, '#000'],
  284. area: ['800px', '50%'],
  285. content: 'detection_add' //iframe的url
  286. });
  287. }
  288. </script>
  289. </body>
  290. </html>