<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2014-9-28 下午2:02:27  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="relation_update_link_id" url="${/request/@context_path}/modules/hls/HLS1010/bp_master_relation.lsc"/>
        <script type="text/javascript"><![CDATA[

            function exp_1051_next() {
                history.go(1);
            }
            
            function exp_1051_back() {
                history.go(-1);
            }
            
            function exp_1051_quit() {
                location.href = $('sys_service_welcome_link').getUrl();
            }
            
            function save_bp_relation() {
                var dept_ds = $('bp_master_com_ds1'); // 取得dataset对象
                var records = dept_ds.getSelected(); // 取得record数组
                var param = new Object();
                var datas = [];
                var data = {};
            
                if (records.length == 0) {
                    Leaf.showInfoMessage('信息', '请至少选择一行！', null, 200, 100);
                }
                for (var i = 0;i < records.length;i++) {
                    data = {};
                    data['bp_id'] = ${/parameter/@bp_id};
                    data['related_bp_id'] = records[i].get('bp_id');
                    data['relation_type'] = 'INSR';
                    data['relation_category'] = 'INSR';
                    data['enabled_flag'] = 'Y';
                    data['_status'] = 'insert';
            
                    datas.push(data);
                }
                param['details'] = datas;
                Leaf.request({
                    url: $('relation_update_link_id').getUrl(),
                    para: param,
                    success: function(args) {
            
                        $('bp_master_com_ds1').query();
                        $('bp_master_com_ds2').query();
            
                    },
                    scope: this
                });
            }
            
            function delete_bp_relation() {
                var dept_ds = $('bp_master_com_ds2'); // 取得dataset对象
                var records = dept_ds.getSelected(); // 取得record数组
                var param = new Object();
                var datas = [];
                var data = {};
            
                if (records.length == 0) {
                    Leaf.showInfoMessage('信息', '请至少选择一行！', null, 200, 100);
                }
                for (var i = 0;i < records.length;i++) {
                    data = {};
                    data['bp_id'] = ${/parameter/@bp_id};
                    data['related_bp_id'] = records[i].get('bp_id');
                    data['_status'] = 'execute';
                    datas.push(data);
                }
                param['details'] = datas;
                Leaf.request({
                    url: $('relation_update_link_id').getUrl(),
                    para: param,
                    success: function(args) {
            
                        $('bp_master_com_ds1').query();
                        $('bp_master_com_ds2').query();
            
                    },
                    scope: this
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="bp_master_query_ds1">
                <a:fields>
                    <a:field name="bp_id" defaultValue="${/parameter/@bp_id}"/>
                    <a:field name="bp_type" defaultValue="LSHM"/>
                    <a:field name="not_exist_query" defaultValue="Y"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="bp_master_query_ds2">
                <a:fields>
                    <a:field name="bp_id" defaultValue="${/parameter/@bp_id}"/>
                    <a:field name="bp_type" defaultValue="LSHM"/>
                    <a:field name="exist_query" defaultValue="Y"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="bp_master_com_ds1" autoQuery="true" model="hls.HLS1010.hls_bp_master_lv" pageSize="15" queryDataSet="bp_master_query_ds1" selectable="true"/>
            <a:dataSet id="bp_master_com_ds2" autoQuery="true" model="hls.HLS1010.hls_bp_master_lv" pageSize="15" queryDataSet="bp_master_query_ds2" selectable="true"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="exp_1051_back" text="HLS.BACK"/>
                <a:gridButton click="exp_1051_next" text="HLS.FORWARD"/>
                <a:gridButton click="exp_1051_quit" text="HLS.EXIT"/>
                <!--    <a:gridButton click="save_bp_relation_ds" text="分配"/> -->
            </a:screenTopToolbar>
            <a:hBox>
                <a:vBox>
                    <a:grid id="bp_master_com_ds_grid1" bindTarget="bp_master_com_ds1" marginHeight="200" navBar="true" width="600">
                        <a:columns>
                            <a:column name="bp_code" align="left" prompt="公司编码" width="100"/>
                            <a:column name="bp_name" align="left" prompt="公司名称" width="100"/>
                            <a:column name="bp_category_n" align="left" prompt="公司类别" width="80"/>
                            <a:column name="bp_type_n" align="left" prompt="公司类型" width="100"/>
                            <a:column name="bp_class_n" align="left" prompt="分类" width="90"/>
                        </a:columns>
                    </a:grid>
                </a:vBox>
                <a:vBox>
                    <a:button click="save_bp_relation" height="35" text="&gt;---" width="50"/>
                    <a:button click="delete_bp_relation" height="35" text="&lt;---" width="50"/>
                </a:vBox>
                <a:vBox>
                    <a:grid id="bp_master_com_ds_grid2" bindTarget="bp_master_com_ds2" marginHeight="200" navBar="true" width="600">
                        <a:columns>
                            <a:column name="bp_code" align="left" prompt="公司编码" width="65"/>
                            <a:column name="bp_name" align="left" prompt="公司名称" width="70"/>
                            <a:column name="bp_category_n" align="left" prompt="公司类别" width="75"/>
                            <a:column name="bp_type_n" align="left" prompt="公司类型" width="200"/>
                            <a:column name="bp_class_n" align="left" prompt="分类" width="90"/>
                        </a:columns>
                    </a:grid>
                </a:vBox>
            </a:hBox>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
     
        ]]></script>
    </a:view>
</a:screen>
