import { LightningElement, api } from 'lwc';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import checkStatus from '@salesforce/apex/LexQISCloneButtonController.checkStatus';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; //deloitte-zhj 20231210 PIPL还原 现在使用标准的克隆
|
|
|
export default class lexQISCloneButton extends NavigationMixin(LightningElement) {
|
@api recordId;
|
|
connectedCallback(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
window.clearTimeout(this.delayTimeout);
|
this.delayTimeout = setTimeout(() => {
|
this.handleClick();
|
}, 0);
|
}
|
|
handleClick(){
|
checkStatus({recordId: this.recordId})
|
.then(result => {
|
console.log('result:', result);
|
if (result) {
|
//deloitte-zhj 20231210 PIPL还原 现在使用标准的克隆 start
|
var pageurl = '/lightning/cmp/c__LexQISPIPLAura?c__isClone=true&c__recordId=' + this.recordId;
|
this.navigate(pageurl);
|
|
|
// 创建导航事件
|
// const defaultFieldValues =encodeDefaultFieldValues({
|
// QIS_pre__c: this.recordId
|
// });
|
// console.log('defaultFieldValues = ' + JSON.stringify(defaultFieldValues));
|
// console.log('this.recordId = ' + this.recordId);
|
// this[NavigationMixin.Navigate]({
|
// type: "standard__objectPage",
|
// attributes: {
|
// objectApiName: 'QIS_Report__c',
|
// actionName: "clone",
|
// recordId: this.recordId,
|
// },state: {
|
// nooverride: '1',
|
// defaultFieldValues:defaultFieldValues
|
// }
|
// });
|
//deloitte-zhj 20231210 PIPL还原 现在使用标准的克隆 end
|
} else {
|
const evt = new ShowToastEvent({
|
title: 'Warning',
|
message: '状态为取消的QIS才可以被复制并新建',
|
variant: 'warning',
|
mode: 'dismissable'
|
});
|
this.dispatchEvent(evt);
|
}
|
this.dispatchEvent(new CloseActionScreenEvent());
|
})
|
}
|
navigate(pageurl) {
|
window.open(pageurl, '_self');
|
// this[NavigationMixin.GenerateUrl]({
|
// type: 'standard__webPage',
|
// attributes: {
|
// url: pageurl
|
// }
|
// }).then(generatedUrl => {
|
// console.log('generatedUrl = ' + generatedUrl);
|
// // setTimeout(() => {
|
// // window.open(generatedUrl, '_self');
|
// // }, 0);
|
// });
|
}
|
}
|