buli
2023-05-26 0e9334dcee28f030b55d8b76749c666a88fd383d
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
import {
    LightningElement,
    wire,
    api
} from 'lwc';
import {
    CurrentPageReference
} from "lightning/navigation";
import {
    CloseActionScreenEvent
} from 'lightning/actions';
import init from '@salesforce/apex/otherButtonRepairController.init';
import selecctAccountById from '@salesforce/apex/otherButtonRepairController.selecctAccountById';
import selecctUser from '@salesforce/apex/otherButtonRepairController.selecctUser';
import selecctQISReport from '@salesforce/apex/otherButtonRepairController.selecctQISReport';
 
export default class LexCreateRepairFromQIS extends LightningElement {
    @api recordId;
    str;
    IsLoading = true;
    Id;
    QISId;
    QISOCMJudgement;
    QISnextAction;
    QISSpecialFollow;
    QISHPID;
    QISSourceOnCall;
    QISName;
    QISDepartmentClassId;
    QISDepartmentClass;
    QISHospitalDepartment;
    QISnonyushohin;
    QISTrableOccurDaYCollect;
    QISsourceForRepair;
    QISHospital;
 
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
        if (currentPageReference) {
            const urlValue = currentPageReference.state.recordId;
            if (urlValue) {
                let str = `${urlValue}`;
                this.recordId = str;
            }
        }
    }
 
    connectedCallback() {
        init({
            recordId: this.recordId
        }).then(result => {
            console.log(result);
            if (result != null) {
                this.IsLoading = false;
                this.Id = result.Id;
 
                this.CreateRepairFromQIS();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
        })
    }
 
    //新建修理QIS    
    CreateRepairFromQIS() {
        selecctQISReport().then(result => {
            console.log(result);
            if (result != null) {
                this.QISHospital = result.Hospital__c;
                this.QISId = result.Id;
                this.QISOCMJudgement = result.OCM_judgement__c;
                this.QISnextAction = result.next_action__c;
                this.QISSpecialFollow = result.Special_follow__c;
                this.QISHPID = result.HP_ID__c;
                this.QISSourceOnCall = result.Source_OnCall__c;
                this.QISName = result.Name;
                this.QISDepartmentClassId = result.Department_Class_Id__c;
                this.QISDepartmentClass = result.Department_Class__c;
                this.QISHospitalDepartment = result.Hospital_Department__c;
                this.QISnonyushohin = result.nonyushohin__c;
                this.QISTrableOccurDaYCollect = result.Trable_occur_daY_collect__c;
                this.QISsourceForRepair = result.source_for_repair__c;
            }
        })
 
        selecctUser().then(result => {
            console.log(result);
            if (result != null) {
                this.RepairSalesPointProvinceChinaC = result.RepairSalesPoint_Province_China__c
            }
        })
 
        var newflag = false;
        if ((this.QISOCMJudgement == '质量问题' && this.QISnextAction == '无偿维修' && this.QISSpecialFollow == '0') || (this.QISOCMJudgement == '非质量问题' && this.QISnextAction == '无偿维修' && this.QISSpecialFollow == '1') || (this.QISOCMJudgement == '非质量问题' && this.QISnextAction == '有偿维修' && this.QISSpecialFollow == '0') || (this.QISOCMJudgement == '质量问题+非质量问题' && this.QISnextAction == '无偿维修' && this.QISSpecialFollow == '1') || (this.QISOCMJudgement == '质量问题+非质量问题' && this.QISnextAction == '有偿维修+无偿维修' && this.QISSpecialFollow == '0')) {
            newflag = true;
        }
        if (newflag) {
            //LJPH-BYZ4JT 【委托】修理画面“修理品返送地”问题调查-后续 精琢技术 wql 20210311 start
            var List;
            selecctAccountById({
                id: this.QISHospitalDepartment
            }).then(result => {
                console.log(result);
                if (result != null) {
                    List = result;
                }
            })
            var RecordTypeId;
            var Incharge_Staff = '';
            var Incharge_Staff_id = '';
            var Work_Location = '';
            if (List['records']['ParentId'] != null) {
                RecordTypeId = List['records']['Parent']['RecordTypeId'].substring(0, 15);
 
                var FSE_GI_Main_Leader__id = '';
                var FSE_GI_Main_Leader__name = '';
                var FSE_SP_Main_Leader__id = '';
                var FSE_SP_Main_Leader__name = '';
                if (List['records']['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
                    FSE_GI_Main_Leader__id = List['records']['Parent']['Parent']['FSE_GI_Main_Leader__c'].substring(0, 15);
                    FSE_GI_Main_Leader__name = List['records']['Parent']['Parent']['FSE_GI_Main_Leader__r']['Name'];
                }
                if (List['records']['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
                    FSE_SP_Main_Leader__id = List['records']['Parent']['Parent']['FSE_SP_Main_Leader__c'].substring(0, 15);
                    FSE_SP_Main_Leader__name = List['records']['Parent']['Parent']['FSE_SP_Main_Leader__r']['Name'];
                }
                //LJPH-BYZ4JT 【委托】修理画面“修理品返送地”问题调查-后续 精琢技术 wql 20210311 start
 
                if (List['records']['Parent']['RecordTypeId'] != null || List['records']['Parent']['RecordTypeId'] != '') {
                    var recordId = List['records']['Parent']['RecordTypeId'].substring(0, 15);
                    //战略科室取消化科、呼吸科、ET 取GI主担当
                    if (recordId == '01210000000QemL' || recordId == '01210000000QezZ' || recordId == '01210000000QemQ') {
                        if (List['records']['Parent']['Parent']['FSE_GI_Main_Leader__c']) {
                            Work_Location = List['records']['Parent']['Parent']['FSE_GI_Main_Leader__r']['Work_Location__c'];
                        }
                    }
                    //战略科室取普外科、泌尿科、耳鼻喉科、妇科、其它 取SP主担当
                    else if (recordId == '01210000000Qeze' || recordId == '01210000000Qezj' || recordId == '01210000000Qezt' || recordId == '01210000000Qezo' || recordId == '01210000000Qezy') {
                        if (List['records']['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
                            Work_Location = List['records']['Parent']['Parent']['FSE_SP_Main_Leader__r']['Work_Location__c'];
                        }
 
                    }
                }
                //LJPH-BYZ4JT 【委托】修理画面“修理品返送地”问题调查-后续 精琢技术 wql 20210311 end
                if (RecordTypeId == '01210000000QemL') {
                    Incharge_Staff = FSE_GI_Main_Leader__name;
                    Incharge_Staff_id = FSE_GI_Main_Leader__id;
                }
                if (RecordTypeId == '01210000000QezZ') {
                    Incharge_Staff = FSE_GI_Main_Leader__name;
                    Incharge_Staff_id = FSE_GI_Main_Leader__id;
                }
                if (RecordTypeId == '01210000000QemQ') {
                    Incharge_Staff = FSE_GI_Main_Leader__name;
                    Incharge_Staff_id = FSE_GI_Main_Leader__id;
                }
                if (RecordTypeId == '01210000000Qeze') {
                    Incharge_Staff = FSE_SP_Main_Leader__name;
                    Incharge_Staff_id = FSE_SP_Main_Leader__id;
                }
                if (RecordTypeId == '01210000000Qezj') {
                    Incharge_Staff = FSE_SP_Main_Leader__name;
                    Incharge_Staff_id = FSE_SP_Main_Leader__id;
                }
                if (RecordTypeId == '01210000000Qezt') {
                    Incharge_Staff = FSE_SP_Main_Leader__name;
                    Incharge_Staff_id = FSE_SP_Main_Leader__id;
                }
                if (RecordTypeId == '01210000000Qezo') {
                    Incharge_Staff = FSE_SP_Main_Leader__name;
                    Incharge_Staff_id = FSE_SP_Main_Leader__id;
                }
                if (RecordTypeId == '01210000000Qezy') {
                    Incharge_Staff = FSE_SP_Main_Leader__name;
                    Incharge_Staff_id = FSE_SP_Main_Leader__id;
                }
            }
            window.open("/a0J/e?CF00N10000002FIJU_lkid={!URLENCODE(QIS_Report__c.Source_OnCallId__c)}&CF00N10000002FIJU=" + this.QISSourceOnCall + "&CF00N10000002FIJZ_lkid=" + this.QISId + "&CF00N10000002FIJZ=" + this.QISName + "&CF00N10000002Dx66_lkid=" + this.QISHPID + "&CF00N10000002Dx66=" + this.QISHospital + "&CF00N10000002Dx5t_lkid=" + this.QISDepartmentClassId + "&CF00N10000002Dx5t=" + this.QISDepartmentClass + "&CF00N10000002Dx5n_lkid={!URLENCODE(QIS_Report__c.Hospital_DepartmentId__c)}&CF00N10000002Dx5n=" + this.QISHospitalDepartment + "&CF00N10000002Dx1X_lkid={!URLENCODE(QIS_Report__c.nonyushohinId__c)}&CF00N10000002Dx1X=" + this.QISnonyushohin + "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + "&00N10000002Dx5y=" + this.QISTrableOccurDaYCollect + "&00N10000006P6SM=" + encodeURI(Work_Location) + "&00N10000002FH86=" + this.QISsourceForRepair + "&00N10000006P6Rn="+this.RepairSalesPointProvinceChinaC +"&retURL=%2F" + this.QISId);
        } else {
            alert("不能新建修理");
        }
    }
}