csh_write_off_interface.lview 65.9 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8
<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="basic.get_sys_default_time" rootPath="sys_default_time"/>
        <a:model-query fetchAll="true" model="csh.CSH531N.csh_transaction" rootPath="csh_transaction_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="csh531n_csh_confirm_data_link" model="csh.CSH531N.csh_data_confirm" modelaction="update"/>
Darming's avatar
Darming committed
9
        <a:link id="csh531n_submit_link_id" model="csh.CSH531N.csh_data_confirm" modelaction="execute"/>
Spencer Chang's avatar
Spencer Chang committed
10
        <a:link id="transaction_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
高泉铭's avatar
高泉铭 committed
11
        <a:link id="transaction_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
niminmin's avatar
niminmin committed
12 13
        <a:link id="csh531n_submit_interface_link_id" model="csh.CSH531N.csh_write_off_interface"
                modelaction="batch_update"/>
Spencer Chang's avatar
Spencer Chang committed
14 15
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
        <script type="text/javascript"><![CDATA[
16

Spencer Chang's avatar
Spencer Chang committed
17 18 19 20 21 22 23 24 25 26 27 28 29
        function csh531n_detail_win_close() {
            $('${/parameter/@winid}').close();
        }

        function csh531d_lock_current_window() {
            Leaf.Masker.mask($('${/parameter/@winid}').wrap, '${l:HLS.EXECUTING}');
        }

        function csh531d_unlock_current_window() {
            Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
        }

        function init() {
Darming's avatar
Darming committed
30

高泉铭's avatar
高泉铭 committed
31

niminmin's avatar
niminmin committed
32
            if ('${/parameter/@collection_classes}' == 'COMBINED' && '${/parameter/@transaction_type}' !== 'DEPOSIT') {
高泉铭's avatar
高泉铭 committed
33
                document.getElementById('write_off_deposit').style.display = 'block';
高泉铭's avatar
高泉铭 committed
34
            }
Darming's avatar
Darming committed
35 36 37
            if ('${/parameter/@advanceDisplayFlag}' == 'Y') {
                document.getElementById('write_off_advance').style.display = 'block';
            }
Darming's avatar
Darming committed
38

高泉铭's avatar
高泉铭 committed
39
            if ('${/parameter/@readOnly}' == 'Y') {
Spencer Chang's avatar
Spencer Chang committed
40 41
                $('csh_grid_add_bt').setVisible(false);
                $('csh_grid_delete_bt').setVisible(false);
niminmin's avatar
niminmin committed
42 43
                $('csh_grid_deposit_add_bt').setVisible(false);
                $('csh_grid_deposit_delete_bt').setVisible(false);
Spencer Chang's avatar
Spencer Chang committed
44 45 46
                $('csh_write_off_grid').hideColumn('left_amount');
                $('csh_write_off_grid').hideColumn('left_principal');
                $('csh_write_off_grid').hideColumn('left_interest');
高泉铭's avatar
高泉铭 committed
47
                $('csh_write_off_grid').hideColumn('unreceived_amount');
Darming's avatar
Darming committed
48
                if ('${/parameter/@interfaceQueryFlag}' == 'N') {
49
                    $('csh_write_off_interface_ds').setQueryUrl('${/request/@context_path}/autocrud/csh.CSH531N.csh_write_off/query?transaction_id=${/parameter/@transaction_id}&transaction_date=${/parameter/@transaction_date}');
Darming's avatar
Darming committed
50 51
                    $('csh_write_off_interface_ds').query();
                }
Darming's avatar
Darming committed
52 53 54
                if ('${/parameter/@approval_flag}' == 'Y') {
                    $('csh531n_write_off_btn_id').setVisible(true);
                    $('csh531n_write_off_return_btn_id').setVisible(true);
Darming's avatar
Darming committed
55
                }
Darming's avatar
Darming committed
56 57 58
            } else {
                // $('csh511_save_all_id').setVisible(true);
                $('csh531n_write_off_submit_btn_id').setVisible(true);
Spencer Chang's avatar
Spencer Chang committed
59
            }
高泉铭's avatar
高泉铭 committed
60

Spencer Chang's avatar
Spencer Chang committed
61 62 63 64 65 66 67 68 69 70
        }

        // function csh_write_off_add(){
        //     var record = $('csh_write_off_interface_ds').create();
        //     record.set('csh_bank_slip_num','${/parameter/@csh_bank_slip_num}');
        //     $('csh_write_off_grid').showEditorByRecord(record);
        // }

        function csh_edit_function(record, name) {
            var batch_status = '${/parameter/@batch_status}';
高泉铭's avatar
高泉铭 committed
71
            var readOnly = '${/parameter/@readOnly}';
Spencer Chang's avatar
Spencer Chang committed
72
            var write_off_type = record.get('write_off_type');
高泉铭's avatar
高泉铭 committed
73
            if (batch_status == 'SUBMIT' || readOnly == 'Y') {
niminmin's avatar
niminmin committed
74

Spencer Chang's avatar
Spencer Chang committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
            } else {
                if (name == 'contract_number') {
                    if (write_off_type != 'DEPOSIT_POOL_CREDIT') {
                        return 'csh_write_off_grid_lv';
                    }

                }
                if (name == 'write_off_type_desc') {
                    return 'csh_write_off_grid_cb';
                }
                // if (name == 'write_off_bp_name') {
                //     return 'csh_write_off_grid_lv';
                // }
                if (name == 'write_off_times') {
                    if (write_off_type == 'RECEIPT_CREDIT') {
                        return 'csh_write_off_grid_lv';
                    }
                }
高泉铭's avatar
高泉铭 committed
93
                if (name == 'write_off_amount' || name == 'write_off_principal' || name == 'write_off_interest' || name == 'write_off_penalty') {
Spencer Chang's avatar
Spencer Chang committed
94 95 96
                    return 'csh_write_off_grid_nf';
                }
                if (name == 'write_off_date' || name == 'journal_date') {
97
                    if (write_off_type == 'RECEIPT_CREDIT' || write_off_type == 'DEPOSIT_CREDIT') {
Darming's avatar
Darming committed
98 99
                        return 'csh_write_off_grid_dp';
                    }
Darming's avatar
Darming committed
100
                    if (write_off_type == 'RECEIPT_ADVANCE_RECEIPT') {
Darming's avatar
Darming committed
101
                        if (record.get('create_wf_flag') == 'Y') {
Darming's avatar
Darming committed
102 103
                            return;
                        }
Darming's avatar
Darming committed
104 105
                        return 'csh_transaction_advanced_grid_dp';
                    }
Darming's avatar
Darming committed
106
                    if (write_off_type == 'RECEIPT_DEPOSIT_POOL') {
Darming's avatar
Darming committed
107 108
                        return 'csh_transaction_deposit_grid_dp';
                    }
Spencer Chang's avatar
Spencer Chang committed
109 110 111 112 113 114 115 116 117
                }
                if (name == 'agent_id_desc') {
                    if (write_off_type == 'DEPOSIT_POOL_CREDIT') {
                        return 'csh_write_off_grid_lv';
                    }
                }
                if (name == 'write_off_classification_desc') {
                    return 'csh_write_off_grid_cb';
                }
niminmin's avatar
niminmin committed
118

Spencer Chang's avatar
Spencer Chang committed
119 120 121 122 123 124 125
            }
        }

        function summaryRenderer(datas, name) {
            var sum = 0;
            var sum_2 = 0;
            for (var i = 0; i < datas.length; i++) {
Darming's avatar
Darming committed
126
                var record = datas[i];
Spencer Chang's avatar
Spencer Chang committed
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
                if (name == "write_off_amount") {
                    var t_1 = record.get("write_off_amount");
                    var t_2 = parseFloat(t_1);
                    if (!isNaN(t_2)) {
                        sum += t_2;
                    }
                }
                if (name == "unreceived_amount") {
                    var n_1 = record.get("unreceived_amount");
                    var n_2 = parseFloat(n_1);
                    if (!isNaN(n_2)) {
                        sum_2 += n_2;
                    }
                }
            }
            if (name == "csh_bank_slip_num") {
                return '<div align="right">合计:</div>';
            }
            if (name == "unreceived_amount") {
                return '<font color="red">' + Leaf.formatNumber(sum_2, 2) + '</font>';
            }
            if (name == "write_off_amount") {
                return '<font color="red">' + Leaf.formatNumber(sum, 2) + '</font>';
            }
        }

        function csh531_update_fun(ds, record, name, value, oldValue) {
            if (name == 'write_off_amount') {
niminmin's avatar
niminmin committed
155
                if (!checkAmount()) {
Darming's avatar
Darming committed
156 157 158 159 160 161 162 163
                    setTimeout(function () {//防止递归
                        record.set(name, oldValue);
                    });
                }

                var h_record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
                csh531_load_fun(ds);

Spencer Chang's avatar
Spencer Chang committed
164 165 166 167 168
                var left_amount = record.get('left_amount');
                var left_principal = record.get('left_principal');
                var left_interest = record.get('left_interest');
                var x_amount;
                if (value) {
169 170 171
                    if (value <= left_principal) {
                        if (left_principal > 0) {
                            record.set('write_off_principal', value);
高泉铭's avatar
高泉铭 committed
172
                        } else {
173
                            record.set('write_off_principal', null);
Spencer Chang's avatar
Spencer Chang committed
174
                        }
175 176
                        record.set('write_off_interest', null);
                    } else if (value > left_principal) {
Spencer Chang's avatar
Spencer Chang committed
177
                        if (left_principal > 0) {
178
                            record.set('write_off_principal', left_principal);
高泉铭's avatar
高泉铭 committed
179
                        } else {
Spencer Chang's avatar
Spencer Chang committed
180 181
                            record.set('write_off_principal', null);
                        }
niminmin's avatar
niminmin committed
182
                        x_amount = minus(value, left_principal);
183 184 185 186 187
                        if (left_interest > 0) {
                            record.set('write_off_interest', x_amount);
                        } else {
                            record.set('write_off_interest', null);
                        }
Spencer Chang's avatar
Spencer Chang committed
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
                    }
                } else {
                    record.set('write_off_interest', null);
                    record.set('write_off_principal', null);
                }
            }
            if (name == 'write_off_type') {
                if (value != oldValue) {
                    //收款核销
                    if (value == 'RECEIPT_CREDIT') {
                        record.getField('contract_number').setRequired(true);

                        record.getField('write_off_times').setReadOnly(false);
                        record.getField('write_off_times').setRequired(true);

                    } else {
                        record.getField('write_off_times').setRequired(false);
                        record.getField('write_off_times').setReadOnly(true);
                    }
                    //收款核销预收款
                    if (value == 'RECEIPT_ADVANCE_RECEIPT') {
                        record.getField('contract_number').setRequired(true);

                        record.set('agent_id_desc', '');
                        record.set('agent_id', '');
                        record.set('write_off_times', '');
                        record.set('write_off_cf_item', '');
                        record.set('write_off_cf_item_desc', '');
                        record.set('write_off_cashflow_id', '');
                        record.set('due_date', '');

                        record.set('write_off_principal', '');
                        record.set('write_off_interest', '');
                        record.set('left_amount', '');
                        record.set('left_principal', '');
                        record.set('left_interest', '');
                    }
                    //核销为保证金池
                    if (value == 'DEPOSIT_POOL_CREDIT') {
                        record.getField('contract_number').setRequired(false);

                        record.getField('agent_id_desc').setReadOnly(false);
                        record.getField('agent_id_desc').setRequired(true);

                        record.set('contract_number', '');
                        record.set('contract_name', '');
                        record.set('contract_id', '');
                        record.set('write_off_bp_id', '');
                        record.set('write_off_bp_name', '');

                        record.set('write_off_times', '');
                        record.set('write_off_cf_item', '');
                        record.set('write_off_cf_item_desc', '');
                        record.set('write_off_cashflow_id', '');
                        record.set('due_date', '');

                        record.set('write_off_principal', '');
                        record.set('write_off_interest', '');
                        record.set('left_amount', '');
                        record.set('left_principal', '');
                        record.set('left_interest', '');
                    } else {
                        record.getField('agent_id_desc').setRequired(false);
                        record.getField('agent_id_desc').setReadOnly(true);
                    }
                    if (value == 'RECEIPT_NONBUSINESS') {
                        record.getField('contract_number').setReadOnly(true);
                        record.getField('contract_number').setRequired(false);
                        record.getField('write_off_times').setRequired(false);
                        record.getField('write_off_times').setReadOnly(true);

                        record.set('contract_number', '');
                        record.set('contract_name', '');
                        record.set('contract_id', '');
                        record.set('write_off_bp_id', '');
                        record.set('write_off_bp_name', '');


                    }
                }
            }
            if (name == 'contract_id') {
                record.getField('write_off_times').setLovPara('contract_id', value);
                record.set('write_off_times', '');
                record.set('write_off_cf_item', '');
                record.set('write_off_cf_item_desc', '');
                record.set('write_off_cashflow_id', '');
                record.set('due_date', '');
                record.set('write_off_principal', '');
                record.set('write_off_interest', '');
                record.set('left_amount', '');
                record.set('left_principal', '');
                record.set('left_interest', '');
            }
niminmin's avatar
niminmin committed
282 283
            if (name == 'wirte_off_date') {
                record.set('journal_date', value);
284
            }
Spencer Chang's avatar
Spencer Chang committed
285 286 287 288 289 290 291 292
        }

        function csh531_wf_amount_validate(record, name, value) {
            var batch_status = '${/parameter/@batch_status}';
            if (batch_status == 'SUBMIT') {
                return true;
            } else {
                if (record.get('write_off_type') == 'RECEIPT_CREDIT') {
高泉铭's avatar
高泉铭 committed
293 294
                    if (value != record.get('left_amount')) {
                        return '分配金额与剩余金额不等!';
Spencer Chang's avatar
Spencer Chang committed
295 296 297 298 299 300 301 302 303 304 305
                    }
                }
            }
            return true;
        }

        function csh531n_save() {
            $('csh_transaction_receipt_write_off_detail_ds').submit();
        }

        function csh531n_write_off() {
Darming's avatar
Darming committed
306
            $('csh531n_write_off_btn_id').disable();
307 308 309
            var returning_amount = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord().get('returning_amount') || 0;
            if (returning_amount > 0) {
                Leaf.showInfoMessage("提示", "该收款单存在审批中的退款流程,无法进行核销操作!");
Darming's avatar
Darming committed
310 311
                $('csh531n_write_off_btn_id').enable();
                return;
312 313 314 315 316
            }
            var interfaceRs = $('csh_write_off_interface_ds').getAll();
            var depositRs = $('csh_transaction_deposit_ds').getAll();
            var advancedRs = $('csh_transaction_advanced_ds').getAll();

Darming's avatar
Darming committed
317 318 319 320 321 322
            //IE浏览器不支持ES6语法

            // var allRs = [...interfaceRs, ...depositRs, ...advancedRs];

            var allRs = [];
            allRs = interfaceRs.concat(depositRs).concat(advancedRs);
323 324 325 326

            for (var i = 0; i < allRs.length; i++) {
                if (allRs[i].dirty) {
                    Leaf.showInfoMessage("提示", "存在未保存数据,请先保存再进行核销操作!");
Darming's avatar
Darming committed
327
                    $('csh531n_write_off_btn_id').enable();
328
                    return;
高泉铭's avatar
高泉铭 committed
329
                }
330
            }
高泉铭's avatar
高泉铭 committed
331

332 333 334 335 336 337 338 339 340 341 342 343 344
            if (checkAmount('WRITE_OFF')) {
                var record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
                if (record) {
                    csh531d_lock_current_window();
                    var transaction_id = record.get('transaction_id');
                    Leaf.request({
                        url: $('csh531n_csh_confirm_data_link').getUrl(),
                        para: {
                            transaction_id: '${/parameter/@transaction_id}',
                            _status: 'update'
                        },
                        success: function () {
                            csh531d_unlock_current_window();
Darming's avatar
Darming committed
345
                            $('csh531n_write_off_btn_id').enable();
346 347 348
                            csh531n_detail_win_close();
                        }, failure: function () {
                            csh531d_unlock_current_window();
Darming's avatar
Darming committed
349
                            $('csh531n_write_off_btn_id').enable();
350 351 352
                        },
                        error: function () {
                            csh531d_unlock_current_window();
Darming's avatar
Darming committed
353
                            $('csh531n_write_off_btn_id').enable();
354 355 356 357
                        },
                        scope: this
                    });
                }
Spencer Chang's avatar
Spencer Chang committed
358 359 360 361 362 363 364 365 366 367 368 369
            }
        }

        function csh531_beforesubmit_fun(ds) {
            var records = ds.getAll();
            var total = 0;
            var head_record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
            var unwrite_off_amount = head_record.get('unwrite_off_amount');
            for (var i = 0; i < records.length; i++) {
                total = plus(total, records[i].get('write_off_amount'))
            }
            if (total > unwrite_off_amount) {
高泉铭's avatar
高泉铭 committed
370
                Leaf.showMessage('${l:PROMPT}', '核销金额不能大于可核销金额!');
Spencer Chang's avatar
Spencer Chang committed
371 372 373 374 375 376 377
                return false;
            }
            return true;
        }

        function csh531_load_fun(ds) {
            var records = ds.getAll();
Darming's avatar
Darming committed
378 379 380 381 382
            var sum = 0;
            var write_off_recs = $('csh_write_off_interface_ds').getAll();
            for (var i = 0; i < write_off_recs.length; i++) {
                var t = parseFloat(write_off_recs[i].get('write_off_amount'));
                if (!isNaN(t)) {
niminmin's avatar
niminmin committed
383
                    sum = plus(sum, t);
Darming's avatar
Darming committed
384 385 386 387 388 389
                }
            }
            var deposit_recs = $('csh_transaction_deposit_ds').getAll();
            for (var i = 0; i < deposit_recs.length; i++) {
                var t = parseFloat(deposit_recs[i].get('write_off_amount'));
                if (!isNaN(t)) {
niminmin's avatar
niminmin committed
390
                    sum = plus(sum, t);
Darming's avatar
Darming committed
391
                }
Spencer Chang's avatar
Spencer Chang committed
392
            }
Darming's avatar
Darming committed
393 394 395 396
            var advanced_recs = $('csh_transaction_advanced_ds').getAll();
            for (var i = 0; i < advanced_recs.length; i++) {
                var t = parseFloat(advanced_recs[i].get('write_off_amount'));
                if (!isNaN(t)) {
niminmin's avatar
niminmin committed
397
                    sum = plus(sum, t);
Darming's avatar
Darming committed
398 399 400
                }
            }
            var h_record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
Darming's avatar
Darming committed
401
            var for_allocate_amount = 0;
niminmin's avatar
niminmin committed
402 403
            if (h_record.get('unwrite_off_amount') && h_record.get('unwrite_off_amount') > 0) {
                for_allocate_amount = minus(h_record.get('unwrite_off_amount'), sum);
Darming's avatar
Darming committed
404
            }
niminmin's avatar
niminmin committed
405
            h_record.set('for_allocate_amount', for_allocate_amount);
Spencer Chang's avatar
Spencer Chang committed
406 407
        }

Darming's avatar
Darming committed
408
        function csh531n_write_off_return() {
Darming's avatar
Darming committed
409
            var record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
Darming's avatar
Darming committed
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
            $('csh531n_write_off_return_btn_id').disable();
            Leaf.Masker.mask(Ext.getBody());
            Leaf.request({
                url: $('csh531n_submit_link_id').getUrl(),
                para: {
                    transaction_id: record.get('transaction_id'),
                    flag: 'RETURN'
                },
                success: function () {
                    Leaf.SideBar.show({
                        msg: '操作成功',
                        duration: 2000
                    });
                    Leaf.Masker.unmask(Ext.getBody());
                    $('csh531n_write_off_return_btn_id').enable();
                    $('${/parameter/@winid}').close();
                },
                error: function () {
                    Leaf.Masker.unmask(Ext.getBody());
                    $('csh531n_write_off_return_btn_id').enable();
                },
                failure: function () {
                    Leaf.Masker.unmask(Ext.getBody());
                    $('csh531n_write_off_return_btn_id').enable();
                },
                scope: this
            });
        }

Spencer Chang's avatar
Spencer Chang committed
439
        function csh531_submitsuccess(ds) {
Darming's avatar
Darming committed
440
            var record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
Darming's avatar
Darming committed
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
            Leaf.Masker.mask(Ext.getBody());
            Leaf.request({
                url: $('csh531n_submit_link_id').getUrl(),
                para: {
                    transaction_id: record.get('transaction_id'),
                    flag: 'SUBMIT'
                },
                success: function () {
                    Leaf.Masker.unmask(Ext.getBody());
                    $('csh531n_write_off_submit_btn_id').enable();
                    $('${/parameter/@winid}').close();
                },
                error: function () {
                    Leaf.Masker.unmask(Ext.getBody());
                    $('csh531n_write_off_submit_btn_id').enable();
                },
                failure: function () {
                    Leaf.Masker.unmask(Ext.getBody());
                    $('csh531n_write_off_submit_btn_id').enable();
                },
                scope: this
            });
Darming's avatar
Darming committed
463
            // $('csh531n_write_off_submit_btn_id').enable();
Darming's avatar
Darming committed
464
            // ds.query();
Spencer Chang's avatar
Spencer Chang committed
465 466
        }

467
        function csh531_submitfailed(ds) {
Darming's avatar
Darming committed
468
            $('csh531n_write_off_submit_btn_id').enable();
高泉铭's avatar
高泉铭 committed
469 470
        }

Spencer Chang's avatar
Spencer Chang committed
471 472 473 474 475 476 477 478 479 480
        function compareDate(start, end) {
            if (start > end) {
                return false;
            }
            return true;
        }

        function write_off_date_validator(record, name, value) {
            if (name == 'write_off_date') {
                if (value) {
高泉铭's avatar
高泉铭 committed
481
                    var head_record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
Spencer Chang's avatar
Spencer Chang committed
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
                    var start_date = Leaf.formatDate(value);
                    var end_date = Leaf.formatDate(new Date());//Leaf.formatDate(head_record.get('transaction_date'));

                    if (!compareDate(start_date, end_date)) {
                        return '核销基准日期不能选在当前日期之后'; //'核销基准日期不能选在收款日期之后'; //校验不通过返回字符串
                    }
                }
                return true; //校验通过返回true
            }

        }

        function attachment_upload() {
            if ('${/parameter/@transaction_id}') {
                //
Darming's avatar
Darming committed
497 498 499 500
                var ds = $('csh_transaction_receipt_write_off_detail_ds');
                var record = ds.getCurrentRecord();
                // var header_id = '${/parameter/@transaction_id}';
                var header_id = record.get('transaction_id');
niminmin's avatar
niminmin committed
501
                if (record.get('transaction_type') == 'ADVANCE_RECEIPT' || record.get('transaction_type') == 'DEPOSIT') {
Darming's avatar
Darming committed
502 503
                    header_id = record.get('source_csh_trx_id');
                }
niminmin's avatar
niminmin committed
504
                if (header_id) {
505 506 507 508 509 510 511 512 513
                    var url = $('transaction_downloadFile_id').getUrl() + '?table_name=CSH_TRANSACTION&header_id=' + header_id;
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: 'transaction_downFile_winid',
                        width: 850,
                        height: 400
                    });
                }
Darming's avatar
Darming committed
514 515 516 517 518
                // win.on('close', function () {
                //     window.location.href = $('csh_transaction_receipt_id').getUrl();
                //     // var url = $('csh_transaction_receipt_id').getUrl();
                //     // Leaf.go(url);
                // });
Spencer Chang's avatar
Spencer Chang committed
519 520
            } else {
                Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
niminmin's avatar
niminmin committed
521

Spencer Chang's avatar
Spencer Chang committed
522 523 524
            }
        }

