acp_invoice_create_invoice.lview 11.4 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
<?xml version="1.0" encoding="UTF-8"?>
<!--
	&author:DJ
	$date:2013/05/08
	$purpose:发票创建
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query model="basic.sys_session_info" rootPath="default_value_record"/>
        <a:model-query model="acp.ACP510.acp_invoice_group_billing_method" rootPath="group_billing_method_list"/>
    </a:init-procedure>
    <a:view>
        <a:link id="svcLink_create_invoice" url="${/request/@context_path}/modules/acp/ACP510/acp_invoice_create.lsc"/>
        <a:link id="acp_invoice_attachment_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:screen-include screen="modules/hls/hls_common_javascript.lview"/>
        <script type="text/javascript"><![CDATA[
            function createScreen_close() {
                var win = $('acp_invoice_create_invoice');
                win.close();
            }
            //var create_flag = false;
            
            function createScreen_create() {
                var win = $('acp_invoice_create_invoice');
            
                f_hls.winMask(win);
            
                var ds = $('headDs');
                var selectds = $('selectedDs');
                var selectRecord = selectds.getAll();
                for (var i = 0;i < selectRecord.length;i++) {
                    var due_amount = selectRecord[i].get('due_amount');
                    var billing_amount = selectRecord[i].get('billing_amount');
                    if (billing_amount > due_amount) {
                        Leaf.showMessage('提示', '本次开票金额不能超出应付金额!');
                        f_hls.winNoMask(win);
                        return '';
                    } else {
                        if (!ds.validate() || !$('selectedDs').validate()) {
                            f_hls.winNoMask(win);
                            return;
                        }
                        var datas = ds.getJsonData();
            
                        f_hls.winNoMask(win);
            
            
                        Leaf.showConfirm('${l:HLS.PROMPT}', '是否确认开票?', function() {
                            //  f_hls.winMask(win);
                            // Leaf.request({
                            // url: $('svcLink_create_invoice').getUrl(),
                            // para: datas,
                            // success: function(res) {
                            // f_hls.winNoMask(win);
                            // createScreen_close();
                            // // create_flag = true;
                            // contractDs_grid_query();
                            // },
                            // failure: function() {
                            // f_hls.winNoMask(win);
                            // },
                            // error: function() {
                            // f_hls.winNoMask(win);
                            // },
                            // scope: this
                            // });
                            ds.submit();
                        }, function() {
                            //	f_hls.winNoMask(win);
                        });
                    }
                }
            
            
            }
            
            function unSelect_selectedDs(ds, record) {
                record.dirty = false;
            }
            
            function onSelect_selectedDs(ds, record) {
                record.dirty = true;
            }
            
            function onLoad_selectedDs(ds) {

                var tax_amount;
                var record;
                //ds.selectAll.defer(5,ds);
                for (var i = 0;i < ds.getAll().length;i++) {
                    record = ds.getAt(i);
                    record.dirty = true;
                    //record.set('1',1);
                }
            
            }
            
            function detail_upload_window(record_id) {
            
                var url = $('acp_invoice_attachment_uploadFile_id').getUrl() + '?table_name=ACP_INVOICE_LN&header_id=' + record_id;
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'insurance_records_uploadFile_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {});
            }
            
            function attachment_upload(val, rec, name) {
                return '<a href=javascript:detail_upload_window(' + rec.get('cashflow_id') + ')>附件上传</a>';
            }
            
            function updateHandler(ds, record, name, value, oldValue) {

                if (name === 'billing_amount') {
                    if (Ext.isEmpty(value)) {
                        record.set('tax_amount', null);
                    } else {
                        var due_amount = record.get('due_amount');
                        var tax_type_rate = record.get('tax_type_rate');
                        if (due_amount < value) {
                            Leaf.showMessage('提示', '本次开票金额不能超出应付金额!');
                            return '';
                        } else {
            
                            record.set('tax_amount', (value / (1 + tax_type_rate) * tax_type_rate).toFixed(0));
                        }
                    }
                }
            }
            
            function ds_submitsuccess(ds) {
                createScreen_close();
            }
        ]]></script>
        <style><![CDATA[
			.item-radio-option {
				margin-right: 50px;
			}
		]]></style>
        <a:dataSets>
            <a:dataSet id="invoiceKindDs" lookupCode="ACR510_INVOICE_KIND"/>
            <a:dataSet id="headDs" autoCreate="true" submitUrl="${/request/@context_path}/modules/acp/ACP510/acp_invoice_create.lsc">
                <a:fields>
                    <a:field name="company_id" defaultValue="${/parameter/@company_id}"/>
                    <a:field name="group_billing_method" defaultValue="GROUP_BY_TIMES"/>
                    <a:field name="accounting_date" defaultValue="${/model/default_value_record/record/@today}" required="true"/>
                    <a:field name="invoice_date" defaultValue="${/model/default_value_record/record/@today}" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="ds_submitsuccess"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="selectedDs" autoQuery="true" bindName="line_info" bindTarget="headDs" fetchAll="true" model="acp.ACP510.acp_invoice_create">
                <a:fields>
                    <a:field name="billing_amount" required="true"/>
                    <a:field name="tax_amount" required="true"/>
                    <a:field name="product_name" required="true"/>
                    <a:field name="invoice_kind"/>
                    <a:field name="invoice_kind_desc" displayField="code_value_name" options="invoiceKindDs" required="true" returnField="invoice_kind" valueField="code_value"/>
                    <a:field name="billing_object"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="onLoad_selectedDs"/>
                    <!-- <a:event name="select" handler="onSelect_selectedDs"/> -->
                    <!-- <a:event name="unselect" handler="unSelect_selectedDs"/> -->
                    <a:event name="update" handler="updateHandler"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="createScreen_close" text="HLS.CLOSE"/>
                <a:gridButton click="createScreen_create" text="创建"/>
            </a:screenTopToolbar>
            <a:form column="3">
                <a:datePicker name="invoice_date" bindTarget="headDs" prompt="ACR.INVOICE_DATE"/>
                <a:datePicker name="accounting_date" bindTarget="headDs" prompt="HLS.ACCOUNT_DATE"/>
            </a:form>
            <a:tabPanel marginHeight="220" marginWidth="30">
                <a:tabs>
                    <a:tab prompt="ACR510.TAB.BILLING_INFO" width="100">
                        <a:grid id="selectedDs_grid" bindTarget="selectedDs" marginHeight="270" marginWidth="60">
                            <a:columns>
                                <a:column name="contract_number" width="150"/>
                                <a:column name="times" align="right" width="40"/>
                                <a:column name="cf_item_desc"/>
                                <a:column name="product_name" editor="selectedDs_grid_editor_tf" width="150"/>
                                <a:column name="invoice_kind_desc" editor="selectedDs_grid_editor_comb"/>
                                <a:column name="currency_desc" align="center"/>
                                <a:column name="due_amount" align="right" renderer="Leaf.formatMoney"/>
                                <!-- <a:column name="received_amount" align="right" renderer="Leaf.formatMoney"/> -->
                                <a:column name="cf_billing_amount" align="right" renderer="Leaf.formatMoney"/>
                                <a:column name="billing_amount" align="right" editor="selectedDs_grid_editor_nf" renderer="Leaf.formatMoney"/>
                                <a:column name="tax_amount" align="right" editor="selectedDs_grid_editor_nf" prompt="开票税金" renderer="Leaf.formatMoney"/>
                                <a:column align="center" prompt="附件上传" renderer="attachment_upload" width="80"/>
                            </a:columns>
                            <a:editors>
                                <a:comboBox id="selectedDs_grid_editor_comb"/>
                                <a:textField id="selectedDs_grid_editor_tf"/>
                                <a:numberField id="selectedDs_grid_editor_nf"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                    <a:tab prompt="ACR510.TAB.ASSIST_INFO" width="100">
                        <a:grid id="selectedDs_grid_2" bindTarget="selectedDs" marginHeight="270" marginWidth="60">
                            <a:columns>
                                <a:column name="contract_number" width="150"/>
                                <a:column name="times" align="right" width="40"/>
                                <a:column name="cf_item_desc"/>
                                <a:column name="contract_name" width="200"/>
                                <a:column name="project_number" width="150"/>
                                <a:column name="project_name" width="200"/>
                                <a:column name="last_received_date" renderer="Leaf.formatDate" width="80"/>
                                <a:column name="exchange_rate" align="right"/>
                                <a:column name="exchange_rate_type_desc"/>
                            </a:columns>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
            <!--<a:fieldSet title="ACR.GROUP_BILLING_METHOD">
                <a:radio name="group_billing_method" bindTarget="headDs" labelField="code_value_name" options="/model/group_billing_method_list" prompt="" radioSeparator="" valueField="code_value" width="600"/>
            </a:fieldSet>-->
        </a:screenBody>
    </a:view>
</a:screen>