/*
|
* @Date: 2023-03-28 16:47:34
|
* @Author: @zyh
|
* @LastEditTime: 2023-04-17 10:33:27
|
* @Descripttion:
|
*/
|
import { LightningElement,wire,track,api } from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import init from '@salesforce/apex/OPDLwcController.initOPDCancelSubmit';
|
import RecordType from '@salesforce/apex/OPDLwcController.RecordType';
|
// import applySelect from '@salesforce/apex/OPDLwcController.applySelect';
|
import changeTrade from '@salesforce/apex/OpdPlanWebService.changeTrade';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
|
export default class OpdUpdateDate extends NavigationMixin(LightningElement) {
|
@api recordId;
|
Status;
|
Name;
|
Id;
|
rtnRecordType;
|
|
@wire(CurrentPageReference)
|
getStateParmeters(currentPageReference) {
|
console.log(111);
|
console.log(currentPageReference);
|
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
console.log("str");
|
console.log(str);
|
this.recordId = str;
|
}
|
}
|
}
|
connectedCallback(){
|
console.log('zheli'+this.recordId);
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
console.log('zheli11'+result);
|
|
console.log(result);
|
if(result != null) {
|
this.IsLoading = false;
|
this.Id = result.Id;
|
this.Status = result.Status;
|
this.Name = result.Name;
|
console.log("123");
|
console.log(this.Id);
|
console.log(this.Status);
|
console.log(this.Name);
|
this.testupdate();
|
this.updateDateSubmit();
|
this.dispatchEvent(new CloseActionScreenEvent());
|
// this.dispatchEvent(new ShowToastEvent({
|
// title: '1111',
|
// message: 'message',
|
// variant: 'success'
|
// }));
|
}
|
}).catch(error => {
|
console.log("error");
|
console.log(error);
|
}).finally(() => {
|
|
});
|
}
|
testupdate(){
|
var typertn = [];
|
RecordType({
|
RecordType : '01210000000gQyMAAU'
|
}).then(result => {
|
console.log(result);
|
const defaultValues = encodeDefaultFieldValues({
|
RecordTypeId: result,
|
Status__c: '延期报告',
|
CancelOPDPlan__c: this.Id
|
});
|
console.log(defaultValues);
|
this.rtnRecordType = defaultValues;
|
console.log(this.rtnRecordType+'======123131typertn');
|
|
});
|
}
|
updateDateSubmit(){
|
var rtn = [];
|
changeTrade({
|
opdplanId: this.Id
|
}).then(result => {
|
console.log(result);
|
console.log('typertn+++++'+this.rtnRecordType);
|
rtn = result;
|
console.log('4-14');
|
if (rtn.lenth > 0) {
|
// alert('只有当OPD计划中的备品申请单无/草案/备品申请的出库指示为空时,才可以进行改期操作!');
|
// return;
|
const evt = new ShowToastEvent({
|
title : 'Error',
|
message : '只有当OPD计划中的备品申请单无/草案/备品申请的出库指示为空时,才可以进行改期操作!',
|
variant : 'error'
|
});
|
this.dispatchEvent(evt);
|
return;
|
}
|
if (rtn != 'OK') {
|
alert(rtn);
|
return;
|
}
|
// window.open('/a3D/e?CF00N10000008ps4s='+this.Name +'&00N10000008ps4u=延期报告&RecordType=01210000000gQyM');
|
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'CancelPostponePlan__c', // 要新建的对象API
|
actionName: 'new'//,
|
// RecordTypeId: '01210000000gQyM'
|
},
|
state:{
|
// defaultFieldValues:'CancelOPDPlan__c='+this.Id// 要复制的字段API
|
defaultFieldValues:this.rtnRecordType// 要复制的字段API
|
|
}
|
});
|
|
});
|
}
|
|
|
}
|