import { LightningElement, api, track, wire } from "lwc";
|
import getApprovalHistory from "@salesforce/apex/ApprovalHistoryController.getApprovalHistory";
|
import submitForApprovalApex from "@salesforce/apex/ApprovalHistoryController.submitForApproval";
|
import reassignStep from "@salesforce/apex/ApprovalHistoryController.reassignStep";
|
import processStep from "@salesforce/apex/ApprovalHistoryController.processStep";
|
import searchUsers from "@salesforce/apex/ApprovalHistoryController.searchUsers";
|
// import saveRecord from "@salesforce/apex/ApprovalHistoryController.saveRecord";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import getInitData from "@salesforce/apex/ApprovalHistoryController.getInitData";
|
import { getRecord } from 'lightning/uiRecordApi';
|
import ProfileId_SystemAdmin from '@salesforce/label/c.ProfileId_SystemAdmin';
|
import ProfileId_2J3 from '@salesforce/label/c.ProfileId_2J3';
|
import USER_ID from '@salesforce/user/Id';
|
import {
|
verifyIfNextApproverWasNeeded,
|
hideModal,
|
showModal,
|
getCommentPropertyFromModal,
|
showGetNextApproverModal,
|
validateUserLookup,
|
setSelectedUser,
|
clearModalState,
|
displayToast,
|
extractErrorMessage,
|
modalStates,
|
displayToastErrorQuery
|
} from "./approvalHistoryUtil.js";
|
import { ShowToastEvent } from "lightning/platformShowToastEvent";
|
import { refreshApex } from "@salesforce/apex";
|
|
const ERROR = "error";
|
const SUCCESS = "success";
|
const FIELDS = ['ObjectName__c.Id', 'ObjectName__c.Name'];
|
const columns = [
|
{
|
label: "步骤名称",
|
fieldName: "stepName",
|
type: "text",
|
typeAttributes: {
|
label: {
|
fieldName: "stepName"
|
}
|
}
|
},
|
{
|
label: "日期",
|
fieldName: "createdDate",
|
type: "date",
|
typeAttributes: {
|
month: "numeric",
|
day: "numeric",
|
year: "numeric",
|
hour: "numeric",
|
minute: "numeric"
|
}
|
},
|
{ label: "状态", fieldName: "stepStatus" },
|
{
|
label: "被分配人",
|
fieldName: "OriginalToUrl",
|
type: "url",
|
typeAttributes: {
|
label: {
|
fieldName: "OriginalTo"
|
}
|
}
|
},
|
{
|
label: "实际批准人",
|
fieldName: "assignedToUrl",
|
type: "url",
|
typeAttributes: {
|
label: {
|
fieldName: "assignedTo"
|
}
|
}
|
},
|
{ label: "评论", fieldName: "comments" },
|
];
|
export default class ApprovalHistory extends LightningElement {
|
@api recordId;
|
@track isLoading=false;
|
@api objectApiName;
|
@api showComments; //Determines if the component will show the comments column
|
@api allowSubmitForApproval; //determines if the component will allow Submit for Approval functionality
|
@track approvalHistory; //approval history to display on page
|
@track isShow;//是否展示需要填写的表单
|
wiredApprovalHistory; //property used to refreshApex
|
|
//modal properties
|
currentModalState; //decides which type of modal to display depending on the action happening(approve, reject, recall, etc)
|
modalComment; //temporarily stores the value of the comment input field in the modal
|
selectedUser; //temporarily stores the selected user from the lookup component in the modal
|
//end modal properties
|
|
//lookup properties
|
lookupErrors = []; //errors related to the lookup component
|
isMultiEntry = false;
|
initialSelection = [];
|
@track obj = {};
|
fieldChange(event){
|
const { value } = event.detail;
|
const { fieldName } = event.target || event.currentTarget;
|
let checked = event.target.value||event.currentTarget.value;
|
if (value == undefined && checked != undefined) {
|
this.obj = {
|
...this.obj,
|
[fieldName]: checked
|
};
|
} else {
|
let theValue = value instanceof Array ? value[0] : value;
|
if(theValue===undefined){
|
theValue = '';
|
}
|
this.obj = {
|
...this.obj,
|
[fieldName]: theValue
|
};
|
}
|
if(this.objectApiName==='Account'&&fieldName=='RejectionReason__c'){
|
if(this.obj.RejectionReason__c==='重复'){
|
this.AssociatedHospitalDis = false;
|
}else{
|
this.AssociatedHospitalDis = true;
|
}
|
if (this.isdealers) {
|
this.RejectionReasonDis = true;
|
this.AssociatedHospitalDis = true;
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = true;
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.WhetherRiskPassingDis = true;
|
}
|
}
|
if(this.objectApiName==='Account'&&fieldName=='InstitutionalType__c'){
|
if(this.obj.InstitutionalType__c==='非医疗机构'){
|
this.HospitalTypeDis = false;
|
}else{
|
this.HospitalTypeDis = true;
|
}
|
if (this.isdealers) {
|
this.RejectionReasonDis = true;
|
this.AssociatedHospitalDis = true;
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = true;
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.WhetherRiskPassingDis = true;
|
}
|
}
|
if(this.objectApiName==='Account_Delay_Apply__c'&&fieldName=='InstitutionalType__c'){
|
if(this.obj.InstitutionalType__c==='非医疗机构'){
|
this.HospitalTypeDis = false;
|
}else{
|
this.HospitalTypeDis = true;
|
}
|
if (this.isdealers) {
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.WhetherRiskPassingDis = true;
|
}
|
}
|
}
|
//end lookup properties
|
get columns() {
|
let tempColumns = columns;
|
if(this.showComments){
|
tempColumns.push({
|
label: "Comments", fieldName: "comments"
|
});
|
}
|
|
return tempColumns;
|
}
|
//url that will display all of the approval process history
|
get viewAllUrl() {
|
return "/lightning/r/" + this.recordId + "/related/ProcessSteps/view";
|
}
|
@track isAcc;
|
@track isAccApply;
|
@track isSolution=false;
|
@track isadmin=false;
|
@track isdealers;
|
@track RejectionReasonDis = true;
|
@track AssociatedHospitalDis = true;
|
@track inputFieldStyle = 'display: block;';
|
@track inputFieldStyleTwo = 'display: block;';
|
@track inputFieldStyleThree = 'display: block;';
|
@track inputFieldStyleFour = 'display: block;';
|
@track InstitutionalTypeDis = true;
|
@track HospitalTypeDis = true;
|
@track WhetherRiskPassingDis = true;
|
nodeName;
|
connectedCallback(){
|
console.log('connectedCallback');
|
console.log(this.objectApiName);
|
console.log(this.recordId);
|
if(this.objectApiName==='Account'){
|
//客户
|
this.isAcc = true;
|
this.isAccApply = false;
|
this.isSolution = false;
|
}else if(this.objectApiName==='Account_Delay_Apply__c'){
|
//客户变更申请
|
this.isAcc = false;
|
this.isAccApply = true;
|
this.isSolution = false;
|
}else{
|
//Solution方案 this.objectApiName==='Solution_Programme__c'
|
this.isAcc = false;
|
this.isAccApply = false;
|
this.isSolution = true;
|
}
|
if(this.objectApiName==='Account'||this.objectApiName==='Account_Delay_Apply__c'||this.objectApiName==='Solution_Programme__c'){
|
getInitData({ recordId: this.recordId,objectApiName:this.objectApiName})
|
.then(result => {
|
this.obj = JSON.parse(result.objJson);
|
// if(this.objectApiName==='Account'){
|
console.log('handleUserInfo');
|
var userProfileId = result.currentUserProfileId;
|
this.nodeName = result.nodeName;
|
console.log(this.nodeName + '<===this.nodeName');
|
console.log('userProfileId = ' + userProfileId);
|
console.log('ProfileId_SystemAdmin = ' + ProfileId_SystemAdmin);
|
console.log('ProfileId_2J3 = ' + ProfileId_2J3);
|
if(userProfileId===ProfileId_SystemAdmin){
|
this.isadmin = true;
|
}else{
|
this.isadmin = false;
|
}
|
if(userProfileId===ProfileId_2J3){
|
this.isdealers = true;
|
}else{
|
this.isdealers = false;
|
}
|
console.log(this.isadmin);
|
console.log(this.isdealers);
|
if(!this.isadmin && !this.isdealers) {
|
console.log('双非锁定');
|
this.RejectionReasonDis = true;
|
this.AssociatedHospitalDis = true;
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = true;
|
this.WhetherRiskPassingDis = true;
|
}else if(this.isadmin && !this.isdealers){
|
console.log('测试执行');
|
this.RejectionReasonDis = false;
|
this.AssociatedHospitalDis = true;
|
this.InstitutionalTypeDis = true;
|
if (this.objectApiName==='Account_Delay_Apply__c') {
|
this.InstitutionalTypeDis = false;
|
this.HospitalTypeDis = true;
|
this.WhetherRiskPassingDis = true;
|
}else{
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = false;
|
this.WhetherRiskPassingDis = true;
|
}
|
}else if (this.isdealers) {
|
this.RejectionReasonDis = false;
|
this.AssociatedHospitalDis = true;
|
|
if (this.objectApiName==='Account_Delay_Apply__c') {
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = true;
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = false;
|
this.WhetherRiskPassingDis = false;
|
}
|
|
}
|
// }
|
}).catch(error => {
|
console.error('Error loading report: ', error);
|
});
|
}
|
}
|
//decides if it will show the menu that may two buttons, the recall and the reassign
|
get showButtonMenu() {
|
return (
|
this.approvalHistory.isCurrentUserApprover ||
|
this.approvalHistory.showRecall
|
);
|
}
|
|
//decides if it will show the submit for approval button
|
get showSubmitForApprovalButton() {
|
return this.approvalHistory &&
|
this.approvalHistory.showSubmitForApproval &&
|
this.allowSubmitForApproval
|
? true
|
: false;
|
}
|
|
//will return a different modal title depending on the state
|
get modalTitle() {
|
if (this.currentModalState && modalStates[this.currentModalState])
|
return modalStates[this.currentModalState].title;
|
return "";
|
}
|
// will return a different label for the submit button, depending on the current state.(Approve, Reject, Submit, etc)
|
get modalsubmitLabel() {
|
if (this.currentModalState && modalStates[this.currentModalState])
|
return modalStates[this.currentModalState].submitLabel;
|
return "";
|
}
|
|
// decides if the comment input field will show in the modal, based on the current state
|
get showCommentModal() {
|
return (
|
this.currentModalState === modalStates.SUBMIT_APPROVAL.state ||
|
this.currentModalState === modalStates.APPROVE.state ||
|
this.currentModalState === modalStates.REJECT.state ||
|
this.currentModalState === modalStates.RECALL.state
|
);
|
}
|
|
// decides if the lookup component will show in the modal, based on the current state
|
get showLookupModal() {
|
return (
|
this.currentModalState === modalStates.GET_NEXT_APPROVER_SUBMIT.state ||
|
this.currentModalState === modalStates.REASSIGN.state ||
|
this.currentModalState === modalStates.GET_NEXT_APPROVER_APPROVE.state
|
);
|
}
|
|
// decides the label for the lookup component, based on the current state
|
get lookupLabel() {
|
return modalStates[this.currentModalState].lookupLabel;
|
}
|
|
get showDataTable() {
|
return this.approvalHistory && this.approvalHistory.approvalSteps.length > 0
|
? true
|
: false;
|
}
|
|
@wire(getApprovalHistory, { recordId: "$recordId" })
|
wiredGetApprovalHist(value) {
|
this.wiredApprovalHistory = value;
|
if (value.data) {
|
this.approvalHistory = value.data;
|
console.log('wiredGetApprovalHist');
|
console.log(JSON.stringify(this.approvalHistory));
|
} else if (value.error) {
|
displayToastErrorQuery(this, ShowToastEvent);
|
}
|
}
|
|
refreshApprovalHistory() {
|
console.log('refreshApprovalHistory');
|
refreshApex(this.wiredApprovalHistory);
|
console.log('/lightning/r/'+this.objectApiName+'/'+this.recordId+'/view');
|
window.location.href = '/lightning/r/'+this.objectApiName+'/'+this.recordId+'/view';
|
}
|
|
@api
|
submitForApproval(){
|
this.handleSubmitForApprovalClick();
|
}
|
//button click handlers
|
//the handlers show the modal and change the currentModalState depending on the button clicked
|
|
handleSubmitForApprovalClick() {
|
console.log('handleSubmitForApprovalClick');
|
showModal(this);
|
this.currentModalState = modalStates.SUBMIT_APPROVAL.state;
|
}
|
|
handleReassignClick() {
|
showModal(this);
|
this.isShow = false;
|
this.currentModalState = modalStates.REASSIGN.state;
|
}
|
|
handleRecallClick() {
|
showModal(this);
|
this.isShow = false;
|
this.currentModalState = modalStates.RECALL.state;
|
}
|
handleApproveClick1() {
|
this.isLoading=true;
|
}
|
handleApproveClick() {
|
this.inputFieldStyle ='display: none;';
|
this.inputFieldStyleTwo = 'display: block;';
|
// this.inputFieldStyleThree = 'display: none;';
|
// this.inputFieldStyleFour = 'display: block;';
|
if(this.objectApiName==='Account'){
|
var InsType = this.obj.InstitutionalType__c;
|
if (this.nodeName.indexOf('医院新建审批_事业推进部')!=-1) {
|
this.RejectionReasonDis = false;
|
this.InstitutionalTypeDis = false;
|
console.log('InsType='+InsType);
|
if(InsType=== '非医疗机构'){
|
this.HospitalTypeDis = false;
|
}else{
|
this.HospitalTypeDis = true;
|
}
|
}
|
if (this.isdealers) {
|
this.RejectionReasonDis = true;
|
this.AssociatedHospitalDis = true;
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = true;
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.WhetherRiskPassingDis = true;
|
}
|
|
}
|
if(this.objectApiName==='Account_Delay_Apply__c'){
|
var InsType = this.obj.InstitutionalType__c;
|
console.log('InsType='+InsType);
|
if (this.nodeName.indexOf('医院变更审批_事业推进部')!=-1) {
|
if(InsType== '非医疗机构'){
|
this.HospitalTypeDis = false;
|
}else{
|
this.HospitalTypeDis = true;
|
}
|
if (this.isdealers) {
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.WhetherRiskPassingDis = true;
|
}
|
}
|
}
|
|
showModal(this);
|
this.isShow = true;
|
this.currentModalState = modalStates.APPROVE.state;
|
|
}
|
|
handleRejectClick() {
|
this.inputFieldStyle = 'display: block;';
|
this.inputFieldStyleTwo = 'display: none;';
|
// this.inputFieldStyleThree = 'display: block;';
|
// this.inputFieldStyleFour = 'display: none;';
|
if(this.objectApiName==='Account'){
|
|
if (this.nodeName.indexOf('医院新建审批_事业推进部')!=-1) {
|
this.InstitutionalTypeDis = false;
|
var InsType = this.InstitutionalTypeDis;
|
if(InsType=== '非医疗机构'){
|
this.HospitalTypeDis = false;
|
}else{
|
this.HospitalTypeDis = true;
|
}
|
if (this.isdealers) {
|
this.RejectionReasonDis = true;
|
this.AssociatedHospitalDis = true;
|
this.InstitutionalTypeDis = true;
|
this.HospitalTypeDis = true;
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.WhetherRiskPassingDis = true;
|
}
|
}
|
}
|
|
if(this.objectApiName==='Account_Delay_Apply__c'){
|
if (this.nodeName.indexOf('医院变更审批_事业推进部')!=-1) {
|
var InsType = this.obj.InstitutionalType__c;
|
if(InsType=== '非医疗机构'){
|
this.HospitalTypeDis = false;
|
}else{
|
this.HospitalTypeDis = true;
|
}
|
if (this.isdealers) {
|
this.WhetherRiskPassingDis = false;
|
}else{
|
this.WhetherRiskPassingDis = true;
|
}
|
}
|
}
|
showModal(this);
|
this.isShow = true;
|
this.currentModalState = modalStates.REJECT.state;
|
}
|
//end button click handlers
|
|
//this function submits for approval, if a next approver is needed,
|
//it will show the next approver modal which will trigger the submition again.
|
submitForApprovalApexCall() {
|
hideModal(this);
|
this.isLoading=true;
|
submitForApprovalApex({
|
recordId: this.recordId,
|
comments: this.modalComment,
|
nextApproverId: this.selectedUser
|
})
|
.then(result => {
|
|
let jsonResult = JSON.parse(result);
|
if (jsonResult.success) {
|
displayToast(this, ShowToastEvent, SUCCESS);
|
this.refreshApprovalHistory();
|
} else {
|
displayToast(this, ShowToastEvent, ERROR);
|
}
|
clearModalState(this);
|
})
|
.catch(error => {
|
if (verifyIfNextApproverWasNeeded(error.body.pageErrors)) {
|
showGetNextApproverModal(this, modalStates.GET_NEXT_APPROVER_SUBMIT.state);
|
} else {
|
let errorMessage = extractErrorMessage(error.body.pageErrors);
|
displayToast(this, ShowToastEvent, ERROR, errorMessage);
|
clearModalState(this);
|
}
|
});
|
}
|
|
//function that takes care of reassigning the pending step to the selected user.
|
reassignApexCall() {
|
hideModal(this);
|
reassignStep({ recordId: this.recordId, newActorId: this.selectedUser })
|
.then(() => {
|
displayToast(this, ShowToastEvent, SUCCESS);
|
clearModalState(this);
|
this.refreshApprovalHistory();
|
})
|
.catch(() => {
|
displayToast(this, ShowToastEvent, ERROR);
|
clearModalState(this);
|
});
|
}
|
|
//function that takes care of approve, reject, and recall. If next approver is needed
|
//it will show the next approver modal which will trigger the submition again.
|
processStepApexCall(action) {
|
console.log('processStepApexCall');
|
hideModal(this);
|
this.isLoading=true;
|
processStep({
|
recordId: this.recordId,
|
comments: this.modalComment,
|
nextApproverId: this.selectedUser,
|
action: action,
|
objApiName:this.objectApiName,
|
modalsubmitLabel:this.modalsubmitLabel,
|
objJson:JSON.stringify(this.obj)
|
})
|
.then(result => {
|
console.log('then');
|
console.log(result);
|
let jsonResult = JSON.parse(result);
|
console.log(jsonResult);
|
console.log(jsonResult.success);
|
if (jsonResult.success) {
|
// displayToast(this, ShowToastEvent, SUCCESS);
|
this.isLoading=false;
|
if (this.modalsubmitLabel=='批准') {
|
this.showToast('success','批准完成');
|
}else{
|
this.showToast('success','驳回完成');
|
}
|
|
setTimeout(() => {
|
this.refreshApprovalHistory();
|
}, 3000);
|
|
} else {
|
if(jsonResult.returnMes){
|
this.showToast('error',jsonResult.returnMes);
|
// window.location.href = '/lightning/r/'+this.objectApiName+'/'+this.recordId+'/view';
|
setTimeout(() => {
|
window.location.href = '/lightning/r/' + this.objectApiName + '/' + this.recordId + '/view';
|
}, 3000);
|
}else{
|
displayToast(this, ShowToastEvent, ERROR);
|
// window.location.href = '/lightning/r/'+this.objectApiName+'/'+this.recordId+'/view';
|
setTimeout(() => {
|
window.location.href = '/lightning/r/' + this.objectApiName + '/' + this.recordId + '/view';
|
}, 3000);
|
}
|
}
|
clearModalState(this);
|
})
|
.catch(error => {
|
console.log('error');
|
if (verifyIfNextApproverWasNeeded(error.body.pageErrors)) {
|
showGetNextApproverModal(this, modalStates.GET_NEXT_APPROVER_APPROVE.state);
|
} else {
|
let errorMessage = extractErrorMessage(error.body.pageErrors);
|
displayToast(this, ShowToastEvent, ERROR, errorMessage);
|
clearModalState(this);
|
setTimeout(() => {
|
window.location.href = '/lightning/r/' + this.objectApiName + '/' + this.recordId + '/view';
|
}, 3000);
|
// window.location.href = '/lightning/r/'+this.objectApiName+'/'+this.recordId+'/view';
|
}
|
});
|
}
|
|
handleModalCancel() {
|
hideModal(this);
|
clearModalState(this);
|
}
|
|
//function that handles the modal Submit button.
|
//depending on the current state, it will call the appropriate imperative method
|
handleModalSubmit() {
|
|
if(this.isShow&&(this.isAcc||this.isAccApply||this.isSolution)){
|
//先提交其他字段的填写
|
var today = new Date();
|
console.log('------------');
|
console.log(this.objectApiName);
|
console.log(this.recordId);
|
console.log(this.isSolution);
|
console.log(this.modalsubmitLabel);
|
console.log(this.currentModalState);
|
console.log(JSON.stringify(this.obj));
|
// return;
|
// if(this.isAcc){
|
// if(this.modalsubmitLabel === '批准' || this.modalsubmitLabel === '拒绝'){
|
// //== '步骤:医院新建审批_营业支援部(等待处理的 首先 批准)'
|
// if(testlink.contains('医院新建审批_营业支援部') ){
|
// if(this.modalsubmitLabel === '批准'){
|
// if(!this.stringIsEmpty(this.obj.RejectionReason__c)){
|
// this.showToast('error', '您已填写驳回理由,批准不需要驳回理由。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.stringIsEmpty(this.obj.InstitutionalType__c)){
|
// this.showToast('error', '批准前,机构类型必填。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.obj.InstitutionalType__c === '非医疗机构' && this.stringIsEmpty(this.obj.HospitalType__c)){
|
// this.showToast('error', '非医疗机构请选择医院类型。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.obj.InstitutionalType__c === '医疗机构' && !this.stringIsEmpty(this.obj.HospitalType__c)){
|
// this.showToast('error', '医疗机构不需要选择医院类型。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.obj.InstitutionalType__c === '医疗机构'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '有効'
|
// };
|
// this.obj = {
|
// ...this.obj,
|
// ['Approved_Confirm_Date__c']: today
|
// };
|
// }
|
// }
|
// //拒绝
|
// if(this.modalsubmitLabel === '拒绝'){
|
// if(this.stringIsEmpty(this.obj.RejectionReason__c)){
|
// this.showToast('error', '拒绝前,请选择驳回理由。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.obj.RejectionReason__c === '重复' && this.stringIsEmpty(this.obj.AssociatedHospital__c)){
|
// this.showToast('error', '驳回理由是重复的,请填写关联医院。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.obj.RejectionReason__c !== '重复' && !this.stringIsEmpty(this.obj.AssociatedHospital__c)){
|
// this.showToast('error', '驳回理由不是重复的,不能填写关联医院。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(!this.stringIsEmpty(this.obj.RejectionReason__c) && (!this.stringIsEmpty(this.obj.InstitutionalType__c)||!this.stringIsEmpty(this.obj.HospitalType__c))){
|
// this.showToast('error', '审批拒绝,不允许填写机构类型或医院类型。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.obj.RejectionReason__c === '医院已关张' || this.obj.RejectionReason__c === '重复'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '驳回'
|
// };
|
// }else{
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '草案中'
|
// };
|
// }
|
// }
|
// }else if(testlink.contains('质量法规二级部长') ){
|
// if(this.modalsubmitLabel === '批准'){
|
// if(this.obj.InstitutionalType__c === '非医疗机构' && this.obj.HospitalType__c === '高等院校'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '有効'
|
// };
|
// this.obj = {
|
// ...this.obj,
|
// ['Approved_Confirm_Date__c']: today
|
// };
|
// }
|
// }
|
// if(this.modalsubmitLabel === '拒绝'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '驳回'
|
// };
|
// }
|
// }else if(testlink.contains('经销商管理部一级审批')){
|
// if(this.modalsubmitLabel === '批准'){
|
// if(this.stringIsEmpty(this.obj.WhetherRiskPassing__c)){
|
// this.showToast('error', '是否为有风险通过 必填。');
|
// hideModal(this);
|
// return;
|
// }
|
// if(this.obj.InstitutionalType__c === '非医疗机构' && this.obj.HospitalType__c === '企业集团' && this.obj.WhetherRiskPassing__c === '否'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '有効'
|
// };
|
// this.obj = {
|
// ...this.obj,
|
// ['Approved_Confirm_Date__c']: today
|
// };
|
// }
|
// }
|
// if(this.modalsubmitLabel == '拒绝'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '驳回'
|
// };
|
// }
|
|
// }else if(testlink.contains('总经理审批')){
|
// if(this.modalsubmitLabel === '批准'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '有効'
|
// };
|
// this.obj = {
|
// ...this.obj,
|
// ['Approved_Confirm_Date__c']: today
|
// };
|
// }
|
// if(this.modalsubmitLabel === '拒绝'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '驳回'
|
// };
|
// }
|
// }else{
|
// if(this.modalsubmitLabel === '拒绝'){
|
// this.obj = {
|
// ...this.obj,
|
// ['Is_Active__c']: '驳回'
|
// };
|
// }
|
// }
|
// }
|
// }
|
if(this.isSolution){
|
if(this.obj.Confirmation_Result__c){
|
}else{
|
this.showToast('error', '必须填写反馈结果!');
|
hideModal(this);
|
return;
|
}
|
}
|
// this.handleSubmit();
|
// saveRecord({objectApiName:this.objectApiName,objId:this.recordId,objJson:JSON.stringify(this.obj)})
|
// .then(result => {
|
this.handleSubmit();
|
// hideModal(this);
|
// return;
|
// })
|
// .catch(error => {
|
// hideModal(this);
|
// this.showToast('error', error);
|
// return;
|
// });
|
}else{
|
this.handleSubmit();
|
}
|
}
|
showToast(variant,mes) {
|
const event = new ShowToastEvent({
|
message: mes,
|
variant: variant,
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
handleSubmit(){
|
console.log('handleSubmit');
|
switch (this.currentModalState) {
|
case modalStates.SUBMIT_APPROVAL.state:
|
this.modalComment = getCommentPropertyFromModal(this);
|
this.submitForApprovalApexCall();
|
break;
|
case modalStates.GET_NEXT_APPROVER_SUBMIT.state:
|
if (validateUserLookup(this)) {
|
setSelectedUser(this);
|
this.submitForApprovalApexCall();
|
}
|
break;
|
case modalStates.REASSIGN.state:
|
if (validateUserLookup(this)) {
|
setSelectedUser(this);
|
this.reassignApexCall();
|
}
|
break;
|
case modalStates.APPROVE.state:
|
this.modalComment = getCommentPropertyFromModal(this);
|
this.processStepApexCall(modalStates.APPROVE.action);
|
break;
|
case modalStates.GET_NEXT_APPROVER_APPROVE.state:
|
if (validateUserLookup(this)) {
|
setSelectedUser(this);
|
this.processStepApexCall(modalStates.APPROVE.action);
|
}
|
break;
|
case modalStates.RECALL.state:
|
this.modalComment = getCommentPropertyFromModal(this);
|
this.processStepApexCall(modalStates.RECALL.action);
|
break;
|
case modalStates.REJECT.state:
|
console.log('1');
|
this.modalComment = getCommentPropertyFromModal(this);
|
console.log('2');
|
this.processStepApexCall(modalStates.REJECT.action);
|
console.log('3');
|
break;
|
default:
|
break;
|
}
|
}
|
//searches the users based on the lookup component search event.
|
handleLookupSearch(event) {
|
searchUsers(event.detail)
|
.then(results => {
|
this.template.querySelector("c-lookup").setSearchResults(results);
|
})
|
.catch(error => {
|
this.lookupErrors = [error];
|
});
|
}
|
|
handleSelectionChange() {
|
this.lookupErrors = [];
|
}
|
stringIsEmpty(str) {
|
if (str === '' || str === undefined || str === null) {
|
return true;
|
} else {
|
return false;
|
}
|
}
|
}
|