<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: 38823
    $Date: 2023-01-24
    $Revision: 1.0
    $purpose: 资产管理费报表明细
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script"
          customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
    </a:init-procedure>
    <a:view>
        <a:link id="csh_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <script type="text/javascript"><![CDATA[
        Leaf.onReady(function() {
            debugger;
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_write_off');
                $(ds_id).setQueryParameter('contract_id','${/parameter/@contract_id}');
                $(ds_id).query();
                if('${/parameter/@winid}' == 'open_asset_check_id'){
                    var gridId= 'CON_ASSET_FEE_DETAIL_ASSET_GRID_csh_write_off_layout_grid_id';
                    $(gridId).hideColumn('write_off_type_desc');
                    $(gridId).hideColumn('write_off_date');
                    $(gridId).hideColumn('write_off_amount');
                    $(gridId).hideColumn('payment_date');
                    $(gridId).hideColumn('payment_amount');
                    $(gridId).hideColumn('creade_by');
                }
        });
       //附件
        function upload_csh_file(id,record_id) {
            debugger;
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            if(record_id == "undefined"){
                var url = $('csh_downloadFile_id').getUrl();
            }else {
                url = $('csh_downloadFile_id').getUrl() + '?table_name=CSH_PAYMENT_REQ_ASSET_HD&header_id=' + record_id;
            }
            var win = new Leaf.Window({
                url: url,
                title: '${l:HLS.SUPPORTING_DOCUMENT}',
                id: 'csh_attachment_uploadFile_id',
                width: 850,
                height: 400
            });
            win.on('close', function () {
                //record.ds.query();
            });
        }

        //发票附件
        function upload_invoice_file(id,record_id) {
            debugger;
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            if(record_id == "undefined"){
                var url = $('csh_downloadFile_id').getUrl();
            }else {
                url = $('csh_downloadFile_id').getUrl() + '?table_name=HL_REQ_PAYMENT_ACP&header_id=' + record_id;
            }
            var win = new Leaf.Window({
                url: url,
                title: '${l:HLS.SUPPORTING_DOCUMENT}',
                id: 'invoice_attachment_uploadFile_id',
                width: 850,
                height: 400
            });
            win.on('close', function () {
                //record.ds.query();
            });
        }

        //超链接渲染
        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
            var link_function = '';
            window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
            if(name == 'attachment'){
                link_function = 'upload_csh_file';
                return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + record.get('payment_req_id') + '\')">' + '附件'+ '</a>';
            }
            if(name == 'invoice_link'){
                link_function = 'upload_invoice_file';
                return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + record.get('payment_req_id') + '\')">' + '发票附件' + '</a>';
            }
        };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>

