| New file |
| | |
| | | import { LightningElement, track, wire, api } from 'lwc'; |
| | | import { CurrentPageReference } from "lightning/navigation"; |
| | | import { CloseActionScreenEvent } from 'lightning/actions'; |
| | | import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | import { updateRecord } from 'lightning/uiRecordApi'; |
| | | |
| | | import init from '@salesforce/apex/lexRepairAgainAnController.init'; |
| | | import updateRepairAgainStatus from '@salesforce/apex/lexRepairAgainAnController.updateRepairAgainStatus'; |
| | | //发起再注册分析并同步SAP |
| | | export default class lexFSESubmit extends LightningElement { |
| | | @api recordId; |
| | | IsLoading = true; |
| | | |
| | | @wire(CurrentPageReference) |
| | | getStateParameters(currentPageReference) { |
| | | |
| | | if (currentPageReference) { |
| | | const urlValue = currentPageReference.state.recordId; |
| | | if (urlValue) { |
| | | let str = `${urlValue}`; |
| | | console.log("str"); |
| | | console.log(str); |
| | | this.recordId = str; |
| | | } |
| | | } |
| | | } |
| | | |
| | | connectedCallback () { |
| | | init({ |
| | | recordId: this.recordId |
| | | }).then(res=>{ |
| | | if(res){ |
| | | this.IsLoading = false; |
| | | |
| | | if(res.repairAgainStatus == '取消'){ |
| | | this.showToast('取消后的再修理返品分析不允许再提交,如果需要提交请点击\"复制\"按钮重新生成一个再修理返品分析','warning'); |
| | | return; |
| | | } |
| | | console.log('res==='+JSON.stringify(res)); |
| | | if(res.repairAgainStatus != '草案中' && res.repairAgainStatus != '取消'){ |
| | | this.showToast('已经提交','warning'); |
| | | return; |
| | | } |
| | | |
| | | console.log(res.rCConfirmer+""===+res.repairLast); |
| | | if(res.rCConfirmer == '' || res.repairLast == null){ |
| | | this.showToast('【RC确认者】或【上次修理】为空时不能提交申请','warning'); |
| | | return; |
| | | } |
| | | |
| | | updateRepairAgainStatus({ |
| | | recordId: this.recordId, |
| | | updateStatus: 'RC填写完毕' |
| | | }).then(result=>{ |
| | | if(result == 'SUCCESS'){ |
| | | this.showToast('提交成功','success'); |
| | | return; |
| | | } |
| | | if(result == 'ERROR'){ |
| | | this.showToast('提交失败','error'); |
| | | return; |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | showToast(msg,type) { |
| | | const event = new ShowToastEvent({ |
| | | message: msg, |
| | | variant: type |
| | | }); |
| | | if(type == 'success'){ |
| | | this.updateRecordView(this.recordId); |
| | | } |
| | | this.dispatchEvent(event); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | } |
| | | |
| | | updateRecordView(recordId) { |
| | | updateRecord({fields: { Id: recordId }}); |
| | | } |
| | | } |