高泉铭's avatar
高泉铭 committed
525
        function attachment_rendered() {
526
            return '<a href="javascript:attachment_upload()"><span style="color:red;">附件查看</span></a>';
高泉铭's avatar
高泉铭 committed
527 528
        }

Spencer Chang's avatar
Spencer Chang committed
529 530 531
        function csh531_add_fun(ds, record, index) {
            record.getField('contract_number').setRequired(true);
            record.getField('write_off_times').setReadOnly(false);
高泉铭's avatar
高泉铭 committed
532 533 534 535
        }

        function csh511_save_all() {
            if (checkAmount()) {
536 537 538
                var datas = [];
                var para = {};
                var records = $('csh_write_off_interface_ds').getAll();
niminmin's avatar
niminmin committed
539
                for (var i = 0; i < records.length; i++) {
540 541 542 543 544 545 546
                    para = records[i].data;
                    para['_status'] = 'update';
                    datas.push(para);
                }
                Leaf.request({
                    url: $('csh531n_submit_interface_link_id').getUrl(),
                    para: datas,
niminmin's avatar
niminmin committed
547
                    success: function (res) {
548 549 550 551 552
                        Leaf.Masker.unmask(Ext.getBody());
                        $('csh_transaction_deposit_ds').submit();
                        $('csh_transaction_advanced_ds').submit();
                        csh531_submitsuccess();
                    },
niminmin's avatar
niminmin committed
553
                    failure: function () {
554 555 556
                        Leaf.Masker.unmask(Ext.getBody());
                        csh531_submitfailed();
                    },
niminmin's avatar
niminmin committed
557
                    error: function () {
558 559 560 561 562 563 564 565
                        Leaf.Masker.unmask(Ext.getBody());
                        csh531_submitfailed();
                    },
                    scope: this
                });
                // $('csh_transaction_deposit_ds').submit();
                // $('csh_transaction_advanced_ds').submit();
                // $('csh_write_off_interface_ds').submit();
高泉铭's avatar
高泉铭 committed
566 567 568 569 570 571 572 573 574
            }
        }

        function checkAmount(type) {
            var sum = 0;
            var write_off_recs = $('csh_write_off_interface_ds').getAll();
            for (var i = 0; i < write_off_recs.length; i++) {
                var t = parseFloat(write_off_recs[i].get('write_off_amount'));
                if (!isNaN(t)) {
niminmin's avatar
niminmin committed
575
                    sum = plus(sum, t);
高泉铭's avatar
高泉铭 committed
576 577 578 579 580 581
                }
            }
            var deposit_recs = $('csh_transaction_deposit_ds').getAll();
            for (var i = 0; i < deposit_recs.length; i++) {
                var t = parseFloat(deposit_recs[i].get('write_off_amount'));
                if (!isNaN(t)) {
niminmin's avatar
niminmin committed
582
                    sum = plus(sum, t);
高泉铭's avatar
高泉铭 committed
583 584 585 586 587 588
                }
            }
            var advanced_recs = $('csh_transaction_advanced_ds').getAll();
            for (var i = 0; i < advanced_recs.length; i++) {
                var t = parseFloat(advanced_recs[i].get('write_off_amount'));
                if (!isNaN(t)) {
niminmin's avatar
niminmin committed
589
                    sum = plus(sum, t);
高泉铭's avatar
高泉铭 committed
590 591 592
                }
            }
            var header_rec = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
593 594
            if (sum > header_rec.get('unwrite_off_amount')) {
                Leaf.showInfoMessage('提示', '核销总金额不能大于剩余可核销金额');
Darming's avatar
Darming committed
595
                $('csh531n_write_off_submit_btn_id').enable();
Darming's avatar
Darming committed
596
                $('csh531n_write_off_btn_id').enable();
高泉铭's avatar
高泉铭 committed
597 598
                return false;
            }
Darming's avatar
Darming committed
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
            // var receipt_type = header_rec.get('receipt_type');
            // var bp_category = header_rec.get('bp_category');
            // var paid_byother_flag = header_rec.get('paid_byother_flag');
            // if (type == 'WRITE_OFF') {
            //     var check_flag = 'N';
            //     if (receipt_type == 'WITHHOLD') { //划扣
            //         check_flag = 'Y';
            //     } else {
            //         if (paid_byother_flag == 'F' && bp_category == 'TENANT') {
            //             check_flag = 'Y';
            //         }
            //     }
            //     if (check_flag == 'Y' && sum != header_rec.get('unwrite_off_amount')) {
            //         Leaf.showInfoMessage('提示', '核销总金额不等于可核销金额,该现金事务不支持部分核销!');
            //         $('csh531n_write_off_submit_btn_id').enable();
            //         return false;
            //     }
            // }
高泉铭's avatar
高泉铭 committed
617
            return true;
Spencer Chang's avatar
Spencer Chang committed
618 619
        }

