From ddb0231ef7c5cf2bad9d3f1afc2f733674ad38a5 Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期四, 24 八月 2023 14:50:51 +0800
Subject: [PATCH] 再修理按钮
---
force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js | 359 +++++++++++++++++++----------------------------------------
1 files changed, 114 insertions(+), 245 deletions(-)
diff --git a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
index d2dbda3..4e09ac0 100644
--- a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
+++ b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
@@ -1,258 +1,127 @@
-import { LightningElement,api, track, wire } from 'lwc';
-import {CurrentPageReference} from 'lightning/navigation';
+import { LightningElement, track, wire, api } from 'lwc';
+import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
-import init from '@salesforce/apex/SelectSubstituteControllerLWT.initFromLoanerArrangedEmailLButton';
-import selectRentalApplyCByName from '@salesforce/apex/SelectSubstituteControllerLWT.selectRentalApplyCByName';
-import selectRaesById1 from '@salesforce/apex/SelectSubstituteControllerLWT.selectRaesById1';
-import selectRaesById2 from '@salesforce/apex/SelectSubstituteControllerLWT.selectRaesById2';
-import getSessionId from '@salesforce/apex/SelectSubstituteControllerLWT.getSessionId';
-import approvalCheck from '@salesforce/apex/SelectSubstituteControllerLWT.approvalCheck';
-import setShipment_requests from '@salesforce/apex/SelectSubstituteControllerLWT.setShipment_requests';
-// import { label } from '@salesforce/label';
-import STATUS_PROCESS_STATE from '@salesforce/label/c.StatusProcessState';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { updateRecord } from 'lightning/uiRecordApi';
+
+import init from '@salesforce/apex/LexLoanerArrangedEmailController.init';
+import getRentalApplyEquipmentSet from '@salesforce/apex/LexLoanerArrangedEmailController.getRentalApplyEquipmentSet';
+import approvalCheck from '@salesforce/apex/RentalApplyWebService.approvalCheck';
+import setShipment_request from '@salesforce/apex/RentalApplyWebService.setShipment_request';
export default class lexLoanerArrangedEmail extends LightningElement {
-
@api recordId;
- id;
- RentalApplyC;
- Status;
- Wei_Assigned_Cnt__c;
- Bollow_Date__c;
- Assigned_Not_Shipment__c;
- IsLoading=true;
- @track statusStringg = STATUS_PROCESS_STATE;
+ IsLoading = true;
+
@wire(CurrentPageReference)
- getStateParameters(currentPageReference){
- console.log("杩涘叆椤甸潰");
- console.log(currentPageReference);
- if(currentPageReference){
- const urvalue=currentPageReference.state.recordId;
- if(urvalue){
- let str=`${urvalue}`;
- console.log('str');
- console.log(str);
- this.recordId=str;
+ getStateParameters(currentPageReference) {
+ if(currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if(urlValue) {
+ let str = `${urlValue}`;
+ this.recordId = str;
}
}
}
+ connectedCallback() {
-
- connectedCallback(){
- console.log(this.recordId);
- init({recordId:this.recordId}).then(result=>{
- console.log(result);
- if(result!=null){
- this.id=result.id;
- this.RentalApplyC=result.RentalApplyC;
- this.Status=result.Status;
- this.Wei_Assigned_Cnt__c=result.WeiAssignedCntC;
- this.Bollow_Date__c=result.BollowDateC;
- this.Assigned_Not_Shipment__c=result.AssignedNotShipmentC;
- this.cancelSubmit().then(res=>{
- this.IsLoading=false;
- this.dispatchEvent(new CloseActionScreenEvent());
- });
- }
- }).catch(err=>{
- console.log("error:");
- console.log(err);
- }).finally(()=>{
-
- });
- }
-
-
-
- async cancelSubmit(){
- let campaignStatus = '';
- let records = null; // 20220217 ljh OBPM甯傚満娲诲姩鑱斿姩
- console.log("Ff");
- let statusSting = "{!$Label.StatusProcessState}"; // 20220322 ljh add
- let statusList = statusSting.split(',');
- console.log(statusSting);
- console.log(statusList);
- console.log(this.statusStringg);
- let raliveryGood;
- await selectRentalApplyCByName({recordId:this.RentalApplyC})
- .then(res=>{
- console.log(res);
- if (res!=null) {
- raliveryGood=res;
+ init({
+ recordId: this.recordId
+ }).then(result => {
+ let id = result.id;
+ let statusArr = result.statusList;
+ console.log('result==='+JSON.stringify(result));
+ if(result != null) {
+ if( result.weiAssignedCnt > 0 ) {
+ this.showToast("鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟",'error');
+ }else if(result.campaignStatus == "鍙栨秷") {
+ this.showToast("瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�",'error');
+ }else if (result.raStatus == "宸插嚭搴撴寚绀�" && result.assignedNotShipment == 0){
+ this.showToast("鎵�鏈夌殑鍊熷嚭澶囧搧Set涓�瑙堥兘杩涜杩囧嚭搴撴寚绀轰簡",'error');
+ }else if (result.assignedNotShipment == 0) {
+ this.showToast("娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�",'error');
+ }else if (result.demoPurpose1 == "闀挎湡鍊熷嚭" && result.contractPdfUpdated == false){
+ this.showToast("闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功",'error');
+ }else if (result.repairId != '' && (result.repairFinalInspectionDateF != null && result.repairFinalInspectionDateF != '') || (result.rCReturnToOffice != null && result.rCReturnToOffice != '')){
+ this.showToast("淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�",'error');
+ }else if (result.iFApproved == true && (result.meetingApprovedNo == null || result.meetingApprovedNo == "")){
+ this.showToast("娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��",'error');
+ }else if (result.iFApproved == true && result.meetingApprovedNo != "" && statusArr.indexOf(result.approvedStatus) != -1){
+ this.showToast("宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�",'error');
+ }else{
+ approvalCheck({
+ rentalApplyId: this.recordId
+ }).then(res1 =>{
+ if (res1 != '1') {
+ this.showToast(res1,'error');
+ }else{
+ //bp2 var rs2 = sforce.apex.execute("RentalApplyWebService", "reserve", {rentalApplyId: raid});
+ //bp2 if (rs2 != '1') {
+ //bp2 alert(rs2);
+ //bp2 } else {
+ //var rs1 = sforce.apex.execute("RentalApplyWebService", "setShipment_request", {raid : "{!Rental_Apply__c.Id}"});
+ setShipment_request({
+ raid: this.recordId
+ }).then(res=>{
+ console.log('res==',res);
+ if (res == '鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�') {
+ this.showToast('鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�','success');
+ print();
+ this.updateRecordView(this.recordId);
+ return;
+ }else {
+ console.log('else==',res);
+ const evt = new ShowToastEvent({
+ title: 'Error',
+ message:res,
+ variant: 'error'
+ });
+ this.dispatchEvent(evt);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ }).catch(e=>{
+ console.log('approvalCheck==='+e);
+ })
+ }
+ }).catch(e=>{
+ console.log('setShipment_request==='+e);
+ })
}
- }).catch(err=>{
- console.log("selectRentalApplyCByName err:")
- console.log(err.message);
- });
- console.log(statusSting);
- console.log(raliveryGood);
- console.log("ddd");
- let RentalApply = raliveryGood[0];
- console.log(RentalApply);
-
- if(RentalApply.Campaign__c != null&&RentalApply.Campaign__c != '' ) {
- console.log();
- let DeliveryGood;
- // 20220217 ljh update OBPM甯傚満娲诲姩鑱斿姩 start
- // DeliveryGood = sforce.connection.query("select Status, Rental_Apply_Flag__c from Campaign where id ='" + RentalApply.Campaign__c + "'");
- // let records= DeliveryGood.getArray("records");
- await selectCampaignById({recordId:RentalApply.Campaign__c}).then(res=>{
- console.log(res);
- DeliveryGood=res;
- });
- console.log(RentalApply);
- records = DeliveryGood;
- console.log(DeliveryGood);
- // 20220217 ljh update OBPM甯傚満娲诲姩鑱斿姩 end
-
- campaignStatus = records[0].Status;
- console.log("hh3");
- }
- if(this.Wei_Assigned_Cnt__c > "0") {
- // alert("鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟"
- });
- this.dispatchEvent(event);
- }else if(campaignStatus == '鍙栨秷'){
- // alert("瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�"
- });
- this.dispatchEvent(event);
- }else if (this.Assigned_Not_Shipment__c == "0") {
- // alert("娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�"
- });
- this.dispatchEvent(event);
- } else if (RentalApply.Demo_purpose1__c == "闀挎湡鍊熷嚭" && RentalApply.Contract_pdf_updated__c == "0") {
- // alert("闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功"
- });
- this.dispatchEvent(event);
- } else if(RentalApply.Repair__c != '' && RentalApply.Repair__c != null && (RentalApply.Repair_Final_Inspection_Date_F__c != null && RentalApply.Repair_Final_Inspection_Date_F__c != '') || (RentalApply.RC_return_to_office__c != null && RentalApply.RC_return_to_office__c != '')) {
- // alert("淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�"
- });
- this.dispatchEvent(event);
- // 20220217 ljh add OBPM甯傚満娲诲姩鑱斿姩 start
- } else if (records != null && records[0].IF_Approved__c == "true" && (records[0].Meeting_Approved_No__c == null || records[0].Meeting_Approved_No__c == "") ) {
- // alert("娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��"
- });
- this.dispatchEvent(event);
- } else if (records != null && records[0].IF_Approved__c == "true" && records[0].Meeting_Approved_No__c != "" && statusList.indexOf(records[0].Approved_Status__c) != -1 ) {
- // alert("宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�"
- });
- this.dispatchEvent(event);
- // 20220217 ljh add OBPM甯傚満娲诲姩鑱斿姩 end
- } else {
- console.log("hhhh3");
- let t=await getSessionId();
- console.log(t);
- window.sforce = window.sforce || {};
- window.sforce.connection = window.sforce.connection || {};
- window.sforce.connection.sessionId =t;
- //154p 1388 yc 20211020
- console.log("hhhh4");
- let raid = RentalApply.Id+";"+this.id;
- console.log(raid);
- let rs1 = await approvalCheck({rentalApplyId:raid});
- console.log(rs1);
- if (rs1 != '1') {
- // alert(rs1);
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:rs1
- });
- this.dispatchEvent(event);
- } else {
- //bp2 let rs2 = sforce.apex.execute("RentalApplyWebService", "reserve", {rentalApplyId: raid});
- //bp2 if (rs2 != '1') {
- //bp2 alert(rs2);
- //bp2 } else {
- setShipment_requests({raid:null,raesid: this.id}).then(res=>{
- if (res == "鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�") {
- // alert("鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�");
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:"鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�"
- });
- this.dispatchEvent(event);
- print().then(res=>{
- setTimeout(function() {location.href = "/"+this.RentalApplyC;}, 100);
- });
- } else {
- // alert(res);
- const event = new ShowToastEvent({
- title: '鎻愮ず淇℃伅',
- message:res
- });
- this.dispatchEvent(event);
- }
- })
- // sforce.apex.execute("RentalApplyWebService", "setRaesShipment_request",
- // {raesid: this.id}
- // ,function(res) {
- // if (res == "鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�") {
- // alert("鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�");
- // print().then(res=>{
- // setTimeout(function() {location.href = "/"+this.RentalApplyC;}, 100);
- // });
- // } else {
- // alert(res);
- // }
- // });
}
- }
-
- async function print(){
- let sqlResult;
- if(this.Bollow_Date__c != ''){
- await selectRaesById1({recordId:RentalApply.Id}).then(res=>{
- sqlResult=res;
- });
- }else{
- await selectRaesById2({recordId:RentalApply.Id}).then(res=>{
- sqlResult=res;
- });
- }
- let records = sqlResult;
- let size =records.length;
- let length = size%10 ==0? size/10 : parseInt(size/10) +1;
- for(let i =0;i<length;i++){
- window.open('/apex/FixtureRentalPDF?raid=' + RentalApply.Id + '&page=' + i);
- }
- }
-
-
- // function fixTime(time){
- // if(time < 10) {time = "0" + time};
- // return time;
- // }
-
- // function fixDate(date){
- // let Month = fixTime(date.getMonth() + 1);
- // let Day = fixTime(date.getDate());
- // let UTC = date.toUTCString();
- // let Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
- // let Minutes = fixTime(date.getMinutes());
- // let Seconds = fixTime(date.getSeconds());
- // return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
- // }
+ })
}
-}
+
+ print() {
+ getRentalApplyEquipmentSet({
+ recordId: this.recordId
+ }).then(result => {
+ window.open("/apex/FixtureRentalPDF?raid=" + this.recordId + "&page=" + result);
+ })
+ }
+
+ fixDate(date){
+ var Month = fixTime(date.getMonth() + 1);
+ var Day = fixTime(date.getDate());
+ var UTC = date.toUTCString();
+ var Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
+ var Minutes = fixTime(date.getMinutes());
+ var Seconds = fixTime(date.getSeconds());
+ return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
+ }
+
+ showToast(msg,type) {
+ const event = new ShowToastEvent({
+ message: msg,
+ variant: type
+ });
+ if(type == 'success'){
+ this.updateRecordView(this.recordId);
+ }
+ this.dispatchEvent(event);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1