import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import init from '@salesforce/apex/ReportController.initForOPDReportButton';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
export default class LexOPDReport extends NavigationMixin(LightningElement) {
|
@api recordId;
|
assetReturnDay2;
|
demoPurpose2;
|
followUPOpp;
|
opdPlan;
|
raStatus;
|
hospital;
|
strategicDept;
|
account;
|
recordTypeId;
|
msg;
|
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;
|
}
|
}
|
}
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
|
updateRecordView(recordId) {
|
updateRecord({fields: { Id: recordId }});
|
}
|
|
connectedCallback(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
init({
|
recordId: this.recordId
|
}).then(result=>{
|
console.log(result);
|
console.log("start");
|
this.assetReturnDay2 = result.assetReturnDay2;
|
this.demoPurpose2 = result.demoPurpose2;
|
this.followUPOpp = result.followUPOpp;
|
this.opdPlan = result.opdPlan;
|
this.raStatus = result.raStatus;
|
this.hospital = result.hospitalId;
|
this.strategicDept = result.strategicDeptId;
|
this.account = result.accountId;
|
this.recordTypeId = result.recordTypeId;
|
this.OPDReportConsum();
|
});
|
}
|
|
OPDReportConsum(){
|
var status = this.raStatus;
|
if(status != "已出库" && status != "申请者已收货" && status != "医院已装机确认" && status != "已回寄" && status != "已回收" && status != "完了" && status != "欠品中"){
|
this.msg = "备品借出状态:" + status + ",不能创建报告书!";
|
this.showToast(this.msg,'error');
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
//2021/7/15 fxk End
|
|
//SWAG-BVW8CW 20201217 让user自己选择recordtype
|
//目的2为---试用(有询价) 带询价
|
var demo_purpose2 = this.demoPurpose2;
|
// var strs ;
|
if(demo_purpose2=='试用(有询价)'){
|
console.log('y');
|
const defaultValues = encodeDefaultFieldValues({
|
Loaner_request_no1__c: this.recordId, // 关联主记录 ID
|
Hospital_Reference__c: this.hospital,
|
Department_Class_Ref__c: this.strategicDept,
|
Report_OPDPlan__c: this.opdPlan,
|
Hospital_Department__c: this.account,
|
Opportunity1__c: this.followUPOpp,
|
Opportunity_Situation__c: '跟进询价',
|
|
});
|
console.log('defaultValues = ' + defaultValues);
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Report__c',
|
actionName: 'new'
|
},
|
state: {
|
//nooverride: '1',
|
defaultFieldValues: defaultValues,
|
recordTypeId: this.recordTypeId
|
}
|
});
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
console.log('n');
|
//Before Update by LiJun 20220321 end
|
//After Update by LiJun 20220321 start
|
const defaultValues = encodeDefaultFieldValues({
|
Loaner_request_no1__c: this.recordId, // 关联主记录 ID
|
Hospital_Reference__c: this.hospital,
|
Department_Class_Ref__c: this.strategicDept,
|
Report_OPDPlan__c: this.opdPlan,
|
Hospital_Department__c: this.account
|
});
|
console.log('defaultValues = ' + defaultValues);
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Report__c',
|
actionName: 'new'
|
},
|
state: {
|
//nooverride: '1',
|
defaultFieldValues: defaultValues,
|
recordTypeId: this.recordTypeId
|
}
|
});
|
this.dispatchEvent(new CloseActionScreenEvent());
|
//After Update by LiJun 20220321 end
|
}
|
}
|