<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script">
    <a:view>
        <a:link id="lend_doc_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
        <a:link id="prj500_cdd_uploadFile_id"
                url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="lend_document_modify_link"
                url="${/request/@context_path}/modules/cont/CON556/document_lend_record_add.lview"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <script type="text/javascript"><![CDATA[

        function exit() {
            $('con_archive_lend_link_winId').close();
        }

        //渲染
        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {

            if (name == 'lend_number' && value) {
                return '<a href="javascript:open_lend_modify_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
            }
            return value;
        };


        function lend_render_fuc(value, record, name) {
            if (name == 'lend_number' && value) {
                return '<a href="javascript:open_lend_modify_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
            }
            return value;
        }


        function open_lend_modify_win(record_id, ds_id) {

            var record = $(ds_id).findById(record_id);
            var status = record.get('status');
            var param = record.data;

            if (status == 'NEW') {
                param['function_code'] = 'CON556E';
                param['function_usage'] = 'MODIFY';
                param['maintain_type'] = 'UPDATE';
            } else {
                param['function_code'] = 'CON556N';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'QUERY';
            }
            param['lend_header_id'] = record.get('lend_header_id');
            param['url_title'] = '借阅信息';
            param['layout_debugger_flag'] = 'N';
            hls_doc_get_layout_code('lend_doc_get_layout_code_link_id', param, 'lend_document_modify_link', ds_id);
        }

        ]]></script>
        <a:dataSets>
            <a:dataSet id="contract_lend_history_result_ds" autoQuery="true" fetchAll="true"
                       model="cont.CON707.con_contract_lend_history"
                       queryUrl="${/request/@context_path}/autocrud/cont.CON707.con_contract_lend_history/query?contract_id=${/parameter/@contract_id}">
            </a:dataSet>

        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="exit" text="HLS.EXIT"/>
            </a:screenTopToolbar>
            <a:grid id="contract_lend_history_result_grid_id" bindTarget="contract_lend_history_result_ds"
                    marginHeight="250" marginWidth="130" navBar="true" style="margin:20px">
                <a:columns>
                    <a:column name="lend_number" prompt="借阅申请编号" renderer="lend_render_fuc" width="200"/>
                    <a:column name="apply_date" prompt="申请日期" renderer="Leaf.formatDate" width="200"/>
                    <a:column name="status_n" prompt="申请状态" width="200"/>
                    <a:column name="borrower_date" prompt="借出日期" renderer="Leaf.formatDate" width="200"/>
                    <a:column name="borrower_id_n" prompt="借阅人" width="200"/>
                    <a:column name="borrow_reason" prompt="借阅原因" width="200"/>
                    <a:column name="promise_date" prompt="预计归还日期" renderer="Leaf.formatDate" width="200"/>
                    <a:column name="send_flag_n" prompt="是否寄出" width="200"/>
                    <a:column name="track_number" prompt="快递单号" width="200"/>
                    <a:column name="recipient" prompt="收件人" width="200"/>
                    <a:column name="real_date" prompt="实际归还时间" renderer="Leaf.formatDate" width="200"/>
                    <a:column name="return_mark" prompt="归还备注" width="200"/>
                    <a:column name="return_send_flag_n" prompt="归还是否寄送" width="200"/>
                    <a:column name="return_recipient" prompt="归还收件人" width="200"/>
                    <a:column name="return_track_number" prompt="归还快递单号" width="200"/>
                    <a:column name="contract_number" prompt="合同编号" width="200"/>
                    <a:column name="bp_name" prompt="客户名称" width="200"/>
                    <a:column name="agent_name" prompt="代理商名称" width="200"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>