/*
|
* @Description:
|
* @version:
|
* @Author: chen jing wu
|
* @Date: 2023-06-09 16:41:45
|
* @LastEditors: chen jing wu
|
* @LastEditTime: 2023-10-10 17:38:50
|
*/
|
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.initForOPDReportConsumButton';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
export default class LexOPDReportConsum extends NavigationMixin(LightningElement) {
|
@api recordId;
|
raStatus;
|
productCategory;
|
hospital;
|
strategicDept;
|
account;
|
consumApplyId;
|
recordTypeId;
|
recordTypeId1;
|
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=>{
|
this.raStatus = result.raStatus;
|
this.productCategory = result.productCategory;
|
this.hospital = result.hospital;
|
this.strategicDept = result.strategicDept;
|
this.account = result.account;
|
this.consumApplyId = result.consumApplyId;
|
this.recordTypeId = result.recordTypeId;
|
this.recordTypeId1 = result.recordTypeId1;
|
this.OPDReportConsum();
|
this.Isloading = false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
|
OPDReportConsum(){
|
var status = this.raStatus;
|
if(status != "已出库" && status != "申请者已收货" && status != "待消耗" && status != "已回寄" && status != "完了"){
|
this.msg = "耗材借出状态:" + status + ",不能创建报告书!";
|
this.showToast(this.msg,'error');
|
return;
|
}
|
var Product_category = this.productCategory;
|
var strs ;
|
var url
|
if(Product_category =='ET'){
|
const defaultValues = encodeDefaultFieldValues({
|
Consum_Apply__c: this.recordId, // 关联主记录 ID
|
Hospital_Reference__c: this.hospital,
|
Department_Class_Ref__c: this.strategicDept,
|
Hospital_Department__c: this.account
|
});
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Report__c',
|
actionName: 'new'
|
},
|
state: {
|
// 2023 08 04 张赫阳 PIPL相关按钮改造 Start
|
//nooverride: '1',
|
// 2023 08 04 张赫阳 PIPL相关按钮改造 End
|
defaultFieldValues: defaultValues,
|
recordTypeId: this.recordTypeId
|
}
|
});
|
}else if(Product_category =='DISP'){
|
const defaultValues = encodeDefaultFieldValues({
|
Consum_Apply__c: this.recordId, // 关联主记录 ID
|
Hospital_Reference__c: this.hospital,
|
Department_Class_Ref__c: this.strategicDept,
|
Hospital_Department__c: this.account
|
});
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Report__c',
|
actionName: 'new'
|
},
|
state: {
|
// 2023 08 04 张赫阳 PIPL相关按钮改造 Start
|
//nooverride: '1',
|
// 2023 08 04 张赫阳 PIPL相关按钮改造 End
|
defaultFieldValues: defaultValues,
|
recordTypeId: this.recordTypeId1
|
}
|
});
|
}
|
// }else{
|
// strs = '';
|
// }
|
// if(strs.length<=0){
|
// url = '/setup/ui/recordtypeselect.jsp?retURL=%2F'
|
// + this.rentalApplyId
|
// + '&save_new_url=%2Fa0B%2Fe%3FretURL%3D%252Fa0B%252Fo';
|
// }else{
|
// url = '/a0B/e?retURL=%2Fa0B%2Fo' + strs;
|
// }
|
// url += '&CF00N100000098rY2=' + this.name +
|
// '&CF00N100000098rY2_lkid=' + this.recordId +
|
// '&CF00N10000002DPUD=' + this.hospital +
|
// '&CF00N10000002DPUD_lkid=' + this.hospitalId +
|
// '&CF00N10000002Dh0f=' + this.strategicDept +
|
// '&CF00N10000002Dh0f_lkid=' + this.strategicDeptId +
|
// '&CF00N10000002CWW4=' + this.account +
|
// '&CF00N10000002CWW4_lkid=' + this.accountId +'&ent=01I10000000SWfe';
|
// window.open(url);
|
}
|
}
|