高章伟
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
<apex:page id="Page" standardController="Product2" extensions="SearchProductCSController" sidebar="false" showHeader="false" >
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <script>
        function setProductList() {
            var nextLine = top.window.opener.getLastLineNoNext(window.opener.document);
            var hasCheckedCnt = 0;
            var checklist = j$("input[name='checklist']");
            for(var i=0; i<checklist.length; i++){
                if (checklist[i].checked) {
                    hasCheckedCnt++;
                    if (nextLine < 150) {
                        SetProductId(nextLine, i);
                        nextLine++;
                    } else {
                        //alert('Max Line 150');
                        return false;
                    }
                }
            }
            if (hasCheckedCnt == 0) {
                alert(top.window.opener.Error_Message34);
                return false;
            }
            top.window.opener.calPriceAll(window.opener.document);
            top.window.close();
        }
        function setProductOne(lineno, i) {
            //lineno = getLastLineNo();
            SetProductId(lineno, i);
            top.window.opener.calPriceAll(window.opener.document);
            top.window.close();
        }
        function SetProductId(lineno, i) {
            var Asset_Model_No__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Asset_Model_No__c")).text();
            var Product2Id = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Product_Id")).val();
            var SFDA_Status__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":SFDA_Status__c")).text();
            var Serial_Lot_No__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Serial_Lot_No__c")).text();
            var Asset_loaner_category__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Asset_loaner_category__c")).text();
            var name = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Name")).text();
            var Intra_Trade_List_RMB__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Intra_Trade_List_RMB__c")).text();
            var Foreign_Trade_List_US__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Foreign_Trade_List_US__c")).text();
            var NameCode = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":NameCode")).val();
            var Sales_Possibility = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Sales_Possibility")).val();
            var Intra_Trade_Cost_RMB__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Intra_Trade_Cost_RMB__c")).val();
            var Foreign_Trade_Cost_US__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Foreign_Trade_Cost_US__c")).val();
            var Bsscategory = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Bsscategory")).val();
            var PricebookEntryId = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":PricebookEntryId")).val();
            var trade = window.opener.j$(escapeVfId("Page:mainForm:block:CurrencyIsoCode")).val();
            var Packing_list_manual__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Packing_list_manual__c")).val();
            // 同梱数必ずある?
            if (Packing_list_manual__c == null || Packing_list_manual__c <= 0) {
                Packing_list_manual__c = 1;
            }
            
            //No
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":indexNo")).text(parseInt(lineno)+1);
 
            //製品型番
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Assert")).val(Asset_Model_No__c);
            
            //Serial/Lot区分
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Serial_Lot")).text(Serial_Lot_No__c);
            
            //资产/耗材
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Asset_loaner_category")).text(Asset_loaner_category__c);
 
             //Status__c
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Status__c")).text(SFDA_Status__c);
            //SFDA hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":SFDA")).val(SFDA_Status__c);
            
            //品目名
            var baseUrl = window.opener.j$(escapeVfId("Page:mainForm:block:baseUrl")).val();
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Nametext1")).attr("href", baseUrl + "/" + Product2Id);
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Nametext1")).text(name);
            //品目名hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Name__c")).val(name);
            
            //同捆数
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Packing_list_manual")).text(Packing_list_manual__c);
 
            //ListPrice
            var ListPrice = 0;
            var Cost_c = 0;
            if(trade == "CNY") {
               ListPrice = Intra_Trade_List_RMB__c;
               Cost_c = Intra_Trade_Cost_RMB__c;
            } else if(trade == "USD"){
               ListPrice = Foreign_Trade_List_US__c;
               Cost_c = Foreign_Trade_Cost_US__c;
            }
            Cost_c = top.window.opener.toNum(Cost_c);
            ListPrice = top.window.opener.toNum(ListPrice);
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":ListPricetext")).text(top.window.opener.toNumComma(ListPrice));
            //ListPrice hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":ListPrice")).val(ListPrice);
 
            //数量 
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Quantity")).val(1);
            
            //価格
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":UnitPrice")).val(top.window.opener.toNumComma(ListPrice));
 
            //単位
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Qty")).text();
            
            //小計 主画面ID变更,逻辑不变设值ID变更
