From e6068da47c1bef5517c9e5fdc8c726766867ad4e Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 14 七月 2023 15:10:02 +0800
Subject: [PATCH] Merge branch 'master' into LEXUpgrade2023-Deloitte
---
force-app/main/default/lwc/lexNewAndEditContactPIPL/lexNewAndEditContactPIPL.js | 340 +++++++++++++++++++++++++++++++++++---------------------
1 files changed, 210 insertions(+), 130 deletions(-)
diff --git a/force-app/main/default/lwc/lexNewAndEditContactPIPL/lexNewAndEditContactPIPL.js b/force-app/main/default/lwc/lexNewAndEditContactPIPL/lexNewAndEditContactPIPL.js
index a0a9ff6..a9f5362 100644
--- a/force-app/main/default/lwc/lexNewAndEditContactPIPL/lexNewAndEditContactPIPL.js
+++ b/force-app/main/default/lwc/lexNewAndEditContactPIPL/lexNewAndEditContactPIPL.js
@@ -5,7 +5,9 @@
import { AWSService } from 'c/piUtils';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
-export default class LexNewAndEditContactPIPL extends NavigationMixin(LightningElement) {
+export default class LexNewAndEditContactPIPL extends NavigationMixin(
+ LightningElement
+) {
sobjectType = 'Contact';
@api recordId;
@@ -16,7 +18,6 @@
@track isShowSpinner = true;
@track layout = [];
@track isDoctor = true;
-
@track staticResource;
@track staticResourceContact;
@@ -54,7 +55,14 @@
this.recordTypeId = this.pageRef.state.recordTypeId;
console.log('this.recordTypeId = ' + this.recordTypeId);
}
- console.log('recordId = ' + this.recordId + ' recordTypeId = ' + this.recordTypeId + ' sobjectType = ' + this.sobjectType);
+ console.log(
+ 'recordId = ' +
+ this.recordId +
+ ' recordTypeId = ' +
+ this.recordTypeId +
+ ' sobjectType = ' +
+ this.sobjectType
+ );
initData({
rid: this.recordId,
recordTypeId: this.recordTypeId,
@@ -64,18 +72,16 @@
if (r.status == 'Success') {
this.isDoctor = r.entity.isDoctor;
console.log('this.isDoctor = ' + this.isDoctor);
- if(this.isEditMode){
+ if (this.isEditMode) {
this.recordTypeId = r.entity.recordTypeId;
}
console.log('this.recordTypeId = ' + this.recordTypeId);
- debugger
+ debugger;
//濡傛灉涓嶆槸鍖婚櫌绫诲瀷锛屼娇鐢ㄦ爣鍑嗛〉闈�
if (!this.isDoctor) {
- if(this.isNewMode)
- this.RedirectStandardNewPage();
- if(this.isEditMode)
- this.RedirectStandardEditPage();
- return
+ if (this.isNewMode) this.RedirectStandardNewPage();
+ if (this.isEditMode) this.RedirectStandardEditPage();
+ return;
}
this.AWSDataId = r.entity.AWSDataId;
let layout = JSON.parse(r.entity.layout);
@@ -83,21 +89,24 @@
console.log('layout = ' + typeof layout);
let index = 1;
- this.sectionName = layout.map(s => s.label);
+ this.sectionName = layout.map((s) => s.label);
for (let s of layout) {
for (let c of s.layoutColumns) {
c['index'] = index++;
if (c.layoutItems) {
for (let item of c.layoutItems) {
- item['isDisable'] = item.behavior == 'Readonly' ? true : false;
- item['isRequired'] = item.behavior == 'Required' ? true : false;
+ item['isDisable'] =
+ item.behavior == 'Readonly' ? true : false;
+ item['isRequired'] =
+ item.behavior == 'Required' ? true : false;
item['isModify'] = false;
if (item['field'] == 'Name') {
item.field = 'LastName';
- item.fieldLabel = '濮撳悕'
+ item.fieldLabel = '濮撳悕';
item['isModify'] = true;
if (this.isEditMode) {
- item['value'] = this.recordData.LastName
+ item['value'] =
+ this.recordData.LastName;
}
}
}
@@ -106,9 +115,10 @@
}
this.layout = layout;
console.log('this.layout = ' + JSON.stringify(this.layout));
- this.AWSToSobjectMap = JSON.parse(JSON.stringify(r.entity.AWSToSobjectNonEncryptedMap));
+ this.AWSToSobjectMap = JSON.parse(
+ JSON.stringify(r.entity.AWSToSobjectNonEncryptedMap)
+ );
this.staticResource = JSON.parse(r.entity.staticResource);
-
//缂栬緫
if (this.isEditMode) {
@@ -119,54 +129,72 @@
} else {
this.showToast('Error', r.msg);
}
- })
+ });
}
querySobjectFromAWS() {
- debugger
+ debugger;
var that = this;
- this.AWSService.query(this.staticResource.queryUrl, this.AWSDataId, function (data) {
- console.log('queryLeadFromAWSIFS data = ' + JSON.stringify(data));
- if (data.object) {
- for (let s of that.layout) {
- for (let lc of s.layoutColumns) {
- if(lc.layoutItems){
- for (let c of lc.layoutItems) {
- for (let f in that.AWSToSobjectMap) {
- if (data.object.hasOwnProperty(f) && c['field'] == that.AWSToSobjectMap[f]) {
- c['value'] = data.object[f] == null ? '' : data.object[f];
- if (c['field'] == 'LastName') {
- that.modifyObj['LastName'] = data.object[f] == null ? '' : data.object[f];
+ this.AWSService.query(
+ this.staticResource.queryUrl,
+ this.AWSDataId,
+ function (data) {
+ console.log(
+ 'queryLeadFromAWSIFS data = ' + JSON.stringify(data)
+ );
+ if (data.object) {
+ for (let s of that.layout) {
+ for (let lc of s.layoutColumns) {
+ if (lc.layoutItems) {
+ for (let c of lc.layoutItems) {
+ for (let f in that.AWSToSobjectMap) {
+ if (
+ data.object.hasOwnProperty(f) &&
+ c['field'] ==
+ that.AWSToSobjectMap[f]
+ ) {
+ c['value'] =
+ data.object[f] == null
+ ? ''
+ : data.object[f];
+ if (c['field'] == 'LastName') {
+ that.modifyObj['LastName'] =
+ data.object[f] == null
+ ? ''
+ : data.object[f];
+ }
}
}
}
}
}
}
+ // for (var s of that.layout) {
+ // for (var c of s.layoutFields) {
+ // for (let f in that.AWSToSobjectMap) {
+ // if (data.object.hasOwnProperty(f) && c['fieldAPI'] == that.AWSToSobjectMap[f]) {
+ // c['value'] = data.object[f] == null ? '' : data.object[f];
+ // if (c['fieldAPI'] == 'LastName') {
+ // that.modifyObj['LastName'] = data.object[f] == null ? '' : data.object[f];
+ // }
+ // }
+ // }
+ // }
+ // }
}
- // for (var s of that.layout) {
- // for (var c of s.layoutFields) {
- // for (let f in that.AWSToSobjectMap) {
- // if (data.object.hasOwnProperty(f) && c['fieldAPI'] == that.AWSToSobjectMap[f]) {
- // c['value'] = data.object[f] == null ? '' : data.object[f];
- // if (c['fieldAPI'] == 'LastName') {
- // that.modifyObj['LastName'] = data.object[f] == null ? '' : data.object[f];
- // }
- // }
- // }
- // }
- // }
- }
- }, this.staticResource.token)
+ },
+ this.staticResource.token
+ );
}
-
dataChange(event) {
- let fieldName = event.target.getAttribute("data-field");
+ let fieldName = event.target.getAttribute('data-field');
let value = event.detail.value;
- console.log("fieldName = " + fieldName + " value = " + event.detail.value);
+ console.log(
+ 'fieldName = ' + fieldName + ' value = ' + event.detail.value
+ );
switch (fieldName) {
- case "LastName":
+ case 'LastName':
this.modifyObj[fieldName] = value;
break;
}
@@ -182,21 +210,26 @@
Object.assign(fields, this.modifyObj);
console.log('fields = ' + JSON.stringify(fields));
- debugger
+ debugger;
//2. select cannot actively select redaction option
let validationResultMessage = this.validateFieldValueFormate(fields);
console.log(validationResultMessage);
if (validationResultMessage) {
this.showToast('Error', validationResultMessage);
- return
+ return;
}
//3. Check Required Field
let checkRequiredFieldMsgResult = this.checkRequiredFieldMsg(fields);
- console.log('checkRequiredFieldMsgResult = ' + checkRequiredFieldMsgResult);
+ console.log(
+ 'checkRequiredFieldMsgResult = ' + checkRequiredFieldMsgResult
+ );
if (checkRequiredFieldMsgResult != '') {
- this.showToast('Error', checkRequiredFieldMsgResult + '闇�瑕佽繘琛屽~鍐�');
- return
+ this.showToast(
+ 'Error',
+ checkRequiredFieldMsgResult + '闇�瑕佽繘琛屽~鍐�'
+ );
+ return;
}
//4. Prepare the payload for New PI API To AWS - To Do
@@ -219,11 +252,9 @@
let error_msg = '';
let b = false;
for (var key in fields) {
- if (fields[key] == "*****")
- b = true;
+ if (fields[key] == '*****') b = true;
}
- if (b)
- error_msg = '涓嬫媺妗嗕笉鑳戒富鍔ㄩ�夋嫨瀵嗘枃閫夐」';
+ if (b) error_msg = '涓嬫媺妗嗕笉鑳戒富鍔ㄩ�夋嫨瀵嗘枃閫夐」';
return error_msg;
}
@@ -235,7 +266,12 @@
for (let lc of s.layoutColumns) {
if (lc.layoutItems) {
for (let c of lc.layoutItems) {
- if (!c.isDisable && c.isRequired && (fields[c.field] == null || fields[c.field] == '')) {
+ if (
+ !c.isDisable &&
+ c.isRequired &&
+ (fields[c.field] == null ||
+ fields[c.field] == '')
+ ) {
msg += ';' + c.fieldLabel;
}
}
@@ -243,7 +279,7 @@
}
}
} catch (err) {
- this.showToast('Error',err.message);
+ this.showToast('Error', err.message);
}
msg = msg.substring(1);
return msg;
@@ -251,15 +287,14 @@
//鑾峰彇PI瀛楁
getPIPayload(sobjJsonLwc) {
- console.log()
+ console.log();
let leadPayloadList = [];
let leadPIData = {};
for (let f in this.AWSToSobjectMap) {
if (sobjJsonLwc.hasOwnProperty(this.AWSToSobjectMap[f])) {
- leadPIData[f] = sobjJsonLwc[this.AWSToSobjectMap[f]]
- }
- else {
+ leadPIData[f] = sobjJsonLwc[this.AWSToSobjectMap[f]];
+ } else {
console.log(this.AWSToSobjectMap[f] + 'is not in sobjJsonLwc');
}
}
@@ -274,27 +309,40 @@
//鏂板缓淇濆瓨ToAWS
NewPIToAWS(payloadForNewPI, fields) {
- this.AWSService.post(this.staticResource.newUrl, payloadForNewPI, (result) => {
- if (result && result.object) {
- console.log('result = ' + JSON.stringify(result));
- for (let f in this.AWSToSobjectMap) {
- if (result.object[0].hasOwnProperty(f)) {
- fields[this.AWSToSobjectMap[f]] = result.object[0][f];
- console.log('this.AWSToSobjectMap[f] = ' + this.AWSToSobjectMap[f]);
- console.log('fields[this.AWSToSobjectMap[f]] = ' + fields[this.AWSToSobjectMap[f]]);
+ this.AWSService.post(
+ this.staticResource.newUrl,
+ payloadForNewPI,
+ (result) => {
+ if (result && result.object) {
+ console.log('result = ' + JSON.stringify(result));
+ for (let f in this.AWSToSobjectMap) {
+ if (result.object[0].hasOwnProperty(f)) {
+ fields[this.AWSToSobjectMap[f]] =
+ result.object[0][f];
+ console.log(
+ 'this.AWSToSobjectMap[f] = ' +
+ this.AWSToSobjectMap[f]
+ );
+ console.log(
+ 'fields[this.AWSToSobjectMap[f]] = ' +
+ fields[this.AWSToSobjectMap[f]]
+ );
+ } else {
+ console.log(f + 'is not in result.object[0]');
+ }
}
- else {
- console.log(f + 'is not in result.object[0]');
- }
+ fields['AWS_Data_Id__c'] = result.object[0].dataId;
+ this.txId = result.txId;
+ //淇濆瓨鍒板悗绔�
+ this.template
+ .querySelector('lightning-record-edit-form')
+ .submit(fields);
+ } else {
+ console.log('result = ' + JSON.stringify(result));
}
- fields['AWS_Data_Id__c'] = result.object[0].dataId;
- this.txId = result.txId;
- //淇濆瓨鍒板悗绔�
- this.template.querySelector('lightning-record-edit-form').submit(fields);
- } else {
- console.log('result = ' + JSON.stringify(result));
- }
- }, this.staticResource.token);
+ },
+ this.staticResource.token
+ );
}
//缂栬緫淇濆瓨ToAWS
@@ -302,33 +350,49 @@
let obj = JSON.parse(payloadForNewPI);
obj[0].dataId = this.AWSDataId;
let payloadForNewPIJson = JSON.stringify(obj);
- this.AWSService.post(this.staticResource.updateUrl, payloadForNewPIJson, (result) => {
- if (result && result.object) {
- console.log('result = ' + JSON.stringify(result));
- for (let f in this.AWSToSobjectMap) {
- if (result.object[0].hasOwnProperty(f)) {
- fields[this.AWSToSobjectMap[f]] = result.object[0][f];
- console.log('this.AWSToSobjectMap[f] = ' + this.AWSToSobjectMap[f]);
- console.log('fields[this.AWSToSobjectMap[f]] = ' + fields[this.AWSToSobjectMap[f]]);
+ this.AWSService.post(
+ this.staticResource.updateUrl,
+ payloadForNewPIJson,
+ (result) => {
+ if (result && result.object) {
+ console.log('result = ' + JSON.stringify(result));
+ for (let f in this.AWSToSobjectMap) {
+ if (result.object[0].hasOwnProperty(f)) {
+ fields[this.AWSToSobjectMap[f]] =
+ result.object[0][f];
+ console.log(
+ 'this.AWSToSobjectMap[f] = ' +
+ this.AWSToSobjectMap[f]
+ );
+ console.log(
+ 'fields[this.AWSToSobjectMap[f]] = ' +
+ fields[this.AWSToSobjectMap[f]]
+ );
+ } else {
+ console.log(f + 'is not in result.object[0]');
+ }
}
- else {
- console.log(f + 'is not in result.object[0]');
+ fields['AWS_Data_Id__c'] = this.AWSDataId;
+ this.txId = result.txId;
+ console.log('this.txId = ' + this.txId);
+ console.log('PI After fields = ' + JSON.stringify(fields));
+ if (fields.RecordTypeId) {
+ fields['RecordTypeId'] = fields.RecordTypeId.substring(
+ 1,
+ fields.RecordTypeId.length - 1
+ );
}
+ //淇濆瓨鍒板悗绔�
+ console.log('update submit = ' + JSON.stringify(fields));
+ this.template
+ .querySelector('lightning-record-edit-form')
+ .submit(fields);
+ } else {
+ console.log('result = ' + JSON.stringify(result));
}
- fields['AWS_Data_Id__c'] = this.AWSDataId;
- this.txId = result.txId;
- console.log('this.txId = ' + this.txId);
- console.log('PI After fields = ' + JSON.stringify(fields));
- if (fields.RecordTypeId) {
- fields['RecordTypeId'] = fields.RecordTypeId.substring(1, fields.RecordTypeId.length - 1);
- }
- //淇濆瓨鍒板悗绔�
- console.log('update submit = ' + JSON.stringify(fields));
- this.template.querySelector('lightning-record-edit-form').submit(fields);
- } else {
- console.log('result = ' + JSON.stringify(result));
- }
- }, this.staticResource.token);
+ },
+ this.staticResource.token
+ );
}
//鎻愪氦淇濆瓨鎴愬姛
@@ -337,39 +401,55 @@
console.log('onsuccess: ', updatedRecord);
console.log('confirmTrans');
let that = this;
- this.AWSService.confirm(true, updatedRecord, this.txId, this.staticResource.token, this.staticResource.transactionUrl, function (result) {
- console.log('result = ' + JSON.stringify(result))
- that.showToast('Success', '淇濆瓨鎴愬姛');
- console.log('updatedRecord = ' + updatedRecord)
- that[NavigationMixin.Navigate]({
- type: 'standard__recordPage',
- attributes: {
- actionName: "view",
- recordId: updatedRecord,
- objectApiName: that.sobjectType
- }
- });
- });
+ this.AWSService.confirm(
+ true,
+ updatedRecord,
+ this.txId,
+ this.staticResource.token,
+ this.staticResource.transactionUrl,
+ function (result) {
+ console.log('result = ' + JSON.stringify(result));
+ that.showToast('Success', '淇濆瓨鎴愬姛');
+ console.log('updatedRecord = ' + updatedRecord);
+ that[NavigationMixin.Navigate]({
+ type: 'standard__recordPage',
+ attributes: {
+ actionName: 'view',
+ recordId: updatedRecord,
+ objectApiName: that.sobjectType
+ }
+ });
+ }
+ );
}
//鎻愪氦淇濆瓨澶辫触
handleError(event) {
event.preventDefault();
event.stopImmediatePropagation();
- this.showToast("Error", event.detail.detail);
- this.AWSService.confirm(false, '', this.txId, this.staticResource.token, this.staticResource.transactionUrl, function (result) {
- console.log('result = ' + JSON.stringify(result))
- });
+ this.showToast('Error', event.detail.detail);
+ this.AWSService.confirm(
+ false,
+ '',
+ this.txId,
+ this.staticResource.token,
+ this.staticResource.transactionUrl,
+ function (result) {
+ console.log('result = ' + JSON.stringify(result));
+ }
+ );
}
//change浜嬩欢
dataChange(event) {
- let fieldName = event.target.getAttribute("data-field");
+ let fieldName = event.target.getAttribute('data-field');
let value = event.detail.value;
- console.log("fieldName = " + fieldName + " value = " + event.detail.value);
+ console.log(
+ 'fieldName = ' + fieldName + ' value = ' + event.detail.value
+ );
if (this.modifyArray.indexOf(fieldName) != -1) {
switch (fieldName) {
- case "LastName":
+ case 'LastName':
this.modifyObj[fieldName] = value;
break;
}
@@ -404,10 +484,10 @@
attributes: {
objectApiName: 'Contact',
recordId: this.recordId,
- actionName: 'edit',
+ actionName: 'edit'
},
state: {
- nooverride: '1',
+ nooverride: '1'
}
});
}
@@ -422,4 +502,4 @@
});
this.dispatchEvent(event);
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.1