<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}zj_wfl_approve_history_check" url="${/request/@context_path}/modules/zjwfl/zj_wfl_approve_history_check.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_contract_modify_link" url="${/request/@context_path}/modules/cont/CON301N/con_contract_query.lview"/>
        <a:link id="car_modify_special_link" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_create.lview"/>
        <a:link id="con731_create_change_link" model="cont.CON731.create_change_req" modelaction="execute"/>
        <a:link id="${/parameter/@layout_code}_contract_print_link_id" url="${/request/@context_path}/modules/cont/CON302N/con_contract_print.lview"/>
        <a:link id="${/parameter/@layout_code}_contract_et_link_id" url="${/request/@context_path}/modules/cont/CON660/con_contract_def_et_detail.lview"/>
        <script type="text/javascript"><![CDATA[
            function open_contract_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON501_MODIFY'; 
                param['maintain_type'] = 'UPDATE';
                param['winid'] = 'con_contract_modify_link_winid';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', ds_id);
            }
            
            function open_project_Window(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var param = {};
                param['company_id'] = record.get('company_id');
                param['project_id'] = record.get('project_id');
                param['function_code'] = 'PRJ502D';
                param['function_usage'] = 'QUERY';
                param['bp_class'] = record.get('bp_class');
                param['maintain_type'] = 'QUERY';
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_special_link', ds_id, '${/parameter/@layout_code}');
            }
            
            function open_change_req_Window(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['change_req_id'] = record.get('change_req_id');
                param['contract_id'] = record.get('change_req_id');
            	param['project_id'] = record.get('project_id');
            	param['prj_bp_id'] = record.get('bp_id_tenant');
                param['function_code'] = 'CON660D';
                param['function_usage'] = 'UPDATE';
                param['maintain_type'] = 'MODIFY';
                param['url_title'] = '提前结清创建';
                param['document_type'] = 'DFF_ET';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, '${/parameter/@layout_code}_contract_et_link_id', ds_id);
            }
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'contract_number' && value) {
                    return '<a href="javascript:open_contract_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                } else if (name == 'project_id_c' && value) {
                    return '<a href="javascript:open_project_Window(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                } else if (name == 'change_req_number' && value) {
                    return '<a href="javascript:open_change_req_Window(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                }
                return value;
            };
            window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
            
                }
            };
            
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var prj_project_result_ds = $(ds_id);
                var records = prj_project_result_ds.getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                }
                Leaf.showConfirm('${l:HLS.PROMPT}', '<font color="red">该操作将导致合同在结清期间无法进行后续操作，请谨慎操作！！！</font></br></br><font color="red">【特别注意】如果需要取消结清，请一定点击取消结清按钮！！！</font>', function() {
                    var record = records[0];
                    var contract = record.get('contract_id');
                    var ccr_document_type = 'DFF_ET';
                    var req_date = record.get('req_date');
                    var description = record.get('description');
                    Leaf.Masker.mask(Ext.getBody());
                    Leaf.request({
                        url: $('con731_create_change_link').getUrl(),
                        para: {
                            simulation_flag: 'N',
                            contract_id: record.get('contract_id'),
                            req_type: ccr_document_type,
                            req_date: req_date,
                            description: description
                        },
                        success: function(res) {
                            var param = record.data;
                            param['change_req_id'] = res.result.change_req_id;
                            param['contract_id'] = res.result.change_req_id;
            
                            param['function_code'] = 'CON660D';
                            param['function_usage'] = 'UPDATE';
                            param['maintain_type'] = 'MODIFY';
                            param['url_title'] = '提前结清创建';
                            param['document_type'] = ccr_document_type;
                            hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, '${/parameter/@layout_code}_contract_et_link_id', ds_id);
                        },
                        failure: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                }, null, 300, 150);
            };
            
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON660"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
