19626
2023-04-13 920f16a391a3a25a7e7f4d90b6cb600d6c6dbd91
升级按钮4.13
51个文件已添加
18个文件已修改
3473 ■■■■■ 已修改文件
force-app/main/default/classes/Add_Report.cls 565 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/Add_Report.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/ControllerUtil.cls 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/MonthlyReportController.cls 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityLightingButtonController.cls 332 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityLightingButtonController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityService.cls 457 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityService.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityWebService.cls 506 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityWebService.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/ReportController.cls 104 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexAgencyAuthorize/__tests__/lexAgencyAuthorize.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.css 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js 198 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtn/__tests__/lexBeforeOPDPDFBtn.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.css 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/__tests__/lexBeforeOPDPDFBtnSIS.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.css 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.html 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.js 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCancel/lexCancel.js 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCancelSubmitReport/lexCancelSubmitReport.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexComplete/lexComplete.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCreateEvent/__tests__/lexCreateEvent.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCreateEvent/lexCreateEvent.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCreateEvent/lexCreateEvent.js 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCreateEvent/lexCreateEvent.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexDispatchOCSMQARA/lexDispatchOCSMQARA.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLoseBid/__tests__/lexLoseBid.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLoseBid/lexLoseBid.css 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLoseBid/lexLoseBid.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLoseBid/lexLoseBid.js 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLoseBid/lexLoseBid.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOCSMNoToReportForReport/lexOCSMNoToReportForReport.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOCSMToReport/lexOCSMToReport.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOLYwinBid/__tests__/lexOLYwinBid.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.css 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDtoSIS/lexOPDtoSIS.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPredictedDateChange/__tests__/lexPredictedDateChange.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.css 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.js 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestDB/__tests__/lexRequestDB.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestDB/lexRequestDB.css 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestDB/lexRequestDB.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestDB/lexRequestDB.js 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestDB/lexRequestDB.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSIStoOPD/lexSIStoOPD.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSubmit/lexSubmit.css 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSubmit/lexSubmit.html 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSubmit/lexSubmit.js 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSubmit/lexSubmit.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSubmitCompetitorReport/lexSubmitCompetitorReport.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexVOCAnswer/lexVOCAnswer.js 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexVOCCheck/lexVOCCheck.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexVOCConfirm/lexVOCConfirm.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexVOCFinish/lexVOCFinish.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexVOCSubmit/lexVOCSubmit.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/Add_Report.cls
New file
@@ -0,0 +1,565 @@
global class Add_Report {
    // TODO reportのidで検索じゃなく、event_id__cで検索
    WebService static String addReportPr(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4,String visitor5, String description, String reportDate){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Comment__c from Report__c where id =:reportId];
            if (rList.size() > 0) {
                return rList.get(0).id;
            }
        }
        Report__c r = new Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        } else {
            r.Manual_Name__c = aId;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        if(visitor1 != null && visitor1 != ''){
            r.Practitioner1__c = visitor1;
        }
        if(visitor2 != null && visitor2 != ''){
            r.Practitioner2__c = visitor2;
        }
        if(visitor3 != null && visitor3 != ''){
            r.Practitioner3__c = visitor3;
        }
        if(visitor4 != null && visitor4 != ''){
            r.Practitioner4__c = visitor4;
        }
        if(visitor5 != null && visitor5 != ''){
            r.Practitioner5__c = visitor5;
        }
        r.Comment__c = description;
        upsert r;
        updateEvent(r.id,eventId,recordType);
        return r.id;
    }
    WebService static String addReportOP(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String opp1, String opp2, String opp3, String opp4, String opp5, String reportDate){
        return addReportOPWithEvaluationPDF(repOwnerId, reportId, dailyReportId, eventId, recordType, aId, visitor1, visitor2, visitor3, visitor4, visitor5, opp1, opp2, opp3, opp4, opp5, reportDate, '', '', '', '');
    }
    WebService static String addReportOP2(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String opp1, String opp2, String opp3, String opp4, String opp5, String reportDate, String sTime, String eTime){
        return addReportOPWithEvaluationPDF(repOwnerId, reportId, dailyReportId, eventId, recordType, aId, visitor1, visitor2, visitor3, visitor4, visitor5, opp1, opp2, opp3, opp4, opp5, reportDate, '', '', sTime, eTime);
    }
    @AuraEnabled
    WebService static String addReportOPWithEvaluationPDF(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String opp1, String opp2, String opp3, String opp4, String opp5, String reportDate, String evaluationPDFNumber, String pro1, String sTime, String eTime) {
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Opportunity1__c, Opportunity2__c, Opportunity3__c, Opportunity4__c, Opportunity5__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        Report__c r = new Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        } else {
            r.Manual_Name__c = aId;
        }
        if (String.isBlank(dailyReportId) == false) r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        if (String.isBlank(eventId) == false) r.Event_Id__c = eventId;
        r.Evaluation_PDF_number__c = evaluationPDFNumber;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        if(visitor1 != null && visitor1 != ''){
            r.Practitioner1__c = visitor1;
        }
        if(visitor2 != null && visitor2 != ''){
            r.Practitioner2__c = visitor2;
        }
        if(visitor3 != null && visitor3 != ''){
            r.Practitioner3__c = visitor3;
        }
        if(visitor4 != null && visitor4 != ''){
            r.Practitioner4__c = visitor4;
        }
        if(visitor5 != null && visitor5 != ''){
            r.Practitioner5__c = visitor5;
        }
        List<String> oppIdList = new List<String>();
        if(opp1 != null && opp1 != ''){
            oppIdList.add(opp1);
        }
        if(opp2 != null && opp2 != ''){
            oppIdList.add(opp2);
        }
        if(opp3 != null && opp3 != ''){
            oppIdList.add(opp3);
        }
        if(opp4 != null && opp4 != ''){
            oppIdList.add(opp4);
        }
        if(opp5 != null && opp5 != ''){
            oppIdList.add(opp5);
        }
        if(oppIdList.size() > 0){
            if(opp1 != null && opp1 != ''){
                r.Opportunity1__c = opp1;
            }
            if(opp2 != null && opp2 != ''){
                r.Opportunity2__c = opp2;
            }
            if(opp3 != null && opp3 != ''){
                r.Opportunity3__c = opp3;
            }
            if(opp4 != null && opp4 != ''){
                r.Opportunity4__c = opp4;
            }
            if(opp5 != null && opp5 != ''){
                r.Opportunity5__c = opp5;
            }
            r.Opportunity_Situation__c = '引合発生';
        }
        else{
            r.Opportunity_Situation__c = '引合無';
        }
        if (String.isBlank(pro1) == false) {
            r.Product1__c = pro1;
        }
        if (sTime != null && sTime != '') {
            r.Operation_From__c = datetime.parse(sTime);
        }
        if (eTime != null && eTime != '') {
            r.Operation_To__c = datetime.parse(eTime);
        }
        upsert r;
        if (String.isBlank(eventId) == false) updateEvent(r.id,eventId,recordType);
        return r.id;
    }
    WebService static String addReportNT(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String sTime, String eTime, String mainPlace){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, From__c, To__c, Location__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        Report__c r = new Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        } else {
            r.Manual_Name__c = aId;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if(visitor1 != null && visitor1 != ''){
            r.Practitioner1__c = visitor1;
        }
        if(visitor2 != null && visitor2 != ''){
            r.Practitioner2__c = visitor2;
        }
        if(visitor3 != null && visitor3 != ''){
            r.Practitioner3__c = visitor3;
        }
        if(visitor4 != null && visitor4 != ''){
            r.Practitioner4__c = visitor4;
        }
        if(visitor5 != null && visitor5 != ''){
            r.Practitioner5__c = visitor5;
        }
        if(sTime != null && sTime != ''){
            //sTime = sTime.substring(0,16);
            r.From__c = datetime.parse(sTime);
        }
        if(eTime != null && eTime != ''){
            //eTime = eTime.substring(0,16);
            r.To__c = datetime.parse(eTime);
        }
        r.Location__c = mainPlace;
        upsert r;
        updateEvent(r.id,eventId,recordType);
        return r.id;
    }
    WebService static String addReportOn(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String v1Str, String startHour, String startMin, String endHour, String endMin, String description){
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<On_Call__c> oList = [select id, Daily_Report__c, Event_Id__c, segment__c from On_Call__c where id =:reportId];
            if(oList.size() > 0){
                return oList.get(0).id;
            }
        }
        On_Call__c o = new On_Call__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            o.segment__c = a.Id;
            // 病院ID(18桁)差込み
            o.Hospital__c = a.Hospital__r.Id;
        }
        o.Daily_Report__c = dailyReportId;
        o.OwnerId = repOwnerId;
        o.Event_Id__c = eventId;
        o.Responsible_Person_HP__c = v1Str;
        if(String.isBlank(description) == false){
            if(description.length() > 255){
                o.Customer_Problem_c__c = description.substring(0, 255);
            } else {
                o.Customer_Problem_c__c = description;
            }
        }
        Date rDate = date.parse(reportDate);
        o.From_c__c = Datetime.newInstance(rDate.year(), rDate.month(), rDate.day(), Integer.valueOf(startHour), Integer.valueOf(StartMin), 0);
        o.To_c__c = Datetime.newInstance(rDate.year(), rDate.month(), rDate.day(), Integer.valueOf(endHour), Integer.valueOf(endMin), 0);
        upsert o;
        updateEvent(o.id,eventId,recordType);
        return o.id;
    }
    WebService static String addReportAc(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<Visit_Report__c> rList = [select id, Daily_Report__c, Event_Id__c, Hospital_Reference__c, Department_Class__c, Department__c, Date__c from Visit_Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        Visit_Report__c r = new Visit_Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Reference__c = a.Hospital__r.Id;
            r.Department_Class__c = a.Department_Class__r.Id;
            r.Department__c = a.Id;
//        } else {
//            r.Manual_Name__c = aId;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.Event_Id__c = eventId;
        r.Evaluate_And_Problem__c = description;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        upsert r;
        updateEvent(r.id,eventId,recordType);
        return r.id;
    }
    WebService static String addClaim(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<QIS_Report__c> rList = [select id, Daily_Report__c, Event_Id__c, Hospital_Department__c, Date__c from QIS_Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        QIS_Report__c r = new QIS_Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class__c = a.Department_Class__r.Id;
            r.Hospital__c = a.Hospital__r.Id;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.Event_Id__c = eventId;
        //r.Department_Class_Ref__c = a.Department_Class__r.Id;
        //r.Hospital_Reference__c = a.Hospital__r.Id;
        r.problem_detail__c = description;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        r.Generation_Source__c = '日报';
        r.Name = '*';
        upsert r;
        updateEvent(r.id,eventId,recordType);
        return r.id;
    }
    // MarketCondition or Competitor
    WebService static String addReportEx(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String reportDate, String description){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Comment__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        Report__c r = new Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if (String.isBlank(visitor1) == false) {
            r.Person_In_Charge__c = visitor1;
        }
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        r.Comment__c = description;
        upsert r;
        updateEvent(r.id,eventId,recordType);
        return r.id;
    }
    WebService static String addReportIm(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Comment__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        Report__c r = new Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Reference__c = a.Hospital__r.Id;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        r.Comment__c = description;
        upsert r;
        updateEvent(r.id,eventId,recordType);
        return r.id;
    }
//    // Maintenance_Contract
//    WebService static String addMC(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
//        List<Account> aList = selectAccount(aId);
//
//        if(reportId != null && reportId != ''){
//            List<Maintenance_Contract__c> rList = [select id, Daily_Report__c, Event_Id__c from Maintenance_Contract__c where id =:reportId];
//            if(rList.size() > 0){
//                return rList.get(0).id;
//            }
//        }
//
//        Maintenance_Contract__c r = new Maintenance_Contract__c();
//
//        if(aList.size() != 0){
//            Account a = aList.get(0);
//            r.Hospital__c = a.Hospital__r.Id;
//            r.Department_Class__c = a.Department_Class__r.Id;
//            r.Department__c = a.Id;
//        }
//
//        r.Daily_Report__c = dailyReportId;
//        r.Event_Id__c = eventId;
//        r.Description__c = description;
////        if(reportDate != null && reportDate != ''){
////            r.Estimation_Create_Date__c = date.parse(reportDate);
////        }
//
//        upsert r;
//
//        updateEvent(r.id,eventId,recordType);
//
//        return r.id;
//    }
    // Rental_Apply
    WebService static String addRA(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description,String followOpps){
        List<Account> aList = selectAccount(aId);
        if(reportId != null && reportId != ''){
            List<Rental_Apply__c> rList = [select id, Daily_Report__c, Event_Id__c from Rental_Apply__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        Rental_Apply__c r = new Rental_Apply__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital__c = a.Hospital__r.Id;
            r.Strategic_dept__c = a.Department_Class__r.Id;
            r.Account__c = a.Id;
        }
        r.Daily_Report__c = dailyReportId;
        r.Event_Id__c = eventId;
        r.Demo_purpose_text__c = description;
        r.Request_return_day__c = Date.today();
        r.Person_In_Charge__c = repOwnerId;
        r.applyUser__c = repOwnerId;
        if(followOpps!=null&&followOpps!=''){
            r.Follow_UP_Opp__c = followOpps;
        }
        upsert r;
        updateEvent(r.id,eventId,recordType);
        return r.id;
    }
    WebService static String selectRecordType(String recordTypeName){
        List<RecordType> rtList = [select id from RecordType where IsActive = true and DeveloperName =:recordTypeName];
        return rtList.get(0).id;
    }
    WebService static List<Account> selectAccount(String aId){
        List<Account> aList = new List<Account>();
        if (aId != null && aId.startsWith('001')) {
            aList = [select Id, Department_Class__r.Id, Hospital__r.Id from Account where Id =:aId];
        }
        return aList;
    }
    WebService static void updateEvent(String rId, String eventId, String recordType){
        Event__c e = [
            select id,Maintenance_Contract_ID__c, Asset_Manual_ID__c, Rental_Apply_ID__c,
                   Product_Description_Id__c, OPD_ID__c, NTC_ID__c, ReportAccompanied_ID__c, CityStatus_ID__c, Improvement_ID__c, Conflict_ID__c, Claim_ID__c
              from Event__c where id =:eventId
        ];
//        if(recordType == 'Maintenance_Contract'){
//            e.Maintenance_Contract_ID__c = rId;
//        }
        if(recordType == 'Rental_Apply'){
            e.Rental_Apply_ID__c = rId;
        }
        if(recordType == 'Asset_Manual'){
            e.Asset_Manual_ID__c = rId;
        }
        if(recordType == 'Product_Explanation'){
            e.Product_Description_Id__c = rId;
        }
        else if(recordType == 'OPD' || recordType == 'SIS'){
            e.OPD_ID__c = rId;
        }
        else if(recordType == 'NTC'){
            e.NTC_ID__c = rId;
        }
        else if(recordType == 'On_Call'){
            e.OnCall_ID__c = rId;
        }
        else if(recordType == 'Visit_With'){
            e.ReportAccompanied_ID__c = rId;
        }
        else if(recordType == 'MarketCondition'){
            e.CityStatus_ID__c = rId;
        }
        else if(recordType == 'Improvement'){
            e.Improvement_ID__c = rId;
        }
        else if(recordType == 'Competitor'){
            e.Conflict_ID__c = rId;
        }
        else if(recordType == 'Complaint'){
            e.Claim_ID__c = rId;
        }
        update e;
    }
    WebService static Product2 getProduct2(String a){
        Product2 p2 = [select Id, Name, Intra_Trade_Cost_RMB__c, Intra_Trade_List_RMB__c FROM Product2 Where Id =:a];
        return p2;
    }
    WebService static Product2 getProduct2US(String a){
        Product2 p2 = [select Id, Name, Foreign_Trade_Cost_US__c, Foreign_Trade_List_US__c FROM Product2 Where Id =:a];
        return p2;
    }
    WebService static String getReportId(String oId, String rDate){
        List<Daily_Report__c> rtList = [select Id from Daily_Report__c where OwnerId =:oId and Reported_Date__c =:date.parse(rDate)];
        return rtList.get(0).id;
    }
    WebService static String checkAccountMatch(String name, String id){
        List<Account> accList = [select Id from Account where Name = :name and Id = :id];
        if (accList.size() > 0) {
            return 'OK';
        }
        return 'NG';
    }
    WebService static Account getAccountForJs(String id){
        return [select Id, Name, Department_Class__r.Name, Department_Class__r.Id,
                Hospital__r.Name, Hospital__r.Id, Hospital__r.OCM_Category__c
                from Account where Id = :id];
    }
}
force-app/main/default/classes/Add_Report.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>20.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/ControllerUtil.cls
@@ -2717,7 +2717,7 @@
        i++;
        i++;
    }
    @AuraEnabled
    WebService static String selectCommonSequence(String valueField, String formatField) {
        Boolean insertNew = false;
        //取得共通採番序列
@@ -4968,6 +4968,7 @@
    /**
    OCM-SI需求表用,复制功能,仅限当前所有SI需求表失效的时候,才能使用
    */
    @AuraEnabled
    WebService static String ISO_Copy_Func(id isoID){
        IS_Opportunity_Demand__c checkISO = [select Opportunity_ID__c from IS_Opportunity_Demand__c where id =:isoID];
        String opporID = checkISO.Opportunity_ID__c;
force-app/main/default/classes/MonthlyReportController.cls
@@ -51,7 +51,7 @@
    }
    //取消提交操作更新相应数据
    @AuraEnabled
    public static void cancel(String recordId) {
    public static String cancel(String recordId) {
       try {
        Monthly_Report__c report = [SELECT     Id,Status__c,Submit_check_flag__c,RecordTypeId,Submit_time__c FROM Monthly_Report__c WHERE Id = :recordId LIMIT 1];
        report.Status__c = LightingButtonConstant.STATUS_DRAFT;
@@ -59,12 +59,13 @@
        report.Submit_check_flag__c = false;
        report.Submit_time__c = null;
        update report;
        return null;
       } catch (Exception e) {
        System.debug(LoggingLevel.INFO, '*** e: ' + e);
       } finally {
        String eMessage = e.getMessage();
        Integer left = eMessage.indexOf(',') + 1;
        Integer right = eMessage.length();
        return eMessage.substring(left,right);
       }
    }
force-app/main/default/classes/OpportunityLightingButtonController.cls
New file
@@ -0,0 +1,332 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-12 11:16:07
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 17:02:46
 */
public with sharing class OpportunityLightingButtonController {
    @AuraEnabled
    public static InitData initForPredictedDateChangeButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
            select
            DirectLossFLG__c,
            Created_Day__c
            from Opportunity where Id =: recordId];
            res.createdDay = opportunity.Created_Day__c;
            res.directLossFLG = opportunity.DirectLossFLG__c;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForAgencyAuthorizeButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                Agency1_ID_18__c,
                StageName,
                SAP_Send_OK__c,
                Opp_order_Type__c,
                If_Have_170__c,
                If_Have_AH__c,
                Cnt_Lost_cancel_Draft__c,
                Cnt_Lost_cancel_report__c,
                Estimation_Id__c,
                DetailNum__c,
                Estimation_Decision__c,
                Sales_Root__c,
                AcecideCntCheck__c,
                IF_Submit__c ,
                Trade__c,
                Is_Corrosion__c,
                If_Authorizing_Lock__c
                from Opportunity where Id =: recordId
            ];
            res.agency1Id = opportunity.Agency1_ID_18__c;
            res.stageName = opportunity.StageName;
            res.sapSendOK = opportunity.SAP_Send_OK__c;
            res.oppOrderType = opportunity.Opp_order_Type__c;
            res.ifHave170 = opportunity.If_Have_170__c;
            res.ifHaveAH = opportunity.If_Have_AH__c;
            res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c;
            res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c;
            res.estimationId = opportunity.Estimation_Id__c;
            res.detailNum = opportunity.DetailNum__c;
            res.estimationDecision = opportunity.Estimation_Decision__c;
            res.salesRoot = opportunity.Sales_Root__c;
            res.acecideCntCheck = opportunity.AcecideCntCheck__c;
            res.ifSubmit = opportunity.IF_Submit__c;
            res.trade = opportunity.Trade__c;
            res.isCorrosion = opportunity.Is_Corrosion__c;
            res.ifAuthorizingLock = opportunity.If_Authorizing_Lock__c;
            String profile18 = UserInfo.getProfileId();
            res.profileId = profile18.substring(0,profile18.length() - 3);
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForLoseBidButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                ifOpenBid__c
                from Opportunity where Id =: recordId
            ];
            res.ifOpenBid = opportunity.ifOpenBid__c;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForOLYwinBidButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                ifOpenBid__c
                from Opportunity where Id =: recordId
            ];
            res.ifOpenBid = opportunity.ifOpenBid__c;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForCreateEventButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                AccountId
                from Opportunity where Id =: recordId];
            res.accountId = opportunity.AccountId;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initFoBeforeOPDPDFBtnButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                AccountId
                from Opportunity where Id =: recordId
            ];
            res.accountId = opportunity.AccountId;
            res.userId = UserInfo.getUserId();
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initFoBeforeOPDPDFBtnSISButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                AccountId
                from Opportunity where Id =: recordId
            ];
            res.accountId = opportunity.AccountId;
            res.userId = UserInfo.getUserId();
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForRequestDBButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                StageName,
                SAP_Send_OK__c,
                Cnt_Lost_cancel_report__c,
                Cnt_Lost_cancel_Draft__c,
                Agency1__c,
                Agency1_ID_18__c,
                Name,
                Bid_Planned_Date__c,
                Sales_assistant_name__c,
                Sales_assistant_ID__c
                from Opportunity where Id =: recordId
            ];
            res.stageName = opportunity.StageName;
            res.sapSendOK = opportunity.SAP_Send_OK__c;
            res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c;
            res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c;
            res.agency1 = opportunity.Agency1__c;
            res.agency1Id = opportunity.Agency1_ID_18__c;
            res.name = opportunity.Name;
            res.bidPlannedDate = opportunity.Bid_Planned_Date__c;
            res.salesAssistantName = opportunity.Sales_assistant_name__c;
            res.salesAssistantID = opportunity.Sales_assistant_ID__c;
            String profileId18 = UserInfo.getProfileId();
            res.profileId = profileId18.substring(0, profileId18.length() - 3);
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static string updateForAgencyAuthorizeButton(String recordId){
        try {
            Opportunity opp = new Opportunity();
            opp.Id = recordId;
            opp.If_Authorizing__c = true;
            opp.if_Interface_Lock__c = true;
            opp.IF_Submit__c = true;
            update opp;
            return null;
        } catch (Exception e) {
            String eMessage = e.getMessage();
            Integer left  = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    @AuraEnabled
    public static string updateForLoseBidButton(String recordId){
        try {
            Opportunity opp = new Opportunity();
            opp.Id = recordId;
            opp.ConfirmationofAward__c = '竞争对手中标';
            update opp;
            return null;
        } catch (Exception e) {
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    @AuraEnabled
    public static string updateForOLYwinBidButton(String recordId){
        try {
            Opportunity opp = [select ConfirmationofAward__c,Closing_Bid_Date__c from Opportunity where Id =: recordId];
            opp.ConfirmationofAward__c = 'OLY中标';
            if (opp.Closing_Bid_Date__c == null) {
                opp.Closing_Bid_Date__c = Date.today();
            }
            update opp;
            return null;
        } catch (Exception e) {
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    @AuraEnabled
    public static List<InquiryPredictsDateChange__c> queryForPredictedDateChangeButton(String recordId){
        List<InquiryPredictsDateChange__c> rac = null;
        try {
            rac = [
                select
                id
                from InquiryPredictsDateChange__c where Predicted_Date_Status__c = '审批中' and Opportunity__c =:recordId];
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return rac;
    }
    @AuraEnabled
    public static List<task__c> queryForLoseBidButton(String recordId){
        List<task__c> tasks = null;
        try {
            tasks = [
                select
                taskStatus__c
                from task__c where OpportunityId__c =: recordId and name like '%中标结果确认%'];
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return tasks;
    }
    @AuraEnabled
    public static List<task__c> queryForOLYwinBidButton(String recordId){
        List<task__c> tasks = null;
        try {
            tasks = [
                select
                taskStatus__c
                from task__c where OpportunityId__c =: recordId and name like '%中标结果确认%'];
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return tasks;
    }
    public class InitData{
        @AuraEnabled
        public Boolean directLossFLG;
        @AuraEnabled
        public Date createdDay;
        @AuraEnabled
        public String agency1Id;
        @AuraEnabled
        public String agency1;
        @AuraEnabled
        public String stageName;
        @AuraEnabled
        public Boolean sapSendOK;
        @AuraEnabled
        public String oppOrderType;
        @AuraEnabled
        public Boolean ifHave170;
        @AuraEnabled
        public Boolean ifHaveAH;
        @AuraEnabled
        public Decimal cntLostCancelDraft;
        @AuraEnabled
        public Decimal cntLostCancelReport;
        @AuraEnabled
        public String estimationId;
        @AuraEnabled
        public Decimal detailNum;
        @AuraEnabled
        public Boolean estimationDecision;
        @AuraEnabled
        public String salesRoot;
        @AuraEnabled
        public Boolean acecideCntCheck;
        @AuraEnabled
        public Boolean ifSubmit;
        @AuraEnabled
        public String trade;
        @AuraEnabled
        public Boolean isCorrosion;
        @AuraEnabled
        public Boolean ifAuthorizingLock;
        @AuraEnabled
        public String profileId;
        @AuraEnabled
        public String ifOpenBid;
        @AuraEnabled
        public String accountId;
        @AuraEnabled
        public String userId;
        @AuraEnabled
        public String name;
        @AuraEnabled
        public Date bidPlannedDate;
        @AuraEnabled
        public String salesAssistantName;
        @AuraEnabled
        public String salesAssistantID;
    }
}
force-app/main/default/classes/OpportunityLightingButtonController.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>56.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/OpportunityService.cls
New file
@@ -0,0 +1,457 @@
public with sharing   class OpportunityService{
  private static String opp_search_field = ' Id, Name, Account_Name_F__c, OwnerId, Hospital__c, Opportunity_No__c, Opportunity_stage__c, StageName__c, Bidding_Project_Name_Bid__c, Department_Class__r.RecordTypeId ';
  // 查询已保存的数据
  //noStr 询价的ID
  //daccountID 客户的ID 现在没用
  // IdStr 招投标的ID
  //hospital 医院的ID
  @AuraEnabled
  public  static string GetNormalProductDataSearch(String noStr,String accountId,String IdStr,String hospital,String[] hospitalArr, String departments) {
    String sql = 'select ';
    // sql += CommonUtils.GetSqlToPorps(Opportunity.SObjectType);
    sql += opp_search_field;
    sql += ' from Opportunity';
    // 多对多关系 去掉未关联的判断 start
    // sql += ' where Bidding_Project_Name_Bid__c = null ';
    sql += ' where id != null ';
    // 多对多关系 去掉未关联的判断 end
    if(noStr != null && noStr != '' && noStr != ' ')
    {
      sql += ' and Opportunity_No__c = :noStr';
    }
    if(hospitalArr!= null && hospitalArr.size() > 0)
    {
      sql += ' and Hospital__c in :hospitalArr';
    }
    if(hospital != null && hospital != '' && hospital != ' ')
    {
      sql += ' and Hospital__c = :hospital';
    }
    // String paremt1 = '012100000006KMe';
    // String paremt2 = '01210000000QekK';
    // String paremt3 = '引合';
    // sql += ' and (recordtypeid = :paremt1 or recordtypeid = :paremt2) and stagename = :paremt3 ';
    sql += ' and recordtype.developername in (\'Opportunity\',\'SI_Oppor\') and Hospital__r.Is_Active__c = \'有効\' '+
        // 这里有修改,别给盖了
    ' and ( (SAP_Send_OK__c = true and SAP_Send_OK_Date__c   = LAST_N_DAYS:183  ) '+
        'or( stagename = \'敗戦\' and Final_Contract_Proceeded_Date__c = LAST_N_DAYS:183  ) or stagename = \'引合\' ) ';
      // 这里有修改,别给盖了
    // 20210914 战略科室修改
    //if (departments != null && String.isNotBlank(departments)) {
    //  String[] depart_types = departments.split(';');
    //  if (depart_types != null && depart_types.size() > 0 && depart_types.size() < 6) {
    //    sql += ' and Department_Class__r.RecordTypeId in :depart_types ';
    //  }
    //}
    // 20210914 战略科室修改
    // 去掉已经关联的招标
    if(IdStr != null && String.isNotBlank(IdStr)) {
      sql += ' and id not in (select Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c = :IdStr) ';
    }
    // 20221014 ljh SWAG-CK28WT add start
    String proId = UserInfo.getProfileId();
    String p_2M4 = System.Label.ProfileId_2M4;
    if(proId.substring(0,15) == p_2M4.substring(0,15)){
       sql += ' AND OwnerId =\''+UserInfo.getUserId()+'\'';
    }
    System.debug('sql:'+sql);
    // 20221014 ljh SWAG-CK28WT add end
    sql += '  limit 50';
    List<Opportunity> arrays = Database.query(sql);
    return JSON.serialize(arrays);
  }
 // 查询未保存的数据
  // IdStr 招投标的ID
  //hospital 医院的ID
  @AuraEnabled
  public  static string GetNormalProductDataNotSave(String IdStr,String[] hospital, String departments) {
    //TODU
    // QueryWrapper query = new QueryWrapper(Tender_information__c.SObjectType);
    // query.eq('Id',IdStr);
    // 招标-询价关联修改 20210813 start
    String sql = 'select ';
    // sql += CommonUtils.GetSqlToPorps(Opportunity.SObjectType);
    sql += opp_search_field;
    sql += ' from Opportunity';
    // 多对多关系 去掉未关联的判断 start
    // sql += ' where Bidding_Project_Name_Bid__c = null ';
    // 多对多关系 去掉未关联的判断 end
    // String paremt1 = '012100000006KMe';
    // String paremt2 = '01210000000QekK';
    // String paremt3 = '引合';
    // sql += ' and (recordtypeid = :paremt1 or recordtypeid = :paremt2) and stagename = \'引合\' ';
    // sql += ' and recordtype.developername in (\'Opportunity\',\'SI_Oppor\') and Hospital__r.Is_Active__c = \'有効\' '+
    sql += ' where recordtype.developername in (\'Opportunity\',\'SI_Oppor\') and Hospital__r.Is_Active__c = \'有効\' '+
        // 这里有修改,别给盖了
    ' and ( (SAP_Send_OK__c = true and SAP_Send_OK_Date__c   = LAST_N_DAYS:183 ) '+
        'or( stagename = \'敗戦\' and Final_Contract_Proceeded_Date__c = LAST_N_DAYS:183  ) or stagename = \'引合\' ) ';
      // 这里有修改,别给盖了
    // 去掉已经关联的招标
    if(IdStr != null && String.isNotBlank(IdStr)) {
      sql += ' and id not in (select Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c = :IdStr) ';
    }
    // 20210914 战略科室修改
    //if (departments != null && String.isNotBlank(departments)) {
    //  String[] depart_types = departments.split(';');
    //  if (depart_types != null && depart_types.size() > 0 && depart_types.size() < 6) {
    //    sql += ' and Department_Class__r.RecordTypeId in :depart_types ';
    //  }
    //}
    // 20210914 战略科室修改
    if(hospital!= null && hospital.size() > 0)
    {
      sql += ' and Hospital__c in :hospital';
    }
    // 20221014 ljh SWAG-CK28WT add start
    String proId = UserInfo.getProfileId();
    String p_2M4 = System.Label.ProfileId_2M4;
    if(proId.substring(0,15) == p_2M4.substring(0,15)){
       sql += ' AND OwnerId =\''+UserInfo.getUserId()+'\'';
    }
    System.debug('sql:'+sql);
    // 20221014 ljh SWAG-CK28WT add end
    sql += '  limit 50';
    List<Opportunity> arrays = Database.query(sql);
    // Tender_information__c
    return JSON.serialize(arrays);
    // 招标-询价关联修改 20210813 end
  }
  //查询已保存
  // 只有一个 当前招投标
  //IdStr 招投标的ID
  @AuraEnabled
  public  static string GetNormalProductDataIsSave(String IdStr) {
    // 招标-询价关联修改 20210817 start
    // 查询方式或许应该优化一下
    // QueryWrapper query = new QueryWrapper(Opportunity.SObjectType);
    // query.eq('Bidding_Project_Name_Bid__c', IdStr);
    // List<Opportunity> arrays = DataBasePlus.listPlus(query);
    List<Id> oppIds = new List<Id>();
    List<Tender_Opportunity_Link__c> links = [select Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c = :IdStr];
    if (links != null && links.size() > 0) {
      for (Tender_Opportunity_Link__c link : links) {
        oppIds.add(link.Opportunity__c);
      }
    }
    // String sql = 'select ' + CommonUtils.GetSqlToPorps(Opportunity.SObjectType) + ' from Opportunity ';
    String sql = 'select ' + opp_search_field + ' from Opportunity ';
    sql += 'where Id in :oppIds';
    List<Opportunity> arrays = Database.query(sql);
    // 招标-询价关联修改 20210817 end
    return JSON.serialize(arrays);
  }
  //保存
   //JsonSelected JSON格式的招投标的已选择数据集合
   //JsonNotSelected JSON格式的招投标的未选择数据集合
   // BiddingId 对应的招标项目名(招投标)
   // flag  修改 招投标项目 关联询价时间的一个标识
  @AuraEnabled
  public  static string SaveData(String JsonSelected,String JsonNotSelected,String BiddingId,Boolean flag) {
    try{
      // 新增招标-询价关联关系表,去掉更新询价上的最新招标信息 20210813 start
      // if(JsonSelected != null &&  JsonSelected != '' && JsonSelected !='[]')
      // {
      //   List<Opportunity> SelectedList = (List<Opportunity>)JSON.deserialize(JsonSelected,List<Opportunity>.class);
      //   for(Opportunity item :SelectedList){
      //     item.Bidding_Project_Name_Bid__c = null;
      //   }
      // Database.update(SelectedList,false);
      // }
      // string OppOwnerId = '';
      // if(JsonNotSelected != null &&  JsonNotSelected != '' && JsonNotSelected !='[]')
      // {
      //   List<Opportunity> NotSelectedList = (List<Opportunity>)JSON.deserialize(JsonNotSelected,List<Opportunity>.class);
      //   for(Opportunity item :NotSelectedList){
      //     item.Bidding_Project_Name_Bid__c = BiddingId;
      //   }
      //   OppOwnerId = NotSelectedList[0].ownerId;
      //   Database.update(NotSelectedList);
      // }
      // if(flag != null && flag == true)
      // {
      //   string tenProp = CommonUtils.GetSqlToPorps(Tender_information__c.SObjectType);
      //   String sql = 'select '+tenProp+' from Tender_information__c  where Id = :BiddingId';
      //   List<Tender_information__c> arrays = Database.query(sql);
      //   arrays[0].RelateOppTime__c = datetime.now();
      //   //if( arrays[0].IsBid__c == null && OppOwnerId != '')
      //   //{
      //   //  arrays[0].ownerId = OppOwnerId;
      //   //}
      //   if (arrays != null && arrays.size() >0 &&
      //   (arrays[0].ownerId == '00510000005sEEM' || arrays[0].ownerId == '00510000000gmxH')
      //   && OppOwnerId != '')
      //   {
      //     arrays[0].ownerId = OppOwnerId;
      //   }
      //   Database.update(arrays);
      // }
      // 新增招标-询价关联关系表,去掉更新询价上的最新招标信息 20210813 end
      // 招标-询价关联修改 20210813 start
      // 查询招标
      // string tenProp = CommonUtils.GetSqlToPorps(Tender_information__c.SObjectType);
      // String sql = 'select '+tenProp+' from Tender_information__c  where Id = :BiddingId';
      String sql = 'SELECT ';
      sql += 'Id, ';
      sql += 'NotBidApprovalStatus__c, ';
      sql += 'IsBid__c, ';
      sql += 'TenderBeginTime__c, ';
      sql += 'InfoType__c, ';
      sql += 'OwnerId, ';
      sql += 'IsReactionOpp__c, ';
      sql += 'IsRelateProject__c, ';
      sql += 'RelateOppTime__c, ';
      sql += 'irrelevantReasons__c, ';
      sql += 'irrelevantReasonOther__c, ';
      sql += 'Hospital__c, ';
      sql += 'Hospital1__c, ';
      sql += 'Hospital2__c, ';
      sql += 'Hospital3__c, ';
      sql += 'Hospital4__c, ';
      sql += 'publicDate__c, ';// 20221114 ljh SWAG-CKL5UC
      sql += 'Tender_Order__c, ';  //20220620 you SWAG-CFD4SU
      sql += 'subInfoType__c ';  //20220718 you 招标任务
      sql += 'FROM Tender_information__c  WHERE Id = :BiddingId order by Tender_Order__c desc,relativeTime_F__c desc'; //20220620 you SWAG-CFD4SU 增加 order by
      List<Tender_information__c> arrays = Database.query(sql);
      Tender_information__c tender = arrays[0];
      // 不应标申请中的时候 调回申请修改 20210907 start
      if (tender.NotBidApprovalStatus__c != null && tender.NotBidApprovalStatus__c == '申请中') {
        List<Approval.ProcessWorkitemRequest> requests = new List<Approval.ProcessWorkitemRequest> ();
        ProcessInstance pi = [Select Id, SubmittedById from ProcessInstance where TargetObjectId = :tender.Id and Status = 'Pending' order by CreatedDate desc limit 1];
        if (pi != null) {
          for(ProcessInstanceWorkItem wi : [Select Id from ProcessInstanceWorkItem where ProcessInstanceId = :pi.Id]){
            Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest();
            if (pi.SubmittedById.equals(Userinfo.getUserId())) {
              req2.setAction('Removed');
              tender.NotBidApprovalStatus__c = '草案中';
            } else {
              req2.setAction('Reject');
              tender.NotBidApprovalStatus__c = '驳回';
              tender.IsBid__c = null;
            }
            req2.setWorkitemId(wi.Id);
            requests.add(req2);
          }
          system.debug('==requests.size()=='+requests.size());
          if (requests.size() > 0) {
            Approval.ProcessResult[] processResults = null;
            processResults = Approval.process(requests, true);
            system.debug('==调回结果=='+processResults);
          }
        }
      }
      // 不应标申请中的时候 调回申请修改 20210907 end
      // 合并已关联和未关联列表
      List<Opportunity> all_selected_list = new List<Opportunity>();
      if (JsonSelected != null &&  JsonSelected != '' && JsonSelected !='[]') {
        all_selected_list.addAll((List<Opportunity>)JSON.deserialize(JsonSelected,List<Opportunity>.class));
      }
      if (JsonNotSelected != null &&  JsonNotSelected != '' && JsonNotSelected !='[]') {
        all_selected_list.addAll((List<Opportunity>)JSON.deserialize(JsonNotSelected,List<Opportunity>.class));
      }
      // 招标所有人是否要修改flag
      // boolean owner_change = false;
      // 先删除旧的link
      // 跳过trigger标记
      // 没有删除逻辑
      StaticParameter.EscapeTOLinkTrigger = true;
      // List<Tender_Opportunity_Link__c> del_links = [select Id from Tender_Opportunity_Link__c where Tender_information__c = :BiddingId];
      // if (del_links != null && del_links.size() > 0) {
      //   delete del_links;
      // }
      // 更新询价
      List<Opportunity> upd_opps = new List<Opportunity>();
      List<Opportunity> upd_opps1 = new List<Opportunity>();
      List<String> owners = new List<String>();
      // 插入link
      if (all_selected_list.size() > 0) {
        // 设置招标所有人
        // OppOwnerId = all_selected_list[0].ownerId;
        // 初始化参数
        List<Tender_Opportunity_Link__c> add_list = new List<Tender_Opportunity_Link__c>();
        // 当询价关联过结果阶段的招标项目,再被另一个结果阶段的招标项目关联时,会因为数据被锁定而报错
        // 在此处重新检索询价
        List<String> oppIds = new List<String>();
        for (Opportunity opp : all_selected_list) {
          oppIds.add(opp.Id);
          owners.add(opp.ownerId);
          // 新建link
          Tender_Opportunity_Link__c link = new Tender_Opportunity_Link__c();
          link.Tender_information__c = tender.Id;
          link.Opportunity__c = opp.Id;
          link.Tender_Opportunity_Uniq__c = String.valueOf(tender.Id) + String.valueOf(opp.Id);
          add_list.add(link);
        }
        // 插入link
        if (add_list.size() > 0) {
          insert add_list;
        }
        // 恢复trigger标记
        StaticParameter.EscapeTOLinkTrigger = false;
        //20220620 you SWAG-CFD4SU 改造 start  始终显示最新的 ① 3:结果,② 4:变更,③ 2:公告,④ 1:预告,⑤ 5:其他
        List<String> tenIds = new List<String>();//20220718 you 招标任务
        system.debug('opportunityservicetest'+oppIds);
        if (oppIds.size() > 0) {
          // 20221114 SWAG-CKL5UC ljh 增加 Created_Day__c,LeadSource,LeakageNumber__c
          List<Opportunity> wait_upd_opps = [select id,Opp_Order__c,Tender_Number__c, Bidding_Project_Name_Bid__c, Bidding_Project_Name_Bid__r.InfoType__c,Created_Day__c,LeadSource,LeakageNumber__c from Opportunity where id in :oppIds ];//and Bidding_Project_Name_Bid__r.InfoType__c != '3:结果'];
          if (wait_upd_opps != null && wait_upd_opps.size() > 0) {
            for (Opportunity opp : wait_upd_opps) {
              /**
              if (opp.Bidding_Project_Name_Bid__c == null || String.isBlank(opp.Bidding_Project_Name_Bid__c)) {
                opp.Bidding_Project_Name_Bid__c = tender.Id;
                opp.TenderBeginDate_Text__c = tender.TenderBeginTime__c;
                upd_opps.add(opp);
              } else if (tender.InfoType__c == '3:结果' && opp.Bidding_Project_Name_Bid__r.InfoType__c != '3:结果') {
                opp.Bidding_Project_Name_Bid__c = tender.Id;
                upd_opps.add(opp);
              }
              **/
              if(opp.Opp_Order__c <= tender.Tender_Order__c){
                opp.Bidding_Project_Name_Bid__c =tender.Id;
                //opp.TenderBeginDate_Text__c = tender.TenderDate__c;//更改询价2时修改这个字段,引用超20,tender.TenderBeginTime__c;
                upd_opps.add(opp);
                //20220715 you 招标项目 start
                if(String.isNotBlank(tender.InfoType__c) && tender.InfoType__c=='3:结果' && String.isNotBlank(tender.subInfoType__c) && (tender.subInfoType__c=='3-5:中标通知' || tender.subInfoType__c=='3-6:合同公告')){
                  tenIds.add(opp.id); //符合条件生成任务
                }
                //20220715 you 招标项目 end
                break;
              }
            }
            //20220829 you SWAG-CHL67J start
            for (Opportunity opp : wait_upd_opps) {
              Integer returncount =0;
              if(String.isNotBlank(tender.InfoType__c) && tender.InfoType__c!='1:预告' && String.isNotBlank(tender.subInfoType__c) && tender.subInfoType__c!='3-1:废标公告' && tender.subInfoType__c!='3-2:流标公告'){
                  returncount += 1;
                }
              opp.Tender_Number__c = returncount;
              // 20221114 ljh SWAG-CKL5UC start
              if(opp.LeakageNumber__c != 1 && tender.publicDate__c != null && String.isNotBlank(opp.LeadSource) && opp.LeadSource == '招标网' && opp.Created_Day__c > tender.publicDate__c){
                opp.LeakageNumber__c = 1;
              }
              // 20221114 ljh SWAG-CKL5UC start
              upd_opps1.add(opp);
            }
            //20220829 you SWAG-CHL67J end
          }
        }
        if (upd_opps1.size() > 0) {
          update upd_opps1;
        }
        //20220620 you SWAG-CFD4SU 改造 end
        // 更新询价上的招标项目
        if (upd_opps.size() > 0) {
          update upd_opps;
        }
         //20220718 you 招标任务 start
        if (tenIds !=null && tenIds.size() > 0) {
            Database.executeBatch(new TenderResultConfirmTaskBatch(tenIds));
          }
          //20220718 you 招标任务 end
      }
      // 查询招标数量并更新
      List<Tender_Opportunity_Link__c> tenderLinks = [SELECT id, Tender_information__c, Opportunity__c, Opportunity__r.Hospital__c, Opportunity__r.OwnerId FROM Tender_Opportunity_Link__c WHERE Tender_information__c = :tender.Id];
      List<String> oppOwnerInLinks = new List<String>();
      for (Tender_Opportunity_Link__c link : tenderLinks) {
        oppOwnerInLinks.add(link.Opportunity__r.OwnerId);
      }
      // 更新招标上的所有人
      if (tender.OwnerId == null || '00510000000gmxH'.equals(tender.OwnerId) || (oppOwnerInLinks.size() > 0 && !oppOwnerInLinks.contains(tender.OwnerId))) {
        tender.ownerId = owners.size() > 0 ? owners.get(0) : '00510000000gmxH';
      }
      // 反映询价状态
      tender.IsReactionOpp__c = true;
      // 查询招标数量并更新
      //List<Tender_Opportunity_Link__c> tenderLinks = [SELECT id, Tender_information__c, Opportunity__c, Opportunity__r.Hospital__c FROM Tender_Opportunity_Link__c WHERE Tender_information__c = :tender.Id];
      tender.OpportunityNum__c = tenderLinks != null ? tenderLinks.size() : 0;
      // 关联询价时间和是否相关状态
      if (tender.IsRelateProject__c != '是') {
        tender.IsRelateProject__c = '是';
        tender.RelateOppTime__c = datetime.now();
        tender.irrelevantReasons__c = null;
        tender.irrelevantReasonOther__c = null;
      }
      // 更新关联医院
      if (tenderLinks != null && tenderLinks.size() > 0) {
        // 招标项目的医院
        Map<String,String> fiveHospitalMap = new Map<String,String>();
        fiveHospitalMap.put('Hospital__c', tender.Hospital__c);
        fiveHospitalMap.put('Hospital1__c', tender.Hospital1__c);
        fiveHospitalMap.put('Hospital2__c', tender.Hospital2__c);
        fiveHospitalMap.put('Hospital3__c', tender.Hospital3__c);
        fiveHospitalMap.put('Hospital4__c', tender.Hospital4__c);
        for(Integer i = 0; i<tenderLinks.size();i++) {
          //当招投标项目的五个医院赋值完成后不再赋值
          Boolean HospitalIsNeedBreak = false;
          for(String ApiName :fiveHospitalMap.keySet()){
              HospitalIsNeedBreak = fiveHospitalMap.get(ApiName)==null?false:true;
          }
          if(HospitalIsNeedBreak){
              break;
          }
          //给招投标项目的5个医院设值
          for(String ApiName : fiveHospitalMap.keySet()){
            String tempTenderHospId = fiveHospitalMap.get(ApiName)==null?'':fiveHospitalMap.get(ApiName);
            String oppHospId = tenderLinks.get(i).Opportunity__r.Hospital__c;
            //如果招标项目已经有该医院就判断下一个询价的医院
            if(tempTenderHospId.contains(oppHospId)){
                break;
            }
            //医院为空,赋值医院(赋值之后进行赋值下一个医院)
            if(String.isBlank( fiveHospitalMap.get(ApiName) )){
                fiveHospitalMap.put(ApiName,oppHospId);
                break;
            }
          }
        }
        tender.Hospital__c = fiveHospitalMap.get('Hospital__c');
        tender.Hospital1__c = fiveHospitalMap.get('Hospital1__c');
        tender.Hospital2__c = fiveHospitalMap.get('Hospital2__c');
        tender.Hospital3__c = fiveHospitalMap.get('Hospital3__c');
        tender.Hospital4__c = fiveHospitalMap.get('Hospital4__c');
      }
      update tender;
      // 招标-询价关联修改 20210813 end
      return '成功';
    }catch (Exception ex) {
      return  ex.getMessage();
    }
  }
}
force-app/main/default/classes/OpportunityService.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>51.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/OpportunityWebService.cls
New file
@@ -0,0 +1,506 @@
global class OpportunityWebService {
    @AuraEnabled
    WebService static String changeTrade(String oppId){
        List<Quote> quoList = [select id from Quote where OpportunityId = :oppId];
        List<OpportunityLineItem> oppLI = [select id from OpportunityLineItem where Opportunity.id = :oppId];
        Opportunity opp = new Opportunity();
        opp.id = oppId;
        opp.Estimation_Decision__c = false;
        opp.Estimation_Id__c = null;
        opp.Quote_Update_Sum__c = null;
        opp.Estimation_No__c = null;
        opp.Estimation_Proposal_Date__c = null;
        opp.Estimation_Name__c = null;
        // LHJ SWAG-C9QAAJ 去掉 Start
        // opp.Authorized_Finish_Sales__c = null;
        // opp.Authorized_DB_No__c = null;
        // opp.Authorized_Date__c = null;
        // opp.Autholization_Activated_Date__c = null;
        // opp.Bidding_Content__c = null;
        // opp.Bid_Date__c = null;
        // opp.Bidding_No__c = null;
        // opp.Bidding_Project_Name__c = null;
        // LHJ End
        Savepoint sp = Database.setSavepoint();
        try {
            delete quoList;
            delete oppLI;
            update opp;
            return '1';
        } catch (Exception ex) {
            Database.rollback(sp);
            return  ex.getMessage() + ' | Line:' + ex.getLineNumber();
        }
    }
    // LHJ CBPR Start
    webservice String parameter { get; set; }
    public OpportunityWebService() {
        this.parameter = 'value';
    }
    @AuraEnabled
    WebService static String oppCheck(String oppid, String saveFlg) {
        Map<Id, String> proMap= new Map<Id, String>();
        List<OpportunityLineItem> OppItemList = [select PricebookEntry.Product2Id, PricebookEntry.Product2.Name
                                                   From OpportunityLineItem
                                                  Where OpportunityId = :oppid];
        if (OppItemList.size() > 0) {
            for (OpportunityLineItem opl : OppItemList) {
                proMap.put(opl.PricebookEntry.Product2Id, opl.PricebookEntry.Product2.Name);
            }
        }
        List<Opportunity> oppList = [select Agency1__c from Opportunity where id = :oppid];
        String angencyId = oppList[0].Agency1__c;
        String strRet = '';
        if (saveFlg == '1') {
            strRet = checkProRegisterDecide(proMap, angencyId, oppid);
        } else {
            strRet = checkProRegisterDecide(proMap, angencyId, '');
        }
        return strRet;
    }
    @AuraEnabled
    // LHJ 阿西赛多检查 Start
    WebService  static String checkDangerItem(String agency1) {
        //没有危化品证照的提示信息
        String licenseStr = '第一经销商没有有效的危险化学品经营许可证。';
        //没有阿西赛多经销商协议的提示信息
        String accStr = '第一经销商没有阿西赛多经销商协议。';
        //检查是否有证照
        List<License_Information__c> licenseList = [SELECT Id
                                                      FROM License_Information__c
                                                     WHERE LicenseAndAccount__c = :agency1
                                                       AND LicenseType__c = '危险化学品经营许可证'
                                                       AND Is_Active_Formula__c = true
                                                    ];
        //检查是否有阿西赛多协议
        List<Account> accountList = [SELECT Id
                                                      FROM Account
                                                     WHERE Parent.id = :agency1
                                                       //阿西赛多 增加检索阿西赛多协议 以及 可以做报价(复选框) 精琢技术 wql 2021/01/04 start
                                                       AND Contract_Quote_Decide_Flag_checkbox__c =true
                                                       AND Assiesedo_Dealer__c  = true
                                                       //阿西赛多 增加检索阿西赛多协议 以及 可以做报价(复选框) 精琢技术 wql 2021/01/04 end
                                                    ];
        system.debug('licenseList:'+licenseList.size());
        system.debug('agency1:'+agency1);
        //①既没有危化品证也没有阿西赛多协议
        if(licenseList.size() == 0 && accountList.size() ==0){
            return licenseStr+accStr;
        }
        //②没有危化品证
        else if(licenseList.size() ==0){
            return licenseStr;
        }
        //②没有阿西赛多经销商协议
        else if(accountList.size() ==0){
            return accStr;
        }
        //③全都有
        else{
            return 'OK';
        }
    }
    // LHJ 阿西赛多检查 End
    public static Map<String, String> MapCheckProRegisterDecide(Map<Id, String> proMap, String agency1, String OppId) {
        Map<String, String> retMap = new Map<String, String>();
        String errormessage = '';
        Boolean error = false;
        Map<String,List<String>> proAllBSstrMap;
        List<String> proNotNeedList = new List<String>();
        Map<String,List<String>> old_newMap = new Map<String,List<String>>();
        Map<String,List<String>> new_oldMap = new Map<String,List<String>>();
        // 取得 经营范围对应产品关系
        List<String> midStr = new List<String>();
        List<String> midStrO = new List<String>();
        // List<Product_Register_contrast__c> rrList = Product_Register_contrast__c.getall().values();
        // for (Product_Register_contrast__c rr : rrList) {
        //     midStr = new List<String>();
        //     midStrO = new List<String>();
        //     // 经营范围对应产品关系 Map作成 旧-新对照
        //     if (old_newMap.containsKey(rr.Register_old__c)) {
        //         old_newMap.get(rr.Register_old__c).add(rr.Register_new__c);
        //     } else {
        //         midStrO.add(rr.Register_new__c);
        //         old_newMap.put(rr.Register_old__c, midStrO.clone());
        //     }
        //     // 经营范围对应产品关系 Map作成 新-旧对照
        //     if (new_oldMap.containsKey(rr.Register_new__c)) {
        //         new_oldMap.get(rr.Register_new__c).add(rr.Register_old__c);
        //     } else {
        //         midStr.add(rr.Register_old__c);
        //         new_oldMap.put(rr.Register_new__c, midStr.clone());
        //     }
        // }
        // 取得经销商 医疗器械经营许可证
        List<License_Information__c> licenseList = [SELECT Id,
                                                           ScopeKey__c,
                                                           LicenseType__c
                                                      FROM License_Information__c
                                                     WHERE LicenseAndAccount__c = :agency1
                                                    AND (LicenseType__c = '医疗器械经营许可证'
                                                        OR LicenseType__c = '第二类医疗器械经营备案凭证')
                                                      AND Is_Active_Formula__c = true
                                                    ];
        // 判断 医疗器械经营许可证 是否存在
        if (licenseList.size() == 0) {
            error = true;
            errormessage = '第一经销商没有有效的医疗器械经营许可证。';
            retMap.put('agency', '0');
        } else {
            //经销商经营范围
            List<String> agListA = new List<String>();
            List<String> agListTemp = new List<String>();
            List<String> agList = new List<String>();
            //取经销商下 所有医疗器械经营许可证、第二类医疗器械经营备案凭证
            for (License_Information__c li : licenseList) {
                if (li.ScopeKey__c != null) {
                    agListA.addAll(li.ScopeKey__c.split(';'));
                    agListTemp.addAll(li.ScopeKey__c.split(';'));
                }
            }
            for (String a : agListTemp) {
                if (a.length() >= 6) {
                    agList.add(a.substring(0, a.length() - 1));
                } else {
                    agList.add(a.trim());
                }
            }
            //产品注册证
            Map<String,Map<String,String>> proBSMap = new Map<String,Map<String,String>>();
            Map<String,String> proMidMap = null;
            //产品所有有效注册证(可以和经销商匹配)
            proAllBSstrMap = new Map<String,List<String>>();
            set<Id> proIdList = new set<Id>();
            for (String qli : proMap.keySet()) {
                    proIdList.add(qli);
                    proBSMap.put(qli, proMidMap);
                    List<String> empList = new List<String>();
                    proAllBSstrMap.put(qli, empList);
            }
            List<Product_Register_Link__c> prls = [
                                                 Select Product2__c,
                                                        Product2__r.Asset_Model_No__c,
                                                        Product2__r.SFDA_Approbated_Status__c,
                                                        Product2__r.SFDA_Status_New__c, // 产品的CFDA最终状态 20181225
                                                        Product_Register__r.Name,
                                                        Product_Register__r.BusinessScopeKey__c,
                                                        Product_Register__r.RegisterNoStatus__c,
                                                        Product_Register__r.MedPrdClass__c
                                                   From Product_Register_Link__c
                                                  where Product2__c in :proIdList
                                                  ];
            // LHJ 20190102 增加跳过逻辑 Start
            List<Product2> productList = [select ID,SFDA_Status__c from Product2 where id in :proIdList];
            for (Product2 pro : productList) {
                if (pro.SFDA_Status__c == '不要') {
                    proNotNeedList.add(pro.ID);
                }
            }
            // LHJ 20190102 增加跳过逻辑 End
            for (Product_Register_Link__c prl : prls) {
                // 设置产品类别MAP
                if (String.isNotBlank(prl.Product_Register__r.BusinessScopeKey__c)) {
                    system.debug('Product2 +++++++' + prl.Product2__c);
                    if (proBSMap.get(prl.Product2__c) != null) {
                        proBSMap.get(prl.Product2__c).put(prl.Product_Register__r.Name, prl.Product_Register__r.BusinessScopeKey__c);
                    } else {
                        Map<String,String> toooMap = new Map<String,String>();
                        toooMap.put(prl.Product_Register__r.Name, prl.Product_Register__r.BusinessScopeKey__c);
                        proBSMap.put(prl.Product2__c, toooMap.clone());
                    }
                }
                // 产品的产品注册证是"不要"状态 不需要匹配注册证 20181225
                if (prl.Product2__r.SFDA_Approbated_Status__c == '不要'
                        || prl.Product_Register__r.MedPrdClass__c == '1') {
                     proNotNeedList.add(prl.Product2__c);
                }
            }
            system.debug('proBSMap +++++++' + proBSMap);
            for (String qli : proMap.keySet()) {
                String proId = qli;
                String proName = proMap.get(proId);
                if (proId != null) {
                    Boolean haveBS = false;
                    // 产品属于非医疗,不用判断经营范围
                    if (proNotNeedList.contains(proId)) {
                        haveBS = true;
                        continue;
                    }
                    if (proBSMap.get(proId) == null) {
                        error = true;
                        errormessage += '产品"' + proName + '"没有有效的产品注册证。\n';
                        retMap.put(proId, '1');
                        continue;
                    }
                    if (proBSMap.get(proId) != null) {
                        system.debug('111 +++++++' + proBSMap);
                        Map<String,String> midMap = new Map<String,String>();
                        midMap = proBSMap.get(proId);
                        for (String str : midMap.keySet()) {
                            // LHJ 20200711 Start
                            String strMidMap = midMap.get(str);
                            List<String> proRegList = new List<String>();
                            proRegList.addAll(strMidMap.split(';'));
                            // LHJ 20200711 End
                            for(String strReg:proRegList){
                                // 被定义为"6815A"的产品类别,经营范围中必须有6815或者6815A外才可以匹配。
                                if (strReg.length() == 6) {
                                    for(String strAg:agListA){
                                        if(strAg.length() >= 5 && midMap.get(str.substring(0, str.length() - 1)) == strAg.substring(0,5)){
                                            proAllBSstrMap.get(proId).add(str.substring(0, str.length() - 1));
                                            haveBS = true;
                                            break;
                                        }
                                    }
                                    /*if (agListA.contains(midMap.get(str.substring(0, str.length() - 1)))) {
                                        proAllBSstrMap.get(proId).add(str.substring(0, str.length() - 1));
                                        haveBS = true;
                                    }*/
                                } else {
                                    system.debug('agList +++++++' + agList);
                                    system.debug('midMap +++++++' + strReg);
                                    if (agList.contains(strReg)) {
                                        //产品类别,匹配到经销商类别
                                        proAllBSstrMap.get(proId).add(str);
                                        haveBS = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (!haveBS) {
                        error = true;
                        errormessage += '第一经销商的经营范围中不包含产品" ' + proName + '"。\n';
                        retMap.put(proId, '2');
                    }
                }
            }
        }
        if (retMap.isEmpty() == false) {
            //return errormessage;
        } else {
            if (OppId != '') {
                // 更新所有注册证信息
                String strRegister_alleffective;
                List<Product2> pro2List = new List<Product2>();
                Map<String, Product2> pro2Map = new Map<String, Product2>();
                List<OpportunityLineItem> updList = new List<OpportunityLineItem>();
                List<OpportunityLineItem> OppItemList = [select id, Id__c, Register_alleffective__c,PricebookEntry.Product2Id
                                                           From OpportunityLineItem
                                                          Where OpportunityId = :OppId];
                // 非医疗或1类产品,取得
                if (proNotNeedList != null && proNotNeedList.size() > 0) {
                    pro2List = [select id, SFDA_Approbated_Status__c, RegisterNo_ALL__c from Product2 where Id in :proNotNeedList];
                }
                for (Product2 pro2 : pro2List) {
                    pro2Map.put(pro2.Id, pro2);
                }
                for (OpportunityLineItem ol : OppItemList) {
                    if (proAllBSstrMap.containsKey(ol.PricebookEntry.Product2Id)) {
                        ol.Register_alleffective__c = '';
                        for(String str: proAllBSstrMap.get(ol.PricebookEntry.Product2Id)) {
                            if (String.isNotBlank(ol.Register_alleffective__c)) {
                                ol.Register_alleffective__c += ';' + str;
                            } else {
                                ol.Register_alleffective__c = str;
                            }
                        }
                        // 非医疗或1类产品
                        if (pro2Map.containskey(ol.PricebookEntry.Product2Id)) {
                            if (pro2Map.get(ol.PricebookEntry.Product2Id).SFDA_Approbated_Status__c == '不要') {
                                ol.Register_alleffective__c = 'FYL';
                            } else {
                                ol.Register_alleffective__c = pro2Map.get(ol.PricebookEntry.Product2Id).RegisterNo_ALL__c;
                            }
                        }
                    }
                    updList.add(ol);
                }
                if (updList.size() > 0)  update updList;
            }
        }
        //如果不满足阿西赛多的条件,进入这个变量 20200821 ljh
        return retMap;
    }
    public static String checkProRegisterDecide(Map<Id, String> proMap, String agency1, String OppId) {
        String errormessage = '';
        Boolean error = false;
        Map<String, String> CheckMap = new Map<String, String>();
        CheckMap = MapCheckProRegisterDecide(proMap, agency1, OppId);
        if (CheckMap.isEmpty()) {
            return 'OK';
        } else {
            return '有不可销售产品或超出经销商经营范围,请更新报价单' + CheckMap;
        }
    }
    @AuraEnabled
    WebService static String updReg(String  oppid) {
        List<OpportunityLineItem> updList = new List<OpportunityLineItem>();
        List<OpportunityLineItem> OppItemList = [select id, Id__c, Register_alleffective__c,
                                                        PricebookEntry.Product2.RegisterNo_ALL__c
                                                           From OpportunityLineItem
                                                          Where OpportunityId = :oppid];
        for (OpportunityLineItem ol : OppItemList) {
            ol.Register_alleffective__c = ol.PricebookEntry.Product2.RegisterNo_ALL__c;
            updList.add(ol);
        }
        if (updList.size() > 0)  update updList;
        return 'OK';
    }
    //SWAG-CG88AG【委托】提出价格申请是在协议有效期内,允许WIN fy start
    WebService static Boolean judgeIsAssistantAppliedOutTime(String  Quoteid) {
        List<PromotionSales__c> PromotionSalesList = [select id,IsAssistantAppliedOutTime__c from PromotionSales__c where Quote__r.Quote_No__c =:Quoteid];
        for(PromotionSales__c pro : PromotionSalesList){
            if(pro.IsAssistantAppliedOutTime__c){
                return false;
            }
        }
        return true;
    }
    //SWAG-CG88AG【委托】提出价格申请是在协议有效期内,允许WIN fy end
    //贸易合规 20230307 you start
    WebService static Boolean accSendEmail(String  AccDealerBlacklist,String accname,String angency1,String angency2,String ownerids,String ddid,String oppid) {
      //发送邮件
        List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>();
        List<String>  MailsList = new List<String>();
        List<String> userIdList = new List<String>();
        if(String.isNotBlank(ownerids)){
            userIdList.add(ownerids);
        }
        if(String.isNotBlank(ddid)){
            userIdList.add(ddid);
        }
         //询价所有人,产品担当,发邮件
        List<User> UsrList = [SELECT email FROM user WHERE id in :userIdList];
        //获取各个用户的email
        for (User u : UsrList){
            MailsList.add(u.email);
        }
        MailsList.add('youchang@prec-tech.com');
        system.debug('111===:'+MailsList);
        if (MailsList!=null&&MailsList.size()>0){
            String title = '';
            String body = '';
            title = ' 新建询价医院/经销商涉及黑名单';
            if(AccDealerBlacklist=='123'){
                body += '黑名单的客户为:' + accname+ '<br/>';
                body += '黑名单的经销商1为:' + angency1+ '<br/>';
                body += '黑名单的经销商2为:' + angency2+ '<br/>';
            }else if(AccDealerBlacklist=='12'){
                body += '黑名单的客户为:' + accname+ '<br/>';
                body += '黑名单的经销商1为:' + angency1+ '<br/>';
            }else if(AccDealerBlacklist=='23'){
                body += '黑名单的经销商1为:' + angency1+ '<br/>';
                body += '黑名单的经销商2为:' + angency2+ '<br/>';
            }else if(AccDealerBlacklist=='13'){
                body += '黑名单的客户为:' + accname+ '<br/>';
                body += '黑名单的经销商2为:' + angency2+ '<br/>';
            }else if(AccDealerBlacklist=='1'){
                body += '黑名单的客户为:' + accname+ '<br/>';
            }else if(AccDealerBlacklist=='2'){
                body += '黑名单的经销商1为:' + angency2+ '<br/>';
            }else if(AccDealerBlacklist=='3'){
                body += '黑名单的经销商2为:' + angency2+ '<br/>';
            }
            body += '<a href="' + System.Label.Environment_Url + oppid + '">'
                    + System.Label.Environment_Url+ oppid +'</a><br/>';
            body += '谢谢!';
            Messaging.SingleEmailMessage messageNEW = new Messaging.SingleEmailMessage();
            messageNEW.setSubject(title);
            messageNEW.setHtmlBody(body);
            messageNEW.setCharset('UTF-8');
            messageNEW.setToAddresses(MailsList);
            //List<String> toCcMailsList = new List<String>();
            //toCcMailsList.add('youchang@prec-tech.com');
            //messageNEW.setCcAddresses(toCcMailsList);
            sendMails.add(messageNEW);
        }
        boolean rs = true;
        if (sendMails.size() > 0) {
            Messaging.Email[] allMails = new Messaging.Email[]{};
            for(Integer j = 0; j < sendMails.size(); j++) {
                allMails.add(sendMails.get(j));
            }
            system.debug('222===:'+allMails);
            Messaging.SendEmailResult[] results = Messaging.sendEmail(allMails);
            System.debug('results 结果 :'+results);
            for (Integer i = 0; i < results.size(); i++) {
                if (results[i].success == false) {
                    system.debug('=====send mail error:' + results[i].errors[0].message);
                    rs = false;
                }
            }
        }
        return rs;
    }
    //贸易合规 20230307 you end
}
force-app/main/default/classes/OpportunityWebService.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>36.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/ReportController.cls
@@ -218,7 +218,7 @@
    //给提交相应的js提供初始化数据
    @AuraEnabled
    public static void updateForSubmitButton(String reocrdId){
    public static String updateForSubmitButton(String reocrdId){
        try {
            Report__c rac = new Report__c();
            rac.Id = reocrdId;
@@ -226,26 +226,34 @@
            rac.Submit_time__c = Datetime.now();
            rac.Submit_report_day__c = Date.today();
            update rac;
            return null;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //OPDtoSIS操作更新相应数据
    @AuraEnabled
    public static void updateForOPDtoSISButton(String recordId){
    public static String updateForOPDtoSISButton(String recordId){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
            rac.RecordTypeId = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_OPD).getRecordTypeId();
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //取消提交操作更新相应数据
    @AuraEnabled
    public static void updateForCancelSubmitReportButton(String recordId){
    public static String updateForCancelSubmitReportButton(String recordId){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
@@ -253,33 +261,45 @@
            rac.Submit_report_day__c = null;
            rac.Submit_time__c = null;
            update rac;
            return null;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //完毕操作更新相应数据
    @AuraEnabled
    public static void updateForCompleteButton(String recordId){
    public static String updateForCompleteButton(String recordId){
        Report__c rac = new Report__c();
        try {
            rac.Id = recordId;
            rac.Status__c = LightingButtonConstant.STATUS_COMPLETE;
            rac.RecordTypeId = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.VOC_NAME).getRecordTypeId();
            update rac;
            return null;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //OCSM要报告操作更新相应数据
    @AuraEnabled
    public static void updateForOCSMToReportButton(String recordId){
    public static String updateForOCSMToReportButton(String recordId){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
            rac.OCSMAdministrativeReportStatus__c = LightingButtonConstant.STATUS_TO_BE_REPORTED;
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
@@ -293,50 +313,65 @@
            update rac;
            return null;
        } catch (Exception e) {
            return e.getMessage();
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //DispatchOCSMQARA操作更新相应数据
    @AuraEnabled
    public static void updateForDispatchOCSMQARAButton(String recordId){
    public static String updateForDispatchOCSMQARAButton(String recordId){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
            rac.Dispatch_OCSM_QARA__c = true;
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',');
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //OCSM不要报告操作更新相应数据
    @AuraEnabled
    public static void updateForOCSMNoToReportButton(String recordId){
    public static String updateForOCSMNoToReportButton(String recordId){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
            rac.OCSMAdministrativeReportStatus__c  = LightingButtonConstant.STATUS_TO_NOT_REPORT;
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',');
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //取消操作更新相应数据
    @AuraEnabled
    public static void updateForCancelButton(String recordId){
    public static String updateForCancelButton(String recordId){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
            rac.Status__c = LightingButtonConstant.STATUS_CANCEL;
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',');
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    
    //VOC结果确认更新相应数据
    @AuraEnabled
    public static void updateForVOCConfirmButton(String recordId,String Satisfy,String Satisfy1){
    public static String updateForVOCConfirmButton(String recordId,String Satisfy,String Satisfy1){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
@@ -362,8 +397,12 @@
                }
                }
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',');
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //VOC回答更新相应数据
@@ -388,7 +427,7 @@
    //提交竞争对手报告更新相应数据
    @AuraEnabled
    public static void updateForSubmitCompetitorReportButton(String recordId){
    public static String updateForSubmitCompetitorReportButton(String recordId){
        try {
            Report__c rac = new Report__c();
            rac.Id = recordId;
@@ -397,13 +436,17 @@
            rac.Submit_report_day__c = Date.today();
            rac.Date__c = Date.today();
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',');
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    //VOC回答更新相应数据
    @AuraEnabled
    public static void updateForVOCSubmitButton(String recordId ,String createdById){
    public static String updateForVOCSubmitButton(String recordId ,String createdById){
        try {
            Report__c rac = [select Status__c,JingliApprovalManager__r.Id,BuchangApprovalManager__r.Id,SalesManager__r.Id,BuchangApprovalManagerSales__r.Id,ZongjianApprovalManager__c,Submit_time__c,Submit_report_day__c,Owner.Id from Report__c where Id = :recordId];
            // share
@@ -424,15 +467,18 @@
            userAccess.add(rac.ZongjianApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
            String rtn = ControllerUtil.setSObjectShare(LightingButtonConstant.SOBJECT_NAME_OF_REPORT_SHARE,LightingButtonConstant.SOBJECT_NAME_OF_VOC_SHARE,recordId,userAccess,rac.Owner.Id);
            if (rtn != LightingButtonConstant.OK) {
            return;
            return null;
            }
            rac.Status__c = LightingButtonConstant.STATUS_VOC_WRITE_OVER;
            rac.Submit_time__c = Date.today();
            rac.Submit_report_day__c = Date.today();
            update rac;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',');
            Integer right = eMessage.length();
            return eMessage.substring(left, right);
        }
    }
    //VOC判定更新相应数据
@@ -480,13 +526,17 @@
    }
    //VOC完毕操作更新相应数据
    @AuraEnabled
    public static void updateForVOCFinishButton (String recordId) {
    public static String updateForVOCFinishButton (String recordId) {
        try {
            Report__c report = [select Id,Status__C from Report__c where Id = :recordId];
            report.Status__c = LightingButtonConstant.STATUS_VOC_FINISH;
            update report;
            return null;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',');
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    public class InitData{
force-app/main/default/lwc/lexAgencyAuthorize/__tests__/lexAgencyAuthorize.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexAgencyAuthorize from 'c/lexAgencyAuthorize';
describe('c-lex-agency-authorize', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-agency-authorize', {
            is: LexAgencyAuthorize
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.css
New file
@@ -0,0 +1,10 @@
.inASACEditorHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.html
New file
@@ -0,0 +1,6 @@
<template>
    <div class="inASACEditorHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={showSuccess}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js
New file
@@ -0,0 +1,198 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-12 14:51:44
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 09:54:19
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForAgencyAuthorizeButton';
import updateForAgencyAuthorizeButton  from '@salesforce/apex/OpportunityLightingButtonController.updateForAgencyAuthorizeButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import checkDangerItem from '@salesforce/apex/OpportunityWebService.checkDangerItem';
import oppCheck from '@salesforce/apex/OpportunityWebService.oppCheck';
import updReg from '@salesforce/apex/OpportunityWebService.updReg';
export default class LexAgencyAuthorize extends LightningElement {
    @api recordId;
    agency1Id;
    stageName;
    sapSendOK;
    oppOrderType;
    ifHave170;
    ifHaveAH;
    cntLostCancelDraft;
    cntLostCancelReport;
    estimationId;
    detailNum;
    estimationDecision;
    salesRoot;
    acecideCntCheck;
    ifSubmit;
    trade;
    isCorrosion;
    profileId;
    ifAuthorizingLock;
    IsLoading = true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            console.log(result);
            this.agency1Id = result.agency1Id;
            this.stageName = result.stageName;
            this.sapSendOK = result.sapSendOK;
            this.oppOrderType = result.oppOrderType;
            this.ifHave170 = result.ifHave170;
            this.ifHaveAH = result.ifHaveAH;
            this.cntLostCancelDraft = result.cntLostCancelDraft;
            this.cntLostCancelReport = result.cntLostCancelReport;
            this.estimationId = result.estimationId;
            this.detailNum = result.detailNum;
            this.estimationDecision = result.estimationDecision;
            this.salesRoot = result.salesRoot;
            this.acecideCntCheck = result.acecideCntCheck;
            this.ifSubmit = result.ifSubmit;
            this.trade = result.trade;
            this.isCorrosion = result.isCorrosion;
            this.profileId = result.profileId;
            this.ifAuthorizingLock = result.ifAuthorizingLock;
            this.AgencyAuthorize();
        })
    }
    AgencyAuthorize(){
        var btns = document.getElementsByName("agency_authorize");
        for (var i=0; i<btns.length; i++) {
        btns[i].disabled = true;
        btns[i].className = 'btnDisabled';
        }
        //2021-10-21 gwy 版本更改为51.0
        var oppid = this.recordId;
        var angency = this.agency1Id;
        var profileId = this.profileId;
        if (profileId != '00e10000000Y3o5' && profileId != '00e10000000Nab7' && profileId != '00e10000000xnpR' && profileId != '00e10000000xyK6' && profileId != '00e10000000NbCE'
        && profileId != '00e10000000xyK6' && profileId != '00e10000000Nb7i') {
            this.showToast("您没有授权申请的权限。请联系系统管理员。","error");
            return;
        }
        if (this.stageName != '引合' && this.stageName != '询价' ) {
            this.showToast("状态1:" + this.stageName + "、不能做授权申请!","error");
            return;
        } else if (this.sapSendOK == '1') {
            this.showToast("已经上传SAP、不能做授权申请了!","error");
            return;
        } else if (this.oppOrderType != '' && this.ifHave170 == true) {
            this.showToast("耗材不可与170产品同时存在!","error");
            return;
        } else if (this.oppOrderType != '' && this.ifHaveAH == true) {
            this.showToast("耗材不可与奥辉产品同时存在!","error");
            return;
        } else if (this.cntLostCancelDraft > 0) {
        if(!confirm('询价有草案中的取消/失单报告,是否继续?')){
            return ;
        }
        } else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) {
            this.showToast('询价有已提交的取消/失单报告。',"error");
            return;
        } else if (this.estimationId == '' || this.detailNum == 0) {
            this.showToast('报价未完成,请先报价。',"error");
            return;
        } else if (this.estimationDecision == '1') {
            this.showToast('报价已决定,不能进行授权申请。',"error");
            return;
        } else if (this.salesRoot != '販売店') {
            this.showToast('医院直销不需要授权申请。',"error");
            return;
        }
        // else if ('{!Opportunity.AcecideCntCheck__c}' != '1') {
        // alert('阿西赛多询价只能包含危化品,或者,普通询价不能包含危化品。');
        // return;
        // }
        else if (this.ifSubmit == '1') {
            this.showToast('上传失败,请联系系统管理员!',"error");
            return;
        }
        if (this.ifAuthorizingLock == 'true') {
            this.showToast('询价正在授权中,请不要重复提交。',"error");
            return;
        }
        if (this.trade == '内貿') {
            if(this.isCorrosion == '1'){
                checkDangerItem({
                    agency1: angency
                }).then(result=>{
                    var rtn1 = result;
                    if (rtn1 != 'OK') {
                        this.showToast(rtn1,"error");
                        return;
                    }
                    this.update();
            });
            }else{
                oppCheck({
                    oppid: oppid,
                    saveFlg: '1'
                }).then(result=>{
                    var rtn = result;
                    if (rtn != 'OK') {
                        this.showToast(rtn,"error");
                        return;
                    }
                    this.update();
                })
            }
        } else {
            updReg({
                oppid: oppid
            }).then(()=>{
                this.update();
            });
        }
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
    update(){
        updateForAgencyAuthorizeButton({
            recordId: this.recordId
        }).then(result=>{
            if(result){
                this.showToast(result,"error");
            }else{
                this.updateRecordView(this.recordId);
                window.open("https://olympus.sharepoint.cn/sites/GSPWF/SitePages/HomePage.aspx");
                this.showToast('提交成功。请在SPO系统中完成授权申请。',"success");
            }
            this.IsLoading = false;
        })
    }
}
force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexBeforeOPDPDFBtn/__tests__/lexBeforeOPDPDFBtn.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexBeforeOPDPDFBtn from 'c/lexBeforeOPDPDFBtn';
describe('c-lex-before-opdpdf-btn', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-before-opdpdf-btn', {
            is: LexBeforeOPDPDFBtn
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.css
New file
@@ -0,0 +1,10 @@
.lexBeforeOPDPDFBtnHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.html
New file
@@ -0,0 +1,6 @@
<template>
    <div class="lexBeforeOPDPDFBtnHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={showSuccess}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js
New file
@@ -0,0 +1,89 @@
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initFoBeforeOPDPDFBtnButton';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import selectCommonSequence from '@salesforce/apex/ControllerUtil.selectCommonSequence';
import addReportOPWithEvaluationPDF from '@salesforce/apex/Add_Report.addReportOPWithEvaluationPDF';
export default class LexBeforeOPDPDFBtn extends LightningElement {
    @api recordId;
    accountId;
    userId;
    IsLoading = true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            this.accountId = result.accountId;
            this.userId = result.userId;
            this.beforeOPDPDFBtn();
        })
    }
    beforeOPDPDFBtn(){
        if (window.confirm('是否新建OPD报告书?\n[确定] => 新建OPD\n[取消] => 只生成 [产品试用评价]')) {
            try {
            selectCommonSequence({
                valueField: 'EvaluationPDF_NextValue__c',
                formatField: 'EvaluationPDF_Format__c'
            }).then(result=>{
                var pdfno = result;
                addReportOPWithEvaluationPDF({
                    "repOwnerId": this.userId,
                    "reportId": "",
                    "dailyReportId": "",
                    "eventId": "",
                    "recordType": "OPD",
                    "aId": this.accountId,
                    "visitor1": "",
                    "visitor2": "",
                    "visitor3": "",
                    "visitor4": "",
                    "visitor5": "",
                    "opp1": this.recordId,
                    "opp2": "",
                    "opp3": "",
                    "opp4": "",
                    "opp5": "",
                    "reportDate": "",
                    "evaluationPDFNumber": pdfno
                }).then(()=>{
                    // 20220913 ljh WLIG-CHMATN update end
                    this.IsLoading = false;
                    window.open('/apex/BeforeOPDPDF?oid=' + this.recordId + '&pdfNo=' + pdfno, 'BeforeOPDPDF');
                    this.dispatchEvent(new CloseActionScreenEvent());
                })
            });
            } catch(e) {
                this.showToast(e,"error");
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        } else {
            window.open('/apex/BeforeOPDPDF?oid=' + this.recordId, 'BeforeOPDPDF');
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
    }
}
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/__tests__/lexBeforeOPDPDFBtnSIS.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexBeforeOPDPDFBtnSIS from 'c/lexBeforeOPDPDFBtnSIS';
describe('c-lex-before-opdpdf-btn-sis', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-before-opdpdf-btn-sis', {
            is: LexBeforeOPDPDFBtnSIS
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.css
New file
@@ -0,0 +1,10 @@
.lexBeforeOPDPDFBtnSISHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.html
New file
@@ -0,0 +1,14 @@
<!--
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-13 15:55:45
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 15:56:58
-->
<template>
    <div class="lexBeforeOPDPDFBtnSISHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={showSuccess}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.js
New file
@@ -0,0 +1,97 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-13 15:55:45
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 16:04:14
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initFoBeforeOPDPDFBtnSISButton';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import selectCommonSequence from '@salesforce/apex/ControllerUtil.selectCommonSequence';
import addReportOPWithEvaluationPDF from '@salesforce/apex/Add_Report.addReportOPWithEvaluationPDF';
export default class LexBeforeOPDPDFBtnSIS extends LightningElement {
    @api recordId;
    accountId;
    userId;
    IsLoading = true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            this.accountId = result.accountId;
            this.userId = result.userId;
            this.beforeOPDPDFBtn();
        })
    }
    beforeOPDPDFBtn(){
        if (window.confirm('是否新建SIS报告书?')) {
            try {
            selectCommonSequence({
                valueField: 'EvaluationPDF_NextValue__c',
                formatField: 'EvaluationPDF_Format__c'
            }).then(result=>{
                var pdfno = result;
                addReportOPWithEvaluationPDF({
                    "repOwnerId": this.userId,
                    "reportId": "",
                    "dailyReportId": "",
                    "eventId": "",
                    "recordType": "SIS",
                    "aId": this.accountId,
                    "visitor1": "",
                    "visitor2": "",
                    "visitor3": "",
                    "visitor4": "",
                    "visitor5": "",
                    "opp1": this.recordId,
                    "opp2": "",
                    "opp3": "",
                    "opp4": "",
                    "opp5": "",
                    "reportDate": "",
                    "evaluationPDFNumber": pdfno
                }).then(()=>{
                    // 20220913 ljh WLIG-CHMATN update end
                    this.IsLoading = false;
                    window.open('/apex/BeforeOPDPDF?oid=' + this.recordId + '&pdfNo=' + pdfno, 'BeforeOPDPDF');
                    this.dispatchEvent(new CloseActionScreenEvent());
                })
            });
            } catch(e) {
                this.showToast(e,"error");
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        } else {
            window.open('/apex/BeforeOPDPDF?oid=' + this.recordId, 'BeforeOPDPDF');
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
    }
}
force-app/main/default/lwc/lexBeforeOPDPDFBtnSIS/lexBeforeOPDPDFBtnSIS.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexCancel/lexCancel.js
@@ -2,9 +2,9 @@
 * @Description: 
 * @version: 
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @Date: 2023-03-27 13:47:21
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:00:54
 * @LastEditTime: 2023-04-11 16:44:49
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -45,13 +45,10 @@
                this.status = result.status;
                console.log(this.status);
                this.cancel();
            }
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
    }
@@ -72,30 +69,34 @@
    cancel () {
        if (this.status == "取消") {
            ShowToastEvent("已经取消!","error");
            this.showToast("已经取消!","error");
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
            }
        if (this.status == "批准") {
            ShowToastEvent("已经批准,不能删除!","error");
            this.showToast("已经批准,不能删除!","error");
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        if (this.status == "完毕") {
            ShowToastEvent("已经完毕,不能删除!","error");
            this.showToast("已经完毕,不能删除!","error");
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        if (this.status == "提交") {
            ShowToastEvent("已经提交,不能删除!","error");
            this.showToast("已经提交,不能删除!","error");
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        updateForCancelButton({
            recordId: this.recordId
        }).then(result =>{
            if(result){
                this.showToast(result,"error");
            }else{
            this.showToast("取消成功!","success");
            this.updateRecordView(this.recordId);
            }
            this.IsLoading = false;
            this.dispatchEvent(new CloseActionScreenEvent());
        });
force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:05:05
 * @LastEditTime: 2023-04-11 11:17:24
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -54,8 +54,6 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });   
    }
@@ -76,8 +74,13 @@
            cancel({
                recordId: this.recordId
            }).then(result=>{
                if(result){
                    this.showToast(result,"error");
                }else{
                this.showToast("成功","success");
                this.updateRecordView(this.recordId);
                }
                this.IsLoading = false;
                this.dispatchEvent(new CloseActionScreenEvent());
            });
            console.log("321");
force-app/main/default/lwc/lexCancelSubmitReport/lexCancelSubmitReport.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:06:00
 * @LastEditTime: 2023-04-11 11:18:36
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -41,12 +41,14 @@
        cancel({
            recordId: this.recordId
        }).then(result =>{
            if(result){
                this.showToast(result,"error");
            }else{
            this.showToast("取消提交成功!","success");
            this.updateRecordView(this.recordId);
            }
            this.IsLoading = false;
            this.dispatchEvent(new CloseActionScreenEvent());
        }).catch(error=>{
            this.showToast(error,"error");
        });
    }
force-app/main/default/lwc/lexComplete/lexComplete.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:06:48
 * @LastEditTime: 2023-04-11 11:21:30
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -46,14 +46,11 @@
                this.status = result.status;
                this.profileId = result.profileId;
                this.complete();
                this.dispatchEvent(new CloseActionScreenEvent());
                //window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Report__c/" + this.recordId + "/view");
            }
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });   
        //this.updateRecordView(this.recordId);
    }
@@ -76,19 +73,24 @@
    complete () {
        // 陆胜,胡迪安,系统管理员以外没有权限
        if (UserInfo_Owner.Id != "00510000004reg2" && UserInfo_Owner.Id != "00510000000gWAE" && this.profileId != "00e10000000Y3o5") {
            ShowToastEvent("你没有权限","error");
            this.showToast("你没有权限","error");
            return;
        }
        if (this.status == "完毕") {
            ShowToastEvent("已经完毕!","error");
            this.showToast("已经完毕!","error");
            return;
        }
        updateForCompleteButton({
            recordId: this.recordId
        }).then(result =>{
            this.IsLoading = false;
            if(result){
                this.showToast(result,"error");
            }else{
            this.updateRecordView(this.recordId);
            this.showToast("完毕成功!","success");
            }
            this.IsLoading = false;
            this.dispatchEvent(new CloseActionScreenEvent());
        });
    }
}
force-app/main/default/lwc/lexCreateEvent/__tests__/lexCreateEvent.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexCreateEvent from 'c/lexCreateEvent';
describe('c-lex-create-event', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-create-event', {
            is: LexCreateEvent
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexCreateEvent/lexCreateEvent.html
New file
@@ -0,0 +1,6 @@
<template>
    <div class="lexCreateEventReportHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexCreateEvent/lexCreateEvent.js
New file
@@ -0,0 +1,59 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-13 13:50:23
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 14:39:54
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForCreateEventButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LexCreateEvent extends LightningElement {
    @api recordId;
    accountId;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            this.accountId = result.accountId;
            this.createEvent();
        }).catch(error=>{
            console.log("error");
            console.log(error);
        })
    }
    createEvent(){
        window.open("/00U/e?retURL=%2Fapex%2FVFClosePage&accid=" + this.accountId + "&oid=" + this.recordId, "新建计划");
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
}
force-app/main/default/lwc/lexCreateEvent/lexCreateEvent.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexDispatchOCSMQARA/lexDispatchOCSMQARA.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:07:34
 * @LastEditTime: 2023-04-11 11:23:37
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -58,9 +58,13 @@
            updateForDispatchOCSMQARAButton({
                recordId: this.recordId
            }).then(result =>{
                if(result){
                    this.showToast(result,"error");
                }else{
                this.showToast("成功","success");
                this.updateRecordView(this.recordId);
                this.IsLoading = false;
                }
                this.dispatchEvent(new CloseActionScreenEvent());
                });
    }
force-app/main/default/lwc/lexLoseBid/__tests__/lexLoseBid.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexLoseBid from 'c/lexLoseBid';
describe('c-lex-lose-bid', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-lose-bid', {
            is: LexLoseBid
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexLoseBid/lexLoseBid.css
New file
@@ -0,0 +1,18 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-13 10:31:18
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 10:46:09
 */
.lexLoseBidHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexLoseBid/lexLoseBid.html
New file
@@ -0,0 +1,6 @@
<template>
    <div class="lexLoseBidHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexLoseBid/lexLoseBid.js
New file
@@ -0,0 +1,89 @@
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForLoseBidButton';
import updateForLoseBidButton  from '@salesforce/apex/OpportunityLightingButtonController.updateForLoseBidButton';
import queryForLexLoseBidButton  from '@salesforce/apex/OpportunityLightingButtonController.queryForLoseBidButton';
export default class LexLoseBid extends LightningElement {
    @api recordId;
    ifOpenBid;
    IsLoading = true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            console.log(result);
            this.ifOpenBid = result.ifOpenBid;
            this.lexLoseBid();
        }).catch(error=>{
            console.log("error");
            console.log(error);
        })
    }
    lexLoseBid(){
        console.log("query start");
        queryForLexLoseBidButton({
            recordId: this.recordId
        }).then(result=>{
            console.log("query end");
            console.log(result);
            var flag = true;
            var taskslist = result;
            for(var task of taskslist ){
                if(task.taskStatus__c != '04 取消'){
                flag = false;
            }
            }
            if(this.ifOpenBid == '非公开招标'){
                flag = false;
            }
            if(flag){
                this.showToast("条件不符合,不可操作","error");
            }else{
                if (window.confirm('是否确认竞争对手中标?')) {
                    updateForLoseBidButton({
                        recordId: this.recordId
                    }).then(result=>{
                        if (result) {
                            this.showToast(result,"error");
                        }else{
                            this.IsLoading = false;
                            this.updateRecordView(this.recordId);
                            this.showToast("操作成功!","success");
                        }
                    })
                }
            }
        });
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
}
force-app/main/default/lwc/lexLoseBid/lexLoseBid.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexOCSMNoToReportForReport/lexOCSMNoToReportForReport.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-03-28 15:59:44
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:08:30
 * @LastEditTime: 2023-04-11 11:24:51
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -82,9 +82,13 @@
           updateForOCSMNoToReportButton({
                recordId: this.recordId
           }).then(result=>{
            if(result){
                this.showToast(result,"error");
            }else{
                this.showToast("OCSM不要报告成功","success");
                this.updateRecordView(this.recordId);
                this.IsLoading = false;
            }
                this.dispatchEvent(new CloseActionScreenEvent());
           });
        }else{
force-app/main/default/lwc/lexOCSMToReport/lexOCSMToReport.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:09:14
 * @LastEditTime: 2023-04-11 11:26:11
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -50,8 +50,6 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
    }
@@ -81,9 +79,13 @@
            updateForOCSMToReportButton({
                recordId: this.recordId
            }).then(result =>{
                if(result){
                    this.showToast(result,"error");
                }else{
                this.showToast("成功","success");
                this.updateRecordView(this.recordId);
                this.IsLoading = false;
                }
                this.dispatchEvent(new CloseActionScreenEvent());
                });
        }else{
force-app/main/default/lwc/lexOLYwinBid/__tests__/lexOLYwinBid.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexOLYwinBid from 'c/lexOLYwinBid';
describe('c-lex-ol-ywin-bid', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-ol-ywin-bid', {
            is: LexOLYwinBid
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.css
New file
@@ -0,0 +1,10 @@
.lexOLYwinBidHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.html
New file
@@ -0,0 +1,6 @@
<template>
    <div class="lexOLYwinBidHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js
New file
@@ -0,0 +1,97 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-13 13:15:52
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 13:37:19
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForOLYwinBidButton';
import updateForOLYwinBidButton  from '@salesforce/apex/OpportunityLightingButtonController.updateForOLYwinBidButton';
import queryForOLYwinBidButton  from '@salesforce/apex/OpportunityLightingButtonController.queryForOLYwinBidButton';
export default class LexOLYwinBid extends LightningElement {
    @api recordId;
    ifOpenBid;
    IsLoading = true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            console.log(result);
            this.ifOpenBid = result.ifOpenBid;
            this.lexLoseBid();
        }).catch(error=>{
            console.log("error");
            console.log(error);
        })
    }
    lexLoseBid(){
        console.log("query start");
        queryForOLYwinBidButton({
            recordId: this.recordId
        }).then(result=>{
            console.log("query end");
            console.log(result);
            var flag = true;
            var taskslist = result;
            for(var task of taskslist ){
                if(task.taskStatus__c != '04 取消'){
                flag = false;
            }
            }
            if(this.ifOpenBid == '非公开招标'){
                flag = false;
            }
            if(flag){
                this.showToast("条件不符合,不可操作","error");
            }else{
                if (window.confirm('是否确认OLY中标?')) {
                    updateForOLYwinBidButton({
                        recordId: this.recordId
                    }).then(result=>{
                        if (result) {
                            this.showToast(result,"error");
                        }else{
                            this.IsLoading = false;
                            this.updateRecordView(this.recordId);
                            this.showToast("操作成功!","success");
                        }
                    })
                }
            }
        });
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
}
force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexOPDtoSIS/lexOPDtoSIS.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:10:06
 * @LastEditTime: 2023-04-11 11:27:14
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -55,8 +55,6 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
    }
@@ -79,9 +77,13 @@
            updateForOPDtoSISButton({
                recordId: this.recordId
            }).then(result =>{
                if(result){
                    this.showToast(result,"error");
                }else{
                this.updateRecordView(this.recordId);
                this.showToast("成功!","success");
                this.IsLoading = false;
                }
                this.dispatchEvent(new CloseActionScreenEvent());
                });
            } else {
force-app/main/default/lwc/lexPredictedDateChange/__tests__/lexPredictedDateChange.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexPredictedDateChange from 'c/lexPredictedDateChange';
describe('c-lex-predicted-date-change', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-predicted-date-change', {
            is: LexPredictedDateChange
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.css
New file
@@ -0,0 +1,10 @@
.predictedDateChangeHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.html
New file
@@ -0,0 +1,6 @@
<template>
    <div class="predictedDateChangeHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.js
New file
@@ -0,0 +1,82 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-12 10:46:24
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-12 13:48:26
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import queryForPredictedDateChangeButton  from '@salesforce/apex/OpportunityLightingButtonController.queryForPredictedDateChangeButton';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForPredictedDateChangeButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LexPredictedDateChange extends LightningElement {
    @api recordId;
    IsLoading = true;
    directLossFLG;
    createdDay;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    showToast(msg,type) {
      const event = new ShowToastEvent({
          title: '',
          message: msg,
          variant: type
      });
      this.dispatchEvent(event);
    }
    updateRecordView(recordId) {
      updateRecord({fields: { Id: recordId }});
    }
    connectedCallback(){
      init({
        recordId: this.recordId
      }).then(result=>{
        this.directLossFLG = result.directLossFLG;
        this.createdDay = result.createdDay;
        this.predictedDateChange();
      }).catch(error=>{
        console.log("error");
        console.log(error);
      })
    }
    predictedDateChange(){
      // 20221206 ljh DB202212030068 start
      var DirectLossFLG = this.directLossFLG;
      var CreatedDay = this.createdDay;
      var Day =  Date('2022-12-03');
      if((DirectLossFLG == 'true' || DirectLossFLG == 1 ) && CreatedDay > Day){
        this.showToast("从招标项目点击失单新建的询价,预测OCSM签约日(KPI)和预测发货日不允许修改","error");
        return;
      }
      // 20221206 ljh DB202212030068 end
      queryForPredictedDateChangeButton({
        recordId: this.recordId
      }).then(result=>{
        var sqlResult = result;
        if (sqlResult.size > 0) {
          this.showToast("已存在待审批的变更申请!","error");
          return;
        } else {
          window.open('/apex/ImprovedForecastTime?id=' + this.recordId,'','height=500,width=800,top=200,left=250,location=no');
          this.dispatchEvent(new CloseActionScreenEvent());
        }
      })
    }
}
force-app/main/default/lwc/lexPredictedDateChange/lexPredictedDateChange.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexRequestDB/__tests__/lexRequestDB.test.js
New file
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import LexRequestDB from 'c/lexRequestDB';
describe('c-lex-request-db', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });
    it('TODO: test case generated by CLI command, please fill in test logic', () => {
        // Arrange
        const element = createElement('c-lex-request-db', {
            is: LexRequestDB
        });
        // Act
        document.body.appendChild(element);
        // Assert
        // const div = element.shadowRoot.querySelector('div');
        expect(1).toBe(1);
    });
});
force-app/main/default/lwc/lexRequestDB/lexRequestDB.css
New file
@@ -0,0 +1,10 @@
.lexRequestDBHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexRequestDB/lexRequestDB.html
New file
@@ -0,0 +1,6 @@
<template>
    <div class="lexRequestDBHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexRequestDB/lexRequestDB.js
New file
@@ -0,0 +1,107 @@
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForRequestDBButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LexRequestDB extends LightningElement {
    @api recordId;
    stageName;
    sapSendOK;
    cntLostCancelReport;
    cntLostCancelDraft;
    agency1;
    agency1Id;
    name;
    bidPlannedDate;
    salesAssistantName;
    salesAssistantID;
    profileId;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            this.stageName = result.stageName;
            this.sapSendOK = result.sapSendOK;
            this.cntLostCancelReport = result.cntLostCancelReport;
            this.cntLostCancelDraft = result.cntLostCancelDraft;
            this.agency1 = result.agency1;
            this.agency1Id = result.agency1Id;
            this.name = result.name;
            this.bidPlannedDate = result.bidPlannedDate;
            this.salesAssistantName = result.salesAssistantName;
            this.salesAssistantID = result.salesAssistantID;
            this.profileId = result.profileId;
            this.requestDB();
        })
    }
    requestDB(){
        var profileId = this.profileId;
        if (profileId != '00e10000000Y3o5' && profileId != '00e10000000xnp2' &&
        profileId != '00e10000000xnpH') {
            this.showToast("您没有授权委托的权限。请联系系统管理员。","error");
        }
        // jsの場合、翻訳された値がでるので、要注意
        else if (this.stageName != '引合'
        && this.stageName != '询价'
        ) {
            this.showToast("状态1:" + this.stageName + "、不能做授权申请!","");
        }
        else if (this.sapSendOK == '1') {
            this.showToast("已经上传SAP、不能做授权申请了!","error");
        }
        else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) {
            this.showToast("询价已经有取消/失单报告了!","error");
        }
        else {
        location.href = '/a2C/e?retURL=%2F' +
            encodeURI(this.recordId) +
            '&RecordType=01210000000RNXi' +
            '&CF00N10000006QdJz=' +
            encodeURI(this.agency1) +
            '&CF00N10000006QdJz_lkid=' +
            encodeURI(this.agency1Id) +
            '&CF00N10000006QdKn=' +
            encodeURI(this.name) +
            '&CF00N10000006QdKn_lkid=' +
            encodeURI(this.recordId) +
            '&00N10000006QdK4=' +
            encodeURI(this.name) +
            '&00N10000006QdYB=' +
            encodeURI(this.bidPlannedDate) +
            '&CF00N10000006QdZT=' +
            encodeURI(this.salesAssistantName) +
            '&CF00N10000006QdZT_lkid=' +
            encodeURI(this.salesAssistantID) +
            '';
        };
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    showToast(msg,type) {
      const event = new ShowToastEvent({
          title: '',
          message: msg,
          variant: type
      });
      this.dispatchEvent(event);
    }
    updateRecordView(recordId) {
      updateRecord({fields: { Id: recordId }});
    }
}
force-app/main/default/lwc/lexRequestDB/lexRequestDB.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexSIStoOPD/lexSIStoOPD.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:10:42
 * @LastEditTime: 2023-04-12 10:15:28
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -52,7 +52,6 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
    }
@@ -86,6 +85,9 @@
                this.IsLoading = false;
                this.dispatchEvent(new CloseActionScreenEvent());
            });              
    } else {
        this.showToast("只草案中状态及OPD/SIS报告书的所有人可以提交","error");
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    
}
force-app/main/default/lwc/lexSubmit/lexSubmit.css
New file
@@ -0,0 +1,10 @@
.submitHolder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display: none !important;
}
force-app/main/default/lwc/lexSubmit/lexSubmit.html
New file
@@ -0,0 +1,7 @@
<template>
    <div class="submitHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
    </div>
</template>
force-app/main/default/lwc/lexSubmit/lexSubmit.js
New file
@@ -0,0 +1,68 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-11 16:46:48
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 16:48:05
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import updateForSubmitButton  from '@salesforce/apex/ReportController.updateForSubmitButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LexSubmit extends LightningElement {
    @api recordId;
    IsLoading = true;
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
             console.log(111);
             console.log(currentPageReference);
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
             let str = `${urlValue}`;
             console.log("str");
             console.log(str);
             this.recordId = str;
           }
         }
     }
     connectedCallback(){
        this.submit();
     }
     showToast(msg,type) {
      const event = new ShowToastEvent({
          title: '',
          message: msg,
          variant: type
      });
      this.dispatchEvent(event);
    }
     updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
     submit(){
        updateForSubmitButton({
          recordId: this.recordId
        }).then(result=>{
          if(result){
            this.showToast(result,"error");
          }else{
            this.updateRecordView(this.recordId);
            this.showToast("提交成功","success");
          }
          this.IsLoading = false;
          this.dispatchEvent(new CloseActionScreenEvent());
        });
     }
}
force-app/main/default/lwc/lexSubmit/lexSubmit.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexSubmitCompetitorReport/lexSubmitCompetitorReport.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:11:11
 * @LastEditTime: 2023-04-11 11:28:51
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -61,8 +61,12 @@
      otherButtonInSubmitCompetitorReport({
        recordId: this.recordId
    }).then(result=>{
      if(result){
        this.showToast(result,"error");
      }else{
      this.showToast("提交对手竞争报告成功","success")
      this.updateRecordView(this.recordId);
      }
      this.IsLoading = false;  
      this.dispatchEvent(new CloseActionScreenEvent());
    });
force-app/main/default/lwc/lexVOCAnswer/lexVOCAnswer.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-03-27 14:05:59
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-10 17:56:04
 * @LastEditTime: 2023-04-11 11:30:45
 */
import { LightningElement, wire, track, api } from "lwc";
import { CurrentPageReference } from "lightning/navigation";
@@ -50,8 +50,7 @@
      .catch((error) => {
        console.log("error");
        console.log(error);
      })
      .finally(() => {});
      });
    //window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Report__c/" + this.recordId + "/view");
  }
