高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<apex:page Controller="ConInvoicedetailsController" showHeader="true" tabStyle="ConInvoiceList__tab" sidebar="true" id="allPage" action="{!init}" title="发票">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<script>
function setFocusOnLoad() {}
function bodyOnLoad(){setFocusOnLoad();}
function checkAll() {
    var productCount = j$(escapeVfId('invoiceOrderRecoedsCount')).value();
    if (j$(escapeVfId('checker')).attr('checked') == 'checked') {
        for (var i = 0; i < productCount; i++) {
            j$(escapeVfId('allPage:allForm:allBlock:invoiceOrderRecoedsSection:consumableorderdetails1Records:' + i + ':consumablesCountproRowCheckbox')).attr('checked',true);
            var z =  parseFloat(j$(escapeVfId('allPage:allForm:allBlock:invoiceOrderRecoedsSection:consumableorderdetails1Records:' + i+':consumablesCount')).value());
            var x = j$(escapeVfId('allPage:allForm:allBlock:invoiceOrderRecoedsSection:consumableorderdetails1Records:' + i+':InvoiceUnitprice')).value().replace(/,/g,'');;
            var c = parseFloat(z * x).toFixed(2);
            document.getElementById('allPage:allForm:allBlock:invoiceOrderRecoedsSection:consumableorderdetails1Records:' + i + ':invoiceAllprice').innerHTML = c;
        }
    } else {
        for (var i = 0; i < productCount; i++) {
            j$(escapeVfId('allPage:allForm:allBlock:invoiceOrderRecoedsSection:consumableorderdetails1Records:' + i + ':consumablesCountproRowCheckbox')).attr('checked',false);
            document.getElementById('allPage:allForm:allBlock:invoiceOrderRecoedsSection:consumableorderdetails1Records:' + i + ':invoiceAllprice').innerHTML = 0.00;
        }
    }
    SumCompute();
}
 
function saveJs() {
    save();
}
//点击金额事件
function ComputePriceCheck(j){
    var z,x,c;
    var a = j.id;
    var i=a.substring(0,a.lastIndexOf(':'));// <apex:variable value="{!1}" var="lineNo" />
    var a=document.getElementById (i+":invoiceAllprice");
    z  =  parseFloat(j$(escapeVfId(i+':consumablesCount')).value());
    var k = j$(escapeVfId(i+':InvoiceUnit')).value();
    if(isNaN(z)){z=0.00;}
    //if(k == '个'){
        if(z<0||!(/^\d+$/.test(z))){
            window.alert("开票单位是个时,发票数量必须是整数!");
            z=0; 
            j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
            j$(escapeVfId(i+':consumablesCount')).val(0);
        }
    //}
    x = j$(escapeVfId(i +':InvoiceUnitprice')).value().replace(/,/g,'');
    if (j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked') == 'checked') {
        c = parseFloat(z * x).toFixed(2);
    }else{
        c = 0;
    }
    a.innerHTML = c;
    SumCompute();
}
//点击数量事件
function ComputeCountCheck(j) {
    var z,x,c,v;
    var a = j.id;
    var i=a.substring(0,a.lastIndexOf(':'));
    var a=document.getElementById (i+":invoiceAllprice");
    var x = j$(escapeVfId(i+':InvoiceUnitprice')).value();
    z  =  parseFloat(j$(escapeVfId(i+':consumablesCount')).value());
    v  =  j$(escapeVfId(i+':InvoiceProNotcount')).value();
    //出库单位
    var dw = j$(escapeVfId(i+':BoxPiece')).value();
    //规格
    var p = j$(escapeVfId(i+':PakingListManual')).value();
    //开票单位
    var k = j$(escapeVfId(i+':InvoiceUnit')).value();
    //z= z.replace(/,/g,'');
    if(isNaN(z)){z=0.00;}
    /*if(isNaN(z)){
        window.alert("发票数量必须是整数!");
        z=0.00;
        j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
        j$(escapeVfId(i+':consumablesCount')).val(0);}*/
    
    if(z!=null&&z!=0&&z!=''){
        if(dw == '盒' && k == '个'){
            var wsl = (v * p).toFixed(0);
            if(z<0||!(/^\d+$/.test(z))){
                window.alert("发票数量必须是整数!");
                z=0; 
                j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
                j$(escapeVfId(i+':consumablesCount')).val(0);
            }else if (z > wsl){
                window.alert("发票数量不能超过还没发票数量!");
                j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
                j$(escapeVfId(i+':consumablesCount')).val(0);
                a.innerHTML = 0.00;
            }else{
                j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',true);
                x = j$(escapeVfId(i+':InvoiceUnitprice')).value().replace(/,/g,'');
                c = parseFloat(z * x).toFixed(2);
                //c = number_format_common (c,2,'.',',');
                a.innerHTML = c;
            }
        }else{
            //if(k == '个'){
                if(z<0||!(/^\d+$/.test(z))){
                    window.alert("发票数量必须是整数!");
                    z=0; 
                    j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
                    j$(escapeVfId(i+':consumablesCount')).val(0);
                }else if (z > v){
                    window.alert("发票数量不能超过还没发票数量!");
                    j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
                    j$(escapeVfId(i+':consumablesCount')).val(0);
                    a.innerHTML = 0.00;
                }else{
                    j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',true);
                    x = j$(escapeVfId(i+':InvoiceUnitprice')).value().replace(/,/g,'');
                    c = parseFloat(z * x).toFixed(2);
                    //c = number_format_common (c,2,'.',',');
                    a.innerHTML = c;
                }
            /*}else{
                if (z > v){
                    window.alert("发票数量不能超过还没发票数量!");
                    j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
                    j$(escapeVfId(i+':consumablesCount')).val(0);
                    a.innerHTML = 0.00;
                }else{
                    j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',true);
                    x = j$(escapeVfId(i+':InvoiceUnitprice')).value().replace(/,/g,'');
                    c = parseFloat(z * x).toFixed(2);
                    //c = number_format_common (c,2,'.',',');
                    a.innerHTML = c;
                }
            }*/
            
        }
        
    }else{
        j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',false);
        a.innerHTML = 0;
    }
    SumCompute();
}
 
