| | |
| | | * @Author: chen jing wu |
| | | * @Date: 2023-04-20 15:04:03 |
| | | * @LastEditors: chen jing wu |
| | | * @LastEditTime: 2023-05-24 15:48:07 |
| | | * @LastEditTime: 2023-05-31 11:42:30 |
| | | */ |
| | | const columns2=[ |
| | | { label: '--无--', value: '' }, |
| | |
| | | import { NavigationMixin } from 'lightning/navigation'; |
| | | import submit from '@salesforce/apex/lexPCLLostReportLwcController.submit'; |
| | | import {CloseActionScreenEvent} from 'lightning/actions'; |
| | | import lexLookupLwc from 'c/lexLookupLwc'; |
| | | import searchProduct from '@salesforce/apex/lexPCLLostReportLwcController.searchProduct'; |
| | | import { updateRecord } from 'lightning/uiRecordApi'; |
| | | export default class LexPCLLostReportPage extends NavigationMixin(LightningElement) { |
| | | |
| | | @api oppId; |
| | | @track columns2=columns2; |
| | | @track pageStatus = 'Create'; |
| | | @api pageStatus = 'Create'; |
| | | @track LostReport = { |
| | | LostBrands: [ |
| | | ], |
| | |
| | | columns3 = columns3; |
| | | //失单类型 |
| | | RecordTypeOptions = RecordTypeOptions; |
| | | isSubmit = false; |
| | | connectedCallback(){ |
| | | init({ |
| | | oppId1: this.oppId, |
| | |
| | | }); |
| | | this.dispatchEvent(event); |
| | | } |
| | | updateRecordView(recordId) { |
| | | updateRecord({fields: { Id: recordId }}); |
| | | } |
| | | |
| | | get isInit(){ |
| | | if(this.LostReport.LostBrands[0].LostProducts[0].productOptions == undefined){ |
| | |
| | | return false; |
| | | } |
| | | |
| | | get isEdit(){ |
| | | get isCreateOrEdit(){ |
| | | if(this.pageStatus == 'Create' || this.pageStatus == 'Edit'){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | get isEdit(){ |
| | | if(this.pageStatus == 'Edit'){ |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | report1: JSON.stringify(this.LostReport), |
| | | reportId: this.reportId |
| | | }).then(result=>{ |
| | | console.log(result); |
| | | if(result.error){ |
| | | this.showToast(result.error,"error"); |
| | | }else{ |
| | |
| | | if(result.message != null){ |
| | | if(result.message == '提交成功!'){ |
| | | this.LostReport = report; |
| | | this.isSubmit = true; |
| | | this.pageStatus = 'View'; |
| | | console.log(this.LostReport); |
| | | this.showToast(result.message,"success"); |
| | | this.updateRecordView(this.reportId); |
| | | |
| | | }else{ |
| | | this.showToast(result.message,"error"); |
| | | } |
| | |
| | | const payloadType = event.detail.payloadType; |
| | | this.LostReport.LostBrands[index].lostBrand.Lost_By_Company__c = payload.value; |
| | | if(payloadType === 'multi-select'){ |
| | | this.clearProducts(payload.value,index); |
| | | this.setDefaultBrand(payload.value,index); |
| | | this.clearBrandMannualName(payload.value,index); |
| | | } |
| | | } |
| | | setDefaultBrand(value,index){ |
| | | console.log('22222'); |
| | | // this.LostReport.LostBrands[index].LostProducts.forEach(product => { |
| | | // product.LostProductss.LostBrandName__c = value; |
| | | // }); |
| | | var newProducts = []; |
| | | this.LostReport.LostBrands[index].LostProducts.forEach(product => { |
| | | product.LostProductss.LostBrandName__c = value; |
| | | this.newProduct.LostProductss.LostBrandName__c = value; |
| | | newProducts.push(JSON.parse(JSON.stringify(this.newProduct))); |
| | | }); |
| | | this.LostReport.LostBrands[index].LostProducts = newProducts; |
| | | } |
| | | clearProducts(value,index){ |
| | | console.log('111111'); |
| | | var newProducts = []; |
| | | this.LostReport.LostBrands[index].LostProducts.forEach(product=>{ |
| | | this.newProduct.LostProductss.LostBrandName__c = value; |
| | | newProducts.push(JSON.parse(JSON.stringify(this.newProduct))); |
| | | }); |
| | | var elements1 = this.template.querySelectorAll('.ProductClass[data-id="' + index + '"]'); |
| | | elements1.forEach(element=>{ |
| | | element.readOnly = false; |
| | | }); |
| | | var elements2 = this.template.querySelectorAll('.Product[data-id="' + index + '"]'); |
| | | elements2.forEach(element=>{ |
| | | element.clearSelection(); |
| | | }); |
| | | this.LostReport.LostBrands[index].LostProducts = newProducts; |
| | | } |
| | | |
| | | |
| | |
| | | var elements = this.template.querySelectorAll('[data-id="Lost_By_Company_Mannual"]'); |
| | | elements[index].disabled = false; |
| | | elements[index].required = true; |
| | | var elements1 = this.template.querySelectorAll('.LostProduct[data-id="' + index + '"]'); |
| | | var elements1 = this.template.querySelectorAll('.Product[data-id="' + index + '"]'); |
| | | elements1.forEach(element=>{ |
| | | element.value = ''; |
| | | element.disabled = true; |
| | | element.letDisabledTrue(); |
| | | }); |
| | | } else { |
| | | var elements = this.template.querySelectorAll('[data-id="Lost_By_Company_Mannual"]'); |
| | |
| | | elements[index].value = ''; |
| | | elements[index].disabled = true; |
| | | elements[index].required = false; |
| | | var elements1 = this.template.querySelectorAll('.Product[data-id="' + index + '"]'); |
| | | elements1.forEach(element=>{ |
| | | element.disabled = false; |
| | | element.letDisabledFalse(); |
| | | }); |
| | | } |
| | | } |
| | |
| | | if(!this.flag){ |
| | | return; |
| | | } |
| | | console.log(this.pageStatus); |
| | | if(this.pageStatus == 'Edit'){ |
| | | this.pageStatus = 'View'; |
| | | }else{ |
| | | dataEntry({ |
| | | report1 : JSON.stringify(this.LostReport) |
| | | }).then(result=>{ |
| | | console.log(result); |
| | | if(result.error){ |
| | | this.showToast(result.error,"error"); |
| | | }else{ |
| | | this.LostReport = JSON.parse(result.LostReport); |
| | | this.reportId = result.reportId; |
| | | console.log(this.LostReport); |
| | | Promise.resolve().then(() => { |
| | | this.pageStatus = 'View'; |
| | | this.template.querySelectorAll('lightning-card').forEach(elem => { |
| | | elem.classList.toggle('View'); |
| | | }); |
| | | }); |
| | | } |
| | | }).catch(error=>{ |
| | | console.log("error"); |
| | |
| | | }); |
| | | } |
| | | |
| | | } |
| | | saveBrandToEditJs(event) { |
| | | Promise.resolve().then(() => { |
| | | this.pageStatus = 'View'; |
| | | this.template.querySelectorAll('lightning-card').forEach(elem => { |
| | | elem.classList.toggle('View'); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | editJs(){ |
| | | Promise.resolve().then(() => { |
| | | this.pageStatus = 'Edit'; |
| | | this.template.querySelectorAll('lightning-card').forEach(elem => { |
| | | elem.classList.toggle('Edit'); |
| | | }); |
| | | }); |
| | | // var elements = this.template.querySelectorAll('.Product'); |
| | | // console.log(elements.length); |
| | | // elements.forEach(element=>{ |
| | | // var name = null; |
| | | // this.productNameList.forEach(product=>{ |
| | | // if(product.index1 == element.title && product.index2 == element.name){ |
| | | // name = product.name; |
| | | // } |
| | | // }); |
| | | // element.editLookup(name); |
| | | // }); |
| | | } |
| | | |
| | | dataCheck(){ |
| | |
| | | } |
| | | this.LostReport.LostBrands[index1].LostProducts.splice(index2,1); |
| | | } |
| | | search(topNum,secondNum){ |
| | | console.log("sb"); |
| | | var elements1 = this.template.querySelectorAll('.ProductClass[data-id="' + topNum + '"]'); |
| | | var elements2 = this.template.querySelectorAll('.ProductCategory[data-id="' + topNum + '"]'); |
| | | if (this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c==null) { |
| | | elements1[secondNum].readOnly = false; |
| | | elements2[secondNum].readOnly = false; |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null; |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=null; |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].bool=false; |
| | | elements1[secondNum].readOnly = true; |
| | | elements2[secondNum].readOnly = true; |
| | | |
| | | }else { |
| | | console.log("a"); |
| | | searchProduct({ |
| | | lostProduct : this.LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c |
| | | }).then(result=>{ |
| | | console.log(result); |
| | | var prd = JSON.parse(result); |
| | | this.LostReport.LostBrands[topNum].LostProducts[secondNum].productOptions = this.productOptionsList[prd.ProductClass__c]; |
| | | if (prd.ProductCategory__c!=null) { |
| | | console.log("c"); |
| | | 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; |
| | | elements1[secondNum].readOnly = true; |
| | | elements2[secondNum].readOnly = true; |
| | | console.log("e"); |
| | | // this.LostReport.LostBrands[topNum].LostProducts[secondNum].bool=true; |
| | | }else { |
| | | console.log("d"); |
| | | elements1[secondNum].readOnly = false; |
| | | 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; |
| | | elements2[secondNum].readOnly = true; |
| | | // this.LostReport.LostBrands[topNum].LostProducts[secondNum].bool=false; |
| | | } |
| | | }).catch(error=>{ |
| | | console.log("error"); |
| | | console.log(error); |
| | | }); |
| | | |
| | | } |
| | | } |
| | | handleSelected(event) { |
| | | console.log('......'); |
| | | var index1 = event.target.title; |
| | | var index2 = event.target.name; |
| | | // var objectname = event.detail.ObjectName; |
| | | this.LostReport.LostBrands[index1].LostProducts[index2].LostProductss.LostProduct__c = event.detail.Id; |
| | | this.LostReport.LostBrands[index1].LostProducts[index2].productName = event.detail.Name; |
| | | this.search(index1,index2); |
| | | console.log(this.LostReport); |
| | | // this.account = {Name : event.detail.Name, Id: event.detail.Id} |
| | | |
| | | } |
| | | |
| | | handleLostTypeChange(event){ |
| | | var value = event.target.value; |
| | |
| | | var value = event.target.value; |
| | | this.LostReport.LostBrands[index].lostBrand.Lost_By_Company_Mannual__c = value; |
| | | this.setDefaultBrand(value,index); |
| | | var elements = this.template.querySelectorAll('.LostProduct[data-id="' + index + '"]'); |
| | | var elements = this.template.querySelectorAll('.Product[data-id="' + index + '"]'); |
| | | if(value == '' || value == null){ |
| | | elements.forEach(element=>{ |
| | | element.value = ''; |
| | | element.disabled = true; |
| | | element.letDisabledTrue(); |
| | | }); |
| | | }else{ |
| | | elements.forEach(element=>{ |
| | | element.disabled = false; |
| | | element.letDisabledFalse(); |
| | | }); |
| | | } |
| | | } |
| | |
| | | this.LostReport.LostBrands[index1].LostProducts[index2].LostProductss.LostProductMannual__c = event.target.value; |
| | | } |
| | | handleProductClassChange(event){ |
| | | console.log("qwer"); |
| | | var index1 = event.target.title; |
| | | var index2 = event.target.name; |
| | | this.LostReport.LostBrands[index1].LostProducts[index2].LostProductss.ProductClass__c = event.target.value; |