| | |
| | | import { LightningElement,wire,track,api} from 'lwc'; |
| | | import { CurrentPageReference } from "lightning/navigation"; |
| | | import { CloseActionScreenEvent } from 'lightning/actions'; |
| | | import { NavigationMixin } from 'lightning/navigation'; |
| | | import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | import { updateRecord } from 'lightning/uiRecordApi'; |
| | | import init from '@salesforce/apex/QISReportController.initForlexRCRecievedButton'; |
| | | import updateQis from '@salesforce/apex/QISReportController.updateQisForRCRecieved'; |
| | | import { |
| | | LightningElement, |
| | | wire, |
| | | api |
| | | } from 'lwc'; |
| | | import { |
| | | CurrentPageReference |
| | | } from "lightning/navigation"; |
| | | import { |
| | | CloseActionScreenEvent |
| | | } from 'lightning/actions'; |
| | | import { |
| | | ShowToastEvent |
| | | } from 'lightning/platformShowToastEvent'; |
| | | import init from '@salesforce/apex/buttonQISReportCtl.init'; |
| | | import updateQisForRCRecieved from '@salesforce/apex/buttonQISReportCtl.updateQisForRCRecieved'; |
| | | |
| | | export default class lexOCSMNogoods extends LightningElement { |
| | | @api recordId; |
| | | err; |
| | | IsLoading = true; |
| | | qisReportId; |
| | | qisStatus; |
| | | isAEProfile; |
| | | isCNBuy; |
| | | @wire(CurrentPageReference) |
| | | getStateParameters(currentPageReference) { |
| | | console.log(111); |
| | | console.log(currentPageReference); |
| | | @api recordId; |
| | | str; |
| | | IsLoading = true; |
| | | Id; |
| | | userId; |
| | | QISStatusC; |
| | | isAEProfileC; |
| | | isCNBuyC; |
| | | isPAEProfileC; |
| | | |
| | | if (currentPageReference) { |
| | | const urlValue = currentPageReference.state.recordId; |
| | | if (urlValue) { |
| | | let str = `${urlValue}`; |
| | | console.log("str"); |
| | | console.log(str); |
| | | this.recordId = str; |
| | | } |
| | | } |
| | | } |
| | | @wire(CurrentPageReference) |
| | | getStateParameters(currentPageReference) { |
| | | if (currentPageReference) { |
| | | const urlValue = currentPageReference.state.recordId; |
| | | if (urlValue) { |
| | | let str = `${urlValue}`; |
| | | this.recordId = str; |
| | | } |
| | | } |
| | | } |
| | | |
| | | connectedCallback () { |
| | | connectedCallback() { |
| | | init({ |
| | | recordId: this.recordId |
| | | }).then(result => { |
| | | this.IsLoading = false; |
| | | this.qisReportId = result.Id; |
| | | this.qisStatus = result.qIStatus; |
| | | this.isAEProfile = result.isAEProfile; |
| | | this.isCNBuy = result.isCNBuy; |
| | | console.log('this.qisStatus='+this.qisStatus); |
| | | if (this.qisStatus!='RC检测申请') { |
| | | const evt = new ShowToastEvent({ |
| | | title : 'OCM服务本部已经收到实物', |
| | | message: '', |
| | | variant: 'error' |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | console.log(result); |
| | | if (result != null) { |
| | | this.IsLoading = false; |
| | | this.Id = result.Id; |
| | | this.userId = result.userId; |
| | | this.QISStatusC = result.QISStatusC; |
| | | this.isAEProfileC = result.isAEProfileC; |
| | | this.isPAEProfileC = result.isPAEProfileC; |
| | | this.isCNBuyC = result.isCNBuyC; |
| | | |
| | | this.OCSMNogoods(); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | }else{ |
| | | if (this.isAEProfile == null || this.isPAEProfile == null || this.isCNBuy != 'true') { |
| | | const evt = new ShowToastEvent({ |
| | | title : '安全信息未判定,请联系质量法规部', |
| | | message: '', |
| | | variant: 'error' |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | }else{ |
| | | this.updateQisSubmit(); |
| | | } |
| | | } |
| | | } |
| | | }).catch(error => { |
| | | console.log('error='+error); |
| | | }).finally(() => { |
| | | |
| | | }); |
| | | console.log(error); |
| | | }) |
| | | } |
| | | |
| | | updateRecordView(recordId) { |
| | | updateRecord({fields: { Id: recordId }}); |
| | | } |
| | | |
| | | updateQisSubmit(){ |
| | | updateQis({ |
| | | recordId: this.recordId |
| | | }).then(result =>{ |
| | | |
| | | console.log('result'+result); |
| | | this.err = result; |
| | | if (result!='成功') { |
| | | const evt = new ShowToastEvent({ |
| | | title : '更新失败', |
| | | message: this.err, |
| | | variant: 'error' |
| | | }); |
| | | this.dispatchEvent(evt); |
| | | //OCSM无实物送达 |
| | | OCSMNogoods() { |
| | | if (this.QISStatusC != 'RC检测申请') { |
| | | this.ShowToastEvent("OCM服务本部已经收到实物", "error"); |
| | | } else { |
| | | if ((this.isAEProfileC == undefined || this.isPAEProfileC == undefined) && this.isCNBuyC != 'true') { |
| | | this.ShowToastEvent("安全信息未判定,请联系质量法规部", "error"); |
| | | var btns = document.getElementsByName('rc_recieved'); |
| | | for (var i = 0; i < btns.length; i++) { |
| | | btns[i].disabled = true; |
| | | btns[i].className = 'btnDisabled'; |
| | | } |
| | | } else { |
| | | updateQisForRCRecieved({ |
| | | QId: this.Id, |
| | | uid: this.userId |
| | | }).then(result => { |
| | | console.log(result); |
| | | if (result.length > 0) { |
| | | alert(result); |
| | | } |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | this.updateRecordView(this.recordId); |
| | | }).catch(error => { |
| | | console.log('error='+error); |
| | | }).finally(() => { |
| | | |
| | | }); |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 弹窗 |
| | | ShowToastEvent(msg, type) { |
| | | const event = new ShowToastEvent({ |
| | | title: '', |
| | | message: msg, |
| | | variant: type |
| | | }); |
| | | this.dispatchEvent(event); |
| | | } |
| | | } |