seedManage.html 8.8 KB

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