//            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":TotalPrice")).text(top.window.opener.toNumComma(ListPrice));
            
            //Subtotal__c hidden
//            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Subtotal__c")).val(ListPrice);
 
            //小計lw
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":ListPriceTotalText")).text(top.window.opener.toNumComma(ListPrice));
            
            //ListPriceTotal hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":ListPriceTotal")).val(ListPrice);
 
            //NameCode hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":NameCode")).val(NameCode);
            
            //Product_Name hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Product_Name")).val(name);
            
            //Product_SFDA hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Product_SFDA")).val(SFDA_Status__c);
            
            //Sales_Possibility hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Sales_Possibility")).val(Sales_Possibility);
            
            //Product_ListPrice hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Product_ListPrice")).val(ListPrice);
            
            //Product_Cost hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Product_Cost")).val(Cost_c);
            
            //Cost hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Cost")).val(Cost_c);
            
            //CostSubTotal hidden Cost_c * Quantity;
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":CostSubTotal")).val(Cost_c);
            
            //Bsscategory hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Bsscategory")).val(Bsscategory);
            
            //Product_Id hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Product_Id")).val(Product2Id);
            
            //PricebookEntryId hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":PricebookEntryId")).val(PricebookEntryId);
            
            //lineNo hidden
            window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":lineNo")).val(parseInt(lineno));
        }
    </script>
    <style type="text/css">
        div#iframelike {
            color: #fff;
            height: 300px;
            overflow-y: auto;
            overflow-x: hidden;
        }
    </style>
    <apex:outputPanel id="all">
        <apex:outputPanel id="message1">
            <apex:messages styleClass="editListError"/>
        </apex:outputPanel>
        <apex:form id="mainForm">
            <apex:pageBlock id="idSearchSetProduct" title="{!$Label.Product_Search}">
                <apex:inputHidden id="Trade" value="{!Trade}"/>
                <table width="1000" border="0" style="background-color:#DCDCDC">
                    <colgroup>
                        <col width="12" />
                        <col width="20" />
                        <col width="20" />
                        <col width="200" />
                        <col width="20" />
                        <col width="428" />
                    </colgroup>
                    <tr>
                        <td>&nbsp;</td>
                        <th>{!$Label.Search_Condition}</th>
                        <td>&nbsp;</td>
                        <th>{!$Label.Asset_No}</th>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td><apex:inputText id="searchName" value="{!SearchName}" style="width:200px" required="false"/></td>
