<%@ 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_KCGL_KCGL_T" html='<a href="${ctx}/platform/fiting/pageList"><li >库存管理</li></a>'/>
                <sfTags:pagePermission authFlag="BJGL_KCGL_FWSKC_T" html='<a href="${ctx}/site/fitting/siteFitting"><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">
                        <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="suitPrinter" 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="oldRetrun" lay-search>
                            <option value="">请选择</option>
                            <option value="0">无需返还</option>
                            <option value="1">需要返还</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="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-input-inline" style="width: 100px;">
                            <input type="text" name="warningMin"  autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid">—</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="warningMax"  autocomplete="off" class="layui-input">
                        </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">

            </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();


        tableExt.render({
            elem: '#test'
            , height: 'full-200'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/site/fitting/getSiteFittingData'
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                , {field: 'id', type: 'checkbox',fixed: 'left'}
                , {field: 'site_name', title: '服务商名称',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'code', title: '物料号',minWidth:'100', sort: false, align: 'center', exportable:true
                    /*,templet:function(d){
                      return '<a style="color:#D9B589" href="javascript:fittingDetail(\'' + d.id + '\');">' + d.code + '</a>'
                    }*/}
                , {field: 'name', title: '备件名称',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'version', title: '备件型号',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'suit_printer', title: '适用机型',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'warning', title: '库存数量',minWidth:'50', sort: false, align: 'center', exportable:true}
                , {field: 'location', title: '库位',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'unit', title: '计量单位',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'site_price', title: '服务商价格',minWidth:'100', sort: false, align: 'center', exportable:true}
                , {field: 'customer_price', title: '零售价格',minWidth:'100', sort: false, align: 'center', exportable:true}
               /* , {field: 'refund_old_flag', title: '返回旧件',minWidth:'100', sort: false, align: 'center', exportable:true,
                    templet:function(d){
                        if(d.refund_old_flag == '0') {//非系统默认角色，可不允许删除
                            return '无需返还';
                        }else{
                            return '需要返还';
                        }
                }}*/
                , {field: 'remarks', title: '备件描述',minWidth:'100', 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"));
                }
            }
        });
        $(".layui-table-tool").hide();
        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            tableExt.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });

        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            switch(obj.event){
                case 'apply':
                    var checkStatus = table.checkStatus(obj.config.id);
                    var data = checkStatus.data;
                    var ids=[];
                    if (data.length < 1) {
                        layer.msg("请选择一条数据",{icon:5,anim:6});
                        return;
                    }
                    $.each(data, function(i, d) {
                        ids.push(d.id);
                    });
                    layer.open({
                        type: 2,
                        content: "${ctx}/site/fitting/getbatchWarehousing?ids="+ids.join(",")  //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                        ,title: "申请备件"
                        ,area:["1200px","370px"],
                        end:function(){
                            //刷新表格
                            //  searchOrder(orderId)
                        }

                    });
                    break;
            }
        })

    });

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

            }
        });
    }

    function reset(){
        $("#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();
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }
</script>
</body>
</html>

