buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
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
import { LightningElement, track, wire,api } from 'lwc';
import { loadStyle, loadScript } from 'lightning/platformResourceLoader'
import blockUIcss from '@salesforce/resourceUrl/blockUIcss';
import jquery183minjs from '@salesforce/resourceUrl/jquery183minjs';
import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
 
 
 
import getData from'@salesforce/apex/LexSearchProductCsController.getData';
 
import Product_Search from '@salesforce/label/c.Product_Search';
import Search_Condition from '@salesforce/label/c.Search_Condition';
import Asset_No  from '@salesforce/label/c.Asset_No';
import Search  from '@salesforce/label/c.Search';
import Add_Product  from '@salesforce/label/c.Add_Product';
import Search_Result  from '@salesforce/label/c.Search_Result';
import Selected  from '@salesforce/label/c.Selected';
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';
 
 
const columns = [
    { label: '选择', fieldName: 'Selected' },
    { label: '产品型号', fieldName: 'Asset_Model_No__c' },
    { label: '产品编码', fieldName: 'OT_CODE_no_link__c' },
    { label: '产品名称', fieldName: 'Name' },
    { label: '代替产品', fieldName: 'Alternative_Products__c' },
    { label: 'NMPA状态', fieldName: 'SFDA_Status__c' },
    { label: '设备/耗材区分', fieldName: 'Serial_Lot_No__c' },
    { label: '备品管理类别', fieldName: 'Asset_loaner_category__c' },
    { label: 'ListPrice(内贸)', fieldName: 'Intra_Trade_List_RMB__c' },
    { label: 'ListPrice(外贸)', fieldName: 'Foreign_Trade_List_US__c' },
    { label: '单位', fieldName: 'Qty_Unit__c' },
                ];
 
export default class lexSearchProductCs extends LightningElement {
 
    Label = {
        Product_Search,
        Search_Condition,
        Asset_No,
        Search,
        Add_Product,
        Search_Result,
        Selected,
        SFDA_Status,
        ListPrice_In,
        ListPrice_Out,
        Unit
    }
 
    @api recordId;
    dataList=[];
    IsLoading=true;
    columns = columns;
    inputData;
    ProductLine;
 
 
    // @wire(CurrentPageReference)
    // getStateParameters(currentPageReference){
    //     if(currentPageReference) {
    //         const urlValue = currentPageReference.state.recordId;
    //         if(urlValue) {
    //             let str = `${urlValue}`;
    //             this.recordId = str;
    //         }
    //     }
    // }
 
 
    async connectedCallback(){
 
 
        console.log('进入callback');
        // var vlData=new Array();
        // vlData  = await getData();
        // if(vlData.size>0){
        //     this.data=vlData;
        //     console.log('keyi')
        //     // console.log(vlData[0]);
        // }
        // else{
        //     console.log('getCs方法返回长度为0');
        // }
        
        
    }
 
 
 
 
    async serContact(event){
        console.log('into serContact')
        var search = this.inputData;
        console.log(search);
        var trade='CNY';
 
        var vlData=new Array();
        console.log('vlData');
        await getData({SearchName:search,trade:trade}).then(result=>{
            this.IsLoading=false;
            this.ProductLine=result;
            console.log(result);
            console.log(this.ProductLine[0]);
            console.log(this.ProductLine[0].pbe.Product2.Asset_Model_No__c);
            this.DataInColumn();
        }).catch(error=>{
            console.log(error);
        })
        
 
    }
 
 
 
    getInputData(event){
        this.inputData=event.detail.value;
 
    }
 
    DataInColumn(){
        console.log('in DataInColumn')
        for(var  i=0;i<this.ProductLine.length-1;i++){
            this.dataList[i]= [this.ProductLine[i].pbe.Product2];
            console.log(this.dataList[i]);
        }
        
 
    }
 
 
 
        // setProductList(event) {
     //            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) {
     //                        console.log('进入setProductList');
     //                        SetProductId(nextLine, i);
     //                        nextLine++;
     //                    }
     //                }
     //            }
     //            if (hasCheckedCnt == 0) {
     //                alert(top.window.opener.Error_Message34);
     //                console.log('hasCheckedCnt==0');
     //            }
     //            top.window.opener.calPriceAll(window.opener.document);
     //            top.window.close();
     //    }
     //    setProductOne(lineno, i) {
     //        //lineno = getLastLineNo();
     //        SetProductId(lineno, i);
     //        top.window.opener.calPriceAll(window.opener.document);
     //        top.window.close();
     //    }
     //    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();
            
     //        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));
     //    }
 
}