From 5ce27d69c427ca16f37ff16d53758d0e877a88f9 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期三, 31 五月 2023 17:48:34 +0800
Subject: [PATCH] 修改页面以及更改跳转方式
---
force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 158 insertions(+), 19 deletions(-)
diff --git a/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js b/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js
index 969f72e..47f681b 100644
--- a/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js
+++ b/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js
@@ -4,7 +4,7 @@
* @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: '' },
@@ -57,11 +57,14 @@
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: [
],
@@ -80,6 +83,7 @@
columns3 = columns3;
//澶卞崟绫诲瀷
RecordTypeOptions = RecordTypeOptions;
+ isSubmit = false;
connectedCallback(){
init({
oppId1: this.oppId,
@@ -149,6 +153,9 @@
});
this.dispatchEvent(event);
}
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
get isInit(){
if(this.LostReport.LostBrands[0].LostProducts[0].productOptions == undefined){
@@ -183,8 +190,15 @@
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;
@@ -203,7 +217,6 @@
report1: JSON.stringify(this.LostReport),
reportId: this.reportId
}).then(result=>{
- console.log(result);
if(result.error){
this.showToast(result.error,"error");
}else{
@@ -219,8 +232,12 @@
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");
}
@@ -262,14 +279,39 @@
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){
- this.LostReport.LostBrands[index].LostProducts.forEach(product => {
- product.LostProductss.LostBrandName__c = value;
+ console.log('22222');
+ // this.LostReport.LostBrands[index].LostProducts.forEach(product => {
+ // product.LostProductss.LostBrandName__c = value;
+ // });
+ var newProducts = [];
+ this.LostReport.LostBrands[index].LostProducts.forEach(product=>{
+ 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;
}
@@ -279,10 +321,9 @@
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"]');
@@ -290,8 +331,9 @@
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();
});
}
}
@@ -311,26 +353,63 @@
if(!this.flag){
return;
}
- dataEntry({
+ 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);
- this.pageStatus = 'View';
+ Promise.resolve().then(() => {
+ this.pageStatus = 'View';
+ this.template.querySelectorAll('lightning-card').forEach(elem => {
+ elem.classList.toggle('View');
+ });
+ });
}
}).catch(error=>{
console.log("error");
console.log(error);
});
+ }
+
}
-
- editJs(){
- this.pageStatus = 'Edit';
+ 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.flag = true;
if(this.LostReport.lostReport.LostType__c == undefined || this.isBlank(this.LostReport.lostReport.LostType__c))
@@ -433,6 +512,66 @@
}
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;
@@ -456,15 +595,14 @@
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();
});
}
}
@@ -506,6 +644,7 @@
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;
--
Gitblit v1.9.1