liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
import { LightningElement,api } from 'lwc';
import GetTenderinformationcData from '@salesforce/apex/TenderDeleteLwcController.GetTenderinformationcData';
import saveData from '@salesforce/apex/TenderDeleteLwcController.saveData';
import searchTender from '@salesforce/apex/TenderDeleteLwcController.searchTender';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import tnederDeletePageCss from '@salesforce/resourceUrl/tnederDeletePageCss';        
import {loadStyle} from 'lightning/platformResourceLoader'    
export default class TenderDeletePage extends LightningElement {
    @api recordid;
    ParamIdStr = '';
    //页面初始化加载数据
    ScreenWidth = ''
    //加载的标识
    IsLoading = false; 
    onLoadin(flag){
        this.IsLoading=flag;
    }
    //招投标项目
    Tenderinformationc={};
    
    connectedCallback() {
        Promise.all([            
            loadStyle(this, tnederDeletePageCss)            
        ]);    
    console.log(this)
        this.onLoadin(true);
        debugger
        var paramId = this.recordid
        if (paramId == null || paramId == '') {
            return;
        }
        this.ScreenWidth = "height:" + (window.screen.availHeight - 50) + "px;overflow:scroll;";
        debugger
        this.ParamIdStr = paramId;
        GetTenderinformationcData({ParamIdStr:paramId}).then(result => {
            debugger
            var results=JSON.parse(result);
            if(results[0].Retain_Tender__c!=undefined && results[0].Retain_Tender__c!=''){
                this.template.querySelector('[data-parent-id="lookup"]').setvalue(results[0].Retain_Tender__c);
            }
            this.Tenderinformationc=results[0];
            this.onLoadin(false);
        }); 
    }
    getQueryVariable(variable) { //id字符串
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        }
        return (false);
    }
    // onsearchchange(event){
    //     debugger
    //     console.log(event.detail.value)
    //     this.Tenderinformationc.Retain_Tender__c=event.detail.value
    // }
    // saveAllData(){
    //     this.onLoadin(true);
    //     if(this.Tenderinformationc.Retain_Tender__c!=undefined&&this.Tenderinformationc.Retain_Tender__c!=''){
    //         var Tenderinformationcjson=JSON.stringify(this.Tenderinformationc);
    //         saveData({Tenderinformationc:Tenderinformationcjson}).then(result=>{
    //             debugger
    //            console.warn(result);
    //            if(result=="成功"){
    //             alert('保存成功');
    //             window.location.hash = "Refresh"+"=="+this.ParamIdStr;
    //             debugger
    //             this.onLoadin(false);
    //            }
    //         });
    //     }else{
    //         alert('保留的招投标:必填!');
    //     }
    // }
 
    // 2022-03-31 更换了控件类型 start
    // 招标项目
    option = [{lableOne:"Name",lableTwo:"TenderManageCode__c"}]
    searchdata=[];
    onsearchchange(event){
        var searchContentStr = event.detail.searchContent;
        searchTender({content:searchContentStr}).then(response=>{
            var datas = JSON.parse(response);
            this.searchdata = datas;
            this.template.querySelector('[data-parent-id="lookup"]').refreshdata(this.searchdata);
        })
    }
 
    selected(event)
    {
        debugger;
        console.warn(event.detail.selectdata.Id);
        this.Tenderinformationc.Retain_Tender__c = event.detail.selectdata.Id;
 
    }
 
    isErrorShow = false;
    saveAllData(){
        var flag = true;
        var id1 = this.template.querySelector('[data-parent-id="lookup"]').getvalue();
    
        if (id1 == undefined || id1 == '') {
            this.Tenderinformationc.Retain_Tender__c = undefined;
        }
 
        if (this.Tenderinformationc.Retain_Tender__c == undefined || this.Tenderinformationc.Retain_Tender__c == "" ) {
            this.xgxLy = "slds-form-element slds-has-error"
            this.xgxLyFlag = true;
            this.isErrorShow = true;
            flag = false;
        }else{
            this.xgxLy = "slds-form-element"
            this.xgxLyFlag = false;
            this.isErrorShow = false;
        }
 
        debugger;
        
        if (flag) {
            this.onLoadin(true);
            debugger;
            console.warn(this.Tenderinformationc);
            var Tenderinformationcjson=JSON.stringify(this.Tenderinformationc);
            saveData({Tenderinformationc:Tenderinformationcjson}).then(result=>{
                debugger
                console.warn(result);
                if(result=="成功"){
                    this.showToast('保存成功','success');
                    setTimeout(() => {
                        window.location.href = '/'+this.recordid
                        // window.open('/'+this.recordid,)
                    },2000)
                    // window.location.hash = "Refresh"+"=="+this.ParamIdStr;
                    // debugger
                    this.onLoadin(false);
                }
            });
        }
    }
    showToast(msg,type) {
        if(type == "success"){
            const event = new ShowToastEvent({
                message: msg,
                variant: type
            });
            this.dispatchEvent(event);
        }else{
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode:"sticky"
            });
            this.dispatchEvent(event);
        }
    }
    // 2022-03-31 更换了控件类型 end
}