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
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/SISearchSetProductController.serContact';
import SelectDone from '@salesforce/apex/SISearchSetProductController.SelectDone';
import getFileName from '@salesforce/apex/SISearchSetProductController.getFileName';
import init from '@salesforce/apex/SISearchSetProductController.init';
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;
                    if(this.data.activities[i].Valid_c){
                        this.data.activities[i].img='';
                    }
                }
                
                this.columns = [
                    // { label: '选择', fieldName: 'isSelected' },
                    { label: 'Report', fieldName: 'setUrl', type:'url' },
                    { 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();
        }
 
        SetMuiltProduct(){
            var Str = this.data.setPFString;
            var isPrepared = this.data.DataStatus;
            if(isPrepared!='Fin'){
                confirm(isPrepared)
            }else if(Str==''||Str==null){
                if(confirm("您尚未选取任何产品配套,确认完成么?")){
                    top.window.close();
                }else{
                }
            }else{
                top.window.opener.setProductEntryGateway(Str);
                top.window.close();
            }
        }
        async DataPrepare() {
            // body...
            console.log("添加:");
            this.data.DataStatus='数据尚未准备好,请稍等';
            console.log(this.data);
            let activities=[];
            let isSelected=[];
            for (var i = this.data.activities.length - 1; i >= 0; i--) {
                activities.push(this.data.activities[i].setProductidFull);
                isSelected.push(this.data.activities[i].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);
                }
            }).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';
        // }
}