<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qianming  
    $Date: 2014-7-25 下午2:23:45  
    $Revision: 1.0  
    $Purpose: 合同代扣账户维护(仅维护个人)
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="bill99_protocol_check_link_id" url="${/request/@context_path}/modules/csh/CSH600/bill99_pki.lsc"/>
        <a:link id="bill99_protocol_sign_link_id" url="${/request/@context_path}/modules/csh/CSH600/bill99_sign_pki.lsc"/>
        <a:link id="cux_ebank_cmb_agentrequest_log_link" url="${/request/@context_path}/modules/cont/CON591/hls_ebank_agentrequest_log.lview"/>
        <a:link id="protocol_delete" url="${/request/@context_path}/autocrud/cont.CON591.con_contract/execute"/>
        <script type="text/javascript"><![CDATA[
            function exit() {
                window.location = '${/request/@context_path}/welcome.lview';
            }
            
            function query() {
                $('con_contract_result_ds').query();
            }
            
            function reset() {
                $('con_contract_query_ds').reset();
            }
            
            function save() {
                var ds = $('con_contract_result_ds');
                if (ds.getSelected().length < 1) {
                    Leaf.showMessage('提示', '至少选择一行数据进行保存!');
                    return;
                }
                $('con_contract_result_ds').submitSelected();
            }
            
            function sign_procotol() {
            
                /* if($('con_contract_result_ds').validate()){
                 Leaf.showMessage('提示', '请先保存!');
                 return;
                 } */
                save();
                var records = $('con_contract_result_ds').getSelected();
                if (records.length < 1) {
                    Leaf.showMessage('提示', '至少选择一行数据协议签订!');
                    return;
                }
                for (var i = 0;i < records.length;i++) {
                    //ebank_id_c,ebank_type_n,ebank_account_name,ebank_account_num
                    if (typeof(records[i].get('ebank_id_c')) == 'undefined' || typeof(records[i].get('ebank_type_n')) == 'undefined' || typeof(records[i].get('ebank_account_name')) == 'undefined' || typeof(records[i].get('ebank_account_num')) == 'undefined') {
                        Leaf.showMessage('提示', '代扣银行,账户类型,户名或账号信息不完整,请维护!');
                        return;
                    }
                }
                Leaf.Masker.mask(Ext.getBody(), '正在执行...');
                var contract_ids;
                contract_ids = records[0].get('contract_id');
            
                for (var i = 1;i < records.length;i++) {
                    contract_ids = contract_ids + ',' + records[i].get('contract_id');
                }
            
                var url_l = $('bill99_protocol_sign_link_id').getUrl();
                Leaf.request({
                    url: url_l,
                    para: {
                        contract_id: '(' + contract_ids + ')'
                    },
                    success: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                        $('con_contract_result_ds').query();
                    },
                    error: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    failure: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });
            }
            
            function refresh_procotol() {
            
                var records = $('con_contract_result_ds').getSelected();
                if (!records.length) {
                    Leaf.showMessage('${l:PROMPT}', '请至少选择一条记录');
                    return;
                }
                for (var i = 0;i < records.length;i++) {
                    //ebank_id_c,ebank_type_n,ebank_account_name,ebank_account_num
                    if (typeof(records[i].get('protocol_number')) == 'undefined') {
                        Leaf.showMessage('提示', '请选择签订协议号的合同进行刷新!');
                        return;
                    }
                }
                Leaf.Masker.mask(Ext.getBody(), '正在执行...');
                var contract_ids;
                contract_ids = records[0].get('contract_id');
                for (var i = 1;i < records.length;i++) {
                    contract_ids = contract_ids + ',' + records[i].get('contract_id');
                }
            
                var url_l = $('bill99_protocol_check_link_id').getUrl();
                Leaf.request({
                    url: url_l,
                    para: {
                        contract_id: '(' + contract_ids + ')'
                    },
                    success: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                        $('con_contract_result_ds').query();
                    },
                    error: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    failure: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });
            }
            
            function resultexport() {
                $('grid_id')._export();
            }
            
            function rendererGrid(value, record, name) {
            
                if (name == 'log_detail') {
                    if (!record.isNew) {
                        return '<a href="javascript:openWindow_log(' + record.get('contract_id') + ');">日志</a>';
                    }
                    return '';
                }
            }
            
            function openWindow_log(contract_id) {
                new Leaf.Window({
                    id: 'cux_ebank_cmb_agentrequest_log_link_winid',
                    url: $('cux_ebank_cmb_agentrequest_log_link').getUrl(),
                    params: {
                        interface_id: contract_id,
                        winId: 'cux_ebank_cmb_agentrequest_log_link_winid'
                    },
                    title: '日志',
                    width: 800,
                    height: 550
                });
            
            }
            
            function delete_procotol() {
                var records = $('con_contract_result_ds').getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '请选择一条记录');
                    return;
                }
                var contract_id = records[0].get('contract_id');
            
                Leaf.showConfirm('提示', '是否删除协议号?', function okFun() {
                    Leaf.request({
                        url: $('protocol_delete').getUrl(),
                        para: {
                            contract_id: contract_id
                        },
                        success: function(res) {
                            $('con_contract_result_ds').query();
                        },
                        error: function() {
            
                           }
                    });
                }, function canFun() {
            
                   });
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON541"/>
        <a:dataSets>
            <a:dataSet id="ebank_cmb_ds" lookupCode="EBANK_TYPE"/>
            <a:dataSet id="account_prop_ds" lookupCode="ACCOUNT_PROP"/>
            <a:dataSet id="ebank_protocol_status_ds" lookupCode="CON591_EBANK_PROTOCOL_STATUS"/>
            <a:dataSet id="con_contract_query_ds" model="cont.CON591.con_contract">
                <a:fields>
                    <a:field name="contract_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON500.con_contract_number_lov" lovWidth="500" prompt="合同编号" title="HLS.CONTRACT_NUMBER">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_name" prompt="合同名称"/>
                    <a:field name="bp_id_tenant"/>
                    <a:field name="bp_id_tenant_n" lovHeight="500" lovLabelWidth="100" lovService="cont.CON591.hls_bp_master_lv" lovWidth="800" prompt="承租人" title="承租人">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_id_tenant_n"/>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="ebank_protocol_status"/>
                    <a:field name="ebank_protocol_status_n" displayField="code_value_name" options="ebank_protocol_status_ds" prompt="协议状态" returnField="ebank_protocol_status" valueField="code_value"/>
                    <a:field name="ebank_id"/>
                    <a:field name="ebank_id_n" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON591.csh_bank_lov" lovWidth="500" prompt="代扣银行" title="银行">
                        <a:mapping>
                            <a:map from="bank_id" to="ebank_id"/>
                            <a:map from="bank_code" to="ebank_id_c"/>
                            <a:map from="bank_short_name" to="ebank_id_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="ebank_account_num" prompt="代扣帐号"/>
                    <a:field name="flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_result_ds" autoQuery="true" model="cont.CON591.con_contract" pageSize="13" queryDataSet="con_contract_query_ds" selectable="true">
                <a:fields>
                    <a:field name="ebank_account_prop_desc" displayField="code_value_name" options="account_prop_ds" returnField="ebank_account_prop" valueField="code_value"/>
                    <a:field name="contract_id"/>
                    <a:field name="contract_number"/>
                    <a:field name="contract_name"/>
                    <a:field name="project_id"/>
                    <a:field name="bp_id_tenant_n"/>
                    <a:field name="ebank_id"/>
                    <a:field name="ebank_id_c" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON591.csh_bank_lov" lovWidth="500" title="银行">
                        <a:mapping>
                            <a:map from="bank_id" to="ebank_id"/>
                            <a:map from="bank_code" to="ebank_id_c"/>
                            <a:map from="bank_short_name" to="ebank_id_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="ebank_type"/>
                    <a:field name="ebank_type_n" displayField="code_value_name" options="ebank_cmb_ds" returnField="ebank_type" valueField="code_value"/>
                    <a:field name="ebank_account_name"/>
                    <a:field name="ebank_account_num"/>
                    <a:field name="id_card_no"/>
                    <a:field name="cell_phone"/>
                    <a:field name="ebank_protocol_status_n"/>
                </a:fields>
                <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenTopToolbar>
            <a:screenTitle/>
            <a:gridButton click="exit" text="退出"/>
            <a:gridButton click="resultexport" text="导出"/>
            <a:gridButton click="query" text="查询"/>
            <a:gridButton click="reset" text="重置"/>
            <a:gridButton click="save" text="保存"/>
            <!-- <a:gridButton click="sign_procotol" text="签订协议"/>
            <a:gridButton click="refresh_procotol" text="刷新协议"/>
            <a:gridButton click="delete_procotol" text="删除协议"/> -->
        </a:screenTopToolbar>
        <a:form column="3" title="HLS.QUERY_TITLE">
            <a:lov name="contract_number" bindTarget="con_contract_query_ds"/>
            <a:textField name="contract_name" bindTarget="con_contract_query_ds"/>
            <a:lov name="bp_id_tenant_n" bindTarget="con_contract_query_ds"/>
            <a:lov name="ebank_id_n" bindTarget="con_contract_query_ds"/>
            <a:textField name="ebank_account_num" bindTarget="con_contract_query_ds"/>
            <!-- <a:comboBox name="ebank_protocol_status_n" bindTarget="con_contract_query_ds"/>
            <a:textField name="protocol_number" bindTarget="con_contract_query_ds" prompt="协议号"/> -->
            <!-- <a:checkBox name="flag" bindTarget="con_contract_query_ds" checkedValue="Y" prompt="过滤" uncheckedValue="N"/> -->
        </a:form>
        <a:grid id="grid_id" bindTarget="con_contract_result_ds" height="400" navBar="true" width="1340">
            <a:columns>
                <a:column name="contract_number" lock="true" prompt="合同号" width="110"/>
                <a:column name="contract_name" prompt="合同名称" width="180"/>
                <a:column name="bp_id_tenant_n" prompt="承租人" width="80"/>
                <a:column name="ebank_id_c" editor="lov_id" prompt="代扣银行代码" width="80"/>
                <a:column name="ebank_id_n" prompt="代扣银行" width="80"/>
                <a:column name="ebank_account_prop_desc" editor="comboBox_id" prompt="代扣属性" width="80"/>
                <a:column name="ebank_type_n" editor="comboBox_id" prompt="代扣账户类型" width="100"/>
                <a:column name="ebank_account_name" editor="textField_id" prompt="代扣账户名" width="100"/>
                <a:column name="ebank_account_num" editor="textField_id" prompt="代扣帐号" width="140"/>
                <a:column name="id_card_no" prompt="证件号" width="140"/>
                <a:column name="cell_phone" prompt="手机" width="100"/>
                <!-- <a:column name="protocol_number" prompt="协议号" width="200"/>
                <a:column name="ebank_protocol_status_n" prompt="协议状态" width="80"/> -->
                <!-- <a:column name="log_detail" align="center" prompt="日志" renderer="rendererGrid" width="50"/> -->
            </a:columns>
            <a:editors>
                <a:textField id="textField_id"/>
                <a:comboBox id="comboBox_id"/>
                <a:lov id="lov_id"/>
            </a:editors>
        </a:grid>
    </a:view>
</a:screen>