From d77b6353ca9b59a6398df3eae9912f9fd766946d Mon Sep 17 00:00:00 2001
From: zhangzhengmei <zhangzhengmei@prec-tech.com>
Date: 星期六, 05 八月 2023 17:04:22 +0800
Subject: [PATCH] fix: lightning 页面确认

---
 force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js |  251 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 251 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js b/force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js
new file mode 100644
index 0000000..7b58902
--- /dev/null
+++ b/force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js
@@ -0,0 +1,251 @@
+import {
+    LightningElement,
+    wire,
+    api
+} from 'lwc';
+import {
+    CurrentPageReference
+} from "lightning/navigation";
+import {
+    CloseActionScreenEvent
+} from 'lightning/actions';
+import init from '@salesforce/apex/buttonAssetCtl.init';
+import initUserName from '@salesforce/apex/buttonAssetCtl.initUserName';
+import selecctAccountByAccountId from '@salesforce/apex/buttonAssetCtl.selecctAccountByAccountId';
+import selecctProduct2ById from '@salesforce/apex/buttonAssetCtl.selecctProduct2ById';
+import selecctRepairByFomatToday from '@salesforce/apex/buttonAssetCtl.selecctRepairByFomatToday';
+import selecctQISReportByFomatToday from '@salesforce/apex/buttonAssetCtl.selecctQISReportByFomatToday';
+
+export default class LexCreateRepairFromAsset extends LightningElement {
+    @api recordId;
+    str;
+    IsLoading = true;
+    Id;
+    userID;
+    EmployeeNoC;
+    day;
+    day1;
+    day2;
+    Name;
+    NoPartRiskDateFC;
+    ProductIDC;
+    AccountId;
+    HPIdC;
+    HospitalC;
+    DepartmentClassC;
+    HospitalId;
+    DepartmentClassId;
+    RepairSalesPointProvinceChinaC;
+    notCreateRepairFromAssetButton;
+    notCreateRepairFromAssetButton02;
+
+    @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.userID = result.userID;
+                this.day = result.day;
+                this.day1 = result.day1;
+                this.day2 = result.day2;
+                this.Name = result.Name;
+                this.NoPartRiskDateFC = result.NoPartRiskDateFC == undefined ? "" : result.NoPartRiskDateFC;
+                this.ProductIDC = result.ProductIDC == undefined ? "" : result.ProductIDC;
+                this.AccountId = result.AccountId == undefined ? "" : result.AccountId;
+                this.HPIdC = result.HPIdC == undefined ? "" : result.HPIdC;
+                this.HospitalC = result.HospitalC == undefined ? "" : result.HospitalC;
+                this.DepartmentClassC = result.DepartmentClassC == undefined ? "" : result.DepartmentClassC;
+                this.HospitalId = result.HospitalId == undefined ? "" : result.HospitalId;
+                this.DepartmentClassId = result.DepartmentClassId == undefined ? "" : result.DepartmentClassId;
+                this.notCreateRepairFromAssetButton = result.notCreateRepairFromAssetButton;
+                this.notCreateRepairFromAssetButton02 = result.notCreateRepairFromAssetButton02;
+
+                initUserName({
+                    userId: this.userID
+                }).then(result => {
+                    console.log(result);
+                    if (result != null) {
+                        this.EmployeeNoC = result[0].Employee_No__c;
+                        this.RepairSalesPointProvinceChinaC = result[0].RepairSalesPoint_Province_China__c;
+                    }
+                    this.CreateRepairFromAsset();
+                })
+
+
+                this.dispatchEvent(new CloseActionScreenEvent());
+            }
+        }).catch(error => {
+            console.log(error);
+        })
+    }
+
+    // 鏂板缓淇悊	
+    CreateRepairFromAsset() {
+        var nCRepairFromAssetBSting = this.notCreateRepairFromAssetButton;
+        var nCRepairFromAssetB02Sting = this.notCreateRepairFromAssetButton02;
+        nCRepairFromAssetBSting = nCRepairFromAssetBSting + nCRepairFromAssetB02Sting;
+        var nCRepairFromAssetBList = nCRepairFromAssetBSting.split(',');
+        var EmployeeNo = this.EmployeeNoC;
+
+        if (nCRepairFromAssetBList.indexOf(EmployeeNo) != -1) {
+            alert("瀵逛笉璧凤紝鎮ㄦ棤鏉冧娇鐢ㄦ鎸夐挳鍒涘缓淇悊锛�");
+            return;
+        }
+
+        var fomatToday = this.day1;
+        var QIS_Name = '';
+        var QIS_Id = '';
+        var url1 = "";
+        var FSE_GI_Main_Leader__id = '';
+        var FSE_GI_Main_Leader__name = '';
+        var FSE_SP_Main_Leader__id = '';
+        var FSE_SP_Main_Leader__name = '';
+        var Incharge_Staff = '';
+        var Incharge_Staff_id = '';
+        var Work_Location = '';
+        var Old_Repair_Name = '';
+
+        selecctQISReportByFomatToday({
+            AssetId: this.Id,
+            fomatToday: fomatToday
+        }).then(records => {
+            console.log(records);
+            if (records.length >= 1) {
+                var boolday = confirm('璇风‘璁ゆ浠舵槸鍚﹀睘浜�10澶╁唴閲嶅鎶ュ憡锛屽鏋滄槸锛岃浣跨敤鍘烸IS淇℃伅濉啓銆�');
+                if (!boolday) {
+                    return;
+                }
+            }
+            if (records.length >= 1) {
+                QIS_Name = records[0].Name;
+                QIS_Id = records[0].Id;
+            }
+        })
+        selecctRepairByFomatToday({
+            AssetId: this.Id,
+            fomatToday: fomatToday
+        }).then(records2 => {
+            console.log(records2);
+            if (records2.length >= 1) {
+                var boolday = confirm('姝や欢璁惧濡備负10澶╁唴閲嶅鎶ュ憡锛屽缓璁洖鍒板師淇悊鍗曚娇鐢ㄥ鍒跺姛鑳芥彁浜ゃ�傝纭鏄惁缁х画鏂板缓淇悊锛� ');
+                if (!boolday) {
+                    return;
+                }
+            }
+            if (records2.length >= 1) {
+                Old_Repair_Name = records2[0].Name;
+            }
+        })
+        var partSupplyFinishDate = this.NoPartRiskDateFC;
+        if (this.day < this.NoPartRiskDateFC && this.NoPartRiskDateFC <= this.day2) {
+            alert('棰勮' + partSupplyFinishDate + '闆朵欢鍗冲皢鍋滀骇锛岃閫佷慨鍓嶄笌宸ュ巶鍙奟C鑱旂粶');
+        }
+        if (this.NoPartRiskDateFC != null && this.NoPartRiskDateFC != undefined && this.NoPartRiskDateFC <= this.day) {
+            alert('璇ュ瀷鍙烽浂浠跺凡缁忓仠浜э紝鏈夌壒娈婇渶姹傦紝璇烽�佷慨鍓嶄笌宸ュ巶RC鑱旂粶');
+        }
+        selecctProduct2ById({
+            Id: this.ProductIDC
+        }).then(recordP => {
+            console.log(recordP);
+
+            if (recordP != null && recordP.length > 0) {
+                var canRepair = recordP[0].Can_Repair__c;
+                if (canRepair == '绗笁鏂�') {
+                    alert('闈炴垜鍙镐慨鐞嗗璞★紝鏃犳硶鏂板缓淇悊锛屽鏈変笉鏄庤鍜ㄨCIC');
+                    return;
+                }
+                if (canRepair == '涓�' || canRepair == null) {
+                    alert('鏈澶囨棤娉曟柊寤轰慨鐞�');
+                    return;
+                }
+                if (canRepair == 'RC閫佷慨') {
+                    url1 = "&00N10000009HAJl=TRUE"
+                }
+            }
+        })
+        selecctAccountByAccountId({
+            AccountId: this.AccountId
+        }).then(List => {
+            console.log(List);
+            if (List != null) {
+                var RecordTypeId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
+                console.log(RecordTypeId);
+                if (RecordTypeId != 'Agency') {
+                    if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
+                        FSE_GI_Main_Leader__id = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'].substring(0, 15);
+                        FSE_GI_Main_Leader__name = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Name'];
+                    }
+                    if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
+                        FSE_SP_Main_Leader__id = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'].substring(0, 15);
+                        FSE_SP_Main_Leader__name = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Name'];
+                    }
+                    if (List[0]['Parent']['RecordType_DeveloperName__c'] != null || List[0]['Parent']['RecordType_DeveloperName__c'] != undefined) {
+                        var recordId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
+                        if (recordId == 'Department_Class_GI' || recordId == 'Department_Class_BF' || recordId == 'Department_Class_ET') {
+                            if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
+                                Work_Location = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Work_Location__c'];
+                            }
+                        } else if (recordId == 'Department_Class_GS' || recordId == 'Department_Class_URO' || recordId == 'Department_Class_ENT' || recordId == 'Department_Class_GYN' || recordId == 'Department_Class_OTH') {
+                            if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
+                                Work_Location = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Work_Location__c'];
+                            }
+
+                        }
+                    }
+                    if (RecordTypeId == 'Department_Class_GI') {
+                        Incharge_Staff = FSE_GI_Main_Leader__name;
+                        Incharge_Staff_id = FSE_GI_Main_Leader__id;
+                    }
+                    if (RecordTypeId == 'Department_Class_BF') {
+                        Incharge_Staff = FSE_GI_Main_Leader__name;
+                        Incharge_Staff_id = FSE_GI_Main_Leader__id;
+                    }
+                    if (RecordTypeId == 'Department_Class_ET') {
+                        Incharge_Staff = FSE_GI_Main_Leader__name;
+                        Incharge_Staff_id = FSE_GI_Main_Leader__id;
+                    }
+                    if (RecordTypeId == 'Department_Class_GS') {
+                        Incharge_Staff = FSE_SP_Main_Leader__name;
+                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                    }
+                    if (RecordTypeId == 'Department_Class_URO') {
+                        Incharge_Staff = FSE_SP_Main_Leader__name;
+                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                    }
+                    if (RecordTypeId == 'Department_Class_ENT') {
+                        Incharge_Staff = FSE_SP_Main_Leader__name;
+                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                    }
+                    if (RecordTypeId == 'Department_Class_GYN') {
+                        Incharge_Staff = FSE_SP_Main_Leader__name;
+                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                    }
+                    if (RecordTypeId == 'Department_Class_OTH') {
+                        Incharge_Staff = FSE_SP_Main_Leader__name;
+                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                    }
+                }
+
+            }
+            var url = "/a0J/e?CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.HospitalC + "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClassC + "&CF00N10000002Dx5n_lkid=" + this.Id + "&CF00N10000002Dx5n=" + this.Name + "&CF00N10000002Dx1X_lkid=" + this.Id + "&CF00N10000002Dx1X=" + this.Name + "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + "&00N10000002FH86=%e5%8f%aa%e4%bf%ae%e7%90%86&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC + "&00N10000006P6SM=" + encodeURI(Work_Location) + "&CF00N10000009H7yM=" + QIS_Name + "&CF00N10000009H7yM_lkid=" + QIS_Id + "&00N10000009H2fa=" + Old_Repair_Name + "&retURL=%2F" + this.Id;
+            if (url1 != undefined) {
+                url = url + url1;
+            }
+            window.open(url);
+        })
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1