Darming's avatar
Darming committed
620

621 622
        function csh_deposit_edit_function(record, name) {
            if ('${/parameter/@readOnly}' == 'Y') {
niminmin's avatar
niminmin committed
623

624 625 626 627 628 629
            } else {
                if (name == 'write_off_amount') {
                    return 'csh_transaction_deposit_grid_nf';
                }
            }
        }
niminmin's avatar
niminmin committed
630

631 632
        function csh_advance_edit_function(record, name) {
            if ('${/parameter/@readOnly}' == 'Y') {
niminmin's avatar
niminmin committed
633

634 635
            } else {
                if (name == 'write_off_amount') {
636 637 638 639 640 641
                    var r = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
                    var deposit_ds = $('csh_transaction_deposit_ds');
                    var advanced_ds = $('csh_transaction_advanced_ds');

                    var current_deposit_r = deposit_ds.getAt(0);
                    var current_advance_r = advanced_ds.getAt(0);
Darming's avatar
Darming committed
642
                    if (r.get('exists_deposit_flag') == 'Y' && current_deposit_r) {
643 644
                        return;
                    }
Darming's avatar
Darming committed
645 646 647
                    // if (r.get('exists_advance_flag') == 'Y' && current_advance_r) {
                    //     return;
                    // }
Darming's avatar
Darming committed
648
                    if (record.get('create_wf_flag') == 'Y') {
649 650
                        return;
                    }
651 652 653 654 655
                    return 'csh_transaction_advanced_grid_nf';
                }
            }
        }

