<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <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">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css" media="all">
    <style>
        dl{
            max-height: 250px;
        }
        .layui-table-opt-link{padding:10px}
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card layui-form">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li><a href="${ctx}/qualityRatioSet/qualityRatioSetPage">质检验收设置</a></li>
                <li class="layui-this"><a href="${ctx}/qualityRatioSet/inspectionRatioSetPage">巡检设置</a></li>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " type="reset"  onclick="reset()" >
                    <i class="layui-icon fs-12">&#xe9aa;</i>
                    重置
                </button>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " id="searchBtn" lay-submit lay-filter="LAY-user-back-search">
                    <i class="layui-icon fs-12">&#xe615;</i>查询
                </button>
            </ul>
        </div>

        <div class="layui-card-body layuiadmin-card-header-auto" >
            <form class="layui-form layui-card" action="" id="searchForm">
                <div class="layui-form-item">

                </div>
            </form>
        </div>

        <div class="layui-card-body">
            <table class="layui-hide " id="test" lay-filter="test"></table>
        </div>

    </div>
</div>
<%--<div id="toolbarDemo" class="layui-form-item layui-hide">
    <sfTags:pagePermission authFlag="PZGL_XJSZ_XZ_T" html='<button class="layui-btn layui-btn-sm" id="addBtn" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</button>'/>
</div>--%>

<script type="text/html" id="table-toolbar" >
    <sfTags:pagePermission authFlag="PZGL_XJSZ_BJ_T" html='<a class="layui-table-opt-link" lay-event="edit">编辑</a>'/>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/data.js"></script>
<script type="text/javascript">
    var saveMark = false;
    //初始数据
    var $form;
    var form;
    var upload;
    var $;
    var table;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form','excel'], function(){
        $ = layui.$
            ,form = layui.form
            ,tableExt = layui.tableExt;
        laydate = layui.laydate;
        table = layui.table;

        //方案信息列表
        tableExt.render({
            elem: '#test'
            , height: 'full-150'
            , id: 'test'
            // , toolbar:"#toolbarDemo"
            , defaultToolbar: false
            , url: '${ctx}/qualityRatioSet/inspectionRatioSetList'
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            , page: true
            , method:"post"
            , limits: [20, 50, 100]
            , limit: 20
            , cols: [[
                {field: 'number', title: '序号', align: 'center', type: 'numbers'}
                // ,{field : 'id', checkbox : true,align : 'center'}
                ,{field:'id', title: '操作',toolbar: '#table-toolbar',align: 'center'}
                , {field: 'ratio', title: '抽检比例', minWidth: 200, align: 'center',exportable:true
                    ,templet: function (d) {
                        if(!isBlank(d.ratio)){
                            return d.ratio+"%";
                        }else {
                            return "";
                        }
                    }
                }
                , {
                    field: 'cycle', title: '生成方式', minWidth: 200, align: 'center', exportable: true
                    , templet: function (d) {
                       if(!isBlank(d.cycle)){
                           return "每"+d.cycle+"个月或满足"+d.house_num+"户";
                       }
                       return "";
                    }
                }
                , {field: 'prop_float', title: '比例浮动', minWidth: 200, align: 'center',exportable:true
                    ,templet: function (d) {
                       if(!isBlank(d.prop_float_wg) && !isBlank(d.prop_float_cj)){
                           var wgText = "完工一次通过率";
                           var cjText = "抽检比例";
                           if(d.just == '1'){
                               wgText += "低于";
                           }else {
                               wgText += "高于";
                           }

                           if(d.floating == '1'){
                               cjText = "下浮";
                           }else {
                               cjText = "上浮";
                           }
                            return wgText+d.prop_float_wg+"%,"+cjText+d.prop_float_cj+"%";
                        }else {
                             return "";
                        }
                    }
                }
                , {field: 'update_time', minWidth: 200, title: '更新时间', align: 'center',exportable:true }
            ],
            ]
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '巡检设置',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 1000,                    //当pageData为false生效
                fileName: '巡检设置',
                where: function (){
                    console.log(_serializeJson($("#searchForm")));//当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            }
        });

        //监听事件
        
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            var id = data.id;
            if(obj.event === 'edit'){
                layer.open({
                    title:'编辑',
                    type: 2,
                    content: '${ctx}/qualityRatioSet/editInspectionSetPage?id='+id,
                    area: ['50%','50%']
                })
            }
        });

        table.on('toolbar(test)',function(obj) {
            if (obj.event === 'add') {
                layer.open({
                    type: 2,
                    title: '新增',
                    content: '${ctx}/qualityRatioSet/addInspectionSetPage',
                    area: ['50%','50%']
                });
            }
        });

        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            tableExt.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });




    });

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function reload(){
        layer.closeAll();
        //执行重载
        var wherobj =_serializeJson($("#searchForm"));
        tableExt.reload('test', {
            where: wherobj
        });
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }

</script>
</body>
</html>





