<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="fnd.fnd_company_all_lov" rootPath="gld110_company_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="gld_copy_execute_link" model="gld.GLD110.je_template_grp_copy" modelaction="batch_update"/>
        <script type="text/javascript"><![CDATA[
			function gld110_confirm_write(){
			    if (!$('gld110_template_company_ds').validate()){
			        return;
			    }
			    var company_id = $('gld110_template_company_ds').getAt(0).get('company_id');
			    var records = $('groupDs').getSelected();
			    var submitData = [];
                var new_data ={};
                for (var i = 0;i < records.length;i++) {
            		new_data={'_status'		 :'update',
            		         'template_group_id':records[i].get('template_group_id'),
            		         'to_company_id':company_id};
                    submitData.push(new_data);
                }
                var url;
                url = $('gld_copy_execute_link').getUrl();
                Leaf.showConfirm('${l:PROMPT}', '确定?', function() {
                    var detail_mask = Ext.getBody();
                    Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    Leaf.request({
                        url: url,
                        para: submitData,
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '操作成功',
                                duration: 2000
                            });
                            Leaf.Masker.unmask(detail_mask);
                            $('gld110_je_copy_screen_id').close();
                        },
                        error: function(){
                            $('gld110_je_copy_screen_id').close();
                            Leaf.Masker.unmask(detail_mask);
                        },
                        failure: function(){
                            $('gld110_je_copy_screen_id').close();
                           Leaf.Masker.unmask(detail_mask);
                        },
                        scope: this
                    });
                }, function() {
                    return;
                }, null, null);
			}
		]]></script>
        <a:dataSets>
            <a:dataSet id="gld110_company_ds">
                <a:datas dataSource="/model/gld110_company_path"/>
            </a:dataSet>
            <a:dataSet id="gld110_template_company_ds" autoCreate="true">
                <a:fields>
                    <a:field name="company_name" displayField="company_short_name" options="gld110_company_ds" required="true" returnField="company_id" valueField="company_id"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenTopToolbar>
            <a:gridButton click="gld110_confirm_write" text="确认"/>
        </a:screenTopToolbar>
        <a:form>
            <a:comboBox name="company_name" bindTarget="gld110_template_company_ds" prompt="公司" width="140"/>
        </a:form>
    </a:view>
</a:screen>