leg_legal_fee_modify.lview 14.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
<?xml version="1.0" encoding="UTF-8"?>
<!--
  create by nyl  2014-12-3 
  for contract context create
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.function_code = ${/parameter/@function_code}" model="cus.CUS100.cus_default_function_name" rootPath="default_function_name"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="leg451_legal_fee_create_link_id" model="leg.LEG450.leg_legal_fee_create" modelaction="batch_update"/>
        <!--  <a:link id="leg_legal_fee_delete_link_id" model="leg.LEG450.leg_legal_fee_create" modelaction="delete"/> -->
        <a:link id="leg_fee_create_link_id" url="${/request/@context_path}/modules/leg/LEG600/leg_fee_create.lsc"/>
        <a:link id="leg_legal_fee_delete_link_id" url="${/request/@context_path}/modules/leg/LEG450/leg_fee_dml.lsc"/>
        <a:link id="hls_bp_master_modify_link" url="${/request/@context_path}/modules/hls/HLS214N/hls_bp_master_modify.lview"/>
        <a:link id="leg_legal_fee_modify_link_id" url="${/request/@context_path}/modules/leg/LEG450/leg_legal_fee_modify.lview"/>
        <script type="text/javascript"><![CDATA[
            //保存前调用
            
            /*
             function leg451_check(ds_id) {
             var records = $(ds_id).getSelected();
             for (var i = 0;i < records.length;i++) {
             var legal_number =records[i].get('legal_number') ;
             var law_office_n =records[i].get('law_office_n') ;
             var cf_item_n =records[i].get('cf_item_n') ;
             var vat_amount = records[i].get('vat_amount') == undefined ? 0 : records[i].get('vat_amount');
             var net_amount = records[i].get('net_amount') == undefined ? 0 : records[i].get('net_amount');
             var amount = records[i].get('amount') == undefined ? 0 : records[i].get('amount');
             var tax_rate = records[i].get('tax_rate') == undefined ? 0 : records[i].get('tax_rate');
             if (amount <= 0 || vat_amount < 0 || net_amount < 0) {
             Leaf.showMessage('${l:PROMPT}', '金额小于零不合法!');
             return;
             }
             if (parseFloat(amount) != parseFloat(vat_amount) + parseFloat(net_amount)) {
             Leaf.showMessage('${l:PROMPT}', '含税金额不等于不含税金额加税额!');
             return;
             }
             if(tax_rate == 0){
             Leaf.showMessage('${l:PROMPT}', law_office_n+'的'+cf_item_n+'(标为红色)税率未维护,请维护!');
             return;
             }
             }
             } */
            
            function create_cashflow() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var param = new Object();
                var datas = [];
                var records = $(ds_id).getSelected();
                for (var i = 0;i < records.length;i++) {
                    if (records[i].get('legal_fee_id')) {
            
                        data = {};
                        data['legal_fee_id'] = records[i].get('legal_fee_id');
                        data['_status'] = 'update';
                        datas.push(data);
            
                    }
                }
                param['details'] = datas;
                var url_l = $('leg451_legal_fee_create_link_id').getUrl();
                Leaf.request({
                    url: url_l,
                    para: datas,
                    success: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        $(ds_id).query();
                    },
                    error: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    scope: this
                });
            
            }
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var tax_rate_count = 0;
                var records = $(ds_id).getSelected();
            
                for (var i = 0;i < records.length;i++) {
                    if (records[i].dirty == true) {
                        Leaf.showMessage('${l:PROMPT}', '请先保存再确认');
                        return;
                    }
                }
            
                if (!records.length) {
                    Leaf.showMessage('${l:PROMPT}', '请至少选择一条记录');
                    return;
                }
            
            
            
                var param = new Object();
                var datas = [];
            
                if (records.length == 0) {
                    Leaf.showInfoMessage('信息', '请至少选择一行!', null, 200, 100);
                }
            
                //校验
                // leg451_check(ds_id);
                for (var i = 0;i < records.length;i++) {
            
                    var legal_number = records[i].get('legal_number');
                    var bp_id_n = records[i].get('bp_id_n');
                    var cf_item_n = records[i].get('cf_item_n');
                    var vat_amount = records[i].get('vat_amount') == undefined ? 0 : records[i].get('vat_amount');
                    var net_amount = records[i].get('net_amount') == undefined ? 0 : records[i].get('net_amount');
                    var amount = records[i].get('amount') == undefined ? 0 : records[i].get('amount');
                    var tax_rate = records[i].get('tax_rate') == undefined ? -99 : records[i].get('tax_rate');
                    if (amount <= 0 || vat_amount < 0 || net_amount < 0) {
                        Leaf.showMessage('${l:PROMPT}', '金额小于零不合法!');
                        return;
                    }
				
					var sum_amount  = vat_amount+net_amount;
                    if (parseFloat(amount.toFixed(2)) != parseFloat(sum_amount.toFixed(2)) ){
            
            
                        Leaf.showMessage('${l:PROMPT}', '含税金额不等于不含税金额加税额!');
            
                        return;
                    }
                    if (tax_rate == -99) {
                        // Leaf.showMessage('${l:PROMPT}', bp_id_n + '的' + cf_item_n + '(标为红色)税率未维护,请维护!', null, 350);
                        tax_rate_count = tax_rate_count + 1;
            
                    }
                }
            
                if (tax_rate_count >= 1) {
                    Leaf.showConfirm('${l:PROMPT}', bp_id_n + '的' + cf_item_n + '(标为红色)税率为0或为维护,是否确认生成现金流?', function() {
                        create_cashflow();
                    }, function() {
            
                       }, 350, 120);
                } else {
                    Leaf.showConfirm('${l:PROMPT}', '是否确认生成现金流?', function() {
                        create_cashflow();
                    }, function() {
            
                       });
                }
            
            };
            //导出
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var grid_id = ds_id.replace('ds', 'layout_grid_id');
                $(grid_id)._export('xls', '${/model/default_function_name/record/@function_name}');
            
            
            };
            
            function open_bp_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
            
                maintain_type = 'CREATE';
                param['url_title'] = 'BP费率维护';
                param['maintain_type'] = maintain_type;
                param['cond_para2'] = param['bp_type'];
                param['function_code'] = 'HLS214D';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
            
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'hls_bp_master_modify_link', ds_id);
            
            }
            
            function open_contract_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
            
                maintain_type = 'CREATE';
                param['function_code'] = 'LEG450D';
                param['function_usage'] = 'CREATE';
                param['url_title'] = '法务费用创建';
                url_l = 'leg_legal_fee_modify_link_id';
            
                param['maintain_type'] = maintain_type;
            
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, url_l, ds_id);
            
            }
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'legal_number') {
                    if (!record.get('tax_rate') && record.get('vat_flag') == 'Y') {
                        return '<a style="color:red"  href="javascript:open_contract_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                    } else {
                        return '<a   href="javascript:open_contract_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                    }
            
                } else if (name == 'bp_id_n' && value) {
                    if (!record.get('tax_rate') && record.get('vat_flag') == 'Y') {
                        //return '<a style="color:red"  href="javascript:open_bp_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                        return '<a style="color:red"  href=#>' + value + '</a>';
            
                    } else {
                        // return '<a   href="javascript:open_bp_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                        return value;
                    }
                } else if (name == 'cashflow_flag' && value == 'Y') {
                    return '<a style="color:red"  href=#>' + value + '</a>';
                }
                return value;
            };
            
            
            /*    function leg450_open_contract_win(record_id, name, type) {
             var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'leg_legal_letter');
             var legal_record = $(ds_id).getCurrentRecord();
             var url_id = 'leg_uploadFile_id';
             if (type == '1') {
             url_id = 'leg_uploadFile_id';
             } else {
             url_id = 'leg_downloadFile_id';
             }
             var url = $(url_id).getUrl() + '?table_name=LEG_LEGAL_LETTER&header_id=' + legal_record.data['legal_letter_id'];
             new Leaf.Window({
             url: url,
             title: '附件',
             id: 'leg_legal_letter_id',
             width: 850,
             height: 400
             });
             }
             window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
             if (name == 'attachment') {
             return '<a href="javascript:leg450_open_contract_win(\'' + record.id + '\',\'' + 'attachment' + '\',' + '2' + ')">' + '附件' + '</a>';
             }
             return value;
             }; */
            /*
             window['${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {
             var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'leg_legal_fee');
             if(ds.id == ds_id && name=='tax_rate' && value){
             var amount = parseFloat(record.get('amount'));
             var tax_rate = parseFloat(value);
             var net_amount = (amount/(1+tax_rate)).toFixed(2);
             var tax_rate_field = record.getField('tax_rate');
             if(value){
             if (tax_rate < 0 || tax_rate > 1) {
             Leaf.showMessage('提示', '税率应在0到1之间!', null, 350);
             record.set('tax_rate', null);
             tax_rate_field.setValue(null);
             record.set('vat_fee', null);
             record.set('net_fee', null);
             return;
             }
             record.set('vat_amount',(amount - net_amount).toFixed(2));
             record.set('net_amount',net_amount);
             }else{
             record.set('vat_amount','');
             record.set('net_amount',amount);
             }
             } else if (ds.id == ds_id && name == 'amount' && record.get('tax_rate')) {
             var tax_rate = parseFloat(record.get('tax_rate')== undefined ? 0 : record.get('tax_rate'));
             var amount = parseFloat(value);
             var net_amount = (amount/(1+tax_rate)).toFixed(2);
             var tax_rate_field = record.getField('tax_rate');
             if (value) {
             if (tax_rate < 0 || tax_rate > 1) {
             Leaf.showMessage('提示', '税率应在0到1之间!', null, 350);
             record.set('tax_rate', null);
             tax_rate_field.setValue(null);
             record.set('vat_fee', null);
             record.set('net_fee', null);
             return;
             }
             record.set('vat_amount', (amount - net_amount).toFixed(2));
             record.set('net_amount', net_amount);
             } else {
             record.set('vat_amount', '');
             record.set('net_amount', amount);
             }
             }
             }; */
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>