<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!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">
    <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
</head>
<body>

<div class="layui-fluid">
    <div class="layui-form layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <sfTags:pagePermission authFlag="SIT_BJGL_GCSSQ_DSH_T" html='<a href="${ctx}/employeInformation/noAudit"><li class="">待审核</li></a>'/>
                <sfTags:pagePermission authFlag="SIT_BJGL_GCSSQ_YSH_T" html='<a href="${ctx}/employeInformation/audited"><li class="layui-this">已审核</li></a>'/>
                <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" id="searchForm">
            <div class="layui-form-item">
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">申请人：</label>
                    <div class="layui-input-block">
                        <select name="empId" lay-search>
                            <option value="">请选择</option>
                            <c:forEach var="emp" items="${empList}">
                                <option value="${emp.columns.id}">${emp.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">物料号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="fittingCode" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">备件名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="fittingName" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">备件型号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="fittingVersion" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">电站名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="station" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">工单编号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="orderNum" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">审核状态：</label>
                    <div class="layui-input-block">
                        <select name="status" lay-search>
                            <option value="">请选择</option>
                            <option value="1">已通过</option>
                            <option value="3">未通过</option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">设备类型：</label>
                    <div class="layui-input-block">
                        <select name="equipment" lay-search>
                            <option value="">请选择</option>
                            <option value="光伏组件">光伏组件</option>
                            <option value="逆变器">逆变器</option>
                            <option value="通讯模块">通讯模块</option>
                            <option value="并网箱">并网箱</option>
                            <option value="线缆">线缆</option>
                            <option value="配件">配件</option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">审核备注：</label>
                    <div class="layui-input-block">
                        <input type="text" name="auditMarks" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">审核时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="auditTimeSta" class="layui-input" id="startTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="auditTimeEnd" class="layui-input" id="endTime" placeholder="结束日期">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <sfTags:pagePermission authFlag="SIT_BJGL_GCSSQ_YSH_DC" html='<button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出
                </button>'/>
                </div>
            </script>
        </div>
    </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        /*layui.use(['lay','table','layer','laypage','laydate','form'], function(){*/
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        var table = tableExt.getLayTable();

        //开始日期
        var insStart = laydate.render({
            elem: '#startTime'
            ,done: function(value, date){
                //更新结束日期的最小日期
                insEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });

                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });

        //结束日期
        var insEnd = laydate.render({
            elem: '#endTime'
            ,done: function(value, date){
                //更新开始日期的最大日期
                insStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        var fitTag = '${fns:checkPagePermission(request, "BJGL_BJSQ_DCK_FITNAME_B")}';
        var orderTag = '${fns:checkPagePermission(request, "BJGL_BJSQ_DCK_ORDER_B")}';
        tableExt.render({
            elem: '#test'
            , height: 'full-200'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/employeInformation/auditedList'
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                , {field: 'fitting_code', title: '物料号',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'fitting_name', title: '备件名称',minWidth:'100', sort: false, align: 'center', exportable:true
                   /* ,templet:function(d){
                        if(fitTag == '0') {//非系统默认角色，可不允许删除
                            return '<a style="color:#D9B589" href="javascript:fittingDetail(\'' + d.id + '\');">' + d.fitting_name + '</a>'
                        }else{
                            return d.fitting_name;
                        }
                    }*/
                }
                , {field: 'power_station_name', title: '电站名称',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'fitting_version', title: '备件型号',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'empName', title: '服务工程师',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'status', title: '审核状态',minWidth:'100', sort: false, align: 'center', exportable:true
                    ,templet:function(d){
                        if(d.status == '1') {
                            return '已通过';
                        }else if(d.status == '3'){
                            return '未通过';
                        }
                    }
                    ,expFormat:function(d){
                        if(d.status == '1') {
                            return '已通过';
                        }else if(d.status == '3'){
                            return '未通过';
                        }
                    }
                }
                , {field: 'employe_name', title: '申请人',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'employe_feedback', title: '申请备注',minWidth:'200', sort: false, align: 'center', exportable:true}
                , {field: 'fitting_apply_num', title: '申请数量',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'fitting_audit_num', title: '审核数量',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'audit_marks', title: '审核备注',minWidth:'250', sort: false, align: 'center', exportable:true}
                , {field: 'refuse_reason', title: '拒绝理由',minWidth:'250', sort: false, align: 'center', exportable:true}
                , {field: 'create_time', title: '申请时间',minWidth:'200', sort: false, align: 'center', exportable:true}
                , {field: 'number', title: '工单编号',minWidth:'200', sort: false, align: 'center', exportable:true}
                , {field: 'appliance_category', title: '设备类型',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'service_type', title: '服务类型',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'warranty_type', title: '保修类型',minWidth:'100', sort: false, align: 'center', exportable:true
                        ,templet:function(d){
                            if(d.warranty_type == '1') {
                                return '保内';
                            }else if (d.warranty_type == '2') {
                                return '保外';
                            } else {
                                return "";
                            }
                        }
                        ,expFormat:function(d){
                            if(d.warranty_type == '1') {
                                return '保内';
                            }else if(d.warranty_type == '2'){
                                return '保外';
                            }else {
                                return "";
                            }
                        }
                    }
                , {field: 'customer_price', title: '零售价格',minWidth:'100', sort: false, align: 'center', exportable:true
                    ,templet:function(d){
                        if (d.warranty_type == '1') {
                            return '0';
                        } else if (d.warranty_type == '2') {
                            return d.customer_price;
                        } else {
                            return '';
                        }
                    }
                    ,expFormat:function(d){
                        if (d.warranty_type == '1') {
                            return '0';
                        } else if (d.warranty_type == '2') {
                            return d.customer_price;
                        } else {
                            return '';
                        }
                    }
                }
                , {field: 'service_measures', title: '服务措施',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'audit_time', title: '审核时间',minWidth:'200', sort: false, align: 'center', exportable:true}
            ]],exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '工程师申请-已审核',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 1000,                    //当pageData为false生效
                fileName: '工程师申请-已审核',
                where: function (){                 //当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            }
        });

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

    });

    /*审核*/
    function ToExamine(id) {
        layer.open({
            type: 2,
            content: "${ctx}/employeInformation/applyToExamineForm?applyId="+id  //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,title: "审核"
            ,area:["800px","550px"]
            , yes: function(index, layero){

            }
        });
    }

    //备件详情
    function fittingDetail(id){
        layer.open({
            type: 2
            , title: '备件信息'
            , content: '${ctx}/platform/fitting/toFittingDetailNo?id=' + id
            , area: ['600px', '430px']
            , yes: function(index, layero){

            }
        });
    }

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

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

    function layerIFrameReload(layerIndex) {
        window['layui-layer-iframe' + layerIndex].location.reload();
    }
</script>
</body>
</html>

