tre_credit_amt_manage.lview 16.4 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Guoxuezhao  
    $Date: 2013-5-27 下午3:43:19  
    $Revision: 1.0  
    $Purpose: 授信额度维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure/>
    <a:view>
        <script type="text/javascript"><![CDATA[
            function tre501_manage_query() {
                $('bank_credit_contract_ds').query();
            }
            
            function tre501_manage_add() {
                $('bank_credit_contract_ds').create();
            }
            
            function tre501_manage_reset() {
                $('bank_credit_contract_query_ds').reset();
            }
            
            function tre501_manage_clear() {
                $('bccd_grid').clear();
            }
            
            function lock_current_window() {
                Leaf.Masker.mask(document.documentElement, '${l:HLS.EXECUTING}');
            }
            
            function unlock_current_window() {
                Leaf.Masker.unmask(document.documentElement);
            }
            
            function tre501_manage_save() {
                lock_current_window();
                if ($('bank_credit_contract_ds').validate()) {
                    $('bank_credit_contract_ds').submit();
                } else {
                    unlock_current_window();
                }
            }
            
            function on_bank_credit_contract_submitsuccess(ds, res) {
                tre501_manage_query();
                ds.query(ds.currentPage);
                unlock_current_window();
            }
            
            function on_bank_credit_contract_submitfailed(ds, res) {
                unlock_current_window();
            }
            
            function viewDetails(value, record, name) {
                if (record.isNew) {
                    return '';
                } else {
                    return '<a href="javascript:openDetailWindow(' + record.get('bp_id') + ',\'' + record.get('credit_contract_id') + '\');">${l:TRE501.TRE_BANK_CREDIT_CONTRACT.DETAIL}</a>';
                }
            }
            
            function openDetailWindow(bp_id,id) {
                var win = new Leaf.Window({
                    id: 'tre_credit_amt_detail_winid',
                    url: 'tre_credit_amt_detail.lview',
                    params: {
                        credit_contract_id: id,
                        bp_id: bp_id
                    },
                    width: '900',
                    height: '500',
                    title: '明细',
                    fullScreen: true
                });
                win.on('close', function() {
                    var result_ds = $('bank_credit_contract_ds');
                    result_ds.query(result_ds.currentPage);
                });
            }
            
            function dateValidator(record, name, value) { //日期校验方法
                if (name == 'credit_date_from' || name == 'credit_date_to') {
                    var start_date = Leaf.formatDate(record.get('credit_date_from'));
                    var end_date = Leaf.formatDate(record.get('credit_date_to'));
                    if ( !! end_date) { //由于结束日期非必填,只有在结束日期填了才进行比较
                        if (!compareDate(start_date, end_date)) {
                            return '${l:TRE501.CREDIT_DATE_FROM_BEYOND_TO}'; //校验不通过返回字符串
                        }
                    }
                    return true; //校验通过返回true
                }
            }
            
            function compareDate(start, end) {
                if (start > end) {
                    return false;
                }
                return true;
            }
            
            function tre501_manage_excel() {
                $('bccd_grid')._export('xls', '授信额度');
            }
            
            function on_bank_credit_contract_update(dataset, record, name, value, oldvalue) {
                var credit_limit_type = record.get('credit_limit_type');
                if (name == 'credit_amount') {
                    //非循环授信:可用额度=授信额度-借款额度
                    if (credit_limit_type == 'UNREVOLVING_CREDIT') {
                        var loan_amount = record.get('loan_amount');
                        var available_amount = value - loan_amount;
                        record.set('available_amount', available_amount);
                    }
                    //循环授信:可用额度=授信额度-借款额度+已还本金
                    if (credit_limit_type == 'REVOLVING_CREDIT') {
                        loan_amount = record.get('loan_amount');
                        var repayment_principal = record.get('repayment_principal');
                        available_amount = value - loan_amount + repayment_principal;
                        record.set('available_amount', available_amount);
                    }
                }
                if (name == 'credit_limit_type_desc') {
                    //非循环授信:可用额度=授信额度-借款额度
                    if (value == '非循环授信') {
                        loan_amount = record.get('loan_amount');
                        var credit_amount = record.get('credit_amount');
                        available_amount = credit_amount - loan_amount;
                        record.set('available_amount', available_amount);
                    }
                    //循环授信:可用额度=授信额度-借款额度+已还本金
                    if (value == '循环授信') {
                        loan_amount = record.get('loan_amount');
                        credit_amount = record.get('credit_amount');
                        repayment_principal = record.get('repayment_principal');
                        available_amount = credit_amount - loan_amount + repayment_principal;
                        record.set('available_amount', available_amount);
                    }
                }
            
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="TRE501_BUSINESS_TERM_ds" lookupCode="TRE501_BUSINESS_TERM"/>
            <a:dataSet id="TRE501_PURPOSE_ds" lookupCode="TRE501_PURPOSE"/>
            <a:dataSet id="TRE501_DIRECTOR_RESOLUTION_ds" lookupCode="TRE501_DIRECTOR_RESOLUTION"/>
            <a:dataSet id="credit_limit_type_ds" lookupCode="TRE501_CREDIT_LIMIT_TYPE"/>
            <a:dataSet id="credit_class_ds" lookupCode="CREDIT_CONTRACT_CREDIT_TYPE"/>
            <a:dataSet id="credit_category_ds" lookupCode="CREDIT_CONTRACT_CREDIT_CATEGORY"/>
            <a:dataSet id="bank_credit_contract_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="credit_class_desc" displayField="code_value_name" options="credit_class_ds" returnField="credit_class" valueField="code_value"/>
                    <a:field name="credit_limit_type_desc" displayField="code_value_name" options="credit_limit_type_ds" returnField="credit_limit_type" valueField="code_value"/>
                    <a:field name="bp_id"/>
                    <a:field name="bank_full_name" lovHeight="500" lovService="basic.csh_bank_for_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="bank_id" to="bank_id"/>
                            <a:map from="bank_full_name" to="bank_full_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bank_branch_name" lovGridHeight="350" lovHeight="510" lovLabelWidth="90" lovService="tre.tre501.tre501_bank_branch_name_lov" lovWidth="580" title="HLS.BANK_BRANCH_NAME">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id"/>
                            <a:map from="bp_name" to="bank_branch_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="currency"/>
                    <a:field name="currency_name" lovAutoQuery="true" lovGridHeight="250" lovHeight="400" lovService="gld.gld_currency_lov" lovWidth="600">
                        <a:mapping>
                            <a:map from="currency_name" to="currency_name"/>
                            <a:map from="currency_code" to="currency"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="bank_credit_contract_ds" autoPageSize="true" autoQuery="true" model="tre.tre501.tre_bank_credit_contract" queryDataSet="bank_credit_contract_query_ds" selectable="true" selectionModel="single" submitUrl="${/request/@context_path}/modules/tre/tre501/tre_credit_contract_save.lsc">
                <a:fields>
                    <a:field name="business_term_desc" displayField="code_value_name" options="TRE501_BUSINESS_TERM_ds" returnField="business_term" valueField="code_value"/>
                    <a:field name="purpose_desc" displayField="code_value_name" options="TRE501_PURPOSE_ds" returnField="purpose" valueField="code_value"/>
                    <a:field name="director_resolution_desc" displayField="code_value_name" options="TRE501_DIRECTOR_RESOLUTION_ds" returnField="director_resolution" valueField="code_value"/>
                    <a:field name="credit_limit_category_desc" displayField="code_value_name" options="credit_category_ds" returnField="credit_limit_category" valueField="code_value"/>
                    <a:field name="credit_class_desc" displayField="code_value_name" options="credit_class_ds" returnField="credit_class" valueField="code_value"/>
                    <a:field name="credit_limit_type_desc" displayField="code_value_name" options="credit_limit_type_ds" required="true" returnField="credit_limit_type" valueField="code_value"/>
                    <a:field name="bp_id"/>
                    <a:field name="bp_id_desc" lovGridHeight="350" lovHeight="510" lovLabelWidth="90" lovService="basic.hls_bp_master_v_all_lov?bp_category=FUNDS_SIDE" lovWidth="580" title="融资对象">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id"/>
                            <a:map from="bp_name" to="bp_id_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bank_branch_name" lovGridHeight="350" lovHeight="510" lovLabelWidth="90" lovService="tre.tre501.tre501_bank_branch_name_lov" lovWidth="580" title="HLS.BANK_BRANCH_NAME">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id"/>
                            <a:map from="bp_name" to="bank_branch_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="currency_name" lovAutoQuery="true" lovGridHeight="250" lovHeight="400" lovService="gld.gld_currency_lov" lovWidth="600">
                        <a:mapping>
                            <a:map from="currency_name" to="currency_name"/>
                            <a:map from="currency_code" to="currency"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="credit_amount" required="true"/>
                    <a:field name="available_amount"/>
                    <a:field name="credit_date_from" required="true" validator="dateValidator"/>
                    <a:field name="credit_date_to" required="true" validator="dateValidator"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="on_bank_credit_contract_update"/>
                    <a:event name="submitsuccess" handler="on_bank_credit_contract_submitsuccess"/>
                    <a:event name="submitfailed" handler="on_bank_credit_contract_submitfailed"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="tre501_manage_add" text="HLS.NEW"/>
                <a:gridButton click="tre501_manage_save" text="HLS.SAVE"/>
                <a:gridButton click="tre501_manage_clear" text="HLS.CLEAR"/>
                <a:gridButton click="tre501_manage_query" text="HLS.QUERY"/>
                <a:gridButton click="tre501_manage_reset" text="重置"/>
                <a:gridButton click="tre501_manage_excel" text="导出"/>
                <!-- <a:gridButton click="tre501_manage_query" text="HLS.QUERY"/>
                <a:gridButton click="tre501_manage_add" text="HLS.NEW"/>
                <a:gridButton click="tre501_manage_clear" text="HLS.CLEAR"/>
                <a:gridButton click="tre501_manage_save" text="HLS.SAVE"/> -->
                <!-- <a:gridButton text="TRE501.RESET_CREDIT"/> -->
            </a:screenTopToolbar>
            <a:form column="2" labelWidth="150" marginWidth="100" title="HLS.QUERY_TITLE">
                <!-- <a:comboBox name="credit_class_desc" bindTarget="bank_credit_contract_query_ds" prompt="授信种类"/> -->
                <a:comboBox name="credit_limit_type_desc" bindTarget="bank_credit_contract_query_ds" prompt="授信额度类型"/>
                <!-- <a:lov name="bank_full_name" bindTarget="bank_credit_contract_query_ds" prompt="授信总行"/> -->
                <!-- <a:lov name="bank_branch_name" bindTarget="bank_credit_contract_query_ds" prompt="借款机构"/> -->
                <a:textField name="credit_contract_number" bindTarget="bank_credit_contract_query_ds" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CREDIT_CONTRACT_NUMBER"/>
                <!-- <a:lov name="currency_name" bindTarget="bank_credit_contract_query_ds" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CURRENCY"/> -->
                <a:datePicker name="credit_date_from" bindTarget="bank_credit_contract_query_ds" prompt="授信期限从"/>
                <a:datePicker name="credit_date_to" bindTarget="bank_credit_contract_query_ds" prompt="授信期限到"/>
            </a:form>
            <a:grid id="bccd_grid" bindTarget="bank_credit_contract_ds" marginHeight="200" marginWidth="100" navBar="true">
                <a:columns>
                    <!-- <a:column name="credit_limit_category_desc" editor="bccd_grid_cb" prompt="授信类别"/> -->
                    <!-- <a:column name="credit_class_desc" editor="bccd_grid_cb" prompt="授信类型"/> -->
                    <a:column name="credit_limit_type_desc" editor="bccd_grid_cb" prompt="授信额度类型"/>
                    <a:column name="bp_id_desc" editor="bccd_grid_lov" prompt="融资对象" width="200"/>
                    <!-- <a:column name="bank_full_name" prompt="授信总行" width="120"/> -->
                    <!-- <a:column name="bank_branch_name" editor="bccd_grid_lov" prompt="借款机构" width="150"/> -->
                    <a:column name="credit_contract_number" editor="bccd_grid_tf" prompt="授信合同号"/>
                    <a:column name="credit_amount" align="right" editor="bccd_grid_nf" prompt="授信额度" renderer="Leaf.formatMoney"/>
                    <a:column name="available_amount" align="right" prompt="可用额度" renderer="Leaf.formatMoney"/>
                    <a:column align="center" forExport="false" prompt="明细" renderer="viewDetails"/>
                    <!-- <a:column name="currency_name" editor="bccd_grid_lov" prompt="TRE501.TRE_BANK_CREDIT_CONTRACT.CURRENCY"/> -->
                    <a:column name="credit_date_from" editor="bccd_grid_dp" prompt="授信期限从" renderer="Leaf.formatDate"/>
                    <a:column name="credit_date_to" editor="bccd_grid_dp" prompt="授信期限到" renderer="Leaf.formatDate"/>
                    <!-- <a:column name="business_term_desc" align="center" editor="bccd_grid_cb" prompt="业务期限" width="100"/> -->
                    <!-- <a:column name="purpose_desc" align="center" editor="bccd_grid_cb" prompt="用途" width="100"/> -->
                    <!-- <a:column name="director_resolution_desc" editor="bccd_grid_cb" prompt="董事会决议是否出具决议" width="170"/> -->
                    <a:column name="notes" editor="bccd_grid_tf" prompt="备注" width="200"/>
                </a:columns>
                <a:editors>
                    <a:comboBox id="bccd_grid_cb"/>
                    <a:lov id="bccd_grid_lov"/>
                    <a:textField id="bccd_grid_tf"/>
                    <a:numberField id="bccd_grid_nf" allowFormat="true" allowNegative="false"/>
                    <a:datePicker id="bccd_grid_dp"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>