From e4e82928f141bd7b580e33289412dfd9bea821f8 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期二, 25 七月 2023 15:24:22 +0800
Subject: [PATCH] review修改以及修改附件

---
 force-app/main/default/classes/AttachmentReQisHandler.cls               |  103 ++++++++++--
 force-app/main/default/triggers/ContentDocumentLink.trigger             |   75 +++++++++
 force-app/main/default/classes/AttachmentReQisHandlerTest.cls           |  158 +++++++++++++++++++
 force-app/main/default/pages/MaintenanceProductData.page                |   62 +++++--
 force-app/main/default/classes/AttachmentReQisHandler.cls-meta.xml      |    2 
 force-app/main/default/pages/SubAuthorizedCreate.page                   |    3 
 force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js |   10 +
 force-app/main/default/pages/MaintenanceProductDataManage.page          |   10 +
 force-app/main/default/triggers/ContentDocumentLink.trigger-meta.xml    |    5 
 force-app/main/default/classes/AttachmentReQisHandlerTest.cls-meta.xml  |    5 
 force-app/main/default/classes/StaticParameter.cls                      |    3 
 force-app/main/default/pages/DiscountProductApplication.page            |    4 
 12 files changed, 394 insertions(+), 46 deletions(-)

diff --git a/force-app/main/default/classes/AttachmentReQisHandler.cls b/force-app/main/default/classes/AttachmentReQisHandler.cls
index 86d17c1..ed28a02 100644
--- a/force-app/main/default/classes/AttachmentReQisHandler.cls
+++ b/force-app/main/default/classes/AttachmentReQisHandler.cls
@@ -5,18 +5,18 @@
  */
 public without sharing class AttachmentReQisHandler extends Oly_TriggerHandler{
     @TestVisible
-    private Map<Id, Attachment> newMap;
+    private Map<Id, ContentDocumentLink> newMap;
     @TestVisible
-    private Map<Id, Attachment> oldMap;
+    private Map<Id, ContentDocumentLink> oldMap;
     @TestVisible
-    private List<Attachment> newList;
+    private List<ContentDocumentLink> newList;
     @TestVisible
-    private List<Attachment> oldList;
+    private List<ContentDocumentLink> oldList;
     public AttachmentReQisHandler() {
-        this.newMap = (Map<Id, Attachment>) Trigger.newMap;
-        this.oldMap = (Map<Id, Attachment>) Trigger.oldMap;
-        this.newList = (List<Attachment>) Trigger.new;
-        this.oldList = (List<Attachment>) Trigger.old;
+        this.newMap = (Map<Id, ContentDocumentLink>) Trigger.newMap;
+        this.oldMap = (Map<Id, ContentDocumentLink>) Trigger.oldMap;
+        this.newList = (List<ContentDocumentLink>) Trigger.new;
+        this.oldList = (List<ContentDocumentLink>) Trigger.old;
     }
     @TestVisible
     protected override void afterInsert() {
@@ -24,19 +24,32 @@
         NoteMail();
     }
     private void NoteMail() {
+        List<Id> linkIdList = new List<Id>();
+        for (ContentDocumentLink link : newList) {
+            linkIdList.add(link.Id);
+        }
+        newList = [select Id,LinkedEntityId,ContentDocumentId from ContentDocumentLink where Id in: linkIdList];
         String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
         List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>();
         List<String> Rlist = new List<String>();
         List<String> ParentIdList = new List<String>();
         // QisID
-        for (Attachment att : newList) {
-            if(String.valueOf(att.ParentId).startsWith('a0J') 
-                || String.valueOf(att.ParentId).startsWith('a0f')){
-                Rlist.add(att.Id);
-                ParentIdList.add(att.ParentId);
+        for (ContentDocumentLink link : newList) {
+            if(String.valueOf(link.LinkedEntityId).startsWith('a0J') 
+                || String.valueOf(link.LinkedEntityId).startsWith('a0f')){
+                Rlist.add(link.ContentDocumentId);
+                ParentIdList.add(link.LinkedEntityId);
             }
         }
-        List<Attachment> NtList = [Select id,ParentId,Name,Body FROM Attachment where Id in : Rlist];
+        // for (Attachment att : newList) {
+        //     if(String.valueOf(att.ParentId).startsWith('a0J') 
+        //         || String.valueOf(att.ParentId).startsWith('a0f')){
+        //         Rlist.add(att.Id);
+        //         ParentIdList.add(att.ParentId);
+        //     }
+        // }
+        // List<Attachment> NtList = [Select id,ParentId,Name,Body FROM Attachment where Id in : Rlist];
+        List<ContentVersion> verList = [select Id,Title,VersionData,ContentDocumentId from ContentVersion where ContentDocumentId in: Rlist];
         Map<Id,Repair__c> updateRprMap = new Map<Id,Repair__c>();
         Map<Id,QIS_Report__c> updateQisMap = new Map<Id,QIS_Report__c>();
         for (Repair__c re :[select id,Name,SerialNumber__c,Delivered_Product__r.Name,HP_Name__c
@@ -61,11 +74,12 @@
             }
         }
         List<User> userList = [select Id, Name, Email, Manager.Email from User where id IN :IdList];
-        for (Attachment nt : NtList) {
-            String titName = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).Name : updateQisMap.get(nt.ParentId).Name;
-            String prname = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).Delivered_Product__r.Name : updateQisMap.get(nt.ParentId).nonyushohin__r.Name;
-            String Serial = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).SerialNumber__c : updateQisMap.get(nt.ParentId).lot_or_serial__c;
-            String accountname = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).HP_Name__c : updateQisMap.get(nt.ParentId).Hospital__r.Name;
+        for (ContentVersion version : verList) {
+            ContentDocumentLink link = [select LinkedEntityId from ContentDocumentLink where ContentDocumentId =: version.ContentDocumentId limit 1];
+            String titName = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).Name : updateQisMap.get(link.LinkedEntityId).Name;
+            String prname = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).Delivered_Product__r.Name : updateQisMap.get(link.LinkedEntityId).nonyushohin__r.Name;
+            String Serial = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).SerialNumber__c : updateQisMap.get(link.LinkedEntityId).lot_or_serial__c;
+            String accountname = updateRprMap.containsKey(link.LinkedEntityId)? updateRprMap.get(link.LinkedEntityId).HP_Name__c : updateQisMap.get(link.LinkedEntityId).Hospital__r.Name;
             String title = '';
             String body = '';
             title = '銆愪慨鐞�/QIS銆戯細' + titName + '宸叉柊澧為檮浠讹紝璇锋煡鐪�';