Darming's avatar
Darming committed
656 657 658 659
        function csh531n_write_off_submit() {
            var returning_amount = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord().get('returning_amount') || 0;
            if (returning_amount > 0) {
                Leaf.showInfoMessage("提示", "该收款单存在审批中的退款流程,无法进行提交操作!");
Darming's avatar
Darming committed
660
                return;
Darming's avatar
Darming committed
661 662 663 664 665
            }
            var interfaceRs = $('csh_write_off_interface_ds').getAll();
            var depositRs = $('csh_transaction_deposit_ds').getAll();
            var advancedRs = $('csh_transaction_advanced_ds').getAll();

Darming's avatar
Darming committed
666 667 668 669 670 671
            //IE浏览器不支持ES6语法

            // var allRs = [...interfaceRs, ...depositRs, ...advancedRs];

            var allRs = [];
            allRs = interfaceRs.concat(depositRs).concat(advancedRs);
Darming's avatar
Darming committed
672 673 674 675


            var sum = 0;
            for (var i = 0; i < allRs.length; i++) {
Darming's avatar
Darming committed
676 677 678 679
                // if (allRs[i].dirty) {
                //     Leaf.showInfoMessage("提示", "存在未保存数据,请先保存再进行提交操作!");
                //     return;
                // }
niminmin's avatar
niminmin committed
680
                sum = plus(sum, allRs[i].get('write_off_amount') || 0);
Darming's avatar
Darming committed
681 682 683 684 685 686
            }

            if (sum == 0) {
                Leaf.showInfoMessage('提示', '请先分配核销金额再进行提交操作');
                return;
            }
niminmin's avatar
niminmin committed
687
            // 以旧换新与三方协议合同的首付款不可进行电汇核销
niminmin's avatar
niminmin committed
688
            var cf_item_2_count = 0;
niminmin's avatar
niminmin committed
689
            for (var i = 0; i < interfaceRs.length; i++) {
邓乾隆's avatar
邓乾隆 committed
690
                if ((interfaceRs[i].get('payment_deduction') == 'TRADE_IN' || interfaceRs[i].get('payment_deduction') == 'TRI_AGREEMENT'||interfaceRs[i].get('payment_deduction')=='DOWN_PAYMENT_DEDUCTION') && interfaceRs[i].get('write_off_cf_item') == '2') {
niminmin's avatar
niminmin committed
691
                    cf_item_2_count = plus(cf_item_2_count, 1);
niminmin's avatar
niminmin committed
692 693
                }
            }
niminmin's avatar
niminmin committed
694
            if (cf_item_2_count > 0) {
niminmin's avatar
niminmin committed
695 696 697
                Leaf.showInfoMessage('提示', ' 首付款抵扣为“无”以外的合同,不可进行首付款电汇核销!');
                return;
            }
Darming's avatar
Darming committed
698

699
            var createConfirm = Leaf.showConfirm('提示', '确认提交复核吗', function () {
Darming's avatar
Darming committed
700
                $('csh531n_write_off_submit_btn_id').disable();
Darming's avatar
Darming committed
701
                csh511_save_all();
Darming's avatar
Darming committed
702 703 704
            });
        }

Darming's avatar
Darming committed
705
        function csh531_add_fun(ds, record, index) {
Darming's avatar
Darming committed
706 707 708
            var h_ds = $('csh_transaction_receipt_write_off_detail_ds');
            var r = h_ds.getCurrentRecord();
            if (r.get('transaction_type') == 'DEPOSIT') {
Darming's avatar
Darming committed
709 710 711 712
                record.set('write_off_type', 'DEPOSIT_CREDIT');
            }
        }