function changeInvoiceUnitprice(j,BoxPiece){
    var p,u,c,x,b;
    var val =j.value;
    var a = j.id;
    var i=a.substring(0,a.lastIndexOf(':'));
    //发票票面金额(元)
    var a=document.getElementById (i+":invoiceAllprice");
    //发票单价
    var v =document.getElementById (i+":InvoiceUnitprice");
    
    //发票数量
    var z = j$(escapeVfId(i+':consumablesCount')).value();
    //规格
    p = j$(escapeVfId(i+':PakingListManual')).value();
    if(BoxPiece == '盒' && val == '个'){
        j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',true);
        //出货单价
        u = j$(escapeVfId(i+':DeliveryListRMB')).value().replace(/,/g,'');
        //发票单价
        c = parseFloat(u / p).toFixed(8);
        //发票金额
        x = parseFloat(c * z).toFixed(2);
        
        c = number_format_common (c,8,'.',',');
        
        v.innerHTML = c;
        a.innerHTML = x;
    }else if(BoxPiece == '盒' && val == '盒'){
        j$(escapeVfId(i+':consumablesCountproRowCheckbox')).attr('checked',true);
        //出货单价
        u = j$(escapeVfId(i+':DeliveryListRMB')).value().replace(/,/g,'');
        //发票单价
        c = parseFloat(u).toFixed(8);
        //发票金额
        x = parseFloat(c * z).toFixed(2);
        c = number_format_common (c,8,'.',',');
        
        v.innerHTML = c;
        a.innerHTML = x;
    }
    SumCompute();
}
 
//要求多向联动
function SumCompute(){
    var SumPrice = 0;
    var consumablesCounttestPriceJList = j$("span[Id$='invoiceAllprice']").value();
    //判断是否为数组 为数组时去掉空值计算
    if (consumablesCounttestPriceJList.constructor == Array) {
        for (var i = 0; i < consumablesCounttestPriceJList.length; i++) {
            var outer = consumablesCounttestPriceJList[i];
            if (isNaN(parseFloat(consumablesCounttestPriceJList[i]))) {
                consumablesCounttestPriceJList.splice(i,1);
                i= i-1;
            }
        }
        var str=consumablesCounttestPriceJList.join("+");
        var SumPrice =eval(str);
    }else{
        var SumPrice = consumablesCounttestPriceJList;
    }
    SumPrice = parseFloat(SumPrice).toFixed(2);
    SumPrice = number_format_common (SumPrice,2,'.',',');
    document.getElementById("allPage:allForm:allBlock:invoiceOrderRecoedsSection:sumPrice_buttom").innerHTML = SumPrice;
}
window.sfdcPage.appendToOnloadQueue(function() {SumCompute();});
 
function closeandreloadJs(){
    window.opener.top.location.reload();
    window.top.close();
}
 
</script>
<style>
    .dateFormat  {
        display: none;
    }
    tr.dataRow {
        background-color:white;
    }
    td.columus {
        background-color:white;
        text-align: right;
    }
    tr.dataRow:hover {
        background-color: #e3f3ff;
    }
