liwentao
2023-08-07 5ba06835141d1af5fa26a72055f1eee2fc8a4c52
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
import { LightningElement, track, wire } from 'lwc';
 
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 serContact from '@salesforce/apex/LexSISearchSetProductController.serContact';
import SelectDone from '@salesforce/apex/LexSISearchSetProductController.SelectDone';
import getFileName from '@salesforce/apex/LexSISearchSetProductController.getFileName';
import init from '@salesforce/apex/LexSISearchSetProductController.init';
import LightningConfirm from 'lightning/confirm';
import a from '@salesforce/resourceUrl/jquery183minjs';
import b from '@salesforce/resourceUrl/PleaseWaitDialog';
export default class lexSISearchSetProduct extends LightningElement {
        Label={
            Set_Name,
            Search_Condition,
            Set_Search,
            Set_Code,
            Search_Result,
            Search,
            Quantity,
            Valid_Status,
        };
        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(){
            // getFileName().then(res=>{
            //     console.log("ttt");
            //     console.log(res);
            //     this.Quote_Select_Info__c_Label=res;
            // })
            console.log("jinru");
            await init().then(res=>{
                console.log("hhh");
                console.log("res:");
                console.log(res);
                console.log(res.LabelI);
                this.data=res;
                this.LabelI=res.LabelI;
                for (var i = this.data.activities.length - 1; i >= 0; i--) {
                    this.data.activities[i].setUrl= res.baseUrl + '/'+ res.reportid +'?pv1='+ this.data.activities[i].setProductid;
                    this.data.activities[i].urlIcon=true;
                    if(this.data.activities[i].Valid_c){
                        this.data.activities[i].img='';
                    }
                }
                
                this.columns = [
                    // { label: '选择', fieldName: 'isSelected' },
                    {
                        label: 'Report',
                        fieldName: 'setUrl',
                        type: 'url',
                        typeAttributes: {
                            label: '◆',
                            target: '_blank'
                        },
                        cellAttributes: {
                            iconName: {
                                fieldName: 'urlIcon',
                                operator: '=',
                                value: true
                            } ? 'standard:link' : '',
                            iconPosition: 'left',
                        }
                    },
                    { 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.data.LabelI, fieldName: 'Quote_Select_Info_c' },
                    { label: this.Label.Valid_Status, fieldName: 'img' }
                ];
                this.isLoad=true;
            });
        }
 
 
        SetProductId(str) {
            //top.window.opener.setProductEntry(str);
            top.window.opener.setProductEntryGateway(str);
            top.window.close();
        }
 
        async SetMuiltProduct(){
            console.log("int");
            var Str = this.data.setPFString;
            var isPrepared = this.data.DataStatus;
            console.log("int1");
            if(isPrepared!='Fin'){
                console.log("int2");
                // confirm(isPrepared)
                console.log("update");
                var result = await LightningConfirm.open({
                    message: isPrepared,
                    variant: 'headerless',
                    label: '提示信息',
                    // setting theme would have no effect
                });
            }else if(Str==''||Str==null){
                console.log("int3");
                console.log("update");
                var result = await LightningConfirm.open({
                    message: "您尚未选取任何产品配套,确认完成么?",
                    variant: 'headerless',
                    label: '提示信息',
                    // setting theme would have no effect
                });
                if(result){
                    top.window.close();
                }else{
                }
            }else{
                console.log("int4");
                top.window.opener.setProductEntryGateway(Str);
                console.log("int4.5");
                top.window.close();
                console.log("int5");
            }
        }
        async DataPrepare() {
            // body...
            console.log("添加:");
            this.data.DataStatus='数据尚未准备好,请稍等';
            console.log(this.data);
            var activities=[];
            var isSelected=[];
            var selected =  this.template.querySelector("lightning-datatable").getSelectedRows();
            for (var i = selected.length - 1; i >= 0; i--) {
                // if(this.data.activities[i].isSelected)
                activities.push(selected[i].setProductidFull);
            }
            console.log("ttt");
            
            console.log(activities);
            console.log(isSelected);
            //j$(escapeVfId("Page:mainForm:DataStatus")).val('数据尚未准备好,请稍等');
            await SelectDone({activities:activities,isSelected:isSelected}).then(res=>{
                console.log("SelectDone:");
                console.log(res);
                if(res!=null){
                    this.data.setPFString=res.setPFString;
                    this.data.setProductidFullList=res.setProductidFullList;
                    this.data.DataStatus=res.DataStatus;
                    console.log(this.data);
                }
                this.SetMuiltProduct();
            }).catch(err=>{
                console.log("err:");
                console.log(err);
                console.log(err.message);
            });
        }
 
        Select(){
            serContact({searchName:this.data.SearchName,searchCode:this.data.SearchCode}).then(res=>{
                console.log("查询结果");
                console.log(res);
                if(res!=null){
                    this.data.cl=res.cl;
                    this.data.activities=res.activities;
                    for (var i = this.data.activities.length - 1; i >= 0; i--) {
 
                        this.data.activities[i].setUrl= this.data.baseUrl + '/'+ this.data.reportid +'?pv1='+ this.data.activities[i].setProductid;
                        if(this.data.activities[i].Valid_c){
                            this.data.activities[i].img='√';
                        }
                    }
                    console.log("activities!");
                }
                let t=this.data;
                this.data={};
                this.data=t;
                console.log(this.data);
            })
        }
        searchNameInputChange(event){
            this.data.SearchName = event.detail.value;
        }
        searchCodeInputChange(event){
            this.data.SearchCode = event.detail.value;
        }
        // function DataReady() {
        //  // body...
        //  j$(escapeVfId("Page:mainForm:DataStatus")).value()='Fin';
        // }
}