<%@ 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="BJGL_CRKMX_CRKMX_T" html='<a href="${ctx}/platform/fittingRefund/toPlatformInAndOutWarehousingList"><li class="layui-this">出入库明细</li></a>'/>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10"  lay-submit lay-filter="resetButton" >
                    <i class="layui-icon fs-12">&#xe615;</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 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" >
                        <select name="type">
                            <option value="">请选择</option>
                            <option value="0">入库</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">
                        <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"  class="layui-input" name="suitPrinter">
                    </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="applicant" 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="remarks" 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="operateTimeStart" 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="operateTimeEnd" class="layui-input" id="endTime" placeholder="结束日期">
                        </div>
                    </div>
                </div>

            </div>
            </form>
        </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="BJGL_CRKMX_DC_T" html='<button class="layui-btn layui-btn-sm" id="exportBtn" lay-event="exports"><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>
    var table;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        //layui.use(['table','layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        table = layui.table;
        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 endTimeSta=laydate.render({
            elem: '#endTimeSta'
            ,done: function(value, date){
                endTimeEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                endTimeEnd.config.elem[0].focus();
            }
        });
        var endTimeEnd=laydate.render({
            elem: '#endTimeEnd'
            ,done: function(value, date){
                //更新开始日期的最大日期
                endTimeSta.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_BJFC_BJFC_ORDERNAME_B")}';
        tableExt.render({
            elem: '#test'
            , height: 'full-240'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/platform/fittingRefund/getPlatformInAndOutWarehousingData'
            , cols: [[
                {type: 'numbers',title: '序号',fixed:'left'}
                , {field: 'fitting_code', title: '物料号',fixed:'left',minWidth:'160', sort: false, align: 'center', exportable:true}
                , {field: 'fitting_name', title: '备件名称',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'version', title: '备件型号',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'type', title: '明细类型',minWidth:'150', sort: false, align: 'center', exportable:true
                    , templet:function(d){
                        var type=d.type;
                        if(type==0){
                          return "入库"
                        }else if(type==1){
                            return "出库"
                        }else {
                            return "调整"
                        }
                    }
                    , expFormat: function (d) {
                        var type=d.type;
                        if(type==0){
                            return "入库"
                        }else if(type==1){
                            return "出库"
                        }else {
                            return "调整"
                        }
                    }
                }
                , {field: 'suit_printer', title: '适用机型',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'amount', title: '明细数量',minWidth:'100', sort: false, align: 'center', exportable:true
                ,templet:function(d){
                    if(d.type==1){
                      return "-"+d.amount;
                    }else{
                        return d.amount;
                    }
                    }
                    ,expFormat:function(d){
                        if(d.type==1){
                            return "-"+d.amount;
                        }else{
                            return d.amount;
                        }
                    }
                }
                , {field: 'applicant', title: '申请人',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'confirmor', title: '确认人',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'remarks', title: '调整原因/备注',minWidth:'230', sort: false, align: 'center', exportable:true}
                , {field: 'site_price', title: '服务商价格',minWidth:'180', sort: false, align: 'center', exportable:true}
                , {field: 'operate_time', title: '出入库时间',minWidth:'180', 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
                }
            });
        });
        //重置
        form.on('submit(resetButton)', function(data){
            $("#searchForm")[0].reset();
            layui.form.render();

        });

    });



    function fittingDetail(id){
        var index=layer.open({
            type: 2
            , title: '旧件信息'
            , content: '${ctx}/platform/fittingRefund/goFitRefundDetail?id=' + id
            , area: ['600px', '500px']
            , yes: function(index, layero){
                layer.close(index);
            }
        });
    }

    function facStatus(d){
        if(d.status=='1'){
            return "未到货"
        }else if(d.status=='2'){
            return "已到厂"
        }else{
            return ""
        }
    }

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

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
</script>
</body>
</html>


