高章伟
2022-03-18 4bfe21c4b5ddc089ae5a95f4b10f6cff148b690d
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
<apex:page controller="ConsumableSampleApplyController" sidebar="false" action="{!init}" id="Page">
    <apex:stylesheet value="{!URLFOR($Resource.jquerysuggestcss)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquerysuggestjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.ConsumableSampleApplyJS)}"/>
    <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquerydoubletapjs)}"/>
    <script type="text/javascript">
        var displayCost = '{!displayCost}';
        var quoid = '{!quoid}';
        var Session_ID = '{!$Api.Session_ID}';
        var Price_Valid_Period = '{!$Label.Price_Valid_Period}';
        var Message_001 = '{!JSENCODE($Label.Message_001)}';
        var Message_Please_Save_Quote = '{!JSENCODE($Label.Please_Save_Quote)}';
        var Message_Check_Your_Clipboard = '{!JSENCODE($Label.Check_Your_Clipboard)}';
        var Error_Message3 = '{!JSENCODE($Label.Error_Message3)}';
        var Error_Message11 = '{!JSENCODE($Label.Error_Message11)}';
        var Error_Message29 = '{!JSENCODE($Label.Error_Message29)}';
        var Error_Message33 = '{!JSENCODE($Label.Error_Message33)}';
        var Error_Message34 = '{!JSENCODE($Label.Error_Message34)}';
        var Error_Message35 = '{!JSENCODE($Label.Error_Message35)}';
        var Error_Message36 = '{!JSENCODE($Label.Error_Message36)}';
        var Error_Message40 = '{!JSENCODE($Label.Error_Message40)}';
        var Confirm_ChangedAfterPrint = '打印后行信息有变化,是否继续操作(报价编码会变新)?';
        var Confirm_PriceRefresh = '报价作成后{!$Label.Price_Valid_Period}天,还没有更新过价格,需要执行{!$Label.Status_Update}?';
        var Confirm_saveBtn = '您选择了委托人员,确定只是保存吗(不进行委托)?';
        window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });
        var openQuoteExcelImportWindow = null;
        
        function selectAll() {
            var checklist = j$("input[name='checklist']");
            var all = j$(escapeVfId("checkAll"));
            for(var i = 0; i < checklist.length; i++){
                if (all[0].checked == true) {
                    checklist[i].checked = true;
                } else {
                    checklist[i].checked = false;
                }
            }
        }
        
        function openpdf() {
            var qid = j$(escapeVfId("Page:mainForm:hiddenQuoid")).value();
            if (qid == '') {
                alert('请先做成消耗品样品。');
                return false;
            }
            if (window.confirm('是否新建SIS报告书?')) {
                try {
                    sforce.connection.sessionId = "{!GETSESSIONID()}";
                    var accid = j$(escapeVfId("Page:mainForm:hiddenHpid")).value();
                    var recordType = "SIS";
                    var repOwnerId = '{!$User.Id}';
                    
                    // 明細の同梱数を取得
                    var cntArray = new Array();
                    var result = sforce.connection.query("select Id, Product2__c, Product2__r.Packing_list_manual__c from ConsumableSampleLineItem__c where ConsumableSample__c =\'" + qid + "\'");
                    var records = result.getArray("records");
                    for (var i = 0; i < records.length; i++) {
                        var manualCnt = records[i].Product2__r.Packing_list_manual__c;
                        if (manualCnt == null || manualCnt <= 0) {
                            manualCnt = 1;
                        }
                        //if (records[i].Product2__r.Packing_list_manual__c != "") {
                        for (var j = 1; j <= manualCnt; j++) {
                            cntArray.push(records[i].Product2__c);
                        }
                        //}
                    }
                    
                    var pdfno = sforce.apex.execute("ControllerUtil", "selectCommonSequence", {valueField: 'EvaluationPDF_NextValue__c', formatField: 'EvaluationPDF_Format__c'});
                    // 報告書を複数作成
                    for (var i = 0; i < cntArray.length; i++) {
                        //新建OPD报告书
                        var rtn = sforce.apex.execute("Add_Report", "addReportOPWithEvaluationPDF", 
                            {repOwnerId: repOwnerId,
                             reportId: null,
                             dailyReportId: null,
                             eventId: null,
                             recordType: recordType,
                             aId: accid,
                             visitor1: null,
                             visitor2: null,
                             visitor3: null,
                             visitor4: null,
                             visitor5: null,
                             opp1: null,
                             opp2: null,
                             opp3: null,
                             opp4: null,
                             opp5: null,
                             reportDate: null,
                             evaluationPDFNumber: pdfno,
                             pro1: cntArray[i]
                            }
                        );
                    }
                    window.open('/apex/BeforeOPDPDF?csid=' + encodeURI(qid) + '&pdfNo=' + encodeURI(pdfno), 'BeforeOPDPDF');
                } catch(e) {
                    alert(e); 
                }
            } else {
                window.open('/apex/BeforeOPDPDF?csid=' + encodeURI(qid), 'BeforeOPDPDF');
            }
        }
    </script>
    <style type="text/css">
        td .dateFormat  {
            display: none;
        }
        
        div#iframelike {
            color: #fff;
            height: 300px;
            overflow: auto;
        }
        div#iframelikeheader {
            color: #fff;
            height: 23px;
            overflow: auto;
        }
        input {
            font-size: 10.5px;
        }
        body {
            font-size: 10.5px;
        }
        
        .visitorplace_results {
            border: 1px solid gray;
            background-color: white;
            padding: 0;
            margin: 0;
            list-style: none;
            position: absolute;
            z-index: 10000;
            display: none;
            overflow:auto;
            white-space:nowrap;
            width:400px;
            height:250px;
        }
        .visitorplace_results li {
            padding: 2px 5px 2px 0px;
            margin-left : 2px;
            color: #101010;
            text-align: left;
        }
    </style>
 
    <apex:form id="mainForm">
        <apex:outputText id="hiddenQuoid" value="{!quoid}" style="display:none;"/>
        <apex:outputText id="hiddenHpid" value="{!quo.Contact__r.AccountId}" style="display:none;"/>
        
        <apex:inputHidden id="changedAfterPrint" value="{!changedAfterPrint}"/>
        <apex:inputHidden id="productStatusUpdated" value="{!productStatusUpdated}"/>
        <apex:actionFunction action="{!excelImport}" name="excelImport" reRender="mainForm" oncomplete="unblockUI();calPriceAll();">
            <apex:param assignTo="{!excel_text}" name="select_index" value=""/>
        </apex:actionFunction>
        <apex:actionFunction action="{!Save}" name="Save" reRender="mainForm,message1" oncomplete="unblockUI();"/>
        <apex:actionFunction action="{!OppReflection}" name="OppReflection" reRender="mainForm,message1" oncomplete="unblockUI();"/>
        <apex:actionFunction action="{!ApprovalBtn}" name="ApprovalBtn" reRender="mainForm,message1" oncomplete="unblockUI();"/>
        <apex:pageBlock id="block">
            <apex:inputHidden value="{!quo.CurrencyIsoCode}" id="CurrencyIsoCode"/>
            <apex:inputHidden value="{!baseUrl}" id="baseUrl"/>
            <apex:outputPanel id="message1">
                <apex:messages styleClass="editListError"/>
            </apex:outputPanel>
            <apex:outputPanel rendered="{!errorflg}" >
                <table width="100%">
                    <tr>
                        <td align="left"><div class="errorMsg">{!errorMessage}</div></td>
                    </tr>
                </table>
            </apex:outputPanel>
            <apex:outputPanel rendered="{!Messageflg}" >
                <table width="100%">
                    <tr>
                        <td align="left">{!Message}</td>
                    </tr>
                </table>
            </apex:outputPanel>
            <div>
                <table border="0">
                    <tr>
                        <th style="text-align:right;width:100px;">{!$ObjectType.ConsumableSample__c.fields.Name.Label}</th>
                        <td style="text-align:left;width:110px;"><apex:outputField value="{!quo.Name}" style="width:100px;"/></td>
                        <th style="text-align:right;width:100px;">{!$ObjectType.Contact.fields.Hospital_name__c.Label}</th>
                        <td style="text-align:left;width:100px;"><apex:outputField value="{!quo.Contact__r.Hospital_name__c}" style="width:90px;"/></td>
                        <th style="text-align:right;width:100px;">{!$ObjectType.ConsumableSample__c.fields.Contact__c.Label}</th>
                        <td style="text-align:left;width:100px;">
                            <div class="requiredInput"><div class="requiredBlock"></div><apex:inputField value="{!quo.Contact__c}" style="width:75px;"/></div>
                        </td>
                        <th style="text-align:right;width:100px;">{!$ObjectType.ConsumableSample__c.fields.Expect_Arrive_Date__c.Label}</th>
                        <td style="text-align:left;width:100px;"><apex:inputField value="{!quo.Expect_Arrive_Date__c}" style="width:75px;"/></td>
                        <th style="text-align:right;width:100px;">{!$ObjectType.ConsumableSample__c.fields.Expect_Use_Date__c.Label}</th>
                        <td style="text-align:left;width:100px;"><apex:inputField value="{!quo.Expect_Use_Date__c}" style="width:75px;"/></td>
                    </tr>
                    <tr>
                        <th style="text-align:right;">{!$ObjectType.ConsumableSample__c.fields.Purpose__c.Label}</th>
                        <td style="text-align:left;" colspan="5"><apex:inputField value="{!quo.Purpose__c}" style="width:500px;"/></td>
                        <th style="text-align:right;">{!$ObjectType.ConsumableSample__c.fields.PIC__c.Label}</th>
                        <td style="text-align:left;"><apex:inputField value="{!quo.PIC__c}" style="width:75px;"/></td>
                    </tr>
                </table>
                <table border="0">
                    <tr>
                        <th style="width:40px;">&nbsp;</th>
                        <td style="width:150px;"></td>
                        <td style="width:150px;"><apex:commandButton onclick="openQuoteExcelImport(event);return false;" value="{!$Label.Excel_Import}" rerender="dummy"/></td>
                        <td style="text-align:right;width:80px;"><apex:commandButton rerender="dummy" id="Btn_RowDelete" onclick="radioChecker2('del');return false;" value="{!$Label.deleteLabel}" style="width:60px;"/></td>
                        <td style="width:150px;">
                            <apex:commandButton rerender="dummy" id="Btn_RowUp" onclick="radioChecker2('up');return false;" value="{!$Label.Row_Up}" style="width:60px;"/>
                            <apex:commandButton rerender="dummy" id="Btn_RowDown" onclick="radioChecker2('down');return false;" value="{!$Label.Row_Down}" style="width:60px;"/>
                        </td>
                        <th style="text-align:right;width:80px;">&nbsp;</th>
                        <th style="text-align:right;width:70px;">资产数量</th>
                        <td style="text-align:right;width:80px;"><apex:outputtext id="Asset_cnt" value="0" /></td>
                        <th style="text-align:right;width:70px;">耗材数量</th>
                        <td style="text-align:right;width:80px;"><apex:outputtext id="Consumable_cnt" value="0" /></td>
                        <th style="text-align:right;width:70px;">总计</th>
                        <td style="text-align:right;width:80px;">
                            <apex:outputtext id="Estimation_List_Price" value="{0, number, ###,##0.00}"><apex:param value="{!total_ListPrice}"/></apex:outputtext>
                            <apex:inputHidden id="hidden_Estimation_List" value="{!total_ListPrice}"/>
                        </td>
                    </tr>
                </table>
            </div>
            <table>
                <tr>
                    <td>&nbsp;</td>
                </tr>
            </table>
            <table style="width:1125px;" border="0">
                <tr>
                    <th style="text-align:center;width:20px;">&nbsp;<input type="checkbox" id="checkAll" onclick="selectAll()" style="width:15px;"/></th>
                    <th style="text-align:center;width:20px;">No</th>
                    <th style="text-align:center;width:150px;">{!$Label.Asset_No}</th>
                    <th style="text-align:center;width:100px;">{!$Label.SFDA_Status}</th>
                    <th style="text-align:center;width:100px;">Serial/Lot区分</th>
                    <th style="text-align:center;width:100px;">资产/耗材</th>
                    <th style="text-align:center;width:320px;">{!$Label.Product_Name}</th>
                    <th style="text-align:center;width:50px;">同捆数</th>
                    <th style="text-align:center;width:80px;">{!$Label.Quantity}</th>
                    <th style="text-align:center;width:85px;">ListPrice</th>
                    <th style="text-align:center;width:100px;">小计</th>
                </tr>
            </table>
            <div id="iframelike" style="width:1143px;">
                <input type="hidden" id="ListPriceTotal" value="0" />
                <input type="hidden" id="UnitPriceTotal" value="0" />
                <apex:pageblocktable value="{!activities}" var="s" id="lists" style="width:1125px;">
                    <apex:column style="width:20px;" >
                        <input type="checkbox" name="checklist" value="{!s.lineNo}" style="width:15px;"/>
                    </apex:column>
                    <apex:column style="width:20px;text-align:right;" >
                        <apex:outputLabel id="indexNo" value="{!IF(s.PageObject.Product2__c==null,null,s.lineNo + 1)}" style="width:15px;"/>
                    </apex:column>
                    <apex:column style="text-align:center;width:150px;">
                        <apex:inputText id="Assert" style="width:120px;" value="{!s.Asset_Model}" onclick="searchProduct('{!s.lineNo}',this.value)" />
                    </apex:column>
                    <apex:column style="width:100px;">
                        <apex:outputField style="width:90px;" id="Status__c" value="{!s.PageObject.SFDA_Status__c}"/>
                        <apex:inputHidden id="SFDA" value="{!s.PageObject.SFDA_Status__c}"/>
                    </apex:column>
                    <apex:column style="width:100px;">
                        <apex:outputText style="width:90px;" id="Serial_Lot" value="{!s.Serial_Lot}"/>
                    </apex:column>
                    <apex:column style="width:100px;">
                        <apex:outputText style="width:90px;" id="Asset_loaner_category" value="{!s.Asset_loaner_category}"/>
                    </apex:column>
                    <apex:column style="width:320px;">
                        <div id="Page:mainForm:block:lists:{!s.lineNo}:NameLink"><apex:outputLink style="width:300px;" value="{!baseUrl}/{!s.PageObject.Product2__c}" id="Nametext1" target="_blank">{!s.PageObject.Name__c}</apex:outputLink></div>
                        <apex:inputHidden id="Name__c" value="{!s.PageObject.Name__c}"/>
                    </apex:column>
                    <apex:column style="width:50px;text-align:right;">
                        <apex:outputText style="width:45px;" id="Packing_list_manual" value="{!s.Packing_list_manual}"/>
                    </apex:column>
                    <apex:column style="text-align:center;width:80px;">
                        <apex:inputField id="Quantity" style="width:50px;text-align:right;" value="{!s.PageObject.Quantity__c}" onChange="calPrice('{!s.lineNo}')" />
                        <script type="text/javascript">
                            j$(escapeVfId('Page:mainForm:block:lists:'+ {!s.lineNo} + ':Quantity')).attr('readonly',true);
                        </script>
                    </apex:column>
                    <apex:column style="width:85px;text-align:right;">
                        <apex:outputPanel layout="none" rendered="{!$ObjectType.ConsumableSampleLineItem__c.fields.ListPrice__c.accessible}" >
                            <apex:outputText style="width:85px;" id="ListPricetext" value="{0, number, ###,##0.00}">
                                <apex:param value="{!s.ListPrice_Page}" />
                            </apex:outputText>
                        </apex:outputPanel>
                        <apex:inputHidden id="ListPrice" value="{!s.ListPrice_Page}"/>
                        <apex:outputPanel layout="none" rendered="{!!$ObjectType.ConsumableSampleLineItem__c.fields.ListPrice__c.accessible}" >
                            <span style="width:85px;text-align:right;" id="Page:mainForm:block:lists:{!s.lineNo}:ListPricetext">{!IF(s.PageObject.Product2__c == null, ' ', 0.00)}</span>
                            <script type="text/javascript">
                                j$(escapeVfId('Page:mainForm:block:lists:'+ {!s.lineNo} + ':ListPrice')).val(toNum(0));
                            </script>
                        </apex:outputPanel>
                    </apex:column>
                    <apex:column style="width:100px;text-align:right;">
                        <apex:outputPanel layout="none" rendered="{!$ObjectType.ConsumableSampleLineItem__c.fields.ListPrice__c.accessible}" >
                            <apex:outputText style="width:80px;" id="ListPriceTotalText" value="{0, number, ###,##0.00}">
                                <apex:param value="{!s.ListPriceTotal_Page}" />
                            </apex:outputText>
                        </apex:outputPanel>
                        <apex:inputHidden id="ListPriceTotal" value="{!s.ListPriceTotal_Page}"/>
                        <apex:outputPanel layout="none" rendered="{!!$ObjectType.ConsumableSampleLineItem__c.fields.ListPrice__c.accessible}" >
                            <span style="width:80px;text-align:right;" id="Page:mainForm:block:lists:{!s.lineNo}:ListPriceTotalText">{!IF(s.PageObject.Product2__c == null, ' ', 0.00)}</span>
                            <script type="text/javascript">
                                j$(escapeVfId('Page:mainForm:block:lists:'+ {!s.lineNo} + ':ListPriceTotal')).val(toNum(0));
                            </script>
                        </apex:outputPanel>
                        <apex:inputHidden id="Product_Id" value="{!s.PageObject.Product2__c}"/>
                        <apex:inputHidden id="lineNo" value="{!s.lineNo}"/>
                    </apex:column>
                </apex:pageBlockTable>
            </div>
 
            <BR></BR>
            <table border="0">
                <tr>
                    <th style="width:650px;" align="left">
                        {!$ObjectType.ConsumableSample__c.fields.Reason__c.Label}<br/>
                        <apex:inputField value="{!quo.Reason__c}" style="width:650px;height:55px;"/>
                    </th>
                    <td>
                        <table border="0">
                            <tr>
                                <th style="width:15px">&nbsp;</th>
                                <td style="width:100px;" align="right"><apex:commandButton onclick="save2btn();return false;" reRender="IraiUserId,hiddenQuoid,message1" value="{!$Label.Save_Button}" style="width:90px;" disabled="{!Save_button}"/></td>
                                <td style="width:100px;" align="right"><apex:commandButton onclick="oppReflection2btn();return false;" rerender="IraiUserId,hiddenQuoid,message1" value="{!$Label.Opp_Button}" style="width:90px;" disabled="{!Save_button}"/></td>
                                <td style="width:100px;" align="right"><apex:commandButton onclick="approval2btn();return false;" reRender="IraiUserId,hiddenQuoid,message1" value="提交申请" style="width:90px;" disabled="{!Save_button}"/></td>
<!--                                 <td style="width:100px;" align="right"><apex:commandButton onclick="openpdf();return false;" value="PDF" style="width:90px;" disabled="{!pdf_button}"/></td> -->
                                <td style="width:100px;" align="right"><apex:commandButton onclick="openpdf();return false;" value="PDF" style="width:90px;" /></td>
                                <td style="width:100px;" align="right"><apex:commandButton action="{!Back}" rerender="IraiUserId,hiddenQuoid,message1" value="不保存(返回)" style="width:90px;"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>