WIDGET-NEW-GUIDE.lview 7.36 KB
Newer Older
niminmin's avatar
niminmin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zsy
    $Date: 2018/11/14
    $Revision: 1.0
    新手入门 微件
-->
<a:screen xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <s:server-script import="contract_print_path.js"><![CDATA[
            $ctx.parameter.file_path = con_print_path['con_print_path'];
            $ctx.parameter.tomcat_source = con_print_path['tomcat_source'];
            ]]></s:server-script>
    </a:init-procedure>
    <a:view template="default" package="leaf.ui.std">
        <style>
            html,body{
                width:220px;
                height:249px;
                margin: 0;
                padding: 0;
                color:#000;
            }
            .widget_new_guide{
                box-sizing:border-box;
                width:220px;
                height:249px;
                background-color:#fff;
                position:relative;
                border:1px solid #F0F0F3;
                user-select:none;
                cursor:default;
            }
            .widget_new_guide .widget_label{
                position:absolute;
                width:40px;
                height:4px;
                top:0;
                left:16px;
                background-color:#5A7FFF;
            }
            .widget_new_guide .widget_title{
                box-sizing:border-box;
                position:relative;
                height:20px;
                line-height:20px;
                margin:16px 0 10px 0;
                font-family: PingFangSC-Medium;
                font-size: 14px;
                padding:0 24px 0 16px;
                color: rgba(75,80,90,0.85);
                letter-spacing: 0;
            }
            .widget_new_guide .widget_content{
                box-sizing:border-box;
                width:100%;
                height:205px;
                border-top:1px solid #EDEDED;
                padding:4px 15px;
            }
            .widget_new_guide .widget_content .link{
                display: block;
                width:100%;
                height:20px;
                margin-top:12px;
                text-decoration:none;
            }
            .widget_new_guide .widget_content .link:visited,
            .widget_new_guide .widget_content .link:hover,
            .widget_new_guide .widget_content .link:active{
                text-decoration:none;
                color: rgba(75,80,90,0.85);
            }
            .widget_new_guide .widget_content .link .icon{
                width:20px;
                height:20px;
            }
            .widget_new_guide .widget_content .link .link_info{
                font-family: PingFangSC-Regular;
                font-size: 12px;
                color: rgba(75,80,90,0.85);
                line-height: 20px;
                vertical-align:top;
                padding-left:0.3em;
                max-width: 150px;
                white-space: nowrap;
                overflow: hidden;
                display: inline-block;
                text-overflow: ellipsis;
            }
        </style>
        <script><![CDATA[
        $L.onReady(function(){
            var ds = $("widget_new_guide_attachment_ds");
            ds.qpara={
                enable_flag:'Y'
            };
            ds.query();
        });
        function onLoad_widget_new_guide_attachment_ds(ds){
            var htmlStr = '';
            var records = ds.getAll();
            var wrapper = jQuery(".widget_new_guide .widget_content");
            var fileArr = [];
            var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
            for(var j=0;j<records.length;j++){
                if(!!records[j].get("file_name")){
                    var arr = records[j].get("file_name").split(';;');
                    for (var i = 0;i < arr.length;i++) {
                        var name = arr[i].split('--')[0];
                        var id = arr[i].split('--')[1];
                        if (!Leaf.isEmpty(name)) {
                            fileArr.push({
                                file_name : name,
                                file_id : id
                            });
                        }
                    }
                }
            }
            for(i=0;i<fileArr.length && i<5;i++){
                htmlStr += '<a class="link"';
                var file_name = fileArr[i].file_name;
                var file_id = fileArr[i].file_id;
                if (file_name.toUpperCase().indexOf('.PDF') >= 0) {
                    htmlStr += '<a class="link" href="javascript:view_pdf(\'' + file_id + '\')">'+
                        '<img class="icon" src="${/request/@context_path}/leafresource/images/widget/attachment.png"/>'+
                        '<span class="link_info" title="' +file_name + '" >' + file_name + '</span>';
                } else if (file_name.toUpperCase().indexOf('.GIF') >= 0 || file_name.indexOf('.JPG') >= 0 | file_name.indexOf('.JPEG') >= 0 || file_name.indexOf('.PNG') >= 0) {
                    htmlStr += '<a class="link" href="' + link + file_id + '">'+
                        '<img class="icon" src="${/request/@context_path}/leafresource/images/widget/attachment.png"/>'+
                        '<span class="link_info" title="' +file_name + '" ref="img">' + file_name + '</span>';
                } else {
                    htmlStr += '<a class="link" href="' + link + file_id + '">'+
                        '<img class="icon" src="${/request/@context_path}/leafresource/images/widget/attachment.png"/>'+
                        '<span class="link_info" title="' +file_name + '">' + file_name + '</span>';
                }
                htmlStr += '</a>';
            }
            wrapper.html(htmlStr);
        }

        function view_pdf(attachment_id) {
            Leaf.request({
                url: '${/request/@context_path}/autocrud/fnd.fnd_atm_attachment/query',
                para: {
                    attachment_id: attachment_id
                },
                success: function(res) {
                    var path = res.result.record.file_path;
                    path = path.substr(path.indexOf('regul_framwork_attachment'));
                    var tomcat_source = '${/parameter/@tomcat_source}';
                        var source_path = 'http://' + window.location.host + '/' + tomcat_source + '/' + path;
                    var oWin = window.open(source_path);

                },
                scope: this
            });
        }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="widget_new_guide_attachment_ds" model="sys.SYS003.hls_new_start_attachment"
                       autoQuery="false" pageSize="5" fetchAll="false">
                <a:fields>
                    <a:field name="attachment_id"/>
                    <a:field name="attachment_name"/>
                    <a:field name="file_name"/>
                    <a:field name="enable_flag"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="onLoad_widget_new_guide_attachment_ds"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <div class="widget_new_guide">
            <span class="widget_label"> </span>
            <div class="widget_title">新手入门</div>
            <div class="widget_content"> </div>
        </div>
    </a:view>
</a:screen>