From 450f9922c8b9435e219e9ee44ccc90df581dcd60 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期五, 19 四月 2024 17:28:23 +0800
Subject: [PATCH] 123
---
force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js | 78 +++++++++++++++++++++++++++------------
1 files changed, 54 insertions(+), 24 deletions(-)
diff --git a/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js
index 08d011f..84ae69b 100644
--- a/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js
+++ b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js
@@ -4,19 +4,25 @@
* @Author: chen jing wu
* @Date: 2023-06-20 14:37:24
* @LastEditors: chen jing wu
- * @LastEditTime: 2023-06-20 17:50:52
+ * @LastEditTime: 2023-10-11 16:54:13
*/
-import { api, wire,LightningElement } from 'lwc';
+import { api, wire,LightningElement, track } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import updateSubmitSolutionForApprovalButton from '@salesforce/apex/lexSolutionProjectRequirementsController.updateSubmitSolutionForApprovalButton';
import init from '@salesforce/apex/lexSolutionProjectRequirementsController.initSubmitSolutionForApprovalButton';
import queryForAttachments from '@salesforce/apex/lexSolutionProjectRequirementsController.queryForAttachments';
-import { updateRecord } from 'lightning/uiRecordApi';
+import { updateRecord,getRecord } from 'lightning/uiRecordApi';
+import STATUS_FIELD from "@salesforce/schema/SolutionProjectRequirements__c.Status__c";
+import { refreshApex } from '@salesforce/apex';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
+import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
+import {loadStyle} from 'lightning/platformResourceLoader';
export default class LexSubmitSolutionForApproval extends LightningElement {
+ @wire(getRecord, { recordId: '$recordId', fields: [STATUS_FIELD] })
+ record;
@api recordId;
status;
submitDateYouWant;
@@ -41,12 +47,22 @@
}
}
showToast(msg,type) {
- const event = new ShowToastEvent({
- title: '',
- message: msg,
- variant: type
- });
- this.dispatchEvent(event);
+ if(type == 'success'){
+ const event = new ShowToastEvent({
+ message: msg,
+ variant: type,
+ });
+ this.dispatchEvent(event);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }else{
+ const event = new ShowToastEvent({
+ message: msg,
+ variant: type,
+ mode: 'sticky'
+ });
+ this.dispatchEvent(event);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
}
@@ -55,16 +71,25 @@
}
connectedCallback(){
+ Promise.all([
+ loadStyle(this, lwcCSS)
+ ]);
+
init({
recordId: this.recordId
}).then(result=>{
- this.status = result.status;
- this.submitDateYouWant = result.submitDateYouWant;
- this.createdDate = result.createdDate;
- this.departmentClassId = result.departmentClassId;
- this.userId = result.userId;
- this.userName = result.userName;
- this.submitSolutionForApproval();
+ console.log(result);
+ if(result.res){
+ this.status = result.res.status;
+ this.submitDateYouWant = new Date(result.res.submitDateYouWant);
+ // this.createdDate = result.res.createdDate;
+ this.createdDate = new Date(result.res.createdDate);
+ this.productLeader = result.res.productLeader;
+ this.departmentClassId = result.res.departmentClassId;
+ this.userId = result.res.userId;
+ this.userName = result.res.userName;
+ this.submitSolutionForApproval();
+ }
});
}
@@ -74,7 +99,8 @@
this.dispatchEvent(new CloseActionScreenEvent());
return;
}
- if(this.submitDateYouWant < this.createdDate + 3){
+ this.createdDate.setDate(this.createdDate.getDate() + 3);
+ if(this.submitDateYouWant.getTime() < this.createdDate.getTime()){
this.showToast('甯屾湜鎻愪氦鏃ユ湡涓嶅緱灏忎簬涓夊ぉ锛屽绱ф�ラ渶姹傝閭欢鑱旂粶Solution鎷呭綋','error');
this.dispatchEvent(new CloseActionScreenEvent());
return;
@@ -82,16 +108,17 @@
queryForAttachments({
Id: this.departmentClassId
}).then(result=>{
+ console.log("start");
var records = result;
var header = this.productLeader;
var usrname = this.userName;
var rtn = '';
- if(header.contains(usrname.replaceAll(' ', ''))){
+ console.log("start");
+ if(header != undefined && header != null && header != '' && header.includes(usrname)){
rtn = 'Y';
}else{
rtn = 'N';
}
-
if(records.length > 0){
if(rtn != 'Y' && this.userId != records[0].Department_Class__r.OwnerId && this.userId != records[0].Department_Class__r.Owner.SalesManager__c){
this.showToast('鍙厑鍏舵垬鐣ョ瀹や富鎷呫�佷骇鍝佹媴褰撳強鐪佺粡鐞嗘彁浜olution椤圭洰闇�姹傦紒','error');
@@ -99,8 +126,6 @@
return;
}
}
-
- //111111111111111111111111111111111111111111
this.handleConfirmClick('涓�鏃︽彁浜ゆ璁板綍浠ュ緟鎵瑰噯锛屾牴鎹偍鐨勮缃偍鍙兘涓嶅啀鑳藉缂栬緫姝よ褰曟垨灏嗕粬浠庢壒鍑嗚繃绋嬩腑璋冨洖銆傛槸鍚︾户缁紵');
});
@@ -112,7 +137,7 @@
const result = await LightningConfirm.open({
message: msg,
variant: 'headerless',
- label: 'this is the aria-label value',
+ label: 'this is the aria-label value'
});
console.log(result);
if(result){
@@ -123,7 +148,13 @@
if(results){
this.showToast(results,"error");
this.dispatchEvent(new CloseActionScreenEvent());
- }
+ } else{
+ setTimeout(() => {
+ refreshApex(this.record);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }, 1000);
+
+ }
} catch (error) {
if(err.faultstring !=undefined && err.faultstring.indexOf('INVALID_SESSION_ID') != -1) {
this.showToast('褰撳墠缃戦〉宸茬櫥鍑猴紝璇锋偍閲嶆柊鐧诲綍鍚庡埛鏂拌缃戦〉锛�','error');
@@ -134,7 +165,6 @@
}
return;
}
- this.updateRecordView(this.recordId);
});
// isopd.Id = "{!SolutionProjectRequirements__c.Id}";
// isopd.Submint_TF__c = true;
--
Gitblit v1.9.1