psr_task_reports.lview 9.1 KB
Newer Older
Spencer Chang's avatar
Spencer Chang 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
<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="remove_link" url="${/request/@context_path}/task_report/delete"/>
        <a:link id="psr_task_reports_authority_link_id" url="${/request/@context_path}/modules/psr/PSR1030/psr_task_reports_authority.lview"/>
        <script type="text/javascript"><![CDATA[
            function down(value, record, name) {
                var report_id = record.get('report_id');
                var file_path = record.get('file_path');
                var file_name_desc = record.get('file_name');
            
                file_path = file_path.replace(/\\/g, '/');
                var index = file_path.lastIndexOf('/');
                index = index + 1;
                var fileName = file_path.substring(index);
                if (!file_name_desc) {
                    file_name_desc = fileName;
                }
                var download_url = '${/request/@context_path}/task_report/download?report_id=' + report_id + '&fileName=' + fileName + '&fileNameDesc=' + file_name_desc;
                var delete_url = $('remove_link').getUrl() + "?report_id=" + report_id + "&fileName=" + fileName;
                var url = '<a href="javascript:download(\'' + download_url + '\',\'' + delete_url + '\')">' + file_name_desc + '</a>';
                return url;
            }
            
            function download(download_url, delete_url) {
                var ds = $('rpt_task_reports_ds');
                Leaf.post(download_url);
                //deleteRecord(delete_url);
            }
            
            function deleteRecord(delete_url) {
                var ds = $('rpt_task_reports_ds');
                $L.showConfirm(_lang['grid.remove.confirm'], _lang['grid.remove.confirmMsg'], function(win) {
                    Leaf.request({
                        url: delete_url,
                        para: {},
                        success: function(args) {
                            ds.remove();
                        },
                        error: ds.onSubmitError,
                        failure: ds.onAjaxFailed,
                        scope: this
                    });
                });
            }
            
            function remove(value, record, name) {
                var report_id = record.get('report_id');
                var file_path = record.get('file_path');
                file_path = file_path.replace(/\\/g, '/');
                var index = file_path.lastIndexOf('/');
                index = index + 1;
                var fileName = file_path.substring(index);
                var delete_url = $('remove_link').getUrl() + "?report_id=" + report_id + "&fileName=" + fileName;
                var url = '<a href="javascript:deleteRecord(\'' + delete_url + '\')">删除文件</a>';
                return url;
            }
            
            function remove_select() {
                $L.showConfirm(_lang['grid.remove.confirm'], _lang['grid.remove.confirmMsg'], function(win) {
                    var ds = $('rpt_task_reports_ds');
                    var records = ds.getSelected();
                    var record;
                    /* for (var i = 0;i < records.length;i++) {
                     record = records[i];
                     var report_id = record.get('report_id');
                     var file_path = record.get('file_path');
                     var index = 0;
                     index = file_path.lastIndexOf('\\');
                     if (index == -1) {
                     index = file_path.lastIndexOf('/');
                     }
                     index = index + 1;
                     var fileName = file_path.substring(index);
                     var delete_url = $('remove_link').getUrl() + "?report_id=" + report_id + "&fileName=" + fileName;
                     deleteRecord_noConfirm(delete_url, record);
                     } */
                    for (var i = 0;i < records.length;i++) {
                        record = records[i];
                        var report_id = record.get('report_id');
                        var file_path = record.get('file_path');
                        file_path = file_path.replace(/\\/g, '/');
                        var index = file_path.lastIndexOf('/');
                        index = index + 1;
                        var fileName = file_path.substring(index);
                        var delete_url = $('remove_link').getUrl() + "?report_id=" + report_id + "&fileName=" + fileName;
                        deleteRecord_noConfirm(delete_url, record);
                    }
                });
            }
            
            function deleteRecord_noConfirm(delete_url, record) {
                var ds = $('rpt_task_reports_ds');
                Leaf.request({
                    url: delete_url,
                    para: {},
                    success: function(args) {
                        ds.remove(record);
                    },
                    error: ds.onSubmitError,
                    failure: ds.onAjaxFailed,
                    scope: this
                });
            }
            
            function query() {
                $('rpt_task_reports_ds').query();
            }
            
            function reset() {
                $('rpt_task_reports_query_ds').reset();
            }
            
            function config_report_result_authority_renderer(value, record, name) {
                var url = '<a href="javascript:result_authority(\'' + record.id + '\')">报表数据授权</a>';
                return url;
            }
            
            function result_authority(report_id) {
                var authority_url = $('psr_task_reports_authority_link_id').getUrl();
                var record = $('rpt_task_reports_ds').findById(report_id);
                new Leaf.Window({
                    id: 'psr_task_reports_authority_winid',
                    url: authority_url,
                    params: {
                        report_id: record.get('report_id'),
                        file_name: record.get('file_name'),
                        winid: 'psr_task_reports_authority_winid'
                    },
                    fullScreen: true,
                    draggable: true,
                    title: '报表数据授权'
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="rpt_task_reports_query_ds"/>
            <a:dataSet id="rpt_task_reports_ds" autoQuery="true" canQuery="true" fetchAll="false" model="psr.PSR1030.psr_task_reports_for_query" pageSize="15" queryDataSet="rpt_task_reports_query_ds" selectable="true"/>
        </a:dataSets>
        <a:form column="2" style="margin-left:10px;margin-top:10px;" title="报表查询" width="600">
            <a:datePicker name="creation_date_from" bindTarget="rpt_task_reports_query_ds" prompt="创建时间从" width="200">
                <a:events>
                    <a:event name="enterdown" handler="query"/>
                </a:events>
            </a:datePicker>
            <a:datePicker name="creation_date_to" bindTarget="rpt_task_reports_query_ds" prompt="创建时间到" width="200">
                <a:events>
                    <a:event name="enterdown" handler="query"/>
                </a:events>
            </a:datePicker>
        </a:form>
        <a:hBox style="margin-left:7px;">
            <a:button click="query" text="HAP_QUERY"/>
            <a:button click="reset" text="HAP_RESET"/>
        </a:hBox>
        <a:grid id="rpt_task_reports_ds_grid" bindTarget="rpt_task_reports_ds" marginHeight="150" marginWidth="30" navBar="true">
            <a:toolBar>
                <a:button click="remove_select" icon="${/request/@context_path}/images/remove.gif" style="height:16px;" text="HAP_DELETE"/>
            </a:toolBar>
            <a:columns>
                <!-- <a:column name="task_description" prompt="任务" width="70"/> -->
                <!-- <a:column name="session_id" prompt="会话" width="70"/> -->
                <a:column name="user_description" align="center" prompt="用户" width="100"/>
                <a:column name="role_name" align="center" prompt="角色" width="70"/>
                <a:column name="company_short_name" align="center" prompt="公司" width="70"/>
                <!-- <a:column name="lang_description" prompt="语言" width="100"/> -->
                <a:column name="creation_date_view" align="center" prompt="创建时间" width="150"/>
                <!-- <a:column name="url" prompt="请求地址" width="200"/> -->
                <a:column name="file_path" align="center" prompt="下载" renderer="down" width="270"/>
                <a:column name="config_report_result_authority" align="center" prompt="报表数据授权" renderer="config_report_result_authority_renderer" width="120"/>
                <!-- <a:column name="download" align="center" prompt="下载" width="270"/>-->
                <!-- <a:column name="delete" align="center" prompt="删除文件" renderer="remove" width="70"/> -->
            </a:columns>
            <a:editors/>
        </a:grid>
    </a:view>
</a:screen>