123
chenjingwu
2024-04-15 66095e6be55c703af7993aed2453374a397d05a3
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
import { LightningElement, track, wire } from 'lwc';
import serContact from '@salesforce/apex/LexSearchProductIraiController.serContact';
import init from '@salesforce/apex/LexSearchProductIraiController.init';
 
import Set_Name from '@salesforce/label/c.Set_Name';
import Search_Condition from '@salesforce/label/c.Search_Condition';
import Set_Search from '@salesforce/label/c.Set_Search';
import Set_Code from '@salesforce/label/c.Set_Code';
import Search from '@salesforce/label/c.Search';
import Search_Result from '@salesforce/label/c.Search_Result';
import Quantity from '@salesforce/label/c.Quantity';
import Valid_Status from '@salesforce/label/c.Valid_Status';
import Product_Search from '@salesforce/label/c.Product_Search';
import Add_Product from '@salesforce/label/c.Add_Product';
import Selected from '@salesforce/label/c.Selected';
import Asset_No from '@salesforce/label/c.Asset_No';
import Product_Name from '@salesforce/label/c.Product_Name';
import SFDA_Status from '@salesforce/label/c.SFDA_Status';
import ListPrice_In from '@salesforce/label/c.ListPrice_In';
import ListPrice_Out from '@salesforce/label/c.ListPrice_Out';
import Unit from '@salesforce/label/c.Unit';
 
export default class lexSearchProductIrai extends LightningElement {
 
 
    Label={
        Set_Name,
        Search_Condition,
        Set_Search,
        Set_Code,
        Search_Result,
        Search,
        Quantity,
        Valid_Status,
        Product_Search,
        Add_Product,
        Selected,
        Asset_No,
        Product_Name,
        SFDA_Status,
        ListPrice_In,
        ListPrice_Out,
        Unit
    };
    isLoad=false;
    data;
    LabelI='';
    SearchName='';
    SearchCode='';
    columns = [
        { label: '选择', fieldName: 'isSelected' },
        { label: 'Report', fieldName: 'setUrl' },
        { label: this.Label.Set_Name, fieldName: 'Name' },
        { label: this.Label.Set_Code, fieldName: 'Product_Set_CD_c' },
        { label: this.Label.Quantity, fieldName: 'Quantity' },
        { label: this.Label.Valid_Status, fieldName: 'img' }
        // { label: 'Website', fieldName: 'Asset_Model_No_forPrint__c', type: 'url' },
        // { label: 'Phone', fieldName: 'phone', type: 'phone' },
        // { label: 'Balance', fieldName: 'amount', type: 'currency' },
        // { label: 'CloseAt', fieldName: 'closeAt', type: 'date' },
    ];
    
 
    async connectedCallback(){
        console.log("ddddd");
        await init().then(res=>{
            console.log("new res:");
            console.log(res);
            this.data=res;
            this.isLoad=true;
            this.columns=[
                { label: this.Label.Selected, fieldName: 'idx' },
                { label: this.Label.Asset_No, fieldName: 'Name' },
                { label: this.data.LabelOT, fieldName: 'OT_CODE_no_link__c' },
                { label: this.Label.Product_Name, fieldName: 'Name' },
                { label: this.data.Labelsuit, fieldName: 'suitDepartment__c' },
                { label: this.data.LabelAl, fieldName: 'Alternative_Products__c' },
                { label: this.Label.SFDA_Status, fieldName: 'SFDA_Status__c' },
                { label: this.Label.ListPrice_In, fieldName: 'Intra_Trade_List_RMB__c' },
                { label: this.Label.ListPrice_Out, fieldName: 'Foreign_Trade_List_US__c' },
                { label: this.Label.Unit, fieldName: 'Qty_Unit__c' },
            ]
        })
    }
 
 
 