@@ -75,12 +89,12 @@
             body += '<br/>';
             body += '鏈鸿韩鍙�/鎵瑰彿 锛�' + Serial;
             body += '<br/>';
-            body += '闄勪欢鍚嶇О/澶囨敞鍚嶇О锛�' + nt.Name;
+            body += '闄勪欢鍚嶇О/澶囨敞鍚嶇О锛�' + version.Title;
             body += '<br/>';
             body += '鎿嶄綔鎷呭綋锛�' + UserInfo.getName();
             body += '<br/>';
             body += '<br/>';
-            body += '閾炬帴锛�' + baseUrl + '/' + nt.ParentId +' ';
+            body += '閾炬帴锛�' + baseUrl + '/' + link.LinkedEntityId +' ';
             //鏀朵欢閭
             List<String> toMailList = new List<String>();
             String uId = UserInfo.getUserId();
@@ -91,8 +105,9 @@
             }
             //鎶勯�佺殑閭
             List<String> ccMailList = new List<String>();
-            ccMailList.add('gaozhangwei@prec-tech.com');
-            ccMailList.add('wei_liang@olympus.com.cn');
+            // ccMailList.add('gaozhangwei@prec-tech.com');
+            // ccMailList.add('wei_liang@olympus.com.cn');
+            ccMailList.add('chenjingwu@prec-tech.com');
             Messaging.SingleEmailMessage messageNEW = new Messaging.SingleEmailMessage();
             messageNEW.subject = title;
             messageNEW.htmlBody = body;
@@ -103,6 +118,48 @@
             }
             sendMails.add(messageNEW);
         }
