psr_report_query.lview 14.7 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: xiaobo  
    $Date: 2012-11-23 下午1:50:45  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view package="leaf.ui.std" template="default">
        <div/>
        <a:link id="psr_report_create" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_create.lview"/>
        <a:link id="psr_report_delete" url="${/request/@context_path}/autocrud/psr.PSR1010.psr_report_delete/execute"/>
        <a:link id="psr_report_mail" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_mail.lsc"/>
        <a:link id="psr_report_preview_link" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_preview.lview"/>
        <a:link id="psr_report_check" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_check.lsc"/>
        <a:link id="psr_report_parameter_dynamic" url="${/request/@context_path}/modules/psr/PSR1020/psr_report_parameter_dynamic.lview"/>
        <a:link id="psr_report_parameter_preview_dynamic" url="${/request/@context_path}/modules/psr/PSR1020/psr_report_parameter_preview_dynamic.lview"/>
        <a:link id="psr_report_output" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_output.lsc"/>
        <script type="text/javascript"><![CDATA[
            function queryFun() {
                $('psr_report_headers_ds').query();
            }
            
            function resetFun() {
                $('psr_report_headers_query_ds').reset();
            }
            
            function previewFun(value, record, name) {
                return '<a href="javascript:outputPreview(' + record.id + ')" >预览</a>';
            }
            
            
            function asynchronization_runFun(value, record, name) {
                var synchronization_flag = 'N';
                return '<a href="javascript:outputFun(' + record.id + ',\'' + synchronization_flag + '\')" >异步运行</a>';
            }
            
            function synchronization_runFun(value, record, name) {
                var synchronization_flag = 'Y';
                return '<a href="javascript:outputFun(' + record.id + ',\'' + synchronization_flag + '\')" >同步运行</a>';
            }
            
            function runFun(value, record, name) {
                var synchronization_flag = record.get('synchronization_flag');
                return '<a href="javascript:outputFun(' + record.id + ',\'' + synchronization_flag + '\')" >运行</a>';
            }
            
            function mailFun(value, record, name) {
                var report_header_id = record.get('report_header_id');
                return '<a href="javascript:outputMail(' + report_header_id + ')" >发送</a>';
            }
            
            function finnal_outputpreview(params) {
                params['winid'] = 'psr_report_preview_screen';
                new Leaf.Window({
                    url: $('psr_report_preview_link').getUrl(),
                    params: params,
                    id: 'psr_report_preview_screen',
                    fullScreen: true
                });
            }
            
            function outputPreview(record_id) {
                var record = $('psr_report_headers_ds').findById(record_id);
                var report_header_id = record.get('report_header_id'),
                    layout_code = record.get('layout_code'),
                    width = record.get('width'),
                    height = record.get('height');
                var fullScreen = true;
                if (width && height) {
                    fullScreen = false;
                }
                if (layout_code) {
                    new Leaf.Window({
                        url: $('psr_report_parameter_preview_dynamic').getUrl(),
                        title: '选择预览参数',
                        params: {
                            winid: 'psr_report_parameter_preview_dynamic_winid',
                            report_header_id: report_header_id,
                            layout_code: layout_code
                        },
                        id: 'psr_report_parameter_preview_dynamic_winid',
                        fullScreen: fullScreen,
                        width: width,
                        height: height,
                        draggable: true
                    });
                } else {
                    finnal_outputpreview({
                        report_header_id: report_header_id
                    });
                }
            }
            
            function reportEditorFun(value, record, name) {
                var report_header_id = record.get('report_header_id');
                //var url = $('psr_report_create').getUrl() + '?report_header_id=' + report_header_id;
                return '<a href="javascript:outputEditor(' + report_header_id + ')" >编辑</a>';
                //return '<a href="' + url + '" >编辑</a>';
            }
            
            function outputEditor(report_header_id) {
                var url1 = $('psr_report_create').getUrl() + '?report_header_id=' + report_header_id;
                Leaf.request({
                    url: $('psr_report_check').getUrl(),
                    para: {
                        report_header_id: report_header_id
                    },
                    success: function(res) {
                        window.location.href = url1;
                    },
                    error: function() {
            
                       }
                });
            }
            
            function reportDelFun(value, record, name) {
                var report_header_id = record.get('report_header_id');
                return '<a href="javascript:reportDelFunction(' + report_header_id + ')" >删除</a>';
            }
            
            function reportDelFunction(report_header_id) {
                Leaf.showConfirm('提示', '是否删除?', function okFun() {
                    Leaf.request({
                        url: $('psr_report_delete').getUrl(),
                        para: {
                            report_header_id: report_header_id
                        },
                        success: function(res) {
                            queryFun();
                        },
                        error: function() {
            
                           }
                    });
                }, function canFun() {
            
                   });
            }
            
            function synchronization_ajax_download_deal(report_id, path, name) {
                var file_path = path;
                var file_name_desc = 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;
                Leaf.post(download_url);
            }
            
            function synchronization_ajax_report(params) {
                if (params['synchronization_flag'] == 'Y') {
                    if (params['winid']) {
                        Leaf.Masker.mask($(params['winid']).wrap, '${l:HLS.EXECUTING}');
                    }
                    Ext.Ajax.request({
                        url: $('psr_report_output').getUrl(),
                        params: {
                            _request_data: Ext.util.JSON.encode({
                                parameter: params
                            })
                        },
                        success: function(res) {
                            var obj = eval('(' + res.responseText + ')');
                            if (obj.result.report_id) {
                                synchronization_ajax_download_deal(obj.result.report_id, obj.result.file_path, obj.result.file_name);
                            } else {
                                alert(res.responseText);
                            }
                            if (params['winid']) {
                                Leaf.Masker.unmask($(params['winid']).wrap);
                            }
                        }
                    });
                } else {
                    Leaf.request({
                        url: $('psr_report_output').getUrl(),
                        para: params,
                        success: function(res) {
                            Leaf.showMessage('${l:HLS.PROMPT}', '文件生成中,请稍后查看任务列表');
                        },
                        scope: this
                    });
                }
            }
            
            function outputFun(record_id, synchronization_flag) {
                var record = $('psr_report_headers_ds').findById(record_id);
                var report_header_id = record.get('report_header_id'),
                    layout_code = record.get('layout_code'),
                    width = record.get('width'),
                    height = record.get('height');
                var fullScreen = true;
                if (width && height) {
                    fullScreen = false;
                }
                if (layout_code) {
                    new Leaf.Window({
                        url: $('psr_report_parameter_dynamic').getUrl(),
                        title: '选择运行参数',
                        params: {
                            winid: 'psr_report_parameter_dynamic_winid',
                            report_header_id: report_header_id,
                            layout_code: layout_code,
                            synchronization_flag: synchronization_flag,
                            function_code: 'PSR1020'
                        },
                        id: 'psr_report_parameter_dynamic_winid',
                        fullScreen: fullScreen,
                        width: width,
                        height: height,
                        draggable: true
                    });
                } else {
                    synchronization_ajax_report({
                        report_header_id: report_header_id,
                        layout_code: layout_code,
                        synchronization_flag: synchronization_flag
                    });
                }
            }
            
            function outputMail(id) {
                var param = {};
                param['report_header_id'] = id;
                Leaf.request({
                    url: $('psr_report_mail').getUrl(),
                    para: param,
                    success: function(argss) { //
                        Leaf.showMessage('${l:HAP_MESSAGE}', '发送成功');
                    },
                    failure: function(response, options) {
                        Leaf.showMessage('${l:HAP_MESSAGE}', '错误');
                    },
            
                    scope: this
                });
            }
        ]]></script>
        <!-- <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONFIG_REPORT&amp;function_code=PSR1020"/> -->
        <a:dataSets>
            <a:dataSet id="psr_view_range_code_ds" lookupCode="PSR_VIEW_RANGE_CODE"/>
            <a:dataSet id="psr_report_type_code_ds" lookupCode="PSR_REPORT_TYPE_CODE"/>
            <a:dataSet id="psr_report_headers_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="all_query_flag" defaultValue="Y"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="psr_report_headers_ds" autoQuery="true" model="psr.PSR1010.psr_report_headers" pageSize="20" queryDataSet="psr_report_headers_query_ds">
                <a:fields>
                    <a:field name="view_range_dis" displayField="code_value_name" options="psr_view_range_code_ds" returnField="view_range" valueField="code_value"/>
                    <a:field name="report_type_dis" displayField="code_value_name" options="psr_report_type_code_ds" returnField="report_type" valueField="code_value"/>
                </a:fields>
                <!-- <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events> -->
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:hBox>
                <a:form column="1" marginWidth="50" title="查询条件">
                    <a:textField name="report_header_name" bindTarget="psr_report_headers_query_ds" prompt="报表名称"/>
                </a:form>
            </a:hBox>
            <a:hBox>
                <a:button click="queryFun" text="查询"/>
                <a:button click="resetFun" text="重置"/>
                <!-- <a:button click="queryTask" text="查看任务"/> -->
            </a:hBox>
            <a:hBox>
                <a:table bindTarget="psr_report_headers_ds" marginWidth="50" navBar="true" width="1050">
                    <a:columns>
                        <a:column name="report_header_name" align="center" percentWidth="20" prompt="报表名称"/>
                        <a:column name="report_header_description" align="center" percentWidth="20" prompt="报表描述"/>
                        <a:column name="view_range_dis" align="center" percentWidth="5" prompt="查看范围"/>
                        <a:column name="report_type_dis" align="center" percentWidth="10" prompt="报表类型"/>
                        <a:column name="report_creation_date" align="center" percentWidth="10" prompt="创建日期" renderer="Leaf.formatDate"/>
                        <a:column name="report_view" align="center" percentWidth="5" prompt="预览" renderer="previewFun"/>
                        <a:column name="report_run" align="center" percentWidth="6" prompt="运行" renderer="runFun"/>
                        <!-- <a:column name="report_run1" align="center" percentWidth="6" prompt="同步运行" renderer="synchronization_runFun"/> -->
                        <!-- <a:column name="report_run2" align="center" percentWidth="6" prompt="异步运行" renderer="asynchronization_runFun"/> -->
                        <!-- <a:column name="report_mail" align="center" percentWidth="5" prompt="发送" renderer="mailFun"/> -->
                        <a:column name="report_editor" align="center" percentWidth="5" prompt="编辑" renderer="reportEditorFun"/>
                        <a:column name="report_del" align="center" percentWidth="5" prompt="删除" renderer="reportDelFun"/>
                    </a:columns>
                </a:table>
            </a:hBox>
        </a:screenBody>
    </a:view>
</a:screen>