buli
2023-04-26 d6a096fadfe9c8f261f56a827cfceed663c36b8b
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
import { LightningElement,wire,api,track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import initPage from '@salesforce/apex/LexConsumableOrderManageController.init1';
import searchConsumableorderdetails from '@salesforce/apex/LexConsumableOrderManageController.searchConsumableorderdetails';
 
export default class LexConsumableOrderManage extends NavigationMixin(LightningElement) {
    @track category1;
    @track orderDate;
    @track orderStatus = '';
    @track provinceOpts = [];
    @track raesList = [];
    @track title = [];
    @track agencyProType;
    @track accountid;
    @track userWorkLocation;
    @track hasHop = false;
    @track showHop = false;
    @track hasSpecial = false;
    @track cols = [];
    @track showSpinner = false;
    @track showPage = false;
 
    connectedCallback(){
        this.showSpinner = true;
        initPage()
            .then(result=>{
                if(result.result == 'Success'){
                    this.provinceOpts = result.provinceOpts;
                    this.title = result.title;
                    this.raesList = result.raesList;
                    this.agencyProType = result.agencyProType;
                    this.accountid = result.accountid;
                    this.userWorkLocation = result.userWorkLocation;
                    this.hasHop = result.hasHop;
                    this.hasSpecial = result.hasSpecial;
                    this.cols = result.cols;
                    if(this.hasHop == true && this.agencyProType == 'ENG'){
                        this.showHop = true;
                    }
                    for(var i in this.raesList){
                        if(this.raesList[i].Order_ForHospital__c){
                            this.raesList[i]['hosUrl'] = '/s/detail/'+this.raesList[i].Order_ForHospital__c;
                            this.raesList[i]['hosName'] = this.raesList[i].Order_ForHospital__r.Name;
                        }
                        this.raesList[i]['nameUrl'] = '/s/lexconsumable?ESetid='+this.raesList[i].Id;
                    }
                    this.showSpinner = false;
                    this.showPage = true;
                }else{
                    this.showSpinner = false;
                    console.log("Error:"+result.errorMsg);
                    const evt = new ShowToastEvent({
                        title : '初始化页面失败',
                        message: result.errorMsg,
                        variant: 'error'
                    });
                    this.dispatchEvent(evt);
                }
            })
            .catch(error=>{
                this.showSpinner = false;
                console.log("Error:"+error);
            })
    }
 
    category1Change(event){
        this.category1 = event.detail.value;
        console.log('category1:'+this.category1);
    }
    
    orderDateChange(event){
        this.orderDate = event.detail.value;
        console.log('orderDate:'+this.orderDate);
    }
 
    orderStatusChange(event){
        this.orderStatus = event.detail.value;
        console.log('orderStatus:'+this.orderStatus);
    }
 
    agreementorder(event){
        const config = {
            type: 'standard__webPage',
            attributes: {
                url: '/lexconsumable?type=agreementorder'
            }
        };
        this[NavigationMixin.Navigate](config);
    }
 
    hospitalorder(event){
        const config = {
            type: 'standard__webPage',
            attributes: {
                url: '/lexconsumable?type=hospitalorder'
            }
        };
        this[NavigationMixin.Navigate](config);
    }
 
    promotionorder(event){
        const config = {
            type: 'standard__webPage',
            attributes: {
                url: '/lexconsumable?type=promotionorder'
            }
        };
        this[NavigationMixin.Navigate](config);
    }
 
    searchProduct(event){
        this.showSpinner = true;
        searchConsumableorderdetails({categoryStr:this.category1,orderDate:this.orderDate,orderStatus:this.orderStatus,accountidStr:this.accountid,agencyProTypeStr:this.agencyProType,userWorkLocationStr:this.userWorkLocation})
            .then(result=>{
                if(result.result == 'Success'){
                    this.raesList = result.raesList;
                    for(var i in this.raesList){
                        if(this.raesList[i].Order_ForHospital__c){
                            this.raesList[i]['hosUrl'] = '/s/detail/'+this.raesList[i].Order_ForHospital__c;
                            this.raesList[i]['hosName'] = this.raesList[i].Order_ForHospital__r.Name;
                        }
                        this.raesList[i]['nameUrl'] = '/s/lexconsumable?ESetid='+this.raesList[i].Id;
                    }
                    this.showSpinner = false;
                    this.showMyToast('搜索成功',result.errorMsg,'success');
                }else{
                    this.showSpinner = false;
                    this.raesList = result.raesList;
                    console.log("Error:"+result.errorMsg);
                    if(result.errorMsg == '没有搜索到相关订单'){
                        this.showMyToast(result.errorMsg,'','error');
                    }else{
                        this.showMyToast('搜索失败',result.errorMsg,'error');
                    }
                    this.dispatchEvent(evt);
                }
            })
    }
 
    clear(event){
        this.category1 = '';
        this.orderDate = null;
        this.orderStatus = '';
        searchConsumableorderdetails({categoryStr:this.category1,orderDate:this.orderDate,orderStatus:this.orderStatus,accountidStr:this.accountid,agencyProTypeStr:this.agencyProType,userWorkLocationStr:this.userWorkLocation})
            .then(result=>{
                if(result.result == 'Success'){
                    this.raesList = result.raesList;
                    for(var i in this.raesList){
                        if(this.raesList[i].Order_ForHospital__c){
                            this.raesList[i]['hosUrl'] = '/s/detail/'+this.raesList[i].Order_ForHospital__c;
                            this.raesList[i]['hosName'] = this.raesList[i].Order_ForHospital__r.Name;
                        }
                        this.raesList[i]['nameUrl'] = '/s/lexconsumable?ESetid='+this.raesList[i].Id;
                    }
                    this.showMyToast('搜索成功',result.errorMsg,'success');
                }else{
                    this.raesList = result.raesList;
                    console.log("Error:"+result.errorMsg);
                    if(result.errorMsg == '没有搜索到相关订单'){
                        this.showMyToast(result.errorMsg,'','error');
                    }else{
                        this.showMyToast('搜索失败',result.errorMsg,'error');
                    }
                    this.dispatchEvent(evt);
                }
            })
    }
 
    showMyToast(title,message,variant){
        const evt = new ShowToastEvent({
           title : title,
           message: message,
           variant: variant
        });
        this.dispatchEvent(evt);
     }
}