Darming's avatar
Darming committed
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
        function get_min_amount(amt1, amt2) {
            if (!Ext.isEmpty(amt1) && !Ext.isEmpty(amt2)) {
                if (amt1 > amt2) {
                    return amt2;
                } else {
                    return amt1;
                }
            } else if (Ext.isEmpty(amt1)) {
                return amt2;
            } else if (Ext.isEmpty(amt2)) {
                return amt1;
            } else {
                return null;
            }
        }

        function write_off_amount_dblclick(grid, record, row, name) {
niminmin's avatar
niminmin committed
730
            if (!record) {
Darming's avatar
Darming committed
731 732 733 734 735 736
                record = grid.record;
            }
            var head_record = $('csh_transaction_receipt_write_off_detail_ds').getAt(0);
            // record = $('csh_transaction_receipt_write_off_detail_ds').getCurrentRecord();
            var for_allocate_amount = head_record.get('for_allocate_amount'),
                unreceived_amount = record.get('unreceived_amount');
niminmin's avatar
niminmin committed
737 738
            if (unreceived_amount) {
                if (Ext.isEmpty(record.get('write_off_amount')) || record.get('write_off_amount') == 0) {
Darming's avatar
Darming committed
739 740 741 742 743 744
                    record.set('write_off_amount', get_min_amount(for_allocate_amount, unreceived_amount));
                }
            }
        }


Spencer Chang's avatar
Spencer Chang committed
745 746 747 748 749 750 751 752 753 754 755
        ]]></script>
        <a:dataSets>
            <a:dataSet id="ds_collection_classes_ds" lookupCode="DS_COLLECTION_CLASSES"/>
            <a:dataSet id="ds_csh_write_off_classification_ds" lookupCode="DS_CSH_WRITE_OFF_CLASSIFICATION"/>
            <a:dataSet id="write_off_cf_item_ds" autoQuery="true" model="csh.CSH531N.hls_cashflow_item_v"/>
            <a:dataSet id="write_off_type_ds" autoQuery="true" model="csh.CSH531N.write_off_type_cb"/>
            <a:dataSet id="csh_transaction_receipt_write_off_detail_ds" model="csh.CSH531N.csh_transaction">
                <a:datas dataSource="/model/csh_transaction_path"/>
                <a:fields>
                    <!--  <a:field name="write_off_date" defaultValue="${/model/sys_default_value/record/@now_time}" required="true"/> -->
                    <a:field name="write_off_date" readOnly="true"/>
高泉铭's avatar
高泉铭 committed
756
                    <a:field name="paid_byother_flag_n" readOnly="true"/>
Spencer Chang's avatar
Spencer Chang committed
757 758 759 760 761 762 763 764 765 766 767 768 769 770
                    <a:field name="ref_contract_num" readOnly="true"/>
                    <a:field name="bank_slip_num" readOnly="true"/>
                    <a:field name="bp_code" readOnly="true"/>
                    <a:field name="bp_category" readOnly="true"/>
                    <a:field name="bp_category_n" readOnly="true"/>
                    <a:field name="transaction_num" readOnly="true"/>
                    <a:field name="currency_name" readOnly="true"/>
                    <a:field name="bp_name" readOnly="true"/>
                    <a:field name="transaction_amount" readOnly="true"/>
                    <a:field name="returned_amount" readOnly="true"/>
                    <a:field name="write_off_amount" readOnly="true"/>
                    <a:field name="unwrite_off_amount" readOnly="true"/>
                    <a:field name="csh_bp_name" readOnly="true"/>
                    <a:field name="bank_account_name" readOnly="true"/>
高泉铭's avatar
高泉铭 committed
771
                    <a:field name="transaction_date" readOnly="true"/>
Spencer Chang's avatar
Spencer Chang committed
772 773 774 775 776
                    <a:field name="bp_bank_account_name" readOnly="true"/>
                    <a:field name="bp_bank_account_num" readOnly="true"/>
                    <a:field name="write_off_flag_desc" readOnly="true"/>
                    <a:field name="review_status_desc" readOnly="true"/>
                    <a:field name="bank_account_num" readOnly="true"/>
777 778
                    <a:field name="opposite_band_na" readOnly="true"/>
                    <a:field name="bank_branch_name" readOnly="true"/>
高泉铭's avatar
高泉铭 committed
779 780
                    <a:field name="collection_classes_desc" readOnly="true" options="ds_collection_classes_ds"
                             displayField="code_value_name" returnField="collection_classes" valueField="code_value"/>
Spencer Chang's avatar
Spencer Chang committed
781 782
                    <a:field name="ref_v01"/>
                    <a:field name="approving_return_amount" readOnly="true"/>
niminmin's avatar
niminmin committed
783
                    <a:field name="for_allocate_amount" readOnly="true"/>
Spencer Chang's avatar
Spencer Chang committed
784 785 786
                </a:fields>

            </a:dataSet>
高泉铭's avatar
高泉铭 committed
787 788
            <a:dataSet id="csh_write_off_interface_ds" autoQuery="true" fetchAll="true"
                       model="csh.CSH531N.csh_write_off_interface"
789
                       queryUrl="${/request/@context_path}/autocrud/csh.CSH531N.csh_write_off_interface/query?trx_interface_id=${/parameter/@transaction_id}&amp;trx_transaction_type=${/parameter/@transaction_type}&amp;transaction_date=${/parameter/@transaction_date}"
高泉铭's avatar
高泉铭 committed
790
                       selectable="true">
Spencer Chang's avatar
Spencer Chang committed
791 792
                <a:fields>
                    <a:field name="company_id" defaultValue="${/parameter/@company_id}"/>
niminmin's avatar
niminmin committed
793 794
                    <a:field name="write_off_date" datatype="java.util.Date" validator="write_off_date_validator"
                             required="true"
Darming's avatar
Darming committed
795
                             defaultValue="${/model/sys_default_time/record/@now_date}"/>
高泉铭's avatar
高泉铭 committed
796 797
                    <a:field name="journal_date" required="true"
                             defaultValue="${/model/sys_default_time/record/@now_date}"/>
Spencer Chang's avatar
Spencer Chang committed
798 799 800 801
                    <a:field name="write_off_period_name" defaultValue="${/parameter/@period_name}"/>
                    <a:field name="write_off_period_num" defaultValue="${/parameter/@internal_period_num}"/>
                    <a:field name="check_flag" defaultValue="Y"/>
                    <a:field name="record_type" defaultValue="MANUAL"/>
高泉铭's avatar
高泉铭 committed
802 803
                    <a:field name="write_off_times" readOnly="true"/>
                    <a:field name="write_off_amount" required="true"/>
Spencer Chang's avatar
Spencer Chang committed
804 805 806 807 808
                    <a:field name="due_date"/>
                    <a:field name="unreceived_amount"/>
                    <a:field name="write_off_cashflow_id"/>
                    <a:field name="contract_id"/>
                    <a:field name="trx_interface_id" defaultValue="${/parameter/@transaction_id}"/>
高泉铭's avatar
高泉铭 committed
809
                    <a:field name="contract_number" prompt="合同编号" autoComplete="true" lovAutoQuery="true"
Darming's avatar
Darming committed
810
                             lovHeight="850" required="true"
811
                             lovUrl="${/request/@context_path}/modules/csh/CSH531N/csh_write_off_ref_contract.lview?bp_id=${/model/csh_transaction_path/record/@bp_id}&amp;deposit_flag=${/parameter/@deposit_flag}&amp;transaction_date=${/model/csh_transaction_path/record/@transaction_date}"
高泉铭's avatar
高泉铭 committed
812
                             lovWidth="1350" title="合同号选择">
Spencer Chang's avatar
Spencer Chang committed
813 814 815 816 817 818 819
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                            <a:map from="contract_id" to="contract_id"/>
                            <a:map from="bp_id_tenant" to="write_off_bp_id"/>
                            <a:map from="bp_id_tenant_name" to="write_off_bp_name"/>
                            <a:map from="contract_status_desc" to="contract_status_desc"/>
niminmin's avatar
niminmin committed
820
                            <a:map from="payment_deduction" to="payment_deduction"/>
Spencer Chang's avatar
Spencer Chang committed
821 822 823 824
                        </a:mapping>
                    </a:field>
                    <a:field name="batch_id" defaultValue="${/parameter/@batch_id}"/>
                    <a:field name="write_off_type" defaultValue="RECEIPT_CREDIT"/>