<!--                        <td><apex:commandButton value="{!$Label.Search}" action="{!serContact}" style="width:100px" rerender="all,message1" onclick="blockme();" oncomplete="unblockUI();"/></td>-->
                        <!-- xudan Enterキーを対応するため、rerender、onclick、oncomplete全部なし -->
                        <td><apex:commandButton value="{!$Label.Search}" action="{!serContact}" style="width:100px" /></td>
                        <td>&nbsp;<apex:commandButton value="{!$Label.Add_Product}" style="width:100px;float:right;" disabled="{!Hascl}" rerender="dummy" onclick="setProductList();return false;"/></td>
                    </tr>
                    <tr>
                        <td style="border-bottom: 1px solid #888;" colspan="15">&nbsp;</td>
                    </tr>
                </table>
                <table width="1000" border="0" style="background-color:#DCDCDC">
                    <tr>
                        <td width="12">&nbsp;</td>
                        <th valign="top">{!$Label.Search_Result}</th>
                        <td width="20">&nbsp;</td>
                        <td>
                            <table border="0">
                                <tr>
                                    <td>
                                    <div id="iframelike" style="width:900px">
                                    <apex:pageBlockTable id="idRezultVisitor" value="{!cl}" var="c" border="1" columns="11" columnsWidth="25px,120px,120px,280px,60px,60px,60px,60px,60px,60px,25px">
                                        <apex:column style="width:15px;" >
                                            <apex:facet name="header">{!$Label.Selected}</apex:facet>
                                            <input type="checkbox" name="checklist" value="" style="width:10px;"/>
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">{!$Label.Asset_No}</apex:facet>
                                            <apex:outputLink id="Asset_Model_No__c" value="{!c.pbe.Product2.Asset_Model_No__c}" onclick="setProductOne('{!lineno}','{!c.idx}');return false;">{!c.pbe.Product2.Asset_Model_No__c}</apex:outputLink>
                                            <apex:inputHidden id="NameCode" value="{!c.NameCode}"/>
                                            <apex:inputHidden id="Sales_Possibility" value="{!c.Sales_Possibility}"/>
                                            <apex:inputHidden id="Bsscategory" value="{!c.Bsscategory}"/>
                                            <apex:inputHidden id="Product_Id" value="{!c.Product_Id}"/>
                                            <apex:inputHidden id="PricebookEntryId" value="{!c.PricebookEntryId}"/>
                                            <apex:inputHidden id="Intra_Trade_Cost_RMB__c" value="{!c.Intra_Trade_Cost_RMB}"/>
                                            <apex:inputHidden id="Foreign_Trade_Cost_US__c" value="{!c.Foreign_Trade_Cost_US}"/>
                                            <apex:inputHidden id="Packing_list_manual__c" value="{!c.Packing_list_manual}"/>
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">{!$ObjectType.Product2.fields.OT_CODE_no_link__c.Label}</apex:facet>
                                            <apex:outputField id="OT_CODE_no_link__c" value="{!c.pbe.Product2.OT_CODE_no_link__c}" />
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">{!$Label.Product_Name}</apex:facet>
                                            <apex:outputField id="Name" value="{!c.pbe.Product2.Name}" />
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">{!$ObjectType.Product2.fields.Alternative_Products__c.Label}</apex:facet>
                                            <apex:outputField id="Alternative" value="{!c.pbe.Product2.Alternative_Products__c}" />
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">{!$Label.SFDA_Status}</apex:facet>
                                            <apex:outputField id="SFDA_Status__c" value="{!c.pbe.Product2.SFDA_Status__c}" />
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">{!$ObjectType.Product2.fields.Serial_Lot_No__c.Label}</apex:facet>
                                            <apex:outputField id="Serial_Lot_No__c" value="{!c.pbe.Product2.Serial_Lot_No__c}" />
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">{!$ObjectType.Product2.fields.Asset_loaner_category__c.Label}</apex:facet>
                                            <apex:outputField id="Asset_loaner_category__c" value="{!c.pbe.Product2.Asset_loaner_category__c}" />
                                        </apex:column>
                                        <apex:column style="text-align:right;">
                                            <apex:facet name="header">{!$Label.ListPrice_In}</apex:facet>
                                            <apex:outputField id="Intra_Trade_List_RMB__c" value="{!c.pbe.Product2.Intra_Trade_List_RMB__c}" />
                                        </apex:column>
                                        <apex:column style="text-align:right;">
                                            <apex:facet name="header">{!$Label.ListPrice_Out}</apex:facet>
                                            <apex:outputField id="Foreign_Trade_List_US__c" value="{!c.pbe.Product2.Foreign_Trade_List_US__c}" />
                                        </apex:column>
                                        <apex:column style="text-align:right;">
                                            <apex:facet name="header">{!$Label.Unit}</apex:facet>
                                            <apex:outputField id="Qty_Unit__c" value="{!c.pbe.Product2.Qty_Unit__c}" />
                                        </apex:column>
                                    </apex:pageBlockTable>
                                    </div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </apex:pageBlock>
        </apex:form>
    </apex:outputPanel>
    <script type="text/javascript">
        // フォーカスセット
        j$(escapeVfId('Page:mainForm:idSearchSetProduct:searchName'))[0].focus();
        j$(escapeVfId('Page:mainForm:idSearchSetProduct:searchName')).val(j$(escapeVfId('Page:mainForm:idSearchSetProduct:searchName')).val());
        var trade = window.opener.j$(escapeVfId("Page:mainForm:block:CurrencyIsoCode")).val();
        j$(escapeVfId("Page:mainForm:idSearchSetProduct:Trade")).val(trade);
    </script>
</apex:page>