| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- {% load staticfiles %}
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>种子种苗管理</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <link href="{% static '/lib/bootstrap-3.3.7/css/bootstrap.css' %}" rel="stylesheet">
- <link rel="stylesheet" href="{% static '/lib/font-awesome/4.5.0/css/font-awesome.css' %}">
- <link rel="stylesheet" href="{% static '/lib/css/ace.min.css' %}" />
- <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
- <style>
- html,body{
- background: #fff;
- }
- .searchTable {
- position: absolute;
- right: 15px;
- top: 0;
- }
- .searchTable input {
- height: 30px;
- line-height: 33px;
- }
- .addData {
- /* text-align: right; */
- }
- /* 表格样式 */
- .layui-table thead tr {
- /* background-color: #e0f6ea; */
- }
- .layui-table th,
- .layui-table tr {
- text-align: center;
- }
- .editBtn,
- .delBtn {
- cursor: pointer;
- margin: 0 5px;
- }
- .green {
- color: #5FB878;
- }
- .red {
- color: #e01515;
- }
- .delBtn:hover {
- color: #e01515;
- text-decoration: underline;
- }
- .editBtn:hover {
- color: #5FB878;
- text-decoration: underline;
- }
- </style>
- </head>
- <body>
- <div class="layui-fluid">
- <div class="layui-row layui-col-space15">
- <div class="layui-col-md12">
- <div class="layui-card">
- <div class="layui-card-header">
- <div class="searchTable">
- <div class="layui-inline">
- <input class="layui-input" name="id" id="companyInp" placeholder="请输入设备ID" autocomplete="off">
- </div>
- <button class="btn btn-sm btn-primary" data-type="reload">搜索</button>
- </div>
- <div class="addData">
- <button class="btn btn-sm btn-primary" data-type="reload" onclick="addData()"> 新建 </button>
- </div>
- </div>
- <div class="layui-card-body">
- <table class="layui-hide baseTable" id="conpanyList" lay-filter="conpanyList"></table>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script type="text/html" id="barDemo">
- <a class="editBtn green" lay-event="edit">编辑</a>
- |
- <a class="delBtn red" lay-event="del">删除</a>
- <!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"></a> -->
- </script>
- <script src="{% static '/lib/layui/layui.all.js' %}"></script>
- <script>
- var table, layer;
- layui.use(['table', 'layer'], function () {
- table = layui.table;
- layer = layui.layer;
- var data = [
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- },
- {
- "id": 10000,
- "basename": "基地1",
- "basearea": "33",
- "basesite": "城市-0",
- "remark": "签名-0"
- }, {
- "id": 10001,
- "basename": "基地2",
- "basearea": "54",
- "basesite": "城市-1",
- "remark": "签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1签名-1"
- }
- ];
- // 方法渲染表格
- table.render({
- elem: '#conpanyList'
- // , url: 'list'
- , data: data
- ,skin: 'line' //行边框风格
- ,even: true //开启隔行背景
- // ,size: 'sm' //小尺寸的表格
- , method: 'post' //如果无需自定义HTTP类型,可不加该参数
- , title: '用户数据表'
- , cols: [[
- { type: 'checkbox' }
- , { field: 'basename', title: '名称', }
- , { field: 'basearea', title: '生产厂家', }
- , { field: 'remark', title: '条形码', }
- , { field: 'remark', title: '是否转基因', }
- , { field: 'remark', title: '备注', }
- , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 200 }
- ]]
- , id: 'tableReload'
- , page: {
- layout: ['prev', 'page', 'next', 'count']
- , groups: 3 //只显示 1 个连续页码
- , first: true //不显示首页
- , last: true //不显示尾页
- , theme: '#428bca'
- }
- });
- // table.on('checkbox(conpanyList)', function (obj) {
- // console.log(obj.checked); //当前是否选中状态
- // console.log(obj.data); //选中行的相关数据
- // console.log(obj.type); //如果触发的是全选,则为:all,如果触发的是单选,则为:one
- // });
- //监听行工具事件
- table.on('tool(conpanyList)', function (obj) {
- var data = obj.data;
- console.log(obj)
- id = obj.data.id
- if (obj.event === 'edit') {
- var index = layer.open({
- type: 2,
- title: '添加信息',
- shadeClose: false,
- shade: [0.5, '#000'],
- area: ['50%', '60%'],
- content: '/seed_manageadd?id=' + id //iframe的url
- });
- } else if (obj.event === 'del') {
- var userid = [];
- userid.push(id)
- layer.confirm('是否删除“ ' + obj.data.name + ' ”!', {
- title: '删除'
- , icon: 3
- , btn: ['确定', '取消']
- }, function (index, layero) {
- $.ajax({
- url: 'dele',
- type: 'get',
- async: true,
- data: {
- id: JSON.stringify(userid)
- },
- // dataType: 'json',
- success: function (data) {
- if (data == 0) {
- //执行重载
- var companyInp = $('#companyInp');
- table.reload('tableReload', {
- where: {
- id: companyInp.val()
- }
- }, 'data');
- //无法关闭这个消息框
- layer.closeAll('dialog'); //加入这个信息点击确定 会关闭这个消息框
- layer.msg("删除成功!", { icon: 1, time: 1000 });
- }
- },
- error: function (type) {
- }
- })
- }
- );
- } else if (obj.event === 'upImg') {
- var index = layer.open({
- type: 2,
- title: '添加单位图像',
- shadeClose: false,
- shade: [0.5, '#000'],
- area: ['50%', '90%'],
- content: '/addCompanyImg?id=' + id //iframe的url
- });
- }
- });
- var $ = layui.$, active = {
- reload: function () {
- var companyInp = $('#companyInp');
- //执行重载
- table.reload('tableReload', {
- page: {
- curr: 1 //重新从第 1 页开始
- }
- , where: {
- id: companyInp.val()
- }
- }, 'data');
- }
- };
- // 搜索
- $('.searchTable .layui-btn').on('click', function () {
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- $('.searchTable #companyInp').on('keyup', function (event) {
- if (event.keyCode == 13) {
- active.reload()
- }
- });
- });
- function addData() {
- var index = layer.open({
- type: 2,
- title: '添加种子种苗信息',
- shadeClose: false,
- shade: [0.5, '#000'],
- area: ['800px', '60%'],
- content: 'seed_manageadd' //iframe的url
- });
- }
- </script>
- </body>
- </html>
|