高泉铭's avatar
高泉铭 committed
825 826 827
                    <a:field name="write_off_type_desc" defaultValue="收款核销债权" prompt="核销类型" required="true"
                             displayField="code_value_name" options="write_off_type_ds" returnField="write_off_type"
                             valueField="code_value"/>
Spencer Chang's avatar
Spencer Chang committed
828
                    <a:field name="write_off_bp_id"/>
niminmin's avatar
niminmin committed
829
                    <a:field name="payment_deduction"/>
高泉铭's avatar
高泉铭 committed
830 831 832
                    <a:field name="write_off_classification_desc" prompt="核销分类"
                             options="ds_csh_write_off_classification_ds" returnField="write_off_classification"
                             valueField="code_value" displayField="code_value_name"/>
Spencer Chang's avatar
Spencer Chang committed
833
                    <a:field name="write_off_cf_item" readOnly="true"/>
高泉铭's avatar
高泉铭 committed
834 835 836
                    <a:field name="write_off_cf_item_desc" readOnly="true" displayField="cf_item_desc"
                             options="write_off_cf_item_ds"
                             returnField="write_off_cf_item" valueField="cf_item"/>
Spencer Chang's avatar
Spencer Chang committed
837 838 839
                </a:fields>
                <a:events>
                    <a:event name="update" handler="csh531_update_fun"/>
840
                    <!--                    <a:event name="beforesubmit" handler="csh531_beforesubmit_fun"/>-->
Spencer Chang's avatar
Spencer Chang committed
841
                    <a:event name="load" handler="csh531_load_fun"/>
842 843
                    <!--<a:event name="submitsuccess" handler="csh531_submitsuccess"/>
                    <a:event name="submitfailed" handler="csh531_submitfailed"/>-->
Spencer Chang's avatar
Spencer Chang committed
844 845 846
                    <a:event name="add" handler="csh531_add_fun"/>
                </a:events>
            </a:dataSet>
高泉铭's avatar
高泉铭 committed
847 848 849 850 851
            <a:dataSet id="csh_transaction_deposit_ds" model="csh.CSH531N.csh_transaction_plan_query" fetchAll="true"
                       autoQuery="true"
                       queryUrl="${/request/@context_path}/autocrud/csh.CSH531N.csh_transaction_plan_query/query?transaction_id=${/parameter/@transaction_id}&amp;write_off_type=RECEIPT_DEPOSIT_POOL"
                       selectable="true">
                <a:fields>
niminmin's avatar
niminmin committed
852 853 854 855 856 857 858 859 860 861 862 863 864 865
                    <!--                    <a:field name="bp_agent_name" lovGridHeight="350" lovHeight="550" lovLabelWidth="50" lovWidth="550"-->
                    <!--                             required="true" readOnly="true" autoComplete="true" autoCompleteField="bp_agent_name"-->
                    <!--                             lovService="basic.hls_bp_master_v_for_lov?bp_category=AGENT&amp;bp_id=${/parameter/@bp_id}"-->
                    <!--                             title="HLS.BP_TITLE">-->
                    <!--                        <a:mapping>-->
                    <!--                            <a:map from="bp_id" to="bp_id"/>-->
                    <!--                            <a:map from="bp_name" to="bp_agent_name"/>-->
                    <!--                        </a:mapping>-->
                    <!--                    </a:field>-->
                    <a:field name="bp_name" readOnly="true" autoComplete="true" lovGridHeight="350" lovHeight="550"
                             lovLabelWidth="50"
                             lovWidth="550"
                             required="true"
                             lovService="basic.hls_bp_master_v_for_lov?bp_id=${/parameter/@bp_id}" title="HLS.BP_TITLE">
高泉铭's avatar
高泉铭 committed
866 867
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id"/>
niminmin's avatar
niminmin committed
868
                            <a:map from="bp_name" to="bp_name"/>
高泉铭's avatar
高泉铭 committed
869 870 871
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id" defaultValue="${/parameter/@bp_id}"/>
niminmin's avatar
niminmin committed
872
                    <a:field name="bp_name" defaultValue="${/model/csh_transaction_path/record/@bp_name}"/>
高泉铭's avatar
高泉铭 committed
873 874 875
                    <a:field name="transaction_id" defaultValue="${/parameter/@transaction_id}"/>
                    <a:field name="write_off_type" defaultValue="RECEIPT_DEPOSIT_POOL"/>
                    <a:field name="company_id" defaultValue="${/session/@company_id}"/>
高泉铭's avatar
高泉铭 committed
876
                    <a:field name="write_off_amount"/>
niminmin's avatar
niminmin committed
877
                    <a:field name="create_wf_flag" defaultValue="N"/>
Darming's avatar
Darming committed
878
                    <a:field name="write_off_date" validator="write_off_date_validator" required="true"
Darming's avatar
Darming committed
879
                             defaultValue="${/model/sys_default_time/record/@now_date}"/>
高泉铭's avatar
高泉铭 committed
880 881 882 883 884 885 886
                </a:fields>
            </a:dataSet>
            <a:dataSet id="csh_transaction_advanced_ds" model="csh.CSH531N.csh_transaction_plan_query" fetchAll="true"
                       autoQuery="true"
                       queryUrl="${/request/@context_path}/autocrud/csh.CSH531N.csh_transaction_plan_query/query?transaction_id=${/parameter/@transaction_id}&amp;write_off_type=RECEIPT_ADVANCE_RECEIPT"
                       selectable="true">
                <a:fields>
高泉铭's avatar
高泉铭 committed
887 888
                    <a:field name="bp_name" readOnly="true" autoComplete="true" lovGridHeight="350" lovHeight="550"
                             lovLabelWidth="50"
高泉铭's avatar
高泉铭 committed
889 890 891 892 893 894 895 896 897
                             lovWidth="550"
                             required="true"
                             lovService="basic.hls_bp_master_v_for_lov?bp_id=${/parameter/@bp_id}" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id"/>
                            <a:map from="bp_name" to="bp_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id" defaultValue="${/parameter/@bp_id}"/>
niminmin's avatar
niminmin committed
898
                    <a:field name="bp_name" defaultValue="${/parameter/@bp_name}"/>
高泉铭's avatar
高泉铭 committed
899 900 901
                    <a:field name="transaction_id" defaultValue="${/parameter/@transaction_id}"/>
                    <a:field name="write_off_type" defaultValue="RECEIPT_ADVANCE_RECEIPT"/>
                    <a:field name="company_id" defaultValue="${/session/@company_id}"/>
高泉铭's avatar
高泉铭 committed
902
                    <a:field name="write_off_amount"/>
Darming's avatar
Darming committed
903
                    <a:field name="create_wf_flag" defaultValue="N"/>
Darming's avatar
Darming committed
904
                    <a:field name="write_off_date" validator="write_off_date_validator" required="true"
Darming's avatar
Darming committed
905
                             defaultValue="${/model/sys_default_time/record/@now_date}"/>
高泉铭's avatar
高泉铭 committed
906 907
                </a:fields>
            </a:dataSet>
Spencer Chang's avatar
Spencer Chang committed
908 909 910
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
Darming's avatar
Darming committed
911 912 913
                <a:screenTitle/>
                <!--                <a:gridButton id="csh511_save_all_id" click="csh511_save_all" style="margin-left:20px;display:none"-->
                <!--                              text="暂存"/>-->
高泉铭's avatar
高泉铭 committed
914
                <a:gridButton id="csh531n_write_off_btn_id" click="csh531n_write_off"
Darming's avatar
Darming committed
915
                              style="margin-left:10px;display:none" text="确认核销"/>
Darming's avatar
Darming committed
916 917
                <a:gridButton id="csh531n_write_off_return_btn_id" click="csh531n_write_off_return"
                              style="margin-left:10px;display:none" text="核销退回"/>
Darming's avatar
Darming committed
918 919
                <a:gridButton id="csh531n_write_off_submit_btn_id" click="csh531n_write_off_submit"
                              style="margin-left:10px;display:none" text="提交复核"/>
Spencer Chang's avatar
Spencer Chang committed
920
            </a:screenTopToolbar>
