| | |
| | | * @Author: chen jing wu |
| | | * @Date: 2023-04-20 15:04:03 |
| | | * @LastEditors: chen jing wu |
| | | * @LastEditTime: 2023-09-13 13:45:33 |
| | | * @LastEditTime: 2023-10-03 11:54:18 |
| | | */ |
| | | let columns2=[ |
| | | { label: '--无--', value: '' }, |
| | |
| | | { label: '--无--', value: '' }, |
| | | { label: '主机', value: '主机' }, |
| | | { label: '镜子', value: '镜子' }, |
| | | { label: '洗消机', value: '洗消机' }, |
| | | { label: '小镜种', value: '小镜种' }, |
| | | { label: '能量', value: '能量' }, |
| | | { label: '光源', value: '光源' }, |
| | | { label: '其他', value: '其他' } |
| | | ]; |
| | | const productCategoryOptions = [ |
| | |
| | | import {CloseActionScreenEvent} from 'lightning/actions'; |
| | | import lexLookupLwc from 'c/lexLookupLwc'; |
| | | import searchProduct from '@salesforce/apex/lexPCLLostReportLwcController.searchProduct'; |
| | | import { updateRecord } from 'lightning/uiRecordApi'; |
| | | import { updateRecord,getRecord } from 'lightning/uiRecordApi'; |
| | | import { refreshApex } from '@salesforce/apex'; |
| | | import submitForApproval from '@salesforce/apex/lexPCLLostReportLwcController.submitForApproval'; |
| | | import reassignStep from '@salesforce/apex/lexPCLLostReportLwcController.reassignStep'; |
| | | import getUserProfileId from '@salesforce/apex/lexPCLLostReportLwcController.getUserProfileId'; |
| | | import PCLReportProfileId from '@salesforce/label/c.PCLReportProfileId'; |
| | | export default class LexPCLLostReportPage extends NavigationMixin(LightningElement) { |
| | | @track visible = false; |
| | | @wire(CurrentPageReference) pageRef; |
| | |
| | | @track status = { |
| | | pageStatus: 'Create' |
| | | } |
| | | newActorId = null; |
| | | newReport; |
| | | action; |
| | | isLookup; |
| | | modalsubmitLabel; |
| | | @track isPop; |
| | | @track message; |
| | | @track isSuccess; |
| | | @track LostReport = { |
| | |
| | | ], |
| | | lostReport: {} |
| | | } |
| | | editStatus; |
| | | reasonOptions = reasonOptions; |
| | | @track brandOptions = []; |
| | | @track isInit = false; |
| | | lostType = '失单'; |
| | |
| | | deleteProductIdList = []; |
| | | IsLoading; |
| | | newApprovalHistorys; |
| | | userProfileId; |
| | | @wire(getUserProfileId) |
| | | wiredUserProfileId({ error, data }) { |
| | | if (data) { |
| | | this.userProfileId = data; |
| | | console.log(this.userProfileId + 'user'); |
| | | } else if (error) { |
| | | // 处理错误 |
| | | } |
| | | } |
| | | handleCustomButtonClick(event) { |
| | | try { |
| | | var index1 = event.target.title; |
| | |
| | | this.LostReport = result.LostReport; |
| | | }else{ |
| | | this.showToast(result.message,"error"); |
| | | setTimeout(() => { |
| | | window.location = '/lightning/r/Opportunity/' + this.oppId + '/view'; |
| | | }, 2000); |
| | | } |
| | | }else{ |
| | | if(result.LostReport.lostReport.Report_Status__c == '申请中'){ |
| | | this.editStatus = '申请中'; |
| | | console.log('shenqingzhong'); |
| | | }else if(result.LostReport.lostReport.Report_Status__c == '批准'){ |
| | | this.editStatus = '批准'; |
| | | console.log('pizhun'); |
| | | } |
| | | |
| | | var report = result.LostReport; |
| | | this.LostReport = report; |
| | | this.LostReport.lostReport.LostTotalAmount__c = 0.0; |
| | | this.LostReport.lostReport.InclusionUltrasound__c = '0'; |
| | | |
| | | if(!this.LostReport.lostReport.LostTotalAmount__c){ |
| | | this.LostReport.lostReport.LostTotalAmount__c = 0.0; |
| | | } |
| | | if(!this.LostReport.lostReport.InclusionUltrasound__c){ |
| | | this.LostReport.lostReport.InclusionUltrasound__c = '0'; |
| | | } |
| | | |
| | | this.newProduct = JSON.parse(JSON.stringify(this.LostReport.LostBrands[0].LostProducts[0])); |
| | | if(this.newProduct.LostProductss.Id){ |
| | | delete this.newProduct.LostProductss.Id; |
| | | } |
| | | this.newProduct.LostProductss.LostBrandName__c = ''; |
| | | this.newProduct.LostProductss.LostProduct__r = ''; |
| | | this.newProduct.LostProductss.Quantity__c = ''; |
| | | this.newProduct.LostProductss.LostProductMannual__c = ''; |
| | | this.newProduct.LostProductss.ProductClass__c = ''; |
| | | this.newProduct.LostProductss.ProductCategory__c = ''; |
| | | // this.newProduct.LostProductss.Id = ''; |
| | | this.newApprovalHistorys = JSON.parse(JSON.stringify(this.LostReport.approvalHistorys)); |
| | | console.log(this.LostReport); |
| | | console.log(this.LostReport.approvalHistorys.length); |
| | |
| | | }else if(this.LostReport.approvalHistorys[i].StepStatus == 'Reassigned'){ |
| | | |
| | | }else if(this.LostReport.approvalHistorys[i].StepStatus == 'Rejected'){ |
| | | resthis.LostReportult.approvalHistorys[i].StepStatus = '已拒绝'; |
| | | this.LostReport.approvalHistorys[i].StepStatus = '已拒绝'; |
| | | }else if(this.LostReport.approvalHistorys[i].StepStatus == 'Removed'){ |
| | | |
| | | }else if(this.LostReport.approvalHistorys[i].StepStatus == 'Started'){ |
| | |
| | | console.log('321'); |
| | | } |
| | | this.submitFlag = true; |
| | | if(this.LostReport.lostReport.Report_Status__c == '批准'){ |
| | | this.submitFlag = false; |
| | | } |
| | | } |
| | | this.isInit = true; |
| | | console.log(PCLReportProfileId.includes(this.userProfileId)); |
| | | console.log(PCLReportProfileId); |
| | | console.log(this.userProfileId); |
| | | getUserProfileId().then(result1=>{ |
| | | this.userProfileId = result1; |
| | | if(this.pageStatus == 'Edit' && !(this.LostReport.lostReport.Report_Status__c == '草案' || this.userProfileId == '00e10000000Y3o5AAC' || (this.LostReport.lostReport.Report_Status__c == '批准' && PCLReportProfileId.includes(this.userProfileId)))){ |
| | | this.status.pageStatus = 'View'; |
| | | } |
| | | this.isInit = true; |
| | | }); |
| | | |
| | | } |
| | | }).catch(error=>{ |
| | | console.log("error"); |
| | |
| | | fieldName: 'ProductCategory__c' |
| | | }).then(result=>{ |
| | | this.productOptionsList = JSON.parse(result); |
| | | this.LostReport = JSON.parse(JSON.stringify(this.LostReport)); |
| | | console.log(this.LostReport.approvalHistorys.length + 'size'); |
| | | }).catch(error=>{ |
| | | console.log('error'); |
| | | console.log(error); |
| | | }); |
| | | |
| | | |
| | | } |
| | | renderedCallback(){ |
| | | const sections = this.template.querySelectorAll('lightning-accordion-section'); |
| | |
| | | console.log(section); |
| | | section.active = true; |
| | | }); |
| | | console.log('1'); |
| | | console.log(this.LostReport.lostReport.LostTotalAmount__c); |
| | | this.LostReport.lostReport.LostTotalAmount__c = this.LostReport.lostReport.LostTotalAmount__c; |
| | | // this.LostReport = JSON.parse(JSON.stringify(this.LostReport)); |
| | | } |
| | | brandTitle = ['失单品牌1','失单品牌2','失单品牌3','失单品牌4','失单品牌5','失单品牌6']; |
| | | |
| | | @wire(CurrentPageReference) |
| | | getStateParameters(currentPageReference) { |
| | |
| | | } |
| | | } |
| | | } |
| | | closeAction(){ |
| | | this.visible = false; |
| | | } |
| | | |
| | | get haveApprovalHistorys(){ |
| | | console.log(this.LostReport.approvalHistorys.length + 'size'); |
| | | if(this.LostReport.approvalHistorys.length > 1){ |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | } |
| | | get isCanSubmit(){ |
| | | if(this.LostReport.lostReport.Report_Status__c == '草案' || this.LostReport.lostReport.Report_Status__c == '批准'){ |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | get isCanEdit(){ |
| | | if(this.LostReport.lostReport.Report_Status__c == '草案' || this.userProfileId == '00e10000000Y3o5AAC' || (this.LostReport.lostReport.Report_Status__c == '批准' && PCLReportProfileId.includes(this.userProfileId))){ |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | showToast(msg,type) { |
| | | try { |
| | |
| | | let delay = 5000; |
| | | console.log(this.message); |
| | | console.log('1'); |
| | | setTimeout(() => { |
| | | this.visible = false; |
| | | }, delay ); |
| | | // setTimeout(() => { |
| | | // this.visible = false; |
| | | // }, delay ); |
| | | } catch (error) { |
| | | console.log(error); |
| | | } |
| | |
| | | } |
| | | return false; |
| | | } |
| | | get isCaoAn(){ |
| | | if(this.LostReport.lostReport.Report_Status__c == '草案'){ |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | get isEdit(){ |
| | | if(this.status.pageStatus == 'Edit'){ |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | get isSubmit(){ |
| | | if(this.submitFlag){ |
| | | return true; |
| | |
| | | lineNo: this.LostReport.LostBrands.length |
| | | }).then(result=>{ |
| | | this.LostReport.LostBrands.push(result); |
| | | // 获取 lightning-accordion 的 DOM 元素 |
| | | setTimeout(() => { |
| | | const accordion = this.template.querySelector('.example-accordion'); |
| | | console.log(accordion); |
| | | console.log('1'); |
| | | accordion.activeSectionName = this.brandTitle; |
| | | }, 200); |
| | | |
| | | }); |
| | | } |
| | | addRow(event){ |
| | |
| | | console.log('1'); |
| | | this.IsLoading = true; |
| | | submit({ |
| | | report1: JSON.stringify(this.LostReport), |
| | | reportId: this.reportId |
| | | reportStatus: this.LostReport.lostReport.Report_Status__c, |
| | | modifyAfterApproval: this.LostReport.lostReport.ModifyAfterApproval__c, |
| | | reportId: this.LostReport.lostReport.Id |
| | | }).then(result=>{ |
| | | if(result.error){ |
| | | this.showToast(result.error,"error"); |
| | |
| | | } |
| | | this.submitFlag = JSON.parse(JSON.stringify(result.submitFlag)); |
| | | console.log(this.LostReport); |
| | | this.updateRecordView(this.reportId); |
| | | this.LostReport.lostReport.Report_Status__c = '申请中'; |
| | | // this.updateRecordView(this.reportId); |
| | | this.showToast('提交成功!','success'); |
| | | setTimeout(() => { |
| | | |
| | | window.location = '/' + this.LostReport.lostReport.Id; |
| | | }, 2000); |
| | | } |
| | | this.IsLoading = false; |
| | | }).catch(error=>{ |
| | |
| | | }); |
| | | } |
| | | onApproveChange(event){ |
| | | window.open('/lightning/r/ProcessInstanceStep/'+ this.LostReport.approvalHistorys[0].Id + '/view?0.source=alohaHeader'); |
| | | // this[NavigationMixin.Navigate]({ |
| | | // type: 'standard__recordPage', |
| | | // attributes: { |
| | | // recordId: this.LostReport.approvalHistorys[0].Id, |
| | | // actionName: 'view' |
| | | // } |
| | | // }); |
| | | // var approvalId; |
| | | // for(var i=0;i < this.LostReport.approvalHistorys.length;i++){ |
| | | // if(this.LostReport.approvalHistorys[i].StepStatus == '待处理'){ |
| | | // approvalId = this.LostReport.approvalHistorys[i].Id; |
| | | // } |
| | | // } |
| | | |
| | | // window.open('/lightning/r/ProcessInstanceStep/'+ approvalId + '/view?0.source=alohaHeader'); |
| | | this.isPop = true; |
| | | |
| | | } |
| | | onApproveChange1(){ |
| | | window.open('/lightning/r/' + this.LostReport.lostReport.Id + '/related/ProcessSteps/view?0.source=alohaHeader'); |
| | | } |
| | | |
| | | |
| | |
| | | this.LostReport.LostBrands[index].lostBrand.Lost_By_Company__c = payload.value; |
| | | this.LostReport.LostBrands[index].lostBrand.Lost_reason_main__c = ''; |
| | | this.LostReport.LostBrands[index].lostBrand.Lost_Reason_Sub__c = ''; |
| | | this.LostReport.LostBrands[index].lostBrand.ChannelSpecificReasons__c = ''; |
| | | this.LostReport.LostBrands[index].reasonFlag = false; |
| | | searchBatchIfForProduct({ |
| | | productName: this.LostReport.LostBrands[index].lostBrand.Lost_By_Company__c |
| | | }).then(result=>{ |
| | |
| | | this.setDefaultBrand(payload.value,index); |
| | | this.clearBrandMannualName(payload.value,index); |
| | | } |
| | | console.log('cnm:' + JSON.stringify(this.LostReport)); |
| | | }); |
| | | |
| | | } |
| | |
| | | // actionName: 'view' |
| | | // } |
| | | // }); |
| | | window.location = '/' +this.oppId; |
| | | window.location = '/lightning/r/Opportunity/' + this.LostReport.lostReport.Opportunity__c + '/view'; |
| | | } |
| | | removeFieldsWithR(obj) { |
| | | if (Array.isArray(obj)) { |
| | | // 如果属性是数组,遍历数组元素 |
| | | for (var i = 0; i < obj.length; i++) { |
| | | // 递归调用函数处理数组元素 |
| | | this.removeFieldsWithR(obj[i]); |
| | | } |
| | | } else if (typeof obj === 'object' && obj !== null) { |
| | | // 如果属性是对象,则遍历对象属性 |
| | | for (var key in obj) { |
| | | if (key.includes('__r') || key === 'approvalHistorys') { |
| | | // 如果属性名以 '__r' 结尾,删除它 |
| | | console.log(key); |
| | | delete obj[key]; |
| | | }else if (typeof obj[key] === 'object' && obj[key] !== null) { |
| | | // 如果属性是对象,则递归调用该函数 |
| | | this.removeFieldsWithR(obj[key]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | saveBrandJs(event) { |
| | | this.IsLoading = true; |
| | |
| | | return; |
| | | } |
| | | console.log(this.LostReport); |
| | | var newLostReport = JSON.parse(JSON.stringify(this.LostReport)); |
| | | newLostReport.approvalHistorys = this.newApprovalHistorys; |
| | | this.newReport = JSON.parse(JSON.stringify(this.LostReport)); |
| | | this.newReport.approvalHistorys = this.newApprovalHistorys; |
| | | console.log(JSON.stringify(this.newReport)); |
| | | this.removeFieldsWithR(this.newReport); |
| | | console.log(JSON.stringify(this.newReport)); |
| | | dataEntry({ |
| | | report1 : JSON.stringify(newLostReport), |
| | | report1 : JSON.stringify(this.newReport), |
| | | deleteBrandIdList: this.deleteBrandIdList, |
| | | deleteProductIdList: this.deleteProductIdList |
| | | }).then(result=>{ |
| | |
| | | removeRow(event){ |
| | | var index1 = event.target.name; |
| | | var index2 = event.target.value; |
| | | var deleteButtons = this.template.querySelectorAll('.deleteButton[data-id="' + index1 + '"]'); |
| | | var deleteButtons = this.template.querySelectorAll('.iconButton[data-id="' + index1 + '"]'); |
| | | console.log(deleteButtons.length + ' chen1'); |
| | | if(deleteButtons.length == 1){ |
| | | return; |
| | | } |
| | |
| | | elements1[secondNum].readOnly = false; |
| | | elements2[secondNum].readOnly = false; |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=prd.ProductClass__c; |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=prd.ProductCategory__c; |
| | | console.log(prd.ProductClass__c + ' ' + prd.ProductCategory__c); |
| | | if(prd.ProductClass__c == '其他' && (prd.ProductCategory__c == '' || prd.ProductCategory__c == null || prd.ProductCategory__c == undefined)){ |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c = '其他'; |
| | | }else{ |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=prd.ProductCategory__c; |
| | | } |
| | | |
| | | elements1[secondNum].readOnly = true; |
| | | elements2[secondNum].readOnly = true; |
| | | }else { |
| | |
| | | elements2[secondNum].readOnly = false; |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null; |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=null; |
| | | elements1[secondNum].readOnly = true; |
| | | // elements1[secondNum].readOnly = true; |
| | | elements2[secondNum].readOnly = true; |
| | | } |
| | | }).catch(error=>{ |
| | |
| | | }); |
| | | |
| | | } |
| | | } |
| | | handleModalCancel(){ |
| | | this.isPop = false; |
| | | } |
| | | handleModalSubmit(){ |
| | | |
| | | this.IsLoading = true; |
| | | const comment = this.template.querySelector('.comment'); |
| | | console.log(this.isLookup == true && this.newActorId == null); |
| | | if(this.isLookup == true && this.newActorId == null){ |
| | | this.showToast('请填入新分配人','error'); |
| | | this.IsLoading = false; |
| | | return; |
| | | } |
| | | this.isPop = false; |
| | | if(this.newActorId){ |
| | | reassignStep({ |
| | | recordId: this.LostReport.lostReport.Id, |
| | | newActorId: this.newActorId |
| | | }).then(result=>{ |
| | | if(result){ |
| | | this.showToast('您无权重新分配','error'); |
| | | this.IsLoading = false; |
| | | }else{ |
| | | window.location = '/' + this.LostReport.lostReport.Id; |
| | | } |
| | | |
| | | }); |
| | | }else{ |
| | | submitForApproval({ |
| | | recordId: this.LostReport.lostReport.Id, |
| | | comments: comment.value, |
| | | action: this.action |
| | | }).then(result=>{ |
| | | if(result){ |
| | | if(this.action == 'Approve'){ |
| | | this.showToast('您无权批准','error'); |
| | | }else if(this.action == 'Reject'){ |
| | | this.showToast('您无权拒绝','error'); |
| | | }else if(this.action == 'Removed'){ |
| | | this.showToast('您无权撤回','error'); |
| | | } |
| | | |
| | | this.IsLoading = false; |
| | | }else{ |
| | | window.location = '/' + this.LostReport.lostReport.Id; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | handleSubmitApp(){ |
| | | this.modalsubmitLabel = '批准'; |
| | | this.isPop = true; |
| | | this.action = 'Approve'; |
| | | this.isLookup = false; |
| | | this.newActorId = null; |
| | | } |
| | | handleReStartApp(){ |
| | | this.modalsubmitLabel = '重新分配'; |
| | | this.isPop = true; |
| | | this.isLookup = true; |
| | | |
| | | } |
| | | handleNoApp(){ |
| | | this.modalsubmitLabel = '拒绝'; |
| | | this.isPop = true; |
| | | this.action = 'Reject'; |
| | | this.isLookup = false; |
| | | this.newActorId = null; |
| | | } |
| | | handleCancelApp(){ |
| | | this.modalsubmitLabel = '撤回'; |
| | | this.isPop = true; |
| | | this.action = 'Removed'; |
| | | this.isLookup = false; |
| | | this.newActorId = null; |
| | | } |
| | | |
| | | handleClear(event){ |
| | |
| | | } |
| | | handleChannelSpecificReasonChange(event){ |
| | | var value = event.target.value; |
| | | this.LostReport.lostReport.LostType__c = value; |
| | | var index = event.target.name; |
| | | this.LostReport.LostBrands[index].lostBrand.ChannelSpecificReasons__c = value; |
| | | } |
| | | |
| | | handleLostReasonMainChange(event){ |
| | |
| | | var value = event.target.value; |
| | | this.LostReport.LostBrands[index].lostBrand.Lost_reason_main__c = value; |
| | | if(value == '渠道因素'){ |
| | | |
| | | this.LostReport.LostBrands[index].reasonFlag = true; |
| | | }else if(this.LostReport.LostBrands[index].lostBrand.Lost_reason_main__c != '渠道因素' && this.LostReport.LostBrands[index].lostBrand.Lost_Reason_Sub__c != '渠道因素'){ |
| | | this.LostReport.LostBrands[index].reasonFlag = false; |
| | | this.LostReport.LostBrands[index].lostBrand.ChannelSpecificReasons__c = ''; |
| | | } |
| | | } |
| | | |
| | |
| | | var index = event.target.name; |
| | | var value = event.target.value; |
| | | this.LostReport.LostBrands[index].lostBrand.Lost_Reason_Sub__c = value; |
| | | if(value == '渠道因素'){ |
| | | this.LostReport.LostBrands[index].reasonFlag = true; |
| | | }else if(this.LostReport.LostBrands[index].lostBrand.Lost_reason_main__c != '渠道因素' && this.LostReport.LostBrands[index].lostBrand.Lost_Reason_Sub__c != '渠道因素'){ |
| | | this.LostReport.LostBrands[index].reasonFlag = false; |
| | | this.LostReport.LostBrands[index].lostBrand.ChannelSpecificReasons__c = ''; |
| | | } |
| | | } |
| | | |
| | | handleLostByCompanyMannualChange(event){ |
| | |
| | | } |
| | | |
| | | } |
| | | handleActorChange(event){ |
| | | this.newActorId = event.target.value; |
| | | } |
| | | |
| | | handleProductCategoryChange(event){ |
| | | var index1 = event.target.title; |