<?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="get_xml" model="cont.CON316.contract_cost_scene" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            getXml();
            $('${/parameter/@layout_code}_save').disable();
            $('${/parameter/@layout_code}_user_button1').disable();
        };

        function getXml() {
            var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_cost_support');
            var req_record = $(req_ds_id).getCurrentRecord();
            var contract_cost_id = req_record.get('contract_cost_id');
            if (req_record.dirty) {
                Leaf.showMessage('${l:HLS.PROMPT}', '页面数据存在修改，请先保存再发起起案！');
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                return;
            }
                Leaf.request({
                    url: $('get_xml').getUrl(),
                    para: {
                        contract_cost_id: contract_cost_id,
                        interface_name: '${/parameter/@case_type}'
                    },
                    success: function(res) {
                        getUrl(res.result.xml)
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    error: function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    scope: this
                });

        }

        function getUrl(xml) {
            Leaf.request({
                url: '${/request/@context_path}/doodream/post/url',
                para: {
                    xml: xml
                },
                success: function(res) {
                    window.open(res.message, "", "width=940, height=650, scrollbars=yes, toolbar=no, location=no, status=no, menubar=no");
                    Leaf.SideBar.show({
                        msg: '${l:HLS.SUBMIT_SUCCESS}',
                        duration: 2000
                    });
                },
                failure: function() {
                    Leaf.SideBar.show({
                        msg: 'failure',
                        duration: 2000
                    });
                },
                error: function() {
                    Leaf.SideBar.show({
                        msg: 'error',
                        duration: 2000
                    });
                },
                scope: this
            });
        }

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