import { LightningElement,track,api } from 'lwc'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import saveActivity from '@salesforce/apex/LwcDailyReportController.saveActivity'; import getEventCById from '@salesforce/apex/LwcDailyReportController.getEventCById'; import queryDepartmentClass from '@salesforce/apex/LwcDailyReportController.queryDepartmentClass'; import queryHospital from '@salesforce/apex/LwcDailyReportController.queryHospital'; import addReportOPWithEvaluationPDF from '@salesforce/apex/LwcDailyReportController.addReportOPWithEvaluationPDF'; import addReportNT from '@salesforce/apex/LwcDailyReportController.addReportNT'; import queryAbountIndo from '@salesforce/apex/LwcDailyReportController.queryAbountIndo'; import getContactAwsIdByCOntactId from '@salesforce/apex/LwcDailyReportController.getContactAwsIdByCOntactId'; import { label } from 'c/labelUtility'; import { NavigationMixin } from 'lightning/navigation'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import ProfileId_2S1 from '@salesforce/label/c.ProfileId_2S1'; import salesman2S1_Price from '@salesforce/label/c.salesman2S1_Price'; //import { AWSService } from 'c/piUtils';//deloitte-zhj 调用aws 2023/07/19 //deloitte-zhj 20231121 PIPL还原 import { updateRecord } from 'lightning/uiRecordApi'; //import getPIPLInfo from '@salesforce/apex/LookUpUtilController.getPIPLInfo';//deloitte-zhj 获取解密信息 2023/07/19 //deloitte-zhj 20231121 PIPL还原 import { refreshApex } from '@salesforce/apex'; import { RefreshEvent } from 'lightning/refresh'; // 2023-12-21 dzk Start 新建OPD计划验证询价上最新报价是否存在符合条件的行项目 import initGetQuote from '@salesforce/apex/LexNewOPDButtonOpportunityController.initGetQuote'; // import initNewOPDButton2 from '@salesforce/apex/LexNewOPDButtonOpportunityController.initNewOPDButton2'; import createProductTags from '@salesforce/apex/LexNewOPDButtonOpportunityController.createProductTags'; // 2023-12-21 dzk End 新建OPD计划验证询价上最新报价是否存在符合条件的行项目 import geOppStatus from '@salesforce/apex/LexNewOPDButtonOpportunityController.geOppStatus';//zzm 20240204 只有询价中的才可以 新建opd计划 export default class ActiveContent extends NavigationMixin(LightningElement) { //AWSService; //deloitte-zhj 20231121 PIPL还原 @track customLabel = label; @api theIndex; @api reportedDate; @api reportedId; @api report; @api reportOwner; @api profileName; @api batchUser; @api currentUserId; @api cancelRequestFlg; @api allDisableFlg; @track timeValid; @api isNotSalesService; @api reportStatusFlg; @api reportReportFlg; @api shour ; @api sminute ; @api ehour ; @api eminute ; @track fields=['Contact.Name','Contact.AWS_Data_Id__c']; @track AccountFields=['Account.Name']; @track CampaignFields=['Campaign.Name']; @track options=[]; @track filter = ''; @track objectName = 'Contact'; @track contactId1 = ''; @track contactId2 = ''; @track contactId3 = ''; // @track contactId4; // @track contactId5; @track beforeHour = ''; @track beforeMinute= ''; @track afterHour= ''; @track afterMinute= ''; @track showSpinner = false; @track activityObj = {}; @track requiredDescription=''; @track requiredLocation=''; @track requiredRelatedService=''; @track requiredReportContract=''; @track requiredReportContractType=''; @track visitValidMes=''; @track requiredVisitor = ''; @track visit= ''; @track visitAim= ''; @track purposeType1= ''; @track purposeType2= ''; @track purposeType3= ''; // @track purposeType4; // @track purposeType5; @track isAccessAcc= ''; @track tempId= ''; @track tempRecordTypeName= ''; @track tempBtnIdHidden= ''; @track tempRedId= ''; @track OPDId= ''; @track isPlaceDis=false; @track isConDis1=false; @track isConDis2=false; @track isConDis3=false; @track isOppDis1=false; @track isOppDis2=false; @track isOppDis3=false; @track isTransferEtDis=false; @track isActivityEtDis=false; @track isupdateAccInfoDis=false; @track isNewOpdDis=false; @track isCheckReportDis=false; @track isOPDSISDis=false; @track isNTCCDSDis=false; @track isNewBuyDis=false; @track isOppUpdateDis1=false; @track isLoseDis1=false; @track isOppUpdateDis2=false; @track isLoseDis2=false; @track isOppUpdateDis3=false; @track isLoseDis3=false; @track isRelatedServiceDis=false; @track isUseReportDis=false; @track isAccDis=false; @track isInfoUpdateDis=true; @track showModal=false; //zzm 230905 start @track beforeHourDis=false; @track saveDis=false; @track visitorPalceObjName = ''; @track visitorPalceFields = ['Account.Name']; @track opportunityFields = ['Opportunity.Name']; @track mcFields = ['Maintenance_Contract__c.Name']; @track infrastructureProjectFields = ['Infrastructure_Project__c.Name']; @track Related_Opportunity1_ID = ''; @track Related_Opportunity2_ID = ''; @track Related_Opportunity3_ID = ''; @track Related_Service1_ID = ''; @track isReportContractDis = true; @track isReportContractTypeDis = true; @track isInfrastructureProjectDis1 = true; @track isInfrastructureProjectDis2 = true; @track Infrastructure_Project1 = ''; @track Infrastructure_Project2 = ''; @api readReportFlag; @api newLeadRecordType; @api updateAccInfoColor = false; @api requiredInfo = {}; @track staticResourceContact={}; @track isSaveBtn = false; @track agencyContactName ; //zzm 230905 end //DB202312521391 zzm 20240102 start @track isConsumablePropulsion=false ; //拜访目的是否是耗材推进 @track etappThirdCategoryDis=true ; @track etappThirdCategoryDis2=true ; @track etappThirdCategoryDis3=true ; @track etappForthCategoryDis=true ; @track etappForthCategoryDis2=true ; @track etappForthCategoryDis3=true ; //DB202312521391 zzm 20240102 end // getPIPLInfoJs() { // console.log('enter connectedCallback') // this.AWSService = new AWSService(); // getPIPLInfo().then((r) => { // r = JSON.parse(JSON.stringify(r)); // console.log('r = ' + JSON.stringify(r)) // if (r.status == 'Success') { // this.staticResourceContact = JSON.parse(r.entity.staticResourceContact); // console.log('this.staticResourceContact.searchUrl actinveContent= ' + this.staticResourceContact.searchUrl) // } else { // console.log('error msg = ' + r.msg) // } // }) // } // 2023-12-25 Add by du Start 产品显示页面数据显示 @track saveOpenUrl; @track Opportunity;//当前询价 @track QuoteNum;//询价中报价的数量 @track Quotedata; @track showproductfalg = false; @track selectProductLine = []; @track columns = [{ label: '商品名称', fieldName: 'ProductName', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, }, { label: '报价编码', fieldName: 'QuoteNo', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, }, { label: '产品代码', fieldName: 'ProductCode', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, }, { label: '产品型号', fieldName: 'ProductModel', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, }, ]; // 2023-12-25 Add by du End 产品显示页面数据显示 @api getActivityObj() { var beforeMinuteTmp = this.beforeMinute; var afterMinuteTmp = this.afterMinute; // if (this.reportOwner.Job_Category__c != '销售服务') { // if(!beforeMinuteTmp) { // beforeMinuteTmp = 0; // } // if(!afterMinuteTmp) { // afterMinuteTmp = 0; // } // } let data = JSON.parse(JSON.stringify(this.activityObj)); let dtStr = this.reportedDate+''; let dt = new Date(dtStr); let startDt = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate(),this.beforeHour,beforeMinuteTmp,0,0); let endDt = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate(),this.afterHour,afterMinuteTmp,0,0); data.StartDateTime__c = startDt; data.EndDateTime__c = endDt; if(this.visit === '病院') { this.visitorPalceObjName = 'SearchVisitorPlace'; } if(this.visit === '販売店') { this.visitorPalceObjName = 'SearchVisitorPlace_Sales'; } if(this.visit === '社内活動') { this.visitorPalceObjName = 'SearchVisitorPlace_Training'; } if(this.visit === '病院'||this.visit === '販売店'||this.visit === '社内活動'){ if(this.filter){ data.Account_ID__c = this.filter; data.Campaign_ID__c = ''; }else{ data.Account_ID__c = ''; } }else if(this.visit === '社外イベント'){ if(this.filter){ data.Campaign_ID__c = this.filter; data.Account_ID__c = ''; }else{ data.Campaign_ID__c = ''; } this.visitorPalceObjName = 'SearchVisitorPlace_Campaign'; this.visitorPalceFields = ['Campaign.Name']; }else{ data.Account_ID__c = ''; data.Campaign_ID__c = ''; } if(this.contactId1){ data.Visitor1_ID__c = this.contactId1; }else{ data.Visitor1_ID__c = ''; } if(this.contactId2){ data.Visitor2_ID__c = this.contactId2; }else{ data.Visitor2_ID__c = ''; } if(this.contactId3){ data.Visitor3_ID__c = this.contactId3; }else{ data.Visitor3_ID__c = ''; } // if(this.contactId4){ // data.Visitor4_ID__c = this.contactId4; // }else{ // data.Visitor4_ID__c = ''; // } // if(this.contactId5){ // data.Visitor5_ID__c = this.contactId5; // }else{ // data.Visitor5_ID__c = ''; // } if(this.visit){ data.Activity_Type2__c = this.visit; }else{ data.Activity_Type2__c = ''; } //zzm 230809 start if(this.Related_Opportunity1_ID){ data.Related_Opportunity1_ID__c = this.Related_Opportunity1_ID; }else{ data.Related_Opportunity1_ID__c = ''; } if(this.Related_Opportunity2_ID){ data.Related_Opportunity2_ID__c = this.Related_Opportunity2_ID; }else{ data.Related_Opportunity2_ID__c = ''; } if(this.Related_Opportunity3_ID){ data.Related_Opportunity3_ID__c = this.Related_Opportunity3_ID; }else{ data.Related_Opportunity3_ID__c = ''; } if(this.Related_Service1_ID){ data.Related_Service1_ID__c = this.Related_Service1_ID; }else{ data.Related_Service1_ID__c = ''; } if(this.Infrastructure_Project1){ data.Infrastructure_Project1__c = this.Infrastructure_Project1; }else{ data.Infrastructure_Project1__c = ''; } if(this.Infrastructure_Project2){ data.Infrastructure_Project2__c = this.Infrastructure_Project2; }else{ data.Infrastructure_Project2__c = ''; } //zzm 230809 end if(this.isNotSalesService){ if(this.visitAim){ data.Activity_PurposeEscFSE__c = this.visitAim; }else{ data.Activity_PurposeEscFSE__c = ''; } if(this.purposeType1){ data.Purpose_TypeEscFSE__c = this.purposeType1; }else{ data.Purpose_TypeEscFSE__c = ''; } if(this.purposeType2){ data.Purpose_TypeEscFSE2__c = this.purposeType2; }else{ data.Purpose_TypeEscFSE2__c = ''; } if(this.purposeType3){ data.Purpose_TypeEscFSE3__c = this.purposeType3; }else{ data.Purpose_TypeEscFSE3__c = ''; } // if(this.purposeType4){ // data.Purpose_TypeEscFSE4__c = this.purposeType4; // }else{ // data.Purpose_TypeEscFSE4__c = ''; // } // if(this.purposeType5){ // data.Purpose_TypeEscFSE5__c = this.purposeType5; // }else{ // data.Purpose_TypeEscFSE5__c = ''; // } }else{ if(this.visitAim){ data.Activity_PurposeFSE__c = this.visitAim; }else{ data.Activity_PurposeFSE__c = ''; } if(this.purposeType1){ data.Purpose_TypeFSE__c = this.purposeType1; }else{ data.Purpose_TypeFSE__c = ''; } if(this.purposeType2){ data.Purpose_TypeFSE2__c = this.purposeType2; }else{ data.Purpose_TypeFSE2__c = ''; } if(this.purposeType3){ data.Purpose_TypeFSE3__c = this.purposeType3; }else{ data.Purpose_TypeFSE3__c = ''; } // if(this.purposeType4){ // data.Purpose_TypeFSE4__c = this.purposeType4; // }else{ // data.Purpose_TypeFSE4__c = ''; // } // if(this.purposeType5){ // data.Purpose_TypeFSE5__c = this.purposeType5; // }else{ // data.Purpose_TypeFSE5__c = ''; // } } if(data.eventStatus__c !='延期') { data.delayReasonSelect__c = ''; data.delayReasonSelectFSE__c = ''; data.delayReasonOther__c = ''; var today = new Date(); var targetDate = (today.getFullYear()+1) + '-' + (today.getMonth()+1) + '-' + today.getDate(); //zzm 20240229 2025-2-29报错问题 start if(today.getMonth() == 1) { targetDate = (today.getFullYear()) + '-' + (today.getMonth()+2) + '-' + today.getDate(); } //zzm 20240229 2025-2-29报错问题 end data.delayToDate__c = targetDate; } else if(data.eventStatus__c =='延期') { if(data.delayReasonSelect__c != '其他' && data.delayReasonSelectFSE__c !='其他') { data.delayReasonOther__c = ''; } } if(data.eventStatus__c !='取消') { data.cancelReasonSelect__c = ''; data.cancelReasonSelectFSE__c = ''; data.cancelReasonOther__c = ''; } else if(data.eventStatus__c =='取消') { if(data.cancelReasonSelect__c != '其他' && data.cancelReasonSelectFSE__c !='其他') { data.cancelReasonOther__c = ''; } } return data; } //报告一览对象 _event; @api get event() { return this._event; } _loadFlag = false; //相当于初始化 set event(newValue) { this._loadFlag = true; // this.clearLookUp(); console.log('newvalue:activityObj:OPDPlan_Flag__c:' ); console.log(JSON.parse(JSON.stringify(newValue))); console.log(newValue.OPDPlan_Flag__c ); this._event = newValue; this.activityObj = {}; this.activityObj = newValue; // if(this.activityObj.Activity_Type2__c){ // // this.visit = this.activityObj.Activity_Type2__c; // this.activityObj = { // ...this.activityObj, // ['Activity_Type2__c']: this.activityObj.Activity_Type2__c // }; // } else { // this.activityObj = { // ...this.activityObj, // ['Activity_Type2__c']: '' // }; // } this.visit = this.activityObj.Activity_Type2__c; if(!this.activityObj.Activity_Type2__c) { this.activityObj = { ...this.activityObj, ['Activity_Type2__c']: '' }; } if(this.isNotSalesService){ this.visitAim = this.activityObj.Activity_PurposeEscFSE__c; this.purposeType1 = this.activityObj.Purpose_TypeEscFSE__c; this.purposeType2 = this.activityObj.Purpose_TypeEscFSE2__c; this.purposeType3 = this.activityObj.Purpose_TypeEscFSE3__c; // this.purposeType4 = this.activityObj.Purpose_TypeEscFSE4__c; // this.purposeType5 = this.activityObj.Purpose_TypeEscFSE5__c; }else{ this.visitAim = this.activityObj.Activity_PurposeFSE__c; this.purposeType1 = this.activityObj.Purpose_TypeFSE__c; this.purposeType2 = this.activityObj.Purpose_TypeFSE2__c; this.purposeType3 = this.activityObj.Purpose_TypeFSE3__c; // this.purposeType4 = this.activityObj.Purpose_TypeFSE4__c; // this.purposeType5 = this.activityObj.Purpose_TypeFSE5__c; } // DB202312521391 zzm 20240102 start if(this.visitAim == '耗材推进') { this.isConsumablePropulsion = true; } else { this.isConsumablePropulsion = false; } // DB202312521391 zzm 20240102 end if(this.activityObj.whatid__c){ this.filter = this.activityObj.whatid__c; console.log(this.filter); } else { this.filter = ''; } // this.contactId4 = this.activityObj.Visitor4_ID__c; // this.contactId5 = this.activityObj.Visitor5_ID__c; if(this.visit === '病院'){ this.isAccessAcc = true; console.log(this.activityObj.Account_ID__c); if(this.activityObj.Visitor1_ID__c) { this.contactId1 = this.activityObj.Visitor1_ID__c; } else { this.contactId1 = ''; this.activityObj = { ...this.activityObj, ['Visitor1_ID__c']: '' }; } if(this.activityObj.Visitor2_ID__c) { this.contactId2 = this.activityObj.Visitor2_ID__c; } else { this.contactId2 = ''; this.activityObj = { ...this.activityObj, ['Visitor2_ID__c']: '' }; } if(this.activityObj.Visitor3_ID__c) { this.contactId3 = this.activityObj.Visitor3_ID__c; } else { this.contactId3 = ''; this.activityObj = { ...this.activityObj, ['Visitor3_ID__c']: '' }; } // if(this.activityObj.Account_ID__c){ // this.filter = this.activityObj.Account_ID__c; // } if(this.activityObj.Related_Opportunity1_ID__c) { this.Related_Opportunity1_ID = this.activityObj.Related_Opportunity1_ID__c; } else { this.Related_Opportunity1_ID = ''; } if(this.activityObj.Related_Opportunity2_ID__c) { this.Related_Opportunity2_ID = this.activityObj.Related_Opportunity2_ID__c; }else { this.Related_Opportunity2_ID = ''; } if(this.activityObj.Related_Opportunity3_ID__c) { this.Related_Opportunity3_ID = this.activityObj.Related_Opportunity3_ID__c; }else { this.Related_Opportunity3_ID = ''; } if(this.activityObj.Related_Service1_ID__c) { this.Related_Service1_ID = this.activityObj.Related_Service1_ID__c; }else { this.Related_Service1_ID = ''; } if(this.activityObj.Infrastructure_Project1__c) { this.Infrastructure_Project1 = this.activityObj.Infrastructure_Project1__c; }else { this.Infrastructure_Project1 = ''; } if(this.activityObj.Infrastructure_Project2__c) { this.Infrastructure_Project2 = this.activityObj.Infrastructure_Project2__c; }else { this.Infrastructure_Project2 = ''; } this.visitorPalceObjName = 'SearchVisitorPlace'; }else if(this.visit === '販売店'){ this.isAccessAcc = true; // if(this.activityObj.Account_ID__c){ // this.filter = this.activityObj.Account_ID__c; // } this.visitorPalceObjName = 'SearchVisitorPlace_Sales'; }else if(this.visit === '社内活動'){ this.isAccessAcc = true; // if(this.activityObj.Account_ID__c){ // this.filter = this.activityObj.Account_ID__c; // } if(this.activityObj.Related_Opportunity1_ID__c) { this.Related_Opportunity1_ID = this.activityObj.Related_Opportunity1_ID__c; }else { this.Related_Opportunity1_ID = ''; } if(this.activityObj.Related_Opportunity2_ID__c) { this.Related_Opportunity2_ID = this.activityObj.Related_Opportunity2_ID__c; }else { this.Related_Opportunity2_ID = ''; } // DB202312521391 zzm 20240102 start if(this.activityObj.Related_Opportunity3_ID__c) { this.Related_Opportunity3_ID = this.activityObj.Related_Opportunity3_ID__c; }else { this.Related_Opportunity3_ID = ''; } // DB202312521391 zzm 20240102 start // if(this.activityObj.Infrastructure_Project1__c) { // this.Infrastructure_Project1 = this.activityObj.Infrastructure_Project1__c; // } this.visitorPalceObjName = 'SearchVisitorPlace_Training'; }else if(this.visit === '社外イベント'){ this.isAccessAcc = false; // if(this.activityObj.Campaign_ID__c){ // this.filter = this.activityObj.Campaign_ID__c; // } // if(this.activityObj.whatid__c){ // this.filter = this.activityObj.whatid__c; // } this.visitorPalceObjName = 'SearchVisitorPlace_Campaign'; this.visitorPalceFields = ['Campaign.Name']; }else { this.isAccessAcc = true; this.filter = ''; } if(!this.filter) { const visitorComponents = this.template.querySelectorAll('c-other-look-up'); console.log(visitorComponents.length); if (visitorComponents.length > 0) { visitorComponents.forEach(visitorComponent => { if(visitorComponent['uniqueKey'] =='AccountID' || !visitorComponent['uniqueKey']) { this.isAccDis = false; visitorComponent.handleRemovePill(); this.isAccDis = true; } }); } } if(this.activityObj.StartDateTime__c){ let startTimeStr = this.activityObj.StartDateTime__c+''; let startDate = new Date(startTimeStr); startDate.setHours(startDate.getHours()) this.beforeHour = startDate.getHours(); this.beforeMinute = startDate.getMinutes(); } else { this.beforeHour = ''; this.beforeMinute = ''; } if(this.activityObj.EndDateTime__c){ let endTimeStr = this.activityObj.EndDateTime__c+''; let endDate = new Date(endTimeStr); endDate.setHours(endDate.getHours()) this.afterHour = endDate.getHours(); this.afterMinute = endDate.getMinutes(); }else{ this.afterHour = ''; this.afterMinute = ''; } //营业的只显示OPD/sis 也要拆分三个按钮 并带默认值 //销售服务是涉及维修合同 显示Ntc按钮(要拆成两个按钮 新品装机培训和故障预防培训) this.options = [ { label: 'OPD/(主机试用报告)', value: 'SIS' }, { label: 'SIS-ET(SIS-ET)', value: 'SIS_ET' }, { label: 'SIS-ENG(SIS-ENG)', value: 'SIS_ENG' } ]; // if(this.reportOwner.Job_Category__c==='销售推广'){ // this.options = [ // { label: 'OPD/(主机试用报告)', value: 'SIS' }, // { label: 'SIS-ET(SIS-ET)', value: 'SIS_ET' }, // { label: 'SIS-ENG(SIS-ENG)', value: 'SIS_ENG' } // ]; // this.options = [ // { label: '跟台(产品主机担当/医院担当考核)', value: 'OPD' }, // { label: 'OPD/(主机试用报告)', value: 'SIS' }, // { label: 'SIS-ET(SIS-ET)', value: 'SIS_ET' }, // { label: 'SIS-ENG(SIS-ENG)', value: 'SIS_ENG' } // ]; // }else{ // this.options = [ // { label: '跟台(产品主机担当/医院担当考核)', value: 'OPD' }, // { label: 'OPD/(主机试用报告)', value: 'SIS' }, // { label: 'SIS-ET(SIS-ET)', value: 'SIS_ET' }, // { label: 'SIS-ENG(SIS-ENG)', value: 'SIS_ENG' } // ]; // } this.setVisitorPlaceDisabled(); this.vpChack1(); // if(this.activityObj && this.activityObj.Id) { // updateRecord({fields: { Id: this.activityObj.Id }}); // } // // refreshApex(this.activityObj); const inputPaddingRight = document.createElement('style'); inputPaddingRight.innerText = ".input-padding-right input { padding-right: 2px !important ;padding-left: 2px !important ;}"; document.body.appendChild(inputPaddingRight); } renderedCallback(){ // console.log('activeContent renderedCallback:'+this.valueId); console.log('otherlookup renderedCallback'); // this.activityObj = this._event ; // if(this.activityObj) { // updateRecord({fields: { Id: this.activityObj.Id }}); // } // if(this._loadFlag) { // this.activityObj = this._event ; // this._loadFlag = false; // if(this.activityObj && this.activityObj.Id) { // updateRecord({fields: { Id: this.activityObj.Id }}); // } // } } //新建成功后传入的客户人员id _conid; @api get conid() { return this._conid; } set conid(newValue) { this._conid = newValue; } //访问对象 handleSelection(event) { console.log('handleSelection!!!!!!!!!!!!'); var key = event.detail.key; if(key==='AgencyContact1'){ this.requiredVisitor = ''; this.contactId1 = event.detail.selectedId; this.activityObj = { ...this.activityObj, ['Visitor1_ID__c']: event.detail.selectedId }; }else if(key==='AgencyContact2'){ this.contactId2 = event.detail.selectedId; this.activityObj = { ...this.activityObj, ['Visitor2_ID__c']: event.detail.selectedId }; }else if(key==='AgencyContact3'){ this.activityObj = { ...this.activityObj, ['Visitor3_ID__c']: event.detail.selectedId }; this.contactId3 = event.detail.selectedId; } this.checkVisitChange(); // else if(key==='AgencyContact4'){ // this.contactId4 = event.detail.selectedId; // }else if(key==='AgencyContact5'){ // this.contactId5 = event.detail.selectedId; // } } //访问场所 handleAccSelection(event) { console.log('handleAccSelection!!!!!!!!!!!!'); this.filter = event.detail.selectedId; this.activityObj = { ...this.activityObj, ['whatid__c']: event.detail.selectedId }; this.requiredLocation = ''; this.changeAccId(); this.checkVisitChange(); } //询价 handleOppertunity1Selection(event) { console.log('handleOppertunity1Selection!!!!!!!!!!!!'); this.Related_Opportunity1_ID = event.detail.selectedId; if(!this.Related_Opportunity1_ID) { this.isOppUpdateDis1 = true; this.isLoseDis1 = true; } else { this.isOppUpdateDis1 = false; this.isLoseDis1 = false; } this.checkVisitChange(); } handleOppertunity2Selection(event) { console.log('handleOppertunity2Selection!!!!!!!!!!!!'); this.Related_Opportunity2_ID = event.detail.selectedId; // this.activityObj.Related_Opportunity2_ID__c = event.detail.selectedId; if(!this.Related_Opportunity2_ID) { this.isOppUpdateDis2 = true; this.isLoseDis2 = true; } else { this.isOppUpdateDis2 = false; this.isLoseDis2 = false; } this.checkVisitChange(); } handleOppertunity3Selection(event) { console.log('handleOppertunity3Selection!!!!!!!!!!!!'); this.Related_Opportunity3_ID = event.detail.selectedId; // this.activityObj.Related_Opportunity3_ID__c = event.detail.selectedId; if(!this.Related_Opportunity3_ID) { this.isOppUpdateDis3 = true; this.isLoseDis3 = true; } else { this.isOppUpdateDis3 = false; this.isLoseDis3 = false; } this.checkVisitChange(); } //基建项目 handleInfrastructureProject1Selection(event) { console.log('handleOppertunity1Selection!!!!!!!!!!!!'); this.Infrastructure_Project1 = event.detail.selectedId; this.checkVisitChange(); } //基建项目 handleInfrastructureProject2Selection(event) { console.log('handleOppertunity1Selection!!!!!!!!!!!!'); this.Infrastructure_Project2 = event.detail.selectedId; this.checkVisitChange(); } //维修合同 handleMCSelection(event) { console.log('handleMCSelection!!!!!!!!!!!!'); this.Related_Service1_ID = event.detail.selectedId; this.activityObj = { ...this.activityObj, ['Related_Service1_ID__c']: event.detail.selectedId } this.requiredRelatedService = ''; this.checkVisitChange(); } get dailyTypeList() { return [ { label: '通常', value: '通常' }, { label: '一日休假', value: '一日休假' }, { label: '全天培训', value: '全天培训' } ]; } //信息更新按钮 slaInfoPage(){ var eventCId = this.activityObj.Id; var index = 1; var visitor1 = this.contactId1; var visitor2 = this.contactId2; var visitor3 = this.contactId3; // var visitor4 = this.contactId4; // var visitor5 = this.contactId5; var visitorPlaceId = this.activityObj.Related_Service1_ID__c; var serviceId = this.filter; var id = this.activityObj.SLAReportInfo__c; var url = "/apex/SLAReportDetails?serviceId="+serviceId+"&index="+index+'&'; if(id){ url += "id="+id+'&'; } if(eventCId){ url += "eventCId="+eventCId+'&'; } if(visitor1){ url += "visitor1="+visitor1+'&'; } if(visitor2){ url += "visitor2="+visitor2+'&'; } if(visitor3){ url += "visitor3="+visitor3+'&'; } // if(visitor4){ // url += "visitor4="+visitor4+'&'; // } // if(visitor5){ // url += "visitor5="+visitor5+'&'; // } if(visitorPlaceId){ url += "accountId="+visitorPlaceId+'&'; } console.log(url); window.open(url,'_blank'); } changeAccId(){ //清空访问对象 const childComponents = this.template.querySelectorAll('c-look-up-util'); console.log(childComponents.length); if (childComponents.length > 0) { childComponents.forEach(childComponent => { childComponent.handleRemovePill(); }); } //清空其他查询组件 const otherComponents = this.template.querySelectorAll('c-other-look-up'); console.log(otherComponents.length); if (otherComponents.length > 0) { otherComponents.forEach(otherComponent => { console.log('清空其他查询组件:') console.log(otherComponent['uniqueKey']) if(otherComponent['uniqueKey'] !='AccountID') { otherComponent.handleRemovePill(); } }); } this.visitDis = false; } clearLookUp() { //清空访问对象 const childComponents = this.template.querySelectorAll('c-look-up-util'); console.log(childComponents.length); if (childComponents.length > 0) { childComponents.forEach(childComponent => { childComponent.handleRemovePill(); }); } //清空其他查询组件 const otherComponents = this.template.querySelectorAll('c-other-look-up'); console.log(otherComponents.length); if (otherComponents.length > 0) { otherComponents.forEach(otherComponent => { otherComponent.handleRemovePill(); }); } this.beforeHour = ''; this.beforeMinute = ''; this.afterHour = ''; this.afterMinute = ''; this.activityObj = { ...this.activityObj, ['Activity_Type2__c']: '', ['Activity_PurposeEscFSE__c']: '', ['Activity_PurposeFSE__c']: '', ['Purpose_TypeEscFSE__c']: '', ['Purpose_TypeEscFSE2__c']: '', ['Purpose_TypeEscFSE3__c']: '', ['Purpose_TypeFSE__c']: '', ['Purpose_TypeFSE2__c']: '', ['Purpose_TypeFSE3__c']: '', ['OPDPlan_Flag__c']: false, ['Report_Contract__c']: '', ['Report_Contract_Type__c']: '', ['Description__c']: '', ['Find_Imitations_Flag__c']: false, ['cancelReasonSelect__c']: '', ['cancelReasonSelectFSE__c']: '', ['cancelReasonOther__c']: '', ['delayReasonSelect__c']: '', ['delayReasonSelectFSE__c']: '', ['delayReasonOther__c']: '', ['delayToDate__c']: '', // DB202312521391 zzm 20240102 start ['etapp_third_category__c']: '', ['etapp_third_category2__c']: '', ['etapp_third_category3__c']: '', ['etapp_forth_category__c']: '', ['etapp_forth_category2__c']: '', ['etapp_forth_category3__c']: '', // DB202312521391 zzm 20240102 end }; } changeCampaignId(event){ this.filter = event.target.value; } fieldChange(event) { console.log('filedChange uniqueKey:'); console.log(event.currentTarget); //清空错误提示信息 salesforce 升级之后不支持 // if(event.currentTarget.dataset.key) { // console.log(event.currentTarget.dataset.key) // const { key } = event.currentTarget.dataset; // const requiredId = event.currentTarget.dataset.key; // this.requiredInfo = { // ...this.requiredInfo, // [key]: '' // }; // } const { value } = event.detail; const { fieldName } = event.target || event.currentTarget; // 使用动态字段名设置对象的属性值 let checked = event.target.value||event.currentTarget.value; if (value == undefined && checked != undefined) { this.activityObj = { ...this.activityObj, [fieldName]: checked }; // this.activityObj[fieldName] = checked; } else { let theValue = value instanceof Array ? value[0] : value; if(theValue===undefined){ theValue = ''; } this.activityObj = { ...this.activityObj, [fieldName]: theValue }; // this.activityObj[fieldName] = theValue; } console.log('1111111111111'); if(fieldName==='Related_Opportunity1_ID__c'||fieldName==='Related_Opportunity2_ID__c'||fieldName==='Related_Opportunity3_ID__c'){ console.log('222222222222'); this.setVisitorPlaceDisabled(); } if(fieldName === 'Report_Contract__c') { this.requiredReportContract = ''; } if(fieldName === 'Report_Contract_Type__c') { this.requiredReportContractType = ''; } if(fieldName === 'Description__c') { this.requiredDescription = ''; } // DB202312521391 zzm 20240102 start if(fieldName === 'etapp_third_category__c') { this.requiredEtappThirdCategory = ''; } if(fieldName === 'etapp_third_category2__c') { this.requiredEtappThirdCategory2 = ''; } if(fieldName === 'etapp_third_category3__c') { this.requiredEtappThirdCategory3 = ''; } if(fieldName === 'etapp_forth_category__c') { this.requiredEtappForthCategory = ''; } if(fieldName === 'etapp_forth_category2__c') { this.requiredEtappForthCategory2 = ''; } if(fieldName === 'etapp_forth_category3__c') { this.requiredEtappForthCategory3 = ''; } // DB202312521391 zzm 20240102 end } handleNewRecord(event){ const openPageEvent = new CustomEvent('openpage', { detail: { activeContentIndex:this.theIndex,lookUpKey:event.detail.key }, }); this.dispatchEvent(openPageEvent); } @api validSaveReport() { let saveflag = false; console.log('validSaveReport start'); let requiredFieldList = this.template.querySelectorAll('lightning-input-field'); requiredFieldList.forEach(ele => { console.log(ele.required); console.log(ele.value); if ( ele.required == true && ele.value) { saveflag = true; return saveflag; } }); let requiredInputList = this.template.querySelectorAll('lightning-input'); requiredInputList.forEach(ele => { if ( ele.required == true && ele.value) { saveflag = true; return saveflag; } }); console.log('validSaveReport end'); return saveflag; } @api validRequired(){ console.log('validRequired'); let flag = true; // //设置必填信息 if(this.report.Status__c === '申請中' && this.stringIsEmpty(this.activityObj.eventStatus__c)){ console.log('1'); //结果必填 if(this.stringIsEmpty(this.activityObj.Description__c) && !this.isNotSalesService){ //zzm 20240228 服务的结果必填 this.requiredDescription = '请输入值'; flag = false; } } if(this.report.Status__c === '申請中' && this.visit === '病院'&& this.stringIsEmpty(this.activityObj.eventStatus__c)){ console.log('2'); //访问场所必填 if(this.stringIsEmpty(this.filter)){ this.requiredLocation = '请输入值'; flag = false; } if(this.stringIsEmpty(this.contactId1)&& !this.isConDis1){ console.log('8'); this.requiredVisitor = '请输入值'; flag = false; } } if (this.report.Daily_Report_Data_Type__c==='一日休假' && this.visit !== '休暇' && this.stringIsEmpty(this.activityObj.eventStatus__c)) { console.log('3'); this.visitValidMes = '全天休假类型的日报拜访区分必须为休假!'; flag = false; } if (this.report.Daily_Report_Data_Type__c==='全天培训' && this.visitAim !== '公司培训' && this.visitAim !== '培训' && this.stringIsEmpty(this.activityObj.eventStatus__c)){ console.log('4'); this.visitValidMes = '全天培训类型的日报拜访目的必须为培训!'; flag = false; } if((this.purposeType1 === '合同季报' || this.activityObj.UseReport__c) && this.stringIsEmpty(this.activityObj.Related_Service1_ID__c) && this.stringIsEmpty(this.activityObj.eventStatus__c) ){ console.log('5'); //维修合同必填 this.requiredRelatedService = '请输入值'; flag = false; } if((this.purposeType1 === '合同季报' || this.activityObj.UseReport__c ||this.purposeType2 === '合同季报'||this.purposeType3 === '合同季报') && this.stringIsEmpty(this.activityObj.Report_Contract__c) && this.stringIsEmpty(this.activityObj.eventStatus__c) ){ console.log('6'); //发放人必填 this.requiredReportContract = '请输入值'; flag = false; } if((this.purposeType1 === '合同季报' || this.activityObj.UseReport__c||this.purposeType2 === '合同季报'||this.purposeType3 === '合同季报') && this.stringIsEmpty(this.activityObj.Report_Contract_Type__c) && this.stringIsEmpty(this.activityObj.eventStatus__c) ){ console.log('6'); //发放方式必填 this.requiredReportContractType = '请输入值'; flag = false; } if((this.purposeType1 === '合同点检' && this.stringIsEmpty(this.activityObj.Related_Service1_ID__c) && this.stringIsEmpty(this.activityObj.eventStatus__c)) ){ console.log('6'); //维修合同必填 this.requiredRelatedService='请输入值'; flag = false; } if(this.stringIsEmpty(this.activityObj.eventStatus__c)) { let requiredFieldList = this.template.querySelectorAll('lightning-input-field'); requiredFieldList.forEach(ele => { if ( ele.required == true && this.stringIsEmpty(ele.value)) { console.log('7'); console.log(ele.fieldName); ele.reportValidity(); flag = false; } }); let requiredInputList = this.template.querySelectorAll('lightning-input'); requiredInputList.forEach(ele => { if ( ele.required == true && this.stringIsEmpty(ele.value)) { console.log('8-1'); console.log(ele.fieldName); ele.reportValidity(); flag = false; } }); } // DB202312521391 zzm 20240102 start if(this.visitAim =='耗材推进' && !this.activityObj.eventStatus__c) { if(this.purposeType1 && !this.activityObj.etapp_third_category__c ) { this.requiredEtappThirdCategory = '请输入值'; flag = false; } if(this.purposeType2 && !this.activityObj.etapp_third_category2__c ) { this.requiredEtappThirdCategory2 = '请输入值'; flag = false; } if(this.purposeType3 && !this.activityObj.etapp_third_category3__c ) { this.requiredEtappThirdCategory3 = '请输入值'; flag = false; } if(this.purposeType1 && !this.activityObj.etapp_forth_category__c ) { this.requiredEtappForthCategory = '请输入值'; flag = false; } if(this.purposeType2 && !this.activityObj.etapp_forth_category2__c ) { this.requiredEtappForthCategory2 = '请输入值'; flag = false; } if(this.purposeType3 && !this.activityObj.etapp_forth_category3__c ) { this.requiredEtappForthCategory3 = '请输入值'; flag = false; } } // DB202312521391 zzm 20240102 end //zzm 230906 start 学术会议时,访问对象不是必填 // if(this.stringIsEmpty(this.contactId1)&& !this.isConDis1){ // console.log('8'); // this.requiredVisitor = '请输入值'; // flag = false; // } //zzm 230906 end //20210520 zh ETAPP与日报联动 start if(!this.isNotSalesService&& this.visitAim === 'ET APP活动'&&!this.activityObj.ETAPPAct__c&& this.activityObj.eventStatus__c!=='延期'&&this.activityObj.eventStatus__c!=='取消'){ this.eventMessage = '请确认:是否需要新建目标ET或者进行目标ET的PDCA管理。'; this.etAPPerrorMsg = '若需要建立目标ET,请点击[转至ET APP]新建目标ET。若已建立目标ET,请点击[ET APP活动]进行活动PDCA管理'; flag = false; }else if(this.isNotSalesService && this.visitAim === 'ET APP活动'&&!this.activityObj.ETAPPAct__c&& this.activityObj.eventStatus__c!=='延期'&&this.activityObj.eventStatus__c!=='取消'){ this.eventMessage = '请确认:是否需要新建目标ET或者进行目标ET的PDCA管理。'; this.etAPPerrorMsg = '若需要建立目标ET,请点击[转至ET APP]新建目标ET。若已建立目标ET,请点击[ET APP活动]进行活动PDCA管理'; flag = false; } if(flag){ flag = this.validOther(); } console.log('validRequired result:' + flag); return flag; } @api validOther(){ console.log('validOther'); if(this.isNotSalesService) { if(!this.beforeMinute && this.beforeHour && this.afterHour) { this.beforeMinute = 0; } if(!this.afterMinute && this.beforeHour && this.afterHour) { this.afterMinute = 0; } } var sHour = this.beforeHour; var sMinute = this.beforeMinute; var eHour = this.afterHour; var eMinute = this.afterMinute; if(!this.isNotSalesService && (this.stringIsEmpty(sMinute) || this.stringIsEmpty(eMinute) || this.stringIsEmpty(sHour)||this.stringIsEmpty(eHour)) ){ // this.timeValid = this.customLabel.Error_Message22; this.showToast('error',this.customLabel.Error_Message22); return false; } else if(this.isNotSalesService && ( this.stringIsEmpty(sHour)||this.stringIsEmpty(eHour)) ) { // this.timeValid = this.customLabel.Error_Message22; this.showToast('error',this.customLabel.Error_Message22); return false; }else{ const regexPattern = /^[0-9]+$/; if (!regexPattern.test(sHour) || !regexPattern.test(sMinute) || !regexPattern.test(eHour) || !regexPattern.test(eMinute)) { // this.timeValid = this.customLabel.Error_Message39; //不正确的日期。 this.showToast('error',this.customLabel.Error_Message39); return false; } // const regexHour = /^(0?[1-9]|1[0-2])$/; // if(!regexHour.test(sHour)||!regexHour.test(eHour)) { // this.timeValid = this.customLabel.Error_Message39; //不正确的日期。 // return false; // } sHour = parseInt(this.beforeHour); sMinute = parseInt(this.beforeMinute); eHour = parseInt(this.afterHour); eMinute = parseInt(this.afterMinute); // 範囲チェック // if(sHour > 23) { // sHour =sHour%24; // this.beforeHour = sHour; // } // if(eHour > 23) { // eHour =eHour%24; // this.afterHour = eHour; // } // if(sMinute > 59) { // sMinute =sMinute%60; // this.beforeMinute = sMinute; // } // if(eMinute > 59) { // eMinute =eMinute%60; // this.afterMinute = eMinute; // } if (sHour < 0 || sHour > 23 || sMinute < 0 || sMinute > 59 || eHour < 0 || eHour > 23 || eMinute < 0 || eMinute > 59) { // this.timeValid = this.customLabel.Error_Message39; this.showToast('error',this.customLabel.Error_Message39); return false; }else if (sHour > eHour || (sHour === eHour && sMinute > eMinute)) { // 逆転チェック // this.timeValid = this.customLabel.Error_Message2; this.showToast('error',this.customLabel.Error_Message2); return false; } this.timeValid = ''; } console.log('validOther end'); return true; } @track eventMessage; @track etAPPerrorMsg; @track customValidationMessage; @track isSaveSuccess; validReport(type){ console.log('validReport!!!!!!!!!!!!'); const openPageEvent = new CustomEvent('validreport', { detail: { type:type,index:this.theIndex}, }); this.showSpinner = false; this.dispatchEvent(openPageEvent); } @api saveTheActivity(type){ console.log('saveTheActivity'); console.log(type); if( typeof(type)=='string') { this.isSaveBtn = true; console.log('save btn '); } else { this.isSaveBtn = false; } this.validReport(type); } @api save(type){ console.log('save'); console.log(type); this.isSaveSuccess = false; this.showSpinner = true; var flag = true; if(type !='延期') { this.activityObj = { ...this.activityObj, ['delayReasonSelect__c']: '' }; this.activityObj = { ...this.activityObj, ['delayReasonSelectFSE__c']: '' }; this.activityObj = { ...this.activityObj, ['delayReasonOther__c']: '' }; var today = new Date(); var targetDate = (today.getFullYear()+1) + '-' + (today.getMonth()+1) + '-' + today.getDate(); //zzm 20240229 2025-2-29报错问题 start if(today.getMonth() == 1) { targetDate = (today.getFullYear()) + '-' + (today.getMonth()+2) + '-' + today.getDate(); } //zzm 20240229 2025-2-29报错问题 end this.activityObj = { ...this.activityObj, ['delayToDate__c']: targetDate } } else if(type =='延期') { if(this.activityObj.delayReasonSelect__c != '其他' && this.activityObj.delayReasonSelectFSE__c !='其他') { this.activityObj.delayReasonOther__c = ''; } } if(type !='取消') { this.activityObj = { ...this.activityObj, ['cancelReasonSelect__c']: '' }; this.activityObj = { ...this.activityObj, ['cancelReasonSelectFSE__c']: '' }; this.activityObj = { ...this.activityObj, ['cancelReasonOther__c']: '' }; } else if(type =='取消') { if(this.activityObj.cancelReasonSelect__c != '其他' && this.activityObj.cancelReasonSelectFSE__c !='其他') { this.activityObj.cancelReasonOther__c = ''; } } // if(!this.isSaveBtn && this.report.Status__c=='申請中') { // flag = this.validRequired(); // } // else { // flag = this.validOther(); // } var beforeMinuteTmp = this.beforeMinute; var afterMinuteTmp = this.afterMinute; if (this.reportOwner.Job_Category__c != '销售服务') { if(!beforeMinuteTmp) { beforeMinuteTmp = 0; } if(!afterMinuteTmp) { afterMinuteTmp = 0; } } if(flag ){ saveActivity({ jsonStr: JSON.stringify(this.activityObj),beforeHour:this.beforeHour,beforeMinute:beforeMinuteTmp ,afterHour:this.afterHour,afterMinute:afterMinuteTmp ,visit:this.visit,visitAim:this.visitAim,purposeType1:this.purposeType1,purposeType2:this.purposeType2, purposeType3:this.purposeType3, // purposeType4:this.purposeType4,purposeType5:this.purposeType5, contactId1:this.contactId1,contactId2:this.contactId2,contactId3:this.contactId3, // contactId4:this.contactId4, contactId5:this.contactId5, accountId:this.filter, reportJsonStr:JSON.stringify(this.report),shour:this.shour,sminute:this.sminute,ehour:this.ehour,eminute:this.eminute ,relatedOpportunity1:this.Related_Opportunity1_ID,relatedOpportunity2:this.Related_Opportunity2_ID ,relatedOpportunity3:this.Related_Opportunity3_ID,relatedService1:this.Related_Service1_ID ,infrastructureProject1:this.Infrastructure_Project1,infrastructureProject2:this.Infrastructure_Project2 }) .then(result => { if(result.code===200){ if(type !== 'newOPDPlan' && type !== 'checkReport' && type !== 'OPDOrSIS' && type !== 'NTCOrCDS' && type !== 'addLeadNew') { this.showToast('success','保存成功'); this.showSpinner = false; } if(type !='延期') { this.activityObj = { ...this.activityObj, ['delayToDate__c']: '' }; } this.setVisitorPlaceDisabled(); let msg = result.msg; if(msg === 'update'){ }else{ this.activityObj = { ...this.activityObj, ['Id']: msg }; //zzm 231113 日报取消延期bug修复 start if(!this.activityObj.Event_ID__c) { getEventCById({eventcID:msg}).then(eventcRes=>{ if(eventcRes) { this.activityObj = { ...this.activityObj, ['Event_ID__c']: eventcRes.Event_ID__c }; } }); } //zzm 231113 日报取消延期bug修复 end } this.isOpen = false; //新建opd计划 if(type==='newOPDPlan'){ console.log('newOPDPlan!!!'); // var content; // if(this.visit === '社外イベント'){ // content = encodeDefaultFieldValues({ // Campaign__c: this.filter, // Related_Opportunity1_ID__c: this.activityObj.Related_Opportunity1_ID__c, // Related_Opportunity2_ID__c: this.activityObj.Related_Opportunity2_ID__c, // }); // }else{ // content = encodeDefaultFieldValues({ // Account_Laboratory__c: this.filter, // Related_Opportunity1_ID__c: this.activityObj.Related_Opportunity1_ID__c, // Related_Opportunity2_ID__c: this.activityObj.Related_Opportunity2_ID__c, // }); // } // const defaultFieldValues = content; // const pageReference = { // type: 'standard__objectPage', // attributes: { // objectApiName: 'OPDPlan__c', // actionName: 'new' // }, // state: { // // defaultFieldValues: JSON.stringify(defaultFieldValues) // defaultFieldValues: defaultFieldValues // } // }; // this[NavigationMixin.Navigate](pageReference); // '/lightning/o/Opportunity/new?defaultFieldValues=Name=' + URLENCODE(Account.Name)+ " Opportunity" + ',AccountId=' + Account.Id + ',StageName=' + "Qualification" + ',CloseDate=' + TEXT(TODAY()+30 // if(!this.activityObj.Related_Opportunity1_ID__c) { // this.activityObj.Related_Opportunity1_ID__c = ''; // } // if(!this.activityObj.Related_Opportunity2_ID__c) { // this.activityObj.Related_Opportunity2_ID__c = ''; // } console.log('this.activityObj:'); console.log(this.activityObj.Related_Opportunity1_ID__c); // alert(this.activityObj.Related_Opportunity1_ID__c); var openUrl = '/lightning/o/OPDPlan__c/new?defaultFieldValues=Account_Laboratory__c='+this.filter; if(this.Related_Opportunity1_ID) { openUrl +=',Related_Opportunity1_ID__c='; openUrl +=this.Related_Opportunity1_ID; } if(this.Related_Opportunity2_ID) { openUrl += ',Related_Opportunity2_ID__c='; openUrl += this.Related_Opportunity2_ID; } openUrl +=',OPDType__c='; openUrl +=encodeURI('日报'); openUrl += ',Name=*'; this.showSpinner = false; this.saveOpenUrl = openUrl; console.log('询价id:' + this.Related_Opportunity1_ID); if (this.Related_Opportunity1_ID === undefined || this.Related_Opportunity1_ID === '') { console.log('没有询价的分支'); window.open(this.saveOpenUrl, '_blank'); } else { //zzm 20240204 只有询价中的才可以 新建opd计划 start geOppStatus({ recordId: this.Related_Opportunity1_ID }).then(result => { console.log('initGetQuote结果----------' + result); if (!result || result!='询价' ) { this.showToast('error','询价状态为:失单、取消、注残、发货、完毕、目标,不允许创建OPD计划。'); } else { initGetQuote({ recordId: this.Related_Opportunity1_ID }).then(result => { console.log('initGetQuote结果----------' + result); if (result != null) { if(result.length > 0){ this.Quotedata = result; this.showproductfalg = true; }else{ this.showToast('error','询价下不存在报价或符合借出条件的报价行项目为空。'); } } else { this.showToast('error','询价下不存在报价或符合借出条件的报价行项目为空。'); } }).catch(error => { // 处理错误 console.error('initGetQuote发生错误:', error); }); } }).catch(error => { // 处理错误 console.error('geOppStatus发生错误:', error); }); //zzm 20240204 只有询价中的才可以 新建opd计划 end } // 2023-12-21 dzk End 新建OPD计划验证询价上最新报价是否存在符合条件的行项目 // 2023-12-21 dzk Start 原代码需要,需解开 // window.open(openUrl, '_blank'); // 2023-12-21 dzk End 原代码需要,需解开 // window.open('/lightning/o/OPDPlan__c/new?defaultFieldValues=Account_Laboratory__c='+this.filter // +',Related_Opportunity1_ID__c='+this.activityObj.Related_Opportunity1_ID__c // +',Related_Opportunity2_ID__c='+this.activityObj.Related_Opportunity2_ID__c // +',OPDType__c='+encodeURI('日报'), '_blank'); }else if(type==='checkReport'){ console.log('checkReport!!!'); var eid = this.activityObj.Id; if (this.stringIsEmpty(eid)) { eid = this.report.Activity_ID__c; } var strVP = this.filter; this.showSpinner = false; var urlStr = '/apex/OFSInsReportLayout?rt=EndoscopeSystem&hpid=' + strVP + '&ecid=' + eid; window.open(urlStr, '_blank'); }else if(type==='OPDOrSIS'){ this.openPD('OPDOrSIS',this.tempRecordTypeName,this.tempReportId); }else if(type==='NTCOrCDS'){ this.openPD('NTCOrCDS',this.tempRecordTypeName,this.tempReportId); }else if(type==='addLeadNew'){ this.addLead(); } }else{ this.activityObj = { ...this.activityObj, ['delayToDate__c']: '' }; this.showToast('error','保存失败,'+result.msg); this.showSpinner = false; } // this.showSpinner = false; }) .catch(error => { // let errorMessage = ""; // error.body.pageErrors.forEach(element => { // errorMessage += element.message; // }); this.activityObj = { ...this.activityObj, ['delayToDate__c']: '' }; this.showToast('error','保存失败.'+error); this.showSpinner = false; }); }else{ this.showSpinner = false; } } // 2023-12-25 Add by du Start 页面选中数据方法 handleRowSelection(event) { const selectedRows = event.detail.selectedRows; this.selectProductLine = selectedRows; // 在这里处理选中的行数据 console.log('选中的行数据:'+ JSON.stringify(selectedRows)); } openSetProduct(event){ this.showproductfalg = false; // this.dispatchEvent(new CloseActionScreenEvent()); } // 2023-12-25 Add by du Start OPD计划新建标准页面与保存按钮合并 NewQuotationProducts(event){ this.showproductfalg = false; if(this.selectProductLine.length == 0){ this.showToast('error','请至少选择一个报价产品,进行OPD计划创建'); this.showproductfalg = true; }else{ createProductTags({ records: JSON.stringify(this.selectProductLine), recordId:this.Related_Opportunity1_ID }).then(result => { // 处理 Apex 方法的返回结果 console.log('Apex 方法返回的结果:', result); // console.log('this.saveoOpenUrl-------' + this.saveoOpenUrl) window.open(this.saveOpenUrl, '_blank'); }).catch(error => { // 处理错误 console.error('发生错误:', error); }); //新建OPD计划数据 } } // 2023-12-25 Add by du End //新建OPD计划 newOPDPlan(event){ console.log('newOPDPlan'); this.showSpinner = true; if (this.stringIsEmpty(this.filter)) { // 訪問場所を設定してください。 this.showToast('error',this.customLabel.Error_Message16); this.showSpinner = false; return; } this.saveTheActivity('newOPDPlan'); } OPDOrSIS(event){ console.log('OPDOrSIS'); console.log(this.visitAim); console.log(this.purposeType1); console.log(this.purposeType2); } beforeHourChange(event) { this.beforeHour = event.detail.value; } beforeMinuteChange(event) { this.beforeMinute = event.detail.value; } afterHourChange(event) { this.afterHour = event.detail.value; } afterMinuteChange(event) { this.afterMinute = event.detail.value; } //设置拜访区分是否可点击 checkVisitChange() { console.log('checkVisitChange start'); var changeFlg = false; if(this.filter){ changeFlg = true; console.log('changeFlg is true 1>>>>>>>>>>>>>>'); } if(this.contactId1){ changeFlg = true; console.log('changeFlg is true 2>>>>>>>>>>>>>>'); } if(this.contactId2){ changeFlg = true; console.log('changeFlg is true 3>>>>>>>>>>>>>>'); } if(this.contactId3){ changeFlg = true; console.log('changeFlg is true 4>>>>>>>>>>>>>>'); } // if(this.contactId4){ // changeFlg = true; // } // if(this.contactId5){ // changeFlg = true; // } if(this.Related_Opportunity1_ID){ changeFlg = true; console.log('changeFlg is true 5>>>>>>>>>>>>>>'); } if(this.Related_Opportunity2_ID){ changeFlg = true; console.log('changeFlg is true 6>>>>>>>>>>>>>>'); } if(this.Related_Opportunity3_ID){ changeFlg = true; console.log('changeFlg is true 7>>>>>>>>>>>>>>'); } if(this.Related_Service1_ID){ changeFlg = true; console.log('changeFlg is true 8>>>>>>>>>>>>>>'); } // if(this.activityObj.Related_Opportunity4_ID__c){ // changeFlg = true; // } // if(this.activityObj.Related_Opportunity5_ID__c){ // changeFlg = true; // } // if(this.activityObj.Related_Service1_ID__c){ // changeFlg = true; // } if(this.activityObj.OPD_ID__c){ changeFlg = true; console.log('changeFlg is true 9>>>>>>>>>>>>>>'); } if(this.activityObj.NTC_ID__c){ changeFlg = true; console.log('changeFlg is true 10>>>>>>>>>>>>>>'); } if(this.activityObj.OnCall_ID__c){ changeFlg = true; console.log('changeFlg is true 11>>>>>>>>>>>>>>'); } if(this.activityObj.ReportAccompanied_ID__c){ changeFlg = true; console.log('changeFlg is true 12>>>>>>>>>>>>>>'); } if(this.activityObj.CityStatus_ID__c){ changeFlg = true; console.log('changeFlg is true 13>>>>>>>>>>>>>>'); } if(this.activityObj.Claim_ID__c){ changeFlg = true; console.log('changeFlg is true 14>>>>>>>>>>>>>>'); } if(this.activityObj.Conflict_ID__c){ changeFlg = true; console.log('changeFlg is true 15>>>>>>>>>>>>>>'); } console.log('changeFlg:'+changeFlg); // if (changeFlg) { // // 値を設定または報告書を作成した場合は変更できません。设定了价格或者制作了报告书的情况下不能变更。 // this.visitDis = true; // // this.showToast('error',this.customLabel.Error_Message21); // // return; // } this.visitDis = changeFlg; console.log('visitDis is true 1>>>>>>>>>>>>>>'); } //拜访区分更改 visitChange(event) { this.visitValidMes = ''; this.requiredVisitor = ''; console.log('visitChange'); // this.checkVisitChange(); this.visit = event.detail.value; this.visitAim = ''; this.purposeType1 = ''; this.purposeType2 = ''; this.purposeType3 = ''; // this.purposeType4 = ''; // this.purposeType5 = ''; console.log('----------'); console.log(this.visit); const otherComponents = this.template.querySelectorAll('c-other-look-up'); if (otherComponents.length > 0) { otherComponents.forEach(otherComponent => { console.log('清空访问场所组件:') console.log(otherComponent['uniqueKey']) if(otherComponent['uniqueKey'] =='AccountID') { otherComponent.handleRemovePill(); } }); } if(this.visit === '病院'){ console.log('1病院'); this.isAccessAcc = true; this.visitorPalceObjName = 'SearchVisitorPlace'; }else if(this.visit === '販売店'){ console.log('2販売店'); this.isAccessAcc = true; this.visitorPalceObjName = 'SearchVisitorPlace_Sales'; }else if(this.visit === '社内活動'){ console.log('3社内活動'); this.isAccessAcc = true; this.visitorPalceObjName = 'SearchVisitorPlace_Training'; }else if(this.visit === '社外イベント'){ console.log('4社外イベント'); this.isAccessAcc = false; this.visitorPalceObjName = 'SearchVisitorPlace_Campaign'; this.visitorPalceFields = ['Campaign.Name']; }else { console.log('5'); this.isAccessAcc = true; this.isAccDis = true; } this.filter = ''; this.activityObj = { ...this.activityObj, ['whatid__c']: '' }; this.setVisitorPlaceDisabled(); } //拜访目的更改 visitAimChange(event) { console.log('visitAimChangeSales'); this.visitAim = event.detail.value; this.purposeType1 = ''; this.purposeType2 = ''; this.purposeType3 = ''; // this.purposeType4 = ''; // this.purposeType5 = ''; this.requiredvisitAim = ''; this.activityObj = { ...this.activityObj, ['Purpose__c']: event.detail.value }; // DB202312521391 zzm 20240102 start if(this.visitAim == '耗材推进') { this.isConsumablePropulsion = true; } else { this.isConsumablePropulsion = false; } // DB202312521391 zzm 20240102 end } //活动区分更改 purposeType1Change(event) { this.purposeType1 = event.detail.value; // if(isNotSalesService) { // this.activityObj ={ // ...this.activityObj, // ['Purpose_TypeEscFSE__c']: event.detail.value // } // } else { // this.activityObj ={ // ...this.activityObj, // ['Purpose_TypeFSE__c']: event.detail.value // } // } this.requiredPurposeType = ''; this.setReportContractDis(); this.setInfrastructureProjectDis(); this.setEtappThirdCategoryDis();// DB202312521391 zzm 20240102 } purposeType2Change(event) { this.purposeType2 = event.detail.value; this.setReportContractDis(); this.setInfrastructureProjectDis(); this.setEtappThirdCategoryDis2();// DB202312521391 zzm 20240102 } purposeType3Change(event) { this.purposeType3 = event.detail.value; this.setReportContractDis(); this.setInfrastructureProjectDis(); this.setEtappThirdCategoryDis3();// DB202312521391 zzm 20240102 } // DB202312521391 zzm 20240102 start setEtappThirdCategoryDis() { console.log('this.visitAim:' +this.visitAim +',this.purposeType1 ' +this.purposeType1); if(this.visitAim == '耗材推进' && this.purposeType1 ) { this.etappThirdCategoryDis = false; this.etappForthCategoryDis = false; } else { this.activityObj = { ...this.activityObj, ['etapp_third_category__c']: '' }; this.activityObj = { ...this.activityObj, ['etapp_forth_category__c']: '' }; this.etappThirdCategoryDis = true; this.etappForthCategoryDis = true; } } setEtappThirdCategoryDis2() { console.log('this.visitAim:' +this.visitAim +',this.purposeType2 ' +this.purposeType2); if(this.visitAim == '耗材推进' && this.purposeType2 ) { this.etappThirdCategoryDis2 = false; this.etappForthCategoryDis2 = false; } else { this.activityObj = { ...this.activityObj, ['etapp_third_category2__c']: '' }; this.activityObj = { ...this.activityObj, ['etapp_forth_category2__c']: '' }; this.etappThirdCategoryDis2 = true; this.etappForthCategoryDis2 = true; } } setEtappThirdCategoryDis3() { console.log('this.visitAim:' +this.visitAim +',this.purposeType2 ' +this.purposeType3); if(this.visitAim == '耗材推进' && this.purposeType3 ) { this.etappThirdCategoryDis3 = false; this.etappForthCategoryDis3 = false; } else { this.activityObj = { ...this.activityObj, ['etapp_third_category3__c']: '' }; this.activityObj = { ...this.activityObj, ['etapp_forth_category3__c']: '' }; this.etappThirdCategoryDis3 = true; this.etappForthCategoryDis3 = true; } } // DB202312521391 zzm 20240102 end //活动区分选择“合同季报”,【涉及的维修合同】【发放人】【发放方式】必填 // 活动区分没选择【合同季报】,【发放人】【发放方式】标灰不可填,【涉及的维修合同】不必填 setReportContractDis() { if(this.purposeType1==='合同季报' || this.purposeType2==='合同季报' || this.purposeType3==='合同季报') { this.isReportContractDis = false; this.isReportContractTypeDis = false; } else { this.activityObj = { ...this.activityObj, ['Report_Contract__c']: '' }; this.activityObj = { ...this.activityObj, ['Report_Contract_Type__c']: '' }; this.requiredReportContract=''; this.requiredReportContractType=''; // this.activityObj['Report_Contract_Type__c'] = ''; this.isReportContractDis = true; this.isReportContractTypeDis = true; } } setInfrastructureProjectDis() { if(this.purposeType1==='基建项目' || this.purposeType2==='基建项目' || this.purposeType3==='基建项目') { this.isInfrastructureProjectDis1 = false; this.isInfrastructureProjectDis2 = false; } else { this.Infrastructure_Project1 = '' this.Infrastructure_Project2 = '' this.isInfrastructureProjectDis1 = true; this.isInfrastructureProjectDis2 = true; } } //点检报告书按钮 checkReport(event){ console.log('checkReport'); this.showSpinner = true; if (this.activityObj.InsReport_ID__c) { // 点検報告書IDあれば、編集モードに var urlStr = '/apex/OFSInsReportLayout?id=' + this.activityObj.InsReport_ID__c; window.open(urlStr, '_blank'); this.showSpinner = false; } else { if (this.stringIsEmpty(this.filter)) { // 訪問場所を設定してください。 this.showToast('error',this.customLabel.Error_Message16); this.showSpinner = false; return; } this.saveTheActivity('checkReport'); } } @track OPDId; @track currentTypeId; //OPD/SIS按钮 OPD(){ console.log('OPD按钮'); var id = this.activityObj.Id; var recordName = 'SIS'; var hiddenId='idOPD_IdHidden'; var redId = 'idOPD'; var reportId = this.reportedId; this.activityObj = { ...this.activityObj, ['Opd_Plan__c']: '' }; var _OPDId = this.activityObj.Opd_Plan__c; this.currentTypeId = this.activityObj.Opd_Plan__c; this.openPDNew('OPDOrSIS',id,recordName,hiddenId,redId,reportId,_OPDId,this.currentTypeId); } SISET(){ console.log('SISET按钮'); var id = this.activityObj.Id; var recordName = 'SIS_ET'; var hiddenId='idOPD_IdHidden'; var redId = 'idOPD'; var reportId = this.reportedId; this.activityObj = { ...this.activityObj, ['Opd_Plan__c']: '' }; var _OPDId = this.activityObj.Opd_Plan__c; this.currentTypeId = this.activityObj.Opd_Plan__c; this.openPDNew('OPDOrSIS',id,recordName,hiddenId,redId,reportId,_OPDId,this.currentTypeId); } SISENG(){ console.log('SISENG按钮'); var id = this.activityObj.Id; var recordName = 'SIS_ENG'; var hiddenId='idOPD_IdHidden'; var redId = 'idOPD'; var reportId = this.reportedId; this.activityObj = { ...this.activityObj, ['Opd_Plan__c']: '' }; var _OPDId = this.activityObj.Opd_Plan__c; this.currentTypeId = this.activityObj.Opd_Plan__c; this.openPDNew('OPDOrSIS',id,recordName,hiddenId,redId,reportId,_OPDId,this.currentTypeId); } //NTC/CDS按钮 新品装机培训 NewInstallTarin(){ console.log('NTC/CDS按钮'); var id = this.activityObj.Id; var recordName = 'NTC'; // var hiddenId='idNTC_IdHidden'; var hiddenId='NewInstallTarin'; var redId = 'idNTC'; var reportId = this.reportedId; this.activityObj = { ...this.activityObj, ['NTC_ID__c']: '' }; var _OPDId = this.activityObj.Opd_Plan__c; this.currentTypeId = this.activityObj.NTC_ID__c; this.openPDNew('NTCOrCDS',id,recordName,hiddenId,redId,reportId,_OPDId,this.currentTypeId); } //故障预防培训 FaultPreventionTraining(){ console.log('NTC/CDS按钮'); var id = this.activityObj.Id; var recordName = 'NTC'; // var hiddenId='idNTC_IdHidden'; var hiddenId='FaultPreventionTraining'; var redId = 'idNTC'; var reportId = this.reportedId; this.activityObj = { ...this.activityObj, ['NTC_ID__c']: '' }; var _OPDId = this.activityObj.Opd_Plan__c; this.currentTypeId = this.activityObj.NTC_ID__c; this.openPDNew('NTCOrCDS',id,recordName,hiddenId,redId,reportId,_OPDId,this.currentTypeId); } //售后跟台 AftermarketHeel(){ console.log('NTC/CDS按钮'); var id = this.activityObj.Id; var recordName = 'NTC'; // var hiddenId='idNTC_IdHidden'; var hiddenId='AftermarketHeel'; var redId = 'idNTC'; var reportId = this.reportedId; this.activityObj = { ...this.activityObj, ['NTC_ID__c']: '' }; var _OPDId = this.activityObj.Opd_Plan__c; this.currentTypeId = this.activityObj.NTC_ID__c; this.openPDNew('NTCOrCDS',id,recordName,hiddenId,redId,reportId,_OPDId,this.currentTypeId); } @track hiddenDivShowFlg = true; openPDNew(type,id, recordName, hiddenId, redId, reportId,_OPDId,currentTypeId) { console.log('openPDNew'); var hiId = currentTypeId; var rsflg = this.reportStatusFlg; this.hiddenDivShowFlg = false; console.log(this.hiddenDivShowFlg); console.log(rsflg); console.log('event_id:'+hiId); if (rsflg === false) { if (hiId) { let urlStr = '/lightning/r/Event__c/'+hiId+'/view'; console.log(urlStr); window.open(urlStr, "_blank"); return; } else { this.showToast('error','无法新建报告书'); return; } } if (this.reportedDate) { }else{ // 日付を入力してください。 this.showToast('error',this.customLabel.Error_Message22); this.setVisitorPlaceDisabled(); return; } //验证报告的时间 var flag = this.validOther(); if(!flag){ return; } if (this.stringIsEmpty(this.filter)) { // 訪問場所を設定してください。 this.showToast('error',this.customLabel.Error_Message16); this.setVisitorPlaceDisabled(); return; } if (this.stringIsEmpty(this.purposeType1)) { // 活動区分を設定してください。 this.showToast('error',this.customLabel.Error_Message18); this.setVisitorPlaceDisabled(); return; } this.tempId = id; //2022-4-22 yjk 如果职种是推广,则默认给tempRecordTypeName 将OPD的值改为 赋值 SIS start if(this.reportOwner.Job_Category__c === '推广' && recordName === 'OPD'){ this.tempRecordTypeName = 'SIS'; }else{ this.tempRecordTypeName = recordName; } //2022-4-22 yjk 如果职种是推广,则默认给tempRecordTypeName 将OPD的值改为 赋值 SIS end this.tempBtnIdHidden = hiddenId; this.tempRedId = redId; this.tempReportId = reportId; this.OPDId = _OPDId; // if ((this.reportOwner.ProfileId !== '00e10000000Y3o5' || this.reportOwner.Batch_User__c !== 'true') && // if ((this.reportOwner.Profile.Name !== '系统管理员' || this.reportOwner.Batch_User__c !== 'true') && if ((this.profileName !== '系统管理员' || this.batchUser !== 'true') && this.report.Status__c === '承認' && this.reportOwner.Id !== this.reportOwner.ManagerId && this.reportOwner.Id !== this.reportOwner.BuchangApprovalManager__c && this.reportOwner.Id !== this.reportOwner.BuchangApprovalManagerSales__c) { // alert('error 1140'); this.showToast('error','已经批准的日报中,不能新建报告书'); this.setVisitorPlaceDisabled(); return; } // 活動1,2,3 も保存したいです。そしてTriggerにて商談などに情報を積み上げます this.saveTheActivity(type); } openPD(type,recordName,reportId) { console.log('openPD'); console.log(type); console.log(this.currentTypeId); // j$(escapeVfId('Page:mainForm:idDayEdit:idActivities:' + index + ':' + hiddenId)) if (this.stringIsEmpty(this.currentTypeId)) { console.log('11111111111'); var reId = reportId; var aId = this.filter; var rId = ''; if (recordName == 'OPD' || recordName == 'SIS' || recordName == 'SIS_ET' || recordName == 'SIS_ENG') { console.log('xxxx'); var dtStr = this.reportedDate+''; var dt = new Date(dtStr); var sTime = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate(),this.beforeHour,this.beforeMinute,0,0); var eTime = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate(),this.afterHour,this.afterMinute,0,0); // 20210107 SWAG-BX24F5 you start console.log(recordName + '==2021==' + this.reportOwner.Job_Category__c); // if (this.reportOwner.Job_Category__c == '销售服务') { // console.log('1'); // recordName = 'OPD'; // } else if (this.reportOwner.Job_Category__c === '推广' && recordName === 'OPD') {//2022-4-21 yjk 销售推广改为推广 console.log('2'); //2021/01/27 liying start this.hiddenDivShowFlg = true; // this.showModal = true; this.createOPDSISReport(); // this.showSpinner = false; return; }else if (this.hiddenDivShowFlg === false) { console.log('3'); // 入力チェック完了したら、ここからdivを出す // divから作成する時、hiddenDivShowFlgをtrueにし、報告書作成ロジックへ this.hiddenDivShowFlg = true; console.log('4'); // this.showModal = true; this.createOPDSISReport(); console.log('5'); console.log(this.showModal); // this.showSpinner = false; return; } console.log(this.hiddenDivShowFlg); console.log('4'); addReportOPWithEvaluationPDF({ repOwnerId: this.reportOwner.Id, dailyReportId: reId,eventId: this.activityObj.Id, recordType: recordName, aId: aId, visitor1: this.contactId1, visitor2: this.contactId2, visitor3: this.contactId3, // visitor4: this.contactId4, visitor5: this.contactId5, opp1: this.Related_Opportunity1_ID, opp2: this.Related_Opportunity2_ID, opp3: this.Related_Opportunity3_ID, // opp4: this.activityObj.Related_Opportunity4_ID__c,opp5: this.activityObj.Related_Opportunity5_ID__c, reportDate: this.reportedDate, sTime: sTime, eTime: eTime}) .then(result => { console.log('4-1'); rId = result; this.activityObj = { ...this.activityObj, ['OPD_ID__c']: rId }; if(recordName == 'SIS' ) { this.activityObj = { ...this.activityObj, ['SIS_FLAG__c']: true }; } else if( recordName == 'SIS_ET' ) { this.activityObj = { ...this.activityObj, ['SIS_ET_FLAG__c']: true }; } else if(recordName == 'SIS_ENG') { this.activityObj = { ...this.activityObj, ['SIS_ENG_FLAG__c']: true }; } this.currentTypeId = rId; this.navaicateUrl(); }) .catch(error => { console.log('4-2'); let errorMessage = ""; error.body.pageErrors.forEach(element => { errorMessage += element.message; }); this.showToast('error',errorMessage); this.showSpinner = false; console.log('4-2-1'); }); } else if (recordName === 'NTC') { console.log('NTC!!!!!'); if(this.tempBtnIdHidden==='NewInstallTarin'){ recordName = 'NewInstallTarin'; }else if(this.tempBtnIdHidden==='FaultPreventionTraining'){ recordName = 'FaultPreventionTraining'; }else if(this.tempBtnIdHidden==='AftermarketHeel'){ //售后跟台 recordName = 'OPD'; } addReportNT({ repOwnerId: this.reportOwner.Id, dailyReportId: reId, eventId: this.activityObj.Id, recordType: recordName, aId: aId, visitor1: this.contactId1, visitor2: this.contactId2, // visitor3: this.contactId3, visitor4: this.contactId4, visitor5: this.contactId5, sTime: sTime, eTime: eTime}) visitor3: this.contactId3, sTime: sTime, eTime: eTime}) .then(result => { // console.log('ntc addReportNT result:'+result); rId = result; this.activityObj = { ...this.activityObj, ['NTC_ID__c']: rId }; if(recordName == 'NewInstallTarin' ) { this.activityObj = { ...this.activityObj, ['NewInstallTarin_FLAG__c']: true }; } else if( recordName == 'FaultPreventionTraining' ) { this.activityObj = { ...this.activityObj, ['FaultPreventionTraining_FLAG__c']: true }; } else if(recordName == 'OPD') { this.activityObj = { ...this.activityObj, ['OPD_FLAG__c']: true }; } this.currentTypeId = rId; this.navaicateUrl(); }) .catch(error => { // console.log('ntc addReportNT error:' + error); let errorMessage = ""; error.body.pageErrors.forEach(element => { errorMessage += element.message; }); this.showToast('error',errorMessage); this.showSpinner = false; }); } }else{ this.navaicateUrl(); } // this.showSpinner = false; console.log('------------------'); } navaicateUrl(){ this.showSpinner = false; console.log('navaicateUrl'); // var urlStr = '/' + this.currentTypeId + '/e?retURL=%2F' + this.currentTypeId+'&CF00N10000008ps6d_lkid='+this.OPDId;//2022-4-17 yjk var urlStr = '/' + this.currentTypeId + '/e?retURL=%2F' + this.currentTypeId+'&Report_OPDPlan__c='+this.OPDId;//2022-4-17 yjk console.log(urlStr+'!!!!!!!!!!!!!!!!!!!'); // window.open(urlStr, '_blank'); if (this.currentTypeId.startsWith('a3x')) { this[NavigationMixin.GenerateUrl]({ type: 'standard__recordPage', attributes: { recordId: this.currentTypeId, objectApiName: 'Report__c', actionName: 'edit' }, state: { backgroundContext: '/lightning/r/Report__c/' + this.currentTypeId + '/view' } }).then(generatedUrl => { window.open(generatedUrl); }); } else { window.open(urlStr, '_blank'); } this.resetOPDSISRadio(); this.showModal = false; } typeChange(event){ console.log('typeChange'); this.tempRecordTypeName = event.target.value; console.log(this.tempRecordTypeName); } createOPDSISReport() { console.log('createOPDSISReport'); console.log(this.tempRecordTypeName); this.hiddenDivShowFlg = true; this.openPD('OPDOrSIS',this.tempRecordTypeName,this.tempReportId); } closeOPDSISDiv() { this.showModal = false; this.hiddenDivShowFlg = false; resetOPDSISRadio(); } resetOPDSISRadio() { if(this.reportOwner.Job_Category__c==='销售推广'){ this.tempRecordTypeName = 'SIS'; }else{ this.tempRecordTypeName = 'OPD'; } } //设置所有的按钮和输入框disable @api setVisitorPlaceDisabled() { // this.allDisableFlg = true; console.log('setVisitorPlaceDisabled:'+this.allDisableFlg); if(this.allDisableFlg){ this.setNotVisible(); return; } this.isPlaceDis=false; this.isConDis1=false; this.isConDis2=false; this.isConDis3=false; this.isOppDis1=false; this.isOppDis2=false; this.isOppDis3=false; this.isTransferEtDis=false; this.isActivityEtDis=false; this.isupdateAccInfoDis=false; this.isNewOpdDis=false; this.isCheckReportDis=false; this.isOPDSISDis=false; this.isNTCCDSDis=false; this.isNewBuyDis=false; this.isOppUpdateDis1=false; this.isLoseDis1=false; this.isOppUpdateDis2=false; this.isLoseDis2=false; this.isOppUpdateDis3=false; this.isLoseDis3=false; this.beforeHourDis = false; this.beforeMinuteDis = false; this.afterHourDis = false; this.afterMinuteDis = false; this.visitDis = false; this.visitAimDis = false; this.Purpose_TypeEscFSEDis = false; this.Purpose_TypeEscFSE2Dis = false; this.Purpose_TypeEscFSE3Dis = false; this.Purpose_TypeFSEDis = false; this.Purpose_TypeFSE2Dis = false; this.Purpose_TypeFSE3Dis = false; this.DescriptionDis = false; this.Find_Imitations_FlagDis = false; this.cancelReasonSelectDis = false; this.cancelReasonSelectFSEDis = false; this.cancelReasonOtherDis = false; this.delayReasonSelectDis = false; this.delayReasonSelectFSEDis = false; this.delayReasonOtherDis = false; this.delayToDateDis = false; this.cancelsaveJSDis = false; this.delaysaveJSDis = false; this.isUseReportDis = false; this.isRelatedServiceDis = false; this.isAccDis = false; this.saveDis = false; console.log(this.visit); if(this.visit === '病院'){//用户拜访 console.log('1'); }else if(this.visit === '販売店'){//经销商拜访 console.log('2'); this.isConDis1 = true; this.isConDis2 = true; this.isConDis3 = true; this.isTransferEtDis = true; this.isActivityEtDis = true; this.isupdateAccInfoDis = true; this.isNewOpdDis = true; this.isCheckReportDis = true; this.isOPDSISDis = true; this.isNTCCDSDis = true; this.isNewBuyDis = true; this.isRelatedServiceDis = true; }else if(this.visit === '社内活動'){//公司工作 console.log('3'); this.isConDis1 = true; this.isConDis2 = true; this.isConDis3 = true; this.isOppDis1 = true; this.isOppDis2 = true; this.isOppDis3 = true; this.isNewBuyDis = true; this.isNewOpdDis = true; this.isCheckReportDis = true; this.isTransferEtDis = true; this.isActivityEtDis = true; this.isupdateAccInfoDis = true; this.isRelatedServiceDis = true; }else if(this.visit === '社外イベント'){//学术会议 console.log('4'); this.isConDis1 = true; this.isConDis2 = true; this.isConDis3 = true; this.isOppDis1 = true; this.isOppDis2 = true; this.isOppDis3 = true; this.isTransferEtDis = true; this.isActivityEtDis = true; this.isupdateAccInfoDis = true; this.isNewOpdDis = true; this.isCheckReportDis = true; this.isOPDSISDis = true; this.isNTCCDSDis = true; this.isNewBuyDis = true; this.isRelatedServiceDis = true; }else{ console.log('5'); console.log(this.reportReportFlg); //访问场所 this.isPlaceDis = true; this.isAccDis = true; //访问对象 this.isConDis1 = true; this.isConDis2 = true; this.isConDis3 = true; //涉及的询价 this.isOppDis1 = true; this.isOppDis2 = true; this.isOppDis3 = true; //转至ET App按钮 this.isTransferEtDis = true; //ET App活动按钮 this.isActivityEtDis = true; //更新客户信息按钮 this.isupdateAccInfoDis = true; //新建OPD计划按钮 this.isNewOpdDis = true; //点检报告书按钮 this.isCheckReportDis = true; //OPD/SIS按钮 this.isOPDSISDis = true; //NTC/CDS按钮 this.isNTCCDSDis = true; //新建购买意向按钮 this.isNewBuyDis = true; //维修合同 this.isRelatedServiceDis = true; } this.setReportContractDis(); this.setInfrastructureProjectDis(); // DB202312521391 zzm 20240102 start this.setEtappThirdCategoryDis(); this.setEtappThirdCategoryDis2(); this.setEtappThirdCategoryDis3(); // DB202312521391 zzm 20240102 end // if(this.isOppDis1===true||this.stringIsEmpty(this.activityObj.Related_Opportunity1_ID__c)){ if(this.isOppDis1===true||this.stringIsEmpty(this.Related_Opportunity1_ID)){ //询价更新按钮 this.isOppUpdateDis1 = true; //失单按钮 this.isLoseDis1 = true; }else{ this.isOppUpdateDis1 = false; this.isLoseDis1 = false; } if(this.isOppDis2===true||this.stringIsEmpty(this.Related_Opportunity2_ID)){ //询价更新按钮 this.isOppUpdateDis2 = true; //失单按钮 this.isLoseDis2 = true; }else{ this.isOppUpdateDis2 = false; this.isLoseDis2 = false; } if(this.isOppDis3===true||this.stringIsEmpty(this.Related_Opportunity3_ID)){ //询价更新按钮 this.isOppUpdateDis3 = true; //失单按钮 this.isLoseDis3 = true; }else{ this.isOppUpdateDis3 = false; this.isLoseDis3 = false; } if (!this.isNotSalesService) { //合同点检的不需要信息更新 if(this.activityObj.Related_Service1_ID__c){ if(this.purposeType1==='合同季报'){ this.isInfoUpdateDis = false; } } } //如果没得报告书权限 if(this.reportReportFlg){ if(!this.isOPDSISDis){ this.isOPDSISDis = true; } if(!this.isNTCCDSDis){ this.isNTCCDSDis = true; } } this.checkVisitChange(); this.initDelayAndCancel(); //如果报告一览的有值,所有输入信息不准更改 // if(!this.stringIsEmpty(this.activityObj.eventStatus__c) && !this.readReportFlag){ if(!this.stringIsEmpty(this.activityObj.eventStatus__c) ){ console.log('如果报告一览的状态有值,所有输入信息不准更改'); this.isPlaceDis = true; this.isConDis1 = true; this.isConDis2 = true; this.isConDis3 = true; this.isOppDis1 = true; this.isOppDis2 = true; this.isOppDis3 = true; this.beforeHourDis = true; this.beforeMinuteDis = true; this.afterHourDis = true; this.afterMinuteDis = true; this.visitDis = true; this.visitAimDis = true; this.Purpose_TypeEscFSEDis = true; this.Purpose_TypeEscFSE2Dis = true; this.Purpose_TypeEscFSE3Dis = true; this.Purpose_TypeFSEDis = true; this.Purpose_TypeFSE2Dis = true; this.Purpose_TypeFSE3Dis = true; this.DescriptionDis = true; this.Find_Imitations_FlagDis = true; this.cancelReasonSelectDis = true; this.cancelReasonSelectFSEDis = true; this.cancelReasonOtherDis = true; this.delayReasonSelectDis = true; this.delayReasonSelectFSEDis = true; this.delayReasonOtherDis = true; this.delayToDateDis = true; this.cancelsaveJSDis = true; this.delaysaveJSDis = true; this.isUseReportDis = true; this.isRelatedServiceDis = true; this.isAccDis = true; this.isupdateAccInfoDis = true; this.isNewBuyDis = true; this.isNewOpdDis = true; this.isOPDSISDis = true; this.isTransferEtDis = true; this.isActivityEtDis = true; this.isCheckReportDis = true; this.isNTCCDSDis = true; this.isReportContractDis = true; this.isReportContractTypeDis = true; this.isInfrastructureProjectDis1 = true; this.isInfrastructureProjectDis2 = true; this.saveDis = true; // DB202312521391 zzm 20240102 start this.etappThirdCategoryDis=true ; this.etappThirdCategoryDis2=true ; this.etappThirdCategoryDis3=true ; this.etappForthCategoryDis=true ; this.etappForthCategoryDis2=true ; this.etappForthCategoryDis3=true ; // DB202312521391 zzm 20240102 end } if(this.activityObj.taskDifferent__c === '主动任务' ) { this.visitDis = true; console.log('visitDis is true 2>>>>>>>>>>>>>>'); if(this.visit !== '社外イベント') { this.isAccDis = true; } } console.log('setVisitorPlaceDisabled 结束'); } @api setNotVisible(){ console.log('activeConten setNotVisible1'); // const allInputsAndButtons = this.template.querySelectorAll('lightning-input, lightning-button,lightning-input-field'); // allInputsAndButtons.forEach(element => { // element.disabled = true; // }); // this.isAccDis = true; // this.isConDis1 = true; // this.isConDis2 = true; // this.isConDis3 = true; this.isPlaceDis=true; this.isConDis1=true; this.isConDis2=true; this.isConDis3=true; this.isOppDis1=true; this.isOppDis2=true; this.isOppDis3=true; this.isTransferEtDis=true; this.isActivityEtDis=true; this.isupdateAccInfoDis=true; this.isNewOpdDis=true; this.isCheckReportDis=true; this.isOPDSISDis=true; this.isNTCCDSDis=true; this.isNewBuyDis=true; this.isOppUpdateDis1=true; this.isLoseDis1=true; this.isOppUpdateDis2=true; this.isLoseDis2=true; this.isOppUpdateDis3=true; this.isLoseDis3=true; this.beforeHourDis = true; this.beforeMinuteDis = true; this.afterHourDis = true; this.afterMinuteDis = true; this.visitDis = true; this.visitAimDis = true; this.Purpose_TypeEscFSEDis = true; this.Purpose_TypeEscFSE2Dis = true; this.Purpose_TypeEscFSE3Dis = true; this.Purpose_TypeFSEDis = true; this.Purpose_TypeFSE2Dis = true; this.Purpose_TypeFSE3Dis = true; this.DescriptionDis = true; this.Find_Imitations_FlagDis = true; this.cancelReasonSelectDis = true; this.cancelReasonSelectFSEDis = true; this.cancelReasonOtherDis = true; this.delayReasonSelectDis = true; this.delayReasonSelectFSEDis = true; this.delayReasonOtherDis = true; this.delayToDateDis = true; this.cancelsaveJSDis = true; this.delaysaveJSDis = true; this.isUseReportDis = true; this.isRelatedServiceDis = true; this.isAccDis = true; this.isInfrastructureProjectDis1 = true; this.isInfrastructureProjectDis2 = true; this.saveDis = true; this.isReportContractDis = true; this.isReportContractTypeDis = true; // DB202312521391 zzm 20240102 start this.etappThirdCategoryDis=true ; this.etappThirdCategoryDis2=true ; this.etappThirdCategoryDis3=true ; this.etappForthCategoryDis=true ; this.etappForthCategoryDis2=true ; this.etappForthCategoryDis3=true ; // DB202312521391 zzm 20240102 end console.log('this.beforeHourDis:' + this.beforeHourDis); } @api setVisible(){ console.log('activeContent setVisible 1424'); // const allInputsAndButtons = this.template.querySelectorAll('lightning-input, lightning-button,lightning-input-field'); // allInputsAndButtons.forEach(element => { // element.disabled = false; // }); this.isPlaceDis=false; this.isConDis1=false; this.isConDis2=false; this.isConDis3=false; this.isOppDis1=false; this.isOppDis2=false; this.isOppDis3=false; this.isTransferEtDis=false; this.isActivityEtDis=false; this.isupdateAccInfoDis=false; this.isNewOpdDis=false; this.isCheckReportDis=false; this.isOPDSISDis=false; this.isNTCCDSDis=false; this.isNewBuyDis=false; this.isOppUpdateDis1=false; this.isLoseDis1=false; this.isOppUpdateDis2=false; this.isLoseDis2=false; this.isOppUpdateDis3=false; this.isLoseDis3=false; this.beforeHourDis = false; this.beforeMinuteDis = false; this.afterHourDis = false; this.afterMinuteDis = false; this.visitDis = false; this.visitAimDis = false; this.Purpose_TypeEscFSEDis = false; this.Purpose_TypeEscFSE2Dis = false; this.Purpose_TypeEscFSE3Dis = false; this.Purpose_TypeFSEDis = false; this.Purpose_TypeFSE2Dis = false; this.Purpose_TypeFSE3Dis = false; this.DescriptionDis = false; this.Find_Imitations_FlagDis = false; this.cancelReasonSelectDis = false; this.cancelReasonSelectFSEDis = false; this.cancelReasonOtherDis = false; this.delayReasonSelectDis = false; this.delayReasonSelectFSEDis = false; this.delayReasonOtherDis = false; this.delayToDateDis = false; this.cancelsaveJSDis = false; this.delaysaveJSDis = false; this.isUseReportDis = false; this.isRelatedServiceDis = false; } //更新客户信息 updateAccInfo(){ if(this.filter){ //查询该访问场所的战略科室分类 queryDepartmentClass({ accId: this.filter}) .then(result => { if(result){ var urlStr = '/' + result; window.open(urlStr,'_blank',''); }else{ this.showToast('error','该访问场所没有战略科室分类'); } }) .catch(error => { let errorMessage = ""; error.body.pageErrors.forEach(element => { errorMessage += element.message; }); this.showToast('error','失败,'+errorMessage); }); }else{ this.showToast('error','请先选择访问场所'); } } // 2018/11/21 SWAG-B6Q8BS 判断是否需要弹窗更新客户信息 start // 2018/11/21 SWAG-B6Q8BS 初始化设置颜色使用 @api setColor(){ // var ProfileId_2S1 = '{!$Label.ProfileId_2S1}'; // var salesman2S1_Price = '{!$Label.salesman2S1_Price}'; // var completionFlg = '{!completionFlg}'; //2S1_销售医院担当 和 2S1_销售医院担当(查看价格) // if("{!$Profile.Id}" != ProfileId_2S1 && "{!$Profile.Id}" != salesman2S1_Price){ // return; // } if(this.reportOwner.ProfileId!=this.ProfileId_2S1 && this.reportOwner.ProfileId!=this.salesman2S1_Price) { return false; } else { this.updateAccInfoColor = this.activityObj.IsAlertInputDep__c; return this.activityObj.IsAlertInputDep__c; } // var actSize = '{!actSize}'; // var alertflg = false; // for(var i = 0;i { console.log('11111111111111111'); console.log('queryHospital.result:'+result); if(result){ var urlStr = 'ocsmet://Activity/' + result; console.log(urlStr); let a = document.createElement('a'); a.setAttribute('href',urlStr); document.body.appendChild(a); a.click(); a.remove(); // window.open(urlStr, '_blank', ''); // window.open(urlStr, '_blank'); // window.location.href=urlStr; }else{ this.showToast('error','该访问场所没有医院(科室)'); } }) // .catch(error => { // let errorMessage = ""; // error.body.pageErrors.forEach(element => { // errorMessage += element.message; // }); // this.showToast('error','失败,'+errorMessage); // }); }else{ this.showToast('error','没有选择医院,不能跳转'); } } } //ET APP活动 ETAPPAct(){ if(this.filter && this.filter.startsWith("001")){ var urlStr = '/apex/productsh?Id=' + this.filter; window.open(urlStr, '_blank', ''); //查询该访问场所的战略科室分类 // queryDepartmentClass({ accId: this.filter}) // .then(result => { // if(result){ // var urlStr = '/' + result; // window.open(urlStr,'_blank'); // }else{ // this.showToast('error','该访问场所没有战略科室分类'); // } // }) // .catch(error => { // let errorMessage = ""; // error.body.pageErrors.forEach(element => { // errorMessage += element.message; // }); // this.showToast('error','失败,'+errorMessage); // }); }else{ this.showToast('error','请先选择访问场所'); } } //访问场所不允许修改 vpChack1() { console.log('vpChack1'); console.log(!this.stringIsEmpty(this.filter)); console.log(!this.stringIsEmpty(this.activityObj.Event_ID__c)); if(!this.stringIsEmpty(this.filter)&&!this.stringIsEmpty(this.activityObj.Event_ID__c)){ this.isAccDis = true; } if(!this.stringIsEmpty(this.visit)&&!this.stringIsEmpty(this.activityObj.Event_ID__c)){ this.visitDis = true; console.log('visitDis is true 3>>>>>>>>>>>>>>'); } if (this.reportOwner.Job_Category__c === '销售服务') { var puroposeTypeFSE1 = this.activityObj.Purpose_TypeFSE__c; if ((puroposeTypeFSE1 === '合同季报'||puroposeTypeFSE1 === '合同点检') && !this.stringIsEmpty(this.activityObj.Event_ID__c)) { this.Purpose_TypeFSEDis = true; this.visitAimDis = true; this.isRelatedServiceDis = true; } } } setRelOppId(index, id, hiddenId){ var str = 'Page:mainForm:idDayEdit:idActivities:'+ index + ':' + id; var strPD = 'Page:mainForm:idDayEdit:idActivities:'+ index + ':idVisitorPlace'; var aNamePD = j$(escapeVfId(strPD)).value(); if(aNamePD == ''){ // 訪問場所を設定してください。 document.getElementById(str).blur(); alert(Error_Message16); return; } var strVP = 'Page:mainForm:idDayEdit:idActivities:'+ index + ':idVisitorPlaceId'; var vl = j$(escapeVfId(strVP)).value(); if(vl.length == 0){ // 訪問場所が存在しません。 document.getElementById(str).blur(); alert(Error_Message15); return; } var match = sforce.apex.execute("Add_Report","checkAccountMatch",{name:aNamePD,id:vl}); if(match == "NG"){ // 訪問場所IDマッチしていない document.getElementById(str).blur(); alert("无法确定访问场所,请再设定一次访问场所。"); return; } var strPage = '/apex/Xin_SearchOpportunity?r=' + encodeURI(vl); jQuery(escapeVfId(str)).unbind(); jQuery(escapeVfId(str)).suggest(strPage,{}); //DoubleTapイベントをbind bindDoubleTap(index, id, hiddenId); } //询价更新按钮 oppUpdate(event){ var indexNumber = event.target.name; var oppId = ''; if(indexNumber==='1'){ // oppId = this.activityObj.Related_Opportunity1_ID__c; oppId = this.Related_Opportunity1_ID; }else if(indexNumber==='2'){ oppId = this.Related_Opportunity2_ID; }else if(indexNumber==='3'){ oppId = this.Related_Opportunity3_ID; } window.open("/apex/EnquiryDetails?EsetId="+oppId+"&indexNumber="+indexNumber,'_blank','width=850px,height=520px'); } //失单按钮 loseOpp(event){ var indexNumber = event.target.name; var oppId = ''; if(indexNumber==='1'){ // oppId = this.activityObj.Related_Opportunity1_ID__c; oppId = this.Related_Opportunity1_ID; }else if(indexNumber==='2'){ oppId = this.Related_Opportunity2_ID; }else if(indexNumber==='3'){ oppId = this.Related_Opportunity3_ID; } // window.open('/apex/PCLLostReportPageLwc?pageStatus=Create&oppId=' + oppId + '&lostType=失单','_blank'); window.open('/lightning/n/PCLLostReportPageLwc#pageStatus=Create&oppId=' + oppId + '&lostType=失单','_blank'); } //新建购买意向按钮 addLeadNew(index, eid) { console.log('addLeadNew'); this.showSpinner = true; if (this.stringIsEmpty(this.filter)) { // 訪問場所を設定してください。 this.showToast('error',this.customLabel.Error_Message16); this.showSpinner = false; } this.saveTheActivity('addLeadNew'); } addLead() { console.log('addLead'); var eid = this.activityObj.Id; var accountRecord = this.activityObj.Account_ID__c; var visitor1 = this.contactId1; var result = this.activityObj.Description__c; var dcId; var accName; var contactName; var contactAwsId = ''; // if(visitor1 != null && visitor1 != ''){ // getContactAwsIdByCOntactId({contactId : visitor1}) // .then(result => { // console.log('getContactAwsIdByCOntactId:'+result); // contactAwsId = result; // }); // } queryAbountIndo({ accId: this.filter,contactId : visitor1}) .then(result => { dcId = result.acc.Department_Class__c; accName = result.acc.Name; let hospitalId = result.acc.Hospital__c; //pipl还原 by DTT-亚楠 20240109 // window.open('/lightning/o/Lead/new?defaultFieldValues=Name=1111,Hospital_Name__c='+this.filter // +',Description='+this.activityObj.Description__c+',Department_Class__c='+dcId+ // ',Company='+encodeURI(accName)+ // ',Contact_Name__c='+visitor1+',awsDataId='+contactAwsId+',RecordTypeId='+this.newLeadRecordType, '_blank'); var leadUrl = '/lightning/o/Lead/new?defaultFieldValues=Hospital_Name__c='+this.filter +',Description='+this.activityObj.Description__c+',Department_Class__c='+dcId +',Company='+encodeURI(accName) +',hospital__c='+hospitalId //pipl还原 by DTT-亚楠 20240109 +',RecordTypeId='+this.newLeadRecordType; // ',Contact_Name__c='+visitor1+',contactName='+contactName+',awsDataId='+contactAwsId if(result){ this.showSpinner = false; if(visitor1) { // contactAwsId = result.awsId;//pipl还原 by DTT-亚楠 20240109 contactName = result.con.Name; leadUrl += ',Name='+contactName+',Contact_Name__c='+visitor1+',contactName='+contactName; // 去除+',awsDataId='+contactAwsId } // console.log(JSON.stringify(result)); console.log('queryAbountIndo:'); console.log('queryAbountIndo agencyContactName'); console.log(this.agencyContactName); // const visitorComponents = this.template.querySelectorAll('c-look-up-util'); // if (visitorComponents.length > 0) { // visitorComponents.forEach(visitorComponent => { // if(visitorComponent['uniqueKey'] =='AgencyContact1') { // visitorComponent.handleRemovePill(); // } // }); // } // contactName = result.contact.Name; console.log(leadUrl); window.open(leadUrl,'_blank'); // newLeadRecordType // const defaultLeadValues = encodeDefaultFieldValues({ // Hospital_Name__c: this.filter, // Description: this.activityObj.Description__c, // Department_Class__c: dcId, // Company: accName, // Contact_Name__c: visitor1, // RecordTypeId: this.newLeadRecordType, // Name: '111' // }); // this[NavigationMixin.Navigate]({ // type: 'standard__objectPage', // attributes: { // objectApiName: 'Lead', // actionName: 'new' // }, // state: { // // nooverride: '1', // defaultFieldValues: defaultLeadValues, // recordTypeId: this.newLeadRecordType // } // }); } }) .catch(error => { let errorMessage = ""; error.body.pageErrors.forEach(element => { errorMessage += element.message; }); this.showToast('error','失败,'+errorMessage); this.showSpinner = false; }); // const defaultFieldValues = encodeDefaultFieldValues({ // Hospital_Name__c: this.filter, // Description: this.activityObj.Description__c, // Contact_Name__c: visitor1, // }); // const pageReference = { // type: 'standard__objectPage', // attributes: { // objectApiName: 'Lead', // actionName: 'new' // }, // state: { // // defaultFieldValues: JSON.stringify(defaultFieldValues) // defaultFieldValues: defaultFieldValues // } // }; // this[NavigationMixin.Navigate](pageReference); } //延期按钮 delaysaveJS() { console.log('delaysaveJS'); var lastDate = this.activityObj.Finish_Date__c; var repd = new Date(this.reportedDate+''); var reod = this.activityObj.delayReasonOther__c; var reodfse = this.activityObj.delayReasonSelectFSE__c; var reodesc = this.activityObj.delayReasonSelect__c; var dlyd = ''; if(this.activityObj.delayToDate__c) { dlyd = new Date(this.activityObj.delayToDate__c+''); } //获取拜访区分 var visitQFV = this.activityObj.Activity_Type2__c; if (this.stringIsEmpty(reodfse) && this.stringIsEmpty(reodesc)) { this.showToast('error','请填写延期理由。'); return; } if (reodfse === '其他' || reodesc === '其他') { if (this.stringIsEmpty(reod)) { this.showToast('error','延期理由为其他,请补充其他原因'); return; } } console.log('-------------------'); if (this.stringIsEmpty(dlyd)) { this.showToast('error','请填写延期日期。'); return; } if (this.stringIsEmpty(this.activityObj.Event_ID__c)) { this.showToast('error','手动创建的日报明细不支持延期。'); return; } else { console.log('11111111111111111'); console.log(repd); var repyear = repd.getFullYear(); console.log('x'); var repmonth = repd.getMonth(); var repday = repd.getDate(); var dlyyear = dlyd.getFullYear(); var dlymonth = dlyd.getMonth(); var dlyday = dlyd.getDate(); console.log('222222222222'); var today = new Date(); console.log('333333333333'); console.log(this.activityObj.taskDifferent__c); console.log(today); if ((repyear == dlyyear && repmonth == dlymonth) || (repyear == dlyyear && dlymonth == repmonth + 1) || (repyear + 1 == dlyyear && dlymonth == 1)) { if (repyear == dlyyear && repmonth == dlymonth && repday >= dlyday) { this.showToast('error','不能延期到本月之前的日期。'); return; }else if(today >= dlyd){ this.showToast('error','延期日期必须填写今天之后的日期。'); return; } else if (this.stringIsEmpty(this.activityObj.taskDifferent__c)) { if (visitQFV === '販売店' && visitQFV === '病院' && visitQFV === '社外イベント') { this.showToast('error','手动创建的日报明细不支持延期。请取消。'); return; } else { if (window.confirm('您是否要延期日历上的活动?')) { this.ifDelayJS(); } } } else if (this.activityObj.taskDifferent__c === '主动任务' && this.activityObj.delayTaskDelay__c) { if (window.confirm('您是否要延期日历上的活动?')) { this.ifDelayJS(); } } else if (this.activityObj.taskDifferent__c === '主动任务' && this.activityObj.delayTaskDelay__c && repmonth !== dlymonth) { this.showToast('error','主动任务只能延期到本月。'); return; } else if (this.activityObj.taskDifferent__c === '被动任务' ||this.activityObj.taskDifferent__c === '上级分配任务') { //2021-10-13 mzy 任务管理改善 end if (dlyd > lastDate) { this.showToast('error','只能延期到' + lastDate + '之前的日期'); return; } else { if (window.confirm('您是否要延期日历上的活动?')) { this.ifDelayJS(); } } } else { if (window.confirm('您是否要延期日历上的活动?')) { this.ifDelayJS(); } } } else { this.showToast('error','只能延期到本月或者下个月。'); return; } } this.showSpinner = false; } ifDelayJS(){ this.showSpinner = true; console.log('ifDelayJS'); // 延期必须是作成中才可以延期。 if(this.report.Status__c == '作成中'){ if (this.report.Status_With_Check__c !== '草案中') { this.showToast('error','只能延期到草案中的日报。'); return; } this.activityObj = { ...this.activityObj, ['eventStatus__c']: '延期' }; this.saveTheActivity('延期'); } } initDelayAndCancel(){ //任务区分 var valTaskDifferent = this.activityObj.taskDifferent__c; //用户Job if(this.activityObj.taskId__c){ //任务状态为 完成 ,则 不可以修改 var valTaskStatus = this.activityObj.backEventStatus__c; //存在,判断是否为上级分配任务 ,是否为完成 if(valTaskDifferent === '上级分配任务' ||valTaskStatus === '03 完成'){ this.cancelReasonSelectDis = true; this.cancelReasonSelectFSEDis = true; this.cancelReasonOtherDis = true; this.delayReasonSelectDis = true; this.delayReasonSelectFSEDis = true; this.delayReasonOtherDis = true; this.delayToDateDis = true; this.cancelsaveJSDis = true; this.delaysaveJSDis = true; } } } //取消按钮 cancelsaveJS(index, eventid) { console.log("cancelsaveJS"); this.showSpinner = true; var celd = this.activityObj.cancelReasonSelectFSE__c; var celd1 = this.activityObj.cancelReasonSelect__c; var celrd = this.activityObj.cancelReasonOther__c; var celOPDbox2 = this.activityObj.OPDPlan_Flag__c; if (celOPDbox2) { if (window.confirm('该医院的OPD计划是否确认取消?如需改期,请选择延期及理由或进入OPD计划进行延期。') == false) { this.showSpinner = false; return; } else{ this.showSpinner = false; } } if (this.stringIsEmpty(celd)&& this.stringIsEmpty(celd1)) { this.showToast('error','请填写取消理由。'); this.showSpinner = false; return; } else if (celd === '其他' || celd1 === '其他') { if (!celrd) { this.showToast('error','取消原因为其他,请补充其他原因。'); this.showSpinner = false; return; } } if (window.confirm('您是否要取消日历上的活动?')) { this.activityObj = { ...this.activityObj, ['eventStatus__c']: '取消' }; this.saveTheActivity('取消'); } else{ this.showSpinner = false; } } stringIsEmpty(str) { if (str === '' || str === undefined || str === null) { return true; } else { return false; } } // showToast(variant,mes) { // const event = new ShowToastEvent({ // message: mes, // variant: variant, // }); // this.dispatchEvent(event); // } showToast(type,msg) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type }); this.dispatchEvent(event); }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode: 'sticky' }); this.dispatchEvent(event); } } }