</style>
    <apex:form id="allForm">
         <apex:actionFunction name="save" action="{!save}" rerender="message" onComplete="unblockUI();">
        </apex:actionFunction>
        <apex:pageBlock id="allBlock" >
            <apex:pageBlock >
                <table>
                    <colgroup>
                        <col width="150px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="90px"/>
                        <col width="100px"/>
                        <col width="10px"/>
                        <col width="85px"/>
                        <col width="100px"/>
                        <col width="10px"/>
                        <col width="70px"/>
                        <col width="100px"/>
                    </colgroup>
                    <tr>
                        <td></td>
                        <td  colspan="2"><apex:commandButton value="确定" onclick="saveJs(); return false;" style="width: 150px;" rerender="dummy" /></td>
                        <td></td>
                    </tr>
                </table>
 
                <apex:pageblocksection columns="1" title="发票信息" collapsible="false">
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="发票号:"/>
                        <apex:outputText value="{!invoicecode.Name}"/>
                    </apex:pageBlockSectionItem>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="客户名:"/>
                        <apex:outputText value="{!invoicecode.ShipmentAccount__c}"/>
                    </apex:pageBlockSectionItem>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="科室:"/>
                        <apex:outputText value="{!invoicecode.Order_ForCustomerText__c}"/>
                    </apex:pageBlockSectionItem>
                </apex:pageblocksection>
 
                <apex:pageblocksection columns="1" title="出库单" collapsible="false">
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="出库单编码:"/>
                        <apex:outputField value="{!coc.name}"/>
                    </apex:pageBlockSectionItem>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="出库日期:"/>
                        <apex:outputField value="{!coc.Outbound_Date__c}"/>
                    </apex:pageBlockSectionItem>
                </apex:pageblocksection>
            </apex:pageBlock>
            <apex:outputPanel id="message">
                <apex:pageMessages />
            </apex:outputPanel>
 
            <apex:pageBlock id="invoiceOrderRecoedsSection" title="出库单明细">
                    <input type="hidden" id="invoiceOrderRecoedsCount" value="{!invoiceOrderRecoedsCount}" />
                    <table class="list" border="0" cellpadding="0" cellspacing="0">
                        <tr class="headerRow">
                            <th><input type='checkbox' onClick='checkAll()' id='checker'/>选择</th>
                            <th>产品型号</th>
                            <th>规格</th>
                            <th>出货单价(元)</th>
                            <th>出货数量</th>
                            <th>返品数量</th>
                            <th>出库单位</th>
                            <th>已发票数量</th>
                            <th>还没发票数量</th>
                            <th>开票单位</th>
                            <th>发票单价</th>
                            <th>发票数量</th>
                            <th>发票票面金额(元)</th>
                        </tr>
                    <apex:repeat value="{!consumableorderdetails1Records}" var="records" id="consumableorderdetails1Records">
                        <tr class="dataRow">
                            <td>
                                <apex:inputCheckbox onclick="ComputePriceCheck(this)" value="{!records.check}" id="consumablesCountproRowCheckbox" />
                                <apex:inputCheckbox value="{!records.oldCheck}" id="proRowOldCheckbox" style="display:none"/></td>
                            <td Class="dataCell">
                                <apex:outputField value="{!records.esd.Asset_Model_No__c}"/></td>
                            <td class="dataCell" align="right"><apex:outputText value="{!records.Packing_list_manual}" id="PakingListManual"/></td>
                            <td class="dataCell" align="right"><apex:outputField value="{!records.esd.Delivery_List_RMB__c}" id="DeliveryListRMB"/></td>
                            <td class="dataCell" align="right"><apex:outputField value="{!records.esd.Shipment_Count__c}" id="ShipmentCount"/></td>
                            <td class="dataCell" align="right"><apex:outputField value="{!records.esd.RrturnPro_count__c}"/></td>
                            <td class="dataCell"><apex:outputField value="{!records.esd.Box_Piece__c}" id="BoxPiece"/></td>
                            <td class="dataCell" align="right"><apex:outputField value="{!records.esd.Invoiced_Procount__c}" id="InvoicedProcount"/></td>
                            <td class="dataCell" align="right"><apex:outputField value="{!records.esd.InvoiceProNot_count__c}" id="InvoiceProNotcount"/></td>
                            <td class="dataCell">
                                <apex:selectList value="{!records.esd.Invoice_Unit__c}" size="1" style="width:75px;" onchange="changeInvoiceUnitprice(this,'{!records.esd.Box_Piece__c}');return false;" disabled="{!IF(records.esd.Box_Piece__c =='个' || (records.esd.Box_Piece__c =='盒' && records.Packing_list_manual ==1),true,false)}" id="InvoiceUnit"><apex:selectOptions value="{!records.Invoice_UnitOpts}"/>
                                </apex:selectList>
                            </td>
                            <td class="dataCell" align="right"><apex:outputField value="{!records.esd.Invoice_Unitprice__c}" id="InvoiceUnitprice"/></td>
                            <td class="dataCell"><div style="width:2px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div><apex:inputText onblur="ComputeCountCheck(this)" value="{!records.invoiceCount}" id="consumablesCount"/></td>
                            <td class="dataCell" align="right"><apex:outputText value="{!records.invoiceAllprice}" id="invoiceAllprice"/></td>
                        </tr>
                    </apex:repeat>
                    </table>
                    <table class="list" cellpadding="0" cellspacing="0" border="none">
                        <tr>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;text-align: right;"><apex:outputText id="sumPrice_buttom" value="{!sumPrice}"/></td>
                        </tr>
                    </table>
               </apex:pageBlock>
        </apex:pageBlock>
    </apex:form>
</apex:page>