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
/*
 * @Description: 耗材现场统一收货
 * @Author: [lijinhuan]
 * @Date: 2023-08-14 22:10:52
 * @LastEditors: [lijinhuan]
 * @LastEditTime: 2023-10-17 10:37:23
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import all_received_fse from '@salesforce/apex/ConsumApplyWebService.all_received_fse';
import { NavigationMixin } from 'lightning/navigation';
 
 
export default class LexAllReceivedBtns extends NavigationMixin(LightningElement) {
    @api raid;
    IsLoading = true;
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
             console.log(111);
             console.log(currentPageReference);
 
         if (currentPageReference) {
            // 20231017 ljh update start
        //    const urlValue = currentPageReference.state.raid;
           const urlValue = currentPageReference.state.recordId;
           // 20231017 ljh update end
           if (urlValue) {
             let str = `${urlValue}`;
             console.log("str");
             console.log(str);
             this.raid = str;
           }
         }
     }
 
     connectedCallback(){
        this.IsLoading = false;
        this.submit()
        
     }
 
 
     showToast(msg,type) {
        if(type == 'success'){
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
            });
            this.dispatchEvent(event);
            this.updateRecordView(this.raid);
            //20231101 sx  add start 
            this.dispatchEvent(new CloseActionScreenEvent());
            //20231101 sx  add end
        }else{
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode: 'sticky'
            });
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
        }   
    }
 
 
     updateRecordView(raid) {
        updateRecord({fields: { Id: raid }});
    }
 
     submit(){
        all_received_fse({caId:this.raid})
        .then(res=>{
            if(res =='现场已全部收货'){
                //20231101 sx  update start 
                this.showToast(res,'success')
                //20231101 sx  update end
                var url = '/'+this.raid; 
                // window.location.href=url;
                const config = {
                    type: 'standard__webPage',
                    attributes: {
                        url: url
                    }
                };
                this[NavigationMixin.Navigate](config);
            }else{
                //20231101 sx  add start 
                this.showToast(res,'warning');
                //20231101 sx  add end
            }
            
        })
        .catch(e=>{
            console.log(e)
        })
        
     }
}