| | |
| | | import { LightningElement,api, track, wire } from 'lwc'; |
| | | // {!RequireScript("/resource/CommonUtilJs")} |
| | | import {CurrentPageReference} from 'lightning/navigation'; |
| | | import { CloseActionScreenEvent } from 'lightning/actions'; |
| | | import LightningConfirm from 'lightning/confirm'; |
| | | import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | import LightningConfirm from 'lightning/confirm'; |
| | | import init from '@salesforce/apex/LexStockCancelController.init'; |
| | | import updateOppotunity from '@salesforce/apex/LexStockCancelController.updateOppotunity'; |
| | | import submitApprovalRequest from '@salesforce/apex/LexStockCancelController.submitApprovalRequest'; |
| | | import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; |
| | | import {loadStyle} from 'lightning/platformResourceLoader'; |
| | | export default class lexStockCancel extends LightningElement { |
| | | |
| | | @api recordId; |
| | | IsLoading=true |
| | | IsLoading=true; |
| | | data; |
| | | @wire(CurrentPageReference) |
| | | getStateParameters(currentPageReference){ |
| | | console.log("进入页面"); |
| | |
| | | } |
| | | |
| | | |
| | | async connectedCallback(){ |
| | | |
| | | connectedCallback(){ |
| | | |
| | | Promise.all([ |
| | | loadStyle(this, lwcCSS) |
| | | ]); |
| | | console.log(this.recordId); |
| | | await init({recordId:this.recordId}).then(result=>{ |
| | | init({recordId:this.recordId}).then(result=>{ |
| | | console.log(result); |
| | | if(result!=null){ |
| | | |
| | | this.sumit().then(res=>{ |
| | | console.log("关闭窗口"); |
| | | this.data=result; |
| | | this.cancelSubmit().then(res=>{ |
| | | this.IsLoading=false; |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | }).catch(err=>{ |
| | | console.log("error:"); |
| | | console.log(err.message); |
| | | const event = new ShowToastEvent({ |
| | | title: '提示信息', |
| | | message:"操作失败,提示信息:"+err.message, |
| | | }); |
| | | this.dispatchEvent(event); |
| | | //alert("操作失败,提示信息:"+err.message); |
| | | }); |
| | | console.log("end"); |
| | | }); |
| | | } |
| | | }).catch(err=>{ |
| | | console.log("error:"); |
| | | console.log(err.message); |
| | | console.log("报错结束"); |
| | | }).finally(()=>{ |
| | | console.log("finally"); |
| | | |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | async cancelSubmit(){ |
| | | let reason = this.data.Stock_cancel_reason__c; |
| | | if (reason == null || reason == '') { |
| | | const event = new ShowToastEvent({ |
| | | title: '', |
| | | message:'必须填写撤销备货理由。', |
| | | variant: 'warning', |
| | | mode: 'sticky' |
| | | }); |
| | | this.dispatchEvent(event); |
| | | return; |
| | | } |
| | | |
| | | // CHAN-BCS8T5 LHJ 20190604 Start |
| | | let stage = this.data.Whether_Upload_Question_Document__c; |
| | | if (stage == '0') { |
| | | const event = new ShowToastEvent({ |
| | | title: "", |
| | | message:'请上传质疑函。', |
| | | variant: 'warning', |
| | | mode: 'sticky' |
| | | }); |
| | | this.dispatchEvent(event); |
| | | return; |
| | | } |
| | | // CHAN-BCS8T5 LHJ 20190604 End |
| | | const resul = await LightningConfirm.open({ |
| | | message: "一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?", |
| | | variant: '', |
| | | label: '', |
| | | // setting theme would have no effect |
| | | }); |
| | | if (resul==false) { |
| | | return; |
| | | } |
| | | let flag=true; |
| | | await updateOppotunity({recordId:this.recordId,stStatus:"撤销填写完毕"}).then(res=>{ |
| | | console.log(res); |
| | | if(res!=null&&res.success==false){ |
| | | let messages =""; |
| | | flag=false; |
| | | messages=res.errors[0]; |
| | | const event = new ShowToastEvent({ |
| | | title: '', |
| | | message:""+messages, |
| | | variant: 'error', |
| | | mode: 'sticky' |
| | | }); |
| | | this.dispatchEvent(event); |
| | | return; |
| | | } |
| | | }) |
| | | if(flag==false)return; |
| | | |
| | | // let rac = new sforce.SObject("Opportunity"); |
| | | // rac.Id = "{!Opportunity.Id}"; |
| | | // rac.Stock_apply_status__c = "撤销填写完毕"; |
| | | // let result = sforce.connection.update([rac]); |
| | | // let messages = getConnectDMLErrorMessages(result); |
| | | // if (messages.length > 0) { |
| | | // alert(messages.join("\n")); |
| | | // return; |
| | | // } |
| | | let ress; |
| | | await submitApprovalRequest({recordId:this.recordId}).then(res=>{ |
| | | console.log(res); |
| | | ress=res; |
| | | }) |
| | | console.log("777"); |
| | | if (ress != null) { |
| | | // let back = new window.sforce.SObject("Opportunity"); |
| | | // back.Id = "{!Opportunity.Id}"; |
| | | // back.Stock_apply_status__c = "批准"; |
| | | // let backResult = sforce.connection.update([back]); |
| | | // backMessages = getConnectDMLErrorMessages(backResult); |
| | | // if (backMessages.length > 0) { |
| | | // showTost("提示信息",backMessages.join("\n")); |
| | | // return; |
| | | // } |
| | | |
| | | // let errmsg = processResults[0].errors.message.toString(); |
| | | // showTost("提示信息",errmsg); |
| | | |
| | | await updateOppotunity({recordId:this.recordId,stStatus: "批准"}).then(res=>{ |
| | | console.log(res); |
| | | if(res!=null&&res.success==false){ |
| | | let messages =""; |
| | | flag=false; |
| | | messages=res.errors[0]; |
| | | const event = new ShowToastEvent({ |
| | | title: '', |
| | | message:""+messages, |
| | | variant: 'warning', |
| | | mode: 'sticky' |
| | | }); |
| | | this.dispatchEvent(event); |
| | | return; |
| | | } |
| | | }); |
| | | if(flag==false)return; |
| | | const event = new ShowToastEvent({ |
| | | title: '', |
| | | message:ress, |
| | | mode: 'sticky' |
| | | }); |
| | | this.dispatchEvent(event); |
| | | } |
| | | // window.location.reload(); |
| | | }; |
| | | |
| | | |
| | | showTost(title,message){ |
| | | |
| | | } |
| | | |
| | | |
| | | async sumit(){ |
| | | |
| | | // var reason = '{!Opportunity.Stock_cancel_reason__c}'; |
| | | // if (reason == null || reason == '') { |
| | | // alert('必须填写撤销备货理由。'); |
| | | // return |
| | | // } |
| | | |
| | | // // CHAN-BCS8T5 LHJ 20190604 Start |
| | | // var stage = '{!Opportunity.Whether_Upload_Question_Document__c}'; |
| | | // if (stage == '0') { |
| | | // alert('请上传质疑函。'); |
| | | // return; |
| | | // } |
| | | // // CHAN-BCS8T5 LHJ 20190604 End |
| | | |
| | | // if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) { |
| | | // return; |
| | | // } |
| | | |
| | | // var rac = new sforce.SObject("Opportunity"); |
| | | // rac.Id = "{!Opportunity.Id}"; |
| | | // rac.Stock_apply_status__c = "撤销填写完毕"; |
| | | // var result = sforce.connection.update([rac]); |
| | | // var messages = getConnectDMLErrorMessages(result); |
| | | // if (messages.length > 0) { |
| | | // alert(messages.join("\n")); |
| | | // return; |
| | | // } |
| | | |
| | | // var request = new sforce.ProcessSubmitRequest(); |
| | | // request.objectId = "{!Opportunity.Id}"; |
| | | // var processResults = sforce.connection.process([request]); |
| | | // if (processResults[0].errors != null) { |
| | | // var back = new sforce.SObject("Opportunity"); |
| | | // back.Id = "{!Opportunity.Id}"; |
| | | // back.Stock_apply_status__c = "批准"; |
| | | // var backResult = sforce.connection.update([back]); |
| | | // backMessages = getConnectDMLErrorMessages(backResult); |
| | | // if (backMessages.length > 0) { |
| | | // alert(backMessages.join("\n")); |
| | | // return; |
| | | // } |
| | | |
| | | // var errmsg = processResults[0].errors.message.toString(); |
| | | // alert(errmsg); |
| | | // return; |
| | | // } |
| | | // window.location.reload(); |
| | | // }; |
| | | } |
| | | |
| | | } |