+        // for (Attachment nt : NtList) {
+        //     String titName = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).Name : updateQisMap.get(nt.ParentId).Name;
+        //     String prname = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).Delivered_Product__r.Name : updateQisMap.get(nt.ParentId).nonyushohin__r.Name;
+        //     String Serial = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).SerialNumber__c : updateQisMap.get(nt.ParentId).lot_or_serial__c;
+        //     String accountname = updateRprMap.containsKey(nt.ParentId)? updateRprMap.get(nt.ParentId).HP_Name__c : updateQisMap.get(nt.ParentId).Hospital__r.Name;
+        //     String title = '';
+        //     String body = '';
+        //     title = '銆愪慨鐞�/QIS銆戯細' + titName + '宸叉柊澧為檮浠讹紝璇锋煡鐪�';
+        //     body += '鐢ㄦ埛鍚嶏細' + accountname;
+        //     body += '<br/>';
+        //     body += '浜у搧鍚嶇О/鍨嬪彿 锛�' + prname;
+        //     body += '<br/>';
+        //     body += '鏈鸿韩鍙�/鎵瑰彿 锛�' + Serial;
+        //     body += '<br/>';
+        //     body += '闄勪欢鍚嶇О/澶囨敞鍚嶇О锛�' + nt.Name;
+        //     body += '<br/>';
+        //     body += '鎿嶄綔鎷呭綋锛�' + UserInfo.getName();
+        //     body += '<br/>';
+        //     body += '<br/>';
+        //     body += '閾炬帴锛�' + baseUrl + '/' + nt.ParentId +' ';
+        //     //鏀朵欢閭
+        //     List<String> toMailList = new List<String>();
+        //     String uId = UserInfo.getUserId();
+        //     for (User u : userList) {
+        //         if (u.Id != uId) {
+        //             toMailList.add(u.Email);
+        //         }
+        //     }
+        //     //鎶勯�佺殑閭
+        //     List<String> ccMailList = new List<String>();
+        //     ccMailList.add('gaozhangwei@prec-tech.com');
+        //     ccMailList.add('wei_liang@olympus.com.cn');
+        //     Messaging.SingleEmailMessage messageNEW = new Messaging.SingleEmailMessage();
+        //     messageNEW.subject = title;
+        //     messageNEW.htmlBody = body;
+        //     messageNEW.setCharset('UTF-8');
+        //     messageNEW.toAddresses = toMailList;
+        //     if(ccMailList.size() > 0){
+        //         messageNEW.ccAddresses = ccMailList;
+        //     }
+        //     sendMails.add(messageNEW);
+        // }
         //鍦ㄥ崟涓簨鍔′腑锛屽彧鑳借皟鐢╯end鏂规硶 10 娆°��
         Messaging.SendEmailResult[] results = messaging.sendEmail(sendMails);
     }
diff --git a/force-app/main/default/classes/AttachmentReQisHandler.cls-meta.xml b/force-app/main/default/classes/AttachmentReQisHandler.cls-meta.xml
index f3bac1f..800e53c 100644
--- a/force-app/main/default/classes/AttachmentReQisHandler.cls-meta.xml
+++ b/force-app/main/default/classes/AttachmentReQisHandler.cls-meta.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
-    <apiVersion>41.0</apiVersion>
+    <apiVersion>43.0</apiVersion>
     <status>Active</status>
 </ApexClass>
