<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: 34291 gzj
    $Date: 2022年9月5日
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query model="rsc.RSC510.workflow_info" defaultWhereClause="instance_id=${/parameter/@instance_id}" rootPath="wolkflow_path"></a:model-query>
    </a:init-procedure>
    <a:view>
        <a:link id="update_final_sort_id" model="rsc.RSC510.rsc_contract_query" modelaction="update"/>
        <a:link id="update_five_class_link" model="rsc.RSC510.update_five_class" modelaction="update"/>
        <a:link id="update_text_link" url="${/request/@context_path}/modules/rsc/RSC510/rsc_update_text.lview" />
        <script><![CDATA[

        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {
            if('${/model/wolkflow_path/record/@current_seq}' == '10'){
                var ds_id=get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                // var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_five_classification');
                var records = $(ds_id).getCurrentRecord();
                if(ds.id==ds_id){
                    if(name=='final_sort') {
                        debugger
                        var presorting_result = records.get('presorting_result');
                        var final_sort = records.get('final_sort');
                        if(presorting_result != final_sort){
                            records.getField('text').setRequired(true);
                        }
                        if(presorting_result == final_sort){
                            records.getField('text').setRequired(false);
                        }
                    }
                }
            }else{
                var ds_id=get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                var ds_id_s=get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT_SAME', 'con_five_classification');
                // var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_five_classification');
                var records = $(ds_id).getCurrentRecord();
                var records_s = $(ds_id_s).getCurrentRecord();
                if(ds.id==ds_id){
                    if(name=='final_sort') {
                        debugger
                        var presorting_result = records.get('presorting_result');
                        var final_sort = records.get('final_sort');
                        if(presorting_result != final_sort){
                            records.getField('text').setRequired(true);
                        }
                        if(presorting_result == final_sort){
                            records.getField('text').setRequired(false);
                        }
                    }
                }
                if(ds.id==ds_id_s){
                    if(name=='final_sort') {
                        debugger
                        var presorting_result = records_s.get('presorting_result');
                        var final_sort = records_s.get('final_sort');
                        if(presorting_result != final_sort){
                            records_s.getField('text').setRequired(true);
                        }
                        if(presorting_result == final_sort){
                            records_s.getField('text').setRequired(false);
                        }
                    }
                }
            }

        }
        //加载时调用(grid,table,gridBox)
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function (ds, record, config_records, bp_seq) {
            if ('${/model/wolkflow_path/record/@current_seq}' == '30') {
                document.getElementById("RSC_FIVE_CLASS_WFL_query").style.display = "none";
                document.getElementById("RSC_FIVE_CLASS_WFL_user_button1").style.display = "none";
                document.getElementById("RSC_FIVE_CLASS_WFL_user_button2").style.display = "none";
            }
            if('${/model/wolkflow_path/record/@current_seq}' == '20'){
                document.getElementById("RSC_FIVE_CLASS_WFL_user_button1").style.display = "none";
                document.getElementById("RSC_FIVE_CLASS_WFL_user_button2").style.display = "none";
                document.getElementById("RSC_FIVE_CLASS_WFL_RESULT_SAVE_layout_dynamic_button_id").style.display = "none";
                document.getElementById("RSC_FIVE_CLASS_WFL_RESULT_ADD_layout_dynamic_button_id").style.display = "none";

            }
            var estimate_num = '${/parameter/@estimate_num}';
            if('${/model/wolkflow_path/record/@current_seq}' == '10'){
                var ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                var records = $(ds_id).getAll();
                for (var i = 0;i < records.length;i++) {
                    records[i].getField('contract_number').setReadOnly(true);
                    records[i].getField('contract_number_n').setReadOnly(true);
                }
            }else{
                var ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                var ds_id_s=get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT_SAME', 'con_five_classification');
                var records = $(ds_id).getAll();
                var records_s = $(ds_id_s).getAll();

                    for (var i = 0;i < records.length;i++) {
                        records[i].getField('contract_number').setReadOnly(true);
                        records[i].getField('contract_number_n').setReadOnly(true);
                        records[i].getField('text').setReadOnly(true);
                        records[i].getField('final_sort').setReadOnly(true);
                        records[i].getField('final_sort_n').setReadOnly(true);
                    }
                    for (var i = 0;i < records_s.length;i++) {
                        records_s[i].getField('contract_number').setReadOnly(true);
                        records_s[i].getField('contract_number_n').setReadOnly(true);
                        records_s[i].getField('text').setReadOnly(true);
                        records_s[i].getField('final_sort').setReadOnly(true);
                        records_s[i].getField('final_sort_n').setReadOnly(true);
                    }
                }

                Leaf.request({
                    url: $('update_final_sort_id').getUrl(),
                    para: {
                        estimate_num: estimate_num
                    },
                    success: function () {
                        // $(ds_id).query();
                        // $(ds_id_s).query();
                    },
                    error: function () {
                    },
                    failure: function () {
                    },
                    scope: this

                })

        }
        //刷新
        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
            var estimate_num = '${/parameter/@estimate_num}';
            if('${/model/wolkflow_path/record/@current_seq}' == '10'){
                var ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                Leaf.request({
                    url: $('update_five_class_link').getUrl(),
                    para: {
                        estimate_num: estimate_num
                    },
                    success: function() {
                        $(ds_id).query();
                        Leaf.SideBar.show({
                            msg:'刷新成功',
                            duration: 2000
                        });
                    },
                    failure: function() {

                    },
                    error: function() {

                    },
                    scope: this
                });
            }else{
                var ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                var ds_id_s=get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT_SAME', 'con_five_classification');
                Leaf.request({
                    url: $('update_five_class_link').getUrl(),
                    para: {
                        estimate_num: estimate_num
                    },
                    success: function() {
                        $(ds_id).query();
                        $(ds_id_s).query();
                        Leaf.SideBar.show({
                            msg:'刷新成功',
                            duration: 2000
                        });
                    },
                    failure: function() {

                    },
                    error: function() {

                    },
                    scope: this
                });
            }


        }
        //批量录入说明
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            if('${/model/wolkflow_path/record/@current_seq}' == '10'){
                var ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                var  record = $(ds_id).getSelected();
                if(record.length<1){
                    Leaf.showMessage('${l:HLS.PROMPT}', '请至少选择一条数据!');
                    return;
                }
                var win = new Leaf.Window({
                    id: 'update_text_winid',
                    url: $('update_text_link').getUrl(),
                    title: '批量录入说明',
                    height: 400,
                    width: 450,
                });
            }else{
                var ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT', 'con_five_classification');
                var ds_id_s=get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'RESULT_SAME', 'con_five_classification');
                var  record = $(ds_id).getSelected();
                var  record_s = $(ds_id_s).getSelected();
                if((record.length<1)&&(record_s.length<1)){
                    Leaf.showMessage('${l:HLS.PROMPT}', '请至少选择一条数据!');
                    return;
                }
                var win = new Leaf.Window({
                    id: 'update_text_winid',
                    url: $('update_text_link').getUrl(),
                    title: '批量录入说明',
                    height: 400,
                    width: 450,
                });
            }


        }

        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>