From 0eabcaed0d842cdf77a80edbe092fc0aaf6fff7a Mon Sep 17 00:00:00 2001
From: zhangzhengmei <zhangzhengmei@prec-tech.com>
Date: 星期一, 17 四月 2023 16:37:56 +0800
Subject: [PATCH] 调拨申请—》欠品发货 按钮修改
---
force-app/main/default/classes/TransferApplyWebService.cls | 214 ++++++++++++++++++++++++++++++++++++++++++
force-app/main/default/classes/TransferApplyWebService.cls-meta.xml | 5 +
force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.css | 11 ++
force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.html | 5 +
force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js-meta.xml | 11 ++
force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js | 39 +++++++
6 files changed, 285 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/classes/TransferApplyWebService.cls b/force-app/main/default/classes/TransferApplyWebService.cls
new file mode 100644
index 0000000..371adb6
--- /dev/null
+++ b/force-app/main/default/classes/TransferApplyWebService.cls
@@ -0,0 +1,214 @@
+global without sharing class TransferApplyWebService {
+ public TransferApplyWebService() {
+
+ }
+
+ @AuraEnabled
+ WebService static String submitApply(String taId) {
+ List<TransferApply__c> taList = [
+ SELECT Id
+ , Status__c
+ , Add_Approval_Status__c
+ , RecordType.DeveloperName //20201202 ljh add
+ , BeiPinWindow__c //20201202 ljh add
+ , Add_Reason__c // 20210429 1831 you
+ FROM TransferApply__c
+ WHERE Id = :taId
+ FOR UPDATE
+ ];
+ if (taList.isEmpty()) {
+ return '璋冩嫧鍗曚笉瀛樺湪銆�';
+ }
+ TransferApply__c ta = taList[0];
+ if(ta.Status__c != '鑽夋涓�' && ta.Add_Approval_Status__c != '鑽夋涓�'){
+ return '璇风‘璁よ皟鎷ㄥ崟鐘舵�侊紝娌℃湁寰呭鎵圭殑鏄庣粏锛屼笉鑳芥彁浜�';
+ }
+ List<String> errorList = checkTransferCount(ta.Id);
+ if(!errorList.isEmpty()) {
+ return String.join(errorList, '\n');
+ }
+ if(ta.Status__c == '鑽夋涓�') {
+
+ ta.Status__c = '濉啓瀹屾瘯';
+ }
+ else {
+
+ // 20210429 1831 you start
+ if(ta.Add_Approval_Status__c == '鑽夋涓�' && String.isBlank(ta.Add_Reason__c) ){
+ return '娌℃湁濉啓杩藉姞鐞嗙敱锛屼笉鑳芥彁浜�';
+ }else {// 20210429 1831 you end
+
+ ta.Add_Approval_Status__c = '濉啓瀹屾瘯';
+ }
+ }
+ //20201202 ljh OCSM_BP5-76 add start
+ if(ta.RecordType.DeveloperName == 'AgencyToCenter' && ta.BeiPinWindow__c == null){
+ return '璇风‘璁ゅ鎵逛汉锛屾病鏈夊鎵逛汉锛堝鍝佹�荤獥鍙o級锛屼笉鑳芥彁浜�';
+ }
+ //20201202 ljh OCSM_BP5-76 add end
+ Savepoint sp = Database.setSavepoint();
+ try {
+ update ta;
+ }
+ catch (Exception e) {
+ Database.rollback(sp);
+ return e.getMessage();
+ }
+ return '1';
+ }
+ public static List<String> checkTransferCount(Id taId) {
+ List<TransferApplyDetail__c> tadList = [
+ SELECT Id
+ , Asset__r.Ji_Zhong_Guan_Li_Ku_Cun__c
+ , Asset__r.TransferableAbandon_F__c
+ , Asset__r.TransferableRepair_F__c
+ , Asset__r.TransferableLost_F__c
+ , Asset__r.Name
+ , Asset__c
+ , Approved_F__c
+ , TransferType__c
+ , OneToOneAccessory__c
+ FROM TransferApplyDetail__c
+ WHERE TransferApply__c=:taId
+ AND Cancel_Select__c = false
+ ];
+
+ Map<Id, Integer> assCountMap = new Map<Id, Integer>(); // assetId->鏈夋晥搴撳瓨
+ Map<Id, Integer> assetAbanCntMap = new Map<Id, Integer>(); // 闈炰竴瀵逛竴闄勫睘鍝佸緟搴熷純鏁扮粺璁★紝淇濇湁璁惧Id->寰呭簾寮冭皟鎷ㄦ暟閲�
+ Map<Id, Integer> assetRepairCntMap = new Map<Id, Integer>(); // 闈炰竴瀵逛竴闄勫睘鍝佸緟搴熷純鏁扮粺璁★紝淇濇湁璁惧Id->寰呭簾寮冭皟鎷ㄦ暟閲�
+ Map<Id, Integer> assetLostCntMap = new Map<Id, Integer>(); // 闈炰竴瀵逛竴闄勫睘鍝佸緟搴熷純鏁扮粺璁★紝淇濇湁璁惧Id->寰呭簾寮冭皟鎷ㄦ暟閲�
+
+ Boolean needApprove = false;
+ for(TransferApplyDetail__c tad: tadList) {
+ if(!tad.Approved_F__c && !tad.OneToOneAccessory__c) {
+ Integer cnt = 0;
+ if(tad.TransferType__c == '寰呭簾寮�') {
+ if(assetAbanCntMap.containsKey(tad.Asset__c)){
+ cnt = assetAbanCntMap.get(tad.Asset__c);
+ }
+ cnt += 1;
+ assetAbanCntMap.put(tad.Asset__c, cnt);
+ }
+ else if(tad.TransferType__c == '寰呬慨鐞�'){
+ if(assetRepairCntMap.containsKey(tad.Asset__c)){
+ cnt = assetRepairCntMap.get(tad.Asset__c);
+ }
+ cnt += 1;
+ assetRepairCntMap.put(tad.Asset__c, cnt);
+ }
+ else if(tad.TransferType__c == '涓㈠け鎵惧洖'){
+ if(assetLostCntMap.containsKey(tad.Asset__c)){
+ cnt = assetLostCntMap.get(tad.Asset__c);
+ }
+ cnt += 1;
+ assetLostCntMap.put(tad.Asset__c, cnt);
+ }
+ else {
+ if(assCountMap.containsKey(tad.Asset__c)) {
+ cnt = assCountMap.get(tad.Asset__c);
+ }
+ cnt += 1;
+ assCountMap.put(tad.Asset__c, cnt);
+ }
+ if(!tad.Approved_F__c) {
+ needApprove = true;
+ }
+ }
+ }
+ Set<String> errorList = new Set<String>();
+ if(!needApprove) {
+ errorList.add('娌℃湁闇�瑕佸鎵圭殑鏄庣粏锛�');
+ }
+ for(TransferApplyDetail__c tad: tadList) {
+ if(assCountMap.containsKey(tad.Asset__c)
+ && assCountMap.get(tad.Asset__c) > intValueOf(tad.Asset__r.Ji_Zhong_Guan_Li_Ku_Cun__c)) {
+ String msg = tad.Asset__r.Name;
+ msg += '锛氭湁鏁堝簱瀛�=' + intValueOf(tad.Asset__r.Ji_Zhong_Guan_Li_Ku_Cun__c);
+ msg += '锛岃皟鎷ㄦ暟閲�=' + assCountMap.get(tad.Asset__c) ;
+ msg += '锛岃纭鏁伴噺鍚庢彁浜�';
+ errorList.add(msg);
+ }
+ if(assetRepairCntMap.containsKey(tad.Asset__c)
+ && assetRepairCntMap.get(tad.Asset__c) > intValueOf(tad.Asset__r.TransferableRepair_F__c)) {
+ String msg = tad.Asset__r.Name;
+ msg += '锛氬彲璋冩嫧鏁癬寰呬慨鐞�=' + intValueOf(tad.Asset__r.TransferableRepair_F__c);
+ msg += '锛屽緟淇悊璋冩嫧鏁伴噺=' + assetRepairCntMap.get(tad.Asset__c) ;
+ msg += '锛岃纭鏁伴噺鍚庢彁浜�';
+ errorList.add(msg);
+ }
+ if(assetAbanCntMap.containsKey(tad.Asset__c)
+ && assetAbanCntMap.get(tad.Asset__c) > intValueOf(tad.Asset__r.TransferableAbandon_F__c)) {
+ String msg = tad.Asset__r.Name;
+ msg += '锛氬彲璋冩嫧鏁癬寰呭簾寮�=' + intValueOf(tad.Asset__r.TransferableAbandon_F__c);
+ msg += '锛屽緟搴熷純璋冩嫧鏁伴噺=' + assetAbanCntMap.get(tad.Asset__c);
+ msg += '锛岃纭鏁伴噺鍚庢彁浜�';
+ errorList.add(msg);
+ }
+ if(assetLostCntMap.containsKey(tad.Asset__c)
+ && assetLostCntMap.get(tad.Asset__c) > intValueOf(tad.Asset__r.TransferableLost_F__c)) {
+ String msg = tad.Asset__r.Name;
+ msg += '锛氬彲璋冩嫧鏁癬涓㈠け鎵惧洖=' + intValueOf(tad.Asset__r.TransferableLost_F__c);
+ msg += '锛屽緟搴熷純璋冩嫧鏁伴噺=' + assetLostCntMap.get(tad.Asset__c);
+ msg += '锛岃纭鏁伴噺鍚庢彁浜�';
+ errorList.add(msg);
+ }
+ }
+ return new List<String>(errorList);
+ }
+
+ @AuraEnabled
+ WebService static String cancelApply(Id taId) {
+ List<TransferApply__c> taList = [
+ SELECT Id
+ , Add_Approval_Status__c
+ , Cancel_Reason__c
+ , OwnerId
+ , Status__c
+ , TA_Status__c
+ , Yi_loaner_arranged__c
+ , RecordType.DeveloperName
+ , Request_approval_time__c
+ FROM TransferApply__c
+ WHERE Id = :taId
+ FOR UPDATE
+ ];
+ if (taList.isEmpty()) {
+ return '璋冩嫧鍗曚笉瀛樺湪銆�';
+ }
+ TransferApply__c ta = taList[0];
+ if(ta.Status__c == '鍙栨秷') {
+ return '宸茬粡鍙栨秷锛屼笉鑳藉啀娆″彇娑�';
+ }
+ if(ta.Status__c == '鐢宠涓�' || ta.Add_Approval_Status__c == '鐢宠涓�'){
+ return '鐢宠涓笉鑳藉彇娑�';
+ }
+ if(ta.RecordType.DeveloperName == 'InsideCenter' && ta.Request_approval_time__c != null) {
+ return '鍚屽鍝佷腑蹇冨唴璋冩嫧鍦ㄦ渶缁堟壒鍑嗕箣鍚庝笉鍙互鍙栨秷';
+ }
+ if(ta.TA_Status__c == '宸插嚭搴�' || ta.Yi_loaner_arranged__c > 0) {
+ return '宸茬粡鍑哄簱锛屼笉鑳藉彇娑�';
+ }
+ if(UserInfo.getUserId() != ta.OwnerId) {
+ return '浠呭垱寤鸿�呭彲浠ュ彇娑�';
+ }
+ if(String.isBlank(ta.Cancel_Reason__c)) {
+ return '蹇呴』杈撳叆鍙栨秷鐞嗙敱';
+ }
+ Savepoint sp = Database.setSavepoint();
+ try {
+ ta.Status__c = '鍙栨秷';
+ update ta;
+ }
+ catch (Exception e) {
+ Database.rollback(sp);
+ return e.getMessage();
+ }
+ return '1';
+ }
+ private static Integer intValueOf(Decimal d) {
+ if(d == null) {
+ return 0;
+ }
+ return Integer.valueOf(d);
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/TransferApplyWebService.cls-meta.xml b/force-app/main/default/classes/TransferApplyWebService.cls-meta.xml
new file mode 100644
index 0000000..91b23b8
--- /dev/null
+++ b/force-app/main/default/classes/TransferApplyWebService.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>46.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.css b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.css
new file mode 100644
index 0000000..af18c76
--- /dev/null
+++ b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.css
@@ -0,0 +1,11 @@
+.Holder{
+ position: relative;
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ text-align: center;
+}
+
+.container .uiContainerManager{
+ display : none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.html b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.html
new file mode 100644
index 0000000..2ef2898
--- /dev/null
+++ b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.html
@@ -0,0 +1,5 @@
+<template>
+ <div class="Holder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js
new file mode 100644
index 0000000..5d79272
--- /dev/null
+++ b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js
@@ -0,0 +1,39 @@
+import { LightningElement, track, wire, api } from 'lwc';
+import {CurrentPageReference} from 'lightning/navigation';
+import { CloseActionScreenEvent } from 'lightning/actions';
+
+export default class lexLostReturnDeliverySlip extends LightningElement {
+ @api recordId;
+
+
+ @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;
+ }
+ }
+ }
+
+ connectedCallback(){
+
+ this.cancelSubmit().then(res=>{
+ this.IsLoading=false;
+ this.dispatchEvent(new CloseActionScreenEvent());
+ });
+ }
+
+ async cancelSubmit(){
+ window.open('/apex/Lost_Return_DeliverySlip?id='+this.recordId,'LostReturnDeliverySlip', 'width=600,height=200');
+ }
+
+ //old js
+ // window.open('/apex/Lost_Return_DeliverySlip?id={!TransferApply__c.Id}');
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js-meta.xml b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js-meta.xml
new file mode 100644
index 0000000..d8dfadb
--- /dev/null
+++ b/force-app/main/default/lwc/lexLostReturnDeliverySlip/lexLostReturnDeliverySlip.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexLostReturnDeliverySlip">
+ <apiVersion>51.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__AppPage</target>
+ <target>lightning__RecordPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ </targets>
+</LightningComponentBundle>
\ No newline at end of file
--
Gitblit v1.9.1