import { LightningElement, track, wire,api } from 'lwc';
|
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import LightningConfirm from 'lightning/confirm';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
|
|
|
|
import applyPermission from '@salesforce/apex/TransferApplyController.applyPermission';
|
import submitApply from '@salesforce/apex/TransferApplyWebService.submitApply';
|
|
export default class lexSubmitApprovalProcess extends LightningElement {
|
@api recordId;
|
transferApplyPermission;
|
IsLoading=true;
|
cancelResult;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
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)
|
]);
|
console.log('this.transferApplyId:' + this.recordId);
|
applyPermission().then(result => {
|
console.log(result);
|
this.transferApplyPermission = result;
|
if (this.transferApplyPermission == false) {
|
this.showToast('没有提交申请的权限','warning');
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
} else{
|
LightningConfirm.open({
|
message: '一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?',
|
variant: 'headerless',
|
|
}).then(cancel=>{
|
if(cancel) {
|
submitApply({taId:this.recordId}).then(submitRes=>{
|
console.log(submitRes);
|
this.cancelResult = submitRes;
|
this.cancelSubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
|
}).catch( error =>{
|
this.showToast(error,"error");
|
});
|
// this.IsLoading=false;
|
// this.dispatchEvent(new CloseActionScreenEvent());
|
} else{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
|
|
});
|
|
}
|
|
|
}).catch( error =>{
|
console.log(error);
|
});
|
}
|
|
|
async cancelSubmit(){
|
console.log(this.cancelResult);
|
if(this.cancelResult == '1') {
|
console.log(this.cancelResult);
|
this.dispatchEvent(
|
new ShowToastEvent({
|
message:'提交成功',
|
variant: "success"
|
})
|
);
|
setTimeout(function(){
|
window.location.href = window.location;
|
}, 1500 )
|
} else {
|
this.dispatchEvent(
|
new ShowToastEvent({
|
message:this.cancelResult,
|
variant: "warning",
|
mode: 'sticky'
|
})
|
);
|
console.log("result:",this.cancelResult);
|
// await this.showToast("",this.cancelResult,"warning");
|
}
|
|
}
|
|
// showToast(_title,_message,_variant) {
|
// const event = new ShowToastEvent({
|
// title: _title,
|
// message:_message,
|
// variant: _variant,
|
// });
|
// this.dispatchEvent(event);
|
// }
|
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
// title: _title,
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}else{
|
const event = new ShowToastEvent({
|
// title: _title,
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}
|
}
|
}
|
|
//old js
|
/*
|
{!REQUIRESCRIPT('/soap/ajax/51.0/connection.js')}
|
{!REQUIRESCRIPT('/soap/ajax/51.0/apex.js')}
|
var result = sforce.connection.describeSObject('TransferApply__c');
|
if (result.createable == 'false') {
|
alert('没有提交申请的权限');
|
}
|
else{
|
if (confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) {
|
var rs = sforce.apex.execute("TransferApplyWebService","submitApply",{taId:'{!TransferApply__c.Id}'});
|
if(rs == '1'){
|
alert('提交成功');
|
window.location.href = window.location;
|
}
|
else{
|
alert(rs);
|
}
|
}
|
}
|
*/
|