// import { api, wire,LightningElement } from 'lwc';
|
// import { CurrentPageReference } from "lightning/navigation";
|
// import { CloseActionScreenEvent } from 'lightning/actions';
|
// import { updateRecord } from 'lightning/uiRecordApi';
|
// import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
// import { NavigationMixin } from 'lightning/navigation';
|
// import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
// import init from '@salesforce/apex/lexNewOnLineSurvey2Controller.init';
|
|
// export default class lexNewOnLineSurvey2 extends NavigationMixin(LightningElement) {
|
// @api recordId;
|
// id;
|
// reportId;
|
// CreatedById;
|
// CreatedBy_Name__c;
|
// Name
|
// @wire(CurrentPageReference)
|
// getStateParameters(currentPageReference) {
|
// if (currentPageReference) {
|
// const urlValue = currentPageReference.state.recordId;
|
// if (urlValue) {
|
// let str = `${urlValue}`;
|
// this.recordId = str;
|
// }
|
// }
|
// }
|
// connectedCallback(){
|
// init({
|
// recordId: this.recordId
|
// }).then(result=>{
|
// this.Name = result.Id;
|
// this.CreatedBy_Name__c=result.CreatedByNameC;
|
// this.CreatedById=result.CreatedById
|
// this.createOPDFromRentalApply();
|
// });
|
// }
|
// createOPDFromRentalApply(){
|
// var today = new Date();
|
// var year = today.getFullYear();
|
// var month = today.getMonth() + 1;
|
// var day = today.getDate();
|
// var hours = today.getHours();
|
// var minutes = today.getMinutes();
|
// var seconds = today.getSeconds();
|
// let time=year + '%2F' + month + '%2F' + day;
|
// let url='/setup/ui/recordtypeselect.jsp?ent=01I10000000u0VA&retURL=%2F'+this.recordId+
|
// '&save_new_url=%2Fa1E%2Fe%3FretURL%3D%252F'+this.recordId+
|
// '%26Report_day__c%3D'+time+
|
// '%26Medical_staff__c%3D'+this.name+
|
// '%26Medical_staff__c_lkid%3D'+this.recordId+
|
// '%26Reporter__c%3D'+this.CreatedBy_Name__c+
|
// '%26Reporter__c_lkid%3D'+this.CreatedById;
|
// // let url='/setup/ui/recordtypeselect.jsp?ent=On_Line_Survey';
|
// this[NavigationMixin.Navigate]({
|
// type: 'standard__webPage',
|
// attributes: {
|
// url:url
|
// }
|
// });
|
// // let url = '/setup/ui/recordtypeselect.jsp';
|
// // let params = new URLSearchParams();
|
// // params.append('ent', '%2F'+this.recordId);
|
// // params.append('save_new_url', '%2Fa1E%2Fe%3FretURL%3D%252F'+this.recordId+
|
// // '%26Report_day__c%3D'+time+
|
// // '%26Medical_staff__c%3D'+this.name+
|
// // '%26Medical_staff__c_lkid%3D'+this.recordId+
|
// // '%26Reporter__c%3D'+this.CreatedBy_Name__c+
|
// // '%26Reporter__c_lkid%3D'+this.CreatedById);
|
// // console.log(url + '?' + params.toString());
|
// // url=url + '?' + params.toString()
|
// // this[NavigationMixin.Navigate]({
|
// // type: 'tandard__webPage',
|
// // attributes: {
|
// // url: url
|
// // }
|
// // });
|
// // window.open();
|
// this.dispatchEvent(new CloseActionScreenEvent());
|
// }
|
// }
|
|
import { api, wire,LightningElement, track } from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { updateRecord } from 'lightning/uiRecordApi';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import init from '@salesforce/apex/lexNewOnLineSurvey2Controller.init';
|
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
export default class LexNewOnLineSurvey2 extends NavigationMixin(LightningElement) {
|
@api recordId;
|
date;
|
practitioner1;
|
ownerId;
|
selectedRecordTypeId;
|
IsLoading = true;
|
@track recordTypeOptions;
|
@wire(getObjectInfo, { objectApiName: 'On_Line_Survey__c' })
|
objectInfo({ error, data }) {
|
if (data) {
|
this.recordTypeOptions = Object.values(data.recordTypeInfos).map((rt) => ({
|
label: rt.name,
|
value: rt.recordTypeId
|
}));
|
} else if (error) {
|
// 处理操作失败的错误
|
}
|
}
|
@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;
|
}
|
}
|
}
|
connectedCallback(){
|
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
init({
|
recordId: this.recordId
|
}).then(result=>{
|
console.log("res:"+result);
|
this.ownerId = result.CreatedById;
|
|
this.IsLoading = false;
|
});
|
}
|
handleRecordTypeChange(event) {
|
this.selectedRecordTypeId = event.target.value;
|
|
var today = new Date();
|
var year = today.getFullYear();
|
var month = today.getMonth() + 1;
|
var day = today.getDate();
|
var hours = today.getHours();
|
var minutes = today.getMinutes();
|
var seconds = today.getSeconds();
|
let time=year + '-' + month + '-' + day;
|
const defaultValues = encodeDefaultFieldValues({
|
// OPD_number__c: this.recordId,
|
Report_day__c: time,
|
Medical_staff__c: this.recordId,
|
Reporter__c: this.ownerId
|
});
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'On_Line_Survey__c',
|
actionName: 'new'
|
},
|
state: {
|
nooverride: '1',
|
defaultFieldValues: defaultValues,
|
recordTypeId: this.selectedRecordTypeId
|
}
|
});
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
|
}
|