csh_payment_update0202.lview 23.1 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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm  
    $Date: 2013-8-29 下午5:42:15  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <!-- <a:model-query autoCount="false" defaultWhereClause=" contract_id=${/parameter/@contract_id}" fetchAll="true" model="csh.CSH501.csh_payment_req_selected" rootPath="payment_req_selected"/> -->
        <a:model-query autoCount="false" defaultWhereClause=" document_category=&apos;PAYMENT_REQ&apos; and  enabled_flag=&apos;Y&apos;" fetchAll="true" model="hls.HLS003.hls_document_type" rootPath="payment_document_type"/>
        <a:model-query autoCount="false" defaultWhereClause=" enabled_flag=&apos;Y&apos;" fetchAll="true" model="gld.gld_exchangerate_types" rootPath="exchangerate_types"/>
        <a:model-query autoCount="false" fetchAll="true" model="csh.CSH501.csh_payment_req_ln_query" rootPath="csh_payment_req_ln_query" trace="true"/>
    </a:init-procedure>
    <a:view>
        <div/>
        <a:link id="csh_payment_req_create" url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_update.lsc"/>
        <a:link id="csh_payment_req_selected" url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_selected.lview"/>
        <a:link id="csh_payment_req_amount_check" model="csh.CSH501.csh_payment_req_amount_check" modelaction="execute"/>
        <a:link id="csh_payment_req_ln_del_link" model="csh.CSH504.csh_payment_req_ln_del" modelaction="batch_update"/>
        <a:link id="csh_req_ddct_link" url="${/request/@context_path}/modules/csh/CSH504/csh_payment_req_ln_ddct.lview"/>
        <script type="text/javascript"><![CDATA[
            function onUpdate_payment_req_hd(dataSet, record, name, value, oldValue) {
                var line_ds = $('csh_payment_req_ln_ds');
                var lineRecords = line_ds.getAll();
                if (name == 'apply_pay_date') {
            
                    for (var i = 0;i < lineRecords.length;i++) {
                        lineRecords[i].set('apply_pay_date', value);
                    }
                } else if (name == 'bp_id') {
                    for (var j = 0;j < lineRecords.length;j++) {
                        lineRecords[j].set('bp_code', record.get('bp_code'));
                        lineRecords[j].set('bp_name', record.get('bp_name'));
                        lineRecords[j].set('bp_id', record.get('bp_id'));
                    }
            
                }
            }
            
            function onUpdate_payment_req_ln(dataSet, record, name, value, oldValue) {
            
                var header_ds = $('csh_payment_req_create_ds');
                var line_ds = $('csh_payment_req_ln_ds');
                var lineRecords = line_ds.getAll();
                var hrecord = header_ds.getAt(0);
                var currency_code;
            
                if (name == 'amount') {
                    var amount = 0;
                    for (var i = 0;i < lineRecords.length;i++) {
                        var lineRecord = lineRecords[i];
                        currency_code = lineRecord.get('currency_code');
                        if (record.get('currency_code') != currency_code) {
                            hrecord.set('amount', null);
                            hrecord.set('currency_code', null);
                            return;
                        } else {
                            current_amount = lineRecord.get('amount');
                            if (current_amount == 'NAN' || current_amount == 'undefined' || current_amount == null || current_amount == '') {
                                current_amount = 0;
                            }
                            amount = amount + current_amount;
                        }
                    }
                    hrecord.set('amount', amount);
                    hrecord.set('currency_code', currency_code);
            
                }
            }
            
            function csh501_payment_create() {
                if ($('csh_payment_req_create_ds').validate() && $('csh_payment_req_ln_ds').validate()) {
                    var headerds = $('csh_payment_req_create_ds');
                    var hrecord = headerds.getAt(0);
                    var headRecordData = hrecord.data;
                    var lineds = $('csh_payment_req_ln_ds');
                    var lrecord = lineds.getAll();
                    var datas = [];
                    for (var i = 0;i < lrecord.length;i++) {
                        var data = lrecord[i].data;
                        datas.push(data);
                    }
                    var req_date = hrecord.get('req_date');
                    req_date = Leaf.formatDate(req_date);
                    var queryParams = new Object();
                    queryParams['details'] = datas;
                    queryParams['document_type'] = hrecord.get('document_type');
                    queryParams['req_date'] = req_date;
                    queryParams['apply_pay_date'] = hrecord.get('apply_pay_date');
                    queryParams['amount'] = hrecord.get('amount');
                    queryParams['currency_code'] = hrecord.get('currency_code');
                    queryParams['description'] = hrecord.get('description');
                    queryParams['bp_id'] = hrecord.get('bp_id');
                    queryParams['bp_category'] = hrecord.get('bp_category');
                    queryParams['payment_req_id'] = '${/parameter/@payment_req_id}';
                    Leaf.Masker.mask(Ext.getBody(), '${l:HLS.SAVING}');
                    Leaf.request({
                        url: $('csh_payment_req_create').getUrl(),
                        para: queryParams,
                        success: function(args) { //
            
                            Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            Leaf.Masker.unmask(Ext.getBody());
                            //$('${/parameter/@winId}').close();
            
                        },
                        failure: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                    //headerds.submit();
                }
            }
            
            function csh501_payment_back() {
                $('${/parameter/@winId}').close();
            }
            
            function csh501_payment_reset() {
                $('csh_payment_req_create_ds').getAt(0).set('document_type', '');
            
            }
            
            function csh501_payment_submit() {
            
                var ds = $('csh_payment_req_create_ds');
                var record = $('csh_payment_req_create_ds').getAt(0);
            
                if (ds.validate()) {
                    /* var saveData = [];
                     record.set('_status', 'update');
                     saveData.push(record.data); */
                    var queryParams = new Object();
                    Leaf.Masker.mask(Ext.getBody(), '${l:HLS.SAVING}');
            
                    Leaf.showConfirm('提示', '确定提交?', function okFun() {
                        Leaf.request({
                            url: '${/request/@context_path}/autocrud/csh.CSH501.upd_csh_payment_sub_flag/execute',
                            para: {
                                payment_req_id: record.get('payment_req_id'),
                                _status: 'execute'
                            },
                            success: function(res) {
                                Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                //window.location.href = $('csh_payment_update_link').getUrl();
                                //window.location.href = $('csh_payment_req_selected').getUrl();
                                $('${/parameter/@winId}').close();
                                $('csh_payment_req_queryDs').query();
                            },
                            failure: function() {
                                Leaf.Masker.unmask(Ext.getBody());
                            },
                            error: function() {
                                Leaf.Masker.unmask(Ext.getBody());
                            },
                            scope: this
                        }, Leaf.Masker.unmask(Ext.getBody()));
                    });
            
                }
            }
            
            function csh501_payment_delete() {
                var Array = $('csh_payment_req_ln_ds').getSelected();
                if (Array.length < 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:CHOOSE_ONE_RECORD}');
                }
                var param = $('csh_payment_req_ln_ds').getJsonData(true);
                //
                Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.DELETE_CONFIRM}', function okFun() {
                    Leaf.request({
                        url: $('csh_payment_req_ln_del_link').getUrl(),
                        para: param,
                        success: function() {
                            $('csh_payment_req_ln_ds').query();
                        },
                        scope: this
                    });
                });
            }
            
            function csh504_ddct_link(value, record, name) {
                if (!record.isNew) {
                    return '<a href="javascript:csh504_open_ddct_link(\'' + record.id + '\',\'' + record.ds.id + '\')">' + '抵扣' + '</a>';
                }
            }
            
            function csh504_open_ddct_link(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var payment_req_ln_id = record.get('payment_req_ln_id');
                var apply_amount = record.get('amount');
                var contract_number = record.get('contract_number');
                var contract_id = record.get('contract_id');
                var win = new Leaf.Window({
                    id: 'prj_project_bp_parameter_window',
                    url: $('csh_req_ddct_link').getUrl(),
                    params: {
                        apply_amount: apply_amount,
                        payment_req_ln_id: payment_req_ln_id,
                        contract_number: contract_number,
                        contract_id: contract_id
                    },
                    title: '抵扣',
                    fullScreen: true
                });
                win.on('close', function() {
                    $('csh_payment_req_ln_ds').query();
                });
            }
            
            //付款申请打印
            
            
            function csh501_payment_print() {
                var records_l = $('csh_payment_req_ln_ds').getAll();
                if (records_l.length > 0) {
                    var ds = $('csh_payment_req_create_ds');
                    var record = $('csh_payment_req_create_ds').getAt(0);
                    var url_1 = 'http://199.10.10.65:8180/reportapp/frameset?__report=reports/req/' + 'con_payment_req.rptdesign' + '&&__format=pdf';
                    var url_1_param = '&&payment_req_id=' + record.get('payment_req_id');
                    window.open(url_1 + url_1_param);
                }
            
            }
            
            function csh504_act_amount(value, record, name) {
                var amount = record.get('amount');
                var sum_ddct_amount = record.get('sum_ddct_amount');
                if (!sum_ddct_amount) {
                    sum_ddct_amount = 0;
                }
                var act_amount = amount - sum_ddct_amount;
                return Leaf.formatMoney(act_amount);
            }
            function csh504_trx_lov_fun(lov){
                var record = this.record;
                record.getField(lov.binder.name).setLovPara('bp_id',record.get('bp_id'));
            }
        ]]></script>
        <a:dataSets>
            <!-- <a:dataSet id="csh_payment_req_ds" selectable="true">
                <a:datas dataSource="/model/payment_req_selected"/>
            </a:dataSet> -->
            <a:dataSet id="document_type_ds">
                <a:datas dataSource="/model/payment_document_type"/>
            </a:dataSet>
            <a:dataSet id="exchangerate_types_ds">
                <a:datas dataSource="/model/exchangerate_types"/>
            </a:dataSet>
            <a:dataSet id="csh_payment_req_create_ds" loadData="true" model="csh.CSH504.csh_payment_req_hd_upd_query" submitUrl="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_update.lsc">
                <a:fields>
                    <!-- <a:field name="tenant_bp_id" defaultValue="${/model/payment_req_selected/record/@tenant_bp_id}"/> -->
                    <a:field name="document_type_dis" displayField="description" options="document_type_ds" required="true" returnField="document_type" valueField="document_type"/>
                    <!-- <a:field name="document_type" displayField="rate_method_code_display" options="exchangerate_types_ds" returnField="rate_method_code" valueField="rate_method_code"/> -->
                    <a:field name="bp_code" lovGridHeight="300" lovHeight="500" lovLabelWidth="100" lovService="basic.hls_bp_master_v_for_lov" lovWidth="530" required="true" title="付款对象">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code"/>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_id" to="bp_id"/>
                            <a:map from="bp_category" to="bp_category"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_name" readOnly="true"/>
                    <a:field name="amount" readOnly="true"/>
                    <a:field name="currency_code" readOnly="true"/>
                    <a:field name="req_date" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate_payment_req_hd"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="csh_payment_req_ln_ds" autoQuery="true" bindName="sub" bindTarget="csh_payment_req_create_ds" model="csh.CSH504.csh_payment_req_ln_upd_query" queryUrl="${/request/@context_path}/autocrud/csh.CSH504.csh_payment_req_ln_upd_query/query?payment_req_id=${/parameter/@payment_req_id}" selectable="true">
                <!-- <a:datas dataSource="/model/csh_payment_req_ln_query"/> -->
                <a:fields>
                    <a:field name="residual_amount"/>
                    <a:field name="apply_pay_date" required="true"/>
                    <a:field name="due_date"/>
                    <a:field name="amount" required="true"/>
                    <a:field name="bp_code" lovGridHeight="300" lovHeight="500" lovLabelWidth="100" lovService="basic.hls_bp_master_v_for_lov" lovWidth="530" required="true" title="付款对象">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code"/>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_id" to="bp_id"/>
                            <a:map from="bp_category" to="bp_category"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="prepayment_trx" lovGridHeight="280" lovHeight="500" lovService="csh.CSH504.csh_prepayment_transaction" lovWidth="500">
                        <a:mapping>
                            <a:map from="transaction_id" to="prepayment_trx_id"/>
                            <a:map from="transaction_num" to="prepayment_trx"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_bank_account_code" autoComplete="true" autoCompleteField="bank_account_num" lovGridHeight="350" lovHeight="550" lovLabelWidth="90" lovService="basic.hls_bp_master_bank_account_v_for_lov?enabled_flag=Y&amp;bp_enabled_flag=Y" lovWidth="580" title="CSH511.BANK_ACCOUNT_CODE">
                        <a:mapping>
                            <a:map from="bank_account_id" to="bp_bank_account_id"/>
                            <a:map from="bank_account_num" to="bp_bank_account_num"/>
                            <a:map from="bank_account_name" to="bp_bank_account_name"/>
                            <a:map from="bank_account_code" to="bp_bank_account_code"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate_payment_req_ln"/>
                    <!-- <a:event name="submitsuccess" handler="onUpdate_payment_req_success"/> -->
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="csh501_payment_create" text="HLS.SAVE"/>
                <a:gridButton click="csh501_payment_submit" text="CSH501.CSH_REQ_POST"/>
                <a:gridButton click="csh501_payment_delete" text="HLS.REMOVE"/>
                <a:gridButton click="csh501_payment_reset" text="HLS.RESET"/>
                <a:gridButton click="csh501_payment_back" text="HLS.BACK"/>
                <a:gridButton click="csh501_payment_print" text="付款申请打印"/>
            </a:screenTopToolbar>
            <a:form title="CSH501.CSH_REQ_MAINTAIN" width="1250">
                <a:box column="4" labelWidth="120">
                    <a:datePicker name="req_date" bindTarget="csh_payment_req_create_ds" prompt="CSH501.CSH_REQ_DATE" width="150"/>
                    <!-- <a:datePicker name="apply_pay_date" bindTarget="csh_payment_req_create_ds" prompt="CSH501.CSH_REQ_PAY_DATE" width="150"/> -->
                    <a:comboBox name="document_type_dis" bindTarget="csh_payment_req_create_ds" prompt="CSH501.CSH_REQ_TYPE" typeCase="upper" width="150"/>
                    <a:lov name="bp_code" bindTarget="csh_payment_req_create_ds" prompt="CSH501.CSH_PAYMENT_OBJ" width="150">
                        <a:events>
                            <a:event name="focus" handler="function(object){on_std_focus(object,&apos;BP&apos;)}"/>
                        </a:events>
                    </a:lov>
                    <a:textField name="bp_name" bindTarget="csh_payment_req_create_ds" prompt="CSH501.CSH_PAYMENT_OBJ_NAME" width="150"/>
                </a:box>
                <a:box column="4" labelWidth="120">
                    <a:numberField name="amount" bindTarget="csh_payment_req_create_ds" prompt="CSH501.CSH_PAYMENT_AMOUNT" renderer="Leaf.formatMoney" typeCase="upper" width="150"/>
                    <a:textField name="currency_code" bindTarget="csh_payment_req_create_ds" prompt="HLS.CURRENCY" width="150"/>
                    <a:textField name="description" bindTarget="csh_payment_req_create_ds" prompt="HLS.COMMENT" width="428"/>
                </a:box>
            </a:form>
            <a:grid id="csh_payment_req_create_grid_ds" bindTarget="csh_payment_req_ln_ds" marginHeight="220" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="contract_number" lock="true" prompt="HLS.CONTRACT_NUMBER" width="100"/>
                    <a:column name="contract_name" lock="true" prompt="HLS.CONTRACT_NAME" width="150"/>
                    <a:column name="bp_code" editor="create_grid_bp_lov" prompt="CSH501.CSH_PAYMENT_OBJ"/>
                    <a:column name="bp_name" prompt="CSH501.CSH_PAYMENT_OBJ_NAME" width="150"/>
                    <a:column name="amount" align="right" editor="numberField" prompt="CSH501.CSH_REQ_AMOUNT" renderer="Leaf.formatMoney"/>
                    <a:column name="prepayment_trx" editor="csh504_tr_lov" prompt="预付款"/>
                    <a:column name="ddct_link" align="center" prompt="CSH710.DEDUCTION_AMOUNT" renderer="csh504_ddct_link"/>
                    <a:column name="sum_ddct_amount" align="right" prompt="抵扣总额" renderer="Leaf.formatMoney"/>
                    <a:column name="act_amount" align="right" prompt="实际申请金额" renderer="csh504_act_amount"/>
                    <a:column name="apply_pay_date" editor="datepicker" prompt="CSH501.CSH_REQ_PAY_DATE" renderer="Leaf.formatDate"/>
                    <a:column name="bp_bank_account_code" editor="csh504_tr_lov" prompt="CSH511.BP_BANK_ACCOUNT_CODE"/>
                    <a:column name="project_name" prompt="HLS.PROJECT_NAME" width="150"/>
                    <a:column name="bp_tenant_name" prompt="HLS.TENANT_NAME" width="150"/>
                    <a:column name="cf_description" prompt="CSH501.CSH_PAYMENT_PRJ" width="150"/>
                    <a:column name="due_amount" prompt="CSH501.CSH_PAYMENT_AMOUNT" renderer="Leaf.formatMoney"/>
                    <a:column name="currency_code" prompt="HLS.CURRENCY"/>
                    <a:column name="due_date" prompt="CSH501.CSH_DUE_DATE" renderer="Leaf.formatDate"/>
                    <a:column name="residual_amount" align="right" prompt="CSH501.CSH_RESIDUAL_AMOUNT" renderer="Leaf.formatMoney"/>
                </a:columns>
                <a:editors>
                    <a:datePicker id="datepicker"/>
                    <a:numberField id="numberField" allowFormat="true" allowNegative="false" decimalPrecision="2"/>
                    <a:lov id="create_grid_bp_lov">
                        <a:events>
                            <a:event name="focus" handler="function(object){on_std_focus(object,&apos;BP&apos;)}"/>
                        </a:events>
                    </a:lov>
                    <a:lov id="csh504_tr_lov">
                        <a:events>
                            <a:event name="focus" handler="csh504_trx_lov_fun"/>
                        </a:events>
                    </a:lov>
                    <a:lov id="csh504_loved"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
        	var head_record = $('csh_payment_req_create_ds').getAt(0);
        	var business_type = head_record.get('business_type');
        	if (business_type == 'PREPAYMENT'){
        	   $('csh_payment_req_create_grid_ds').hideColumn('contract_number'); 
        	   $('csh_payment_req_create_grid_ds').hideColumn('contract_name'); 
        	   $('csh_payment_req_create_grid_ds').hideColumn('times');
        	   $('csh_payment_req_create_grid_ds').hideColumn('sum_ddct_amount');
        	   $('csh_payment_req_create_grid_ds').hideColumn('residual_amount');
        	   $('csh_payment_req_create_grid_ds').hideColumn('project_name');
        	   $('csh_payment_req_create_grid_ds').hideColumn('bp_tenant_name');
        	   $('csh_payment_req_create_grid_ds').hideColumn('cf_description');
        	   $('csh_payment_req_create_grid_ds').hideColumn('due_amount');
        	   $('csh_payment_req_create_grid_ds').hideColumn('due_date');
        	   $('csh_payment_req_create_grid_ds').hideColumn('prepayment_trx');
        	   
        	}
        ]]></script>
    </a:view>
</a:screen>