<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta name="decorator" content="base" />
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css" media="all">
    <style>
        .layui-card{box-shadow: none;}
    </style>
</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_YYGL_JSZL_JSZL_T" html='<a href="${ctx}/technical/technicalInfoList"><li class="layui-this sf-tab">技术资料</li></a>'/>
            </ul>
        </div>
    </div>

    <div class='layui-card'>
        <div class="layui-card-body">
            <table class="layui-hide" lay-skin="row" id="test-table-reload" lay-filter="table-toolbar"></table>
        </div>
    </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/base64.js"></script>
<script type="text/html" id="table-toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="downLoad">下载</a>
</script>
<script type="text/javascript">
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer'], function(){
        var tableExt = layui.tableExt;
        var layer = layui.layer;
        var $ = layui.jquery;
        var fitTag = '${fns:checkPagePermission(request, "SIT_YYGL_JSZL_ZLXQ_B")}';
        tableExt.render({
            elem: '#test-table-reload'
           // ,toolbar : '#toolbarDemo'
            ,defaultToolbar : false
            ,url: '${ctx}/notification/ajaxTechnicalData'
            ,cols: [[
                {type: 'numbers',title:'序号',}
                ,{field:'href', title: '资料政策',align: 'center', templet: function(d){
                      //  var encodedUrl = encodeURIComponent('${commonStaticImgPath}'+d.href);

                        return  "<a href=\"${commonStaticImgPath}"+d.href+"\" class=\"layui-table-link\" >"+d.name+"</a>";
                }}
                ,{field:'description', title: '资料说明',align: 'center',width: 700}
                ,{field:'create_time', title: '上传时间',align: 'center',width: 250}
            ]]
            ,page:true
        });


        var table = tableExt.getLayTable();
        var fitTag2 = '${fns:checkPagePermission(request, "SIT_YYGL_JSZL_XZ_B")}';
        //监听行工具事件
        table.on('tool(table-toolbar)',function(obj){
            if(fitTag2 !='0'){
                layer.msg("对不起，您现在没有下载权限！",{icon:2});
                return;
            }
            var data = obj.data;
            var href = data.href;
            var name = data.name;
            var index = name.indexOf(".");
            var fileGS = name.substring(index,name.length);
           var closeIndex = layer.confirm('你确认要下载吗?',{
                icon:3,
                btn:['确定','取消'] //按钮
            },function(){
               layer.close(closeIndex);
                if(obj.event == 'downLoad'){
                    window.open('${commonStaticImgPath}'+href)
                   // location.href = '${ctx}/technical/imgDownload?path='+'${commonStaticImgPath}'+href+"&fileGS="+fileGS+"&name="+name
                }
            })

        })

        var active = {
            reload: function(){
                table.reload('test-table-reload', {
                    where: {
                        name: $('#form-name').val()
                    }
                });
            }
        };



    });

    function previewUrl(_url){
        if (!checkUrl(_url)) {
            return false;
        }
        var base = new Base64();
        var b64Encoded =  base.encode(_url);
        if(_url.endsWith('pdf')) {
            window.open('http://47.98.203.224:8012/onlinePreview?url=' + encodeURIComponent(b64Encoded)+'&officePreviewType=pdf');
        }else{
            window.open('http://47.98.203.224:8012/onlinePreview?url=' + encodeURIComponent(b64Encoded));
        }
    }
</script>
</body>
</html>
