<?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="prj_project_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_create_tree_n.lview"/>
        <a:link id="car_modify_special_link2" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_create_special.lview"/>
        <a:link id="car_modify_mananger_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain_manager.lview"/>
        <a:link id="car_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain_readonly.lview"/>
        <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/CON302N/con_contract_modify.lview"/>
        <a:link id="car_modify_special_link" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_create.lview"/>
        <a:link id="${/parameter/@layout_code}_contract_print_link_id" url="${/request/@context_path}/modules/cont/CON302N/con_contract_print.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'] = 'CON301'; /* param['function_usage'] = 'QUERY'; */
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'QUERY';
                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);
                //项目类layout_code

                        maintain_type = 'QUERY';
                        param = record.data;
                        param['bp_class'] = 'NP';
                        param['document_id'] = record.get('project_id');
                        param['function_code'] = 'PRJ501Q';
                        param['function_usage'] = 'QUERY';
                        param['maintain_type'] = 'QUERY';
                        param['maintain_type'] = maintain_type;
                        param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                        hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_link', 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>';
                }
                if (name == 'project_id_c' && value) {
                    return '<a href="javascript:open_project_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 records = $(ds_id).getSelected();
                for (var i = 0;i < records.length;i++) {
                    var param = records[i].data;
                    param['function_code'] = 'CON480_MODIFY'; /* param['function_usage'] = 'QUERY'; */
                    param['maintain_type'] = 'UPDATE';
                    param['bp_class'] = 'NP';
                    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);
                }
            };
            
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
                var result_ds = $('CONTRACT_QUERY_ENTRANCE_G_CONTRACT_RESULT_con_contract_ds');
                var record = result_ds.getCurrentRecord();
                var document_id = record.get('contract_id');
                var contract_number = record.get('contract_number');
                var contract_name = record.get('contract_name');
                var win = new Leaf.Window({
                    id: 'con_contract_print_win_id',
                    params: {
                        contract_id: record.get('contract_id'),
                        winid: 'con_contract_print_win_id',
                        contract_number: contract_number,
                        contract_name: contract_name
                    },
                    url: $('${/parameter/@layout_code}_contract_print_link_id').getUrl(),
                    title: '打印支付计划',
                    width: 1300,
                    height: 550
                });
                //在关闭页面之后,刷新一下ds
                win.on('close', function() {
            
                   });
            };
            
            //单据跟踪
            window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function() {
                // var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                // var records = $('prj_project_ds_id').getSelected();
                var ds = $('CONTRACT_QUERY_ENTRANCE_G_CONTRACT_RESULT_con_contract_ds');
                var records = ds.getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('提示', '请选择一条数据！');
                    return;
                }
                var instance_id = records[0].get('wfl_instance_id');
                var win = new Leaf.Window({
                    id: 'history_check',
                    url: $('${/parameter/@layout_code}${/parameter/@pre_layout}zj_wfl_approve_history_check').getUrl(),
                    params: {
                        instance_id: instance_id
                    },
                    title: '单据历史查看',
                    height: 500,
                    width: 860,
                    fullScreen: true
                });
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON501"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