高泉铭's avatar
高泉铭 committed
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
            <a:form style="margin-left:20px;">
                <a:fieldSet labelWidth="250" title="收款单详情">
                    <a:box column="3" labelWidth="100">
                        <a:datePicker name="transaction_date" bindTarget="csh_transaction_receipt_write_off_detail_ds"/>
                        <a:numberField name="transaction_amount" allowFormat="true"
                                       bindTarget="csh_transaction_receipt_write_off_detail_ds"/>
                        <!--                        <a:textField name="transaction_num" bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->
                        <!--                        <a:textField name="bank_account_name" bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->
                        <a:textField name="bank_slip_num" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="银行流水号"/>
                        <!--                        <a:textField name="bank_account_num" bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->
                    </a:box>
                    <a:box column="3" labelWidth="100">
                        <a:textField name="paid_byother_flag_n" prompt="代付"
                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>
                        <a:textField name="bp_name" prompt="商业伙伴"
                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>
                        <a:textField name="collection_classes_desc" prompt="款项用途"
                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>
                        <!--                        <a:numberField name="returned_amount" allowFormat="true"-->
                        <!--                                       bindTarget="csh_transaction_receipt_write_off_detail_ds"-->
                        <!--                                       prompt="HLS.RETURNED_AMOUNT"/>-->
                        <!--                        <a:numberField name="write_off_amount" allowFormat="true"-->
                        <!--                                       bindTarget="csh_transaction_receipt_write_off_detail_ds"-->
                        <!--                                       prompt="HLS.WRITEOFF_AMOUNT"/>-->
                        <!--                        <a:numberField name="unwrite_off_amount" allowFormat="true"-->
                        <!--                                       bindTarget="csh_transaction_receipt_write_off_detail_ds"-->
                        <!--                                       prompt="CSH513.REMAINING_WRITEOFF_AMOUNT"/>-->
                    </a:box>
950
                    <a:box column="3" labelWidth="100">
高泉铭's avatar
高泉铭 committed
951 952 953
                        <a:textField name="description" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="摘要"
                                     readOnly="true" colspan="2" width="370"/>
Darming's avatar
Darming committed
954
                        <a:numberField name="unwrite_off_amount" prompt="剩余可核销金额" renderer="Leaf.formatMoney"
955
                                       bindTarget="csh_transaction_receipt_write_off_detail_ds" readOnly="true"/>
高泉铭's avatar
高泉铭 committed
956
                    </a:box>
957
                    <a:box column="3" labelWidth="100">
高泉铭's avatar
高泉铭 committed
958 959
                        <a:textField colspan="2" name="ref_v05" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="备注" width="370" readOnly="true"/>
Darming's avatar
Darming committed
960
                        <a:numberField name="returned_amount" prompt="已退款金额" renderer="Leaf.formatMoney"
961
                                       bindTarget="csh_transaction_receipt_write_off_detail_ds" readOnly="true"/>
高泉铭's avatar
高泉铭 committed
962
                    </a:box>
Darming's avatar
Darming committed
963
                    <a:box column="3" labelWidth="100">
964
                        <a:label prompt="附件查看" colspan="2" bindTarget="csh_transaction_receipt_write_off_detail_ds"
Darming's avatar
Darming committed
965
                                 renderer="attachment_rendered" width="370"/>
niminmin's avatar
niminmin committed
966 967
                        <a:numberField name="for_allocate_amount" renderer="Leaf.formatMoney" prompt="剩余可分配金额"
                                       readOnly="true" bindTarget="csh_transaction_receipt_write_off_detail_ds"/>
高泉铭's avatar
高泉铭 committed
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991
                    </a:box>

                    <!--                    <a:box column="4" labelWidth="100">-->
                    <!--                        <a:textField name="review_status_desc" prompt="分配状态"-->
                    <!--                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->
                    <!--                        <a:textField name="purpose" prompt="用途" readOnly="true"-->
                    <!--                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->

                    <!--                        <a:numberField name="approving_return_amount" allowFormat="true"-->
                    <!--                                       bindTarget="csh_transaction_receipt_write_off_detail_ds" prompt="审批中退款金额"/>-->
                    <!--                    </a:box>-->
                    <!--                    <a:box column="4" labelWidth="100">-->

                    <!--                        <a:comboBox name="collection_classes_desc"-->
                    <!--                                    bindTarget="csh_transaction_receipt_write_off_detail_ds"-->
                    <!--                                    prompt="款项分类"/>-->

                    <!--                        <a:gridButton click="csh531n_save" text="HLS.SAVE"/>-->
                    <!--                    </a:box>-->
                    <!--<a:box column="2" labelWidth="100">-->
                    <!--<a:textArea name="description" bindTarget="csh_transaction_receipt_write_off_detail_ds" prompt="摘要" readOnly="true" width="405"/>-->
                    <!--</a:box>-->
                </a:fieldSet>
                <a:fieldSet labelWidth="250" title="账户信息">
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
                    <a:box column="3" labelWidth="100">
                        <!--                        <a:textField name="bp_bank_account_name" prompt="对方账户"-->
                        <!--                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->
                        <!--                        <a:textField name="bp_bank_account_num" prompt="对方账号"-->
                        <!--                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->
                        <!--                        <a:textField name="write_off_flag_desc" prompt="核销状态"-->
                        <!--                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"/>-->
                        <a:textField name="bank_account_name" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="CSH510.CSH_TRANSACTION.MY_ACCOUNT_NAME"/>
                        <a:textField name="bank_branch_name" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="CSH510.CSH_TRANSACTION.MY_BANK_NAME"/>
                        <a:textField name="bank_account_num" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="CSH510.CSH_TRANSACTION.MY_ACCOUNT_USERNAME"/>
                        <!--对方账户户名-->
                        <a:textField name="bp_bank_account_name"
                                     bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="CSH510.CSH_TRANSACTION.YOUR_ACCOUNT_NAME"/>
                        <!--对方银行名称-->
                        <a:textField name="opposite_band_na" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="CSH510.CSH_TRANSACTION.YOUR_BANK_NAME"/>
                        <!--对方账户账号-->
                        <a:textField name="bp_bank_account_num" bindTarget="csh_transaction_receipt_write_off_detail_ds"
                                     prompt="CSH510.CSH_TRANSACTION.YOUR_ACCOUNT_USERNAME"/>
高泉铭's avatar
高泉铭 committed
1015 1016
                    </a:box>
                </a:fieldSet>
Spencer Chang's avatar
Spencer Chang committed
1017
            </a:form>
高泉铭's avatar
高泉铭 committed
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
            <a:tabPanel height="450" marginWidth="30" style="margin-left:20px;">
                <a:tabs>
                    <a:tab prompt="核销债权" width="120" id="write_off_rental">
                        <a:grid id="csh_write_off_grid" bindTarget="csh_write_off_interface_ds" height="370"
                                marginWidth="10" navBar="true">
                            <a:toolBar>
                                <a:button id="csh_grid_add_bt" type="add"/>
                                <a:button id="csh_grid_delete_bt" type="delete"/>
                            </a:toolBar>
                            <a:columns>
                                <!--<a:column name="csh_bank_slip_num" footerRenderer="summaryRenderer" prompt="CSH531.BANK_SLIP_NUM" width="120"/>-->
                                <!--                                <a:column name="write_off_type_desc" editorFunction="csh_edit_function"-->
                                <!--                                          prompt="HLS.WRITE_OFF_TYPE"-->
                                <!--                                          width="100"/>-->
                                <a:column name="contract_number" editorFunction="csh_edit_function" align="center"
                                          prompt="HLS.CONTRACT_NUMBER"
                                          width="120"/>
                                <a:column name="bp_tenant_name" prompt="承租人" width="120"/>
                                <a:column name="write_off_cf_item_desc" editorFunction="csh_edit_function"
                                          align="center"
                                          prompt="CSH531.CF_ITEM"
                                          width="80"/>
Darming's avatar
Darming committed
1040 1041
                                <a:column name="due_date" prompt="支付日" renderer="Leaf.formatDate" width="80"
                                          align="center"/>
高泉铭's avatar
高泉铭 committed
1042 1043
                                <a:column name="write_off_times" prompt="HLS.TIMES" align="center"
                                          width="80"/>
Darming's avatar
Darming committed
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
                                <!--                                <a:column name="left_principal" renderer="Leaf.formatMoney" prompt="未收本金"-->
                                <!--                                          width="120" align="right"/>-->
                                <!--                                <a:column name="left_interest" renderer="Leaf.formatMoney" prompt="未收利息"-->
                                <!--                                          width="120"-->
                                <!--                                          align="right"/>-->
                                <!--                                <a:column name="left_amount" renderer="Leaf.formatMoney" prompt="未收金额"-->
                                <!--                                          width="120"-->
                                <!--                                          align="right"/>-->
                                <a:column name="principal" renderer="Leaf.formatMoney" prompt="应收本金"
                                          width="120" align="right"/>
                                <a:column name="interest" renderer="Leaf.formatMoney" prompt="应收利息"
                                          width="120"
                                          align="right"/>
                                <a:column name="due_amount" renderer="Leaf.formatMoney" prompt="应收金额"
                                          width="120"
                                          align="right"/>
