| | |
| | | import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; |
| | | import { updateRecord } from 'lightning/uiRecordApi'; |
| | | |
| | | import LightningConfirm from 'lightning/confirm'; |
| | | import init from '@salesforce/apex/AddSubmitApprovalProcessController.init'; |
| | | import submitApproval from '@salesforce/apex/AddSubmitApprovalProcessController.submitApproval'; |
| | | import setSObjectShare from '@salesforce/apex/ControllerUtil.setSObjectShare'; |
| | | import changeAddApprovalStatus from '@salesforce/apex/AddSubmitApprovalProcessController.changeAddApprovalStatus'; |
| | | |
| | | export default class lexAddSubmitApprovalProcess extends LightningElement { |
| | | @api recordId; |
| | |
| | | this.ToastShow('没有需要审批的追加附属品','warning'); |
| | | return; |
| | | } |
| | | if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) { |
| | | // if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) { |
| | | // this.dispatchEvent(new CloseActionScreenEvent()); |
| | | // return; |
| | | // } |
| | | const SUBMIT = LightningConfirm.open({ |
| | | message: "一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?", |
| | | variant: 'headerless', |
| | | label: '提示信息', |
| | | // setting theme would have no effect |
| | | }); |
| | | |
| | | if(SUBMIT==false){ |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | } |
| | | |
| | | // 希望到货日不能早于申请提交日-0418追加 |
| | | //if ('{!Rental_Apply__c.Request_shipping_day__c}' < '{!TODAY()}') { |
| | | // alert('希望到货日不能早于申请提交日'); |
| | |
| | | //userAccess.push('{!Rental_Apply__c.ZongjianApprovalManagerId__c}_Read');//20210727 ljh SFDC-C54C33 update 共享触发器完成 |
| | | //userAccess.push('{!Rental_Apply__c.Status__c}_Read'); |
| | | |
| | | console.log('参数==='+result.rentalApplyId+' '+userAccess+' '+result.ownerId); |
| | | setSObjectShare({ |
| | | sobjectName:'Rental_Apply__Share', |
| | | rowCause:'ApplyUserShare__c', |
| | |
| | | userAccess:userAccess, |
| | | ownerId:result.ownerId |
| | | }).then(res=>{ |
| | | console.log('setSObjectShareSuccess===='+res); |
| | | |
| | | if(res!='OK'){ |
| | | this.ToastShow(res,'warning'); |
| | | return; |
| | | }else{ |
| | | console.log('setSObjectShareSuccess====OK'); |
| | | //追加备品申请状态确认,已经提交过的申请,不能重复提交Status__c |
| | | if (result.rentalApplyStatus != '已批准' && result.rentalApplyStatus != '已出库指示') { |
| | | this.ToastShow('请备品申请状态确认,申请状态已批准后才可以提交追加审批','warning'); |
| | | return; |
| | | } |
| | | |
| | | changeAddApprovalStatus({ |
| | | recordId: this.recordId, |
| | | status: '填写完毕' |
| | | }).then(changeResult=>{ |
| | | if(changeResult == '更新成功'){ |
| | | submitApproval({ |
| | | recordId: this.recordId |
| | | }).then(submitApprovalRes=>{ |
| | | if(submitApprovalRes == 'OK'){ |
| | | this.ToastShow('提交追加待审批','success'); |
| | | this.updateRecordView(this.recordId); |
| | | }else{ |
| | | this.ToastShow('追加待审批失败','ERROR'); |
| | | } |
| | | }) |
| | | }else{ |
| | | this.ToastShow(changeResult,'error'); |
| | | } |
| | | }) |
| | | } |
| | | }).catch(err=>{ |
| | | console.log('setSObjectShareErr===='+err); |
| | | }) |
| | | |
| | | // var request = new sforce.ProcessSubmitRequest(); |
| | | // request.objectId = "{!Rental_Apply__c.Id}"; |
| | | // var processResults = sforce.connection.process([request]); |
| | | |
| | | |
| | | // if (processResults[0].errors != null) { |
| | | // var back = new sforce.SObject("Rental_Apply__c"); |
| | | // back.Id = "{!Rental_Apply__c.Id}"; |
| | | // back.Add_Approval_Status__c = "草案中"; |
| | | // var backResult = sforce.connection.update([back]); |
| | | // backMessages = this.getConnectDMLErrorMessages(backResult); |
| | | // if (backMessages.length > 0) { |
| | | // this.showToast(backMessages.join("\n"),'error'); |
| | | // return; |
| | | // } |
| | | |
| | | // var errmsg = processResults[0].errors.message.toString(); |
| | | // this.showToast(errmsg,'error'); |
| | | // return; |
| | | // } |
| | | |
| | | //updateRecord({fields: { Id: this.recordId }}); |
| | | |
| | | submitApproval({ |
| | | recordId: this.recordId |
| | | }).then(res=>{ |
| | | console.log('submitApproval===='+res); |
| | | if(res == 'OK'){ |
| | | this.ToastShow('提交成功','success'); |
| | | }else{ |
| | | this.ToastShow(res,'error'); |
| | | } |
| | | }) |
| | | updateRecord({fields: { Id: this.recordId }}); |
| | | |
| | | }).catch(err=>{ |
| | | console.log('sErr====',err.message); |
| | | console.log('====1111====',err); |
| | | }) |
| | | } |
| | | |
| | |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | } |
| | | |
| | | getConnectDMLErrorMessages(results){ |
| | | var messages = [], |
| | | i = 0, |
| | | len = results.length, |
| | | r; |
| | | for (; i < len; i++) { |
| | | r = results[i]; |
| | | if (!r.getBoolean("success")) { |
| | | messages = messages.concat(this.getConnectDMLMessagesOfAResult(r)); |
| | | } |
| | | } |
| | | return messages; |
| | | } |
| | | |
| | | getConnectDMLMessagesOfAResult(res){ |
| | | var messages = [], |
| | | errors = res.getArray("errors"), |
| | | i = 0, |
| | | len = errors.length, |
| | | e; |
| | | for (; i < len; i++) { |
| | | e = errors[i]; |
| | | messages.push(e.message + " " + this.getConnectDMLErrorFields(e)); |
| | | } |
| | | return messages; |
| | | } |
| | | |
| | | getConnectDMLErrorFields(error){ |
| | | var fields = error.getArray('fields'); |
| | | if (fields.length > 0) { |
| | | return "[" + fields.join(",") + "]" |
| | | } else { |
| | | return ""; |
| | | } |
| | | updateRecordView(recordId) { |
| | | updateRecord({fields: { Id: recordId }}); |
| | | } |
| | | } |