<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Calvin
    $Date: 2017年12月19日17:01:10
    $Revision: 1.0
    $Purpose: 代扣账户维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query model="cont.CON594.deduct_bank_lov" rootpath="deduct_bank_path"/>
        <a:model-query model="basic.sys_session_info" rootPath="default_value_record"/>
    </a:init-procedure>

    <a:view>
        <a:link id="default_idtype_idcode_mobile_link" model="cont.CON594.default_idtype_idcode_mobile"
                modelaction="batch_update"/>
        <a:link id="ebank_sms_list_import_link"
                url="${/request/@context_path}/modules/cont/CON594/ebank_list_import.lview"/>
        <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 resultexport() {
            $('grid_id')._export(null,'合同绑卡明细明细');
        }

        function con_contract_result_update(ds, record, name, value) {
            if (name == 'acctype') {
                if (value == 'VIRTUAL_CARD_DEDUCT') {
                    record.set('deduct_bank', 'CMB');
                    record.set('deduct_bank_n', '招商银行');
                }
            }

        }

        function bank_import() {
            var url_l = $('ebank_sms_list_import_link').getUrl();
            var win = new Leaf.Window({
                id: 'ebank_list_batch_import_win',
                url: url_l,
                params: {

                    'winid': 'ebank_list_batch_import_win',
                    'session_id': '${/session/@session_id}',
                    'parent_ds_id': 'con_contract_result_ds'
                },
                title: '信息导入',
                width: 430,
                height: 390
            });
            win.on('close', function () {
                query();
            });

        }

        function con591_editorFunction(record, name) {
            if (record.get('deduct_bank') == 'CMB') {
                if (name == 'bankacctid') {
                    var contract_id = record.get('contract_id');
                    record.getField(name).setLovPara('contract_id', contract_id);
                    return 'lov_id';
                }
            } else {
                if (name == 'bankacctname') {
                    return 'textField_id';
                }

                if (name == 'bankacctid') {
                    return 'textField_id';
                }
            }
            return;
        }


        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON594"/>
        <a:dataSets>
            <a:dataSet id="deduct_bank_path_ds">
                <a:datas dataSource="/model/deduct_bank_path"/>
            </a:dataSet>
            <a:dataSet id="yes_and_no_ds" lookupCode="YES_NO"/>
            <a:dataSet id="ebank_prop_ds" lookupCode="HLS211_ID_TYPE"/>
            <!-- <a:dataSet id="ebank_cmb_ds" lookupCode="DEDUCTION_CARD_TYPE"/> -->
            <a:dataSet id="ebank_cmb_ds" lookupCode="EBANK_DEDUCT_TYPE"/>
            <a:dataSet id="deduct_bank_ds" lookupCode="DEDUCT_BANK"/>
            <a:dataSet id="ebank_protocol_status_ds" lookupCode="CON594_EBANK_PROTOCOL_STATUS"/>
            <a:dataSet id="con_contract_query_ds" model="cont.CON594.con_contract">
                <a:fields>
                    <a:field name="contract_number"/>
                    <a:field name="contract_name"/>
                    <a:field name="bp_id_tenant"/>
                    <a:field name="bp_id_tenant_n" lovHeight="500" lovLabelWidth="100"
                             lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT&amp;authority_flag=Y&amp;trx_category=BP&amp;trx_id=t1.bp_id" 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_account_num" prompt="代扣帐号"/>
                    <a:field name="flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="deduction_flag"/>
                    <a:field name="deduction_flag_n" displayField="code_value_name" options="yes_and_no_ds"
                             returnField="deduction_flag" valueField="code_value"/>
                    <a:field name="send_sms_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="dd_sign_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="acctype" required="false"/>
                    <a:field name="acctype_n" displayField="code_value_name" options="ebank_cmb_ds" required="false"
                             returnField="acctype" valueField="code_value"/>
                    <a:field name="deduct_bank" required="false"/>
                    <a:field name="deduct_bank_n" displayField="code_value_name" options="deduct_bank_path_ds"
                             required="false" returnField="deduct_bank" valueField="code_value"/>
                    <a:field name="bankacctname"/>
                    <a:field name="bankacctid"/>
                    <a:field name="expireddate_from" datatype="DATE"/>
                    <a:field name="expireddate_to" datatype="DATE"/>
                    <a:field name="bp_id_agent_level1_n" lovService="basic.hls_bp_master_v_for_lov?bp_category=AGENT&amp;authority_flag=Y&amp;trx_category=BP&amp;trx_id=t1.bp_id"
                             lovHeight="500" lovLabelWidth="100" lovWidth="800" prompt="代理商" title="代理商">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id_agent_level1"/>
                            <a:map from="bp_name" to="bp_id_agent_level1_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="__async__"  defaultValue="Y" prompt="异步导出"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_result_ds" autoPageSize="true" autoQuery="false" fetchAll="false"
                       model="cont.CON594.con_contract" queryDataSet="con_contract_query_ds" selectable="true">
                <a:fields>
                    <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="bankid"/>
                    <a:field name="acctype" required="false"/>
                    <a:field name="acctype_n" displayField="code_value_name" options="ebank_cmb_ds" required="false"
                             returnField="acctype" valueField="code_value"/>
                    <a:field name="deduct_bank" required="false"/>
                    <a:field name="deduct_bank_n" displayField="code_value_name" options="deduct_bank_ds"
                             required="false" returnField="deduct_bank" 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:field name="deduction_flag"/>
                    <a:field name="deduction_flag_n" displayField="code_value_name" options="yes_and_no_ds"
                             returnField="deduction_flag" valueField="code_value"/>
                    <a:field name="bankacctname" required="false"/>
                    <a:field name="bankacctid" required="false" lovService="cont.CON594.csh_receipt_bank_account_lov"
                             lovHeight="500" lovLabelWidth="100" lovWidth="800">
                        <a:mapping>
                            <a:map from="bank_account_number" to="bankacctid"/>
                            <a:map from="bank_account_name" to="bankacctname"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                    <a:event name="update" handler="con_contract_result_update"/>
                    <a:event name="submitsuccess" handler="query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="query" text="查询"/>
                <a:gridButton click="reset" text="重置"/>
                <!--<a:gridButton id="save_button_id" click="save" text="保存"/>-->
                <a:gridButton id="resultexport_button_id" click="resultexport" text="导出"/>
                <!--<a:gridButton id="bank_import_button_id" click="bank_import" text="导入"/>-->
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="140" marginWidth="80" title="HLS.QUERY_TITLE">
                <a:textField name="contract_number" bindTarget="con_contract_query_ds" prompt="合同编号"/>
                <!--<a:textField name="contract_name" bindTarget="con_contract_query_ds" prompt="合同名称"/>-->
                <a:lov name="bp_id_tenant_n" bindTarget="con_contract_query_ds" prompt="客户名称"/>
                <!--<a:comboBox name="acctype_n" bindTarget="con_contract_query_ds" prompt="扣款类型"/>-->
                <a:comboBox name="deduct_bank_n" bindTarget="con_contract_query_ds" prompt="扣款银行"/>
                <a:textField name="bankacctname" bindTarget="con_contract_query_ds" prompt="扣款账户名称"/>
                <a:textField name="bankacctid" bindTarget="con_contract_query_ds" prompt="扣款银行卡号"/>
                <a:lov name="bp_id_agent_level1_n" bindTarget="con_contract_query_ds"/>
                <a:datePicker name="expireddate_from" bindTarget="con_contract_query_ds" prompt="协议/绑定日期从"/>
                <a:datePicker name="expireddate_to" bindTarget="con_contract_query_ds" prompt="协议/绑定日期到"/>
            </a:form>
            <a:grid id="grid_id" bindTarget="con_contract_result_ds" marginHeight="250" marginWidth="80" navBar="true">
                <a:columns>
                    <a:column name="contract_number" lock="true" prompt="合同编号" width="120"/>
                    <!--<a:column name="contract_name" prompt="合同名称" width="220"/>-->
                    <a:column name="bp_id_tenant_n" prompt="客户名称" width="180"/>
                    <a:column name="bp_id_agent_level1_n" prompt="代理商"/>
                    <!--<a:column name="acctype_n" align="center" editor="comboBox_id" prompt="扣款类型" width="120"/>-->
                    <a:column name="deduct_bank_n" align="center"  prompt="扣款银行" width="120"/>
                    <a:column name="bankacctname"  prompt="扣款账户名称" width="150"/>
                    <a:column name="bankacctid"  prompt="扣款银行卡号" width="160"/>
                    <a:column name="expireddate" align="center"  prompt="协议/绑定日期"
                              renderer="Leaf.formatDate" width="110"/>
                    <a:column name="contract_status_desc" prompt="合同状态"/>
                    <a:column name="lease_execution_date" prompt="执行日期" renderer="Leaf.formatDate"/>
                    <!--<a:column name="app_bank_name" prompt="app-银行" width="120"/>-->
                    <!--<a:column name="app_bank_branch" prompt="app-开户行" width="150"/>-->
                    <!--<a:column name="app_bank_account_name" prompt="app-账户名" width="150"/>-->
                    <!--<a:column name="app_bank_account_num" prompt="app-账号" width="150"/>-->
                </a:columns>

            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
        if ('${/model/default_value_record/record/@bp_category}' == 'AGENT') {
            $('save_button_id').disable();
            $('bank_import_button_id').disable();
            $('resultexport_button_id').disable();
        }
        ]]></script>
    </a:view>
</a:screen>