@@ -76,13 +75,12 @@
    updateForVOCAnswerButton({
      recordId: this.recordId
    }).then(result => {
      if (result == null) {
        this.showToast("成功", "success");
      } else {
        console.log(result);
      if (result) {
        this.showToast(result,"error");
      }
      } else {
        this.showToast("成功", "success");
      this.updateRecordView(this.recordId);
      }
      this.Isloading = false;
      this.dispatchEvent(new CloseActionScreenEvent());
    }).catch(error=>{
force-app/main/default/lwc/lexVOCCheck/lexVOCCheck.js
@@ -52,8 +52,6 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
    }
@@ -95,11 +93,11 @@
                    personId:this.personId
                }
            ).then(result =>{
                if(result == null){
                if(result){
                    this.showToast(result,"error");
                }else{
                    this.showToast("成功","success");
                    this.updateRecordView(this.recordId);
                }else {
                    this.showToast(result,"error");
                }
                this.Isloading = false;   
                this.dispatchEvent(new CloseActionScreenEvent());
force-app/main/default/lwc/lexVOCConfirm/lexVOCConfirm.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-03-27 14:08:56
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-10 17:49:00
 * @LastEditTime: 2023-04-11 11:33:01
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -56,11 +56,8 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
        //window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Report__c/" + this.recordId + "/view");
        this.updateRecordView(this.recordId);
    }
    updateRecordView(recordId) {
@@ -93,8 +90,12 @@
            Satisfy: this.VOCSatisfy,
            Satisfy1: this.VOCSatisfy1    
        }).then(result=>{
            if(result){
                this.showToast(result,"error");
            }else{
            this.updateRecordView(this.recordId);
            this.showToast("成功","success");
            }
            this.Isloading = false;
            this.dispatchEvent(new CloseActionScreenEvent());
        });
force-app/main/default/lwc/lexVOCFinish/lexVOCFinish.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-03-27 14:11:17
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-10 17:52:00
 * @LastEditTime: 2023-04-11 11:34:01
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -50,8 +50,6 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
        //window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Report__c/" + this.recordId + "/view");
        //this.updateRecordView(this.recordId);
@@ -85,8 +83,12 @@
            update({
                recordId: this.recordId
            }).then(result =>{
                if(result){
                    this.showToast(result,"error");
                }else{
                this.showToast("成功","success");
                this.updateRecordView(this.recordId);
                }
                this.IsLoading = false;
                this.dispatchEvent(new CloseActionScreenEvent());
            });
force-app/main/default/lwc/lexVOCSubmit/lexVOCSubmit.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-03-27 13:39:23
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-10 17:57:16
 * @LastEditTime: 2023-04-11 11:35:31
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -51,8 +51,6 @@
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });   
        //this.updateRecordView(this.recordId);
    }
@@ -80,8 +78,12 @@
                recordId: this.recordId,
                createdById: this.createdById
            }).then(result =>{
                if(result){
                    this.showToast(result,"error");
                }else{
                this.showToast("成功","success");
                this.updateRecordView(this.recordId);
                }
                this.IsLoading = false;
                this.dispatchEvent(new CloseActionScreenEvent());
            });