高泉铭's avatar
高泉铭 committed
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
                                <!--                                <a:column name="write_off_bp_name" editorFunction="csh_edit_function"-->
                                <!--                                          prompt="CSH531.WRITE_OFF_BP_NAME" width="100"/>-->
                                <!--                                <a:column name="left_amount" align="right" footerRenderer="summaryRenderer"-->
                                <!--                                          prompt="剩余金额"-->
                                <!--                                          renderer="Leaf.formatMoney" width="120"/>-->
                                <!--<a:column name="left_principal" align="right" footerRenderer="summaryRenderer" prompt="剩余本金" renderer="Leaf.formatMoney" width="120"/>-->
                                <!--<a:column name="left_interest" align="right" footerRenderer="summaryRenderer" prompt="剩余利息" renderer="Leaf.formatMoney" width="120"/>-->
                                <!--                                <a:column name="write_off_classification_desc" editorFunction="csh_edit_function"-->
                                <!--                                          prompt="核销分类"/>-->
                                <!--                                <a:column name="write_off_date" align="center" editorFunction="csh_edit_function"-->
                                <!--                                          renderer="Leaf.formatDate" prompt="核销基准日期" width="120"/>-->
                                <!--                                <a:column name="journal_date" align="center" editorFunction="csh_edit_function"-->
                                <!--                                          renderer="Leaf.formatDate" prompt="凭证日期" width="120"/>-->
                                <a:column name="unreceived_amount" align="right" editorFunction="csh_edit_function"
                                          footerRenderer="summaryRenderer" prompt="未收金额"
                                          renderer="Leaf.formatMoney"
                                          width="120"/>
                                <a:column name="write_off_amount" align="right" editorFunction="csh_edit_function"
                                          footerRenderer="summaryRenderer" prompt="核销金额"
                                          renderer="Leaf.formatMoney"
                                          width="120"/>
                                <a:column name="write_off_date"
Darming's avatar
Darming committed
1082
                                          prompt="核销日期" editorFunction="csh_edit_function"
高泉铭's avatar
高泉铭 committed
1083 1084 1085 1086 1087
                                          renderer="Leaf.formatDate" width="80"/>
                                <!--<a:column name="agent_id_desc" editorFunction="csh_edit_function" prompt="代理商"/>-->
                            </a:columns>
                            <a:editors>
                                <a:textField id="csh_write_off_grid_tf"/>
Darming's avatar
Darming committed
1088 1089 1090 1091 1092
                                <a:numberField id="csh_write_off_grid_nf" allowNegative="false">
                                    <a:events>
                                        <a:event name="focus" handler="write_off_amount_dblclick"/>
                                    </a:events>
                                </a:numberField>
高泉铭's avatar
高泉铭 committed
1093 1094 1095 1096
                                <a:datePicker id="csh_write_off_grid_dp"/>
                                <a:comboBox id="csh_write_off_grid_cb"/>
                                <a:lov id="csh_write_off_grid_lv"/>
                            </a:editors>
Darming's avatar
Darming committed
1097 1098 1099
                            <a:events>
                                <a:event name="dblclick" handler="write_off_amount_dblclick"/>
                            </a:events>
高泉铭's avatar
高泉铭 committed
1100 1101
                        </a:grid>
                    </a:tab>
niminmin's avatar
niminmin committed
1102
                    <a:tab id="write_off_deposit" tabStyle="display:none" prompt="核销为保证金" width="150">
高泉铭's avatar
高泉铭 committed
1103 1104 1105 1106
                        <a:grid id="csh_transaction_deposit_grid" navBar="true"
                                bindTarget="csh_transaction_deposit_ds"
                                height="370"
                                marginWidth="10">
niminmin's avatar
niminmin committed
1107 1108 1109 1110
                            <a:toolBar>
                                <a:button id="csh_grid_deposit_add_bt" type="add"/>
                                <a:button id="csh_grid_deposit_delete_bt" type="delete"/>
                            </a:toolBar>
高泉铭's avatar
高泉铭 committed
1111
                            <a:columns>
niminmin's avatar
niminmin committed
1112
                                <a:column name="bp_name" prompt="商业伙伴" width="180" align="center"
高泉铭's avatar
高泉铭 committed
1113
                                          editor="csh_transaction_deposit_grid_lv"/>
1114 1115
                                <a:column name="write_off_amount" prompt="核销金额"
                                          editorFunction="csh_deposit_edit_function" renderer="Leaf.formatMoney"
高泉铭's avatar
高泉铭 committed
1116
                                          width="180"
1117
                                          align="right"
高泉铭's avatar
高泉铭 committed
1118 1119
                                          footerRenderer="summaryRenderer"/>
                                <a:column name="write_off_date" prompt="核销日期" width="180" align="center"
Darming's avatar
Darming committed
1120
                                          renderer="Leaf.formatDate" editorFunction="csh_edit_function"/>
高泉铭's avatar
高泉铭 committed
1121 1122 1123
                            </a:columns>
                            <a:editors>
                                <a:lov id="csh_transaction_deposit_grid_lv"/>
niminmin's avatar
niminmin committed
1124 1125 1126 1127 1128
                                <a:numberField id="csh_transaction_deposit_grid_nf" allowNegative="false">
                                    <a:events>
                                        <a:event name="focus" handler="write_off_amount_dblclick"/>
                                    </a:events>
                                </a:numberField>
高泉铭's avatar
高泉铭 committed
1129 1130
                                <a:datePicker id="csh_transaction_deposit_grid_dp"/>
                            </a:editors>
niminmin's avatar
niminmin committed
1131 1132 1133
                            <a:events>
                                <a:event name="dblclick" handler="write_off_amount_dblclick"/>
                            </a:events>
高泉铭's avatar
高泉铭 committed
1134 1135
                        </a:grid>
                    </a:tab>
Darming's avatar
Darming committed
1136
                    <a:tab id="write_off_advance" tabStyle="display:none" prompt="核销为预收款" width="150">
高泉铭's avatar
高泉铭 committed
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
                        <a:grid id="csh_transaction_advanced_grid" navBar="true"
                                bindTarget="csh_transaction_advanced_ds" height="370"
                                marginWidth="10">
                            <!--                            <a:toolBar>-->
                            <!--                                <a:button id="csh_grid_advanced_add_bt" type="add"/>-->
                            <!--                                <a:button id="csh_grid_advanced_delete_bt" type="delete"/>-->
                            <!--                            </a:toolBar>-->
                            <a:columns>
                                <a:column name="bp_name" prompt="商业伙伴" width="180" align="center"
                                          editor="csh_transaction_advanced_grid_lv"/>
1147 1148
                                <a:column name="write_off_amount" prompt="核销金额"
                                          editorFunction="csh_advance_edit_function" renderer="Leaf.formatMoney"
高泉铭's avatar
高泉铭 committed
1149
                                          width="180"
1150
                                          align="right"
高泉铭's avatar
高泉铭 committed
1151 1152
                                          footerRenderer="summaryRenderer"/>
                                <a:column name="write_off_date" prompt="核销日期" width="180" align="center"
Darming's avatar
Darming committed
1153
                                          renderer="Leaf.formatDate" editorFunction="csh_edit_function"/>
Darming's avatar
Darming committed
1154
                                <!--                                <a:column name="create_wf_flag_desc" prompt="已核销标志"/>-->
高泉铭's avatar
高泉铭 committed
1155 1156 1157
                            </a:columns>
                            <a:editors>
                                <a:lov id="csh_transaction_advanced_grid_lv"/>
Darming's avatar
Darming committed
1158 1159 1160 1161 1162
                                <a:numberField id="csh_transaction_advanced_grid_nf" allowNegative="false">
                                    <a:events>
                                        <a:event name="focus" handler="write_off_amount_dblclick"/>
                                    </a:events>
                                </a:numberField>
高泉铭's avatar
高泉铭 committed
1163 1164
                                <a:datePicker id="csh_transaction_advanced_grid_dp"/>
                            </a:editors>
Darming's avatar
Darming committed
1165 1166 1167
                            <a:events>
                                <a:event name="dblclick" handler="write_off_amount_dblclick"/>
                            </a:events>
高泉铭's avatar
高泉铭 committed
1168 1169 1170 1171
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
Spencer Chang's avatar
Spencer Chang committed
1172 1173 1174 1175 1176 1177
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
        Leaf.onReady(init);
        ]]></script>
    </a:view>
</a:screen>