diff --git a/force-app/main/default/classes/AttachmentReQisHandlerTest.cls b/force-app/main/default/classes/AttachmentReQisHandlerTest.cls
new file mode 100644
index 0000000..c160159
--- /dev/null
+++ b/force-app/main/default/classes/AttachmentReQisHandlerTest.cls
@@ -0,0 +1,158 @@
+@isTest
+private class AttachmentReQisHandlerTest {
+    private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+    static testMethod void testMethod1() {
+        // 鐥呴櫌銈掍綔銈�
+        Account hospital = new Account();
+        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+        hospital.Name = 'test hospital';
+        insert hospital;
+        
+        // 鎴︾暐绉戝銈掑緱銈�
+        List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+        
+        // 瑷虹檪绉戙倰浣溿倠
+        Account dep = new Account();
+        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+        dep.Name = 'test dep';
+        dep.ParentId = strategicDep[0].Id;
+        dep.Department_Class__c = strategicDep[0].Id;
+        dep.Hospital__c = hospital.Id;
+        insert dep;
+        
+        // 瑁藉搧銈掍綔銈�
+        Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�');
+        insert productA;
+        
+        // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠     
+        PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+        entry.UnitPrice = 0;
+        entry.IsActive = true;
+        entry.UseStandardPrice = false;
+        entry.CurrencyIsoCode = 'CNY';
+        entry.Product2Id = productA.Id;
+        insert entry;
+        
+        // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+        Asset asset = new Asset();
+        asset.Name = '銉嗐偣銉堟鍣�';
+        asset.AccountId = dep.Id;
+        asset.Department_Class__c = strategicDep[0].Id;
+        asset.Hospital__c = hospital.Id;
+        asset.SerialNumber = 'testserial';
+        insert asset;
+        
+        // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+        Maintenance_Contract__c contract = new Maintenance_Contract__c();
+        contract.Name = 'tect contract';
+        contract.Hospital__c = hospital.Id;
+        contract.Department_Class__c = strategicDep[0].Id;
+        contract.Department__c = dep.Id;
+        insert contract;
+        
+        // 淇悊銈掍綔鎴愩仚銈�
+        Repair__c repair = new Repair__c();
+        repair.Account__c = dep.Id;
+        repair.Department_Class__c = strategicDep[0].Id;
+        repair.Hospital__c = hospital.Id;
+        repair.Delivered_Product__c = asset.Id;
+        insert repair;
+        // Attachment att = new Attachment(
+        //     Name = 'test',
+        //     ParentId = repair.Id,
+        //     Body = EncodingUtil.base64Decode('test')
+        // );
+        ContentVersion version = new ContentVersion(
+            Title = 'test',
+            VersionData = EncodingUtil.base64Decode('test'),
+            ContentLocation = 's',
+            PathOnClient = 'test.txt'
+        );
+        insert version;
+        version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
+        ContentDocumentLink link = new ContentDocumentLink();
+        link.ContentDocumentId = version.ContentDocumentId;
+        link.LinkedEntityId = repair.Id;
+        link.ShareType = 'I';
+        link.Visibility = 'AllUsers';
+        insert link;
+
+    }
+    // 瑕嗙洊鐜囪ˉ鍏�
+    static testMethod void testMethod2() {
+        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+        if (rectCo.size() == 0) {
+            return;
+        }
+        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
+        if (rectSct.size() == 0) {
+            return;
+        }
+        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'];
+        if (rectDpt.size() == 0) {
+            return;
+        }
+        StaticParameter.EscapeOpportunityBefUpdTrigger = true;
+        StaticParameter.EscapeSyncOpportunityTrigger = true;
+        StaticParameter.EscapeNFM007Trigger = true;
+        StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
+        StaticParameter.EscapeSyncOpportunityTrigger = true;
+
+        // 銉嗐偣銉堛儑銉笺偪
+        Account company = new Account();
+        company.RecordTypeId = rectCo[0].Id;
+        company.Name         = 'NFM007TestCompany';
+        upsert company;
+        Account section = new Account();
+        section.RecordTypeId = rectSct[0].Id;
+        section.Name         = '*';
+        section.Department_Class_Label__c = '娑堝寲绉�';
+        section.ParentId                  = company.Id;
+        section.Hospital_Department_Class__c = company.Id;
+        upsert section;
+        Account depart = new Account();
+        depart.RecordTypeId = rectDpt[0].Id;
+        depart.Name         = '*';
+        depart.Department_Name__c  = 'NFM007TestDepart';
+        depart.ParentId            = section.Id;
+        depart.Department_Class__c = section.Id;
+        depart.Hospital__c         = company.Id;
+        upsert depart;
+
+        Opportunity opp = new Opportunity();
+        opp.AccountId           = depart.Id;
+        opp.Department_Class__c = section.Id;
+        opp.Hospital__c         = company.Id;
+        opp.SAP_Send_OK__c      = false;
+        opp.Name                = 'GZ-SP-NFM007_1';
+        opp.Trade__c            = '鍐呰部';
+        opp.StageName           = '寮曞悎';
+        opp.CloseDate           = Date.today().adddays(1);
+        opp.Stock_apply_status__c = '鐢宠涓�';
+        insert opp;
+
+        Opportunity_File__c ofile = new Opportunity_File__c();
+        ofile.Name = 'test file';
+        ofile.Opportunity__c = opp.Id;
+        ofile.Oppor_File_Stage__c = 'G';
+        insert ofile;
+
+        ContentVersion version = new ContentVersion(
+            Title = 'test',
+            VersionData = EncodingUtil.base64Decode('test'),
+            ContentLocation = 's',
+            PathOnClient = 'test.txt'
+        );
+        insert version;
+        version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
+        ContentDocumentLink link = new ContentDocumentLink();
+        link.ContentDocumentId = version.ContentDocumentId;
+        link.LinkedEntityId = ofile.Id;
+        link.ShareType = 'I';
+        link.Visibility = 'AllUsers';
+        insert link;
+
+        delete ofile;
+
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/AttachmentReQisHandlerTest.cls-meta.xml b/force-app/main/default/classes/AttachmentReQisHandlerTest.cls-meta.xml
new file mode 100644
index 0000000..45cccbd
--- /dev/null
+++ b/force-app/main/default/classes/AttachmentReQisHandlerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>57.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
\ No newline at end of file
diff --git a/force-app/main/default/classes/StaticParameter.cls b/force-app/main/default/classes/StaticParameter.cls
index 7a03c79..02872c6 100644
--- a/force-app/main/default/classes/StaticParameter.cls
+++ b/force-app/main/default/classes/StaticParameter.cls
@@ -66,7 +66,8 @@
 
     // 棰勬祴璺宠繃璇环鍜屾敞娈�
     public static Boolean EscapeOppandStaTrigger = false;
-
+    //璺宠繃鏂囨。閾炬帴鎺ュ彛
+    public static Boolean ContentDocumentLink = true;
     public StaticParameter(){
     }
 
diff --git a/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js
index b0deed5..23ea464 100644
--- a/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js
+++ b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js
@@ -1,3 +1,11 @@
+/*
+ * @Description: 
+ * @version: 
+ * @Author: chen jing wu
+ * @Date: 2023-06-15 09:52:50
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-07-25 09:16:27
+ */
 import { api, wire,LightningElement } from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
 import { CloseActionScreenEvent } from 'lightning/actions';
@@ -6,7 +14,7 @@
 import { NavigationMixin } from 'lightning/navigation';
 import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
 
-export default class LexNewAgencyHospital extends LightningElement {
+export default class LexNewAgencyHospital extends NavigationMixin(LightningElement) {
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
             console.log(111);
diff --git a/force-app/main/default/pages/DiscountProductApplication.page b/force-app/main/default/pages/DiscountProductApplication.page
index bea6893..59cdfef 100644
--- a/force-app/main/default/pages/DiscountProductApplication.page
+++ b/force-app/main/default/pages/DiscountProductApplication.page
@@ -1,4 +1,4 @@
-<apex:page standardController="DiscountProductApplication__c" extensions="DiscountProductApplicationController"  action="{!init}"  showHeader="false"   sidebar="true" id="dpaPage"  title="鐗逛环浜у搧鐢宠淇℃伅">
+<apex:page standardController="DiscountProductApplication__c" extensions="DiscountProductApplicationController"  action="{!init}"  showHeader="false"   sidebar="true" id="dpaPage"  title="鐗逛环浜у搧鐢宠淇℃伅" lightningStylesheets="true">
 <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
 <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
 <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
@@ -109,7 +109,7 @@
         <apex:actionFunction name="search" action="{!searchAllProduct2}" oncomplete="unblockUI();" reRender="ConsumableorderdetailsSection,message" />
         <apex:pageBlock title="鐗逛环浜у搧鐢宠淇℃伅" id="dpaBlock" >
             <apex:pageBlockButtons location="top"  >
-                <apex:commandButton value="淇濆瓨" disabled="{!IF(dpa.ApplicationStatus__c='鐢宠涓�'||dpa.ApplicationStatus__c='鎵瑰噯'||dpa.ApplicationStatus__c='椹冲洖',true,false)}" onclick="blockme();" style="margin-left:30px;width:100px" action="{!savesaveDiscountProduct}" onComplete="unblockUI();CheckStatusAfter();" reRender="ConsumableorderdetailsSection,message"/>
+                <apex:commandButton value="淇濆瓨" disabled="{!IF(dpa.ApplicationStatus__c='鐢宠涓�'||dpa.ApplicationStatus__c='鎵瑰噯'||dpa.ApplicationStatus__c='椹冲洖',true,false)}" onclick="blockme();" style="margin-left:30px;width:100px;float: left;" action="{!savesaveDiscountProduct}" onComplete="unblockUI();CheckStatusAfter();" reRender="ConsumableorderdetailsSection,message"/>
             </apex:pageBlockButtons>
             <table style="width: 900px;margin: auto;">
                 <tr>
diff --git a/force-app/main/default/pages/MaintenanceProductData.page b/force-app/main/default/pages/MaintenanceProductData.page
index 9c5e8cc..0f53402 100644
--- a/force-app/main/default/pages/MaintenanceProductData.page
+++ b/force-app/main/default/pages/MaintenanceProductData.page
@@ -21,6 +21,17 @@
     td.dataCol.first.last{
         width: 100%
     }
+    body .pbBody table.list tr th, body .pbBody table.list tr td {
+    border: 1px solid #ededed;
+    white-space: nowrap;
+}
+    body .pbBody table.list tr.headerRow td,body .pbBody table.list tr.headerRow th {
+        background: #f2f3f3;
+        border-width: 0 0 1px 1px;
+        border-color: #e0e3e5;
+        font-size: .9em;
+        font-weight: bold;
+    }
 </style>
 <script>
     function refreshPageSizeJs() {
@@ -957,9 +968,9 @@
             <div style="float: left;width: 95%;overflow:auto;">
             <table class="list" border="0" cellpadding="0" cellspacing="0" width="100%"  >
                 <tr class="headerRow">
-                    <th rowspan = "2">鏈�夋嫨鐨勪骇鍝�<br/>閫変腑鏁版嵁鎵归噺淇敼</th>
+                    <th rowspan = "2" style="min-width: 100px">鏈�夋嫨鐨勪骇鍝�<br/>閫変腑鏁版嵁鎵归噺淇敼</th>
                     <apex:repeat value="{!title}" var="t">
-                    <th><apex:outputText value="{!t}"/></th>
+                    <th style="min-width: 100px"><apex:outputText value="{!t}"/></th>
                     </apex:repeat>
                 </tr>
                 <!-- 閲嶇偣浜у搧缁存姢 -->
@@ -1157,7 +1168,7 @@
             </table>
             </div>
             <div style="float: right;width:4%;position:relative;" >
-                <button type="button" onclick="moreChange();"  style="width:100%;display:inline-block;height:30px;margin-top:15px;">纭畾</button>             
+                <button type="button" onclick="moreChange();"  style="width: 100%;display: inline-block;height: 30px;margin-top: 30px;border-radius: .25rem;color: rgba(1, 118, 211, 1);background-color: white;border-width: 1px;border-color: rgb(201, 201, 201);border-style: double;">纭畾</button>             
             </div> 
             <div style="clear: both;"></div> 
         </apex:pageBlock>
@@ -1199,7 +1210,7 @@
             </table>
             </div>
             <div style="float: right;width:4%;position:relative;" >
-                <button type="button" onclick="ServiceMoreChange();"  style="width:100%;display:inline-block;height:30px;margin-top:15px;">纭畾</button>             
+                <button type="button" onclick="ServiceMoreChange();"  style="width: 100%;display: inline-block;height: 30px;margin-top: 30px;border-radius: .25rem;color: rgba(1, 118, 211, 1);background-color: white;border-width: 1px;border-color: rgb(201, 201, 201);border-style: double;">纭畾</button>             
             </div> 
             <div style="clear: both;"></div> 
         </apex:pageBlock>
@@ -1215,21 +1226,38 @@
                 <input type="hidden" id="allPage:allForm:allBlock:edmpdDetails:mpdDetailsRecordsCount" value="{!mpdDetailsRecordsCount}" />
                     <table class="list" border="0" cellpadding="0" cellspacing="0">
                         <tr class="headerRow">
-                            <apex:variable var="v" value="" rendered="{!IF(editAble&&RecordTypeName='GuranteeMain'&&mpd.Status__c='鏈嶅姟濉啓',true,false)}">
-                               <th>閫夋嫨</th>
+                            <apex:variable var="q" value="" rendered="{!IF(editAble,true,false)}">
+                                <apex:variable var="v" value="" rendered="{!IF(editAble&&RecordTypeName='GuranteeMain'&&mpd.Status__c='鏈嶅姟濉啓',true,false)}">
+                                <th>閫夋嫨</th>
+                                </apex:variable>
+                                <th>浜у搧鍚嶇О</th>
+                                <th>浜у搧缂栫爜</th> 
+                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
+                                <th>澶氬勾淇濅慨绫诲瀷</th> 
+                                </apex:variable>                          
+                                <apex:repeat value="{!title}" var="t">
+                                <th><apex:outputText value="{!t}"/></th>
+                                </apex:repeat>
+                                <apex:variable var="type" value="" rendered="{!IF(editAble&&!(RecordTypeName='GuranteeMain'&&mpd.Status__c='鏈嶅姟濉啓'),true,false)}"> 
+                                <th>鎿嶄綔</th>
+                                </apex:variable>
                             </apex:variable>
-                            <th>浜у搧鍚嶇О</th>
-                            <th>浜у搧缂栫爜</th> 
-                            <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
-                            <th>澶氬勾淇濅慨绫诲瀷</th> 
-                            </apex:variable>                          
-                            <apex:repeat value="{!title}" var="t">
-                            <th><apex:outputText value="{!t}"/></th>
-                            </apex:repeat>
-                            <apex:variable var="type" value="" rendered="{!IF(editAble&&!(RecordTypeName='GuranteeMain'&&mpd.Status__c='鏈嶅姟濉啓'),true,false)}"> 
-                            <th>鎿嶄綔</th>
+                            <apex:variable var="q" value="" rendered="{!IF(editAble,false,true)}">
+                                <apex:variable var="v" value="" rendered="{!IF(editAble&&RecordTypeName='GuranteeMain'&&mpd.Status__c='鏈嶅姟濉啓',true,false)}">
+                                <th>閫夋嫨</th>
+                                </apex:variable>
+                                <th style="min-width: 130px;">浜у搧鍚嶇О</th>
+                                <th style="min-width: 130px;">浜у搧缂栫爜</th> 
+                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
+                                <th>澶氬勾淇濅慨绫诲瀷</th> 
+                                </apex:variable>                          
+                                <apex:repeat value="{!title}" var="t">
+                                <th style="min-width: 130px;"><apex:outputText value="{!t}"/></th>
+                                </apex:repeat>
+                                <apex:variable var="type" value="" rendered="{!IF(editAble&&!(RecordTypeName='GuranteeMain'&&mpd.Status__c='鏈嶅姟濉啓'),true,false)}"> 
+                                <th>鎿嶄綔</th>
+                                </apex:variable>
                             </apex:variable>
-
                         </tr>
                         <apex:repeat value="{!mpdDetailsRecords}" var="aa" id="bb"> 
                             <tr>
diff --git a/force-app/main/default/pages/MaintenanceProductDataManage.page b/force-app/main/default/pages/MaintenanceProductDataManage.page
index 44d9d32..8712988 100644
--- a/force-app/main/default/pages/MaintenanceProductDataManage.page
+++ b/force-app/main/default/pages/MaintenanceProductDataManage.page
@@ -1,10 +1,14 @@
-<apex:page standardController="Maintenance_Product_Data__c" showHeader="false" sidebar="false">
+<apex:page standardController="Maintenance_Product_Data__c" showHeader="true" sidebar="true" lightningStylesheets="true">
     <script type="text/javascript">
         function init() {
 //          var test = window.location.search;
             var str = '/apex/MaintenanceProductData?cpn1=*';
+            console.log("123124215125");
             if(getParam('RecordType') != null){
                 str += '&RecordType='+getParam('RecordType');
+            }
+            if(getParam('recordTypeId') != null){
+                str += '&RecordType='+getParam('recordTypeId');
             }
             if(getParam('CMRT') != null){
                 str += '&CMRT='+getParam('CMRT');
@@ -30,12 +34,16 @@
         }
         function getParam(paramName) {
             paramValue = "", isFound = !1;
+            console.log(this.location.search);
             if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
                 arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
                 while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
             }
             return paramValue == "" && (paramValue = null), paramValue
         }
+        document.addEventListener("DOMContentLoaded", function(event) {
+            init();
+        });
     </script>
     <body onload="init()">
         
diff --git a/force-app/main/default/pages/SubAuthorizedCreate.page b/force-app/main/default/pages/SubAuthorizedCreate.page
index 21c9564..123f80c 100644
--- a/force-app/main/default/pages/SubAuthorizedCreate.page
+++ b/force-app/main/default/pages/SubAuthorizedCreate.page
@@ -24,6 +24,9 @@
             }
             return paramValue == "" && (paramValue = null), paramValue
         }
+        document.addEventListener("DOMContentLoaded", function(event) {
+            init();
+        });
     </script>
     <body onload="init()">
     </body>
diff --git a/force-app/main/default/triggers/ContentDocumentLink.trigger b/force-app/main/default/triggers/ContentDocumentLink.trigger
new file mode 100644
index 0000000..0cc587b
--- /dev/null
+++ b/force-app/main/default/triggers/ContentDocumentLink.trigger
@@ -0,0 +1,75 @@
+trigger ContentDocumentLink on ContentDocumentLink (before delete, after insert) {
+
+    // if((!Test.isRunningTest())&&UserInfo.getUserId()==System.Label.ByPassTrigger){
+    //     return;
+    // }
+    system.debug('enter ContentDocumentLink');
+    system.debug('Trigger.new = ' + (List<ContentDocumentLink>) Trigger.new);
+    system.debug('Trigger.old = ' + (List<ContentDocumentLink>) Trigger.old);
+
+    String invoiceStart = System.Label.invoiceStart;
+    System.debug('invoiceStart = ' + invoiceStart);
+    List<String> rentalIds = new List<String>();
+    List<String> attIds = new List<String>();
+    // List<String> rentaldelIds = new List<String>();
+    // List<String> attdelIds = new List<String>();
+
+    if (Trigger.isAfter && Trigger.isInsert) {
+        System.debug('Trigger.isAfter && Trigger.isInsert');
+        for (ContentDocumentLink cdl : Trigger.new) {
+            System.debug('cdl.LinkedEntityId = ' + cdl.LinkedEntityId);
+            System.debug('cdl.ContentDocumentId = ' + cdl.ContentDocumentId);
+            if (String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)) {
+                System.debug('String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)');
+                rentalIds.add(cdl.LinkedEntityId);
+                attIds.add(cdl.ContentDocumentId);
+                System.debug('rentalIds = ' + rentalIds);
+                System.debug('attIds = ' + attIds);
+            }
+        }
+    }
+
+    // if (Trigger.isBefore && Trigger.isDelete) {
+    //     System.debug('Trigger.isBefore && Trigger.isDelete');
+    //     for (ContentDocumentLink cdl : Trigger.old) {
+    //         System.debug('cdl.LinkedEntityId = ' + cdl.LinkedEntityId);
+    //         System.debug('cdl.ContentDocumentId = ' + cdl.ContentDocumentId);
+    //         if (String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)) {
+    //             System.debug('String.valueOf(cdl.LinkedEntityId).startsWith(invoiceStart)');
+    //             rentaldelIds.add(cdl.LinkedEntityId);
+    //             attdelIds.add(cdl.ContentDocumentId);
+    //             System.debug('rentaldelIds = ' + rentaldelIds);
+    //             System.debug('attdelIds = ' + attdelIds);
+    //         }
+    //     }
+    // }
+
+
+    if (rentalIds.size() > 0) {
+        List<Consumable_order__c> rentalList = new List<Consumable_order__c>();
+        for (Consumable_order__c ra : [SELECT Id FROM Consumable_order__c WHERE Id IN :rentalIds]) {
+            ra.Consumable_pdf_insert_day__c = Date.today();
+            ra.Order_Attachment__c = attIds[0];
+            rentalList.add(ra);
+        }
+        System.debug('rentalList = ' + rentalList);
+        ControllerUtil.updRentalApplyList(rentalList);
+    }
+    // if (Trigger.isInsert && Trigger.isAfter && StaticParameter.ContentDocumentLink) {
+    //     AttachmentReQisHandler handler = new AttachmentReQisHandler();
+    //     handler.run();
+    // }
+
+    // if (rentaldelIds.size() > 0) {
+    //     List<Consumable_accessories_invoice__c> rentaldelList = new List<Consumable_accessories_invoice__c>();
+    //     for (Consumable_accessories_invoice__c ra : [
+    //         SELECT Id
+    //         FROM Consumable_accessories_invoice__c
+    //         WHERE Invoice_code__c IN :rentaldelIds AND Attachment_ID__c IN :attdelIds
+    //     ]) {
+    //         rentaldelList.add(ra);
+    //     }
+    //     System.debug('rentaldelList = ' + rentaldelList);
+    //     ControllerUtil.delConsumableAccessoriesInvoiceSet(rentaldelList);
+    // }
+}
\ No newline at end of file
diff --git a/force-app/main/default/triggers/ContentDocumentLink.trigger-meta.xml b/force-app/main/default/triggers/ContentDocumentLink.trigger-meta.xml
new file mode 100644
index 0000000..b01a1f0
--- /dev/null
+++ b/force-app/main/default/triggers/ContentDocumentLink.trigger-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>57.0</apiVersion>
+    <status>Active</status>
+</ApexTrigger>

--
Gitblit v1.9.1