    serContact(){
        serContact({trade:this.data.trade,searchMode:this.data.searchMode,celon:this.data.celon,SearchName:this.data.SearchName}).then(res=>{
            console.log(res);
            this.data.cl=res.cl;
            if(res!=null){
                this.data.cl=res.cl;
                this.data.activities=res.activities;
                this.data.cc=[];
                for (var i = this.data.cl.length - 1; i >= 0; i--) {
                    this.data.cc.push(this.data.cl[i].pbe.Product2)
                }
                console.log("activities!");
            }
            let t=this.data;
            this.data={};
            this.data=t;
        })
    }
    searchNameInputChange(event){
        this.data.SearchName = event.detail.value;
    }
 
//          QuoteEntryMaxLine = window.opener.QuoteEntryMaxLine;
    add(){
        setProductList();
        return false;
    }
        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 < QuoteEntryMaxLine) {
                        SetProductId(nextLine, i);
                        nextLine++;
                    } else {
                        alert('Over Max Line ' + QuoteEntryMaxLine);
                        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) {
//             debugger
//             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 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 Intra_Trade_Service_RMB__c =j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Intra_Trade_Service_RMB")).val();
//             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();
//             //DB202212304166 【紧急-报价委托与购买意向】请将最后操作的报价委托状态放到购买意向中 fy start
//             var CanNotCancelledGurantee__c = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":CanNotCancelledGurantee__c")).val();
//             //DB202212304166 【紧急-报价委托与购买意向】请将最后操作的报价委托状态放到购买意向中 fy end
 
//             //CHAN-BHNBX6 2019/11/20 START 
//             var GuaranteePeriod =  j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":GuaranteePeriod")).value();    
//             //nodiscount 小计
//             var Intra_Trade_Service_RMB =j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Intra_Trade_Service_RMB")).value(); 
//             //CHAN-BHNBX6 2019/11/20 END
//             //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);
 
//              //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);
            
//             //DB202212304166 【紧急-报价委托与购买意向】请将最后操作的报价委托状态放到购买意向中 fy start
//             //取消市场多年保
//             window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":CanNotCancelledGurantee__c")).val(CanNotCancelledGurantee__c);
//             //DB202212304166 【紧急-报价委托与购买意向】请将最后操作的报价委托状态放到购买意向中 fy end
 
 
//             //品目名
//             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);
 
//             //ListPrice
//             var ListPrice = 0;
//             var Cost_c = 0;
//             //CHAN-BHNBX6 2019/11/20 START 
//             var NoDiscount = 0;
            
//             if(trade == "CNY") {
//                ListPrice = Intra_Trade_List_RMB__c;
//                Cost_c = Intra_Trade_Cost_RMB__c;
//                NoDiscount = Intra_Trade_Service_RMB;
//             } 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);
//             NoDiscount = top.window.opener.toNum(NoDiscount);
//             //CHAN-BHNBX6 2019/11/20 END
//             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);
//             //CHAN-BHNBX6  NoDiscount 2019/11/20 START
//             window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":NoDiscount")).val(NoDiscount);
//             //CHAN-BHNBX6  NoDiscount 2019/11/20 END
//             //数量 
//             window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":Quantity")).val(1);
            
//             //CHAN-BHNBX6 保修年限 2019/11/20 START 
//             window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":itemGuaranteePeriod")).text(GuaranteePeriod);
//             window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":itemGuaranteePeriod")).val(GuaranteePeriod);
//             //CHAN-BHNBX6 保修年限 2019/11/20 END
//             //価格
//             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);
 
//             //CHAN-BHNBX6 nodiscount 小计 2019/11/20 START 
//             //DB202212304166 【紧急-报价委托与购买意向】请将最后操作的报价委托状态放到购买意向中 fy start
//             // var cancelMultiyearInsurance = top.window.opener.j$(escapeVfId("Page:mainForm:block:cancelMultiyearInsurance")).val();
//             // var NoDiscount1;
//             // if(cancelMultiyearInsurance == '不要' && CanNotCancelledGurantee__c == 'false'){
//             //     NoDiscount1 = 0.00;
//             // }else{
//             //     NoDiscount1 = NoDiscount;
//             // }
//             // window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":NoDiscountTotalText")).text(top.window.opener.toNumComma(NoDiscount1));
 
//             //DB202212304166 【紧急-报价委托与购买意向】请将最后操作的报价委托状态放到购买意向中 fy end
//             window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":NoDiscountTotalText")).text(top.window.opener.toNumComma(NoDiscount));
//             //CHAN-BHNBX6 nodiscount 小计 2019/11/20 END 
//             // window.opener.j$(escapeVfId("Page:mainForm:block:lists:"+ lineno +":NoDiscountTotal")).val(Intra_Trade_Service_RMB);
 
 
//             //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));
//         }
}