buli
2023-05-04 d4a4ce824f3b2f3a335a3ad8e8c9efb3b37d630f
backup

backup
18个文件已修改
4个文件已添加
19903 ■■■■■ 已修改文件
force-app/main/default/classes/ArriveGoodsController.cls 4927 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/CPL003Rest.cls 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/DNUpsertBatch.cls 1080 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/DNUpsertBatchTest.cls 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InventoryViewController.cls 769 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexArriveGoodsController.cls 389 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexArriveGoodsController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexSummonsCreatController.cls 1408 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LogAutoSendBatch.cls 322 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OCSMHandler.cls 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/updateESignBatch.cls 1285 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/updateESignBatchTest.cls 3192 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/customOutputGoods.html 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/customReturnGoodInput.html 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/customShipmentNumber.html 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexCustomLightningDatatable/lexCustomLightningDatatable.js 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.html 1248 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.js 2550 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/paginatedList/paginatedList.html 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/paginatedList/paginatedList.js 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/summonsCreat.page 2468 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest/packageForSign.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/ArriveGoodsController.cls
Diff too large
force-app/main/default/classes/CPL003Rest.cls
@@ -1,28 +1,27 @@
@RestResource(urlMapping='/CPL003/*')
global with sharing class CPL003Rest {
    global class GeDatas {
        webservice NFMUtil.Monitoring Monitoring;
        webservice CPL003Rest.GeData[] Inventory;
        webService NFMUtil.Monitoring Monitoring;
        webService CPL003Rest.GeData[] Inventory;
    }
    global class GeData {
        webservice String MaterialNumber; //产品编码(产品代码)
        webservice String ItemQuantity;   //OpenPO和库存的总数量
        webService String MaterialNumber; //产品编码(产品代码)
        webService String ItemQuantity; //OpenPO和库存的总数量
        webservice String Area;    //区域(待定)
        webService String Area; //区域(待定)
        //webservice String other1;
        //webservice String other2;
        //webservice String other3;
    }
    @HttpPost
    @HttpPost
    global static void execute() {
        // 取得接口传输内容
        // 取得接口传输内容
        String strData = RestContext.request.requestBody.toString();
        GeDatas ges = (GeDatas) JSON.deserializeStrict(strData, GeDatas.class);
        if (ges == null ) {
        if (ges == null) {
            return;
        }
@@ -46,7 +45,6 @@
        return;
    }
    @future
    global static void executefuture(String rowData_Id) {
        main(rowData_Id);
@@ -54,8 +52,29 @@
    global static void main(String rowData_Id) {
        Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
        BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,retry_cnt__c from BatchIF_Log__c where RowDataFlg__c = true and Id = :rowData_Id];
        MDMITMWebService.isRunning = true;
        BatchIF_Log__c rowData = [
            SELECT
                Id,
                Name,
                Log__c,
                ErrorLog__c,
                Log2__c,
                Log3__c,
                Log4__c,
                Log5__c,
                Log6__c,
                Log7__c,
                Log8__c,
                Log9__c,
                Log10__c,
                Log11__c,
                Log12__c,
                MessageGroupNumber__c,
                retry_cnt__c
            FROM BatchIF_Log__c
            WHERE RowDataFlg__c = TRUE AND Id = :rowData_Id
        ];
        //MDMITMWebService.isRunning = true; //Commented By Li Jun 20230428
        String logstr = rowData.MessageGroupNumber__c + ' start\n';
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = 'CPL003';
@@ -67,36 +86,39 @@
        String rowDataStr = NFMUtil.getRowDataStr(rowData);
        //rowDataStr = XMLTools.xml2json(rowDataStr);
        List<GeData> itemMasterList = (List<GeData>) JSON.deserialize(rowDataStr, List<GeData>.class);
        if (itemMasterList == null || itemMasterList.size() == 0) {
            return;
        }
        }
        Savepoint sp = Database.setSavepoint();
        try{
        try {
            List<String> materialNumberList = new List<String>();
            for (GeData GeData : itemMasterList) {
                if (String.isBlank(GeData.MaterialNumber))  continue;
                if (String.isBlank(GeData.ItemQuantity))  continue;
                if (String.isBlank(GeData.MaterialNumber))
                    continue;
                if (String.isBlank(GeData.ItemQuantity))
                    continue;
                materialNumberList.add(GeData.MaterialNumber);
            }
            List<Product2> product2List = [select Id, ProductCode, StorageStatusNo__c
                                             from Product2
                                            where ProductCode in :materialNumberList ];
            Map<String,Product2> product2Map = new Map<String,Product2>();
            List<Product2> product2List = [
                SELECT Id, ProductCode, StorageStatusNo__c
                FROM Product2
                WHERE ProductCode IN :materialNumberList
            ];
            Map<String, Product2> product2Map = new Map<String, Product2>();
            for (Product2 product2 : product2List) {
                product2Map.put(product2.ProductCode, product2);
            }
            List<Product2> upsertProList = new List<Product2>();
            Map<String,Product2> prdUpdateMap = new Map<String, Product2>();
            Map<String, Product2> prdUpdateMap = new Map<String, Product2>();
            for (GeData GeData : itemMasterList) {
                if (String.isBlank(GeData.MaterialNumber)) {
                    iflog.ErrorLog__c += 'MaterialNumber is required.\n';
                    continue;
@@ -106,29 +128,36 @@
                    Product2 product = product2Map.get(GeData.MaterialNumber);
                    product.StorageStatusNo__c = Double.valueOf(GeData.ItemQuantity);
                    upsertProList.add(product);
                } else {
                    iflog.ErrorLog__c += 'This MaterialNumber [ ' + GeData.MaterialNumber + ' ] is not Exist.\n';
                    continue;
                }
            }
            if(upsertProList.size() > 0)    upsert upsertProList;
            if (upsertProList.size() > 0)
                upsert upsertProList;
            logstr += '\nend';
            rowData.retry_cnt__c=0;
        } catch(Exception ex) {
            rowData.retry_cnt__c = 0;
        } catch (Exception ex) {
            // エラーが発生した場合
            Database.rollback(sp);
            logstr += '\n' + ex.getMessage();
            iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
            if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
            if (rowData.retry_cnt__c < batch_retry_max_cnt){
            if (rowData.retry_cnt__c == null)
                rowData.retry_cnt__c = 0;
            if (rowData.retry_cnt__c < batch_retry_max_cnt) {
                rowData.retry_cnt__c++;
                LogAutoSendSchedule.assignOneMinute();
            }
            if (rowData.retry_cnt__c >= batch_retry_max_cnt){
                rowData.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowData.ErrorLog__c+'错误次数已经超过自动收信设定的最大次数,请手动收信';
            if (rowData.retry_cnt__c >= batch_retry_max_cnt) {
                rowData.ErrorLog__c =
                    ex.getMessage() +
                    '\n' +
                    ex.getStackTraceString() +
                    '\n' +
                    rowData.ErrorLog__c +
                    '错误次数已经超过自动收信设定的最大次数,请手动收信';
            }
        }
@@ -142,4 +171,4 @@
        }
        update iflog;
    }
}
}
force-app/main/default/classes/DNUpsertBatch.cls
@@ -1,5 +1,5 @@
global class DNUpsertBatch implements Database.Batchable<sObject>, Database.Stateful {
    public string  rowData_Id;
    public string rowData_Id;
    public transient static List<Id> orderReturnIdList;
    private class DNdetail {
        private string DeliveryNote;
@@ -8,29 +8,69 @@
    global DNUpsertBatch() {
    }
    global DNUpsertBatch( string rowData_Id ) {
    global DNUpsertBatch(string rowData_Id) {
        this.rowData_Id = rowData_Id;
    }
    global Database.QueryLocator start(Database.BatchableContext bc) {
        if( string.isBlank( rowData_Id )){
        if (string.isBlank(rowData_Id)) {
            return Database.getQueryLocator(
                [Select Id, Name, Log__c, ErrorLog__c, Log2__c,
                 Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c,
                 Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,
                 retry_cnt__c,DN_retry_cnt__c, CreatedDate
                 from BatchIF_Log__c
                 where RowDataFlg__c = true
                 and IsUpsertDN__c = true
                 and (DN_retry_cnt__c = null
                     or (DN_retry_cnt__c != 0 and DN_retry_cnt__c < 3))]);
        }else{
            return Database.getQueryLocator([Select Id, Name, Log__c, ErrorLog__c, Log2__c,
                                             Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c,
                                             Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,
                                             retry_cnt__c ,DN_retry_cnt__c,CreatedDate
                                             from BatchIF_Log__c
                                             where RowDataFlg__c = true
                                             and Id = :rowData_Id ]);
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        retry_cnt__c,
                        DN_retry_cnt__c,
                        CreatedDate
                    FROM BatchIF_Log__c
                    WHERE
                        RowDataFlg__c = TRUE
                        AND IsUpsertDN__c = TRUE
                        AND (DN_retry_cnt__c = NULL
                        OR (DN_retry_cnt__c != 0
                        AND DN_retry_cnt__c < 3))
                ]
            );
        } else {
            return Database.getQueryLocator(
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        retry_cnt__c,
                        DN_retry_cnt__c,
                        CreatedDate
                    FROM BatchIF_Log__c
                    WHERE RowDataFlg__c = TRUE AND Id = :rowData_Id
                ]
            );
        }
    }
    global void execute(Database.BatchableContext BC, List<BatchIF_Log__c> rowDataList) {
@@ -41,19 +81,19 @@
        // String day = String.valueOf(strdate.day()) ;
        // String datestr = String.valueOf(year+month+day);
        //add by rentx 20210727 end
        BatchIF_Log__c rowData = rowDataList[0];
        rowData.IsUpsertDN__c = false;
        update rowData;
        //update by rentx  20210823
        //update by rentx  20210823
        //本次修改只针对于保有设备 之前使用年月日去插入时 会出现 同一天多批日志里有同一个设备 导致更新失败  现解决方案为精确到分
        Datetime nowTime = rowData.CreatedDate;
        String oyear = String.valueOf(nowTime.year()) ;
        String omonth = String.valueOf(nowTime.month()) ;
        String oday = String.valueOf(nowTime.day()) ;
        String ohour = String.valueOf(nowTime.hour()) ;
        String ominute = String.valueOf(nowTime.minute()) ;
        String datestr = String.valueOf(oyear+omonth+oday+ohour+ominute);
        String oyear = String.valueOf(nowTime.year());
        String omonth = String.valueOf(nowTime.month());
        String oday = String.valueOf(nowTime.day());
        String ohour = String.valueOf(nowTime.hour());
        String ominute = String.valueOf(nowTime.minute());
        String datestr = String.valueOf(oyear + omonth + oday + ohour + ominute);
        //update by rentx  20210823
        //之前使用年月日去插入时 会出现 同一天多批日志里有同一个设备 导致更新失败  现解决方案为精确到分
@@ -69,30 +109,30 @@
        iflog.ErrorLog__c = '';
        insert iflog;
        String rowDataStr = NFMUtil.getRowDataStr(rowData);
        List<NFM110Rest.GeneralData> generalDataList =
            (List<NFM110Rest.GeneralData>) JSON.deserialize(rowDataStr, List<NFM110Rest.GeneralData>.class);
        List<NFM110Rest.GeneralData> generalDataList = (List<NFM110Rest.GeneralData>) JSON.deserialize(
            rowDataStr,
            List<NFM110Rest.GeneralData>.class
        );
        if (generalDataList == null || generalDataList.size() == 0) {
            return;
        }
        // 电子签收单 start 优化原有select
        list<account> olympusAcclist =
            [select Id , ParentId ,AgentCode_Ext__c
             from Account
             where AgentCode_Ext__c = '9999900' or
             AgentCode_Ext__c = '9999999' or
             AgentCode_Ext__c = '9999901'
        list<account> olympusAcclist = [
            SELECT Id, ParentId, AgentCode_Ext__c
            FROM Account
            WHERE AgentCode_Ext__c = '9999900' OR AgentCode_Ext__c = '9999999' OR AgentCode_Ext__c = '9999901'
        ];
        Account ocm ,olympus,olympus_return;
        for(Account tempAcc : olympusAcclist){
            if(tempAcc.AgentCode_Ext__c.equals('9999900')){
        Account ocm, olympus, olympus_return;
        for (Account tempAcc : olympusAcclist) {
            if (tempAcc.AgentCode_Ext__c.equals('9999900')) {
                ocm = tempAcc;
            }else if(tempAcc.AgentCode_Ext__c.equals('9999999')){
            } else if (tempAcc.AgentCode_Ext__c.equals('9999999')) {
                olympus = tempAcc;
            }else if(tempAcc.AgentCode_Ext__c.equals('9999901')){
            } else if (tempAcc.AgentCode_Ext__c.equals('9999901')) {
                olympus_return = tempAcc;
            }
        }
    // 电子签收单 end
        // 电子签收单 end
        NFM110Rest.isRunning = true;
        //orderoutIdList = new List<Id>();
        orderReturnIdList = new List<Id>();
@@ -121,7 +161,7 @@
                // 病院と診療科の管理コード、TODO 販売店
                infoH.EndUserNo = NFMUtil.trimLeft(infoH.EndUserNo, '0');
                infoH.DepartmentNo = NFMUtil.trimLeft(infoH.DepartmentNo, '0');
                if (infoH.EndUserNo == null || infoH.EndUserNo  == '') {
                if (infoH.EndUserNo == null || infoH.EndUserNo == '') {
                    // 病院と診療科の管理コードがない場合、処理と飛ばす
                    continue;
                }
@@ -145,106 +185,121 @@
                        //根据数据传的样式决定
                    }
                }
                if (!(infoH.ReturnMark == null || infoH.ReturnMark  == ''
                      || infoH.ReturnMark == '1' || infoH.ReturnMark == '3'
                     )) {
                         // ReturnMark = 上記以外の場合 Errorメッセージ出力
                         continue;
                     }
                if (!(infoH.ReturnMark == null || infoH.ReturnMark == '' || infoH.ReturnMark == '1' || infoH.ReturnMark == '3')) {
                    // ReturnMark = 上記以外の場合 Errorメッセージ出力
                    continue;
                }
                for (nfm110rest.DnInformation dnInfo : infoH.DnInformation) {
                    dnInfo.SerialNoorLotNo = checkSerialNoorLotNo(dnInfo.SerialNoorLotNo);
                    productCodeList.add(dnInfo.OTCode);
                    // CHAN-BBLAAP start
                    string Product_Serial_No = '';
                    if (dnInfo.SorLMark == 'S') {
                        Product_Serial_No =
                            dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo;
                        Product_Serial_No = dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo;
                    } else {
                        Product_Serial_No  =
                            dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo
                            + '(' + dnInfo.TracingCode + ')';
                        Product_Serial_No = dnInfo.OTCode + ':' + dnInfo.SerialNoorLotNo + '(' + dnInfo.TracingCode + ')';
                    }
                    // CHAN-BBLAAP end
                    if (dnInfo.OTCode == null || dnInfo.OTCode == ''
                        || dnInfo.SerialNoorLotNo == null || dnInfo.SerialNoorLotNo == ''
                       ) {
                           // 商品コードがない場合、処理と飛ばす
                           continue;
                       }
                    if (dnInfo.OTCode == null || dnInfo.OTCode == '' || dnInfo.SerialNoorLotNo == null || dnInfo.SerialNoorLotNo == '') {
                        // 商品コードがない場合、処理と飛ばす
                        continue;
                    }
                    // HHOA-AGN2EH start
                    //add by rentx 20210726 start
                    dnInfo.SerialNoorLotNo = dnInfo.SerialNoorLotNo == '.'? datestr +dnInfo.OTCode : dnInfo.SerialNoorLotNo;
                    //add by rentx 20210726 start
                    dnInfo.SerialNoorLotNo = dnInfo.SerialNoorLotNo == '.' ? datestr + dnInfo.OTCode : dnInfo.SerialNoorLotNo;
                    //update by rentx 20210726 end
                    productSerialNoList.add(dnInfo.SerialNoorLotNo);
                    productSerialNoList.add(dnInfo.SerialNoorLotNo + '(' + dnInfo.TracingCode + ')');
                }
            }
            // 电子签收单 start 额外检索end user
             List<Account> accList = [select Id, Name, Management_Code__c, Department_Class__c, Hospital__c, ParentId,
                                     RecordType.DeveloperName, Department_Name__c, OCM_man_province_txt__c
                                     from Account
                                     where Management_Code__c in :managementCodeList];
            List<Account> accList = [
                SELECT
                    Id,
                    Name,
                    Management_Code__c,
                    Department_Class__c,
                    Hospital__c,
                    ParentId,
                    RecordType.DeveloperName,
                    Department_Name__c,
                    OCM_man_province_txt__c
                FROM Account
                WHERE Management_Code__c IN :managementCodeList
            ];
            // HHOA-BLC8S6 update by vivek 2020-02-13 end
            Map<String, Account> accsMap = new Map<String, Account>();
            for (Account acc : accList) {
                accsMap.put(acc.Management_Code__c, acc);
            }
            Map<String, Opportunity> oppMap = new Map<String, Opportunity>();
            List<Opportunity> oppList = [Select Id, Purchase_Type__c, Opportunity_No__c,Strategic_department_Class_Name__c,
                                         Sales_Root__c, SAP_Province__c, Trade__c, Agency1__c,Agency1__r.Name,
                                         Agency1__r.OCM_man_province_txt__c, Opportunity_Category__c,
                                         OCM_man_province_cus__c, Sales_assistant_name_text__c
                                        // 电子签收单 start
                                        // 临时使用 用作试点经销商
                                        ,Agency1__r.EsignTestAccount__c,Agency1__r.EsignTestAccountType__c
                                        // 电子签收单 end
                                        //集中采购询价 精琢技术 wql  start
                                        ,Group_purchase_PCL__c
                                        //集中采购询价 精琢技术 wql  end
                                        ,Is_Corrosion__c
                                         From Opportunity Where Opportunity_No__c IN :inquiryNoList];
            List<Opportunity> oppList = [
                SELECT
                    Id,
                    Purchase_Type__c,
                    Opportunity_No__c,
                    Strategic_department_Class_Name__c,
                    Sales_Root__c,
                    SAP_Province__c,
                    Trade__c,
                    Agency1__c,
                    Agency1__r.Name,
                    Agency1__r.OCM_man_province_txt__c,
                    Opportunity_Category__c,
                    OCM_man_province_cus__c,
                    Sales_assistant_name_text__c,
                    // 电子签收单 start
                    // 临时使用 用作试点经销商
                    Agency1__r.EsignTestAccount__c,
                    Agency1__r.EsignTestAccountType__c,
                    // 电子签收单 end
                    //集中采购询价 精琢技术 wql  start
                    Group_purchase_PCL__c,
                    //集中采购询价 精琢技术 wql  end
                    Is_Corrosion__c
                FROM Opportunity
                WHERE Opportunity_No__c IN :inquiryNoList
            ];
            for (Opportunity opp : oppList) {
                oppMap.put(opp.Opportunity_No__c, opp);
            }
            // 检索出DN 并生成DN Map
            Boolean flg=true;
            map <string, Statu_Achievements_DN__c> DNMap = new  map <string, Statu_Achievements_DN__c>();
            Boolean flg = true;
            map<string, Statu_Achievements_DN__c> DNMap = new Map<string, Statu_Achievements_DN__c>();
            List<Statu_Achievements_DN__c> DNList = GetDNList(DNNoSet);
                // [select id, Name,
                //  DeliveryDate_Raw__c,
                //  DeliveryNote_Raw__c,
                //  DepartmentNo_Raw__c,
                //  EndUserNo_Raw__c,
                //  InquiryNo_Raw__c,
                //  ReturnMark_Raw__c,
                //  SoNo_Raw__c,
                //  Opportunity__c,
                //  Statu_Achievements__c,
                //  endUser__c
                //  //电子签收单试点用户赋值
                //  ,endUser__r.RecordType.Name
                //  // 电子签收单 start
                //  , Sales_assistant_name_text__c,
                //  RC_Manager__c,ReturnMark__c
                //  // 试点用户,届时需要删掉
                //  , EsignTestAccount__c
                //  // 电子签收单  end
                //  //ET召回品不生成签收单 start
                // , ETRecalledProducts__c
                //  //ET召回品不生成签收单 end
                //  //acc标识 start
                //  ,ACC_Text__c,
                //  Is_Corrosion__c,
                //  //无偿出库标识 thh 2021-11-01 start
                //  Statu_Achievements__r.orderType__c
                //  //无偿出库标识 thh 2021-11-01 end
                //  //acc标识 end
                //  from Statu_Achievements_DN__c where
                //  Name in: DNNoSet];
            // [select id, Name,
            //  DeliveryDate_Raw__c,
            //  DeliveryNote_Raw__c,
            //  DepartmentNo_Raw__c,
            //  EndUserNo_Raw__c,
            //  InquiryNo_Raw__c,
            //  ReturnMark_Raw__c,
            //  SoNo_Raw__c,
            //  Opportunity__c,
            //  Statu_Achievements__c,
            //  endUser__c
            //  //电子签收单试点用户赋值
            //  ,endUser__r.RecordType.Name
            //  // 电子签收单 start
            //  , Sales_assistant_name_text__c,
            //  RC_Manager__c,ReturnMark__c
            //  // 试点用户,届时需要删掉
            //  , EsignTestAccount__c
            //  // 电子签收单  end
            //  //ET召回品不生成签收单 start
            // , ETRecalledProducts__c
            //  //ET召回品不生成签收单 end
            //  //acc标识 start
            //  ,ACC_Text__c,
            //  Is_Corrosion__c,
            //  //无偿出库标识 thh 2021-11-01 start
            //  Statu_Achievements__r.orderType__c
            //  //无偿出库标识 thh 2021-11-01 end
            //  //acc标识 end
            //  from Statu_Achievements_DN__c where
            //  Name in: DNNoSet];
            for (Statu_Achievements_DN__c dn : DNList) {
                DNMap.put(dn.Name, dn);
            }
@@ -254,49 +309,73 @@
            List<DNdetail> insertDNdetailList = new List<DNdetail>();
            // CHAN-BBLAAP  end
            List<Statu_Achievements__c> boList = [select Id, Name
                                                  from Statu_Achievements__c
                                                  where Name in :soNoList and OverviewStatus__c <> '无效合同'];
            List<Statu_Achievements__c> boList = [
                SELECT Id, Name
                FROM Statu_Achievements__c
                WHERE Name IN :soNoList AND OverviewStatus__c != '无效合同'
            ];
            Map<String, String> boMap = new Map<String, String>();
            for (Statu_Achievements__c bo : boList) {
                boMap.put(bo.Name, bo.Id);
            }
            List<Product2> prdList = [select Id, Name, ProductCode, ProductCode_Ext__c, MDM_Model_No__c
                                      from Product2
                                      where ProductCode_Ext__c in :productCodeList];
            List<Product2> prdList = [
                SELECT Id, Name, ProductCode, ProductCode_Ext__c, MDM_Model_No__c
                FROM Product2
                WHERE ProductCode_Ext__c IN :productCodeList
            ];
            Map<String, Product2> prdsMap = new Map<String, Product2>();
            for (Product2 prd : prdList) {
                prdsMap.put(prd.ProductCode_Ext__c, prd);
            }
            List<Asset> astList = [select Id, Name, Product2.ProductCode, Product2.Dealer_special_Object__c , Product2.Dealer_Object__c,
                                   SerialNumber, Product_Serial_No__c, Repair_Count__c, TracingCode__c,
                                   Product2Id, AccountId, Account.Management_Code__c, Department_Class__c, Hospital__c,
                                   Posting_Date__c, InstallDate, SLMark__c, MDM_Model_No__c, OT_CODE__c,
                                   Guarantee_period_for_products__c, Installation_Site__c, Delete_Flag__c, Return_Flag__c,
                                   Extend_Gurantee_DateTo__c, guarantee_period__c, Proviston_period__c
                                   from Asset
                                   where SerialNumber in :productSerialNoList
                                   and IsCompetitorProduct = false
                                   and Information_From__c <> '失单'];
            List<Asset> astList = [
                SELECT
                    Id,
                    Name,
                    Product2.ProductCode,
                    Product2.Dealer_special_Object__c,
                    Product2.Dealer_Object__c,
                    SerialNumber,
                    Product_Serial_No__c,
                    Repair_Count__c,
                    TracingCode__c,
                    Product2Id,
                    AccountId,
                    Account.Management_Code__c,
                    Department_Class__c,
                    Hospital__c,
                    Posting_Date__c,
                    InstallDate,
                    SLMark__c,
                    MDM_Model_No__c,
                    OT_CODE__c,
                    Guarantee_period_for_products__c,
                    Installation_Site__c,
                    Delete_Flag__c,
                    Return_Flag__c,
                    Extend_Gurantee_DateTo__c,
                    guarantee_period__c,
                    Proviston_period__c
                FROM Asset
                WHERE SerialNumber IN :productSerialNoList AND IsCompetitorProduct = FALSE AND Information_From__c != '失单'
            ];
            Map<String, Asset> astsMap = new Map<String, Asset>();
            for (Asset ast : astList) {
                astsMap.put(ast.MDM_Model_No__c + ast.SerialNumber, ast);
            }
            // 电子签收单 start
            // key 是省份名字, value 是对应的营业管理部担当 1 ,2 ,3
            Map < String, String > provinceOwnerMap = new Map< String, String > ();
            Map<String, String> provinceOwnerMap = new Map<String, String>();
            //集中采购询价 构建助理map key是省份名称 value是助理
            Map < String, String > provinceGIMap = new Map< String, String > ();
            Map<String, String> provinceGIMap = new Map<String, String>();
            //检索OCSM管理省对象
            //集中采购询价 增加检索助理
            List < OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c,Window1__c   from OCM_Management_Province__c ];
            //集中采购询价 增加检索助理
            List<OCM_Management_Province__c> ompList = [SELECT id, Name, SalesManage__c, GI_assistant__c FROM OCM_Management_Province__c];
            //存放map<省,担当>
            for (OCM_Management_Province__c omp: ompList) {
            for (OCM_Management_Province__c omp : ompList) {
                provinceOwnerMap.put(omp.Name, omp.SalesManage__c);
                //provinceGIMap.put(omp.Name,omp.GI_assistant__c); //Commented by Li Jun 20230420
                provinceGIMap.put(omp.Name, omp.Window1__c);// Add By Li Jun 更新 签收单的【营业助理】值,从OCSM管理省对应的【营业窗口】字段获取
                provinceGIMap.put(omp.Name, omp.GI_assistant__c);
            }
            // 电子签收单 end
@@ -320,48 +399,72 @@
                    continue;
                }
                if (infoH.DnInformation == null || infoH.DnInformation.size() == 0) {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] DnInformation is required. This DN is skipped.\n';
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] DnInformation is required. This DN is skipped.\n';
                    continue;
                }
                if (infoH.EndUserNo == null || infoH.EndUserNo  == '') {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] EndUserNo is required. This DN is skipped.\n';
                if (infoH.EndUserNo == null || infoH.EndUserNo == '') {
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] EndUserNo is required. This DN is skipped.\n';
                    continue;
                }
                if (accsMap.get(infoH.EndUserNo) == null) {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] EndUserNo[' + infoH.EndUserNo + ']NotExist. This DN is skipped.\n';
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] EndUserNo[' +
                        infoH.EndUserNo +
                        ']NotExist. This DN is skipped.\n';
                    continue;
                } else if (accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'HP'
                           && accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'Agency'
                           && accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'AgencyContract') {
                    iflog.ErrorLog__c += 'Error! SoNo[' + infoH.SoNo + '] DeliveryNote[' + infoH.DeliveryNote + '] EndUserNo[' + infoH.EndUserNo + ']Is Not HP or Agency(Contract). This DN is skipped.\n';
                } else if (
                    accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'HP' &&
                    accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'Agency' &&
                    accsMap.get(infoH.EndUserNo).RecordType.DeveloperName != 'AgencyContract'
                ) {
                    iflog.ErrorLog__c +=
                        'Error! SoNo[' +
                        infoH.SoNo +
                        '] DeliveryNote[' +
                        infoH.DeliveryNote +
                        '] EndUserNo[' +
                        infoH.EndUserNo +
                        ']Is Not HP or Agency(Contract). This DN is skipped.\n';
                    continue;
                }
                Statu_Achievements_DN__c tempSADN =
                    DNMap.get(infoH.DeliveryNote);
                Statu_Achievements_DN__c tempSADN = DNMap.get(infoH.DeliveryNote);
                if (infoH.DeliveryNote != null) {
                    if (tempSADN == null) {
                        tempSADN = new Statu_Achievements_DN__c();
                        tempSADN.Statu_Achievements__c = null;
                        tempSADN = SetSADN(tempSADN, infoH, boMap, oppMap, accsMap , provinceOwnerMap,provinceGIMap);
                        checkSA( tempSADN, UpsertDNList, iflog, infoH );
                        tempSADN = SetSADN(tempSADN, infoH, boMap, oppMap, accsMap, provinceOwnerMap, provinceGIMap);
                        checkSA(tempSADN, UpsertDNList, iflog, infoH);
                    } else {
                        if (infoH.SoNo != tempSADN.SoNo_Raw__c ||
                        if (
                            infoH.SoNo != tempSADN.SoNo_Raw__c ||
                            infoH.InquiryNo != tempSADN.InquiryNo_Raw__c ||
                            infoH.ReturnMark != tempSADN.ReturnMark_Raw__c ||
                            infoH.DeliveryDate != tempSADN.DeliveryDate_Raw__c ||
                            infoH.EndUserNo != tempSADN.EndUserNo_Raw__c ||
                            infoH.DepartmentNo != tempSADN.DepartmentNo_Raw__c ||
                            infoH.DeliveryNote != tempSADN.DeliveryNote_Raw__c
                           ) {
                               string SADNID = tempSADN.id;
                               // 电子签收单  额外增加营业管理部担当赋值 start
                               tempSADN = SetSADN(tempSADN, infoH, boMap,
                               oppMap,accsMap, provinceOwnerMap,provinceGIMap);
                               // 电子签收单  额外增加营业管理部担当赋值 end
                               tempSADN.id = SADNID;
                               checkSA( tempSADN, UpsertDNList, iflog, infoH );
                           }
                        ) {
                            string SADNID = tempSADN.id;
                            // 电子签收单  额外增加营业管理部担当赋值 start
                            tempSADN = SetSADN(tempSADN, infoH, boMap, oppMap, accsMap, provinceOwnerMap, provinceGIMap);
                            // 电子签收单  额外增加营业管理部担当赋值 end
                            tempSADN.id = SADNID;
                            checkSA(tempSADN, UpsertDNList, iflog, infoH);
                        }
                    }
                }
                integer tempDNdetailNumber = 0;
@@ -377,10 +480,13 @@
                    }
                    //  CHAN-BBLAAP 插入保有设备明细时插入对应DN start
                    boolean tempReturnFlg = infoH.ReturnMark == '1' ? true : false;
                    DNdetail tempDNdetail
                        = SetSADNDetails(infoH.DeliveryNote, tempReturnFlg, dnInfo, ast,
                                         dnInfo.SerialNoorLotNo != null && dnInfo.SerialNoorLotNo.equals('.') ?
                                         tempDNdetailNumber++ : tempDNdetailNumber);
                    DNdetail tempDNdetail = SetSADNDetails(
                        infoH.DeliveryNote,
                        tempReturnFlg,
                        dnInfo,
                        ast,
                        dnInfo.SerialNoorLotNo != null && dnInfo.SerialNoorLotNo.equals('.') ? tempDNdetailNumber++ : tempDNdetailNumber
                    );
                    insertDNdetailList.add(tempDNdetail);
                }
            }
@@ -391,43 +497,42 @@
                DNMap.put(tempSADN.Name, tempSADN);
            }
            DNList = GetDNList(DNMap.keySet());
                // [select id, Name,
                //  DeliveryDate_Raw__c,
                //  DeliveryNote_Raw__c,
                //  DepartmentNo_Raw__c,
                //  EndUserNo_Raw__c,
                //  InquiryNo_Raw__c,
                //  ReturnMark_Raw__c,
                //  SoNo_Raw__c,
                //  Opportunity__c,
                //  Statu_Achievements__c,
                //  endUser__c
                //  //电子签收单试点用户赋值
                //  ,endUser__r.RecordType.Name
                //  // 电子签收单 start
                //  , Sales_assistant_name_text__c,
                //  RC_Manager__c,ReturnMark__c
                //  // 试点用户,届时需要删掉
                //  , EsignTestAccount__c
                //  // 电子签收单  end
                //  //ET召回品不生成签收单 start
                // , ETRecalledProducts__c
                //  //ET召回品不生成签收单 end
                //  //acc标识 start
                //  ,ACC_Text__c,
                //  Is_Corrosion__c,
                //  Statu_Achievements__r.orderType__c
                //  //acc标识 end
                //  from Statu_Achievements_DN__c where
                //  Name in: DNMap.keySet()];
            // [select id, Name,
            //  DeliveryDate_Raw__c,
            //  DeliveryNote_Raw__c,
            //  DepartmentNo_Raw__c,
            //  EndUserNo_Raw__c,
            //  InquiryNo_Raw__c,
            //  ReturnMark_Raw__c,
            //  SoNo_Raw__c,
            //  Opportunity__c,
            //  Statu_Achievements__c,
            //  endUser__c
            //  //电子签收单试点用户赋值
            //  ,endUser__r.RecordType.Name
            //  // 电子签收单 start
            //  , Sales_assistant_name_text__c,
            //  RC_Manager__c,ReturnMark__c
            //  // 试点用户,届时需要删掉
            //  , EsignTestAccount__c
            //  // 电子签收单  end
            //  //ET召回品不生成签收单 start
            // , ETRecalledProducts__c
            //  //ET召回品不生成签收单 end
            //  //acc标识 start
            //  ,ACC_Text__c,
            //  Is_Corrosion__c,
            //  Statu_Achievements__r.orderType__c
            //  //acc标识 end
            //  from Statu_Achievements_DN__c where
            //  Name in: DNMap.keySet()];
            for (Statu_Achievements_DN__c dn : DNList) {
                DNMap.put(dn.Name, dn);
            }
            list<Statu_Achievements_DN_details__c> insertSADNdetailList
                = new  list<Statu_Achievements_DN_details__c>();
            list<Statu_Achievements_DN_details__c> insertSADNdetailList = new List<Statu_Achievements_DN_details__c>();
            //电子签收单 虚进虚出 tracingcode为空不生成签收单 精琢技术 2020/12/08 start
             map <string, Statu_Achievements_DN__c> DNRestructureMap = new  map <string, Statu_Achievements_DN__c>();
            map<string, Statu_Achievements_DN__c> DNRestructureMap = new Map<string, Statu_Achievements_DN__c>();
            //电子签收单 虚进虚出 tracingcode为空不生成签收单 精琢技术 2020/12/08 end
            for (DNdetail tempDNd : insertDNdetailList) {
                if (DNMap.containskey(tempDNd.DeliveryNote)) {
@@ -438,25 +543,22 @@
                    insertSADNdetailList.add(tempDNd.DNd);
                    //电子签收单 虚进虚出 tracingcode为空不生成签收单 精琢技术 2020/12/08 start
                    if(tempSADN.ACC_Text__c != 'Y'){
                        if(String.isBlank(tempDNd.DNd.TracingCode_Raw__c)){
                            tempSADN.ACC_Text__c = 'Y';
                    if (tempSADN.ACC_Text__c != 'Y') {
                        if (String.isBlank(tempDNd.DNd.TracingCode_Raw__c)) {
                            tempSADN.ACC_Text__c = 'Y';
                        }
                    }
                    DNRestructureMap.put(tempSADN.Name, tempSADN);
                    //电子签收单 虚进虚出 tracingcode为空不生成签收单 精琢技术 2020/12/08 end
                }
            }
            List<Statu_Achievements_DN_details__c> DNdetailList =
                [SELECT Id
                 FROM Statu_Achievements_DN_details__c
                 where Statu_Achievements_DN__r.Name in: DNMap.keySet()];
            List<Statu_Achievements_DN_details__c> DNdetailList = [
                SELECT Id
                FROM Statu_Achievements_DN_details__c
                WHERE Statu_Achievements_DN__r.Name IN :DNMap.keySet()
            ];
            if (DNdetailList.size() > 0 && !System.Test.isRunningTest()) {
                delete DNdetailList;
@@ -466,68 +568,69 @@
            }
            // 电子签收单  2020/07/17 start
            // 检索出签收单,并生成签收单map key 为DN号
            map <string, eSignForm__c> eSFMap = new  map <string, eSignForm__c>();
            List<eSignForm__c> eSFList =
                [select id, DNName__c,
                Hazardous_Chemicals__c,
                 Statu_Achievements__c,Statu_Achievements_DN__c
                 from eSignForm__c where
                 DNName__c in: DNNoSet];
            map<string, eSignForm__c> eSFMap = new Map<string, eSignForm__c>();
            List<eSignForm__c> eSFList = [
                SELECT id, DNName__c, Hazardous_Chemicals__c, Statu_Achievements__c, Statu_Achievements_DN__c
                FROM eSignForm__c
                WHERE DNName__c IN :DNNoSet
            ];
            for (eSignForm__c eSF : eSFList) {
                eSFMap.put(eSF.DNName__c, eSF);
            }
            //电子签收单 虚进虚出 明细为racing code 为空的 不生成签收单 20201207 精琢技术 start
            list<eSignForm__c> UpsertESFList = SetupeSignForm( eSFMap , DNRestructureMap.values() );
            list<eSignForm__c> UpsertESFList = SetupeSignForm(eSFMap, DNRestructureMap.values());
            //电子签收单 虚进虚出 明细为racing code 为空的 不生成签收单 20201207 精琢技术 end
            if(UpsertESFList.size()> 0) {
            if (UpsertESFList.size() > 0) {
                upsert UpsertESFList;
            }
            // key 为 对应DN的ID
            map <string, eSignForm__c> eSFAllMap = new map <string, eSignForm__c> ();
            for( eSignForm__c tempeSignForm : UpsertESFList){
                eSFAllMap.put(tempeSignForm.DNName__c,tempeSignForm);
            map<string, eSignForm__c> eSFAllMap = new Map<string, eSignForm__c>();
            for (eSignForm__c tempeSignForm : UpsertESFList) {
                eSFAllMap.put(tempeSignForm.DNName__c, tempeSignForm);
            }
            // 检索现有签收单明细,并生成签收单明细map key 为DN号 + 产品OTCode
            map <string, eSignFormLineItem__c> eSFLMap = new  map <string, eSignFormLineItem__c>();
            List<eSignFormLineItem__c> eSFLList =
                [select id,DNProductNo__c,
                 Count__c,Product2__c,eSignForm__c
                 , CaseNumber__c
                 from eSignFormLineItem__c
                 where eSignForm__r.DNName__c in: DNNoSet
                ];
            map<string, eSignFormLineItem__c> eSFLMap = new Map<string, eSignFormLineItem__c>();
            List<eSignFormLineItem__c> eSFLList = [
                SELECT id, DNProductNo__c, Count__c, Product2__c, eSignForm__c, CaseNumber__c
                FROM eSignFormLineItem__c
                WHERE eSignForm__r.DNName__c IN :DNNoSet
            ];
            for (eSignFormLineItem__c eSFL : eSFLList) {
                eSFL.Count__c = 0;
                eSFLMap.put(eSFL.DNProductNo__c, eSFL);
            }
            // 构造签收单明细
            list<eSignFormLineItem__c> UpsertESFLList =
                SetupeSignFormLineItems( insertSADNdetailList, eSFLMap , eSFAllMap, prdsMap);
            if(UpsertESFLList.size() > 0){
            list<eSignFormLineItem__c> UpsertESFLList = SetupeSignFormLineItems(insertSADNdetailList, eSFLMap, eSFAllMap, prdsMap);
            if (UpsertESFLList.size() > 0) {
                upsert UpsertESFLList;
            }
            rowData.IsUpsertDN__c = false;
            rowData.DN_retry_cnt__c = 0;
            if(System.Test.isRunningTest()){
            if (System.Test.isRunningTest()) {
                throw new ControllerUtil.myException('测试错误!');
            }
            // 电子签收单  2020/07/17 end
        } catch (Exception ex) {
            Database.rollback(sp);
            logstr += '\n' + ex.getMessage();
             rowData.IsUpsertDN__c = true;
            rowData.IsUpsertDN__c = true;
            iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
            if (rowData.DN_retry_cnt__c == null) rowData.DN_retry_cnt__c = 0;
            if (rowData.DN_retry_cnt__c == null)
                rowData.DN_retry_cnt__c = 0;
            if (rowData.DN_retry_cnt__c < batch_retry_max_cnt) {
                rowData.DN_retry_cnt__c++;
                DNUpsertSchedule.assignOneMinute();
            }
            if (rowData.DN_retry_cnt__c >= batch_retry_max_cnt) {
                rowData.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowData.ErrorLog__c + '错误次数已经超过自动收信设定的最大次数,请手动收信';
                rowData.ErrorLog__c =
                    ex.getMessage() +
                    '\n' +
                    ex.getStackTraceString() +
                    '\n' +
                    rowData.ErrorLog__c +
                    '错误次数已经超过自动收信设定的最大次数,请手动收信';
            }
        }
@@ -540,107 +643,92 @@
            iflog.ErrorLog__c = iflog.ErrorLog__c.subString(0, 32760) + ' ...';
        }
        update iflog;
    }
    //优化两次sql查询 thh 2021-11-02 start
    private static list<Statu_Achievements_DN__c> GetDNList(Set<String> DNNoSet){
        List<Statu_Achievements_DN__c> DNList =
                [select id, Name,
                 DeliveryDate_Raw__c,
                 DeliveryNote_Raw__c,
                 DepartmentNo_Raw__c,
                 EndUserNo_Raw__c,
                 InquiryNo_Raw__c,
                 ReturnMark_Raw__c,
                 SoNo_Raw__c,
                 Opportunity__c,
                 Statu_Achievements__c,
                 endUser__c
                 //电子签收单试点用户赋值
                 ,endUser__r.RecordType.Name
                 // 电子签收单 start
                 , Sales_assistant_name_text__c,
                 RC_Manager__c,ReturnMark__c
                 // 试点用户,届时需要删掉
                 , EsignTestAccount__c
                 // 电子签收单  end
                 //ET召回品不生成签收单 start
                , ETRecalledProducts__c
                 //ET召回品不生成签收单 end
                 //acc标识 start
                 ,ACC_Text__c,
                 Is_Corrosion__c,
                 //无偿出库标识 thh 2021-11-01 start
                 Statu_Achievements__r.orderType__c
                 //无偿出库标识 thh 2021-11-01 end
                 //acc标识 end
                 //Add by Li Jun 20230420 start
                 ,Opportunity__r.OCM_man_province_cus__c
                 //Add By Li Jun 20230420 end
                 from Statu_Achievements_DN__c where
                 Name in: DNNoSet];
    private static list<Statu_Achievements_DN__c> GetDNList(Set<String> DNNoSet) {
        List<Statu_Achievements_DN__c> DNList = [
            SELECT
                id,
                Name,
                DeliveryDate_Raw__c,
                DeliveryNote_Raw__c,
                DepartmentNo_Raw__c,
                EndUserNo_Raw__c,
                InquiryNo_Raw__c,
                ReturnMark_Raw__c,
                SoNo_Raw__c,
                Opportunity__c,
                Statu_Achievements__c,
                endUser__c,
                //电子签收单试点用户赋值
                endUser__r.RecordType.Name,
                // 电子签收单 start
                Sales_assistant_name_text__c,
                RC_Manager__c,
                ReturnMark__c,
                // 试点用户,届时需要删掉
                EsignTestAccount__c,
                // 电子签收单  end
                //ET召回品不生成签收单 start
                ETRecalledProducts__c,
                //ET召回品不生成签收单 end
                //acc标识 start
                ACC_Text__c,
                Is_Corrosion__c,
                //无偿出库标识 thh 2021-11-01 start
                Statu_Achievements__r.orderType__c
            //无偿出库标识 thh 2021-11-01 end
            //acc标识 end
            FROM Statu_Achievements_DN__c
            WHERE Name IN :DNNoSet
        ];
        return DNList;
    }
    global void finish(Database.BatchableContext BC) {
    }
    //Add By Li Jun 0420 Start query management province
    private static Map<String,OCM_Management_Province__c> provinceManagementMap{set;get;}
    public static Map<String,OCM_Management_Province__c> getManagementProvince(){
        if(provinceManagementMap !=null && provinceManagementMap.keySet().size()>0 ){
            return provinceManagementMap;
        }
        provinceManagementMap = new Map<String,OCM_Management_Province__c>();
        List <OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c,Window1__c   from OCM_Management_Province__c];
        for (OCM_Management_Province__c omp: ompList) {
            provinceManagementMap.put(omp.Name,omp);
        }
        return provinceManagementMap;
    }
      //Add By Li Jun 0420 End
    /* 构建签收单:
     * eSFMap 是系统里面现有的签收单
     * key 为 DN号;
     * 退货DN不生成签收单
     */
    @TestVisible
    private static list<eSignForm__c> SetupeSignForm(map <string, eSignForm__c> eSFMap , list<Statu_Achievements_DN__c> DNList){
        list<eSignForm__c> UpsertESFList = new list<eSignForm__c> ();
        for(Statu_Achievements_DN__c tempDN:DNList ){
    private static list<eSignForm__c> SetupeSignForm(map<string, eSignForm__c> eSFMap, list<Statu_Achievements_DN__c> DNList) {
        list<eSignForm__c> UpsertESFList = new List<eSignForm__c>();
        for (Statu_Achievements_DN__c tempDN : DNList) {
            // 获取现有签收单
            eSignForm__c tempeSF = eSFMap.get(tempDN.Name);
            if( tempeSF == null ){
            if (tempeSF == null) {
                tempeSF = new eSignForm__c();
            }
            // 签收单名字 为: DN号-发货日年月日
            string datestr = tempDN.DeliveryDate_Raw__c == null?
            Date.today().format().ReplaceAll('/', ''):
            tempDN.DeliveryDate_Raw__c ;
            tempeSF.Name = string.valueof(integer.valueOf(tempDN.Name)) + '-' +datestr;
            string datestr = tempDN.DeliveryDate_Raw__c == null ? Date.today().format().ReplaceAll('/', '') : tempDN.DeliveryDate_Raw__c;
            tempeSF.Name = string.valueof(integer.valueOf(tempDN.Name)) + '-' + datestr;
            tempeSF.DNName__c = tempDN.Name;
            tempeSF.Statu_Achievements__c = tempDN.Statu_Achievements__c;
            tempeSF.Statu_Achievements_DN__c = tempDN.ID;
            //Updated By Li Jun 20230420 start
            //tempeSF.Sales_assistant_name_text__c = tempDN.Sales_assistant_name_text__c;
            tempeSF.Sales_assistant_name_text__c = tempDN.Opportunity__c != null && tempDN.Opportunity__r.OCM_man_province_cus__c != '' && getManagementProvince().containsKey(tempDN.Opportunity__r.OCM_man_province_cus__c)?
                                                    getManagementProvince().get(tempDN.Opportunity__r.OCM_man_province_cus__c).Window1__c: null;
            tempeSF.Sales_assistant_name_text__c = tempDN.Sales_assistant_name_text__c;
            tempeSF.RC_Manager__c = tempDN.RC_Manager__c;
            //Updated By Li Jun 20230420 end
            //生成签收单时,给是否无偿出库赋值  精琢技术 thh 2021-10-15 start
            if(tempDN.Statu_Achievements__r.orderType__c == 'ZM16'){
            if (tempDN.Statu_Achievements__r.orderType__c == 'ZM16') {
                tempeSF.isFreeDelivery__c = true;
            }
            //生成签收单时,给是否无偿出库赋值  精琢技术 thh 2021-10-15 end
            // 经销商试点用户
            //电子签收单 虚进虚出 明细为racing code 为空的 不生成签收单 20201207 精琢技术 start
            if(tempDN.EsignTestAccount__c && !tempDN.ETRecalledProducts__c&&!tempDN.ReturnMark__c&&(tempDN.ACC_Text__c!='Y'||(tempDN.ACC_Text__c=='Y'&&tempDN.Is_Corrosion__c))){//&&tempDN.Is_Corrosion__c
            if (
                tempDN.EsignTestAccount__c &&
                !tempDN.ETRecalledProducts__c &&
                !tempDN.ReturnMark__c &&
                (tempDN.ACC_Text__c != 'Y' || (tempDN.ACC_Text__c == 'Y' && tempDN.Is_Corrosion__c))
            ) {
                //&&tempDN.Is_Corrosion__c
                //添加危化品标识
                if(tempDN.ACC_Text__c=='Y'&&tempDN.Is_Corrosion__c){//&&tempDN.Is_Corrosion__c
                    tempeSF.Hazardous_Chemicals__c=true;
                if (tempDN.ACC_Text__c == 'Y' && tempDN.Is_Corrosion__c) {
                    //&&tempDN.Is_Corrosion__c
                    tempeSF.Hazardous_Chemicals__c = true;
                }
                UpsertESFList.add(tempeSF);
            }
@@ -663,202 +751,208 @@
    @TestVisible
    private static list<eSignFormLineItem__c> SetupeSignFormLineItems(
        list<Statu_Achievements_DN_details__c> insertSADNdetailList,
        map <string, eSignFormLineItem__c> eSFLMap ,map <string, eSignForm__c> eSFAllMap,
        Map<String, Product2> prdsMap){
            // key 是 DN号 + 箱号 + 产品OTCode
            for(Statu_Achievements_DN_details__c tempDNDetail : insertSADNdetailList){
                string key = tempDNDetail.DNName__c + '-' +
                tempDNDetail.CaseNumber__c + '-' + tempDNDetail.OTCode_Raw__c;
                //获取现有签收单明细
                eSignFormLineItem__c tempeSignFormLineItem = eSFLMap.get(key);
                if( tempeSignFormLineItem == null){
                    tempeSignFormLineItem = new eSignFormLineItem__c();
                    tempeSignFormLineItem.Count__c = 0;
                }
                tempeSignFormLineItem.Count__c++;
                // Double CaseNumber;
                if(string.isBlank(tempDNDetail.CaseNumber__c)){
                    tempeSignFormLineItem.CaseNumber__c = null;
                }else{
                    tempeSignFormLineItem.CaseNumber__c = Double.valueOf(tempDNDetail.CaseNumber__c);
                }
                // Double CaseNumber = tempDNDetail.CaseNumber__c == null ? tempDNDetail.CaseNumber__c : Double.valueOf(tempDNDetail.CaseNumber__c);
                tempeSignFormLineItem.DNProductNo__c = key ;
                tempeSignFormLineItem.Name  = tempDNDetail.CaseNumber__c == null ? String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) + '-' +  tempDNDetail.OTCode_Raw__c:String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) + '-' +
                tempDNDetail.CaseNumber__c + '-' + tempDNDetail.OTCode_Raw__c;
                tempeSignFormLineItem.Product2__c = prdsMap.get(tempDNDetail.OTCode_Raw__c).ID;
                if(eSFAllMap.containskey(tempDNDetail.DNName__c)){
                    tempeSignFormLineItem.eSignForm__c = eSFAllMap.get(tempDNDetail.DNName__c).ID;
                    eSFLMap.put(key,tempeSignFormLineItem);
                }
        map<string, eSignFormLineItem__c> eSFLMap,
        map<string, eSignForm__c> eSFAllMap,
        Map<String, Product2> prdsMap
    ) {
        // key 是 DN号 + 箱号 + 产品OTCode
        for (Statu_Achievements_DN_details__c tempDNDetail : insertSADNdetailList) {
            string key = tempDNDetail.DNName__c + '-' + tempDNDetail.CaseNumber__c + '-' + tempDNDetail.OTCode_Raw__c;
            //获取现有签收单明细
            eSignFormLineItem__c tempeSignFormLineItem = eSFLMap.get(key);
            if (tempeSignFormLineItem == null) {
                tempeSignFormLineItem = new eSignFormLineItem__c();
                tempeSignFormLineItem.Count__c = 0;
            }
            return eSFLMap.values();
            tempeSignFormLineItem.Count__c++;
            // Double CaseNumber;
            if (string.isBlank(tempDNDetail.CaseNumber__c)) {
                tempeSignFormLineItem.CaseNumber__c = null;
            } else {
                tempeSignFormLineItem.CaseNumber__c = Double.valueOf(tempDNDetail.CaseNumber__c);
            }
            // Double CaseNumber = tempDNDetail.CaseNumber__c == null ? tempDNDetail.CaseNumber__c : Double.valueOf(tempDNDetail.CaseNumber__c);
            tempeSignFormLineItem.DNProductNo__c = key;
            tempeSignFormLineItem.Name = tempDNDetail.CaseNumber__c == null
                ? String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) + '-' + tempDNDetail.OTCode_Raw__c
                : String.valueOf(integer.valueOf(tempDNDetail.DNName__c)) +
                  '-' +
                  tempDNDetail.CaseNumber__c +
                  '-' +
                  tempDNDetail.OTCode_Raw__c;
            tempeSignFormLineItem.Product2__c = prdsMap.get(tempDNDetail.OTCode_Raw__c).ID;
            if (eSFAllMap.containskey(tempDNDetail.DNName__c)) {
                tempeSignFormLineItem.eSignForm__c = eSFAllMap.get(tempDNDetail.DNName__c).ID;
                eSFLMap.put(key, tempeSignFormLineItem);
            }
        }
        return eSFLMap.values();
    }
    // 设置发货DN
    private static Statu_Achievements_DN__c SetSADN(
        Statu_Achievements_DN__c tempSADN,
        NFM110Rest.GeneralData infoH,
        Map<String, String> boMap,
        Map<String, Opportunity> oppMap,
      Map<String, Account> accsMap,
        Map < String, String > provinceOwnerMap,
        Map < String, String > provinceGIMap) {
            tempSADN.SoNo_Raw__c = infoH.SoNo;
            tempSADN.InquiryNo_Raw__c = infoH.InquiryNo ;
            tempSADN.ReturnMark_Raw__c = infoH.ReturnMark ;
            tempSADN.DeliveryDate_Raw__c = infoH.DeliveryDate ;
            tempSADN.EndUserNo_Raw__c = infoH.EndUserNo ;
            tempSADN.DepartmentNo_Raw__c = infoH.DepartmentNo ;
            tempSADN.DeliveryNote_Raw__c = infoH.DeliveryNote ;
            // 电子签收单 2020/07/17 start
            tempSADN.supplier__c = infoH.supplier ;
            tempSADN.supplierNo__c = infoH.supplierNo ;
            tempSADN.shippingUnit__c = infoH.shippingUnit ;
            tempSADN.shippingAddress__c = infoH.shippingAddress ;
            tempSADN.contactName__c = infoH.contactName ;
            tempSADN.contactNumber__c = infoH.contactNumber ;
            tempSADN.totalNumber__c = infoH.totalNumber ;
            tempSADN.transportMode__c = infoH.transportMode ;
            tempSADN.totalWeight__c = infoH.totalWeight ;
            //tempSADN.GoodDetails__c = infoH.GoodDetails ;
            //tempSADN.weight__c = infoH.weight ;
            tempSADN.endUser__c = accsMap.get(infoH.EndUserNo) == null ?null : accsMap.get(infoH.EndUserNo).id  ;
        Map<String, Account> accsMap,
        Map<String, String> provinceOwnerMap,
        Map<String, String> provinceGIMap
    ) {
        tempSADN.SoNo_Raw__c = infoH.SoNo;
        tempSADN.InquiryNo_Raw__c = infoH.InquiryNo;
        tempSADN.ReturnMark_Raw__c = infoH.ReturnMark;
        tempSADN.DeliveryDate_Raw__c = infoH.DeliveryDate;
        tempSADN.EndUserNo_Raw__c = infoH.EndUserNo;
        tempSADN.DepartmentNo_Raw__c = infoH.DepartmentNo;
        tempSADN.DeliveryNote_Raw__c = infoH.DeliveryNote;
        // 电子签收单 2020/07/17 start
        tempSADN.supplier__c = infoH.supplier;
        tempSADN.supplierNo__c = infoH.supplierNo;
        tempSADN.shippingUnit__c = infoH.shippingUnit;
        tempSADN.shippingAddress__c = infoH.shippingAddress;
        tempSADN.contactName__c = infoH.contactName;
        tempSADN.contactNumber__c = infoH.contactNumber;
        tempSADN.totalNumber__c = infoH.totalNumber;
        tempSADN.transportMode__c = infoH.transportMode;
        tempSADN.totalWeight__c = infoH.totalWeight;
        //tempSADN.GoodDetails__c = infoH.GoodDetails ;
        //tempSADN.weight__c = infoH.weight ;
        tempSADN.endUser__c = accsMap.get(infoH.EndUserNo) == null ? null : accsMap.get(infoH.EndUserNo).id;
            // 电子签收单 2020/07/17 end
            //增加发货DNacc标识 2020/11/23 start
            if(infoH.ACCMark !=null){
                if(infoH.ACCMark.trim() == 'Y'){
                    tempSADN.ACC_Mark__c = 'Y';
                }else{
                    tempSADN.ACC_Mark__c = 'N';
                }
        // 电子签收单 2020/07/17 end
        //增加发货DNacc标识 2020/11/23 start
        if (infoH.ACCMark != null) {
            if (infoH.ACCMark.trim() == 'Y') {
                tempSADN.ACC_Mark__c = 'Y';
            } else {
                tempSADN.ACC_Mark__c = 'N';
            }
            tempSADN.name = infoH.DeliveryNote;
            tempSADN.ReturnMark__c = infoH.ReturnMark == '1' ? true : false;
            if (tempSADN.Statu_Achievements__c == null) {
                tempSADN.Statu_Achievements__c = boMap.get(infoH.SoNo);
            }
            tempSADN.DeliveryDate__c = NFMUtil.parseStr2Date(infoH.DeliveryDate);
            //发货日在2020/12/01以后的,才生成签收单 start
            Date afterDate = NFMUtil.parseStr2Date('20201201');
            String todate = NFMUtil.formatDate2Str(afterDate);
            String DeliveryDate = NFMUtil.formatDate2Str(tempSADN.DeliveryDate__c);
            //发货日在2020/12/01以后的,才生成签收单 end
            String[] Inquiry;
            if (infoH.InquiryNo != null && infoH.InquiryNo.contains(',')) {
                Inquiry = infoH.InquiryNo.split(',');
                if (oppMap.get(Inquiry[0]) != null) {
                    opportunity opp =  oppMap.get(Inquiry[0]);
                    tempSADN.Opportunity__c = opp.id;
                    tempSADN.Is_Corrosion__c=opp.Is_Corrosion__c;
                    // 电子签收单  赋值营业助理和营业管理部担当 start
                    //集中采购的询价 精琢技术 wql 2020/01/11 start
                    //Add By Li Jun 20230420 Start
                    tempSADN.Sales_assistant_name_text__c =opp.OCM_man_province_cus__c!='' && provinceGIMap.containskey(opp.OCM_man_province_cus__c)?provinceGIMap.get(opp.OCM_man_province_cus__c):null;
                    //Add By Li Jun 20230420 End
                    if(opp.Group_purchase_PCL__c){
                        //tempSADN.Sales_assistant_name_text__c = provinceGIMap.get('集采课'); //Commented By Li Jun 20230420
                        tempSADN.RC_Manager__c =  provinceOwnerMap.get('集采课');
                    }else{
                        //tempSADN.Sales_assistant_name_text__c = opp.Sales_assistant_name_text__c; //Commented By Li Jun 20230420
                        tempSADN.RC_Manager__c =  provinceOwnerMap.get(opp.OCM_man_province_cus__c);
                    }
                    //集中采购的询价 精琢技术 wql 2020/01/11 end
                    //如果 发货日期 大于 2020/12/01 才生成签收单
                    if(DeliveryDate >= todate){
                        tempSADN.EsignTestAccount__c =true;
                    }else{
                        tempSADN.EsignTestAccount__c =false;
                    }
                    //SAP里召回品换出订单的送达方地址如果为奥林巴斯办事处的地址,DN不生成待签收信息。
                    String ContactName = tempSADN.ContactName__c.toUpperCase();
                    if(ContactName.indexOf('OCSM')>=0){
                        tempSADN.ETRecalledProducts__c =true;
                    }else{
                        tempSADN.ETRecalledProducts__c =false;
                    }
                }
                if (Inquiry.size() > 1) {
                    tempSADN.Order_No__c = Inquiry[1];
                }
            }
            return tempSADN;
        }
    private static void checkSA(Statu_Achievements_DN__c tempSADN,
                                List<Statu_Achievements_DN__c> UpsertDNList,
                                BatchIF_Log__c iflog,
                                NFM110rest.GeneralData infoH ) {
                                    if (tempSADN.Statu_Achievements__c != null)
                                        UpsertDNList.add(tempSADN);
                                    else {
                                        iflog.ErrorLog__c += 'warning! SoNo[' + infoH.SoNo +
                                            '] Statu_Achievements__c  NotExist. The insert of this DN is skipped.\n';
                                    }
                                }
    private static DNdetail SetSADNDetails(string DNnumber, boolean returnFlg,
                                           NFM110Rest.DnInformation dnInfo, asset ast, integer tempDNdetailNumber) {
                                               DNdetail tempDNdetail = new DNdetail();
                                               Statu_Achievements_DN_details__c DNd = new Statu_Achievements_DN_details__c();
                                               DNd.Qty_Raw__c = dnInfo.QTY;
                                               DNd.QTY__c = String.isBlank(dnInfo.QTY) || Decimal.valueOf(dnInfo.QTY.trim()) == 0 ?
                                                   1 : Decimal.valueOf(dnInfo.QTY.trim());
                                               DNd.ShippedAmount_without_tax__c = String.isBlank(dnInfo.NetWorth) ?
                                                   0 : returnFlg == false ?
                                                       Decimal.valueOf(dnInfo.NetWorth.trim()) : - Decimal.valueOf(dnInfo.NetWorth.trim());
        tempSADN.name = infoH.DeliveryNote;
        tempSADN.ReturnMark__c = infoH.ReturnMark == '1' ? true : false;
        if (tempSADN.Statu_Achievements__c == null) {
            tempSADN.Statu_Achievements__c = boMap.get(infoH.SoNo);
        }
        tempSADN.DeliveryDate__c = NFMUtil.parseStr2Date(infoH.DeliveryDate);
        //发货日在2020/12/01以后的,才生成签收单 start
        Date afterDate = NFMUtil.parseStr2Date('20201201');
        String todate = NFMUtil.formatDate2Str(afterDate);
        String DeliveryDate = NFMUtil.formatDate2Str(tempSADN.DeliveryDate__c);
        //发货日在2020/12/01以后的,才生成签收单 end
                                               DNd.ShippedAmount__c = String.isBlank(dnInfo.VALUE) ?
                                                   0 : returnFlg == false ?
                                                       Decimal.valueOf(dnInfo.VALUE.trim()) : - Decimal.valueOf(dnInfo.VALUE.trim());
        String[] Inquiry;
        if (infoH.InquiryNo != null && infoH.InquiryNo.contains(',')) {
            Inquiry = infoH.InquiryNo.split(',');
            if (oppMap.get(Inquiry[0]) != null) {
                opportunity opp = oppMap.get(Inquiry[0]);
                tempSADN.Opportunity__c = opp.id;
                tempSADN.Is_Corrosion__c = opp.Is_Corrosion__c;
                // 电子签收单  赋值营业助理和营业管理部担当 start
                //集中采购的询价 精琢技术 wql 2020/01/11 start
                if (opp.Group_purchase_PCL__c) {
                    tempSADN.Sales_assistant_name_text__c = provinceGIMap.get('集采课');
                    tempSADN.RC_Manager__c = provinceOwnerMap.get('集采课');
                } else {
                    tempSADN.Sales_assistant_name_text__c = opp.Sales_assistant_name_text__c;
                    tempSADN.RC_Manager__c = provinceOwnerMap.get(opp.OCM_man_province_cus__c);
                }
                //集中采购的询价 精琢技术 wql 2020/01/11 end
                                               DNd.NetWorthNoProviston__c = String.isBlank(dnInfo.NetWorthNoProviston) ?
                                                   0 : returnFlg == false ?
                                                       Decimal.valueOf(dnInfo.NetWorthNoProviston.trim()) : - Decimal.valueOf(dnInfo.NetWorthNoProviston.trim());
                                               if (dnInfo.SorLMark == 'S') {
                                                   DNd.SerialNumber__c = dnInfo.SerialNoorLotNo;
                                               } else {
                                                   DNd.SerialNumber__c  = dnInfo.SerialNoorLotNo + '(' + dnInfo.TracingCode + ')';
                                               }
                                               DNd.Product_Serial_No__c = dnInfo.OTCode + ':' + DNd.SerialNumber__c;
                                               DNd.DNProduct_Serial_No__c = DNnumber + ':' + DNd.Product_Serial_No__c;
                                               if (dnInfo.SerialNoorLotNo != null && dnInfo.SerialNoorLotNo.equals('.')) {
                                                   DNd.DNProduct_Serial_No__c += tempDNdetailNumber;
                                               }
                                               // 电子签收单 start
                                               DNd.CaseNumber__c = NFMUtil.trimLeft(dnInfo.CaseNumber, '0');
                                               // 电子签收单 end
                //如果 发货日期 大于 2020/12/01 才生成签收单
                if (DeliveryDate >= todate) {
                    tempSADN.EsignTestAccount__c = true;
                } else {
                    tempSADN.EsignTestAccount__c = false;
                }
                                               DNd.Barcode_Raw__c = dnInfo.Barcode;
                                               DNd.OTCode_Raw__c = dnInfo.OTCode;
                                               DNd.SerialNoorLotNo_Raw__c = dnInfo.SerialNoorLotNo;
                                               DNd.SorLMark_Raw__c = dnInfo.SorLMark;
                                               DNd.GuaranteePeriod_Raw__c = dnInfo.GuaranteePeriod;
                                               DNd.TracingCode_Raw__c = dnInfo.TracingCode;
                                               DNd.ValidTo_Raw__c = dnInfo.ValidTo;
                                               DNd.NetWorth_Raw__c = dnInfo.NetWorth;
                                               DNd.GuaranteePrice_Raw__c    = dnInfo.GuaranteePrice;
                                               DNd.GuaranteeType_Raw__c     = dnInfo.GuaranteeType;
                                               DNd.MaintenancePrice_Raw__c = dnInfo.MaintenancePrice;
                                               DNd.NetWorthNoProviston_Raw__c = dnInfo.NetWorthNoProviston;
                                               DNd.ProduceDate_Raw__c = dnInfo.ProduceDate;
                                               DNd.ProvistonPeriod_Raw__c = dnInfo.ProvistonPeriod;
                                               DNd.ServicePrice_Raw__c = dnInfo.ServicePrice;
                                               DNd.VALUE_Raw__c = dnInfo.VALUE;
                                               DNd.NetWorth_Raw__c = dnInfo.NetWorth;
                                               DNd.NMPA_Approbation_No__c = dnInfo.NMPA_NO;
                                               DNd.ProduceCompany__c = dninfo.Provider;
                                               tempDNdetail.DeliveryNote = DNnumber;
                                               tempDNdetail.DNd = DNd;
                                               if (ast != null && ast.id != null) {
                                                   tempDNdetail.DNd.asset__c = ast.id;
                                               }
                                               return tempDNdetail;
                                           }
                //SAP里召回品换出订单的送达方地址如果为奥林巴斯办事处的地址,DN不生成待签收信息。
                String ContactName = tempSADN.ContactName__c.toUpperCase();
                if (ContactName.indexOf('OCSM') >= 0) {
                    tempSADN.ETRecalledProducts__c = true;
                } else {
                    tempSADN.ETRecalledProducts__c = false;
                }
            }
            if (Inquiry.size() > 1) {
                tempSADN.Order_No__c = Inquiry[1];
            }
        }
        return tempSADN;
    }
    private static void checkSA(
        Statu_Achievements_DN__c tempSADN,
        List<Statu_Achievements_DN__c> UpsertDNList,
        BatchIF_Log__c iflog,
        NFM110rest.GeneralData infoH
    ) {
        if (tempSADN.Statu_Achievements__c != null)
            UpsertDNList.add(tempSADN);
        else {
            iflog.ErrorLog__c += 'warning! SoNo[' + infoH.SoNo + '] Statu_Achievements__c  NotExist. The insert of this DN is skipped.\n';
        }
    }
    private static DNdetail SetSADNDetails(
        string DNnumber,
        boolean returnFlg,
        NFM110Rest.DnInformation dnInfo,
        asset ast,
        integer tempDNdetailNumber
    ) {
        DNdetail tempDNdetail = new DNdetail();
        Statu_Achievements_DN_details__c DNd = new Statu_Achievements_DN_details__c();
        DNd.Qty_Raw__c = dnInfo.QTY;
        DNd.QTY__c = String.isBlank(dnInfo.QTY) || Decimal.valueOf(dnInfo.QTY.trim()) == 0 ? 1 : Decimal.valueOf(dnInfo.QTY.trim());
        DNd.ShippedAmount_without_tax__c = String.isBlank(dnInfo.NetWorth)
            ? 0
            : returnFlg == false ? Decimal.valueOf(dnInfo.NetWorth.trim()) : -Decimal.valueOf(dnInfo.NetWorth.trim());
        DNd.ShippedAmount__c = String.isBlank(dnInfo.VALUE)
            ? 0
            : returnFlg == false ? Decimal.valueOf(dnInfo.VALUE.trim()) : -Decimal.valueOf(dnInfo.VALUE.trim());
        DNd.NetWorthNoProviston__c = String.isBlank(dnInfo.NetWorthNoProviston)
            ? 0
            : returnFlg == false ? Decimal.valueOf(dnInfo.NetWorthNoProviston.trim()) : -Decimal.valueOf(dnInfo.NetWorthNoProviston.trim());
        if (dnInfo.SorLMark == 'S') {
            DNd.SerialNumber__c = dnInfo.SerialNoorLotNo;
        } else {
            DNd.SerialNumber__c = dnInfo.SerialNoorLotNo + '(' + dnInfo.TracingCode + ')';
        }
        DNd.Product_Serial_No__c = dnInfo.OTCode + ':' + DNd.SerialNumber__c;
        DNd.DNProduct_Serial_No__c = DNnumber + ':' + DNd.Product_Serial_No__c;
        if (dnInfo.SerialNoorLotNo != null && dnInfo.SerialNoorLotNo.equals('.')) {
            DNd.DNProduct_Serial_No__c += tempDNdetailNumber;
        }
        // 电子签收单 start
        DNd.CaseNumber__c = NFMUtil.trimLeft(dnInfo.CaseNumber, '0');
        // 电子签收单 end
        DNd.Barcode_Raw__c = dnInfo.Barcode;
        DNd.OTCode_Raw__c = dnInfo.OTCode;
        DNd.SerialNoorLotNo_Raw__c = dnInfo.SerialNoorLotNo;
        DNd.SorLMark_Raw__c = dnInfo.SorLMark;
        DNd.GuaranteePeriod_Raw__c = dnInfo.GuaranteePeriod;
        DNd.TracingCode_Raw__c = dnInfo.TracingCode;
        DNd.ValidTo_Raw__c = dnInfo.ValidTo;
        DNd.NetWorth_Raw__c = dnInfo.NetWorth;
        DNd.GuaranteePrice_Raw__c = dnInfo.GuaranteePrice;
        DNd.GuaranteeType_Raw__c = dnInfo.GuaranteeType;
        DNd.MaintenancePrice_Raw__c = dnInfo.MaintenancePrice;
        DNd.NetWorthNoProviston_Raw__c = dnInfo.NetWorthNoProviston;
        DNd.ProduceDate_Raw__c = dnInfo.ProduceDate;
        DNd.ProvistonPeriod_Raw__c = dnInfo.ProvistonPeriod;
        DNd.ServicePrice_Raw__c = dnInfo.ServicePrice;
        DNd.VALUE_Raw__c = dnInfo.VALUE;
        DNd.NetWorth_Raw__c = dnInfo.NetWorth;
        DNd.NMPA_Approbation_No__c = dnInfo.NMPA_NO;
        DNd.ProduceCompany__c = dninfo.Provider;
        tempDNdetail.DeliveryNote = DNnumber;
        tempDNdetail.DNd = DNd;
        if (ast != null && ast.id != null) {
            tempDNdetail.DNd.asset__c = ast.id;
        }
        return tempDNdetail;
    }
    @TestVisible
    private static String checkSerialNoorLotNo(String sn) {
        if (sn == null || sn == '' || sn.length() < 8) {
@@ -900,4 +994,4 @@
        }
        return sn;
    }
}
}
force-app/main/default/classes/DNUpsertBatchTest.cls
@@ -221,13 +221,5 @@
        prdsMap.put(prd.ProductCode_Ext__c, prd);
        DNUpsertBatch.SetupeSignFormLineItems(insertSADNdetailList, eSFLMap, eSFMap, prdsMap);
        //Add By DTT - Li Jun Start 20230425
        OCM_Management_Province__c ocsmTest = new OCM_Management_Province__c();
        ocsmTest.Name = '其他';
        ocsmTest.Province__c = '北京市';
        ocsmTest.Window1__c = UserInfo.getUserId();
        insert ocsmTest;
        Map<String, OCM_Management_Province__c> provinceMap = DNUpsertBatch.getManagementProvince();
        //Add by DTT - Li Jun End 20230425
    }
}
force-app/main/default/classes/InventoryViewController.cls
@@ -1,40 +1,48 @@
public without sharing class InventoryViewController {
    /*****************画面表示Bean******************/
    public List<ConsumableorderdetailsInfo> consumableorderdetailsRecords =new List<ConsumableorderdetailsInfo>();
    public List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
    public List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
    //page
    Public Integer pagesize{get; set;}
    Public Integer totalcount{get; set;}
    Public Integer pagecount{get; set;}
    Public Integer currentpage{get; set;}
    public Boolean hasPrevious{get; set;}
    public Boolean hasNext{get; set;}
    public Integer pagesize { get; set; }
    public Integer totalcount { get; set; }
    public Integer pagecount { get; set; }
    public Integer currentpage { get; set; }
    public Boolean hasPrevious { get; set; }
    public Boolean hasNext { get; set; }
    public List<ConsumableorderdetailsInfo> pageRecords { get; set; }
    public String soql {get;set;}
    public String soql { get; set; }
    public String sortKey { get; set; }
    public String preSortKey { get; private set; }
    public Boolean sortOrderAsc { get; private set; }
    public String[] sortOrder { get; private set; }
    private String[] columus = new String[]{ 'Product2__c.Name__c','Asset_Model_No__c','','Category3__c','Category4__c','Category5__c',''};
    String[] proLimitAndDate =new String[]{};
    private Map<String,Date> productkucun = new Map<String,Date>();
    public List<SelectOption> categoryOptionList{get;set;}
    public List<SelectOption> category4OptionList{get;set;}
    public List<SelectOption> category5OptionList{get;set;}
    private String[] columus = new List<String>{
        'Product2__c.Name__c',
        'Asset_Model_No__c',
        '',
        'Category3__c',
        'Category4__c',
        'Category5__c',
        ''
    };
    String[] proLimitAndDate = new List<String>{};
    private Map<String, Date> productkucun = new Map<String, Date>();
    public List<SelectOption> categoryOptionList { get; set; }
    public List<SelectOption> category4OptionList { get; set; }
    public List<SelectOption> category5OptionList { get; set; }
    public String category5 { get; set; }
    public String category4 { get; set; }
    public String category3 { get; set; }
    public String category_Goods {get ; set;}
    public String category_Goods { get; set; }
    public String category1 { get; set; }
    public Boolean editAble {get;set;}
    public Boolean editAble { get; set; }
    // 经销商在库产品ID
    List<String> orderDetZaikuList = new List<String>();
    // 产品 ID
    public String ESetId  { get; set; }
    public String idCheck {get;set;}
    public String ESetId { get; set; }
    public String idCheck { get; set; }
    /*****************ソート時再検索条件(画面からの入力条件を無視するため)******************/
    private String accountid = null;
    public String accountName { get; set; }
@@ -43,11 +51,11 @@
    // 登录者工作地
    private String userWorkLocation;
    //经销商用户产品分类(ET、ENG)
    public String agencyProType {get;set;}
    public String agencyProType { get; set; }
    String sqlagencyProType;
    //add by rentx 2021-3-10
    public Boolean hasHos {get;set;}
    public Boolean hasHos { get; set; }
    //add by rentx 2021-3-10
    public InventoryViewController() {
@@ -64,162 +72,176 @@
    }
    // 画面初始化
    public void init() {
        this.sortKey = '2';
        this.preSortKey = '2';
        this.sortOrderAsc = false;
        this.sortOrder = new String[8];
        this.sortOrder = new String[]{' ','',' ',' ','','','','↓'};
        this.sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '↓' };
        //取用户ID
        String userId = UserInfo.getUserId();
        User useracc = [select Accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:userId];
        User useracc = [SELECT Accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
        accountid = useracc.accountid;
        userWorkLocation = useracc.Work_Location__c;
        agencyProType = Useracc.UserPro_Type__c;
        if(String.isBlank(Useracc.UserPro_Type__c)){
        if (String.isBlank(Useracc.UserPro_Type__c)) {
            agencyProType = 'ET';
        }
        Account accountInfo = [SELECT Name,Dealer_discount__c,Product_Limit_Date__c FROM account WHERE id =:accountid];
        Account accountInfo = [SELECT Name, Dealer_discount__c, Product_Limit_Date__c FROM account WHERE id = :accountid];
        accountName = accountInfo.Name;
        //经销商查看产品
        String product_Limit = accountInfo.Product_Limit_Date__c;
        if(product_Limit != null && product_Limit !=''){
        if (product_Limit != null && product_Limit != '') {
            proLimitAndDate = product_Limit.split(',');
        }
        List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
        Map<String,Product2__c> MidMap = new Map<String,Product2__c>();
        Map<String,ConsumableorderdetailsInfo> newMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String,ConsumableorderdetailsInfo> newMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String, Product2__c> MidMap = new Map<String, Product2__c>();
        Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
        //库存明细取得
        sqlagencyProType = '%' + agencyProType + '%';
        orderDetZaikuList = new List<String>();
        List<AggregateResult>  orderDetZaiku = [SELECT count(Id),
                                                      Consumable_Product__c
                                                FROM Consumable_order_details2__c
                                                WHERE Dealer_Arrive__c = true
                                                AND Dealer_Shipment__c = false
                                                AND Dealer_Saled__c = false
                                                AND Lose_Flag__c = false
                                                AND Dealer_Returned__c = false
                                                AND Bar_Code__c !=null
                                                AND Product_Type__c like : sqlagencyProType
                                                AND Dealer_Info_text__c = :accountName
                                                AND Cancellation_Flag__c = false
                                                AND Arrive_Owner_Work_Location__c =: userWorkLocation
                                                group by Consumable_Product__c];
        for(AggregateResult zaikuId : orderDetZaiku){
        List<AggregateResult> orderDetZaiku = [
            SELECT count(Id), Consumable_Product__c
            FROM Consumable_order_details2__c
            WHERE
                Dealer_Arrive__c = TRUE
                AND Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Lose_Flag__c = FALSE
                AND Dealer_Returned__c = FALSE
                AND Bar_Code__c != NULL
                AND Product_Type__c LIKE :sqlagencyProType
                AND Dealer_Info_text__c = :accountName
                AND Cancellation_Flag__c = FALSE
                AND Arrive_Owner_Work_Location__c = :userWorkLocation
            GROUP BY Consumable_Product__c
        ];
        for (AggregateResult zaikuId : orderDetZaiku) {
            orderDetZaikuList.add(String.valueOf(zaikuId.get('Consumable_Product__c')));
        }
        List<Consumable_order_details2__c> CountDel = [SELECT Id,
                            Bar_Code__c,
                            Name,
                            Inventory_date__c,
                            Consumable_Product__c,
                            Recordtypeid,
                            Guarantee_period_for_products__c,
                            Isoverdue__c,
                            Box_Piece__c,
                            hospitalSpecialOffer__c
                        FROM Consumable_order_details2__c
                        WHERE Dealer_Arrive__c = true
                        AND Dealer_Shipment__c = false
                        AND Dealer_Saled__c = false
                        AND Dealer_Returned__c = false
                        AND Lose_Flag__c = false
                        AND Cancellation_Flag__c = false
                        AND Bar_Code__c !=null
                        AND Product_Type__c like : sqlagencyProType
                        AND Dealer_Info_text__c = :accountName
                        AND Arrive_Owner_Work_Location__c =: userWorkLocation
                        ];
        List<Product2__c> product2Selected = [select Id, Name,Name__c,Intra_Trade_List_RMB__c,
                                Asset_Model_No__c,
                                Category3__c,Category4__c,Category5__c,
                                SFDA_Status__c,
                                Product2__r.SFDA_Approbation_No__c,
                                Product2__r.SFDA_Expiration_Date__c,
                                Product2__r.Packing_list_manual__c
                            FROM Product2__c
                            WHERE Id in : orderDetZaikuList ];
        List<Consumable_order_details2__c> CountDel = [
            SELECT
                Id,
                Bar_Code__c,
                Name,
                Inventory_date__c,
                Consumable_Product__c,
                Recordtypeid,
                Guarantee_period_for_products__c,
                Isoverdue__c,
                Box_Piece__c,
                hospitalSpecialOffer__c
            FROM Consumable_order_details2__c
            WHERE
                Dealer_Arrive__c = TRUE
                AND Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                AND Cancellation_Flag__c = FALSE
                AND Bar_Code__c != NULL
                AND Product_Type__c LIKE :sqlagencyProType
                AND Dealer_Info_text__c = :accountName
                AND Arrive_Owner_Work_Location__c = :userWorkLocation
        ];
        List<Product2__c> product2Selected = [
            SELECT
                Id,
                Name,
                Name__c,
                Intra_Trade_List_RMB__c,
                Asset_Model_No__c,
                Category3__c,
                Category4__c,
                Category5__c,
                SFDA_Status__c,
                Product2__r.SFDA_Approbation_No__c,
                Product2__r.SFDA_Expiration_Date__c,
                Product2__r.Packing_list_manual__c
            FROM Product2__c
            WHERE Id IN :orderDetZaikuList
        ];
        for (Integer i = 0; i < product2Selected.size(); i++) {
            MidMap.put(product2Selected[i].Id, product2Selected[i]);
        }
        /////////////////////====================================update by rentx
        Map<String,ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String,ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
        //update by rentx 2021-01-27 start
        for(Integer i = 0 ; i< CountDel.size();i++){
        for (Integer i = 0; i < CountDel.size(); i++) {
            //然后循环CountDel做Box和piece2个map
            if(MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '盒'){
            if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '盒') {
                String tex = 'A';
                if (CountDel[i].hospitalSpecialOffer__c) {
                    tex = 'B';
                }
                if(newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex)){
                    ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex).clone();
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                if (newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
                    ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)
                        .clone();
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                }else{
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                } else {
                    ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                }
            }else if(MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '个'){
            } else if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '个') {
                String tex = 'A';
                if (CountDel[i].hospitalSpecialOffer__c) {
                    tex = 'B';
                }
                if(newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c  + tex)){
                    ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex).clone();
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                if (newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
                    ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
                            CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex
                        )
                        .clone();
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                }else{
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                } else {
                    ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                }
            }
        }
        consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
        //把Boxmap里的值从新赋给boxRecords
        for(ConsumableorderdetailsInfo bss : newMidBoxMap.values()){
            if(bss.allnumber>0){
        for (ConsumableorderdetailsInfo bss : newMidBoxMap.values()) {
            if (bss.allnumber > 0) {
                bss.sortBy = false;
                bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
                bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
@@ -230,43 +252,42 @@
        }
        boxRecords.sort();
        for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
            if(bss.allnumber>0){
        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
            if (bss.allnumber > 0) {
                bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
                bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
                bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
                bss.overlimitCount = bss.allnumber - bss.limitCount;
            }
        }
        for(ConsumableorderdetailsInfo bss : boxRecords){
        for (ConsumableorderdetailsInfo bss : boxRecords) {
            consumableorderdetailsRecords.add(bss);
            //该产品是医院特价产品
            if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id+'个B')) {
                if (newMidPieceMap.get(bss.Prod.Id+'个B').hospitalSpecialOffer) {
                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id+'个B'));
                    newMidPieceMap.remove(bss.Prod.Id+'个B');
            if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '个B')) {
                if (newMidPieceMap.get(bss.Prod.Id + '个B').hospitalSpecialOffer) {
                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个B'));
                    newMidPieceMap.remove(bss.Prod.Id + '个B');
                }
            }
            if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id+'个A')) {
            if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '个A')) {
                // if (newMidPieceMap.get(bss.Prod.Id+'个A')) {
                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id+'个A'));
                    newMidPieceMap.remove(bss.Prod.Id+'个A');
                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个A'));
                newMidPieceMap.remove(bss.Prod.Id + '个A');
                // }
            }
        }
        for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
            if (newMidPieceMap.containsKey(bss.Prod.Id+'个B')) {
        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
            if (newMidPieceMap.containsKey(bss.Prod.Id + '个B')) {
                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个B'));
            }
        }
        for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
            if (newMidPieceMap.containsKey(bss.Prod.Id+'个A')) {
        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
            if (newMidPieceMap.containsKey(bss.Prod.Id + '个A')) {
                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个A'));
            }
        }
        /////////////////////====================================update by rentx
        /*for(Integer i = 0 ; i< CountDel.size();i++){
@@ -346,132 +367,176 @@
        //update by rentx 2021-01-27 end
        productLimtAndDate();
          datelimitSearch();
        datelimitSearch();
        //add by rentx 2021-3-10 start
        Integer hosnum = 0;
        //add by rentx 2021-3-10 end
        for(ConsumableorderdetailsInfo bss : consumableorderdetailsRecords){
            if(productkucun.get(bss.Prod.Id) != null){
        for (ConsumableorderdetailsInfo bss : consumableorderdetailsRecords) {
            if (productkucun.get(bss.Prod.Id) != null) {
                bss.guaranteeperiod = productkucun.get(bss.Prod.Id);
            }
            //add by rentx 2021-3-10 start
            if (bss.hospitalSpecialOffer) {
                hosnum = hosnum +1;
                hosnum = hosnum + 1;
            }
        }
        if (hosnum > 0) {
            hasHos = true;
        }else{
        } else {
            hasHos = false;
        }
        //add by rentx 2021-3-10 end
        //listCut();
        AggregateResult[] categoryList = [select Count(id), Category3_text__c c3c from Product2__c WHERE Estimation_Entry_Possibility__c = '○' AND Product_Type__c like :agencyProType AND Category3_text__c != null group by Category3_text__c];
         categoryOptionList = new List<SelectOption>();
         categoryOptionList.add(new SelectOption('', '-无-'));
         for(AggregateResult category3Search : categoryList) {
        AggregateResult[] categoryList = [
            SELECT Count(id), Category3_text__c c3c
            FROM Product2__c
            WHERE Estimation_Entry_Possibility__c = '○' AND Product_Type__c LIKE :agencyProType AND Category3_text__c != NULL
            GROUP BY Category3_text__c
        ];
        categoryOptionList = new List<SelectOption>();
        categoryOptionList.add(new SelectOption('', '-无-'));
        for (AggregateResult category3Search : categoryList) {
            String deliverycnt = String.valueOf(category3Search.get('c3c'));
            categoryOptionList.add(new SelectOption(deliverycnt,deliverycnt));
         }
            categoryOptionList.add(new SelectOption(deliverycnt, deliverycnt));
        }
         category4OptionList = new List<SelectOption>();
         category4OptionList.add(new SelectOption('', '-无-'));
         category5OptionList = new List<SelectOption>();
         category5OptionList.add(new SelectOption('', '-无-'));
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        //总件数
        totalcount = consumableorderdetailsRecords.size();
        //页数
        pagecount=(totalcount  +  pagesize  - 1) / pagesize;
        pagecount = (totalcount + pagesize - 1) / pagesize;
        //显示第一页
        moveToFirst();
        makeCurrentPageRecords();
    }
  public void categoryAllload() {
         AggregateResult[] category4List = [select Count(id), Category4_text__c c4c from Product2__c WHERE Estimation_Entry_Possibility__c = '○' AND Category3_text__c=:category3 AND Product_Type__c like :agencyProType AND Category4_text__c != null AND Category5_text__c != null group by Category4_text__c];
         category4OptionList = new List<SelectOption>();
         category4OptionList.add(new SelectOption('', '-无-'));
         for(AggregateResult category4Search : category4List) {
    public void categoryAllload() {
        AggregateResult[] category4List = [
            SELECT Count(id), Category4_text__c c4c
            FROM Product2__c
            WHERE
                Estimation_Entry_Possibility__c = '○'
                AND Category3_text__c = :category3
                AND Product_Type__c LIKE :agencyProType
                AND Category4_text__c != NULL
                AND Category5_text__c != NULL
            GROUP BY Category4_text__c
        ];
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        for (AggregateResult category4Search : category4List) {
            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
            category4OptionList.add(new SelectOption(deliverycnt4,deliverycnt4));
         }
            category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
        }
           AggregateResult[] category5List = [select Count(id), Category5_text__c c5c from Product2__c WHERE Estimation_Entry_Possibility__c = '○' AND Category3_text__c=:category3 AND Product_Type__c like :agencyProType AND Category4_text__c != null AND Category5_text__c != null group by Category5_text__c];
         category5OptionList = new List<SelectOption>();
         category5OptionList.add(new SelectOption('', '-无-'));
         for(AggregateResult category5Search : category5List) {
        AggregateResult[] category5List = [
            SELECT Count(id), Category5_text__c c5c
            FROM Product2__c
            WHERE
                Estimation_Entry_Possibility__c = '○'
                AND Category3_text__c = :category3
                AND Product_Type__c LIKE :agencyProType
                AND Category4_text__c != NULL
                AND Category5_text__c != NULL
            GROUP BY Category5_text__c
        ];
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        for (AggregateResult category5Search : category5List) {
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5,deliverycnt5));
         }
            category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
        }
    }
    public void categoryload() {
         AggregateResult[] category4List = [select Count(id), Category4_text__c c4c from Product2__c WHERE Estimation_Entry_Possibility__c = '○' AND Category3_text__c=:category3 AND Product_Type__c like :agencyProType AND Category4_text__c != null AND Category5_text__c != null group by Category4_text__c];
         category4OptionList = new List<SelectOption>();
         category4OptionList.add(new SelectOption('', '-无-'));
         for(AggregateResult category4Search : category4List) {
        AggregateResult[] category4List = [
            SELECT Count(id), Category4_text__c c4c
            FROM Product2__c
            WHERE
                Estimation_Entry_Possibility__c = '○'
                AND Category3_text__c = :category3
                AND Product_Type__c LIKE :agencyProType
                AND Category4_text__c != NULL
                AND Category5_text__c != NULL
            GROUP BY Category4_text__c
        ];
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        for (AggregateResult category4Search : category4List) {
            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
            category4OptionList.add(new SelectOption(deliverycnt4,deliverycnt4));
         }
            category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
        }
           AggregateResult[] category5List = [select Count(id), Category5_text__c c5c from Product2__c WHERE Estimation_Entry_Possibility__c = '○' AND Category3_text__c=:category3 AND Product_Type__c like :agencyProType AND Category4_text__c=:category4 AND Category5_text__c != null group by Category5_text__c];
         category5OptionList = new List<SelectOption>();
         category5OptionList.add(new SelectOption('', '-无-'));
         for(AggregateResult category5Search : category5List) {
        AggregateResult[] category5List = [
            SELECT Count(id), Category5_text__c c5c
            FROM Product2__c
            WHERE
                Estimation_Entry_Possibility__c = '○'
                AND Category3_text__c = :category3
                AND Product_Type__c LIKE :agencyProType
                AND Category4_text__c = :category4
                AND Category5_text__c != NULL
            GROUP BY Category5_text__c
        ];
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        for (AggregateResult category5Search : category5List) {
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5,deliverycnt5));
         }
            category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
        }
    }
        // 检索
    // 检索
    public void searchConsumableorderdetails() {
        this.sortKey = '2';
        this.preSortKey = '2';
        this.sortOrderAsc = false;
        this.sortOrder = new String[8];
        this.sortOrder = new String[]{' ','',' ',' ','','','','↓'};
        this.sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '↓' };
        List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
        List<Consumable_order_details2__c> CountDel = [SELECT Id,
                            Bar_Code__c,
                            Name,
                            Inventory_date__c,
                            Consumable_Product__c,
                            Recordtypeid,
                            Guarantee_period_for_products__c,
                            Isoverdue__c,
                            Box_Piece__c,
                            hospitalSpecialOffer__c
                        FROM Consumable_order_details2__c
                        WHERE Dealer_Arrive__c = true
                        AND Dealer_Shipment__c = false
                        AND Dealer_Saled__c = false
                        AND Dealer_Returned__c = false
                        AND Lose_Flag__c = false
                        AND Bar_Code__c !=null
                        AND Product_Type__c like : sqlagencyProType
                        AND Dealer_Info_text__c = :accountName
                        AND Arrive_Owner_Work_Location__c =: userWorkLocation
                        ];
        List<Consumable_order_details2__c> CountDel = [
            SELECT
                Id,
                Bar_Code__c,
                Name,
                Inventory_date__c,
                Consumable_Product__c,
                Recordtypeid,
                Guarantee_period_for_products__c,
                Isoverdue__c,
                Box_Piece__c,
                hospitalSpecialOffer__c
            FROM Consumable_order_details2__c
            WHERE
                Dealer_Arrive__c = TRUE
                AND Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                AND Bar_Code__c != NULL
                AND Product_Type__c LIKE :sqlagencyProType
                AND Dealer_Info_text__c = :accountName
                AND Arrive_Owner_Work_Location__c = :userWorkLocation
        ];
        List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
        Map<String,Product2__c> MidMap = new Map<String,Product2__c>();
        Map<String,ConsumableorderdetailsInfo> newMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String,ConsumableorderdetailsInfo> newMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String, Product2__c> MidMap = new Map<String, Product2__c>();
        Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
        // 所有产品取得
        String soql = this.makeSoql(category1,category_Goods,category3,category4,category5);
        String soql = this.makeSoql(category1, category_Goods, category3, category4, category5);
        System.debug('====>soql11' + soql);
        //soql += ' ORDER BY ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last');
        List<Product2__c> queryList = Database.query(soql);
        for (Integer i = 0; i < queryList.size(); i++) {
@@ -519,8 +584,8 @@
                }
            }
        } 注释by rentx */
        Map<String,ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String,ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> newHosMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
        /*for(Integer i = 0 ; i< CountDel.size();i++){
            //如果是 医院特价创建的明细2  则   update and add by rentx 2020-11-26 start
@@ -620,75 +685,78 @@
                
            }
        }*/
        for(Integer i = 0 ; i< CountDel.size();i++){
        for (Integer i = 0; i < CountDel.size(); i++) {
            //然后循环CountDel做Box和piece2个map
            if(MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '盒'){
            if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '盒') {
                String tex = 'A';
                if (CountDel[i].hospitalSpecialOffer__c) {
                    tex = 'B';
                }
                if(newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex)){
                    ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex).clone();
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                if (newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
                    ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)
                        .clone();
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                }else{
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                } else {
                    ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                    newMidBoxMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                }
            }else if(MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '个'){
            } else if (MidMap.containsKey(CountDel[i].Consumable_Product__c) && CountDel[i].Box_Piece__c == '个') {
                String tex = 'A';
                if (CountDel[i].hospitalSpecialOffer__c) {
                    tex = 'B';
                }
                if(newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c  + tex)){
                    ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex).clone();
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                if (newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
                    ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
                            CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex
                        )
                        .clone();
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                }else{
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                } else {
                    ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(CountDel[i].Consumable_Product__c));
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Isoverdue__c == 1){
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Isoverdue__c == 1) {
                        Jstage.limitCount = Jstage.limitCount + 1;
                    }
                    Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else {
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex, Jstage);
                    newMidPieceMap.put(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex, Jstage);
                }
            }
        }
        consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
        //把Boxmap里的值从新赋给boxRecords
        for(ConsumableorderdetailsInfo bss : newMidBoxMap.values()){
            if(bss.allnumber>0){
        for (ConsumableorderdetailsInfo bss : newMidBoxMap.values()) {
            if (bss.allnumber > 0) {
                bss.sortBy = false;
                bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
                bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
@@ -699,43 +767,42 @@
        }
        boxRecords.sort();
        for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
            if(bss.allnumber>0){
        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
            if (bss.allnumber > 0) {
                bss.packing_list = Integer.valueof(bss.Prod.Product2__r.Packing_list_manual__c);
                bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
                bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
                bss.overlimitCount = bss.allnumber - bss.limitCount;
            }
        }
        for(ConsumableorderdetailsInfo bss : boxRecords){
        for (ConsumableorderdetailsInfo bss : boxRecords) {
            consumableorderdetailsRecords.add(bss);
            //该产品是医院特价产品
            if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id+'个B')) {
                if (newMidPieceMap.get(bss.Prod.Id+'个B').hospitalSpecialOffer) {
                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id+'个B'));
                    newMidPieceMap.remove(bss.Prod.Id+'个B');
            if (bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '个B')) {
                if (newMidPieceMap.get(bss.Prod.Id + '个B').hospitalSpecialOffer) {
                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个B'));
                    newMidPieceMap.remove(bss.Prod.Id + '个B');
                }
            }
            if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id+'个A')) {
            if (!bss.hospitalSpecialOffer && newMidPieceMap.containsKey(bss.Prod.Id + '个A')) {
                // if (newMidPieceMap.get(bss.Prod.Id+'个A')) {
                    consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id+'个A'));
                    newMidPieceMap.remove(bss.Prod.Id+'个A');
                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个A'));
                newMidPieceMap.remove(bss.Prod.Id + '个A');
                // }
            }
        }
        for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
            if (newMidPieceMap.containsKey(bss.Prod.Id+'个B')) {
        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
            if (newMidPieceMap.containsKey(bss.Prod.Id + '个B')) {
                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个B'));
            }
        }
        for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
            if (newMidPieceMap.containsKey(bss.Prod.Id+'个A')) {
        for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
            if (newMidPieceMap.containsKey(bss.Prod.Id + '个A')) {
                consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个A'));
            }
        }
        /////////////////////====================================update by rentx
        /*//把Boxmap里的值从新赋给boxRecords
        for(ConsumableorderdetailsInfo bss : newMidBoxMap.values()){
@@ -770,9 +837,9 @@
            consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '个'));
        }注释 by rentx 2020-12-09*/
        productLimtAndDate();
          datelimitSearch();
        for(ConsumableorderdetailsInfo bss : consumableorderdetailsRecords){
            if(productkucun.get(bss.Prod.Id) != null){
        datelimitSearch();
        for (ConsumableorderdetailsInfo bss : consumableorderdetailsRecords) {
            if (productkucun.get(bss.Prod.Id) != null) {
                bss.guaranteeperiod = productkucun.get(bss.Prod.Id);
            }
        }
@@ -782,12 +849,12 @@
        this.preSortKey = '2';
        this.sortOrderAsc = false;
        this.sortOrder = new String[8];
        this.sortOrder = new String[]{' ','',' ',' ','','','','↓'};
        this.sortOrder = new List<String>{ ' ', '', ' ', ' ', '', '', '', '↓' };
        //总件数
        totalcount = consumableorderdetailsRecords.size();
        //页数
        pagecount=(totalcount  +  pagesize  - 1) / pagesize;
        pagecount = (totalcount + pagesize - 1) / pagesize;
        //显示第一页
        currentpage = 0;
@@ -795,54 +862,60 @@
        makeCurrentPageRecords();
    }
        //库存上下限
    public void productLimtAndDate (){
    //库存上下限
    public void productLimtAndDate() {
        String nowName = null, nowRightAsstModelNo = null;
        Map<String,String> productLimt = new Map<String,String>();
        for(Integer i = 0; i < proLimitAndDate.size(); i++){
        Map<String, String> productLimt = new Map<String, String>();
        for (Integer i = 0; i < proLimitAndDate.size(); i++) {
            nowName = proLimitAndDate[i];
            if( nowName.indexOf( '|') >= 0) {
                nowRightAsstModelNo = nowName.subString( 0, nowName.indexOf( '|'));
                nowName = nowName.subString( nowName.indexOf( '|')+1);
            if (nowName.indexOf('|') >= 0) {
                nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
                nowName = nowName.subString(nowName.indexOf('|') + 1);
            }
            productLimt.put(nowRightAsstModelNo, nowName);
        }
        for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
            if(productLimt.containsKey(ass.Prod.Asset_Model_No__c)){
              ass.lowerlimit = decimal.valueOf(productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf( '|')));
              ass.upperlimit = decimal.valueOf(productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf( '|')+1));
           }
        for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
            if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
                ass.lowerlimit = decimal.valueOf(
                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|'))
                );
                ass.upperlimit = decimal.valueOf(
                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1)
                );
            }
        }
    }
    public void datelimitSearch(){
    public void datelimitSearch() {
        List<String> barcodekucun = new List<String>();
        List<Consumable_order_details2__c> orderkucun = [SELECT Id,Bar_Code__c, Name,Consumable_Product__c,Recordtypeid,
                                                            Guarantee_period_for_products__c,Sterilization_limit__c
                                                        FROM Consumable_order_details2__c
                                                        WHERE Dealer_Arrive__c = true
                                                        AND Dealer_Shipment__c = false
                                                        AND Dealer_Saled__c = false
                                                        AND Dealer_Returned__c = false
                                                        AND Lose_Flag__c = false
                                                        AND Bar_Code__c !=null
                                                        AND Product_Type__c like : sqlagencyProType
                                                        AND Dealer_Info_text__c = :accountName
                                                        AND Arrive_Owner_Work_Location__c =: userWorkLocation
                                                        ORDER BY Consumable_Product__c, Sterilization_limit__c asc];
        for(Integer i = 0 ; i< orderkucun.size();i++){
            if(productkucun.containsKey(orderkucun[i].Consumable_Product__c)){
        List<Consumable_order_details2__c> orderkucun = [
            SELECT Id, Bar_Code__c, Name, Consumable_Product__c, Recordtypeid, Guarantee_period_for_products__c, Sterilization_limit__c
            FROM Consumable_order_details2__c
            WHERE
                Dealer_Arrive__c = TRUE
                AND Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                AND Bar_Code__c != NULL
                AND Product_Type__c LIKE :sqlagencyProType
                AND Dealer_Info_text__c = :accountName
                AND Arrive_Owner_Work_Location__c = :userWorkLocation
            ORDER BY Consumable_Product__c, Sterilization_limit__c ASC
        ];
        for (Integer i = 0; i < orderkucun.size(); i++) {
            if (productkucun.containsKey(orderkucun[i].Consumable_Product__c)) {
                continue;
            }else{
            } else {
                productkucun.put(orderkucun[i].Consumable_Product__c, orderkucun[i].Sterilization_limit__c);
            }
        }
    }
    //名称排序
    public void SortLimited(){
        Map<String,ConsumableorderdetailsInfo> MidMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String,ConsumableorderdetailsInfo> newMap = new Map<String,ConsumableorderdetailsInfo>();
    public void SortLimited() {
        Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> newMap = new Map<String, ConsumableorderdetailsInfo>();
        if (this.sortKey == this.preSortKey) {
            // 方向が変わるのみ
            this.sortOrderAsc = !this.sortOrderAsc;
@@ -855,27 +928,30 @@
        this.preSortKey = this.sortKey;
        // 所有产品取得
        String soql = this.makeSoql(null,null,null,null,null);
        soql += ' ORDER BY ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last');
        String soql = this.makeSoql(null, null, null, null, null);
        soql +=
            ' ORDER BY ' +
            this.columus[Integer.valueOf(this.sortKey)] +
            ' ' +
            (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last');
        List<Product2__c> queryList = Database.query(soql);
        for (Integer i = 0; i < queryList.size(); i++) {
            MidMap.put(queryList[i].Id + '盒', null);
            MidMap.put(queryList[i].Id + '个', null);
        }
        //update by rentx 2020-12-29
        for(Integer i = 0 ; i< pageRecords.size();i++){
            if(MidMap.containsKey(pageRecords[i].prod.Id+pageRecords[i].BoxPiece)){
        for (Integer i = 0; i < pageRecords.size(); i++) {
            if (MidMap.containsKey(pageRecords[i].prod.Id + pageRecords[i].BoxPiece)) {
                ConsumableorderdetailsInfo Jstage = pageRecords[i].clone();
                if (Jstage.hospitalSpecialOffer == true) {
                    newMap.put(pageRecords[i].prod.id+pageRecords[i].BoxPiece, Jstage);
                }else{
                    MidMap.put(pageRecords[i].prod.id+pageRecords[i].BoxPiece, Jstage);
                    newMap.put(pageRecords[i].prod.id + pageRecords[i].BoxPiece, Jstage);
                } else {
                    MidMap.put(pageRecords[i].prod.id + pageRecords[i].BoxPiece, Jstage);
                }
            }
        }
        //update by rentx 2020-12-29
        //update by rentx 2020-12-29
        // for(Integer i = 0 ; i< pageRecords.size();i++){
        //     if(MidMap.containsKey(pageRecords[i].prod.Id+pageRecords[i].BoxPiece)){
@@ -887,17 +963,16 @@
        //update byr entx 2020-12-29
        //再把map里的值从新赋给CpageRecords
        for(ConsumableorderdetailsInfo bss : MidMap.values()){
            if(bss != null){
        for (ConsumableorderdetailsInfo bss : MidMap.values()) {
            if (bss != null) {
                pageRecords.add(bss);
                if (newMap.get(bss.Prod.Id+bss.BoxPiece) != null) {
                    pageRecords.add(newMap.get(bss.Prod.Id+bss.BoxPiece));
                    newMap.remove(bss.Prod.Id+bss.BoxPiece);
                if (newMap.get(bss.Prod.Id + bss.BoxPiece) != null) {
                    pageRecords.add(newMap.get(bss.Prod.Id + bss.BoxPiece));
                    newMap.remove(bss.Prod.Id + bss.BoxPiece);
                }
            }
        }
        for(ConsumableorderdetailsInfo bss : newMap.values()){
        for (ConsumableorderdetailsInfo bss : newMap.values()) {
            if (bss != null) {
                pageRecords.add(bss);
            }
@@ -912,8 +987,8 @@
        //update by rentx 2020-12-29
    }
        //库存排序
    public void SortStore(){
    //库存排序
    public void SortStore() {
        if (this.sortKey == this.preSortKey) {
            // 方向が変わるのみ
            this.sortOrderAsc = !this.sortOrderAsc;
@@ -925,74 +1000,87 @@
        }
        this.preSortKey = this.sortKey;
        for(ConsumableorderdetailsInfo ass :pageRecords){
        for (ConsumableorderdetailsInfo ass : pageRecords) {
            ass.sortBy = this.sortOrderAsc;
        }
        pageRecords.sort();
    }
    //检索sql文做成
    private String makeSoql(String CateName,String CateCode,String Category3,String Category4,String Category5){
    private String makeSoql(String CateName, String CateCode, String Category3, String Category4, String Category5) {
        String sqlTail = '(\'';
        for(Integer i = 0 ; i< orderDetZaikuList.size();i++){
            if(i<orderDetZaikuList.size()-1){
                sqlTail += orderDetZaikuList[i]+'\',\'';
            }else{
                sqlTail += orderDetZaikuList[i]+'\')';
        for (Integer i = 0; i < orderDetZaikuList.size(); i++) {
            if (i < orderDetZaikuList.size() - 1) {
                sqlTail += orderDetZaikuList[i] + '\',\'';
            } else {
                sqlTail += orderDetZaikuList[i] + '\')';
            }
        }
        String soql = 'select Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Category3__c,Category4__c,Category5__c,';
        soql += ' SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c FROM Product2__c ';
        soql += ' WHERE Id in' + sqlTail;
        if(!String.isBlank(CateName)){
            soql += ' AND (Name__c like \'%' + String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + '%\' or Asset_Model_No__c like \'%' + String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + '%\')';
        }if(!String.isBlank(Category3)){
            soql += ' AND Category3__c = \'' +  Category3 + '\'';
        }if(!String.isBlank(Category4)){
            soql += ' AND Category4__c = \'' +  Category4 + '\'';
        }if(!String.isBlank(Category5)){
            soql += ' AND Category5__c = \'' +  Category5 + '\'';
        if (!String.isBlank(CateName)) {
            soql +=
                ' AND (Name__c like \'%' +
                String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
                '%\' or Asset_Model_No__c like \'%' +
                String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
                '%\')';
        }
        if (!String.isBlank(Category3)) {
            soql += ' AND Category3__c = \'' + Category3 + '\'';
        }
        if (!String.isBlank(Category4)) {
            soql += ' AND Category4__c = \'' + Category4 + '\'';
        }
        if (!String.isBlank(Category5)) {
            soql += ' AND Category5__c = \'' + Category5 + '\'';
        }
        System.debug('====>soql' + soql);
        return soql;
    }
    //首页
    public void moveToFirst(){
        if(currentpage == 1) return;
    public void moveToFirst() {
        if (currentpage == 1)
            return;
        currentpage = 1;
        canMove();
    }
    //尾页
    public void moveToLast(){
        if(currentpage >= pagecount) return;
    public void moveToLast() {
        if (currentpage >= pagecount)
            return;
        currentpage = pagecount;
        canMove();
    }
   //上一页
   public void moveToPrevious(){
        if(currentpage == 1) return;
        currentpage = currentpage -1;
    //上一页
    public void moveToPrevious() {
        if (currentpage == 1)
            return;
        currentpage = currentpage - 1;
        canMove();
    }
    //下一页
    public void moveToNext(){
        if(currentpage >= pagecount) return;
    public void moveToNext() {
        if (currentpage >= pagecount)
            return;
        currentpage = currentpage + 1;
        canMove();
    }
    //判断是否可翻页
    public void canMove(){
    public void canMove() {
        hasPrevious = false;
        hasNext = false;
        if(pagecount > 1 && currentpage > 1) hasPrevious = true;
        if(pagecount > 1 && currentpage < pagecount)  hasNext = true;
        if (pagecount > 1 && currentpage > 1)
            hasPrevious = true;
        if (pagecount > 1 && currentpage < pagecount)
            hasNext = true;
    }
    //刷新当前页
    public PageReference refreshPageSize() {
@@ -1000,22 +1088,22 @@
        return null;
    }
   //编辑当前页内容
   public void makeCurrentPageRecords(){
    //编辑当前页内容
    public void makeCurrentPageRecords() {
        Integer startIdx;
        Integer endIdx;
        pageRecords = new List<ConsumableorderdetailsInfo>();
        startIdx = (currentpage-1) * pagesize;
        endIdx = (currentpage-1) * pagesize+ pagesize;
        if (endIdx > consumableorderdetailsRecords.size()){
        startIdx = (currentpage - 1) * pagesize;
        endIdx = (currentpage - 1) * pagesize + pagesize;
        if (endIdx > consumableorderdetailsRecords.size()) {
            endIdx = consumableorderdetailsRecords.size();
        }
        }
        for(Integer i=startIdx; i < endIdx ; i++){
        for (Integer i = startIdx; i < endIdx; i++) {
            pageRecords.add(consumableorderdetailsRecords.get(i));
        }
   }
    }
    // Data Bean
    class ConsumableorderdetailsInfo implements Comparable {
@@ -1044,16 +1132,16 @@
        }
        // 排序
        public Integer compareTo(Object compareTo) {
            ConsumableorderdetailsInfo compareToesd =(ConsumableorderdetailsInfo)compareTo;
            ConsumableorderdetailsInfo compareToesd = (ConsumableorderdetailsInfo) compareTo;
            Integer returnValue = 0;
            if(sortBy == false){
            if (sortBy == false) {
                if (allnumber > compareToesd.allnumber) {
                    returnValue = -1;
                } else if (allnumber < compareToesd.allnumber) {
                    returnValue = 1;
                }
                return returnValue;
            }else{
            } else {
                if (allnumber > compareToesd.allnumber) {
                    returnValue = 1;
                } else if (allnumber < compareToesd.allnumber) {
@@ -1061,7 +1149,6 @@
                }
                return returnValue;
            }
        }
    }
}
}
force-app/main/default/classes/LexArriveGoodsController.cls
New file
@@ -0,0 +1,389 @@
public without sharing class LexArriveGoodsController {
    public static String barcode { get; set; }
    public static Consumable_order__c coc { get; set; }
    /*****************画面表示Bean******************/
    public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
    public static List<ConsumableorderdetailsInfo> consumableInventory { get; set; }
    public static List<ConsumableorderdetailsInfo> detailsSummary { get; set; }
    public static List<ConsumableorderdetailsInfo> consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
    //更新明细取消时间
    public static List<Consumable_order_details2__c> consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
    // 更新借调信息 add by gzw 2020-0-415 start
    public static Map<String, Consumable_order_details2__c> orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
    // 更新借调信息 add by gzw 2020-0-415 end
    public static List<Consumable_order_details2__c> consumableorderdetails2Insert = new List<Consumable_order_details2__c>();
    public static List<Consumable_order_details2__c> consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
    public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordserror { get; set; }
    public static transient List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
    public static List<ConsumableorderdetailsInfo> ShowGoodsofReturnList { get; set; }
    public static List<ConsumableorderdetailsInfo> ShowGoodsofRemoveBoxReturnList { get; set; }
    //add by rentx 20210602 CHAN-C3K4ZQ
    public static List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview { get; set; }
    //add by rentx 20210602 CHAN-C3K4ZQ
    public static List<String> GrList = new List<String>();
    //超出定货数量的产品
    public static List<String> cancellationProList = new List<String>();
    //错误信息
    public static String alertMessage { get; set; }
    public static integer getinventorysize() {
        return consumableInventory.size();
    }
    public static integer geterrorsize() {
        return ConsumableorderdetailsRecordserror.size();
    }
    public static Set<String> noboxBarcodeList = new Set<String>();
    public static transient Map<String, String> ExistIdMap = new Map<String, String>();
    public static transient Map<String, String> ErrorIdMap = new Map<String, String>();
    public static transient Map<String, String> AllMap = new Map<String, String>();
    public static Map<String, String> otherAgencyMap = new Map<String, String>();
    public static transient Map<String, String> barMcodeMap = new Map<String, String>();
    public static Map<String, Integer> BarcodeCntMap = new Map<String, Integer>();
    public static transient List<String> BarCodeListP = new List<String>();
    public static Map<String, Decimal> orderProductCunMap = new Map<String, Decimal>();
    public static Map<String, Decimal> orderProductArrivedCunMap = new Map<String, Decimal>();
    public static Map<String, Decimal> orderWantArriveCunMap = new Map<String, Decimal>();
    //超出型号和数量
    public static Map<String, Decimal> overOrderCunMap = new Map<String, Decimal>();
    //超出BARCODE和型号
    public static Map<String, List<String>> overOrderBARcodeCunMap = new Map<String, List<String>>();
    public static List<String> overOrderBARcodeTTTTTT = new List<String>();
    //不符合的barcode和型号
    public static Map<String, List<String>> notEqualBARcodeCunMap = new Map<String, List<String>>();
    public static List<String> overOrderBARcodeSSSSSS = new List<String>();
    public static List<String> productList = new List<String>();
    public static List<String> notInlist = new List<String>();
    //不选择订单时保存订单ID、产品型号用
    //库存登录使用
    public static List<String> notInStorelist = new List<String>();
    public static List<String> exitBarCodeList = new List<String>();
    public static Map<String, String> HosErrorMap = new Map<String, String>();
    public static List<String> HosErrorList = new List<String>();
    public static String baseUrl { get; private set; }
    public static String ESetId { get; set; }
    public static String arriveId = '';
    private static String accountid = null;
    private static String accountName = null;
    public static Decimal orderCountAll = 0;
    public static Decimal orderCountNotarrive = 0;
    private static id return_Order_id = null;
    private static id inventory_Order_id = null;
    public static boolean ReturnFLGbln { get; set; }
    public static boolean saveFLGbln { get; set; }
    public static String ArrType { get; set; }
    // 登录者工作地
    private static String userWorkLocation;
    //用户产品区分
    public static String userPro_Typestr = null;
    public static String userPro_Type = null;
    public static String product_Type = null;
    public static Boolean EngFlag = false;
    public static Boolean ETFlag = false;
    @AuraEnabled
    public static Results init(String arrTypeStr, String eSetIdStr) {
        Results results = new Results();
        ESetId = eSetIdStr;
        ArrType = arrTypeStr;
        ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
        ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
        ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
        consumableInventory = new List<ConsumableorderdetailsInfo>();
        consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
        consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
        consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
        orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
        detailsSummary = new List<ConsumableorderdetailsInfo>();
        saveFLGbln = false;
        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
        try {
            String userId = UserInfo.getUserId();
            List<user> Useracc = new List<user>();
            Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
            accountid = Useracc[0].accountid;
            userPro_Type = Useracc[0].UserPro_Type__c;
            if (String.isBlank(userPro_Type)) {
                userPro_Type = 'ET';
            }
            if (userPro_Type == 'ENG') {
                product_Type = 'ET';
                EngFlag = true;
            } else {
                product_Type = 'ENG';
                ETFlag = true;
            }
            userPro_Typestr = '%' + userPro_Type + '%';
            userWorkLocation = Useracc[0].Work_Location__c;
            system.debug('userWorkLocation' + userWorkLocation);
            List<account> accountInfo = [SELECT Name FROM account WHERE id = :accountid];
            accountName = accountInfo[0].Name;
            system.debug('accountName' + accountName);
            coc = new Consumable_order__c();
            if (ArrType == 'ReG') {
                ReturnFLGbln = true;
            } else {
                ReturnFLGbln = false;
            }
            if (ESetId != '' && ESetId != null) {
                List<Consumable_order__c> qs = new List<Consumable_order__c>();
                List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
                List<Consumable_Orderdetails__c> reSet = new List<Consumable_Orderdetails__c>();
                qs = [
                    SELECT
                        Id,
                        Name,
                        Order_status__c,
                        Dealer_Info__c,
                        Deliver_date__c,
                        ReturnGs_Upload_Date__c,
                        Order_Reason__c,
                        Order_date__c,
                        Contract_application_decision__c,
                        Order_type__c,
                        Total_num__c,
                        OrderNumber_arrived__c,
                        Delivery_detail_count__c,
                        OrderNumber_notarrive__c,
                        orderPattern__c
                    FROM Consumable_order__c
                    WHERE Id = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation AND Dealer_Info__c = :accountid
                ];
                if (qs.size() > 0) {
                    coc = qs[0];
                    orderCountAll = coc.Total_num__c;
                    orderCountNotarrive = coc.OrderNumber_notarrive__c;
                }
                //产品定货数量
                reSet = [
                    SELECT Asset_Model_No__c, Consumable_order__c, Consumable_count__c
                    FROM Consumable_Orderdetails__c
                    WHERE Consumable_order__c = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation
                ];
                for (Integer i = 0; i < reSet.size(); i++) {
                    productList.add(reSet[i].Asset_Model_No__c);
                    orderProductCunMap.put(reSet[i].Asset_Model_No__c, reSet[i].Consumable_count__c);
                    orderProductArrivedCunMap.put(reSet[i].Asset_Model_No__c, 0);
                    orderWantArriveCunMap.put(reSet[i].Asset_Model_No__c, 0);
                    overOrderCunMap.put(reSet[i].Asset_Model_No__c, 0);
                    overOrderBARcodeCunMap.put(reSet[i].Asset_Model_No__c, overOrderBARcodeTTTTTT);
                }
                reSet1 = [
                    SELECT
                        Id,
                        Name,
                        Intra_Trade_List_RMB__c,
                        Asset_Model_No__c,
                        Consumable_Product__c,
                        Consumable_Product__r.Name,
                        Consumable_Product__r.Name__c,
                        Sterilization_limit__c,
                        Deliver_date__c,
                        Bar_Code__c,
                        Arrive_date__c,
                        Send_Date__c,
                        Consumable_order_minor__r.Name,
                        Consumable_order_minor__c,
                        Dealer_Arrive__c,
                        Guarantee_period_for_products__c,
                        CFDA_Status__c,
                        Box_Piece__c,
                        Rrturn_count__c,
                        ProductPacking_list_manual__c,
                        Report_Product_Approbation__c,
                        Report_Product_Expiration__c,
                        ContractNo_text__c,
                        Consumable_order_minor__r.ContractNo__c
                    FROM Consumable_order_details2__c
                    WHERE
                        recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                        AND Arrive_Owner_Work_Location__c = :userWorkLocation
                        AND Consumable_order_minor__c = :ESetId
                        AND Dealer_Arrive__c = TRUE
                        AND Box_Piece__c != '个'
                ];
                for (Integer i = 0; i < reSet1.size(); i++) {
                    if (orderProductArrivedCunMap.containsKey(reSet1[i].Asset_Model_No__c)) {
                        orderProductArrivedCunMap.put(
                            reSet1[i].Asset_Model_No__c,
                            orderProductArrivedCunMap.get(reSet1[i].Asset_Model_No__c) + 1
                        );
                    }
                }
            }
            results.accountId = accountid;
            results.accountName = accountName;
            results.userProType = userPro_Type;
            results.userProTypestr = userPro_Typestr;
            results.productType = product_Type;
            results.saveFLGbln = saveFLGbln;
            results.returnFLGbln = ReturnFLGbln;
            results.engFlag = EngFlag;
            results.etFlag = ETFlag;
            results.userWorkLocation = userWorkLocation;
            results.productList = productList;
            results.orderProductCunMap = orderProductCunMap;
            results.orderProductArrivedCunMap = orderProductArrivedCunMap;
            results.orderWantArriveCunMap = orderWantArriveCunMap;
            results.overOrderCunMap = overOrderCunMap;
            results.overOrderBARcodeCunMap = overOrderBARcodeCunMap;
            results.result = 'Success';
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
        }
        return results;
    }
    @AuraEnabled
    public static Results methodName() {
        Results results = new Results();
        try {
            results.result = 'Success';
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
        }
        return results;
    }
    public class Results {
        @AuraEnabled
        public String result;
        @AuraEnabled
        public String errorMsg;
        @AuraEnabled
        public String accountId;
        @AuraEnabled
        public String accountName;
        @AuraEnabled
        public String userProType;
        @AuraEnabled
        public String userProTypestr;
        @AuraEnabled
        public String productType;
        @AuraEnabled
        public String userWorkLocation;
        @AuraEnabled
        public String inventoryOrderId;
        @AuraEnabled
        public String returnOrderId;
        @AuraEnabled
        public String arriveId;
        @AuraEnabled
        public Boolean returnFLGbln;
        @AuraEnabled
        public Boolean saveFLGbln;
        @AuraEnabled
        public Boolean engFlag;
        @AuraEnabled
        public Boolean etFlag;
        @AuraEnabled
        public Consumable_order__c coc;
        @AuraEnabled
        public List<String> productList;
        @AuraEnabled
        public Map<String, Decimal> orderProductCunMap;
        @AuraEnabled
        public Map<String, Decimal> orderProductArrivedCunMap;
        @AuraEnabled
        public Map<String, Decimal> orderWantArriveCunMap;
        @AuraEnabled
        public Map<String, Decimal> overOrderCunMap;
        @AuraEnabled
        public Map<String, List<String>> overOrderBARcodeCunMap;
    }
    public class ConsumableorderdetailsInfo implements Comparable {
        @AuraEnabled
        public Consumable_order_details2__c esd { get; set; }
        @AuraEnabled
        public Product2__c Prod { get; set; }
        @AuraEnabled
        public String ProductName { get; set; }
        @AuraEnabled
        public String barCodeNo { get; set; }
        @AuraEnabled
        public Date sterilizationlimitDate { get; set; }
        @AuraEnabled
        public String serialNoorLotNo { get; set; }
        @AuraEnabled
        public String tracingCodeNo { get; set; }
        @AuraEnabled
        public String ReturnReason { get; set; }
        @AuraEnabled
        public String oldConsumableCount { get; set; }
        @AuraEnabled
        public String ErrorReason { get; set; }
        @AuraEnabled
        public boolean canEdit { get; set; }
        @AuraEnabled
        public Integer intMark { get; set; }
        @AuraEnabled
        public Decimal arriveAmount { get; set; }
        @AuraEnabled
        public Decimal arrivedCount { get; set; }
        public String ReportProductExpirationDate { get; set; }
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e, string str) {
            esd = e;
            Prod = e.Consumable_Product__r;
            oldConsumableCount = e.name;
            ErrorReason = str;
            intMark = 1;
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
            }
        }
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
            canEdit = false;
            if (e.Box_Piece__c == '盒') {
                e.Rrturn_count__c = 1;
                canEdit = true;
            }
            esd = e;
            Prod = e.Consumable_Product__r;
            oldConsumableCount = e.name;
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
            }
        }
        public ConsumableorderdetailsInfo(Product2__c e, List<String> barinfoL) {
            esd = new Consumable_order_details2__c();
            ProductName = e.Name__c;
            Prod = e;
            barCodeNo = barinfoL[0];
            if (String.isNotBlank(barinfoL[1])) {
                sterilizationlimitDate = Date.valueOf(barinfoL[1]);
            }
            serialNoorLotNo = barinfoL[2];
            tracingCodeNo = barinfoL[3];
            ReturnReason = '';
        }
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e, List<String> barinfoL) {
            esd = e;
            Prod = e.Consumable_Product__r;
            barCodeNo = barinfoL[0];
            if (String.isNotBlank(barinfoL[1])) {
                sterilizationlimitDate = Date.valueOf(barinfoL[1]);
            }
            serialNoorLotNo = barinfoL[2];
            tracingCodeNo = barinfoL[3];
            if (e.Report_Product_Expiration__c != null) {
                ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
            }
        }
        public ConsumableorderdetailsInfo(Product2__c e) {
            Prod = e;
        }
        // 排序
        public Integer compareTo(Object compareTo) {
            return null;
        }
    }
}
force-app/main/default/classes/LexArriveGoodsController.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>56.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/LexSummonsCreatController.cls
@@ -1,5 +1,4 @@
public without sharing class LexSummonsCreatController {
    public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    /*****************検索用******************/
@@ -42,13 +41,19 @@
    public static List<SelectOption> category4OptionList { get; set; }
    public static List<SelectOption> category5OptionList { get; set; }
    @AuraEnabled
    public static Map<String,String> categoryOptionMap { get; set; }
    public static Map<String, String> categoryOptionMap { get; set; }
    @AuraEnabled
    public static Map<String,String> category4OptionMap { get; set; }
    public static Map<String, String> category4OptionMap { get; set; }
    @AuraEnabled
    public static Map<String,String> category5OptionMap { get; set; }
    public static Map<String, String> category5OptionMap { get; set; }
    /*****************画面表示Bean******************/
    private static List<ConsumableorderdetailsInfo> consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
    //明细2
    @AuraEnabled
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
    //错误明细
    @AuraEnabled
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror { get; set; }
    @AuraEnabled
    public static List<ConsumableorderdetailsInfo> pageRecords { get; set; }
    public static List<ConsumableorderdetailsInfoLwc> pageRecordsLwc { get; set; }
@@ -58,6 +63,18 @@
    private static List<ConsumableorderdetailsInfo> consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
    private static List<Attachment> attachmentinfo = new List<Attachment>();
    public static List<Product2__c> product2Selected = new List<Product2__c>();
    @AuraEnabled
    public static Map<String, String> orderpieceorboxMap { get; set; }
    @AuraEnabled
    public static List<Consumable_orderdetails__c> orderdetails { get; set; }
    @AuraEnabled
    public static Map<String, Decimal> orderagencypriceMap { get; set; }
    @AuraEnabled
    public static Map<String, Decimal> orderpriceMap { get; set; }
    @AuraEnabled
    public static Map<String, Decimal> orderdetCountMap { get; set; }
    @AuraEnabled
    public static Boolean hasSpecialHos { get; set; }
    //选择产品size
    public static Integer consumableorderdetailsCount {
        get {
@@ -88,31 +105,42 @@
    public static Boolean EditDelCommitBtnDisabled { get; private set; }
    public static Boolean saveBtnDisabled { get; private set; }
    public static Boolean SorderBtnDisabled { get; private set; }
    // page
    public static Integer pagesize { get; set; }
    public static Integer pageToken { get; set; }
    //public static String sortField { get; set; }
    //public static String sortOrder { get; set; }
    public static Integer totalcount { get; set; }
    public static Integer addSize { get; set; }
    //List<ConsumableorderdetailsInfoLwc> reSetLwc
    public static List<ConsumableorderdetailsInfo> addData { get; set; }
    public static Map<String, String> skipData { get; set; }
    // 保存后动作: 1.检索 2.排序
    public static String sortKey { get; set; }
    public static String preSortKey { get; private set; }
    public static Boolean sortOrderAsc { get; private set; }
    public static String[] sortOrder { get; private set; }
    private static String[] columus = new List<String>{
        'Consumable_Product__r.Name',
        'Consumable_Product__r.Asset_Model_No__c',
        'Consumable_Product__r.Intra_Trade_List_RMB__c',
        '',
        '',
        'Consumable_Product__r.Category3__c',
        'Consumable_Product__r.Category4__c',
        'Consumable_Product__r.Category5__c'
    };
    private static String[] columus_no = new List<String>{
        'Product2__c.Name',
        'Product2__c.Asset_Model_No__c',
        'Product2__c.Intra_Trade_List_RMB__c',
        '',
        '',
        'Category3__c',
        'Category4__c',
        'Category5__c'
    };
    // public static String sortKey { get; set; }
    // public static String preSortKey { get; private set; }
    // public static Boolean sortOrderAsc { get; private set; }
    // public static String[] sortOrder { get; private set; }
    // private static String[] columus = new List<String>{
    //     'Consumable_Product__r.Name',
    //     'Consumable_Product__r.Asset_Model_No__c',
    //     'Consumable_Product__r.Intra_Trade_List_RMB__c',
    //     '',
    //     '',
    //     'Consumable_Product__r.Category3__c',
    //     'Consumable_Product__r.Category4__c',
    //     'Consumable_Product__r.Category5__c'
    // };
    // private static String[] columus_no = new List<String>{
    //     'Product2__c.Name',
    //     'Product2__c.Asset_Model_No__c',
    //     'Product2__c.Intra_Trade_List_RMB__c',
    //     '',
    //     '',
    //     'Category3__c',
    //     'Category4__c',
    //     'Category5__c'
    // };
    //到货单明细1
    private static List<Consumable_Orderdetails__c> consumableorderdetailsSelected = new List<Consumable_Orderdetails__c>();
@@ -168,9 +196,9 @@
        category4OptionList = new List<SelectOption>();
        category5OptionList = new List<SelectOption>();
        categoryOptionMap = new Map<String,String>();
        category4OptionMap = new Map<String,String>();
        category5OptionMap = new Map<String,String>();
        categoryOptionMap = new Map<String, String>();
        category4OptionMap = new Map<String, String>();
        category5OptionMap = new Map<String, String>();
        outOutPatternOptionMap = new Map<String, String>();
        outOutPatternOptionMap.put('', '-无-');
@@ -183,7 +211,7 @@
        HospitalName = '';
    }
    public static void firstInit(String ESetidJs){
    public static void firstInit(String ESetidJs) {
        System.debug('enter firstInit');
        ESetid = ESetidJs;
        System.debug('ESetid = ' + ESetid);
@@ -200,9 +228,9 @@
        category4OptionList = new List<SelectOption>();
        category5OptionList = new List<SelectOption>();
        categoryOptionMap = new Map<String,String>();
        category4OptionMap = new Map<String,String>();
        category5OptionMap = new Map<String,String>();
        categoryOptionMap = new Map<String, String>();
        category4OptionMap = new Map<String, String>();
        category5OptionMap = new Map<String, String>();
        outOutPatternOptionMap = new Map<String, String>();
        outOutPatternOptionMap.put('', '-无-');
@@ -217,9 +245,10 @@
    // 画面初始化
    @AuraEnabled
    public static ResponseBodyLWC init(String ESetidJs) {
    public static ResponseBodyLWC init(String ESetidJs, String statusEdit, Integer pageSizeLWC, Integer pageTokenLWC) {
        // try {
        firstInit(ESetidJs);
        statusEdit = statusEdit;
        arriveorder = '';
        HospitalName = '';
        provinceOpts = new List<SelectOption>();
@@ -227,12 +256,18 @@
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        // public static Integer pagesize { get; set; }
        // public static Integer pageToken { get; set; }
        // public static String sortField { get; set; }
        // public static String sortOrder { get; set; }
        pagesize = pageSizeLWC;
        pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
        sortKey = '1';
        preSortKey = '1';
        sortOrderAsc = false;
        sortOrder = new String[8];
        sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '↓', '', '', '' };
        // sortKey = '1';
        // preSortKey = '1';
        // sortOrderAsc = false;
        // sortOrder = new List<String>(8);
        // sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '↓', '', '', '' };
        //cate1ForSort = '';
        sumPrice = 0;
        IdCheck = EsetId;
@@ -308,6 +343,9 @@
        for (AggregateResult orderdetail : orderdetailCount) {
            zaikuId.add(String.valueOf(orderdetail.get('cpc')));
        }
        System.debug('sqlagencyProType = ' + sqlagencyProType);
        System.debug('userWorkLocation = ' + userWorkLocation);
        System.debug('accountName = ' + accountName);
        List<Consumable_order_details2__c> CountDel = [
            SELECT
                Id,
@@ -341,8 +379,8 @@
            SummonsFlag = 'hidden';
            String msoql = makeSoqlinventory();
            initStandardController(msoql);
            System.debug('msoql = ' + msoql);
            product2Selected = Database.query(msoql);
            //product2Selected = product2s();
            if (String.isBlank(arriveorder)) {
                EditDelCommitBtnDisabled = true;
                for (Integer i = 0; i < product2Selected.size(); i++) {
@@ -396,6 +434,7 @@
                            MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
                        }
                    }
                    System.debug('MidMap2.size() = ' + MidMap2.size());
                    /*//然后循环CountDel去修改map里的allnumber
                        if(MidMap.containsKey(CountDel[i].Consumable_Product__c)){
                            ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c);
@@ -432,7 +471,7 @@
                Integer ishosnum = 0;
                for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
                    ass.sortBy = sortOrderAsc;
                    //ass.sortBy = sortOrderAsc;
                    //add by rentx 2021-3-10
                    if (ass.hospitalSpecialOffer) {
                        ishosnum = ishosnum + 1;
@@ -623,7 +662,7 @@
                Integer ishosnum = 0;
                for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
                    ass.sortBy = sortOrderAsc;
                    //ass.sortBy = sortOrderAsc;
                    for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
                        cdc1.Shipment_Count__c = cdc1.Consumable_count__c;
                        if (ass.prod.Id == cdc1.Consumable_Product__c) {
@@ -690,9 +729,8 @@
                    consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i]));
                }
            }
        }
        // 更新、
        else {
        } else {
            // 更新、
            SummonsFlag = 'visible';
            // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select
            consumableInvoiceRecords = [
@@ -703,6 +741,8 @@
                    AND Invoice_status__c != '草案中'
            ];
            System.debug('coc ESetId = ' + ESetId);
            System.debug('coc userWorkLocation = ' + userWorkLocation);
            coc = [
                SELECT
                    Id,
@@ -998,9 +1038,8 @@
                for (Integer i = 0; i < consumablearriveproductdetailsSelected.size(); i++) {
                    consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i]));
                }
            }
            // 不是到货订单来的时候
            else {
            } else {
                // 不是到货订单来的时候
                if (coc.SummonsStatus_c__c == '已提交' || coc.SummonsStatus_c__c == '批准') {
                    system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c);
                    saveBtnDisabled = true;
@@ -1082,7 +1121,7 @@
                for (Integer i = 0; i < product2Selected.size(); i++) {
                    MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
                }
                for (Integer i = 0; i < CountDel.size(); i++) {
                    String str = '';
                    if (CountDel[i].hospitalSpecialOffer__c) {
@@ -1157,7 +1196,7 @@
                // return null;
                Integer ishosnum = 0;
                for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
                    ass.sortBy = sortOrderAsc;
                    //ass.sortBy = sortOrderAsc;
                    for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
                        //update by rentx 2012-3-1 start
                        // if(ass.prod.Id == cdc1.Consumable_Product__c){
@@ -1273,7 +1312,7 @@
        categoryOptionList = new List<SelectOption>();
        categoryOptionList.add(new SelectOption('', '-无-'));
        categoryOptionMap = new Map<String,String>();
        categoryOptionMap = new Map<String, String>();
        categoryOptionMap.put('', '-无-');
        for (AggregateResult category3Search : categoryList) {
            String deliverycnt = String.valueOf(category3Search.get('c3c'));
@@ -1283,7 +1322,7 @@
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category4OptionMap = new Map<String,String>();
        category4OptionMap = new Map<String, String>();
        category4OptionMap.put('', '-无-');
        /*for(AggregateResult category4Search : category4List) {
                String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
@@ -1292,34 +1331,64 @@
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        category5OptionMap = new Map<String,String>();
        category5OptionMap = new Map<String, String>();
        category5OptionMap.put('', '-无-');
        //分页
        PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
        totalCount = pageRecords.size();
        System.debug('pageToken = ' + pageToken);
        System.debug('pageSize = ' + pageSize);
        System.debug('totalCount = ' + totalCount);
        paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
        System.debug('paginatedAccounts.nextPageToken = ' + paginatedAccounts.nextPageToken);
        paginatedAccounts.recordStart = pageToken + 1;
        paginatedAccounts.pageNumber = pageToken / pageSize + 1;
        Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
        paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
        paginatedAccounts.totalRecords = totalCount;
        Integer startIdx;
        Integer endIdx;
        startIdx = pageToken;
        endIdx = pageToken + pageSize;
        List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
        if (endIdx > pageRecords.size()) {
            endIdx = pageRecords.size();
        }
        for (Integer i = startIdx; i < endIdx; i++) {
            pageRecordsTemp.add(pageRecords.get(i));
        }
        Boolean Existarrive = (coc.Arrive_Order__c != null);
        String ConsumableOut_report = System.Label.ConsumableOut_report;
        System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords);
        data.put('ConsumableOut_report','ConsumableOut_report');
        data.put('accountid',accountid);
        data.put('consumableproductdetailsRecords',consumableproductdetailsRecords);
        data.put('agencyProType',agencyProType);
        data.put('accountName',accountName);
        data.put('userWorkLocation',userWorkLocation);
        data.put('categoryOptionMap',categoryOptionMap);
        data.put('category4OptionMap',category4OptionMap);
        data.put('category5OptionMap',category5OptionMap);
        data.put('outOutPatternOptionMap',outOutPatternOptionMap);
        data.put('hasHosPro',hasHosPro);
        data.put('Existarrive',Existarrive);
        data.put('sumPrice',sumPrice);
        data.put('paginatedAccounts', paginatedAccounts);
        data.put('ConsumableOut_report', ConsumableOut_report);
        data.put('accountid', accountid);
        data.put('consumableproductdetailsRecords', consumableproductdetailsRecords);
        data.put('agencyProType', agencyProType);
        data.put('accountName', accountName);
        data.put('userWorkLocation', userWorkLocation);
        data.put('categoryOptionMap', categoryOptionMap);
        data.put('category4OptionMap', category4OptionMap);
        data.put('category5OptionMap', category5OptionMap);
        data.put('outOutPatternOptionMap', outOutPatternOptionMap);
        data.put('hasHosPro', hasHosPro);
        data.put('Existarrive', Existarrive);
        data.put('sumPrice', sumPrice);
        data.put('HospitalName', HospitalName);
        data.put('provinceOptsMap', provinceOptsMap);
        data.put('SummonsFlag', SummonsFlag);
        data.put('EditDelCommitBtnDisabled', EditDelCommitBtnDisabled);
        data.put('EditAble', EditAble);
        data.put('coc', coc);
        data.put('pageRecords', pageRecords);
        data.put('arriveorder',arriveorder);
        data.put('pageRecords', pageRecordsTemp);
        data.put('arriveorder', arriveorder);
        data.put('consumableorderdetails2Count', consumableorderdetails2Count);
        data.put('consumableorderdetails2Records', consumableorderdetails2Records);
        data.put('HospitalInfo', HospitalInfo);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
@@ -1329,9 +1398,119 @@
        // }
    }
    @AuraEnabled
    public static ResponseBodyLWC categoryAllload(String category3Lwc) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        category3 = category3Lwc;
        AggregateResult[] category4List = [
            SELECT Count(id), Category4_text__c c4c
            FROM Product2__c
            WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
            GROUP BY Category4_text__c
        ];
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category4OptionMap = new Map<String, String>();
        category4OptionMap.put('', '-无-');
        for (AggregateResult category4Search : category4List) {
            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
            category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
            category4OptionMap.put(deliverycnt4, deliverycnt4);
        }
        AggregateResult[] category5List = [
            SELECT Count(id), Category5_text__c c5c
            FROM Product2__c
            WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
            GROUP BY Category5_text__c
        ];
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        category5OptionMap = new Map<String, String>();
        category5OptionMap.put('', '-无-');
        for (AggregateResult category5Search : category5List) {
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
            category5OptionMap.put(deliverycnt5, deliverycnt5);
        }
        data.put('category4OptionMap', category4OptionMap);
        data.put('category5OptionMap', category5OptionMap);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    @AuraEnabled
    public static ResponseBodyLWC categoryload(String category3Lwc, String category4Lwc) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        category3 = category3Lwc;
        category4 = category4Lwc;
        AggregateResult[] category4List = [
            SELECT Count(id), Category4_text__c c4c
            FROM Product2__c
            WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
            GROUP BY Category4_text__c
        ];
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category4OptionMap = new Map<String, String>();
        category4OptionMap.put('', '-无-');
        for (AggregateResult category4Search : category4List) {
            String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
            category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
            category4OptionMap.put(deliverycnt4, deliverycnt4);
        }
        AggregateResult[] category5List = [
            SELECT Count(id), Category5_text__c c5c
            FROM Product2__c
            WHERE Category3_text__c = :category3 AND Category4_text__c = :category4 AND Category5_text__c != NULL
            GROUP BY Category5_text__c
        ];
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        category5OptionMap = new Map<String, String>();
        category5OptionMap.put('', '-无-');
        for (AggregateResult category5Search : category5List) {
            String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
            category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
            category5OptionMap.put(deliverycnt5, deliverycnt5);
        }
        data.put('category4OptionMap', category4OptionMap);
        data.put('category5OptionMap', category5OptionMap);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    // 检索
    @AuraEnabled
    public static ResponseBodyLWC searchConsumableorderdetails(String agencyProTypeLwc,String accountNameLwc,String userWorkLocationLwc,String outOutPattern,String category1,String category3,String category4,String category5,Boolean editAbleLwc,List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,String arriveorderLwc) {
    public static ResponseBodyLWC searchConsumableorderdetails(
        String agencyProTypeLwc,
        String accountNameLwc,
        String userWorkLocationLwc,
        String outOutPattern,
        String category1,
        String category3,
        String category4,
        String category5,
        Boolean editAbleLwc,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,
        List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
        String arriveorderLwc,
        Integer pageSizeLWC,
        Integer pageTokenLWC
    ) {
        consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
        pageRecordsLwc = pageRecordsLwcLwc;
        System.debug('pageRecordsLwc = ' + pageRecordsLwc);
@@ -1339,6 +1518,14 @@
        accountName = accountNameLwc;
        userWorkLocation = userWorkLocationLwc;
        agencyProType = agencyProTypeLwc;
        product2Selected = new List<Product2__c>();
        pagesize = pageSizeLWC;
        pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
        addSize = 0;
        addData = new List<ConsumableorderdetailsInfo>();
        System.debug('start addData = ' + addData);
        System.debug('accountName = ' + accountName);
        System.debug('userWorkLocation = ' + userWorkLocation);
        String sqlagencyProType = '%' + agencyProTypeLwc + '%';
        List<AggregateResult> orderdetailCount = [
            SELECT count(id), Consumable_Product__c cpc, Box_Piece__c
@@ -1366,13 +1553,13 @@
        SearchDone = 'SearchDone';
        Map<String, String> selectedIdMap = new Map<String, String>();
        List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
        Map<String,ConsumableorderdetailsInfo> MidMap = new Map<String,ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
        //update by rentx 2021-01-29
        Map<String,ConsumableorderdetailsInfo> MidMap2 = new Map<String,ConsumableorderdetailsInfo>();
        Map<String, ConsumableorderdetailsInfo> MidMap2 = new Map<String, ConsumableorderdetailsInfo>();
        String countdelSoql = 'SELECT Id,Bar_Code__c,Name,Inventory_date__c,Consumable_Product__c,Consumable_Product__r.Asset_Model_No__c,Recordtypeid,Box_Piece__c,ProductPacking_list_manual__c,hospitalSpecialOffer__c FROM Consumable_order_details2__c WHERE  Dealer_Arrive__c = true AND Dealer_Shipment__c = false AND Dealer_Saled__c = false AND Dealer_Returned__c = false AND Lose_Flag__c = false AND Bar_Code__c != null AND Isoverdue__c = 1 AND Arrive_Owner_Work_Location__c =  :userWorkLocation AND Dealer_Info_text__c = :accountName ';
        if (String.isNotBlank(outOutPattern) && outOutPattern.equals('ishos')) {
            countdelSoql += ' AND hospitalSpecialOffer__c = true';
        }else if (String.isNotBlank(outOutPattern) && outOutPattern.equals('nothos')) {
        } else if (String.isNotBlank(outOutPattern) && outOutPattern.equals('nothos')) {
            countdelSoql += ' AND hospitalSpecialOffer__c = false';
        }
        System.debug('countdelSoql = ' + countdelSoql);
@@ -1382,20 +1569,20 @@
        consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
        //consumableorderdetailsSelectRecords = reSet;
        String soql = makeSoql(category1,category3,category4,category5);
        System.debug('soql = ' + soql);
        String soql = makeSoql(category1, category3, category4, category5);
        size = Integer.valueOf(System.Label.orderdetLimitsize);
        initStandardController(soql);
        System.debug('soql = ' + soql);
        product2Selected = Database.query(soql);
        for (Integer i = 0; i < product2Selected.size(); i++) {
            MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
        }
        for (Integer i = 0; i < CountDel.size() ;i++ ) {
        for (Integer i = 0; i < CountDel.size(); i++) {
            String str = '';
            if (CountDel[i].hospitalSpecialOffer__c) {
                str = 'isHos';
            }else{
            } else {
                str = 'notHos';
            }
            System.debug('MidMap = ' + MidMap);
@@ -1403,50 +1590,50 @@
            if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
                //设置map中key的后缀 用于区分医院特价和非医院特价
                if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) {
                    ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c+str);
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Box_Piece__c == '盒'){
                    ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c + str);
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Box_Piece__c == '盒') {
                        Jstage.Boxnumber = Jstage.Boxnumber + 1;
                    }else if(CountDel[i].Box_Piece__c == '个'){
                    } else if (CountDel[i].Box_Piece__c == '个') {
                        Jstage.Piecenumber = Jstage.Piecenumber + 1;
                    }
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else{
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    if (HosProMap.containsKey(Jstage.Prod.Id)) {
                        Jstage.hosPro = true;
                    }
                    MidMap2.put(CountDel[i].Consumable_Product__c+str, Jstage);
                }else{
                    MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
                } else {
                    //midmap2中没有对应的产品
                    ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c).clone();
                    Jstage.allnumber = Jstage.allnumber+1 ;
                    if(CountDel[i].Box_Piece__c == '盒'){
                    Jstage.allnumber = Jstage.allnumber + 1;
                    if (CountDel[i].Box_Piece__c == '盒') {
                        Jstage.Boxnumber = Jstage.Boxnumber + 1;
                    }else if(CountDel[i].Box_Piece__c == '个'){
                    } else if (CountDel[i].Box_Piece__c == '个') {
                        Jstage.Piecenumber = Jstage.Piecenumber + 1;
                    }
                    if (CountDel[i].hospitalSpecialOffer__c) {
                        Jstage.hospitalSpecialOffer = true;
                    }else{
                    } else {
                        Jstage.hospitalSpecialOffer = false;
                    }
                    if (HosProMap.containsKey(Jstage.Prod.Id)) {
                        Jstage.hosPro = true;
                    }
                    //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
                    MidMap2.put(CountDel[i].Consumable_Product__c+str, Jstage);
                    MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
                }
            }
        }
        Integer ishosnum = 0;
        System.debug('MidMap2 = ' + MidMap2);
        for(ConsumableorderdetailsInfo bss : MidMap2.values()){
            if(selectedIdMap.containsKey(bss.Prod.id)){
        for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
            if (selectedIdMap.containsKey(bss.Prod.id)) {
                continue;
            }else{
            } else {
                bss.sortBy = false;
                bss.packinglist = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
                bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
@@ -1458,52 +1645,95 @@
                }
            }
        }
         if (ishosnum > 0) {
        if (ishosnum > 0) {
            hasHosPro = true;
        }else{
        } else {
            hasHosPro = false;
        }
        consumableorderdetailsSelectRecords.sort();
        //add by rentx
        //noOfRecords = consumableorderdetailsSelectRecords.size();
        //add by rentx
        //makepagerecords();
        makepagerecordsLwc();
        // this.sortKey = '1';
        // this.preSortKey = '1';
        // this.sortOrderAsc = false;
        // this.sortOrder = new String[8];
        // this.sortOrder = new String[]{' ',' ',' ',' ','↓','','',''};
        data.put('pageRecords', pageRecords);
        data.put('test','test');
        //分页
        PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
        totalCount = pageRecords.size();
        paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
        paginatedAccounts.recordStart = pageToken + 1;
        paginatedAccounts.pageNumber = pageToken / pageSize + 1;
        Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
        paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
        paginatedAccounts.totalRecords = totalCount;
        System.debug('addSize = ' + addSize);
        Integer startIdx;
        Integer endIdx;
        startIdx = pageToken;
        endIdx = pageToken + pageSize;
        List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
        if (endIdx > pageRecords.size()) {
            endIdx = pageRecords.size();
        }
        System.debug('addData.size() = ' + addData.size());
        for (ConsumableorderdetailsInfo ci : addData) {
            pageRecordsTemp.add(ci);
        }
        System.debug('startIdx = ' + startIdx);
        System.debug('endIdx = ' + endIdx);
        System.debug('skipData = ' + skipData);
        System.debug('pageRecords = ' + pageRecords.size());
        String hos = '';
        for (Integer i = startIdx; i < endIdx; i++) {
            System.debug('skipData.get(pageRecords.get(i).Prod.Id) = ' + skipData.get(pageRecords.get(i).Prod.Id));
            if (pageRecords.get(i).hospitalSpecialOffer == true) {
                hos = 'ishos';
            } else {
                hos = 'nothos';
            }
            if (skipData.get(pageRecords.get(i).Prod.Id + hos) == null) {
                pageRecordsTemp.add(pageRecords.get(i));
            }
        }
        System.debug('pageRecordsTemp = ' + pageRecordsTemp.size());
        data.put('paginatedAccounts', paginatedAccounts);
        data.put('pageRecords', pageRecordsTemp);
        data.put('SearchDone', SearchDone);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    private static String makeSoql(String CateName,String Category3,String Category4,String Category5){
    private static String makeSoql(String CateName, String Category3, String Category4, String Category5) {
        String sqlTail1 = '(\'';
        for(Integer i = 0 ; i< zaikuId.size();i++){
            if(i<zaikuId.size()-1){
                sqlTail1 += zaikuId[i]+'\',\'';
            }else{
                sqlTail1 += zaikuId[i];
        for (Integer i = 0; i < zaikuId.size(); i++) {
            if (zaikuId[i] != null) {
                if (i < zaikuId.size() - 1) {
                    sqlTail1 += zaikuId[i] + '\',\'';
                } else {
                    sqlTail1 += zaikuId[i];
                }
            }
        }
        sqlTail1 += '\')';
        String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c  FROM Product2__c ';
        soql += ' WHERE Id in' + sqlTail1;
        if(!String.isBlank(CateName)){
            soql += ' AND (Name__c like \'%' + String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + '%\' or Asset_Model_No__c like \'%' + String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + '%\')';
        }if(!String.isBlank(Category3)){
            soql += ' AND Category3__c = \'' +  Category3 + '\'';
        }if(!String.isBlank(Category4)){
            soql += ' AND Category4__c = \'' +  Category4 + '\'';
        }if(!String.isBlank(Category5)){
            soql += ' AND Category5__c = \'' +  Category5 + '\'';
        if (!String.isBlank(CateName)) {
            soql +=
                ' AND (Name__c like \'%' +
                String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
                '%\' or Asset_Model_No__c like \'%' +
                String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
                '%\')';
        }
        if (!String.isBlank(Category3)) {
            soql += ' AND Category3__c = \'' + Category3 + '\'';
        }
        if (!String.isBlank(Category4)) {
            soql += ' AND Category4__c = \'' + Category4 + '\'';
        }
        if (!String.isBlank(Category5)) {
            soql += ' AND Category5__c = \'' + Category5 + '\'';
        }
        return soql;
    }
@@ -1526,10 +1756,12 @@
    public static String makeSoqlinventory() {
        String sqlTail = '(\'';
        for (Integer i = 0; i < zaikuId.size(); i++) {
            if (i < zaikuId.size() - 1) {
                sqlTail += zaikuId[i] + '\',\'';
            } else {
                sqlTail += zaikuId[i];
            if (zaikuId[i] != null) {
                if (i < zaikuId.size() - 1) {
                    sqlTail += zaikuId[i] + '\',\'';
                } else {
                    sqlTail += zaikuId[i];
                }
            }
        }
        sqlTail += '\')';
@@ -1568,6 +1800,7 @@
        }
        System.debug('zhj3');
        pageRecords = new List<ConsumableorderdetailsInfo>();
        System.debug('reSet.size() = ' + reSet.size());
        if (editAble && String.isBlank(arriveorder)) {
            pageRecords = reSet;
        }
@@ -1575,7 +1808,7 @@
        //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
        Integer addNo = 0;
        //update by rentx 2021-2-26 start
        System.debug('consumableorderdetailsSelectRecords = ' + consumableorderdetailsSelectRecords);
        System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size());
        for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) {
            Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
            if (
@@ -1600,6 +1833,7 @@
    public static List<ConsumableorderdetailsInfo> makepagerecordsLwc() {
        List<ConsumableorderdetailsInfoLwc> reSetLwc = new List<ConsumableorderdetailsInfoLwc>();
        Map<String, String> selectedIdMap = new Map<String, String>();
        skipData = new Map<String, String>();
        System.debug('makepagerecordsLwc pageRecordsLwc = ' + pageRecordsLwc);
        //取出选择的产品
        if (pageRecordsLwc != null) {
@@ -1608,19 +1842,21 @@
                if (ass.check == true) {
                    if (ass.hospitalSpecialOffer == true) {
                        selectedIdMap.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
                        skipData.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
                    } else {
                        selectedIdMap.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
                        skipData.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
                    }
                    reSetLwc.add(ass);
                }
            }
        }
        System.debug('reSetLwc = ' + reSetLwc);
        System.debug('selectedIdMap = ' + selectedIdMap);
        pageRecords = new List<ConsumableorderdetailsInfo>();
        if (editAble && String.isBlank(arriveorder)) {
            List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
            for(ConsumableorderdetailsInfoLwc assLwc : reSetLwc){
            System.debug('reSetLwc = ' + reSetLwc);
            for (ConsumableorderdetailsInfoLwc assLwc : reSetLwc) {
                ConsumableorderdetailsInfo ci = new ConsumableorderdetailsInfo();
                ci.check = assLwc.check;
                ci.oldCheck = assLwc.oldCheck;
@@ -1646,19 +1882,24 @@
                reSet.add(ci);
            }
            pageRecords = reSet;
            System.debug('reSet = ' + reSet);
            addData = reSet.clone();
            System.debug('addData = reSet = ' + addData);
        }
        //Integer pagestartNo = (setCon.getPageNumber() * size)-size;
        //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
        Integer addNo = 0;
        //update by rentx 2021-2-26 start
        System.debug('consumableorderdetailsSelectRecords = ' + consumableorderdetailsSelectRecords);
        System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size());
        for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) {
            Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
            if (
                (info.hospitalSpecialOffer && selectedIdMap.containsKey(info.Prod.Id + 'ishos')) ||
                (info.hospitalSpecialOffer == false && selectedIdMap.containsKey(info.Prod.Id + 'nothos'))
            ) {
                System.debug('去掉的id : ' + info.Prod.Id);
                addNo++;
                addSize++;
            } else {
                if (info.check == false) {
                    info.orderdetails1 = orderdetails1;
@@ -1667,93 +1908,109 @@
                addNo++;
            }
        }
        System.debug('pageRecords = ' + pageRecords);
        System.debug('pageRecords.size() = ' + pageRecords.size());
        System.debug('end  addData = ' + addData);
        return pageRecords;
    }
    // 保存按钮
    @AuraEnabled
    public static ResponseBodyLWC save(Consumable_order__c cocLwc,String hospitalInfoLwc,String hospitalNameLwc,String secondaryDistributor,List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,String accountid,String ESetId,List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc) {
        System.debug('cocLwc = ' + cocLwc);
    public static ResponseBodyLWC save(
        Consumable_order__c cocLwc,
        String hospitalInfoLwc,
        String hospitalNameLwc,
        String secondaryDistributorLwc,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,
        String accountidLwc,
        String ESetIdLwc,
        List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
        String agencyProTypeLwc,
        String userWorkLocationLwc
    ) {
        coc = cocLwc;
        HospitalInfo = hospitalInfoLwc;
        HospitalName = hospitalNameLwc;
        SecondDealer = secondaryDistributor;
        SecondDealer = secondaryDistributorLwc;
        pageRecordsLwc = pageRecordsLwc;
        accountid = accountidLwc;
        consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
        ESetId = ESetIdLwc;
        agencyProType = agencyProTypeLwc;
        userWorkLocation = userWorkLocationLwc;
        System.debug('coc = ' + coc);
        System.debug('HospitalInfo = ' + HospitalInfo);
        System.debug('HospitalName = ' + HospitalName);
        System.debug('SecondDealer = ' + SecondDealer);
        System.debug('pageRecordsLwc = ' + pageRecordsLwc);
        System.debug('accountid = ' + accountid);
        System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords);
        System.debug('ESetId = ' + ESetId);
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        //订单信息确认
        if(coc.SummonsForDirction__c  ==''||coc.SummonsForDirction__c  == null){
        if (coc.SummonsForDirction__c == '' || coc.SummonsForDirction__c == null) {
            // coc.SummonsForDirction__c.addError('请输入指示单目的。');
            // return null;
            return new ResponseBodyLWC('Error',500, '请输入指示单目的。', '');
        }
        else if(coc.SummonsForDirction__c =='直接销售给医院'){
            if(String.isBlank(HospitalInfo) || String.isBlank(HospitalName)){
            return new ResponseBodyLWC('Error', 500, '请输入指示单目的。', '');
        } else if (coc.SummonsForDirction__c == '直接销售给医院') {
            if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
                // coc.addError('请输入医院。');
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入医院。', '');
                return new ResponseBodyLWC('Error', 500, '请输入医院。', '');
            }
            if(String.isBlank(coc.Order_ForCustomerText__c)){
            if (String.isBlank(coc.Order_ForCustomerText__c)) {
                // coc.Order_ForCustomerText__c.addError('请输入科室。');
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入科室。', '');
            }
            else if(String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)){
                return new ResponseBodyLWC('Error', 500, '请输入科室。', '');
            } else if (String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)) {
                // coc.addError('不需要二级经销商和经销商(录入)信息。' );
                // return null;
                return new ResponseBodyLWC('Error',500, '不需要二级经销商和经销商(录入)信息。', '');
                return new ResponseBodyLWC('Error', 500, '不需要二级经销商和经销商(录入)信息。', '');
            }
        }else if(coc.SummonsForDirction__c =='医院试用'){
            if(String.isBlank(HospitalInfo) || String.isBlank(HospitalName)){
        } else if (coc.SummonsForDirction__c == '医院试用') {
            if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
                // coc.addError('请输入医院。');
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入医院。', '');
                return new ResponseBodyLWC('Error', 500, '请输入医院。', '');
            }
            if(String.isBlank(coc.Order_ForCustomerText__c)){
            if (String.isBlank(coc.Order_ForCustomerText__c)) {
                // coc.Order_ForCustomerText__c.addError('请输入科室。');
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入科室。', '');
                return new ResponseBodyLWC('Error', 500, '请输入科室。', '');
            }
        }
        else if(coc.SummonsForDirction__c =='销售给二级经销商'){
            if(String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)){
        } else if (coc.SummonsForDirction__c == '销售给二级经销商') {
            if (String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)) {
                // coc.addError('必须输入二级经销商或经销商(录入)。');
                // return null;
                return new ResponseBodyLWC('Error',500, '必须输入二级经销商或经销商(录入)。', '');
                return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)。', '');
            }
            if(String.isBlank(HospitalInfo) || String.isBlank(HospitalName)){
            if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
                // coc.addError('请输入医院。');
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入医院。', '');
                return new ResponseBodyLWC('Error', 500, '请输入医院。', '');
            }
            if(String.isBlank(coc.Order_ForCustomerText__c)){
            if (String.isBlank(coc.Order_ForCustomerText__c)) {
                // coc.Order_ForCustomerText__c.addError('请输入科室。');
                // return null;
                return new ResponseBodyLWC('Error',500, '请输入科室。', '');
                return new ResponseBodyLWC('Error', 500, '请输入科室。', '');
            }
        }
        else if(coc.SummonsForDirction__c =='互相调货'){
            if(String.isNotBlank(HospitalInfo) || String.isNotBlank(HospitalName)){
        } else if (coc.SummonsForDirction__c == '互相调货') {
            if (String.isNotBlank(HospitalInfo) || String.isNotBlank(HospitalName)) {
                // coc.addError('不需要输入医院。');
                // return null;
                return new ResponseBodyLWC('Error',500, '不需要输入医院。', '');
                return new ResponseBodyLWC('Error', 500, '不需要输入医院。', '');
            }
            if(String.isNotBlank(coc.Order_ForCustomerText__c)){
            if (String.isNotBlank(coc.Order_ForCustomerText__c)) {
                // coc.Order_ForCustomerText__c.addError('不需要输入科室。');
                // return null;
                return new ResponseBodyLWC('Error',500, '不需要输入科室。', '');
                return new ResponseBodyLWC('Error', 500, '不需要输入科室。', '');
            }
            if(String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)){
            if (String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)) {
                // coc.addError('必须输入二级经销商或经销商(录入)。');
                // return null;
                return new ResponseBodyLWC('Error',500, '必须输入二级经销商或经销商(录入)。', '');
                return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)。', '');
            }
        }
@@ -1761,47 +2018,47 @@
        Integer FLG = 0;
        Integer Count = 0;
        for(ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
        for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
            FLG = FLG + 1;
            if(CheckCount.check == false){
            if (CheckCount.check == false) {
                Count = Count + 1;
            }else{
            } else {
                //add by rentx
                if (CheckCount.hospitalSpecialOffer) {
                    isHos = isHos+1;
                    isHos = isHos + 1;
                }
                //add by rentx
            }
        }
        if(Count == FLG){
        if (Count == FLG) {
            // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请选择所需消耗品'));
            // return null;
            return new ResponseBodyLWC('Error',500, '请选择所需消耗品', '');
            return new ResponseBodyLWC('Error', 500, '请选择所需消耗品', '');
        }
        // gzw 注释 判断提前 20210308
        //checkOutPattern();
        //根据用户选中的产品给 出库单上的是否医院特价出库字段赋值
        Integer isHosCheckOutPattern = 0;
        for(ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
        for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
            if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) {
                isHosCheckOutPattern = isHosCheckOutPattern +1;
                isHosCheckOutPattern = isHosCheckOutPattern + 1;
            }
        }
        if (isHosCheckOutPattern > 0) {
            coc.OutPattern__c = true;
        }else{
        } else {
            coc.OutPattern__c = false;
        }
        // add by rentx 2021-3-10 start
        //特价医院出库非本医院维护的特价商品时,报错 非特价医院出库维护在医院特价关系表的产品时 报错
        if(coc.SummonsForDirction__c !='互相调货'){
        if (coc.SummonsForDirction__c != '互相调货') {
            //非特价医院出库特价产品时 报错(当前经销商下没有特价医院除外)
            List<hospitalprice__c> hopList = [select id,hospital__c,product__c from hospitalprice__c where account__c = :accountid];
            List<hospitalprice__c> hopList = [SELECT id, hospital__c, product__c FROM hospitalprice__c WHERE account__c = :accountid];
            //经销商对应医院下的所有特价产品
            Map<String,String> proMap = new Map<String,String>();
            Map<String, String> proMap = new Map<String, String>();
            //经销商下的所有特价产品
            Map<String,String> allProMap = new Map<String,String>();
            Map<String, String> allProMap = new Map<String, String>();
            if (hopList != null && hopList.size() > 0) {
                Boolean flag = false;
@@ -1810,47 +2067,50 @@
                        allProMap.put(hp.product__c, '');
                        //如果当前 医院特价关系中的医院对应出库单上出库的医院,则放产品id到map
                        if (hp.hospital__c == HospitalInfo) {
                            flag = true;
                            flag = true;
                            proMap.put(hp.product__c, '');
                        }
                    }
                }
                for(ConsumableorderdetailsInfoLwc ass : pageRecordsLwc){
                for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
                    if (ass.check == true) {
                        //判断选中的医院特价产品
                        if (ass.hospitalSpecialOffer == true) {
                            //用户选中了当前医院下的特价产品
                            if (proMap.containsKey(ass.Prod.Id)) {
                                continue;
                            //用户选中了没有维护特价医院的特价产品
                            }else if (!allProMap.containsKey(ass.Prod.Id)) {
                                //用户选中了没有维护特价医院的特价产品
                            } else if (!allProMap.containsKey(ass.Prod.Id)) {
                                continue;
                            }else{
                            } else {
                                //用户选中非当前医院维护的特价产品
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '当前医院没有维护 消耗品:'+ ass.Prod.Name__c +' 的特价'));
                                // return null;
                                return new ResponseBodyLWC('Error',500, '当前医院没有维护 消耗品:' + ass.Prod.Name__c + '的特价', '');
                                return new ResponseBodyLWC('Error', 500, '当前医院没有维护 消耗品:' + ass.Prod.Name__c + '的特价', '');
                            }
                        }//非医院特价产品可以出库给任意医院,所以不需要判断
                        } //非医院特价产品可以出库给任意医院,所以不需要判断
                    }
                }
            }
        }else{
            //如果是互相调货,判断 经销商(录入) 是否维护了 当前选中的特价产品
            List<hospitalprice__c> hopList = [select id,hospital__c,product__c from hospitalprice__c where account__c = :coc.Order_ForDealerTextID__c];
            Map<Id,String> proMap = new Map<Id,String>();
        } else {
            //如果是互相调货,判断 经销商(录入) 是否维护了 当前选中的特价产品
            List<hospitalprice__c> hopList = [
                SELECT id, hospital__c, product__c
                FROM hospitalprice__c
                WHERE account__c = :coc.Order_ForDealerTextID__c
            ];
            Map<Id, String> proMap = new Map<Id, String>();
            if (hopList != null && hopList.size() > 0) {
                for (hospitalprice__c hpc : hopList) {
                    proMap.put(hpc.product__c, '');
                }
                String proStr = '';
                for(ConsumableorderdetailsInfoLwc ass : pageRecordsLwc){
                for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
                    if (ass.check == true) {
                        if (ass.hospitalSpecialOffer == true) {
                            if (!proMap.containsKey(ass.Prod.Id)) {
                                proStr += ass.Prod.Name__c+',';
                                proStr += ass.Prod.Name__c + ',';
                            }
                        }
                    }
@@ -1858,124 +2118,291 @@
                if (proStr != '') {
                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '经销商:'+coc.Order_ForDealerText__c +' 没有消耗品:'+proStr.substring(0,proStr.length()-1) + ' 的特价'));
                    // return null;
                    return new ResponseBodyLWC('Error',500, '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0,proStr.length()-1) + ' 的特价', '');
                    return new ResponseBodyLWC(
                        'Error',
                        500,
                        '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0, proStr.length() - 1) + ' 的特价',
                        ''
                    );
                }
            }
        }
        // checkOutPattern();
        Consumable_order__c p = new Consumable_order__c();
        List<Consumable_orderdetails__c> Ins = New List<Consumable_orderdetails__c>();
        List<Consumable_order_details2__c> InsProduct = New List<Consumable_order_details2__c>();
        List<Consumable_orderdetails__c> Ins = new List<Consumable_orderdetails__c>();
        List<Consumable_order_details2__c> InsProduct = new List<Consumable_order_details2__c>();
        Savepoint sp = Database.setSavepoint();
        // try {
            //新建订单时
            if(String.isEmpty(ESetId)){
                p.Name = '*';
                p.Order_type__c = '传票';
                p.Order_ProType__c = agencyProType;
                if(coc.SummonsStatus_c__c ==null||String.isBlank(coc.SummonsStatus_c__c))coc.SummonsStatus_c__c ='草案中';
                // update strat by vivek 2019-7-12
                p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
                // update end by vivek 2019-7-12
                p.SummonsStatus_c__c = coc.SummonsStatus_c__c;
                if(coc.Arrive_Order__c != null){
                    p.Arrive_Order__c = coc.Arrive_Order__c;
                }
                p.Offers_Price__c = coc.Offers_Price__c;
                p.Dealer_Info__c = accountid;
                if(String.isBlank(SecondDealer)){
                    p.Order_ForHospital__c =String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                    p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                }else {
                    p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                    p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                    p.Order_ForDealer__c = SecondDealer;
                }
                P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
                P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
                p.Order_date__c = coc.Order_date__c;
                p.SummonsForDirction__c = coc.SummonsForDirction__c;
                p.RecordTypeid = System.Label.RT_ConOrder_Outboundorder;
                // update start by vivek 2019-7-15
                p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
                // update end by vivek 2019-7-15
                //add by rentx
                p.OutPattern__c = coc.OutPattern__c;
                //add by rentx
                //Map<String,String> ProductNewMap = new Map<String, String>();
                for(ConsumableorderdetailsInfoLwc ass : pageRecordsLwc){
                    if(ass.check == true){
                        if(ass.orderdetails1.Delivery_List_RMB__c < 0){
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入正确的出货单价 (元)。', '');
                        }
                        if(ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c !='医院试用'){
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入正确的出货单价 (元)。', '');
                        }
                        if(ass.orderdetails1.Delivery_List_RMB__c == 0 && (coc.SummonsForDirction__c =='销售给二级经销商' || coc.SummonsForDirction__c =='直接销售给医院')){
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', '');
                        }
                        if(ass.orderdetails1.Shipment_Count__c == null ||ass.orderdetails1.Shipment_Count__c ==0){
                            // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货数量。', '');
                        }
        //新建订单时
        if (String.isEmpty(ESetId)) {
            p.Name = '*';
            p.Order_type__c = '传票';
            p.Order_ProType__c = agencyProType;
            if (coc.SummonsStatus_c__c == null || String.isBlank(coc.SummonsStatus_c__c))
                coc.SummonsStatus_c__c = '草案中';
            // update strat by vivek 2019-7-12
            p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
            // update end by vivek 2019-7-12
            p.SummonsStatus_c__c = coc.SummonsStatus_c__c;
            if (coc.Arrive_Order__c != null) {
                p.Arrive_Order__c = coc.Arrive_Order__c;
            }
            p.Offers_Price__c = coc.Offers_Price__c;
            p.Dealer_Info__c = accountid;
            if (String.isBlank(SecondDealer)) {
                p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
            } else {
                p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                p.Order_ForDealer__c = SecondDealer;
            }
            P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
            P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
            p.Order_date__c = coc.Order_date__c;
            p.SummonsForDirction__c = coc.SummonsForDirction__c;
            p.RecordTypeid = System.Label.RT_ConOrder_Outboundorder;
            // update start by vivek 2019-7-15
            p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
            // update end by vivek 2019-7-15
            //add by rentx
            p.OutPattern__c = coc.OutPattern__c;
            //add by rentx
            //Map<String,String> ProductNewMap = new Map<String, String>();
            for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
                if (ass.check == true) {
                    if (ass.orderdetails1.Delivery_List_RMB__c < 0) {
                        // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', '');
                    }
                    if (ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c != '医院试用') {
                        // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', '');
                    }
                    if (
                        ass.orderdetails1.Delivery_List_RMB__c == 0 &&
                        (coc.SummonsForDirction__c == '销售给二级经销商' ||
                        coc.SummonsForDirction__c == '直接销售给医院')
                    ) {
                        // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', '');
                    }
                    if (ass.orderdetails1.Shipment_Count__c == null || ass.orderdetails1.Shipment_Count__c == 0) {
                        // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入出货数量。', '');
                    }
                        if(ass.orderdetails1.Box_Piece__c == null ||ass.orderdetails1.Box_Piece__c ==''){
                            // ass.orderdetails1.Box_Piece__c.addError('请输入单位。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入单位。', '');
                        }
                        if(ass.orderdetails1.Box_Piece__c == '盒'){
                            if(ass.orderdetails1.Shipment_Count__c > ass.Boxnumber){
                                //ass.orderdetails1.Shipment_Count__c.addError('库存不足');
                                if(ass.oldCheck == false){
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                }
                    if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') {
                        // ass.orderdetails1.Box_Piece__c.addError('请输入单位。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入单位。', '');
                    }
                    if (ass.orderdetails1.Box_Piece__c == '盒') {
                        if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) {
                            //ass.orderdetails1.Shipment_Count__c.addError('库存不足');
                            if (ass.oldCheck == false) {
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', '');
                            } else {
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
                        }else if(ass.orderdetails1.Box_Piece__c == '个'){
                            if(ass.orderdetails1.Shipment_Count__c > ass.Piecenumber){
                                //ass.orderdetails1.Shipment_Count__c.addError('库存不足');
                                if(ass.oldCheck == false){
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                }
                        }
                    } else if (ass.orderdetails1.Box_Piece__c == '个') {
                        if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) {
                            //ass.orderdetails1.Shipment_Count__c.addError('库存不足');
                            if (ass.oldCheck == false) {
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', '');
                            } else {
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
                        }
                    }
                }
                insert p;
                ESetId = p.id;
                List<Consumable_order__c> detailName = new List<Consumable_order__c>();
                detailName = [SELECT id,Name FROM Consumable_order__c WHERE id =:ESetId];
                Integer i = 1;
                for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc)  {
                    if(ass.check == true){
                        Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
            }
            insert p;
            ESetId = p.id;
            List<Consumable_order__c> detailName = new List<Consumable_order__c>();
            detailName = [SELECT id, Name FROM Consumable_order__c WHERE id = :ESetId];
            Integer i = 1;
            for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
                if (ass.check == true) {
                    Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
                    String str = string.valueOf(i);
                    if (str.length() == 1) {
                        str = '0' + str;
                    }
                    InsAfterDel.Name = detailName[0].name + '-' + str;
                    InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
                    InsAfterDel.Consumable_order__c = p.id;
                    InsAfterDel.Consumable_Product__c = ass.Prod.id;
                    InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
                    InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
                    // TODO 默认 盒 ,需要修正
                    InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c;
                    InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c;
                    //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
                    InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
                    InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
                    //add by rentx 2021-2-26 start
                    InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer;
                    //add by rentx 2021-2-26 end
                    i++;
                    Ins.add(InsAfterDel);
                }
            }
            // 如果 出库单 和 OCM发货Header连 的话,发货的Detail2 Copy到 出库单的Detail2里
            if (getExistarrive()) {
                for (ConsumableorderdetailsInfo ass : consumableproductdetailsRecords) {
                    //BlockForP;
                    Consumable_order_details2__c InsProductDet = new Consumable_order_details2__c();
                    InsProductDet.Id = ass.orderdetails2.Id;
                    InsProductDet.Consumable_ZS_order__c = p.id;
                    i++;
                    InsProduct.add(InsProductDet);
                }
            }
            if (Ins.size() > 0) {
                insert Ins;
            }
            if (InsProduct.size() > 0) {
                //ControllerUtil.updateOrderDetailsSatus(InsProduct);
                update InsProduct;
            }
        } else if (ESetId != null || ESetId.length() > 0) {
            //修改之后 保存订单
            List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
            // update start by vivek 2019-7-15 add "NoConfirmedPrice__c" in select
            cocinfo = [
                SELECT Id, Name, SummonsStatus_c__c, NoConfirmedPrice__c, Dealer_Info__c, Order_ForHospital__c, SummonsForDirction__c
                FROM Consumable_order__c
                WHERE Id = :ESetId
            ];
            // update end by vivek 2019-7-15
            if (cocinfo.size() > 0) {
                p = cocinfo[0];
            }
            p.Name = coc.Name;
            p.Dealer_Info__c = accountid;
            p.Order_ProType__c = agencyProType;
            if (String.isEmpty(SecondDealer)) {
                p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                System.debug('SecondDealer = ' + SecondDealer);
                p.Order_ForDealer__c = null;
            } else {
                p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                p.Order_ForDealer__c = SecondDealer;
            }
            P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
            P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
            p.Order_date__c = coc.Order_date__c;
            p.SummonsForDirction__c = coc.SummonsForDirction__c;
            //add by rentx
            p.OutPattern__c = coc.OutPattern__c;
            // update start by vivek 2019-7-15
            if (p.SummonsStatus_c__c == '价格未定') {
                p.NoConfirmedPrice__c = false;
                p.SummonsStatus_c__c = '已完成';
            } else {
                p.SummonsStatus_c__c = '草案中';
            }
            // p.SummonsStatus_c__c = '草案中';
            // update end by vivek 2019-7-15
            Integer i = 1;
            //Map<String,String> ProductOldMap = new Map<String, String>();
            for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
                if (ass.check == true) {
                    if (ass.orderdetails1.Delivery_List_RMB__c < 0) {
                        // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', '');
                    }
                    Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
                    if (ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c != '医院试用') {
                        // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', '');
                    }
                    if (
                        ass.orderdetails1.Delivery_List_RMB__c == 0 &&
                        (coc.SummonsForDirction__c == '销售给二级经销商' ||
                        coc.SummonsForDirction__c == '直接销售给医院')
                    ) {
                        // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', '');
                    }
                    if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') {
                        // ass.orderdetails1.Box_Piece__c.addError('请输入单位。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入单位。', '');
                    }
                    if (ass.orderdetails1.Box_Piece__c == '盒') {
                        if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) {
                            //ass.orderdetails1.Shipment_Count__c.addError('库存不足');
                            if (ass.oldCheck == false) {
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', '');
                            } else {
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
                        }
                    } else if (ass.orderdetails1.Box_Piece__c == '个') {
                        if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) {
                            if (ass.oldCheck == false) {
                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', '');
                            } else {
                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
                        }
                    }
                    if (ass.orderdetails1.Shipment_Count__c == null || ass.orderdetails1.Shipment_Count__c == 0) {
                        // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。');
                        // return null;
                        return new ResponseBodyLWC('Error', 500, '请输入出货数量。', '');
                    } else {
                        String str = string.valueOf(i);
                        if(str.length() == 1){
                        if (str.length() == 1) {
                            str = '0' + str;
                        }
                        InsAfterDel.Name = detailName[0].name + '-'+ str;
                        InsAfterDel.Name = p.name + '-' + str;
                        InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
                        InsAfterDel.Consumable_order__c = p.id;
                        InsAfterDel.Consumable_order__c = ESetId;
                        InsAfterDel.Consumable_Product__c = ass.Prod.id;
                        InsAfterDel.Intra_Trade_List_RMB__c =ass.Prod.Intra_Trade_List_RMB__c;
                        InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
                        InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
                        // TODO 默认 盒 ,需要修正
                        InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c;
                        InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c;
                        //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
@@ -1988,155 +2415,17 @@
                        Ins.add(InsAfterDel);
                    }
                }
                // 如果 出库单 和 OCM发货Header连 的话,发货的Detail2 Copy到 出库单的Detail2里
                if (getExistarrive()) {
                    for (ConsumableorderdetailsInfo ass : consumableproductdetailsRecords)  {
                        //BlockForP;
                        Consumable_order_details2__c InsProductDet = new Consumable_order_details2__c();
                        InsProductDet.Id = ass.orderdetails2.Id;
                        InsProductDet.Consumable_ZS_order__c = p.id;
                        i++;
                        InsProduct.add(InsProductDet);
                    }
                }
                if(Ins.size()>0){
                    insert Ins;
                }
                if(InsProduct.size() >0){
                    ControllerUtil.updateOrderDetailsSatus(InsProduct);
                }
            }
            //修改之后 保存订单
            else if(ESetId != null || ESetId.length() >0 ){
                List<Consumable_order__c> cocinfo = New List<Consumable_order__c>();
                // update start by vivek 2019-7-15 add "NoConfirmedPrice__c" in select
                cocinfo = [SELECT Id,
                                Name,
                                SummonsStatus_c__c,
                                NoConfirmedPrice__c,
                                Dealer_Info__c,
                                Order_ForHospital__c,
                                SummonsForDirction__c
                            FROM Consumable_order__c
                            WHERE Id =:ESetId];
                // update end by vivek 2019-7-15
                if (cocinfo.size()>0){
                    p = cocinfo[0];
                }
                p.Name = coc.Name;
                p.Dealer_Info__c = accountid;
                p.Order_ProType__c = agencyProType;
                if(SecondDealer == null){
                    p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                    p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                    p.Order_ForDealer__c = SecondDealer;
                }else {
                    p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
                    p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                    p.Order_ForDealer__c = SecondDealer;
                }
                P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
                P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
                p.Order_date__c = coc.Order_date__c;
                p.SummonsForDirction__c = coc.SummonsForDirction__c;
                //add by rentx
                p.OutPattern__c = coc.OutPattern__c;
                // update start by vivek 2019-7-15
                if(p.SummonsStatus_c__c== '价格未定'){
                    p.NoConfirmedPrice__c = false;
                    p.SummonsStatus_c__c= '已完成';
                }else{
                    p.SummonsStatus_c__c = '草案中';
                }
                // p.SummonsStatus_c__c = '草案中';
                // update end by vivek 2019-7-15
                Integer i = 1;
                //Map<String,String> ProductOldMap = new Map<String, String>();
                for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc)  {
                    if(ass.check == true){
                        if(ass.orderdetails1.Delivery_List_RMB__c < 0){
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入正确的出货单价 (元)。', '');
                        }
                        Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
                        if(ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c !='医院试用'){
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', '');
                        }
                        if(ass.orderdetails1.Delivery_List_RMB__c == 0 && (coc.SummonsForDirction__c =='销售给二级经销商' || coc.SummonsForDirction__c =='直接销售给医院')){
                            // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', '');
                        }
                        if(ass.orderdetails1.Box_Piece__c == null ||ass.orderdetails1.Box_Piece__c ==''){
                            // ass.orderdetails1.Box_Piece__c.addError('请输入单位。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入单位。', '');
                        }
                        if(ass.orderdetails1.Box_Piece__c == '盒'){
                            if(ass.orderdetails1.Shipment_Count__c > ass.Boxnumber){
                                //ass.orderdetails1.Shipment_Count__c.addError('库存不足');
                                if(ass.oldCheck == false){
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                }
                            }
                        }else if(ass.orderdetails1.Box_Piece__c == '个'){
                            if(ass.orderdetails1.Shipment_Count__c > ass.Piecenumber){
                                if(ass.oldCheck == false){
                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', '');
                                }else{
                                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                                    return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
                                }
                            }
                        }
                        if(ass.orderdetails1.Shipment_Count__c == null||ass.orderdetails1.Shipment_Count__c==0){
                            // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。');
                            // return null;
                            return new ResponseBodyLWC('Error',500, '请输入出货数量。', '');
                        }else{
                            String str = string.valueOf(i);
                            if(str.length() == 1){
                                str = '0' + str;
                            }
                            InsAfterDel.Name = p.name + '-'+ str;
                            InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
                            InsAfterDel.Consumable_order__c = ESetId;
                            InsAfterDel.Consumable_Product__c = ass.Prod.id;
                            InsAfterDel.Intra_Trade_List_RMB__c =ass.Prod.Intra_Trade_List_RMB__c;
                            InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
                            InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c;
                            InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c;
                            //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
                            InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
                            InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
                            //add by rentx 2021-2-26 start
                            InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer;
                            //add by rentx 2021-2-26 end
                            i++;
                            Ins.add(InsAfterDel);
                        }
                    }
                }
                update p;
                List<Consumable_orderdetails__c> qs = New List<Consumable_orderdetails__c>();
                qs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c =:ESetId];
                if (qs.size()>0){
                    delete qs;
                }
                if(Ins.size()>0){
                    insert Ins;
                }
            update p;
            List<Consumable_orderdetails__c> qs = new List<Consumable_orderdetails__c>();
            qs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId];
            if (qs.size() > 0) {
                delete qs;
            }
            if (Ins.size() > 0) {
                insert Ins;
            }
        }
        // }catch (Exception ex) {
        //     Database.rollback(sp);
        //     // ApexPages.addMessages(ex);
@@ -2144,31 +2433,31 @@
        //     //return new ResponseBodyLWC('Error',500, ex.getMessage(), '');
        //     return new ResponseBodyLWC('Error',500, JSON.serialize(ex), '');
        // }
        data.put('ESetId',ESetId);
        data.put('ESetId', ESetId);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    public static void checkOutPattern(){
    public static void checkOutPattern() {
        //根据用户选中的产品给 出库单上的是否医院特价出库字段赋值
        Integer isHos = 0;
        for(ConsumableorderdetailsInfo CheckCount : pageRecords) {
        for (ConsumableorderdetailsInfo CheckCount : pageRecords) {
            if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) {
                ishos = ishos +1;
                ishos = ishos + 1;
            }
        }
        if (isHos > 0) {
            coc.OutPattern__c = true;
        }else{
        } else {
            coc.OutPattern__c = false;
        }
    }
    //打印PDF
    @AuraEnabled
    public static ResponseBodyLWC PraseToPDF(Consumable_order__c cocLwc,String ESetId){
    public static ResponseBodyLWC PraseToPDF(Consumable_order__c cocLwc, String ESetId) {
        System.debug('cocLwc = ' + cocLwc);
        System.debug('ESetId = ' + ESetId);
        coc = cocLwc;
@@ -2176,19 +2465,184 @@
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        if(coc.SummonsStatus_c__c =='批准'){
        if (coc.SummonsStatus_c__c == '批准') {
            Consumable_order__c P = new Consumable_order__c();
            List<Consumable_order__c> cocinfo = New List<Consumable_order__c>();
            // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select
            cocinfo = [SELECT Id,Name,SummonsStatus_c__c,NoConfirmedPrice__c,Dealer_Info__c,Order_ForHospital__c,SummonsForDirction__c,Billed_Status__c FROM Consumable_order__c WHERE Id =:ESetId];
            List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
            // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select
            cocinfo = [
                SELECT
                    Id,
                    Name,
                    SummonsStatus_c__c,
                    NoConfirmedPrice__c,
                    Dealer_Info__c,
                    Order_ForHospital__c,
                    SummonsForDirction__c,
                    Billed_Status__c
                FROM Consumable_order__c
                WHERE Id = :ESetId
            ];
            // update end by vivek 2019-7-15
                if (cocinfo.size()>0){
                    p = cocinfo[0];
                }
            if (cocinfo.size() > 0) {
                p = cocinfo[0];
            }
            p.SummonsStatus_c__c = '出库单已打印';
            update p;
        }
        data.put('ESetId',ESetId);
        data.put('ESetId', ESetId);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    //查找经销商
    @AuraEnabled(cacheable=true scope='global')
    public static List<LookupSearchResult> search(String searchTerm) {
        System.debug('searchTerm = ' + searchTerm);
        String nameCondition = '';
        nameCondition += '%' + String.escapeSingleQuotes(''.replaceAll('%', '\\%')) + '%';
        List<Account> accs;
        System.debug('nameCondition = ' + nameCondition);
        accs = [
            SELECT id, Parentid
            FROM Account
            WHERE
                Parent.Name LIKE :nameCondition
                AND Contract_Decide_Start_Date__c <= :Date.Today()
                AND Contract_Decide_End_Date__c >= :Date.Today()
        ];
        // 用于保存特约经销商匹配到的其父类的id
        Set<String> pids = new Set<String>();
        for (Account acc : accs) {
            pids.add(acc.Parentid);
        }
        accs = [
            SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
            FROM Account
            WHERE
                (Id IN :pids
                OR (Name = '奥林巴斯(北京)销售服务有限公司'
                AND Name LIKE :nameCondition))
                AND RecordType.DeveloperName = 'Agency'
                AND Is_Active__c != '無効'
            ORDER BY Name
            LIMIT 5
        ];
        List<LookupSearchResult> results = new List<LookupSearchResult>();
        String accountIcon = 'standard:account';
        for (Account account : accs) {
            String subtitle = account.BillingCity == null ? 'Account' : 'Account • ' + account.BillingCity;
            results.add(new LookupSearchResult(account.Id, 'Account', accountIcon, account.Name, subtitle));
        }
        results.sort();
        System.debug('results = ' + results);
        return results;
    }
    //保存附件
    @AuraEnabled
    public static String saveFile(Id recordId, String fileName, String base64Data) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
        ContentVersion cv = new ContentVersion();
        cv.Title = fileName;
        cv.PathOnClient = '/' + fileName;
        cv.FirstPublishLocationId = recordId;
        cv.VersionData = EncodingUtil.base64Decode(base64Data);
        cv.IsMajorVersion = true;
        insert cv;
        return cv.Id;
    }
    //获取附件
    @AuraEnabled
    public static ResponseBodyLWC getFiles(Id recordId) {
        System.debug('getFiles recordId = ' + recordId);
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        List<ContentVersion> cvList = [
            SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate
            FROM ContentVersion
            WHERE FirstPublishLocationId = :recordId
        ];
        data.put('cvList', cvList);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    //跳转出货/销售
    @AuraEnabled
    public static ResponseBodyLWC GoodsDelivery(
        Consumable_order__c cocLwc,
        String ESetId,
        List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc
    ) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        coc = cocLwc;
        ESetId = ESetId;
        pageRecordsLwc = pageRecordsLwcLwc;
        if (coc.SummonsForDirction__c == '互相调货') {
            List<Account> accList = [
                SELECT Id
                FROM Account
                WHERE Name = :coc.Order_ForDealerText__c AND RecordType.DeveloperName = 'Agency'
            ];
            if (accList.size() < 1) {
                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请输入二级经销商全称!'));
                // return null;
                return new ResponseBodyLWC('Error', 500, '请输入二级经销商全称!', '');
            }
        }
        if (coc.SummonsStatus_c__c == '批准') {
            // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请先打印指示单!'));
            // return null;
            return new ResponseBodyLWC('Error', 500, '请先打印指示单!', '');
        }
        for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
            if (ass.orderdetails1.Shipment_Count__c > ass.allnumber) {
                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足'));
                // return null;
                return new ResponseBodyLWC('Error', 500, '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', '');
            }
        }
        data.put('ESetid', ESetid);
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
        return res;
    }
    //删除按钮
    @AuraEnabled
    public static ResponseBodyLWC DelConsumable(String ESetId) {
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        ESetId = ESetId;
        Savepoint sp = Database.setSavepoint();
        try {
            List<Consumable_order__c> qs = new List<Consumable_order__c>();
            List<Consumable_orderdetails__c> Dqs = new List<Consumable_orderdetails__c>();
            Dqs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId];
            qs = [SELECT Id FROM Consumable_order__c WHERE Id = :ESetId];
            if (Dqs.size() > 0 || qs.size() > 0) {
                delete Dqs;
                delete qs;
            }
        } catch (Exception e) {
            Database.rollback(sp);
            System.debug(e.getMessage() + e.getLineNumber());
            return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
        }
        res.status = 'Success';
        res.code = 200;
        System.debug('res = ' + res);
@@ -2240,7 +2694,8 @@
        @AuraEnabled
        public Boolean hosPro { get; set; }
        public ConsumableorderdetailsInfo(){}
        public ConsumableorderdetailsInfo() {
        }
        public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
            check = true;
@@ -2289,6 +2744,7 @@
            hospitalSpecialOffer = false;
            hosPro = false;
        }
        public ConsumableorderdetailsInfo(Product2__c e) {
            check = false;
            oldCheck = false;
@@ -2334,7 +2790,7 @@
        }
    }
    class ConsumableorderdetailsInfoLwc{
    class ConsumableorderdetailsInfoLwc {
        @AuraEnabled
        public Boolean check { get; set; }
        @AuraEnabled
@@ -2377,24 +2833,38 @@
        @AuraEnabled
        public Boolean hosPro { get; set; }
        @AuraEnabled
        public List<Map<String,String>> unitOptions{ get; set; }
        public List<Map<String, String>> unitOptions { get; set; }
        @AuraEnabled
        public String unitValue{ get; set; }
        public String unitValue { get; set; }
        @AuraEnabled
        public Integer shipmentNumber{ get; set; }
        public Integer shipmentNumber { get; set; }
        @AuraEnabled
        public Decimal shippingUnitPrice{ get; set; }
        public Decimal shippingUnitPrice { get; set; }
        @AuraEnabled
        public String recordId{ get; set; }
        public String recordId { get; set; }
        @AuraEnabled
        public String Id{ get; set; }
        public String Id { get; set; }
        @AuraEnabled
        public String Name{ get; set; }
        public String Name { get; set; }
        @AuraEnabled
        public String Category3{ get; set; }
        public String Category3 { get; set; }
        @AuraEnabled
        public String Category4{ get; set; }
        public String Category4 { get; set; }
        @AuraEnabled
        public String Category5{ get; set; }
        public String Category5 { get; set; }
    }
}
    //分页Bean
    public class PaginatedAccounts {
        @AuraEnabled
        public Integer nextPageToken;
        @AuraEnabled
        public Integer pageNumber { get; set; }
        @AuraEnabled
        public Integer totalRecords { get; set; }
        @AuraEnabled
        public Integer recordStart { get; set; }
        @AuraEnabled
        public Integer recordEnd { get; set; }
    }
}
force-app/main/default/classes/LogAutoSendBatch.cls
@@ -1,15 +1,9 @@
global class LogAutoSendBatch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful {
    private String typeNFM;
    private String messageGroupNumber;
    private Datetime times;
    private Boolean isForecast;// 20220318 ljh SWAG-CC54R2 add
    private Boolean isForecast; // 20220318 ljh SWAG-CC54R2 add
    private String loginId;
     //20230203 lt 计划的作业优化  一小时两次 start
     private BatchEmailUtil.ScBean scB1;
     //20230203 lt 计划的作业优化  一小时两次 end
    /**
     * コンスタント
     */
@@ -19,14 +13,14 @@
        this.loginId = loginId;
    }
    // 2023-1-19 zyh DB202301301244 add start
    global LogAutoSendBatch(String type,String message) {
    global LogAutoSendBatch(String type, String message) {
        this.typeNFM = type;
        this.messageGroupNumber = message;
        System.debug('type++++++'+type + 'message+++++' + message);
        System.debug('type++++++' + type + 'message+++++' + message);
    }
    // 2023-1-19 zyh DB202301301244 add end
    // 20220318 ljh SWAG-CC54R2 add start
    global LogAutoSendBatch(String type,Boolean isForecast) {
    global LogAutoSendBatch(String type, Boolean isForecast) {
        this.typeNFM = type;
        this.isForecast = isForecast;
    }
@@ -43,103 +37,224 @@
     */
    public Integer max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
    global Database.QueryLocator start(Database.BatchableContext BC) {
        //20230203 lt 计划的作业优化  一小时两次 start
        scB1 = BatchEmailUtil.setSc1('LogAutoSendSchedule', 0, 23, 0, '0 30 *', null);
        if (System.Test.isRunningTest() == false) {
            for(CronTrigger ct : [SELECT Id FROM CronTrigger WHERE CronJobDetail.Name =: scB1.scName]) {
                System.abortJob(ct.Id);
            }
            system.schedule(scB1.scName, scB1.scTime, new LogAutoSendSchedule());
        }
        //20230203 lt 计划的作业优化  一小时两次 end
        String profileId = UserInfo.getProfileId();
        // 20220318 ljh SWAG-CC54R2 add start
        if(String.isNotBlank(typeNFM) && typeNFM == 'NFM010' && String.isBlank(messageGroupNumber)){
        if (String.isNotBlank(typeNFM) && typeNFM == 'NFM010' && String.isBlank(messageGroupNumber)) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                 AND (retry_cnt__c = null OR (retry_cnt__c != null AND retry_cnt__c > 0 AND retry_cnt__c < : max_cnt))
                 AND Type__c = : typeNFM ]
                );
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                    FROM BatchIF_Log__c
                    WHERE
                        RowDataFlg__c = TRUE
                        AND (retry_cnt__c = NULL
                        OR (retry_cnt__c != NULL
                        AND retry_cnt__c > 0
                        AND retry_cnt__c < :max_cnt))
                        AND Type__c = :typeNFM
                ]
            );
        }
        // gzw 603 重发判断 暂时用
        // ljh只执行自己这条日志,而且这个日志retry_cnt__c不是0
        else if (String.isNotBlank(loginId)) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                    Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                    retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                    FROM BatchIF_Log__c
                    WHERE RowDataFlg__c = true
                    AND retry_cnt__c != 0
                    AND id = : loginId ]
                );
                    WHERE RowDataFlg__c = TRUE AND retry_cnt__c != 0 AND id = :loginId
                ]
            );
        }
        // gzw 603 重发判断 暂时用
        // 2023-01-19   zyh   add start
        else if (String.isNotBlank(typeNFM) && String.isNotBlank(messageGroupNumber) && times == null) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                                       AND Type__c = : typeNFM AND MessageGroupNumber__c = : messageGroupNumber
                                                    ]
                );
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                    FROM BatchIF_Log__c
                    WHERE RowDataFlg__c = TRUE AND Type__c = :typeNFM AND MessageGroupNumber__c = :messageGroupNumber
                ]
            );
        }
        // 2023-01-19   zyh   add end
        else if (String.isNotBlank(typeNFM) && String.isNotBlank(messageGroupNumber) && times != null) {
        // 20220318 ljh SWAG-CC54R2 add end
        //20191224 HWAG-BK65E8 add start
        // if (String.isNotBlank(typeNFM) && String.isNotBlank(messageGroupNumber) && times != null) {
            // 20220318 ljh SWAG-CC54R2 add end
            //20191224 HWAG-BK65E8 add start
            // if (String.isNotBlank(typeNFM) && String.isNotBlank(messageGroupNumber) && times != null) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                                         AND Type__c != 'NFM007'  // 2023-01-18   ZYH   ADD
                                        AND Type__c = : typeNFM AND CreatedDate >= : times AND MessageGroupNumber__c >= : messageGroupNumber
                                                     order by MessageGroupNumber__c asc ]
                );
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                    FROM BatchIF_Log__c
                    WHERE
                        RowDataFlg__c = TRUE
                        AND Type__c != 'NFM007' // 2023-01-18   ZYH   ADD
                        AND Type__c = :typeNFM
                        AND CreatedDate >= :times
                        AND MessageGroupNumber__c >= :messageGroupNumber
                    ORDER BY MessageGroupNumber__c ASC
                ]
            );
            //20191224 HWAG-BK65E8 add end
        } else if (profileId.left(15).equals('00e10000000dzzG') || profileId.left(15).equals('00e10000000Y3o5')) {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                                         AND Type__c != 'NFM007'  // 2023-01-18   ZYH   ADD
                                        AND ((retry_cnt__c != null AND retry_cnt__c > 0 AND retry_cnt__c < : max_cnt)
                                            OR (NFM501Future_Count__c != null
                                                AND NFM501Future_Count__c > 0 AND NFM501Future_Count__c < : max_cnt)
                                            OR(NFM501_Web_Annex_Count__c != null
                                               AND NFM501_Web_Annex_Count__c > 0 AND NFM501_Web_Annex_Count__c < : max_cnt))]
                );
        }else {
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                    FROM BatchIF_Log__c
                    WHERE
                        RowDataFlg__c = TRUE
                        AND Type__c != 'NFM007' // 2023-01-18   ZYH   ADD
                        AND ((retry_cnt__c != NULL
                        AND retry_cnt__c > 0
                        AND retry_cnt__c < :max_cnt)
                        OR (NFM501Future_Count__c != NULL
                        AND NFM501Future_Count__c > 0
                        AND NFM501Future_Count__c < :max_cnt)
                        OR (NFM501_Web_Annex_Count__c != NULL
                        AND NFM501_Web_Annex_Count__c > 0
                        AND NFM501_Web_Annex_Count__c < :max_cnt))
                ]
            );
        } else {
            return Database.getQueryLocator(
                [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
                 Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, Type__c,
                 retry_cnt__c, NFM501Future_Count__c, NFM501_Web_Annex_Count__c
                 FROM BatchIF_Log__c
                 WHERE RowDataFlg__c = true
                                         AND Type__c != 'NFM007'  // 2023-01-18   ZYH   ADD
                                        AND ((retry_cnt__c != null AND retry_cnt__c > 0 AND retry_cnt__c < : max_cnt)
                                            OR (NFM501Future_Count__c != null
                                                AND NFM501Future_Count__c > 0 AND NFM501Future_Count__c < : max_cnt)
                                            OR(NFM501_Web_Annex_Count__c != null
                                               AND NFM501_Web_Annex_Count__c > 0 AND NFM501_Web_Annex_Count__c < : max_cnt))
                                       AND ownerId = : UserInfo.getUserId()
                                       ORDER BY CreatedDate // 2023-02-04   ZYH   ADD
                                       ]
                );
                [
                    SELECT
                        Id,
                        Name,
                        Log__c,
                        ErrorLog__c,
                        Log2__c,
                        Log3__c,
                        Log4__c,
                        Log5__c,
                        Log6__c,
                        Log7__c,
                        Log8__c,
                        Log9__c,
                        Log10__c,
                        Log11__c,
                        Log12__c,
                        MessageGroupNumber__c,
                        Type__c,
                        retry_cnt__c,
                        NFM501Future_Count__c,
                        NFM501_Web_Annex_Count__c
                    FROM BatchIF_Log__c
                    WHERE
                        RowDataFlg__c = TRUE
                        AND Type__c != 'NFM007' // 2023-01-18   ZYH   ADD
                        AND ((retry_cnt__c != NULL
                        AND retry_cnt__c > 0
                        AND retry_cnt__c < :max_cnt)
                        OR (NFM501Future_Count__c != NULL
                        AND NFM501Future_Count__c > 0
                        AND NFM501Future_Count__c < :max_cnt)
                        OR (NFM501_Web_Annex_Count__c != NULL
                        AND NFM501_Web_Annex_Count__c > 0
                        AND NFM501_Web_Annex_Count__c < :max_cnt))
                        AND ownerId = :UserInfo.getUserId()
                    ORDER BY CreatedDate // 2023-02-04   ZYH   ADD
                ]
            );
        }
    }
@@ -163,12 +278,14 @@
            if (strType_c == 'NFM001') {
                NFM001Controller.execute(rowData, null);
            }
            if (strType_c == 'NFM002') {
                NFM002WebService.execute(rowData.Id);
            }
            if (strType_c == 'NFM006') {
                NFM006WebService.execute(rowData.Id);
            }
            // 清理Apex 20230428 LHJ Start
            //if (strType_c == 'NFM002') {
            //    NFM002WebService.execute(rowData.Id);
            //}
            //if (strType_c == 'NFM006') {
            //    NFM006WebService.execute(rowData.Id);
            //}
            // 清理Apex 20230428 LHJ End
            if (strType_c == 'NFM007') {
                NFM007Controller.execute(rowData, null);
            }
@@ -225,17 +342,17 @@
            }
            // 2021/12/1 fxk add Star
            if (strType_c == 'NFM115') {
                NFM115Controller.execute(rowData,null);
                NFM115Controller.execute(rowData, null);
            }
            if (strType_c == 'NFM114') {
                NFM114Rest.main(rowData.Id);
            }
            // 2021/12/1 fxk add End
            // // 电子签收单发送SAP接口 thh 20220427 start
            // // 电子签收单发送SAP接口 thh 20220427 start
            if (strType_c == 'NFM116') {
                NFM116Controller.execute(rowData,null);
                NFM116Controller.execute(rowData, null);
            }
            // // 电子签收单发送SAP接口 thh 20220427 end
            // // 电子签收单发送SAP接口 thh 20220427 end
            // XLIU-CEW9PD 零件预计齐备日期 -SFDC增加 LY 20220610 start
            if (strType_c == 'NFM117') {
                NFM117Rest.main(rowData.Id);
@@ -330,17 +447,20 @@
            // if (strType_c == 'NFM624') {//智慧医疗pk
            //     NFM624Rest.main(rowData.Id);
            // }
            if (strType_c == 'NFM624Rest2') {//智慧医疗pk
            if (strType_c == 'NFM624Rest2') {
                //智慧医疗pk
                NFMUtil.againSendToAWS624(rowData.Id);
            }
            //zhj 新方案改造 2023-01-06 end
            if (strType_c == 'NFM622') {
                NFM622Controller.execute(rowData, null);
            }
            if (strType_c == 'NFM112') {//先款后修pk
            if (strType_c == 'NFM112') {
                //先款后修pk
                NFM112Controller.ManualExecute(rowData.id);
            }
            if (strType_c == 'NFM113') {//先款后修pk
            if (strType_c == 'NFM113') {
                //先款后修pk
                NFM113Rest.main(rowData.id);
            }
            if (strType_c == 'NFM701') {
@@ -534,13 +654,11 @@
    }
    global void finish(Database.BatchableContext BC) {
        BatchEmailUtil.removeOtherSc('LogAutoSendSchedule', scB1.scName);  //20230203 lt 计划的作业优化
        // 今回はやることないです
        // 20220318 ljh SWAG-CC54R2 add start
        if(String.isNotBlank(typeNFM) && typeNFM == 'NFM010' && isForecast){
        if (String.isNotBlank(typeNFM) && typeNFM == 'NFM010' && isForecast) {
            Id execBTId = Database.executeBatch(new BeforeSSOpportunityBatch(), 100);
        }
        // 20220318 ljh SWAG-CC54R2 add end
    }
}
}
force-app/main/default/classes/OCSMHandler.cls
@@ -1,15 +1,15 @@
public with sharing class OCSMHandler extends Oly_TriggerHandler {
    //LY          2021/11/12                  start
    //平台窗口1、2、3任何一个有变更都会触发客户人员接口,向共通平台发送
    public static void OCSMToUser(List<OCM_Management_Province__c> newList, Map<Id, OCM_Management_Province__c> newMap, List<OCM_Management_Province__c> oldList, Map<Id, OCM_Management_Province__c> oldMap){
    public static void OCSMToUser(
        List<OCM_Management_Province__c> newList,
        Map<Id, OCM_Management_Province__c> newMap,
        List<OCM_Management_Province__c> oldList,
        Map<Id, OCM_Management_Province__c> oldMap
    ) {
        OCM_Management_Province__c old = null;
        List<String> noList = new List<String>();
        //Add By Li Jun 20230420 Start OCSM省的【营业窗口】人员发生变动时,需要更新现有的未完成的签收单的【营业助理】值
        Set<String> changedWindowProvince = new set<String>();
        //Add By Li Jun 20230420 End
        for (OCM_Management_Province__c local : newList) {
            if (Trigger.isInsert) {
                if (String.isNotBlank(local.OnlinePlatformWindow1__c)) {
                    noList.add(local.OnlinePlatformWindow1__c);
@@ -48,23 +48,11 @@
                        noList.add(old.OnlinePlatformWindow3__c);
                    }
                }
                //Add By Li Jun 20230420 Start
                if (local.Window1__c != null &&  local.Window1__c != old.Window1__c) {
                    changedWindowProvince.add(local.Name);
                }
                //Add By Li Jun 20230420 End
            }
        }
        if (noList.size() > 0) {
            NFM621Controller.callout('',  noList);
            NFM621Controller.callout('', noList);
        }
        //Add By Li Jun 20230420 Start
        if(changedWindowProvince.size() > 0){
            SyncProvinceWIndowToSignForm.syncProvinceWIndow(changedWindowProvince);
        }
        //Add By Li Jun 20230420 End
    }
}
//LY          2021/11/12                  end
//LY          2021/11/12                  end
force-app/main/default/classes/updateESignBatch.cls
@@ -1,4 +1,4 @@
global class updateESignBatch implements Database.Batchable < sObject > , Database.Stateful {
global class updateESignBatch implements Database.Batchable<sObject>, Database.Stateful {
    //电子签收单-签收单录入表更新签收单  精琢技术 wql 2020-09-25 start
    /*
    ①正常执行 Database.executeBatch(new updateESignBatch(), 20);
@@ -29,18 +29,17 @@
    //存放需要更新的签收单id
    private String id;
    //存放需要更新的一些签收单
    private List < String > ids;
    private List<String> ids;
    //存放已经最终状态的flag
    private Boolean flag;
    //用于执行batch同时记录日志信息
    private BatchIF_Log__c iflog;
    global List < String > emailMessages = new List < String > ();
    global List<String> emailMessages = new List<String>();
    global Integer totalCount = 0; // 总件数
    global Integer failedCount = 0; //失败件数
    global Boolean ManualExecution_Identification = false;
    //默认跑所有签收单
    global updateESignBatch() {
        iflog = new BatchIF_Log__c();
        iflog.Type__c = 'ESignBatch';
        iflog.Is_Error__c = 0;
@@ -75,7 +74,7 @@
        // insert iflog;
    }
    //批量更新签收单
    global updateESignBatch(List < String > ids) {
    global updateESignBatch(List<String> ids) {
        //手动标识置成true
        this.ManualExecution_Identification = true;
        this.ids = ids;
@@ -88,7 +87,6 @@
    }
    //更新某一条的签收单
    global updateESignBatch(String id) {
        //手动标识置成true
        this.ManualExecution_Identification = true;
        system.debug('手动传参1:' + ManualExecution_Identification);
@@ -114,7 +112,7 @@
        // insert iflog;
    }
    //批量更新已处理的签收单
    global updateESignBatch(List < String > ids, boolean flag) {
    global updateESignBatch(List<String> ids, boolean flag) {
        //手动标识置成true
        this.ManualExecution_Identification = true;
        this.ids = ids;
@@ -138,9 +136,11 @@
            // 如果哟同名的Batch计划删除已存在的计划重新设置
            if (haveError) {
                haveError = false;
                for (CronTrigger ct : [SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
                                       FROM CronTrigger
                                       WHERE CronJobDetail.Name = :scB.scName]) {
                for (CronTrigger ct : [
                    SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
                    FROM CronTrigger
                    WHERE CronJobDetail.Name = :scB.scName
                ]) {
                    System.abortJob(ct.Id);
                }
                try {
@@ -202,7 +202,7 @@
            if (spafter != null && String.isNotBlank(spafter)) {
                b.scName = baseName + '005';
                b.scTime = spafter + ' ' + day + ' ' + month + ' ? ' + year;
                // system.schedule(sJobame,spafter + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
                return b;
            } else {
@@ -242,164 +242,139 @@
            b.scName = baseName + '001';
            b.scTime = '0 ' + minMin + ' ' + (hour + 1) + ' ' + day + ' ' + month + ' ? ' + year;
            // system.schedule(sJobame,'0 ' + minMin + ' ' + (hour + 1) +' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
        }
        return b;
    }
    public static void removeOtherSc(String likeName, String needName) {
        String likeStr = likeName + '00%';
        for (CronTrigger ct : [SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
                               FROM CronTrigger
                               WHERE CronJobDetail.Name Like :likeStr
                               AND CronJobDetail.Name != :needName]) {
        for (CronTrigger ct : [
            SELECT Id, CronJobDetailId, CronExpression, CronJobDetail.Name
            FROM CronTrigger
            WHERE CronJobDetail.Name LIKE :likeStr AND CronJobDetail.Name != :needName
        ]) {
            System.abortJob(ct.Id);
        }
    }
    global void execute(Database.BatchableContext BC, list < eSignForm__c > eSignList) {
    global void execute(Database.BatchableContext BC, list<eSignForm__c> eSignList) {
        //用作录入表的检索条件
        List < String > esFormidList = new List < String > ();
        List<String> esFormidList = new List<String>();
        //存放签收单录入表明细
        List < eSignFormLineItemEntry__c > eSignFormLineItemEntryList = new List < eSignFormLineItemEntry__c > ();
        List<eSignFormLineItemEntry__c> eSignFormLineItemEntryList = new List<eSignFormLineItemEntry__c>();
        //用作签收单明细的检索条件
        List < String > eSignFormLineIdList = new List < String > ();
        List<String> eSignFormLineIdList = new List<String>();
        //更新的签收单明细
        List < eSignFormLineItem__c > eSignFormLuRUList = new List < eSignFormLineItem__c > ();
        List<eSignFormLineItem__c> eSignFormLuRUList = new List<eSignFormLineItem__c>();
        //存放最后更新的 录入表id
        List < Id > fileIdList = new List < Id > ();
        List<Id> fileIdList = new List<Id>();
        //存放最新的 签收单id,签收单录入id
        Map < Id, Id > eSignIdMap = new Map < Id, Id > ();
        Map<Id, Id> eSignIdMap = new Map<Id, Id>();
        //存放最新的 签收单id,签收单录入id 用于最后一条签收单录入表不删除
        Map < Id, Id > eSignFormLastIdMap = new Map < Id, Id > ();
        Map<Id, Id> eSignFormLastIdMap = new Map<Id, Id>();
        //存放最新的 签收单id,签收单录入id 用于文件更新
        Map < Id, Id > eSignFlieIdMap = new Map < Id, Id > ();
        Map<Id, Id> eSignFlieIdMap = new Map<Id, Id>();
        //存放录入表id,录入表
        Map < String, eSignFormEntry__c > lasteSignFormEntryMap = new Map < String, eSignFormEntry__c > ();
        Map<String, eSignFormEntry__c> lasteSignFormEntryMap = new Map<String, eSignFormEntry__c>();
        //存放最新的 签收单明细id,签收单明细录入id
        Map < Id, Id > eSignFormLineItemEntryIdMap = new Map < Id, Id > ();
        Map<Id, Id> eSignFormLineItemEntryIdMap = new Map<Id, Id>();
        //签收单录入表明细id,签收单录入表明细
        Map < String, eSignFormLineItemEntry__c > lasteSignFormLineItemEntryMap = new Map < String, eSignFormLineItemEntry__c > ();
        Map<String, eSignFormLineItemEntry__c> lasteSignFormLineItemEntryMap = new Map<String, eSignFormLineItemEntry__c>();
        //存放 签收单id,文件数量
        Map < String, Integer > fileMap = new Map < String, Integer > ();
        Map<String, Integer> fileMap = new Map<String, Integer>();
        //驳回后删除文件 后  排序问题  精琢技术 wql  2020/12/24 start
        // List<Attachment> esignAttachAgencyList = new List<Attachment>();
        // List<Attachment> esignAttachHPList = new List<Attachment>();
        List<FileAddress__c> esignAttachAgencyList = new List<FileAddress__c>();        //zhj Attachment To AWS 2023-02-06
        List<FileAddress__c> esignAttachHPList = new List<FileAddress__c>();            //zhj Attachment To AWS 2023-02-06
        List<Attachment> esignAttachAgencyList = new List<Attachment>();
        List<Attachment> esignAttachHPList = new List<Attachment>();
        Map<String, Integer> fileAgencyMap = new Map<String, Integer>();
        Map<String, Integer> fileHPMap = new Map<String, Integer>();
        //驳回后删除文件 后  排序问题  精琢技术 wql  2020/12/24 end
        //存放ocsm管理省
        List < String > provinceList = new List < String > ();
        List<String> provinceList = new List<String>();
        //存放15位签收单id,ocsm管理省
        Map < Id, String > provinceMap = new Map < Id, String > ();
        Map<Id, String> provinceMap = new Map<Id, String>();
        //存放用于更新的签收单数组
        List < eSignForm__c > eSignFormList = new List < eSignForm__c > ();
        List<eSignForm__c> eSignFormList = new List<eSignForm__c>();
        //存放签收单录入表id,name
        Map < Id, String > eSignNameMap = new Map < Id, String > ();
        Map<Id, String> eSignNameMap = new Map<Id, String>();
        //存放签收单录入表id,type
        Map < Id, String > eSignTypeMap = new Map < Id, String > ();
        Map<Id, String> eSignTypeMap = new Map<Id, String>();
        //删除中间表数据用
        Map < String, eSignFormEntry__c > eSignStringMap = new Map < String, eSignFormEntry__c > ();
        Map<String, eSignFormEntry__c> eSignStringMap = new Map<String, eSignFormEntry__c>();
        //存放所有签收单录入表id
        List < String > luruIsSubmitList = new List < String > ();
        List<String> luruIsSubmitList = new List<String>();
        //存放所有签收单录入表id
        List < String > luruIsLastSubmitList = new List < String > ();
        // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
        List<String> luruIsLastSubmitList = new List<String>();
        //判断是否有未处理的录入表
        // Map < Id, eSignFormEntry__c > unprocessedESignEneryMap = new Map < Id, eSignFormEntry__c > ();
        Map < Id, List<eSignFormEntry__c> > unprocessedESignEneryMap = new Map < Id, List<eSignFormEntry__c> > ();
        List<eSignFormEntry__c> unprocessedEntries = new List<eSignFormEntry__c>();
        // Map <Id, eSignFormEntry__c> unprocessedEntries = new Map<Id, eSignFormEntry__c>();
        // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
        Map<Id, eSignFormEntry__c> unprocessedESignEneryMap = new Map<Id, eSignFormEntry__c>();
        //用于判断删除驳回的附件的筛选条件
        Map < Id, eSignForm__c > rejectESignEneryMap = new Map < Id, eSignForm__c > ();
        Map<Id, eSignForm__c> rejectESignEneryMap = new Map<Id, eSignForm__c>();
        //驳回后 删除之前上传的文件id
        //List<Attachment> deleteLastFileList = new List<Attachment>();
        List<FileAddress__c> deleteLastFileList = new List<FileAddress__c>();       //zhj Attachment To AWS 2023-02-06
        List<Attachment> deleteLastFileList = new List<Attachment>();
        //存放未更新前的经销商审批状态
        Map < String, String > oldESignAgencyStatusMap = new Map < String, String > ();
        Map<String, String> oldESignAgencyStatusMap = new Map<String, String>();
        //存放未更新前的医院审批状态
        Map < String, String > oldESignHPStatusMap = new Map < String, String > ();
        Map<String, String> oldESignHPStatusMap = new Map<String, String>();
        try {
            //循环存放签收单id 用作检索签收单录入表的条件
            system.debug('eSignList:' + eSignList);
            if (eSignList.size() > 0) {
                for (eSignForm__c esForm : eSignList) {
                    //存放签收单id,ocsm管理省 如果询价是集采 则取ocsm管理省为集采课的担当
                    if(esForm.Statu_Achievements__r.Opportunity__r.Group_purchase_PCL__c){
                    if (esForm.Statu_Achievements__r.Opportunity__r.Group_purchase_PCL__c) {
                        provinceMap.put(esForm.Id, '集采课');
                        //检索条件
                        provinceList.add('集采课');
                    }else{
                    } else {
                        provinceMap.put(esForm.Id, esForm.OCM_man_province_cus__c);
                        //检索条件
                        provinceList.add(esForm.OCM_man_province_cus__c);
                    }
                    esFormidList.add(esForm.Id);
                    //有经销商驳回或者医院驳回时删除之前附件
                    if (esForm.agencyRejectDate__c != null || esForm.HPRejectDate__c != null) {
                        rejectESignEneryMap.put(esForm.Id, esForm);
                    }
                }
            }
            system.debug('rejectESignEneryMap:' + rejectESignEneryMap);
            //如果map不为空 则作为筛选条件
            if (rejectESignEneryMap.size()>0) {
                // List<Attachment> deleteFileList = [SELECT parentId, createdDate, Name,Description
                //                                    FROM Attachment
                //                                    WHERE parentId IN: rejectESignEneryMap.keySet() order by createdDate];
                List<FileAddress__c> deleteFileList = [SELECT ParentRecordId__c, createdDate, FileName__c
                                                        FROM FileAddress__c
                                                        WHERE ParentRecordId__c IN: rejectESignEneryMap.keySet() order by createdDate];  //zhj Attachment To AWS 2023-02-06
            if (rejectESignEneryMap.size() > 0) {
                List<Attachment> deleteFileList = [
                    SELECT parentId, createdDate, Name, Description
                    FROM Attachment
                    WHERE parentId IN :rejectESignEneryMap.keySet()
                    ORDER BY createdDate
                ];
                system.debug('deleteFileList:' + deleteFileList);
                if (deleteFileList.size() > 0) {
                    for (eSignForm__c esFile : rejectESignEneryMap.values()) {
                        //for (Attachment att : deleteFileList) {
                        for (FileAddress__c att : deleteFileList) {             //zhj Attachment To AWS 2023-02-06
                        for (Attachment att : deleteFileList) {
                            if (esFile.agencyRejectDate__c != null || esFile.HPRejectDate__c != null) {
                                if (att.ParentRecordId__c == esFile.Id ) {
                                if (att.parentId == esFile.Id) {
                                    //①经销商驳回后需要删除的附件
                                    if (esFile.agencyRejectDate__c != null) {
                                        //zhj Attachment To AWS 2023-02-06
                                        // if (att.Name.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) {
                                        //     deleteLastFileList.add(att);
                                        // }
                                        if (att.FileName__c.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) {
                                        if (att.Name.substring(0, 1) == 'A' && att.createdDate < esFile.agencyRejectDate__c) {
                                            deleteLastFileList.add(att);
                                        }
                                    }
                                    //②医院驳回后需要删除的附件
                                    if (esFile.HPRejectDate__c != null) {
                                        //zhj Attachment To AWS 2023-02-06
                                        // if (att.Name.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) {
                                        //     deleteLastFileList.add(att);
                                        // }
                                        if (att.FileName__c.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) {
                                        if (att.Name.substring(0, 1) == 'H' && att.createdDate < esFile.HPRejectDate__c) {
                                            deleteLastFileList.add(att);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            system.debug('驳回后删除的文件:' + deleteLastFileList);
@@ -409,12 +384,47 @@
            }
            //检索所有录入表
            List < eSignFormEntry__c > eSignFormEntryList = [select id, Name, entryType__c, eSignForm__c, eSignForm__r.OCM_man_province_cus__c, salesManageConfirmDate__c, salesHPManageConfirmDate__c, agencyScanDayBack__c, agencySignUpDateBack__c, agencyConfirmDateBack__c, HPScanDayBack__c, HPSignUpDateBack__c, HPConfirmDateBack__c,
                                       eSignForm__r.Name, IsSubmit__c, IsHPSubmit__c, IsAgencyConfirmSubmit__c, agencyAutoSignUpStatus__c, HPSignUpStatus__c, Sales_Root_Formula__c, Sales_assistant_ID__c, IsHandled__c, IsHPHandled__c, createdDate, AgencyWorkflowEmailBack__c, HPWorkflowEmailBack__c, AgencyWorkflowEmail__c, HPWorkflowEmail__c, eSignForm__r.Id, agencyDNSignUpStatus__c, HPDNSignUpStatus__c, agencyReject__c, HPReject__c, IsAgencyScan__c, IsHPScan__c
                                       from eSignFormEntry__c
                                       where eSignForm__c IN: esFormidList
                                       order by eSignForm__c, createdDate asc
                                                            ];
            List<eSignFormEntry__c> eSignFormEntryList = [
                SELECT
                    id,
                    Name,
                    entryType__c,
                    eSignForm__c,
                    eSignForm__r.OCM_man_province_cus__c,
                    salesManageConfirmDate__c,
                    salesHPManageConfirmDate__c,
                    agencyScanDayBack__c,
                    agencySignUpDateBack__c,
                    agencyConfirmDateBack__c,
                    HPScanDayBack__c,
                    HPSignUpDateBack__c,
                    HPConfirmDateBack__c,
                    eSignForm__r.Name,
                    IsSubmit__c,
                    IsHPSubmit__c,
                    IsAgencyConfirmSubmit__c,
                    agencyAutoSignUpStatus__c,
                    HPSignUpStatus__c,
                    Sales_Root_Formula__c,
                    Sales_assistant_ID__c,
                    IsHandled__c,
                    IsHPHandled__c,
                    createdDate,
                    AgencyWorkflowEmailBack__c,
                    HPWorkflowEmailBack__c,
                    AgencyWorkflowEmail__c,
                    HPWorkflowEmail__c,
                    eSignForm__r.Id,
                    agencyDNSignUpStatus__c,
                    HPDNSignUpStatus__c,
                    agencyReject__c,
                    HPReject__c,
                    IsAgencyScan__c,
                    IsHPScan__c
                FROM eSignFormEntry__c
                WHERE eSignForm__c IN :esFormidList
                ORDER BY eSignForm__c, createdDate ASC
            ];
            if (eSignFormEntryList.size() > 0) {
                for (Id eid : esFormidList) {
@@ -424,24 +434,16 @@
                        eSignStringMap.put(eSignFormEntryWhole.Id, eSignFormEntryWhole);
                        //②所有的 用于更新文件(包含已处理未处理的数据 )
                        fileIdList.add(eSignFormEntryWhole.Id);
                        // 这里是什么鬼?都不判断一下签收单id的?
                        // if (eSignFormEntryWhole.IsHandled__c == false) {
                        if (eSignFormEntryWhole.IsHandled__c == false && eSignFormEntryWhole.eSignForm__r.Id  == eid) {
                        if (eSignFormEntryWhole.IsHandled__c == false) {
                            //未处理的
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
                            // unprocessedESignEneryMap.put(eid, eSignFormEntryWhole);
                            List<eSignFormEntry__c> entries = unprocessedESignEneryMap.size() > 0 && unprocessedESignEneryMap.keySet().contains(eid) ? unprocessedESignEneryMap.get(eid) : new List<eSignFormEntry__c>();
                            entries.add(eSignFormEntryWhole);
                            unprocessedESignEneryMap.put(eid, entries);
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 end
                            unprocessedESignEneryMap.put(eid, eSignFormEntryWhole);
                        }
                        if (eSignFormEntryWhole.eSignForm__r.Id  == eid) {
                        if (eSignFormEntryWhole.eSignForm__r.Id == eid) {
                            //存放 签收单id,录入表id 文件用
                            eSignFlieIdMap.put(eSignFormEntryWhole.Id, eid);
                            //存放签收单录入表,id,name 文件用
                            eSignNameMap.put(eid, eSignFormEntryWhole.eSignForm__r.Name);
                        }
                        //存放录入表id,记录类型 id,type 文件用
                        eSignTypeMap.put(eSignFormEntryWhole.Id, eSignFormEntryWhole.entryType__c);
@@ -453,10 +455,8 @@
                for (Id esFormid : esFormidList) {
                    //内层是签收单录入表
                    for (eSignFormEntry__c eSignFormEntry : eSignFormEntryList) {
                        //①取最新的 录入表 + 未处理的
                        if (esFormid.equals(eSignFormEntry.eSignForm__c)) {
                            if (!eSignFormEntry.IsHandled__c) {
                                //存放 签收单id,录入表id
                                eSignIdMap.put(esFormid, eSignFormEntry.Id);
@@ -465,9 +465,7 @@
                                // break;
                            }
                            eSignFormLastIdMap.put(esFormid, eSignFormEntry.Id);
                        }
                    }
                }
                //最后更新的录入表id
@@ -482,42 +480,26 @@
                //重新对附件排序  规则变为根据签收单现有附件序号进行排序 精琢技术 wql start
                //暂时存放一下签收单名称
                Map<string, string> tempMap = new Map<string, string>();
                //zhj Attachment To AWS 2023-02-06
                // List<Attachment> tempAttList = [SELECT parentId, createdDate, Name,Description
                //                                 FROM Attachment
                //                                 WHERE parentId IN: esFormidList order by createdDate];
                List<FileAddress__c> tempAttList = [SELECT ParentRecordId__c, createdDate, FileName__c
                                                FROM FileAddress__c
                                                WHERE ParentRecordId__c IN: esFormidList order by createdDate];
                List<Attachment> tempAttList = [
                    SELECT parentId, createdDate, Name, Description
                    FROM Attachment
                    WHERE parentId IN :esFormidList
                    ORDER BY createdDate
                ];
                if (tempAttList.size() > 0) {
                    //外层循环签收单
                    for (String es : esFormidList) {
                        //zhj Attachment To AWS 2023-02-06
                        //内层循环附件
                        // for (Attachment att : tempAttList) {
                        //     //如果id相等
                        //     if (es.equals(att.parentId)) {
                        //         //根据名称拆分 存入不同list
                        //         String name = att.Name;
                        //         if (name.substring(0, 1).equals('A')) {
                        //             esignAttachAgencyList.add(att);
                        //         } else if (name.substring(0, 1).equals('H')) {
                        //             esignAttachHPList.add(att);
                        //         }
                        //     }
                        // }
                        for (FileAddress__c att : tempAttList) {
                        for (Attachment att : tempAttList) {
                            //如果id相等
                            if (es.equals(att.ParentRecordId__c)) {
                            if (es.equals(att.parentId)) {
                                //根据名称拆分 存入不同list
                                String name = att.FileName__c;
                                String name = att.Name;
                                if (name.substring(0, 1).equals('A')) {
                                    esignAttachAgencyList.add(att);
                                } else if (name.substring(0, 1).equals('H')) {
                                    esignAttachHPList.add(att);
                                }
                            }
                        }
                        //分别存入到经销商or医院的附件map 用于后期命名
@@ -530,7 +512,6 @@
                        //清空list 供下一个签收单使用
                        esignAttachAgencyList.clear();
                        esignAttachHPList.clear();
                    }
                }
                system.debug('fileAgencyMap:' + fileAgencyMap);
@@ -538,10 +519,21 @@
                //重新对附件排序  规则变为根据签收单现有附件序号进行排序 精琢技术 wql end
                //根据所有的签收单录入表id检索所有的签收单明细录入
                List < eSignFormLineItemEntry__c > eSignFormLineItemEntryLists = [select id, eSignFormEntry__r.entryType__c, eSignFormEntry__r.IsHandled__c, eSignFormLineItem__c, eSignFormEntry__c,
                                                   agencyConfirmResult__c, HPConfirmResult__c, HPGoodStatus__c, agencyGoodStatus__c
                                                   from eSignFormLineItemEntry__c where eSignFormEntry__c in : luruIsSubmitList  and eSignFormEntry__r.IsHandled__c = false order by createdDate asc
                                                                                 ];
                List<eSignFormLineItemEntry__c> eSignFormLineItemEntryLists = [
                    SELECT
                        id,
                        eSignFormEntry__r.entryType__c,
                        eSignFormEntry__r.IsHandled__c,
                        eSignFormLineItem__c,
                        eSignFormEntry__c,
                        agencyConfirmResult__c,
                        HPConfirmResult__c,
                        HPGoodStatus__c,
                        agencyGoodStatus__c
                    FROM eSignFormLineItemEntry__c
                    WHERE eSignFormEntry__c IN :luruIsSubmitList AND eSignFormEntry__r.IsHandled__c = FALSE
                    ORDER BY createdDate ASC
                ];
                if (eSignFormLineItemEntryLists.size() > 0) {
                    for (eSignFormLineItemEntry__c eSignFormLineItemEntry : eSignFormLineItemEntryLists) {
                        eSignFormLineIdList.add(eSignFormLineItemEntry.eSignFormLineItem__c);
@@ -550,7 +542,11 @@
                system.debug('eSignFormLineIdList:' + eSignFormLineIdList);
                if (eSignFormLineIdList.size() > 0) {
                    //根据签收单明细录入表 去检索签收单明细
                    List < eSignFormLineItem__c > eSignFormLineItemList = [select id, agencyGoodStatus__c, HPGoodStatus__c from eSignFormLineItem__c where id IN: eSignFormLineIdList];
                    List<eSignFormLineItem__c> eSignFormLineItemList = [
                        SELECT id, agencyGoodStatus__c, HPGoodStatus__c
                        FROM eSignFormLineItem__c
                        WHERE id IN :eSignFormLineIdList
                    ];
                    if (eSignFormLineItemList.size() > 0) {
                        //外层签收单明细
                        for (eSignFormLineItem__c eSignFormLineItem : eSignFormLineItemList) {
@@ -570,7 +566,6 @@
                if (eSignFormLineIdList.size() > 0) {
                    //循环 更新签收单
                    for (Id esefId : eSignFormLineIdList) {
                        if (lasteSignFormLineItemEntryMap.containsKey(esefId)) {
                            eSignFormLineItemEntry__c luru = lasteSignFormLineItemEntryMap.get(esefId);
                            //new 一个签收单明细对象
@@ -591,8 +586,6 @@
                                eSignFormLuRuList.add(eSignLuRu);
                            }
                        }
                    }
                }
                System.debug('更新的签收单明细list:' + eSignFormLuRUList);
@@ -608,195 +601,167 @@
                        boolean IsHPSubmit = false;
                        //销售渠道
                        String Sales_Root_Formula;
                        //录入类型
                        String type; // 这东西没有用
                        //录入类型
                        String type;
                        System.debug('lasteSignFormEntryMap:' + lasteSignFormEntryMap);
                        if (lasteSignFormEntryMap.containsKey(eSignFormid)) {
                            eSignForm.id = eSignFormid;
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 start
                            //签收单id
                            // eSignFormEntry__c eSignFormEntry = lasteSignFormEntryMap.get(eSignFormid);
                            for (eSignFormEntry__c eSignFormEntry : unprocessedESignEneryMap.get(eSignFormid)) {
                                // 根据录入类型去更新对应的部分数据
                                // entryType__c包含经销商
                                if (String.isNotBlank(eSignFormEntry.entryType__c) && eSignFormEntry.entryType__c.contains('经销商')) {
                                    //如果经销商确认日为空的话 进去判断更新经销商审批状态
                                    if (eSignFormEntry.agencyDNSignUpStatus__c != '签收已完成') {
                                        if (eSignFormEntry.agencyConfirmDateBack__c == null) {
                                            if (eSignFormEntry.IsSubmit__c == true) {
                                                eSignForm.agencyAutoSignUpStatus__c = '申请中';
                                                eSignForm.agencyReject__c = false;
                                            } else {
                                                if (eSignFormEntry.agencyScanDayBack__c != null && eSignFormEntry.IsAgencyScan__c) {
                                                    // 调整草案中的赋值逻辑,多端操作的情况下有可能先申请后草案
                                                    // eSignForm.agencyAutoSignUpStatus__c = '草案中';
                                                    eSignForm.agencyAutoSignUpStatus__c = String.isBlank(eSignForm.agencyAutoSignUpStatus__c) ? '草案中' : eSignForm.agencyAutoSignUpStatus__c;
                                                    eSignForm.agencyReject__c = false;
                                                }
                                            }
                                        }
                                        //未更新前的经销商审批状态 用于文件累计汇总
                                        if(eSignFormEntry.agencyAutoSignUpStatus__c!=null &&eSignFormEntry.agencyAutoSignUpStatus__c!=''){
                                            oldESignAgencyStatusMap.put('A' + eSignForm.id, eSignFormEntry.agencyAutoSignUpStatus__c);
                                        }else{
                                            oldESignAgencyStatusMap.put('A' + eSignForm.id, '无');
                                        }
                                    }
                                    //如果没变化则不更新
                                    if (eSignFormEntry.AgencyWorkflowEmailBack__c != eSignFormEntry.AgencyWorkflowEmail__c) {
                                        //经销商邮件
                                        eSignForm.AgencyWorkflowEmail__c = eSignFormEntry.AgencyWorkflowEmailBack__c;
                                    }
                                    // 日期更新
                                    if (eSignFormEntry.agencyDNSignUpStatus__c != '签收已完成') {
                                        //经销商扫描日
                                        if (eSignFormEntry.agencyScanDayBack__c != null) {
                                            eSignForm.agencyScanDay__c = eSignFormEntry.agencyScanDayBack__c;
                                        }
                                        //经销商签收日
                                        if (eSignFormEntry.agencySignUpDateBack__c != null) {
                                            eSignForm.agencySignUpDate__c = eSignFormEntry.agencySignUpDateBack__c;
                                        }
                                        //经销商确认日
                                        if (eSignFormEntry.agencyConfirmDateBack__c != null) {
                                            eSignForm.agencyConfirmDate__c = eSignFormEntry.agencyConfirmDateBack__c;
                            eSignFormEntry__c eSignFormEntry = lasteSignFormEntryMap.get(eSignFormid);
                            //如果经销商确认日为空的话 进去判断更新经销商审批状态
                            if (eSignFormEntry.agencyDNSignUpStatus__c != '签收已完成') {
                                if (eSignFormEntry.agencyConfirmDateBack__c == null) {
                                    if (eSignFormEntry.IsSubmit__c == true) {
                                        eSignForm.agencyAutoSignUpStatus__c = '申请中';
                                        eSignForm.agencyReject__c = false;
                                    } else {
                                        if (eSignFormEntry.agencyScanDayBack__c != null && eSignFormEntry.IsAgencyScan__c) {
                                            eSignForm.agencyAutoSignUpStatus__c = '草案中';
                                            eSignForm.agencyReject__c = false;
                                        }
                                    }
                                }
                                // entryType__c包含医院
                                if (String.isNotBlank(eSignFormEntry.entryType__c) && eSignFormEntry.entryType__c.contains('医院')) {
                                    if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') {
                                        //如果医院确认日为空的话 进去判断更新医院审批状态
                                        if (eSignFormEntry.salesHPManageConfirmDate__c == null) {
                                            if (eSignFormEntry.IsHPSubmit__c == true) {
                                                eSignForm.HPSignUpStatus__c = '申请中';
                                                eSignForm.HPReject__c = false;
                                            } else {
                                                if (eSignFormEntry.HPScanDayBack__c != null && eSignFormEntry.IsHPScan__c) {
                                                    // 调整草案中的赋值逻辑,多端操作的情况下有可能先申请后草案
                                                    // eSignForm.HPSignUpStatus__c = '草案中';
                                                    eSignForm.HPSignUpStatus__c = String.isBlank(eSignForm.HPSignUpStatus__c) ? '草案中' : eSignForm.HPSignUpStatus__c;
                                                    eSignForm.HPReject__c = false;
                                                }
                                            }
                                        }
                                        //未更新前的医院审批状态 用于文件累计汇总
                                        if(eSignFormEntry.HPSignUpStatus__c!=null &&eSignFormEntry.HPSignUpStatus__c!=''){
                                            oldESignHPStatusMap.put('H' + eSignForm.id, eSignFormEntry.HPSignUpStatus__c);
                                        }else{
                                            oldESignHPStatusMap.put('H' + eSignForm.id, '无');
                                        }
                                    }
                                    //如果没变化则不更新
                                    if (eSignFormEntry.HPWorkflowEmailBack__c != eSignFormEntry.HPWorkflowEmail__c) {
                                        //医院邮件
                                        eSignForm.HPWorkflowEmail__c = eSignFormEntry.HPWorkflowEmailBack__c;
                                    }
                                    // 日期更新
                                    if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') {
                                        //医院扫描日
                                        if (eSignFormEntry.HPScanDayBack__c != null) {
                                            eSignForm.HPScanDay__c = eSignFormEntry.HPScanDayBack__c;
                                        }
                                        //医院签收日
                                        if (eSignFormEntry.HPSignUpDateBack__c != null) {
                                            eSignForm.HPSignUpDate__c = eSignFormEntry.HPSignUpDateBack__c;
                                        }
                                        //医院确认日
                                        if (eSignFormEntry.HPConfirmDateBack__c != null) {
                                            eSignForm.HPConfirmDate__c = eSignFormEntry.HPConfirmDateBack__c;
                                        }
                                    }
                                //未更新前的经销商审批状态 用于文件累计汇总
                                if (eSignFormEntry.agencyAutoSignUpStatus__c != null && eSignFormEntry.agencyAutoSignUpStatus__c != '') {
                                    oldESignAgencyStatusMap.put('A' + eSignForm.id, eSignFormEntry.agencyAutoSignUpStatus__c);
                                } else {
                                    oldESignAgencyStatusMap.put('A' + eSignForm.id, '无');
                                }
                                //给营业助理赋值
                                //eSignForm.Sales_assistant_name_text__c = eSignFormEntry.Sales_assistant_ID__c;// Commented By Li Jun 20230420
                                //存一个id
                                idlast = eSignFormEntry.Id;
                                //签收单name用作文件命名
                                name = eSignFormEntry.eSignForm__r.Name;
                                //是否经销商提交
                                IsSubmit = eSignFormEntry.IsSubmit__c;
                                //是否医院提交
                                IsHPSubmit = eSignFormEntry.IsHPSubmit__c;
                                //最后录入表
                                eSignForm.finalUpadteFrom__c = eSignFormEntry.Id;
                                //销售渠道 区分直销还是分销
                                Sales_Root_Formula = eSignFormEntry.Sales_Root_Formula__c;
                                //录入类型
                                type = eSignFormEntry.entryType__c; // 没有用
                                // 所有没有没有处理的entry都要标记为处理
                                eSignFormEntry.IsHandled__c = true;
                                unprocessedEntries.add(eSignFormEntry);
                                // unprocessedEntries.put(eSignFormEntry.Id, eSignFormEntry);
                            }
                            // 2023-03-16 ssm 优化逻辑,避免同时多设备做系统更新以及医院和经销商在同一批次(15分钟内)上传数据 end
                            if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') {
                                //如果医院确认日为空的话 进去判断更新医院审批状态
                                if (eSignFormEntry.salesHPManageConfirmDate__c == null) {
                                    if (eSignFormEntry.IsHPSubmit__c == true) {
                                        eSignForm.HPSignUpStatus__c = '申请中';
                                        eSignForm.HPReject__c = false;
                                    } else {
                                        if (eSignFormEntry.HPScanDayBack__c != null && eSignFormEntry.IsHPScan__c) {
                                            eSignForm.HPSignUpStatus__c = '草案中';
                                            eSignForm.HPReject__c = false;
                                        }
                                    }
                                }
                                //未更新前的医院审批状态 用于文件累计汇总
                                if (eSignFormEntry.HPSignUpStatus__c != null && eSignFormEntry.HPSignUpStatus__c != '') {
                                    oldESignHPStatusMap.put('H' + eSignForm.id, eSignFormEntry.HPSignUpStatus__c);
                                } else {
                                    oldESignHPStatusMap.put('H' + eSignForm.id, '无');
                                }
                            }
                            //如果没变化则不更新
                            if (eSignFormEntry.AgencyWorkflowEmailBack__c != eSignFormEntry.AgencyWorkflowEmail__c) {
                                //经销商邮件
                                eSignForm.AgencyWorkflowEmail__c = eSignFormEntry.AgencyWorkflowEmailBack__c;
                            }
                            //如果没变化则不更新
                            if (eSignFormEntry.HPWorkflowEmailBack__c != eSignFormEntry.HPWorkflowEmail__c) {
                                //医院邮件
                                eSignForm.HPWorkflowEmail__c = eSignFormEntry.HPWorkflowEmailBack__c;
                            }
                            if (eSignFormEntry.agencyDNSignUpStatus__c != '签收已完成') {
                                //经销商扫描日
                                if (eSignFormEntry.agencyScanDayBack__c != null) {
                                    eSignForm.agencyScanDay__c = eSignFormEntry.agencyScanDayBack__c;
                                }
                                //经销商签收日
                                if (eSignFormEntry.agencySignUpDateBack__c != null) {
                                    eSignForm.agencySignUpDate__c = eSignFormEntry.agencySignUpDateBack__c;
                                }
                                //经销商确认日
                                if (eSignFormEntry.agencyConfirmDateBack__c != null) {
                                    eSignForm.agencyConfirmDate__c = eSignFormEntry.agencyConfirmDateBack__c;
                                }
                            }
                            if (eSignFormEntry.HPDNSignUpStatus__c != '签收已完成') {
                                //医院扫描日
                                if (eSignFormEntry.HPScanDayBack__c != null) {
                                    eSignForm.HPScanDay__c = eSignFormEntry.HPScanDayBack__c;
                                }
                                //医院签收日
                                if (eSignFormEntry.HPSignUpDateBack__c != null) {
                                    eSignForm.HPSignUpDate__c = eSignFormEntry.HPSignUpDateBack__c;
                                }
                                //医院确认日
                                if (eSignFormEntry.HPConfirmDateBack__c != null) {
                                    eSignForm.HPConfirmDate__c = eSignFormEntry.HPConfirmDateBack__c;
                                }
                            }
                            //给营业助理赋值
                            eSignForm.Sales_assistant_name_text__c = eSignFormEntry.Sales_assistant_ID__c;
                            //存一个id
                            idlast = eSignFormEntry.Id;
                            //签收单name用作文件命名
                            name = eSignFormEntry.eSignForm__r.Name;
                            //是否经销商提交
                            IsSubmit = eSignFormEntry.IsSubmit__c;
                            //是否医院提交
                            IsHPSubmit = eSignFormEntry.IsHPSubmit__c;
                            //最后录入表
                            eSignForm.finalUpadteFrom__c = eSignFormEntry.Id;
                            //销售渠道 区分直销还是分销
                            Sales_Root_Formula = eSignFormEntry.Sales_Root_Formula__c;
                            //录入类型
                            type = eSignFormEntry.entryType__c;
                        }
                        system.debug('签收单对象-----:' + eSignForm);
                        if (eSignForm != null) {
                            system.debug('eSignFormid:' + eSignFormid);
                            if (eSignForm.id != null) {
                                eSignFormList.add(eSignForm);
                            }
                        }
                        system.debug('eSignFormList111:' + eSignFormList);
                        if (eSignFormList.size() > 0) {
                            //更新OCSM管理省 担当
                            eSignFormList = updateOwner(provinceList, provinceMap, eSignFormList, false);
                        }
                    }
                }
            }
            if (eSignFormList.size() <= 0) {
                system.debug('我走到这里了!');
                eSignFormList  = updateOwner(provinceList, provinceMap, eSignList, true);
                eSignFormList = updateOwner(provinceList, provinceMap, eSignList, true);
            }
            List<Id> fileList = new List<Id> ();
            List<Id> fileList = new List<Id>();
            if (fileIdList.size() > 0) {
                for (Id fileId : fileIdList) {
                    if (!fileList.contains(fileId)) {
                        fileList.add(fileId);
                    }
                }
            }
            System.debug('fileIdList:' + fileIdList);
            System.debug('fileList:' + fileList);
            //用于最后insert 附件
            //zhj Attachment To AWS 2023-02-06
            //List<Attachment> insertAttactment = new List<Attachment>();
            List<FileAddress__c> insertAttactment = new List<FileAddress__c>();
            List<Attachment> insertAttactment = new List<Attachment>();
            //附件  start
            //List<Attachment> attachMentList = [SELECT id, parentId, Body, Name, ContentType,Description  from Attachment where parentId IN :fileList and Description!='电子签收单:已处理'];
            List<FileAddress__c> attachMentList = [SELECT id, ParentRecordId__c, FileName__c,subInfoType__c,AWS_File_Key__c,DownloadLink__c,ViewLink__c  from FileAddress__c where ParentRecordId__c IN :fileList and subInfoType__c  !='电子签收单:已处理'];
            //修复已处理数据 附件没更新  即没有附件能提交的bug 精琢技术 wql 2021/01/19 start
            //List<Attachment> eSignEntryAttachMentList = new List<Attachment>();
            List<FileAddress__c> eSignEntryAttachMentList = new List<FileAddress__c>();
            List<Attachment> attachMentList = [
                SELECT id, parentId, Body, Name, ContentType, Description
                FROM Attachment
                WHERE parentId IN :fileList AND Description != '电子签收单:已处理'
            ];
            //修复已处理数据 附件没更新  即没有附件能提交的bug 精琢技术 wql 2021/01/19 start
            List<Attachment> eSignEntryAttachMentList = new List<Attachment>();
            //文件数量 用于文件命名
            Integer agencyCount = 0;
            Integer hpCount = 0;
            String name;
            String type ;
            String type;
            Integer agencyFileCountNum = 0;
            Integer hpFileCountNum = 0;
            Integer i = 0;
            Integer j = 0;
            //记录该签收单的最新经销商附件数量
            Map<id,Integer> eSignAgencyAttSum = new Map<id,Integer> ();
            Map<id, Integer> eSignAgencyAttSum = new Map<id, Integer>();
            //记录该签收单的最新医院附件数量
            Map<id,Integer> eSignHpAttSum = new Map<id,Integer> ();
            Map<id, Integer> eSignHpAttSum = new Map<id, Integer>();
            //同一条录入表多个附件标识
            Boolean agencyNumFlag = false;
@@ -811,28 +776,25 @@
                system.debug('eSignFlieIdMap:' + eSignFlieIdMap);
                system.debug('eSignNameMap:' + eSignNameMap);
                for (Id eSignFormEntryId : fileList) {
                    for (FileAddress__c attach : attachMentList) {          //zhj Attachment To AWS 2023-02-06
                        if (attach.ParentRecordId__c == eSignFormEntryId) {
                            Id eid = eSignFlieIdMap.get(attach.ParentRecordId__c);
                    for (Attachment attach : attachMentList) {
                        if (attach.parentId == eSignFormEntryId) {
                            Id eid = eSignFlieIdMap.get(attach.parentId);
                            system.debug('eid:' + eid);
                            name = eSignNameMap.get(eid);
                            system.debug('name:' + name);
                            type = eSignTypeMap.get(attach.ParentRecordId__c);
                            type = eSignTypeMap.get(attach.parentId);
                            //因为外层循环是中间表 如果2条以上录入表都有经销商附件 则使用最新构建的经销商附件数量来命名
                            //否则取未更新之前有的经销商附件数量 并且 不是1个录入表多个附件 也就是false的时候 取模拟的最新数量
                            if(eSignAgencyAttSum.size()>0&&!agencyNumFlag){
                            if (eSignAgencyAttSum.size() > 0 && !agencyNumFlag) {
                                agencyCount = eSignAgencyAttSum.get(eid);
                                //记录一个最新的附件数
                                agencySumCount =agencyCount;
                            }else if(agencySumCount>0){
                                agencySumCount = agencyCount;
                            } else if (agencySumCount > 0) {
                                //本次循环内 第一次取附件数最新值 后续都在此基础上i++
                                agencyCount =agencySumCount;
                            }
                            else if(fileAgencyMap.size() > 0){
                                agencyCount = agencySumCount;
                            } else if (fileAgencyMap.size() > 0) {
                                //只有一条数据时,使用此附件数即可 后续在此基础上i++
                                agencyCount = fileAgencyMap.get(eid);
                            }
@@ -854,20 +816,19 @@
                            //经销商附件命名 end
                            //因为外层循环是中间表 如果2条以上录入表都有医院附件 则使用最新构建的医院附件数量来命名
                            //否则取未更新之前有的医院附件数量 并且 不是1个录入表多个附件 也就是false的时候 取模拟的最新数量
                            if(eSignHpAttSum.size()>0&&!hpNumFlag){
                            if (eSignHpAttSum.size() > 0 && !hpNumFlag) {
                                hpCount = eSignHpAttSum.get(eid);
                                //记录一个最新的附件数
                                hpSumCount = hpCount;
                            }else if(hpSumCount >0 ){
                            } else if (hpSumCount > 0) {
                                //本次循环内 第一次取附件数最新值 后续都在此基础上j++
                                hpCount =hpSumCount;
                            }
                            else if(fileHPMap.size() > 0){
                                hpCount = hpSumCount;
                            } else if (fileHPMap.size() > 0) {
                                //只有一条数据时,使用此附件数即可 后续在此基础上j++
                                hpCount = fileHPMap.get(eid);
                            }
                            //同一个内部循环里置成true
                            hpNumFlag =true;
                            hpNumFlag = true;
                            //医院附件命名 start
                            // if (fileHPMap.size() > 0) {
                            //     hpCount = fileHPMap.get(eid);
@@ -880,12 +841,12 @@
                                hpFileCountNum = hpCount + 1 + j;
                            }
                            //构建最新的签收单经销商附件数量
                            if(agencyFileCountNum>0){
                                eSignAgencyAttSum.put(eid,agencyFileCountNum);
                            if (agencyFileCountNum > 0) {
                                eSignAgencyAttSum.put(eid, agencyFileCountNum);
                            }
                            //构建最新的签收单医院附件数量
                            if(hpFileCountNum>0){
                                eSignHpAttSum.put(eid,hpFileCountNum);
                            if (hpFileCountNum > 0) {
                                eSignHpAttSum.put(eid, hpFileCountNum);
                            }
                            //医院附件命名 end
                            //用于拆分经销商/医院 区别文件名
@@ -915,40 +876,31 @@
                            //     title = title +'.jpg';
                            // }
                            //判断一下格式,不然下载下来是类型是所有文件 无法打开
                            //zhj Attachment To AWS 2023-02-06 start
                            if (attach.FileName__c.lastIndexOf('.') > -1) {
                                title = title + attach.FileName__c.substring(attach.FileName__c.lastIndexOf('.'));
                            if (attach.Name.lastIndexOf('.') > -1) {
                                title = title + attach.Name.substring(attach.Name.lastIndexOf('.'));
                            }
                            //Attachment newAttachment = attach.clone();
                            FileAddress__c newAttachment = attach.clone();
                            newAttachment.ParentRecordId__c = eid;
                            newAttachment.FileName__c = title;
                            Attachment newAttachment = attach.clone();
                            newAttachment.parentId = eid;
                            newAttachment.name = title;
                            // newAttachment.ContentType =attach.ContentType;
                            //要更新的签收单附件
                            insertAttactment.add(newAttachment);
                            //反更新录入表的附件 用来判断附件是否被更新
                            //Attachment oldAttachment = new  Attachment();
                            FileAddress__c oldAttachment = new  FileAddress__c();
                            Attachment oldAttachment = new Attachment();
                            oldAttachment.Id = attach.Id;
                            //oldAttachment.Description = '电子签收单:已处理';
                            oldAttachment.subInfoType__c = '电子签收单:已处理';
                            //zhj Attachment To AWS 2023-02-06 end
                            oldAttachment.Description = '电子签收单:已处理';
                            eSignEntryAttachMentList.add(oldAttachment);
                        }
                    }
                    //整单循环后 清空值
                    i = 0;
                    j = 0;
                    agencyNumFlag= false;
                    hpNumFlag =false;
                    agencySumCount =0;
                    hpSumCount=0;
                    agencyNumFlag = false;
                    hpNumFlag = false;
                    agencySumCount = 0;
                    hpSumCount = 0;
                }
            }
            //电子签收单 增加本次更新附件数量  2020/01/07 精琢技术 wql start
@@ -956,7 +908,7 @@
            if (insertAttactment.size() > 0) {
                insert insertAttactment;
                //反向更新录入表附件
                if(eSignEntryAttachMentList.size()>0){
                if (eSignEntryAttachMentList.size() > 0) {
                    update eSignEntryAttachMentList;
                }
@@ -964,84 +916,59 @@
                if (eSignFormList.size() > 0) {
                    //外层所有签收单
                    for (eSignForm__c es : eSignFormList) {
                        //a为经销商附件的数量 h为医院附件的数量
                        Integer a = 0;
                        Integer h = 0;
                        //内层所有需要更新的附件
                        //for (Attachment att : insertAttactment) {
                        for (FileAddress__c att : insertAttactment) {   //zhj Attachment To AWS 2023-02-06
                        for (Attachment att : insertAttactment) {
                            if (es.Id != null) {
                                if (es.Id.equals(att.ParentRecordId__c)) {
                                if (es.Id.equals(att.parentId)) {
                                    if (es.agencyAutoSignUpStatus__c != null) {
                                        if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size()>0) {
                                                if(!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')){
                                                    if (att.FileName__c.substring(0, 1).equals('A')) {      //zhj Attachment To AWS 2023-02-06
                                                        a ++;
                                                    }
                                        if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size() > 0) {
                                            if (!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')) {
                                                if (att.Name.substring(0, 1).equals('A')) {
                                                    a++;
                                                }
                                            }
                                        }
                                    }
                                    if (es.HPSignUpStatus__c != null) {
                                        if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size()>0) {
                                            if(!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')){
                                                if (att.FileName__c.substring(0, 1).equals('H')) {          //zhj Attachment To AWS 2023-02-06
                                                    h ++;
                                        if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size() > 0) {
                                            if (!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')) {
                                                if (att.Name.substring(0, 1).equals('H')) {
                                                    h++;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //只有真正扫码提交的 并且没有附件才会被更新
                        if (es.agencyAutoSignUpStatus__c != null) {
                            if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size()>0) {
                                if(!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')){
                            if (es.agencyAutoSignUpStatus__c.equals('申请中') && oldESignAgencyStatusMap.size() > 0) {
                                if (!oldESignAgencyStatusMap.get('A' + es.Id).equals('申请中')) {
                                    es.agencyAttachNum__c = a;
                                }
                            }
                        }
                        //只有真正扫码提交的 并且没有附件才会被更新
                        if (es.HPSignUpStatus__c != null) {
                            if (es.HPSignUpStatus__c.equals('申请中') &&oldESignHPStatusMap.size()>0 ) {
                                if(!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')){
                                     es.HPAttachNum__c = h;
                            if (es.HPSignUpStatus__c.equals('申请中') && oldESignHPStatusMap.size() > 0) {
                                if (!oldESignHPStatusMap.get('H' + es.Id).equals('申请中')) {
                                    es.HPAttachNum__c = h;
                                }
                            }
                        }
                        a = 0;
                        h = 0;
                    }
                }
                //电子签收单 增加本次更新附件数量  2020/01/07 精琢技术 wql end
                //文件 end
            }
            // 更新签收单录入表
            if(unprocessedEntries.size() > 0) {
                Database.SaveResult[] lsr = Database.update(unprocessedEntries, false);
                // Database.SaveResult[] lsr = Database.update(unprocessedEntries.values(), false);
                eb.setError(lsr, MAXERRORCNT, eSignFormEntry__c.sObjectType);
                for (Integer tIdx = 0; tIdx < lsr.size(); tIdx++) {
                    Database.SaveResult sr = lsr[tIdx];
                    System.debug('sr.isSuccess:' + sr.isSuccess());
                    if (!sr.isSuccess()) {
                        Database.Error emsg = sr.getErrors()[0];
                        iflog.ErrorLog__c += 'ERROR ' + unprocessedEntries[tIdx].Id + ' eSignFormEntry__c:' + emsg + '\n';
                        // iflog.ErrorLog__c += 'ERROR ' + unprocessedEntries.values()[tIdx].Id + ' eSignFormEntry__c:' + emsg + '\n';
                    }
                }
            }
            system.debug('更新的签收单:' + eSignFormList);
            //更新签收单明细并添加日志
@@ -1070,35 +997,30 @@
                    }
                }
            }
        }catch(NullPointerException npe){
                iflog.ErrorLog__c += 'ERROR : eSignForm__c:空指针错误-行号:'+ npe.getLineNumber()+ '\n';
        }
        catch (Exception e) {
        } catch (NullPointerException npe) {
            iflog.ErrorLog__c += 'ERROR : eSignForm__c:空指针错误-行号:' + npe.getLineNumber() + '\n';
        } catch (Exception e) {
            // Database.rollback(sp);
            iflog.ErrorLog__c += 'ERROR : eSignForm__c:'+ e.getMessage() + '\n';
            iflog.ErrorLog__c += 'ERROR : eSignForm__c:' + e.getMessage() + '\n';
        }
        try{
            System.debug('luruIsLastSubmitList:'+luruIsLastSubmitList);
        try {
            System.debug('luruIsLastSubmitList:' + luruIsLastSubmitList);
            if (luruIsLastSubmitList.size() > 0) {
                //删除中间表数据(因为住主详关系,删除录入表即可)
                deleteMiddleData(eSignStringMap, luruIsLastSubmitList);
            }
        }catch(Exception e){
            iflog.ErrorLog__c += 'ERROR : eSignForm__c:'+ e.getMessage() + '\n';
        } catch (Exception e) {
            iflog.ErrorLog__c += 'ERROR : eSignForm__c:' + e.getMessage() + '\n';
        }
        //文件 end
    }
    //删除中间表数据(因为住主详关系,删除录入表即可)
    private static void deleteMiddleData(Map < String, eSignFormEntry__c > eSignStringMap, List < String > luruIsSubmitList) {
    private static void deleteMiddleData(Map<String, eSignFormEntry__c> eSignStringMap, List<String> luruIsSubmitList) {
        system.debug('检索的所有录入表:' + eSignStringMap);
        system.debug('最后录入的id :' + luruIsSubmitList + '----数量:' + luruIsSubmitList.size());
        list < eSignFormEntry__c > eSignFormDeleteList = new list < eSignFormEntry__c > ();
        list<eSignFormEntry__c> eSignFormDeleteList = new List<eSignFormEntry__c>();
        for (String essm : eSignStringMap.keySet()) {
            for (String lisl : luruIsSubmitList) {
                if (essm.equals(lisl)) {
@@ -1111,73 +1033,68 @@
        }
        system.debug('删除的数据id:' + eSignFormDeleteList + '----数量:' + eSignFormDeleteList.size());
        //删除签收单录入表其他数据
        if (eSignFormDeleteList.size() > 0) {
            //循环遍历id 删除文件
            List<String> fileDeleteIdList = new List<String> ();
            //List<Attachment> deleteAttachmentList = new List<Attachment>();
            List<FileAddress__c> deleteAttachmentList = new List<FileAddress__c>();     //zhj Attachment To AWS 2023-02-06
            List<String> fileDeleteIdList = new List<String>();
            List<Attachment> deleteAttachmentList = new List<Attachment>();
            for (eSignFormEntry__c eSigf : eSignFormDeleteList) {
                fileDeleteIdList.add(eSigf.Id);
            }
            //循环找到文件id
            if (fileDeleteIdList.size() > 0) {
                // 2022-02-28 shashiming Apex heap size too large
                // 去掉Body字段
                //List<Attachment> attachMentList = [SELECT id, parentId, Name, ContentType,Description  from Attachment where parentId = :fileDeleteIdList];
                List<FileAddress__c> attachMentList = [SELECT id, ParentRecordId__c, FileName__c,AWS_File_Key__c  from FileAddress__c where ParentRecordId__c = :fileDeleteIdList];       //zhj Attachment To AWS 2023-02-06
                List<Transaction_Log__c> tranList = new List<Transaction_Log__c>();
                List<Attachment> attachMentList = [
                    SELECT id, parentId, Name, ContentType, Description
                    FROM Attachment
                    WHERE parentId = :fileDeleteIdList
                ];
                if (attachMentList.size() > 0) {
                    for (FileAddress__c att : attachMentList) {
                        FileAddress__c am = new FileAddress__c();           //zhj Attachment To AWS 2023-02-06
                    for (Attachment att : attachMentList) {
                        Attachment am = new Attachment();
                        am.Id = att.Id;
                        deleteAttachmentList.add(am);
                        //zhj 新增日志,删除AWS的附件 2023-02-17
                        Transaction_Log__c tran = new Transaction_Log__c();
                        tran.AWS_Data_Id__c = att.AWS_File_Key__c;
                        tran.Status__c = 'In Process';
                        tran.Module__c = '签收单附件删除';
                        tranList.add(tran);
                    }
                    //新增日志,删除AWS的附件 zhj 2023-02-17
                    if(tranList.size() > 0){
                        insert tranList;
                    }
                    //删除文件
                    if (deleteAttachmentList.size() > 0) {
                        delete deleteAttachmentList;
                    }
                }
            }
            //删除录入表
            System.debug('删除录入表 : ' + eSignFormDeleteList);
            // delete eSignFormDeleteList;  // 2023-03-14 ssm 暂时不自动删除中间表数据,方便短期内做check
            delete eSignFormDeleteList;
        }
    }
    @TestVisible
    //更新营业部担当
    private static List < eSignForm__c > updateOwner(List < String > provinceList, Map < Id, String > provinceMap, List < eSignForm__c > eSignFormList, boolean ocsmFlag) {
    private static List<eSignForm__c> updateOwner(
        List<String> provinceList,
        Map<Id, String> provinceMap,
        List<eSignForm__c> eSignFormList,
        boolean ocsmFlag
    ) {
        //营业担当 map
        Map < String, String > provinceOwnerMap = new Map < String, String > ();
        Map<String, String> provinceOwnerMap = new Map<String, String>();
        //营业助理 map
        Map < String, String > provinceGIMap = new Map < String, String > ();
        Map<String, String> provinceGIMap = new Map<String, String>();
        List < eSignForm__c > eSignFormLastList = new List < eSignForm__c >();
        List<eSignForm__c> eSignFormLastList = new List<eSignForm__c>();
        //检索OCSM管理省对象
        List < OCM_Management_Province__c > ompList = [select id, Name, SalesManage__c,GI_assistant__c,Window1__c    from OCM_Management_Province__c where Name IN: provinceList];
        List<OCM_Management_Province__c> ompList = [
            SELECT id, Name, SalesManage__c, GI_assistant__c
            FROM OCM_Management_Province__c
            WHERE Name IN :provinceList
        ];
        //存放map<省,担当>
        for (OCM_Management_Province__c omp : ompList) {
            //不用map<String,list>的 原因是 想 ocsm管理省 和签收单 营业担当的顺序保持一致
            //String salesManage = omp.SalesManage__c+','+omp.SalesManage2__c+','+omp.SalesManage3__c;
            //provinceOwnerMap.put(omp.Name, salesManage);
            provinceOwnerMap.put(omp.Name, omp.SalesManage__c);
            provinceGIMap.put(omp.Name, omp.Window1__c);//Update By Li Jun 20230420 for  签收单营业助理从GI/SP助理改为签收单OCSM省的营业窗口
            provinceGIMap.put(omp.Name, omp.GI_assistant__c);
        }
        //①为true的时候 是其他没发生变化只有ocsm省上营业担当改变
        //②为false的时候,有中间表正常更新的情况
@@ -1223,7 +1140,6 @@
        //             }
        //         }
        //     }
        //     return eSignFormLastList;
@@ -1257,43 +1173,39 @@
        if (ocsmFlag) {
            //给最后要更新的签收单的审批者(营业部担当)赋值
            for (Integer cnt = 0; cnt < eSignFormList.size(); cnt++) {
                if (provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id)) != eSignFormList[cnt].RC_Manager__c ||provinceMap.get(eSignFormList[cnt].Id).equals('集采课')) {
                if (
                    provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id)) != eSignFormList[cnt].RC_Manager__c ||
                    provinceMap.get(eSignFormList[cnt].Id).equals('集采课')
                ) {
                    eSignForm__c eSignForm = new eSignForm__c();
                    eSignForm.Id = eSignFormList[cnt].Id;
                    eSignForm.RC_Manager__c = provinceOwnerMap.get(provinceMap.get(eSignFormList[cnt].Id));
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start
                    if(provinceMap.get(eSignFormList[cnt].Id).equals('集采课')){
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start
                    if (provinceMap.get(eSignFormList[cnt].Id).equals('集采课')) {
                        eSignForm.Sales_assistant_name_text__c = provinceGIMap.get(provinceMap.get(eSignFormList[cnt].Id));
                    }
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 end
                    eSignFormLastList.add(eSignForm);
                }
            }
            return eSignFormLastList;
        } else {
            //给最后要更新的签收单的审批者(营业部担当)赋值
            for (eSignForm__c esf : eSignFormList) {
                if (provinceOwnerMap.get(provinceMap.get(esf.Id)) != null) {
                    esf.RC_Manager__c = provinceOwnerMap.get(provinceMap.get(esf.Id));
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start
                    if(provinceMap.get(esf.Id).equals('集采课')){
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 start
                    if (provinceMap.get(esf.Id).equals('集采课')) {
                        esf.Sales_assistant_name_text__c = provinceGIMap.get(provinceMap.get(esf.Id));
                    }
                    //集采询价 营业助理需要维护成 集采课的SP、GI助理 精琢技术 wql 2021/01/08 end
                }
            }
            return eSignFormList;
        }
    }
    global void finish(Database.BatchableContext BC) {
        //更新该日志的数据信息
        iflog.Log__c += '\nupdateESignBatch end';
        String tmp = iflog.ErrorLog__c;
@@ -1331,7 +1243,7 @@
                //写死精琢用户 上线后应该会修改成自定义标签
                // String batchUserId = '00510000005sEEM';
                String batchUserId = System.Label.Batch_User_Id;
                List<User> us = [Select Id, NAme, Email From User Where Id = : batchUserId];
                List<User> us = [SELECT Id, NAme, Email FROM User WHERE Id = :batchUserId];
                if (!us.isEmpty()) {
                    User use = us[0];
                    if (String.isNotBlank(use.Email)) {
@@ -1339,11 +1251,7 @@
                        if (System.Label.ESign_Error_Send_To_CC != 'null') {
                            MailCc = System.Label.ESign_Error_Send_To_CC.split(',');
                        }
                        FixtureUtil.sendMessage(batchUserId,
                                                MailCc,
                                                'updateESignBatch Error',
                                                body
                                               );
                        FixtureUtil.sendMessage(batchUserId, MailCc, 'updateESignBatch Error', body);
                    }
                }
            }
@@ -1364,7 +1272,7 @@
            messageMap = new Map<Id, String>();
            overMax = false;
        }
        public void setError (Database.SaveResult[] saveRes, Integer maxCut, Schema.sObjectType obj) {
        public void setError(Database.SaveResult[] saveRes, Integer maxCut, Schema.sObjectType obj) {
            if (messageMap.keySet().size() <= maxCut && overMax == false) {
                String objectName = obj.getDescribe().getName();
                String objectLabel = obj.getDescribe().getLabel();
@@ -1376,12 +1284,16 @@
                                break;
                            }
                            for (Database.Error err : saveRe.getErrors()) {
                                String message = objectName + ':'
                                                 + objectLabel + ':'
                                                 + err.getStatusCode() + ':'
                                                 + err.getFields() + ':'
                                                 + err.getMessage();
                                String message =
                                    objectName +
                                    ':' +
                                    objectLabel +
                                    ':' +
                                    err.getStatusCode() +
                                    ':' +
                                    err.getFields() +
                                    ':' +
                                    err.getMessage();
                                // 数据里面有复数错误信息的话只获取第一条
                                messageMap.put(saveRe.getId(), message);
                                break;
@@ -1394,519 +1306,8 @@
    }
    //定时跑任务
    public Class ScBean {
    public class ScBean {
        public String scName;
        public String scTime;
    }
    public static void improveTestRate(){
        Integer i = 0;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
    }
}
}
force-app/main/default/classes/updateESignBatchTest.cls
Diff too large
force-app/main/default/lwc/lexCustomLightningDatatable/customOutputGoods.html
New file
@@ -0,0 +1,7 @@
<template>
    <c-custom-output-good
        output-value={typeAttributes.outputValue}
        output-type={typeAttributes.type}
        record-id={typeAttributes.recordId}
    ></c-custom-output-good>
</template>
force-app/main/default/lwc/lexCustomLightningDatatable/customReturnGoodInput.html
New file
@@ -0,0 +1,7 @@
<template>
    <c-lex-return-good-cus-input
        intput-value={typeAttributes.inputValue}
        box-price={typeAttributes.boxPrice}
        record-id={typeAttributes.recordId}
    ></c-lex-return-good-cus-input>
</template>
force-app/main/default/lwc/lexCustomLightningDatatable/customShipmentNumber.html
@@ -1,8 +1,8 @@
<template>
    <c-custom-shipment-number-comp
    record-id={typeAttributes.recordId}
    shipment-number={typeAttributes.shipmentNumber}
        style="border-color: red"
        record-id={typeAttributes.recordId}
        shipment-number={typeAttributes.shipmentNumber}
    >
    </c-custom-shipment-number-comp>
</template>
</template>
force-app/main/default/lwc/lexCustomLightningDatatable/lexCustomLightningDatatable.js
@@ -5,44 +5,58 @@
import customShipmentAmountTemplate from './customShipmentAmount.html';
import customDiffReasonTemplate from './lexCustomDiffReason.html';
import attachmentTypeTemplate from './customAttachmentType.html';
import { loadStyle} from 'lightning/platformResourceLoader';
import customTableInputTemplate from './customTableInput.html';
import customOutputGoodsTemplate from './customOutputGoods.html';
import customReturnGoodInputTemplate from './customReturnGoodInput.html';
import { loadStyle } from 'lightning/platformResourceLoader';
import LexCustomDataTable from '@salesforce/resourceUrl/LexCustomDataTable';
export default class LexCustomLightningDatatable extends LightningDatatable {
    static customTypes = {
        customUnit: {
            template: customUnitTemplate,
            typeAttributes: ['unitValue','unitOptions','recordId'],
            typeAttributes: ['unitValue', 'unitOptions', 'recordId']
        },
        customShipment: {
            template: customShipmentNumberTemplate,
            typeAttributes: ['shipmentNumber','recordId'],
            typeAttributes: ['shipmentNumber', 'recordId']
        },
        customShipmentUnitPrice: {
            template: customShippingUnitPriceTemplate,
            typeAttributes: ['shippingUnitPrice','recordId'],
            typeAttributes: ['shippingUnitPrice', 'recordId']
        },
        customShipmentAmount: {
            template: customShipmentAmountTemplate,
            typeAttributes: ['shipmentAmount','recordId'],
            typeAttributes: ['shipmentAmount', 'recordId']
        },
        customDiffReason : {
        customDiffReason: {
            template: customDiffReasonTemplate,
            typeAttributes: ['ProdId'],
            typeAttributes: ['ProdId']
        },
        customAttachmentType: {
            template: attachmentTypeTemplate,
            typeAttributes: ['typeValue','typeOptions','recordId','isDisabledAttachment'],
            typeAttributes: [
                'typeValue',
                'typeOptions',
                'recordId',
                'isDisabledAttachment'
            ]
        },
        customTableInput: {
            template: customTableInputTemplate,
            typeAttributes:['inputValue','recordId'],
            typeAttributes: ['inputValue', 'recordId']
        },
        customOutputGood: {
            template: customOutputGoodsTemplate,
            typeAttributes: ['outputValue', 'type', 'recordId']
        },
        customReturnGoodInput: {
            template: customReturnGoodInputTemplate,
            typeAttributes: ['inputValue', 'boxPrice', 'recordId']
        }
    };
    constructor() {
        super();
        Promise.all([
            loadStyle(this, LexCustomDataTable),
        ]).then(() => {})
        Promise.all([loadStyle(this, LexCustomDataTable)]).then(() => {});
    }
}
}
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.html
@@ -2,51 +2,96 @@
<!-- sldsValidatorIgnore -->
<template>
    <template if:true={isShowSpinner}>
        <lightning-spinner alternative-text="Loading" size="large"></lightning-spinner>
        <lightning-spinner
            alternative-text="Loading"
            size="large"
        ></lightning-spinner>
    </template>
    <!-- 搜索客户名 -->
    <template if:true={isModalOpen}>
        <!-- Modal/Popup Box LWC starts here -->
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true"
            aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
        <section
            role="dialog"
            tabindex="-1"
            aria-labelledby="modal-heading-01"
            aria-modal="true"
            aria-describedby="modal-content-id-1"
            class="slds-modal slds-fade-in-open"
        >
            <div class="slds-modal__container">
                <!-- Modal/Popup Box LWC header here -->
                <header class="slds-modal__header">
                    <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
                        title="Close" onclick={closeModal}>
                        <lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse"
                            size="small"></lightning-icon>
                    <button
                        class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
                        title="Close"
                        onclick={closeModal}
                    >
                        <lightning-icon
                            icon-name="utility:close"
                            alternative-text="close"
                            variant="inverse"
                            size="small"
                        ></lightning-icon>
                        <span class="slds-assistive-text">Close</span>
                    </button>
                    <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">
                    <h2
                        id="modal-heading-01"
                        class="slds-text-heading_medium slds-hyphenate"
                    >
                        经销商医院检索
                    </h2>
                </header>
                <!-- Modal/Popup Box LWC body starts here -->
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                <div
                    class="slds-modal__content slds-p-around_medium"
                    id="modal-content-id-1"
                >
                    <lightning-layout>
                        <lightning-layout-item flexibility="auto" padding="around-small">
                            <lightning-input type="text" label="医院名称" onchange={dataChange}
                                data-field="searchHospitalName" value={searchHospitalName}
                                variant="label-inline"></lightning-input>
                        <lightning-layout-item
                            flexibility="auto"
                            padding="around-small"
                        >
                            <lightning-input
                                type="text"
                                label="医院名称"
                                onchange={dataChange}
                                data-field="searchHospitalName"
                                value={searchHospitalName}
                                variant="label-inline"
                            ></lightning-input>
                        </lightning-layout-item>
                        <lightning-layout-item flexibility="auto" padding="around-small">
                            <lightning-button label="检索" onclick={searchHospital}></lightning-button>
                        <lightning-layout-item
                            flexibility="auto"
                            padding="around-small"
                        >
                            <lightning-button
                                label="检索"
                                onclick={searchHospital}
                            ></lightning-button>
                        </lightning-layout-item>
                    </lightning-layout>
                    <div class="tableColumn">
                        <lightning-layout class="datatable">
                            <lightning-datatable class="datatabel slds-border_top" key-field="id" data={hospitalList}
                                columns={hospitalColumns} hide-checkbox-column="true"
                                onrowaction={searchHandleRowAction}>
                            <lightning-datatable
                                class="datatabel slds-border_top"
                                key-field="id"
                                data={hospitalList}
                                columns={hospitalColumns}
                                hide-checkbox-column="true"
                                onrowaction={searchHandleRowAction}
                            >
                            </lightning-datatable>
                        </lightning-layout>
                    </div>
                </div>
                <!-- Modal/Popup Box LWC footer starts here -->
                <footer class="slds-modal__footer">
                    <button class="slds-button slds-button_neutral" onclick={closeModal} title="Cancel">
                    <button
                        class="slds-button slds-button_neutral"
                        onclick={closeModal}
                        title="Cancel"
                    >
                        关闭
                    </button>
                </footer>
@@ -57,27 +102,64 @@
    <!-- 上传附件弹窗 -->
    <template if:true={showAttPop}>
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open slds-modal_small" style="border: 1px solid #D4D4D4;">
        <section
            role="dialog"
            tabindex="-1"
            aria-labelledby="modal-heading-01"
            aria-modal="true"
            aria-describedby="modal-content-id-1"
            class="slds-modal slds-fade-in-open slds-modal_small"
            style="border: 1px solid #d4d4d4"
        >
            <template if:true={showPopSpinner}>
                <lightning-spinner size="medium" variant="brand"></lightning-spinner>
                <lightning-spinner
                    size="medium"
                    variant="brand"
                ></lightning-spinner>
            </template>
            <div class="slds-modal__container">
                <header class="slds-modal__header" style="background-color: #F3F3F3;">
                    <button style="" class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closePop}>
                        <lightning-icon icon-name="utility:close"
                <header
                    class="slds-modal__header"
                    style="background-color: #f3f3f3"
                >
                    <button
                        style=""
                        class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
                        title="Close"
                        onclick={closePop}
                    >
                        <lightning-icon
                            icon-name="utility:close"
                            alternative-text="close"
                            variant="inverse"
                            size="small" ></lightning-icon>
                            size="small"
                        ></lightning-icon>
                        <span class="slds-assistive-text">Close</span>
                    </button>
                    <h2 id="modal-heading-02" class="slds-text-heading_medium slds-hyphenate">上传附件</h2>
                    <h2
                        id="modal-heading-02"
                        class="slds-text-heading_medium slds-hyphenate"
                    >
                        上传附件
                    </h2>
                </header>
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-2" style="border: 1px solid #F3F3F3;">
                <div
                    class="slds-modal__content slds-p-around_medium"
                    id="modal-content-id-2"
                    style="border: 1px solid #f3f3f3"
                >
                    <div class="slds-m-top_medium slds-m-bottom_x-large">
                        <div class="slds-p-around_medium lgc-bg">
                            <lightning-input type="file" label="附件上传" accept=".xlsx, .xls, .csv, .png, .doc, .docx, .pdf" onchange={attChange}></lightning-input>
                            <lightning-input
                                type="file"
                                label="附件上传"
                                accept=".xlsx, .xls, .csv, .png, .doc, .docx, .pdf"
                                onchange={attChange}
                            ></lightning-input>
                        </div>
                        <p>已选择文件:{fileName} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <p>
                            已选择文件:{fileName}
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <template if:true={attDelBtn}>
                                <a onclick={removeAtt}>移除</a>
                            </template>
@@ -85,8 +167,18 @@
                    </div>
                </div>
                <footer class="slds-modal__footer">
                    <lightning-button style="margin-left: 10px;" variant="neutral" label="取消" onclick={closePop}></lightning-button>
                    <lightning-button style="margin-left: 10px;" variant="neutral" label="上传" onclick={handleSave}></lightning-button>
                    <lightning-button
                        style="margin-left: 10px"
                        variant="neutral"
                        label="取消"
                        onclick={closePop}
                    ></lightning-button>
                    <lightning-button
                        style="margin-left: 10px"
                        variant="neutral"
                        label="上传"
                        onclick={handleSave}
                    ></lightning-button>
                </footer>
            </div>
        </section>
@@ -121,8 +213,11 @@
                                <tr>
                                    <td>
                                        <template if:true={isSaveShow}>
                                            <lightning-button label="保存" onclick={saveConfirmJs}
                                                style="width: 150px"></lightning-button>
                                            <lightning-button
                                                label="保存"
                                                onclick={saveConfirmJs}
                                                style="width: 150px"
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td colspan="4">
@@ -135,25 +230,35 @@
                                <tr>
                                    <td></td>
                                    <td>
                                        <template if:true={isEditShow}>
                                            <lightning-button label="编辑出库单" onclick={EditConsumable}
                                                style="width: 150px" disabled={isEditDisabled}></lightning-button>
                                            <lightning-button
                                                label="编辑出库单"
                                                onclick={EditConsumable}
                                                style="width: 150px"
                                                disabled={isEditDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isDeliveryShow}>
                                            <lightning-button label="出货/销售" onclick={GoodsDeliveryJs}
                                                style="width: 150px;" disabled={isDeliveryDisabled}></lightning-button>
                                            <lightning-button
                                                label="出货/销售"
                                                onclick={GoodsDeliveryJs}
                                                style="width: 150px"
                                                disabled={isDeliveryDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isOpenToInvoiceShow}>
                                            <lightning-button label="开票" onclick={openToInvoiceJs} style="width: 150px"
                                                disabled={isOpenToInvoiceDisabled}></lightning-button>
                                            <lightning-button
                                                label="开票"
                                                onclick={openToInvoiceJs}
                                                style="width: 150px"
                                                disabled={isOpenToInvoiceDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                </tr>
@@ -161,26 +266,34 @@
                                    <td></td>
                                    <td>
                                        <template if:true={isPraseToPDFShow}>
                                            <lightning-button label="打印指示单" onclick={PraseToPDFJs} style="width: 150px"
                                                disabled={isPraseToPDFDisabled}></lightning-button>
                                            <lightning-button
                                                label="打印指示单"
                                                onclick={PraseToPDFJs}
                                                style="width: 150px"
                                                disabled={isPraseToPDFDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isOpenReportShow}>
                                            <lightning-button label="显示明细" onclick={openReportJs} style="width: 150px"
                                                disabled={isOpenReportDisabled}></lightning-button>
                                            <lightning-button
                                                label="显示明细"
                                                onclick={openReportJs}
                                                style="width: 150px"
                                                disabled={isOpenReportDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td>
                                        <template if:true={isDeleteShow}>
                                            <lightning-button label="删除" onclick={DeleteConsumable} style="width: 150px"
                                                disabled={isDeleteDisabled}></lightning-button>
                                            <lightning-button
                                                label="删除"
                                                onclick={DeleteConsumable}
                                                style="width: 150px"
                                                disabled={isDeleteDisabled}
                                            ></lightning-button>
                                        </template>
                                    </td>
                                    <td></td>
@@ -202,182 +315,323 @@
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <!-- SummonsStatus_c__c == '价格未定' -->
                                <template if:true={summonsStatusPriceNotDetermined}>
                                    <lightning-record-edit-form object-api-name="Consumable_order__c" record-id={cocId}
                                        onload={handleLoad}>
                                <template
                                    if:true={summonsStatusPriceNotDetermined}
                                >
                                    <lightning-record-edit-form
                                        object-api-name="Consumable_order__c"
                                        record-id={cocId}
                                        onload={handleLoad}
                                    >
                                        <!-- 出库单号 出库单状态 -->
                                        <lightning-layout multiple-rows="true">
                                            <template if:true={isSummonsFlag}>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item size="4">
                                                    <lightning-output-field field-name="Name"
                                                        class="hehe-layoutItem"></lightning-output-field>
                                                    <lightning-output-field
                                                        field-name="Name"
                                                        class="hehe-layoutItem"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="SummonsStatus_c__c"></lightning-output-field>
                                                        field-name="SummonsStatus_c__c"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                            </template>
                                        </lightning-layout>
                                        <!-- 目的   开票状态 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="SummonsForDirction__c"></lightning-output-field>
                                                    field-name="SummonsForDirction__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="Billed_Status__c"></lightning-output-field>
                                                    field-name="Billed_Status__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 二级经销商 -->
                                        <template if:true={isSummonsForDirctionTwoShow}>
                                            <lightning-layout multiple-rows="true">
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                        <template
                                            if:true={isSummonsForDirctionTwoShow}
                                        >
                                            <lightning-layout
                                                multiple-rows="true"
                                            >
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="Order_Dealer_Info__c"></lightning-output-field>
                                                        field-name="Order_Dealer_Info__c"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                            </lightning-layout>
                                        </template>
                                        <!-- 客户名 发票-->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-output-field class="hideHelpText"
                                                    field-name="ShipmentAccount__c"></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field data-field={ConInvoice_Code__c}
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    class="hideHelpText"
                                                    field-name="ShipmentAccount__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    data-field={ConInvoice_Code__c}
                                                    onchange={invoiceChange}
                                                    field-name="ConInvoice_Code__c"></lightning-input-field>
                                                    field-name="ConInvoice_Code__c"
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 科室 出库金额 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="Order_ForCustomerText__c"></lightning-output-field>
                                                    field-name="Order_ForCustomerText__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="Shipment_total_amount__c"></lightning-output-field>
                                                    field-name="Shipment_total_amount__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 没有确定价格 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-output-field
                                                    field-name="NoConfirmedPrice__c"></lightning-output-field>
                                                    field-name="NoConfirmedPrice__c"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                    </lightning-record-edit-form>
                                </template>
                                <!-- SummonsStatus_c__c != '价格未定' -->
                                <template if:false={summonsStatusPriceNotDetermined}>
                                    <lightning-record-edit-form object-api-name="Consumable_order__c" record-id={cocId}
                                        onsubmit={handleSubmit} onload={handleLoad}>
                                <template
                                    if:false={summonsStatusPriceNotDetermined}
                                >
                                    <lightning-record-edit-form
                                        object-api-name="Consumable_order__c"
                                        record-id={cocId}
                                        onsubmit={handleSubmit}
                                        onload={handleLoad}
                                    >
                                        <!-- 出库单号 出库单状态 -->
                                        <lightning-layout multiple-rows="true">
                                            <template if:true={isSummonsFlag}>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                    <lightning-output-field field-name="Name"></lightning-output-field>
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="Name"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                                <lightning-layout-item size="1"></lightning-layout-item>
                                                <lightning-layout-item
                                                    size="1"
                                                ></lightning-layout-item>
                                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-layout-item
                                                    class="hehe-layoutItem"
                                                    size="4"
                                                >
                                                    <lightning-output-field
                                                        field-name="SummonsStatus_c__c"></lightning-output-field>
                                                        field-name="SummonsStatus_c__c"
                                                    ></lightning-output-field>
                                                </lightning-layout-item>
                                            </template>
                                        </lightning-layout>
                                        <!-- 目的   二级经销商 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field data-field="summonsForDirction"
                                                    value={summonsForDirction} field-name="SummonsForDirction__c"
                                                    required="true" onchange={ChangeDirction}></lightning-input-field>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    data-field="summonsForDirction"
                                                    value={summonsForDirction}
                                                    field-name="SummonsForDirction__c"
                                                    required="true"
                                                    onchange={ChangeDirction}
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-combobox data-field="secondaryDistributor"
                                                    name="secondaryDistributor" label="二级经销商"
                                                    value={secondaryDistributor} placeholder="请选择..."
                                                    options={secondaryDistributorOptions} variant="label-inline"
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-combobox
                                                    data-field="secondaryDistributor"
                                                    name="secondaryDistributor"
                                                    label="二级经销商"
                                                    value={secondaryDistributor}
                                                    placeholder="请选择..."
                                                    options={secondaryDistributorOptions}
                                                    variant="label-inline"
                                                    onchange={dataChange}
                                                    disabled={isDisabledSecondaryDistributor}></lightning-combobox>
                                                    disabled={isDisabledSecondaryDistributor}
                                                ></lightning-combobox>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 客户名   经销商录入 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <div
                                                    class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right">
                                                    <lightning-icon size="x-small"
                                                    class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right"
                                                >
                                                    <lightning-icon
                                                        size="x-small"
                                                        class="iconMargin slds-icon slds-input__icon slds-input__icon_right slds-icon-text-default"
                                                        icon-name="utility:search"></lightning-icon>
                                                    <lightning-input type="text" name="HospitalName" label="客户名"
                                                        value={HospitalName} variant="label-inline"
                                                        onclick={searchHospitalNameModal} data-field="HospitalName"
                                                        icon-name="utility:search"
                                                    ></lightning-icon>
                                                    <lightning-input
                                                        type="text"
                                                        name="HospitalName"
                                                        label="客户名"
                                                        value={HospitalName}
                                                        variant="label-inline"
                                                        onclick={searchHospitalNameModal}
                                                        data-field="HospitalName"
                                                        disabled={isDisabledHospitalName}
                                                        onchange={clearAgencyI}></lightning-input>
                                                        onchange={clearAgencyI}
                                                    ></lightning-input>
                                                </div>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <template if:true={isMutualTransferGoods}>
                                                    <c-lex-lookup onsearch={handleSearch}
                                                        onselectionchange={handleSelectionChange} label="经销商(录入)"
                                                        variant="label-inline" placeholder="搜索经销商"
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <template
                                                    if:true={isMutualTransferGoods}
                                                >
                                                    <c-lex-lookup
                                                        onsearch={handleSearch}
                                                        onselectionchange={handleSelectionChange}
                                                        label="经销商(录入)"
                                                        variant="label-inline"
                                                        placeholder="搜索经销商"
                                                        onisdisabledfordealertext={isDisabledForDealerText}
                                                        onblur={vpClear2Delay} disabled={isDisabledForDealerText}>
                                                        onblur={vpClear2Delay}
                                                        disabled={isDisabledForDealerText}
                                                    >
                                                    </c-lex-lookup>
                                                </template>
                                                <template if:false={isMutualTransferGoods}>
                                                    <lightning-input type="text" name="Order_ForDealerText__c"
                                                        label="经销商(录入)" value={ForDealerText} onchange={dataChange}
                                                <template
                                                    if:false={isMutualTransferGoods}
                                                >
                                                    <lightning-input
                                                        type="text"
                                                        name="Order_ForDealerText__c"
                                                        label="经销商(录入)"
                                                        value={ForDealerText}
                                                        onchange={dataChange}
                                                        data-field="Order_ForDealerText__c"
                                                        disabled={isDisabledForDealerText} variant="label-inline">
                                                        disabled={isDisabledForDealerText}
                                                        variant="label-inline"
                                                    >
                                                    </lightning-input>
                                                </template>
                                            </lightning-layout-item>
@@ -385,32 +639,60 @@
                                        <!-- 科室   总金额 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field onchange={dataChange}
                                                    data-field="ForCustomerText" value={ForCustomerText}
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    onchange={dataChange}
                                                    data-field="ForCustomerText"
                                                    value={ForCustomerText}
                                                    field-name="Order_ForCustomerText__c"
                                                    disabled={isDisabledForCustomerText}></lightning-input-field>
                                                    disabled={isDisabledForCustomerText}
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input type="text" name="sumPrice" label="总金额"
                                                    value={sumPrice} variant="label-inline" onchange={dataChange}
                                                    data-field="sumPrice" readonly></lightning-input>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input
                                                    type="text"
                                                    name="sumPrice"
                                                    label="总金额"
                                                    value={sumPrice}
                                                    variant="label-inline"
                                                    onchange={dataChange}
                                                    data-field="sumPrice"
                                                    readonly
                                                ></lightning-input>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                        <!-- 没有确定价格 -->
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item class="hehe-layoutItem" size="4">
                                                <lightning-input-field value={NoConfirmedPrice}
                                                    field-name="NoConfirmedPrice__c" data-field="NoConfirmedPrice"
                                                    onchange={dataChange}></lightning-input-field>
                                            <lightning-layout-item
                                                class="hehe-layoutItem"
                                                size="4"
                                            >
                                                <lightning-input-field
                                                    value={NoConfirmedPrice}
                                                    field-name="NoConfirmedPrice__c"
                                                    data-field="NoConfirmedPrice"
                                                    onchange={dataChange}
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                    </lightning-record-edit-form>
@@ -431,100 +713,146 @@
                        <div style="padding: 10px">
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <lightning-record-edit-form object-api-name="Consumable_order__c" record-id={cocId}
                                    onload={handleLoad2}>
                                <lightning-record-edit-form
                                    object-api-name="Consumable_order__c"
                                    record-id={cocId}
                                    onload={handleLoad2}
                                >
                                    <!-- 出库单号 出库单状态 -->
                                    <lightning-layout multiple-rows="true">
                                        <template if:true={isSummonsFlag}>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item size="4">
                                                <lightning-output-field field-name="Name"
                                                    class="hehe-layoutItem"></lightning-output-field>
                                                <lightning-output-field
                                                    field-name="Name"
                                                    class="hehe-layoutItem"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item size="4">
                                                <lightning-output-field field-name="SummonsStatus_c__c"
                                                    class="hehe-layoutItem"></lightning-output-field>
                                                <lightning-output-field
                                                    field-name="SummonsStatus_c__c"
                                                    class="hehe-layoutItem"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </template>
                                    </lightning-layout>
                                    <!-- 目的   开票状态 -->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="SummonsForDirction__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="SummonsForDirction__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="Billed_Status__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="Billed_Status__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                    <!-- 二级经销商 -->
                                    <template if:true={isSummonsForDirctionTwoShow}>
                                    <template
                                        if:true={isSummonsForDirctionTwoShow}
                                    >
                                        <lightning-layout multiple-rows="true">
                                            <lightning-layout-item size="1"></lightning-layout-item>
                                            <lightning-layout-item
                                                size="1"
                                            ></lightning-layout-item>
                                            <lightning-layout-item size="4">
                                                <lightning-output-field field-name="Order_Dealer_Info__c"
                                                    class="hehe-layoutItem"></lightning-output-field>
                                                <lightning-output-field
                                                    field-name="Order_Dealer_Info__c"
                                                    class="hehe-layoutItem"
                                                ></lightning-output-field>
                                            </lightning-layout-item>
                                        </lightning-layout>
                                    </template>
                                    <!-- 客户名 发票-->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field class="hideHelpText"
                                                field-name="ShipmentAccount__c"></lightning-output-field>
                                            <lightning-output-field
                                                class="hideHelpText"
                                                field-name="ShipmentAccount__c"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <template if:true={isConInvoiceShow}>
                                            <lightning-layout-item size="4">
                                                <lightning-input-field data-field={ConInvoice_Code__c}
                                                    onchange={invoiceChange} field-name="ConInvoice_Code__c"
                                                    class="hehe-layoutItem"></lightning-input-field>
                                                <lightning-input-field
                                                    data-field={ConInvoice_Code__c}
                                                    onchange={invoiceChange}
                                                    field-name="ConInvoice_Code__c"
                                                    class="hehe-layoutItem"
                                                ></lightning-input-field>
                                            </lightning-layout-item>
                                        </template>
                                    </lightning-layout>
                                    <!-- 科室 出库金额 -->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="Order_ForCustomerText__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="Order_ForCustomerText__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="Shipment_total_amount__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="Shipment_total_amount__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                    <!-- 没有确定价格 -->
                                    <lightning-layout multiple-rows="true">
                                        <lightning-layout-item size="1"></lightning-layout-item>
                                        <lightning-layout-item
                                            size="1"
                                        ></lightning-layout-item>
                                        <lightning-layout-item size="4">
                                            <lightning-output-field field-name="NoConfirmedPrice__c"
                                                class="hehe-layoutItem"></lightning-output-field>
                                            <lightning-output-field
                                                field-name="NoConfirmedPrice__c"
                                                class="hehe-layoutItem"
                                            ></lightning-output-field>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                </lightning-record-edit-form>
@@ -540,61 +868,153 @@
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <lightning-layout multiple-rows>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label">消耗品名称</div>
                                            <lightning-input type="text" name="consumableName" label="消耗品名称"
                                                value={consumableName} variant="label-hidden" onchange={dataChange}
                                                data-field="consumableName"></lightning-input>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label" style="width:70px">第3分类</div>
                                            <lightning-combobox name="progress" label="第3分类" value={Category3}
                                                variant="label-hidden" options={category3Options} onchange={dataChange}
                                                data-field="Category3" style="min-width: 185px;"></lightning-combobox>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                            >
                                                消耗品名称
                                            </div>
                                            <lightning-input
                                                type="text"
                                                name="consumableName"
                                                label="消耗品名称"
                                                value={consumableName}
                                                variant="label-hidden"
                                                onchange={dataChange}
                                                data-field="consumableName"
                                            ></lightning-input>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label" style="width:70px">第4分类</div>
                                            <lightning-combobox name="progress" label="第4分类" value={Category4}
                                                variant="label-hidden" options={category4Options} onchange={dataChange}
                                                data-field="Category4" style="min-width: 185px;"></lightning-combobox>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                                style="width: 70px"
                                            >
                                                第3分类
                                            </div>
                                            <lightning-combobox
                                                name="progress"
                                                label="第3分类"
                                                value={Category3}
                                                variant="label-hidden"
                                                options={category3Options}
                                                onchange={dataChange}
                                                data-field="Category3"
                                                style="min-width: 160px"
                                            ></lightning-combobox>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <div class="slds-form-element__label" style="width:70px">第5分类</div>
                                            <lightning-combobox name="progress" label="第5分类" value={Category5}
                                                variant="label-hidden" onchange={dataChange} data-field="Category5"
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                                style="width: 70px"
                                            >
                                                第4分类
                                            </div>
                                            <lightning-combobox
                                                name="progress"
                                                label="第4分类"
                                                value={Category4}
                                                variant="label-hidden"
                                                options={category4Options}
                                                onchange={dataChange}
                                                data-field="Category4"
                                                style="min-width: 160px"
                                            ></lightning-combobox>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <div
                                                class="slds-form-element__label"
                                                style="width: 70px"
                                            >
                                                第5分类
                                            </div>
                                            <lightning-combobox
                                                name="progress"
                                                label="第5分类"
                                                value={Category5}
                                                variant="label-hidden"
                                                onchange={dataChange}
                                                data-field="Category5"
                                                options={category5Options}
                                                style="min-width: 185px;"></lightning-combobox>
                                                style="min-width: 160px"
                                            ></lightning-combobox>
                                        </div>
                                    </lightning-layout-item>
                                    <template if:true={hasHosPro}>
                                        <lightning-layout-item padding="around-small">
                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                <div class="slds-form-element__label">医院特价</div>
                                                <lightning-combobox name="progress" label="医院特价" value={outOutPattern}
                                                    variant="label-hidden" options={outOutPatternOptionList}
                                                    onchange={handleChange}></lightning-combobox>
                                        <lightning-layout-item
                                            padding="around-small"
                                            flexibility="auto"
                                        >
                                            <div
                                                class="slds-grid slds-grid_vertical-align-center"
                                            >
                                                <div
                                                    class="slds-form-element__label"
                                                >
                                                    医院特价
                                                </div>
                                                <lightning-combobox
                                                    name="progress"
                                                    label="医院特价"
                                                    value={outOutPattern}
                                                    variant="label-hidden"
                                                    options={outOutPatternOptionList}
                                                    onchange={handleChange}
                                                ></lightning-combobox>
                                            </div>
                                        </lightning-layout-item>
                                    </template>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <lightning-button label="检索" onclick={searchProductJs}></lightning-button>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <lightning-button
                                                label="检索"
                                                onclick={searchProductJs}
                                            ></lightning-button>
                                        </div>
                                    </lightning-layout-item>
                                    <lightning-layout-item padding="around-small">
                                        <div class="slds-grid slds-grid_vertical-align-center">
                                            <lightning-button label="清空" onclick={ClearJs}></lightning-button>
                                    <lightning-layout-item
                                        padding="around-small"
                                        flexibility="auto"
                                    >
                                        <div
                                            class="slds-grid slds-grid_vertical-align-center"
                                        >
                                            <lightning-button
                                                label="清空"
                                                onclick={ClearJs}
                                            ></lightning-button>
                                        </div>
                                    </lightning-layout-item>
                                </lightning-layout>
@@ -613,23 +1033,83 @@
                    <div style="padding: 10px">
                        <template if:true={EditAble}>
                            <template if:true={showTable}>
                                <c-lex-custom-lightning-datatable key-field="Id" data={data} columns={columns}
                                    onunitchange={handleUnitChange} onshipmentnumber={handleShipmentNumber}
                                    onshipmentunitprice={handleShipmentUnitPrice} onrowselection={getSelectedRows}
                                    selected-rows={selectedRows} style="word-wrap:break-word; word-break:break-all; ">
                                <c-lex-custom-lightning-datatable
                                    key-field="Id"
                                    data={data}
                                    columns={columns}
                                    onunitchange={handleUnitChange}
                                    onshipmentnumber={handleShipmentNumber}
                                    onshipmentunitprice={handleShipmentUnitPrice}
                                    onrowselection={getSelectedRows}
                                    selected-rows={selectedRows}
                                    default-sort-direction={defaultSortDirection}
                                    sorted-direction={sortDirection}
                                    sorted-by={sortedBy}
                                    onsort={onHandleSort}
                                    style="
                                        word-wrap: break-word;
                                        word-break: break-all;
                                    "
                                >
                                </c-lex-custom-lightning-datatable>
                            </template>
                            <c-paginator
                                onprevious={handlePrevious}
                                onnext={handleNext}
                                onpageschange={handlePageschange}
                                onfirst={handleFirst}
                                onlast={handleLast}
                                page-size-options={pageSizeOptions}
                                previous-button-disabled={previousButtonDisabled}
                                next-button-disabled={nextButtonDisabled}
                                record-start={recordStart}
                                record-end={recordEnd}
                                total-records={totalRecords}
                            ></c-paginator>
                        </template>
                        <template if:false={EditAble}>
                            <template if:true={showTable}>
                                <c-lex-custom-lightning-datatable hide-checkbox-column key-field="Id" data={data}
                                    columns={editColumns} onunitchange={handleUnitChange}
                                <c-lex-custom-lightning-datatable
                                    hide-checkbox-column
                                    key-field="Id"
                                    data={editData}
                                    columns={editColumns}
                                    onunitchange={handleUnitChange}
                                    onshipmentnumber={handleShipmentNumber}
                                    onshipmentunitprice={handleShipmentUnitPrice} onrowselection={getSelectedRows}
                                    selected-rows={selectedRows} style="word-wrap:break-word; word-break:break-all; ">
                                    onshipmentunitprice={handleShipmentUnitPrice}
                                    onrowselection={getSelectedRows}
                                    selected-rows={selectedRows}
                                    default-sort-direction={defaultSortDirection}
                                    sorted-direction={sortDirection}
                                    sorted-by={sortedBy}
                                    onsort={onHandleSort}
                                    style="
                                        word-wrap: break-word;
                                        word-break: break-all;
                                    "
                                >
                                </c-lex-custom-lightning-datatable>
                                <c-paginator
                                    onprevious={editHandlePrevious}
                                    onnext={editHandleNext}
                                    onpageschange={editHandlePageschange}
                                    onfirst={editHandleFirst}
                                    onlast={editHandleLast}
                                    page-size-options={pageSizeOptions}
                                    previous-button-disabled={previousButtonDisabled}
                                    next-button-disabled={nextButtonDisabled}
                                    record-start={recordStart}
                                    record-end={recordEnd}
                                    total-records={totalRecords}
                                ></c-paginator>
                            </template>
                        </template>
                        <template if:true={isEditShowSpinner}>
                            <lightning-spinner
                                alternative-text="Uploading now"
                            ></lightning-spinner>
                        </template>
                    </div>
                </div>
@@ -643,8 +1123,12 @@
                            </p>
                        </div>
                        <div style="padding: 10px">
                            <lightning-datatable key-field="id" data={consumableorderdetails2Records}
                                columns={consumableorderdetails2RecordsColumns} hide-checkbox-column>
                            <lightning-datatable
                                key-field="id"
                                data={consumableorderdetails2Records}
                                columns={consumableorderdetails2RecordsColumns}
                                hide-checkbox-column
                            >
                            </lightning-datatable>
                        </div>
                    </div>
@@ -662,7 +1146,10 @@
                            <div lwc:dom="manual" class="resultDiv"></div>
                            <div draggable="false">
                                <lightning-card title="">
                                    <lightning-layout multiple-rows="true" style="margin-top: -20px">
                                    <lightning-layout
                                        multiple-rows="true"
                                        style="margin-top: -20px"
                                    >
                                        <!-- <lightning-layout-item size="12">
                                            <lightning-input label="" name="file uploader" onchange={handleFilesChange}
                                                type="file" accept={acceptedType}></lightning-input><br />
@@ -676,16 +1163,27 @@
                                        </lightning-layout-item> -->
                                        <lightning-layout-item size="5">
                                        </lightning-layout-item>
                                        <lightning-layout-item padding="around-small">
                                            <lightning-button label='上传附件' onclick={uploadOrder}></lightning-button>
                                        <lightning-layout-item
                                            padding="around-small"
                                        >
                                            <lightning-button
                                                label="上传附件"
                                                onclick={uploadOrder}
                                            ></lightning-button>
                                        </lightning-layout-item>
                                    </lightning-layout>
                                    <template if:true={showLoadingSpinner}>
                                        <lightning-spinner alternative-text="Uploading now"></lightning-spinner>
                                        <lightning-spinner
                                            alternative-text="Uploading now"
                                        ></lightning-spinner>
                                    </template>
                                    <footer style="margin-top: 20px">
                                        <lightning-datatable key-field="id" data={fileData} columns={fileColumns}
                                            hide-checkbox-column>
                                        <lightning-datatable
                                            key-field="id"
                                            data={fileData}
                                            columns={fileColumns}
                                            hide-checkbox-column
                                        >
                                        </lightning-datatable>
                                    </footer>
                                </lightning-card>
@@ -707,66 +1205,152 @@
                        <div lwc:dom="manual" class="resultDiv"></div>
                        <div draggable="false">
                            <lightning-layout multiple-rows="true">
                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                <lightning-layout-item
                                    class="hehe-layoutItem"
                                    size="4"
                                >
                                </lightning-layout-item>
                                <template if:true={isSales}>
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                        <lightning-button label="销售" onclick={SaveP}
                                            style="margin-top:-10px"></lightning-button>
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                        <lightning-button
                                            label="销售"
                                            onclick={SaveP}
                                            style="margin-top: -10px"
                                        ></lightning-button>
                                    </lightning-layout-item>
                                </template>
                                <template if:false={isSales}>
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                        <lightning-button label="出货" onclick={SaveE}></lightning-button>
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                        <lightning-button
                                            label="出货"
                                            onclick={SaveE}
                                        ></lightning-button>
                                    </lightning-layout-item>
                                </template>
                                <lightning-layout-item class="hehe-layoutItem" size="4">
                                <lightning-layout-item
                                    class="hehe-layoutItem"
                                    size="4"
                                >
                                </lightning-layout-item>
                            </lightning-layout>
                            <template if:true={isShowInformation}>
                                <div class="borderCss" style="margin-top: 5px;">
                                <div class="borderCss" style="margin-top: 5px">
                                    <div class="headerDorderCss">
                                        <p style="font-size: 16px">
                                            <strong>出库单信息</strong>
                                        </p>
                                    </div>
                                    <div style="padding: 10px">
                                        <div lwc:dom="manual" class="resultDiv"></div>
                                        <div
                                            lwc:dom="manual"
                                            class="resultDiv"
                                        ></div>
                                        <div draggable="false">
                                            <lightning-record-edit-form object-api-name="Consumable_order__c"
                                                record-id={cocId} onload={handleLoad2}>
                                                <lightning-layout multiple-rows="true">
                                                    <lightning-layout-item size="3" padding="around-small">
                                            <lightning-record-edit-form
                                                object-api-name="Consumable_order__c"
                                                record-id={cocId}
                                                onload={handleLoad2}
                                            >
                                                <lightning-layout
                                                    multiple-rows="true"
                                                >
                                                    <lightning-layout-item
                                                        size="3"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field field-name="Name"></lightning-output-field> -->
                                                        <div class="slds-grid slds-grid_vertical-align-center">
                                                            <div class="slds-form-element__label" style="padding: 0px;">出库单号:</div>
                                                            <lightning-output-field field-name="Name" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                出库单号:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="Name"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                        </div>
                                                    </lightning-layout-item>
                                                    <lightning-layout-item size="4" padding="around-small">
                                                    <lightning-layout-item
                                                        size="4"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field
                                                            field-name="ShipmentAccount__c" class="hideHelpText"></lightning-output-field> -->
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label" style="padding: 0px;">客户名:</div>
                                                                <lightning-output-field field-name="ShipmentAccount__c" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                客户名:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="ShipmentAccount__c"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                        </div>
                                                    </lightning-layout-item>
                                                    <lightning-layout-item size="2" padding="around-small">
                                                    <lightning-layout-item
                                                        size="2"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field
                                                            field-name="Order_ForCustomerText__c"></lightning-output-field> -->
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label" style="padding: 0px;">科室:</div>
                                                                <lightning-output-field field-name="Order_ForCustomerText__c" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                科室:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="Order_ForCustomerText__c"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                        </div>
                                                    </lightning-layout-item>
                                                    <lightning-layout-item size="2" padding="around-small">
                                                    <lightning-layout-item
                                                        size="2"
                                                        padding="around-small"
                                                    >
                                                        <!-- <lightning-output-field
                                                            field-name="SummonsForDirction__c"></lightning-output-field> -->
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label" style="padding: 0px;">目的:</div>
                                                                <lightning-output-field field-name="SummonsForDirction__c" variant="label-hidden"></lightning-output-field>
                                                        <div
                                                            class="slds-grid slds-grid_vertical-align-center"
                                                        >
                                                            <div
                                                                class="slds-form-element__label"
                                                                style="
                                                                    padding: 0px;
                                                                "
                                                            >
                                                                目的:
                                                            </div>
                                                            <lightning-output-field
                                                                field-name="SummonsForDirction__c"
                                                                variant="label-hidden"
                                                            ></lightning-output-field>
                                                        </div>
                                                    </lightning-layout-item>
                                                </lightning-layout>
                                            </lightning-record-edit-form>
@@ -782,31 +1366,63 @@
                                            </p>
                                        </div>
                                        <div style="padding: 10px">
                                            <div lwc:dom="manual" class="resultDiv"></div>
                                            <div
                                                lwc:dom="manual"
                                                class="resultDiv"
                                            ></div>
                                            <div draggable="false">
                                                <lightning-record-edit-form object-api-name="Consumable_order__c"
                                                    record-id={cocId}>
                                                    <lightning-layout multiple-rows="true">
                                                        <lightning-layout-item size="1"></lightning-layout-item>
                                                        <lightning-layout-item padding="around-small">
                                                <lightning-record-edit-form
                                                    object-api-name="Consumable_order__c"
                                                    record-id={cocId}
                                                >
                                                    <lightning-layout
                                                        multiple-rows="true"
                                                    >
                                                        <lightning-layout-item
                                                            size="1"
                                                        ></lightning-layout-item>
                                                        <lightning-layout-item
                                                            padding="around-small"
                                                        >
                                                            <!-- <lightning-textarea name="Barcode" label="BarCode号"
                                                                onchange={dataChange} variant="label-inline"
                                                                data-field="Barcode"
                                                                value={Barcode}></lightning-textarea> -->
                                                            <div class="slds-grid">
                                                                <div class="slds-form-element__label">BarCode号</div>
                                                                <lightning-textarea name="Barcode" label="BarCode号"
                                                                    onchange={dataChange} variant="label-hidden"
                                                                    data-field="Barcode" value={Barcode}
                                                                    style="min-width: 400px;"></lightning-textarea>
                                                            <div
                                                                class="slds-grid"
                                                            >
                                                                <div
                                                                    class="slds-form-element__label"
                                                                >
                                                                    BarCode号
                                                                </div>
                                                                <lightning-textarea
                                                                    name="Barcode"
                                                                    label="BarCode号"
                                                                    onchange={dataChange}
                                                                    variant="label-hidden"
                                                                    data-field="Barcode"
                                                                    value={Barcode}
                                                                    style="
                                                                        min-width: 400px;
                                                                    "
                                                                ></lightning-textarea>
                                                            </div>
                                                        </lightning-layout-item>
                                                        <lightning-layout-item padding="around-small">
                                                            <div class="slds-grid slds-grid_vertical-align-center">
                                                                <div class="slds-form-element__label">
                                                                    <lightning-button label="确认"
                                                                        onclick={SalesearchProductJs}></lightning-button>
                                                        <lightning-layout-item
                                                            padding="around-small"
                                                        >
                                                            <div
                                                                class="slds-grid slds-grid_vertical-align-center"
                                                            >
                                                                <div
                                                                    class="slds-form-element__label"
                                                                >
                                                                    <lightning-button
                                                                        label="确认"
                                                                        onclick={SalesearchProductJs}
                                                                    ></lightning-button>
                                                                </div>
                                                            </div>
                                                        </lightning-layout-item>
@@ -824,11 +1440,21 @@
                                        </p>
                                    </div>
                                    <div style="padding: 10px">
                                        <div lwc:dom="manual" class="resultDiv"></div>
                                        <div
                                            lwc:dom="manual"
                                            class="resultDiv"
                                        ></div>
                                        <div draggable="false">
                                            <lightning-datatable key-field="id" data={salesData} columns={salesColumns}
                                            <lightning-datatable
                                                key-field="id"
                                                data={salesData}
                                                columns={salesColumns}
                                                hide-checkbox-column
                                                style="word-wrap:break-word; word-break:break-all; ">
                                                style="
                                                    word-wrap: break-word;
                                                    word-break: break-all;
                                                "
                                            >
                                            </lightning-datatable>
                                        </div>
                                    </div>
@@ -841,30 +1467,58 @@
                                        </p>
                                    </div>
                                    <div style="padding: 10px">
                                        <div lwc:dom="manual" class="resultDiv"></div>
                                        <div
                                            lwc:dom="manual"
                                            class="resultDiv"
                                        ></div>
                                        <div draggable="false">
                                            <lightning-datatable key-field="id" data={salesErrorData}
                                                columns={salesErrorColumns} hide-checkbox-column
                                                style="word-wrap:break-word; word-break:break-all; ">
                                            <lightning-datatable
                                                key-field="id"
                                                data={salesErrorData}
                                                columns={salesErrorColumns}
                                                hide-checkbox-column
                                                style="
                                                    word-wrap: break-word;
                                                    word-break: break-all;
                                                "
                                            >
                                            </lightning-datatable>
                                        </div>
                                    </div>
                                </div>
                                <lightning-layout multiple-rows="true">
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                    </lightning-layout-item>
                                    <template if:true={isSales}>
                                        <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-button label="销售" onclick={SaveP}></lightning-button>
                                        <lightning-layout-item
                                            class="hehe-layoutItem"
                                            size="4"
                                        >
                                            <lightning-button
                                                label="销售"
                                                onclick={SaveP}
                                            ></lightning-button>
                                        </lightning-layout-item>
                                    </template>
                                    <template if:false={isSales}>
                                        <lightning-layout-item class="hehe-layoutItem" size="4">
                                            <lightning-button label="出货" onclick={SaveE}></lightning-button>
                                        <lightning-layout-item
                                            class="hehe-layoutItem"
                                            size="4"
                                        >
                                            <lightning-button
                                                label="出货"
                                                onclick={SaveE}
                                            ></lightning-button>
                                        </lightning-layout-item>
                                    </template>
                                    <lightning-layout-item class="hehe-layoutItem" size="4">
                                    <lightning-layout-item
                                        class="hehe-layoutItem"
                                        size="4"
                                    >
                                    </lightning-layout-item>
                                </lightning-layout>
                            </template>
@@ -874,4 +1528,4 @@
            </template>
        </div>
    </div>
</template>
</template>
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.js
@@ -1,414 +1,418 @@
import { LightningElement, wire, api, track } from "lwc";
import init from "@salesforce/apex/LexSummonsCreatController.init";
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import searchConsumableorderdetails from "@salesforce/apex/LexSummonsCreatController.searchConsumableorderdetails";
import PraseToPDF from "@salesforce/apex/LexSummonsCreatController.PraseToPDF";
import apexSearch from "@salesforce/apex/LexSummonsCreatController.search";
import saveFile from "@salesforce/apex/LexSummonsCreatController.saveFile";
import getFiles from "@salesforce/apex/LexSummonsCreatController.getFiles";
import GoodsDelivery from "@salesforce/apex/LexSummonsCreatController.GoodsDelivery";
import DelConsumable from "@salesforce/apex/LexSummonsCreatController.DelConsumable";
import categoryAllload from "@salesforce/apex/LexSummonsCreatController.categoryAllload";
import categoryload from "@salesforce/apex/LexSummonsCreatController.categoryload";
import GoodsDeliveryInit from "@salesforce/apex/LexSaleOrderController.GoodsDeliveryInit";
import SearchPro from "@salesforce/apex/LexSaleOrderController.SearchPro";
import ProdElivery from "@salesforce/apex/LexSaleOrderController.ProdElivery";
import ProSale from "@salesforce/apex/LexSaleOrderController.ProSale";
import save from "@salesforce/apex/LexSummonsCreatController.save";
import OPPORTUNITY_OBJECT from "@salesforce/schema/Consumable_Orderdetails__c";
import { getObjectInfo } from "lightning/uiObjectInfoApi";
import hospitalInit from "@salesforce/apex/lexSearchAgencyHospitalController.init";
import serContact from "@salesforce/apex/lexSearchAgencyHospitalController.serContact";
import { NavigationMixin } from "lightning/navigation";
import { LightningElement, wire, api, track } from 'lwc';
import init from '@salesforce/apex/LexSummonsCreatController.init';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import searchConsumableorderdetails from '@salesforce/apex/LexSummonsCreatController.searchConsumableorderdetails';
import PraseToPDF from '@salesforce/apex/LexSummonsCreatController.PraseToPDF';
import apexSearch from '@salesforce/apex/LexSummonsCreatController.search';
import saveFile from '@salesforce/apex/LexSummonsCreatController.saveFile';
import getFiles from '@salesforce/apex/LexSummonsCreatController.getFiles';
import GoodsDelivery from '@salesforce/apex/LexSummonsCreatController.GoodsDelivery';
import DelConsumable from '@salesforce/apex/LexSummonsCreatController.DelConsumable';
import categoryAllload from '@salesforce/apex/LexSummonsCreatController.categoryAllload';
import categoryload from '@salesforce/apex/LexSummonsCreatController.categoryload';
import GoodsDeliveryInit from '@salesforce/apex/LexSaleOrderController.GoodsDeliveryInit';
import SearchPro from '@salesforce/apex/LexSaleOrderController.SearchPro';
import ProdElivery from '@salesforce/apex/LexSaleOrderController.ProdElivery';
import ProSale from '@salesforce/apex/LexSaleOrderController.ProSale';
import save from '@salesforce/apex/LexSummonsCreatController.save';
import OPPORTUNITY_OBJECT from '@salesforce/schema/Consumable_Orderdetails__c';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import hospitalInit from '@salesforce/apex/lexSearchAgencyHospitalController.init';
import serContact from '@salesforce/apex/lexSearchAgencyHospitalController.serContact';
import { NavigationMixin } from 'lightning/navigation';
export default class LexSummonsCreat extends NavigationMixin(LightningElement) {
    @track isShowSpinner = true;
    @track isEditShowSpinner = false;
    @track showResults = true;
    @track results = [
        {
            Id: "1",
            Name: "z",
            Id: '1',
            Name: 'z'
        },
        {
            Id: "2",
            Name: "h",
            Id: '2',
            Name: 'h'
        },
        {
            Id: "3",
            Name: "j",
        },
            Id: '3',
            Name: 'j'
        }
    ];
    @track COLS = [
        {
            label: "Account Name",
            type: "customName",
            label: 'Account Name',
            type: 'customName',
            typeAttributes: {
                accountName: { fieldName: "Name" },
            },
        },
                accountName: { fieldName: 'Name' }
            }
        }
    ];
    @track columns = [
        {
            label: "消耗品名称",
            fieldName: "Name__c",
            //hideDefaultActions: true,
            label: '消耗品名称',
            fieldName: 'Name__c',
            hideDefaultActions: true,
            wrapText: true,
            //initialWidth : 100,
            initialWidth: 150,
            sortable: true
        },
        {
            label: "规格",
            fieldName: "packinglist",
            label: '规格',
            fieldName: 'packinglist',
            //initialWidth : 50,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "CFDA状态",
            fieldName: "SFDA_Status__c",
            label: 'CFDA状态',
            fieldName: 'SFDA_Status__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证编码号",
            fieldName: "approbation_No",
            label: '注册证编码号',
            fieldName: 'approbation_No',
            //initialWidth : 150,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证效期",
            label: '注册证效期',
            //initialWidth : 100,
            wrapText: true,
            fieldName: "expiration_Date",
            hideDefaultActions: true,
            fieldName: 'expiration_Date',
            hideDefaultActions: true
        },
        {
            label: "第3分类",
            fieldName: "Category3__c",
            label: '第3分类',
            fieldName: 'Category3__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第4分类",
            fieldName: "Category4__c",
            label: '第4分类',
            fieldName: 'Category4__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第5分类",
            fieldName: "Category5__c",
            label: '第5分类',
            fieldName: 'Category5__c',
            //initialWidth : 100,
            wrapText: true,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "单位",
            type: "customUnit",
            label: '单位',
            type: 'customUnit',
            //initialWidth : 100,
            hideDefaultActions: true,
            typeAttributes: {
                unitValue: { fieldName: "unitValue" },
                unitOptions: { fieldName: "unitOptions" },
                recordId: { fieldName: "recordId" },
            },
                unitValue: { fieldName: 'unitValue' },
                unitOptions: { fieldName: 'unitOptions' },
                recordId: { fieldName: 'recordId' }
            }
        },
        {
            label: "出货数量",
            type: "customShipment",
            label: '出货数量',
            type: 'customShipment',
            //initialWidth : 150,
            hideDefaultActions: true,
            typeAttributes: {
                recordId: { fieldName: "recordId" },
                shipmentNumber: { fieldName: "shipmentNumber" },
            },
                recordId: { fieldName: 'recordId' },
                shipmentNumber: { fieldName: 'shipmentNumber' }
            }
        },
        {
            label: "出货单价(元)",
            type: "customShipmentUnitPrice",
            label: '出货单价(元)',
            type: 'customShipmentUnitPrice',
            //initialWidth : 150,
            hideDefaultActions: true,
            typeAttributes: {
                recordId: { fieldName: "recordId" },
                shippingUnitPrice: { fieldName: "shippingUnitPrice" },
            },
                recordId: { fieldName: 'recordId' },
                shippingUnitPrice: { fieldName: 'shippingUnitPrice' }
            }
        },
        {
            label: "出货金额(元)",
            type: "customShipmentAmount",
            label: '出货金额(元)',
            type: 'customShipmentAmount',
            //initialWidth : 120,
            hideDefaultActions: true,
            typeAttributes: {
                shipmentAmount: { fieldName: "shipmentAmount" },
            },
                shipmentAmount: { fieldName: 'shipmentAmount' }
            }
        },
        {
            label: "有效期内库存(盒)",
            fieldName: "Boxnumber",
            label: '有效期内库存(盒)',
            fieldName: 'Boxnumber',
            //initialWidth : 120,
            wrapText: true,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "有效期内库存(个)",
            fieldName: "Piecenumber",
            label: '有效期内库存(个)',
            fieldName: 'Piecenumber',
            //initialWidth : 120,
            wrapText: true,
            hideDefaultActions: true,
        },
            hideDefaultActions: true
        }
    ];
    @track editColumns = [
        {
            label: "消耗品名称",
            fieldName: "Name__c",
            label: '消耗品名称',
            fieldName: 'Name__c',
            hideDefaultActions: true,
            initialWidth: 250,
            wrapText: true,
            sortable: true
        },
        {
            label: "规格",
            fieldName: "packinglist",
            label: '规格',
            fieldName: 'packinglist',
            initialWidth: 50,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "CFDA状态",
            fieldName: "SFDA_Status__c",
            label: 'CFDA状态',
            fieldName: 'SFDA_Status__c',
            initialWidth: 100,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证编码号",
            fieldName: "approbation_No",
            label: '注册证编码号',
            fieldName: 'approbation_No',
            initialWidth: 150,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "注册证效期",
            label: '注册证效期',
            initialWidth: 100,
            fieldName: "expiration_Date",
            hideDefaultActions: true,
            fieldName: 'expiration_Date',
            hideDefaultActions: true
        },
        {
            label: "第3分类",
            fieldName: "Category3__c",
            label: '第3分类',
            fieldName: 'Category3__c',
            initialWidth: 100,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第4分类",
            fieldName: "Category4__c",
            label: '第4分类',
            fieldName: 'Category4__c',
            initialWidth: 100,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "第5分类",
            fieldName: "Category5__c",
            label: '第5分类',
            fieldName: 'Category5__c',
            initialWidth: 100,
            hideDefaultActions: true,
            sortable: true,
            sortable: true
        },
        {
            label: "单位",
            fieldName: "Box_Piece__c",
            label: '单位',
            fieldName: 'Box_Piece__c',
            initialWidth: 100,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "出货数量",
            fieldName: "Shipment_Count__c",
            label: '出货数量',
            fieldName: 'Shipment_Count__c',
            initialWidth: 150,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "出货单价(元)",
            fieldName: "Shipment_amount__c",
            type: "number",
            label: '出货单价(元)',
            fieldName: 'Shipment_amount__c',
            type: 'number',
            typeAttributes: {
                minimumFractionDigits: 2,
                minimumFractionDigits: 2
            },
            initialWidth: 150,
            hideDefaultActions: true,
        },
            hideDefaultActions: true
        }
    ];
    @track editData = [];
    @track hospitalList = [];
    @track hospitalColumns = [
        {
            label: "医院名称",
            fieldName: "Name",
            label: '医院名称',
            fieldName: 'Name',
            initialWidth: 400,
            hideDefaultActions: true,
            hideDefaultActions: true
        },
        {
            label: "省份",
            fieldName: "stateMasterName",
            hideDefaultActions: true,
            label: '省份',
            fieldName: 'stateMasterName',
            hideDefaultActions: true
        },
        {
            label: "选择",
            fieldName: "Id1",
            type: "button",
            label: '选择',
            fieldName: 'Id1',
            type: 'button',
            hideDefaultActions: true,
            typeAttributes: {
                label: "选择",
                name: "Id2",
                size: 1,
            },
        },
                label: '选择',
                name: 'Id2',
                size: 1
            }
        }
    ];
    @track accountid = "";
    @track accountid = '';
    @track consumableproductdetailsRecords = [];
    @track SummonsStatus = "";
    @track ESetid = "";
    @track statusEdit = "";
    @track SummonsStatus = '';
    @track ESetid = '';
    @track statusEdit = '';
    @track cocLwc = {};
    @track selectedRows = [];
    @track ConsumableOut_report = "";
    @track ConsumableOut_report = '';
    @track isMutualTransferGoods = false;
    @track Barcode = "";
    @track Barcode = '';
    @track summonsForDirction = '';
    @track consumableorderdetails2RecordsColumns = [
        {
            label: "消耗品名称",
            fieldName: "ProdName",
            hideDefaultActions: true,
            label: '消耗品名称',
            fieldName: 'ProdName',
            hideDefaultActions: true
        },
        {
            label: "批次号",
            fieldName: "orderdetails2SerialLotNo__c",
            hideDefaultActions: true,
            label: '批次号',
            fieldName: 'orderdetails2SerialLotNo__c',
            hideDefaultActions: true
        },
        {
            label: "管理编码",
            fieldName: "orderdetails2TracingCode__c",
            hideDefaultActions: true,
            label: '管理编码',
            fieldName: 'orderdetails2TracingCode__c',
            hideDefaultActions: true
        },
        {
            label: "使用期限",
            fieldName: "orderdetails2Sterilization_limit__c",
            hideDefaultActions: true,
        },
            label: '使用期限',
            fieldName: 'orderdetails2Sterilization_limit__c',
            hideDefaultActions: true
        }
    ];
    @track consumableorderdetails2Records = [];
    //出货/销售
    @track salesColumns = [
        {
            label: "消耗品订单",
            fieldName: "Consumable_order_minor__c",
            label: '消耗品订单',
            fieldName: 'Consumable_order_minor__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品明细2名称",
            fieldName: "orderdetails2NameUrl",
            type: "url",
            label: '消耗品明细2名称',
            fieldName: 'orderdetails2NameUrl',
            type: 'url',
            typeAttributes: {
                label: { fieldName: "orderdetails2Name" },
                target: "_blank",
                label: { fieldName: 'orderdetails2Name' },
                target: '_blank'
            },
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 240
        },
        {
            label: "单位",
            fieldName: "Box_Piece__c",
            label: '单位',
            fieldName: 'Box_Piece__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品名称",
            fieldName: "ProdName",
            label: '消耗品名称',
            fieldName: 'ProdName',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "发货日期",
            fieldName: "Deliver_date__c",
            label: '发货日期',
            fieldName: 'Deliver_date__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "BarCode",
            fieldName: "Bar_Code__c",
            label: 'BarCode',
            fieldName: 'Bar_Code__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 500
        },
        {
            label: "使用期限",
            fieldName: "Sterilization_limit__c",
            label: '使用期限',
            fieldName: 'Sterilization_limit__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "出货数量",
            fieldName: "outboundCount",
            label: '出货数量',
            fieldName: 'outboundCount',
            hideDefaultActions: true,
            wrapText: true,
        },
            wrapText: true
        }
    ];
    @track salesData = [];
    @track salesErrorColumns = [
        {
            label: "消耗品订单",
            fieldName: "Consumable_order_minor__c",
            label: '消耗品订单',
            fieldName: 'Consumable_order_minor__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品明细2名称",
            fieldName: "orderdetails2Name",
            label: '消耗品明细2名称',
            fieldName: 'orderdetails2Name',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "消耗品名称",
            fieldName: "ProdName",
            label: '消耗品名称',
            fieldName: 'ProdName',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "单位",
            fieldName: "Box_Piece__c",
            label: '单位',
            fieldName: 'Box_Piece__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "BarCode",
            fieldName: "Bar_Code__c",
            hideDefaultActions: true,
            label: 'BarCode',
            fieldName: 'Bar_Code__c',
            hideDefaultActions: true
        },
        {
            label: "使用期限",
            fieldName: "Sterilization_limit__c",
            label: '使用期限',
            fieldName: 'Sterilization_limit__c',
            hideDefaultActions: true,
            wrapText: true,
            wrapText: true
        },
        {
            label: "错误原因",
            fieldName: "ErrorReason",
            label: '错误原因',
            fieldName: 'ErrorReason',
            hideDefaultActions: true,
            wrapText: true,
        },
            wrapText: true
        }
    ];
    @track salesErrorData = [];
    @track salesAccountName = "";
    @track salesUserWorkLocation = "";
    @track salesAccountid = "";
    @track salesAccountName = '';
    @track salesUserWorkLocation = '';
    @track salesAccountid = '';
    @track salesOrderdetails = [];
    @track salesCoc = {};
    @track salesOrderpieceorboxMap;
@@ -441,55 +445,55 @@
    @track isDeleteDisabled = false;
    //出库单信息
    @track cocId = "";
    @track cocId = '';
    @track EditAble = false;
    @track summonsStatusPriceNotDetermined = false;
    @track isSummonsForDirctionTwoShow = false;
    @track isSummonsFlag = false;
    @track isConInvoiceShow = false;
    @track sumPrice = "";
    @track sumPrice = '';
    @track isSearchShow = false;
    @track Existarrive = false;
    @track Category3 = "";
    @track Category3 = '';
    @track category3Options = [];
    @track Category4 = "";
    @track Category4 = '';
    @track category4Options = [];
    @track Category5 = "";
    @track Category5 = '';
    @track category5Options = [];
    //发票id
    @track invoiceId = '';
    //二级经销商
    @track secondaryDistributor = "";
    @track secondaryDistributor = '';
    @track secondaryDistributorOptions = [];
    @track isDisabledSecondaryDistributor = false;
    //经销商录入
    @track ForDealerText = "";
    @track ForDealerText = '';
    @track isDisabledForDealerText = false;
    //客户名
    @track isModalOpen = false;
    @track HospitalName = "";
    @track searchHospitalName = "";
    @track OECId = "";
    @track HospitalName = '';
    @track searchHospitalName = '';
    @track OECId = '';
    @track isDisabledHospitalName = false;
    //科室
    @track ForCustomerText = "";
    @track ForCustomerText = '';
    @track isDisabledForCustomerText = false;
    //没有确定价格
    @track NoConfirmedPrice = false;
    //消耗品名称
    @track consumableName = "";
    @track consumableName = '';
    @track agencyProType = "";
    @track accountName = "";
    @track userWorkLocation = "";
    @track agencyProType = '';
    @track accountName = '';
    @track userWorkLocation = '';
    @track OutPattern__c = false;
    @track outOutPattern = "";
    @track outOutPattern = '';
    //出库单明细
    @track showTable = false;
@@ -497,37 +501,59 @@
    @track isSelectShow = false;
    @track hidecheckboxcolumn = false;
    @track is345Show = false;
    @track arriveorder = "";
    @track arriveorder = '';
    @track hasHosPro = false;
    @track InvoiceProNotLabel = "";
    @track RrturnProLabel = "";
    @track InvoicedLabel = "";
    @track InvoiceProNotLabel = '';
    @track RrturnProLabel = '';
    @track InvoicedLabel = '';
    @track outOutPatternOptionList = [];
    //文件上传
    @track showLoadingSpinner = false;
    @track UploadFile = "Upload File";
    @track fileName = "";
    @track UploadFile = 'Upload File';
    @track fileName = '';
    @track fileData = [];
    @track fileColumns = [
        {
            label: "标题",
            fieldName: "url",
            type: "url",
            typeAttributes: { label: { fieldName: "Title" }, target: "_blank" },
            hideDefaultActions: true,
            label: '标题',
            fieldName: 'url',
            type: 'url',
            typeAttributes: { label: { fieldName: 'Title' }, target: '_blank' },
            hideDefaultActions: true
        },
        {
            label: "创建人",
            fieldName: "CreatedByName",
            hideDefaultActions: true,
        },
            label: '创建人',
            fieldName: 'CreatedByName',
            hideDefaultActions: true
        }
    ];
    filesUploaded = [];
    fileContents;
    fileReader;
    content;
    MAX_FILE_SIZE = 1500000;
    //分页start
    //@track sortBy = "";
    //@track sortDirection = "asc";
    defaultSortDirection = 'asc';
    sortDirection = 'asc';
    sortedBy;
    @track pageSize = 5;
    error;
    records;
    currentPageToken = 0;
    nextPageToken = this.pageSize;
    @track totalRecords = 0;
    @track loader = false;
    @track pageNumber = 1;
    @track paginationVisibility = false;
    @track totalPages = 1;
    pageSizeOptions = [5, 10, 25, 50, 75, 100];
    @track recordStart = 0;
    @track recordEnd = 0;
    //end
    @track SearchDone = '';
    //InvoiceProNotLabel    RrturnProLabel  InvoicedLabel
    @wire(getObjectInfo, { objectApiName: OPPORTUNITY_OBJECT })
@@ -536,16 +562,16 @@
            this.InvoiceProNotLabel = data.fields.InvoiceProNot_count__c.label;
            this.RrturnProLabel = data.fields.RrturnPro_count__c.label;
            this.InvoicedLabel = data.fields.Invoiced_Procount__c.label;
            console.log("this.InvoiceProNotLabel = " + this.InvoiceProNotLabel);
            console.log("this.RrturnProLabel = " + this.RrturnProLabel);
            console.log("this.InvoicedLabel = " + this.InvoicedLabel);
            console.log('this.InvoiceProNotLabel = ' + this.InvoiceProNotLabel);
            console.log('this.RrturnProLabel = ' + this.RrturnProLabel);
            console.log('this.InvoicedLabel = ' + this.InvoicedLabel);
        }
    }
    //获取链接参数
    getQueryString(name) {
        console.log("getQueryString name " + name);
        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        console.log('getQueryString name ' + name);
        let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        let r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return decodeURIComponent(r[2]);
@@ -553,414 +579,577 @@
        return null;
    }
    connectedCallback() {
        console.log("connectedCallback LexSummonsCreat");
        this.ESetid = this.getQueryString("ESetid");
        this.ESetid = this.ESetid == null ? "" : this.ESetid;
        console.log('connectedCallback LexSummonsCreat');
        this.ESetid = this.getQueryString('ESetid');
        this.ESetid = this.ESetid == null ? '' : this.ESetid;
        //statusEdit
        this.statusEdit = this.getQueryString("KeyWords");
        this.statusEdit = this.statusEdit == null ? "" : this.statusEdit;
        console.log("this.ESetid = " + this.ESetid);
        console.log("this.statusEdit = " + this.statusEdit);
        if (this.ESetid == "") {
        this.statusEdit = this.getQueryString('KeyWords');
        this.statusEdit = this.statusEdit == null ? '' : this.statusEdit;
        console.log('this.ESetid = ' + this.ESetid);
        console.log('this.statusEdit = ' + this.statusEdit);
        if (this.ESetid == '') {
            this.isShowInformation = false;
        }
        console.log("init LexSummonsCreat");
        console.log('init LexSummonsCreat');
        init({
            ESetidJs: this.ESetid,
            statusEdit: this.statusEdit
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            statusEdit: this.statusEdit,
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
            if (r.status == "Success") {
                if (r.status == 'Success') {
                    //分页
                    console.log(
                        'r.entity.paginatedAccounts = ' +
                            JSON.stringify(r.entity.paginatedAccounts)
                    );
                    this.nextPageToken =
                        r.entity.paginatedAccounts.nextPageToken;
                    this.totalRecords = r.entity.paginatedAccounts.totalRecords;
                    this.recordStart = r.entity.paginatedAccounts.recordStart;
                    this.recordEnd = r.entity.paginatedAccounts.recordEnd;
                    this.totalPages = Math.ceil(
                        r.entity.paginatedAccounts.totalRecords / this.pageSize
                    );
                    console.log('this.totalPages = ' + this.totalPages);
                this.OECId = r.entity.HospitalInfo == null ? '' : r.entity.HospitalInfo;
                console.log("this.OECId = " + this.OECId);
                this.ConsumableOut_report = r.entity.ConsumableOut_report;
                console.log("this.ConsumableOut_report = " + this.ConsumableOut_report);
                this.accountid = r.entity.accountid;
                this.consumableproductdetailsRecords =
                    r.entity.consumableproductdetailsRecords;
                this.accountName = r.entity.accountName;
                this.agencyProType = r.entity.agencyProType;
                this.accountName = r.entity.accountName;
                this.userWorkLocation = r.entity.userWorkLocation;
                this.EditAble = r.entity.EditAble;
                this.consumableorderdetails2Records =
                    r.entity.consumableorderdetails2Records;
                for (var i in this.consumableorderdetails2Records) {
                    this.consumableorderdetails2Records[i]["ProdName"] =
                        this.consumableorderdetails2Records[i].Prod.Name;
                    this.consumableorderdetails2Records[i][
                        "orderdetails2SerialLotNo__c"
                    ] =
                        this.consumableorderdetails2Records[i].orderdetails2.SerialLotNo__c;
                    this.consumableorderdetails2Records[i][
                        "orderdetails2TracingCode__c"
                    ] =
                        this.consumableorderdetails2Records[i].orderdetails2.TracingCode__c;
                    this.consumableorderdetails2Records[i][
                        "orderdetails2Sterilization_limit__c"
                    ] =
                        this.consumableorderdetails2Records[
                            i
                        ].orderdetails2.Sterilization_limit__c;
                }
                this.isShowOutboundProductDetails =
                    r.entity.consumableorderdetails2Count > 0 ? true : false;
                console.log("this.agencyProType = " + this.agencyProType);
                console.log("this.EditAble = " + this.EditAble);
                //查询附件
                if (!this.EditAble) this.getFiles();
                //第3分类
                for (var key in r.entity.categoryOptionMap) {
                    let object = {};
                    object["label"] = r.entity.categoryOptionMap[key];
                    object["value"] = key;
                    this.category3Options.push(object);
                }
                console.log("this.category3Options = " + JSON.stringify(this.category3Options));
                //第4分类
                for (var key in r.entity.category4OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category4OptionMap[key];
                    object["value"] = key;
                    this.category4Options.push(object);
                }
                console.log("this.category4Options = " + this.category4Options);
                //第5分类
                for (var key in r.entity.category5OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category5OptionMap[key];
                    object["value"] = key;
                    this.category5Options.push(object);
                }
                console.log("this.category5Options = " + this.category5Options);
                this.data = r.entity.pageRecords;
                console.log("this.data start = " + JSON.stringify(this.data));
                for (var i in this.data) {
                    let unitOptions = [];
                    for (var key in this.data[i].boxorpieceMap) {
                        let unitOption = {};
                        unitOption["label"] = this.data[i].boxorpieceMap[key];
                        unitOption["value"] = key;
                        unitOptions.push(unitOption);
                    this.OECId =
                        r.entity.HospitalInfo == null
                            ? ''
                            : r.entity.HospitalInfo;
                    console.log('this.OECId = ' + this.OECId);
                    this.ConsumableOut_report = r.entity.ConsumableOut_report;
                    console.log(
                        'this.ConsumableOut_report = ' +
                            this.ConsumableOut_report
                    );
                    this.accountid = r.entity.accountid;
                    this.consumableproductdetailsRecords =
                        r.entity.consumableproductdetailsRecords;
                    this.accountName = r.entity.accountName;
                    this.agencyProType = r.entity.agencyProType;
                    this.accountName = r.entity.accountName;
                    this.userWorkLocation = r.entity.userWorkLocation;
                    this.EditAble = r.entity.EditAble;
                    this.consumableorderdetails2Records =
                        r.entity.consumableorderdetails2Records;
                    for (var i in this.consumableorderdetails2Records) {
                        this.consumableorderdetails2Records[i]['ProdName'] =
                            this.consumableorderdetails2Records[i].Prod.Name;
                        this.consumableorderdetails2Records[i][
                            'orderdetails2SerialLotNo__c'
                        ] =
                            this.consumableorderdetails2Records[
                                i
                            ].orderdetails2.SerialLotNo__c;
                        this.consumableorderdetails2Records[i][
                            'orderdetails2TracingCode__c'
                        ] =
                            this.consumableorderdetails2Records[
                                i
                            ].orderdetails2.TracingCode__c;
                        this.consumableorderdetails2Records[i][
                            'orderdetails2Sterilization_limit__c'
                        ] =
                            this.consumableorderdetails2Records[
                                i
                            ].orderdetails2.Sterilization_limit__c;
                    }
                    this.data[i]["unitOptions"] = unitOptions;
                    this.data[i]["unitValue"] = this.data[i]["unitValue"] == null ? unitOptions[0].value : this.data[i]["unitValue"];
                    if (this.EditAble) {
                        this.data[i].orderdetails1["Box_Piece__c"] = this.data[i].orderdetails1["Box_Piece__c"] == null ? unitOptions[0].value : this.data[i].orderdetails1["Box_Piece__c"];
                        this.data[i].orderdetails1["Shipment_Count__c"] = this.data[i].orderdetails1["Shipment_Count__c"] == null ? 0 : this.data[i].orderdetails1["Shipment_Count__c"];
                        this.data[i].orderdetails1["Delivery_List_RMB__c"] = this.data[i].orderdetails1["Delivery_List_RMB__c"] == null ? 0.0 : this.data[i].orderdetails1["Delivery_List_RMB__c"];
                    } else {
                        this.data[i]["InvoiceProNot_count__c"] =
                            this.data[i].orderdetails1.InvoiceProNot_count__c;
                        this.data[i]["RrturnPro_count__c"] =
                            this.data[i].orderdetails1.RrturnPro_count__c;
                        this.data[i]["Invoiced_Procount__c"] =
                            this.data[i].orderdetails1.Invoiced_Procount__c;
                    }
                    // this.data[i]["shipmentNumber"] = 0;
                    // this.data[i]["shippingUnitPrice"] = 0.0;
                    //this.data[i]["shipmentNumber"] = this.data[i].orderdetails1["Shipment_Count__c"] == 0 ? '' : this.data[i].orderdetails1["Shipment_Count__c"];
                    //this.data[i]["shippingUnitPrice"] = this.data[i].orderdetails1["Delivery_List_RMB__c"] == 0 ? '' : this.data[i].orderdetails1["Delivery_List_RMB__c"];
                    this.data[i]["shipmentNumber"] = this.data[i].orderdetails1["Shipment_Count__c"];
                    this.data[i]["shippingUnitPrice"] = this.data[i].orderdetails1["Delivery_List_RMB__c"];
                    this.data[i]["recordId"] = this.data[i].Prod.Id;
                    this.data[i]["Id"] = this.data[i].Prod.Id;
                    this.data[i]["Name__c"] = this.data[i].Prod.Name__c;
                    this.data[i]["SFDA_Status__c"] = this.data[i].Prod.SFDA_Status__c;
                    this.data[i]["Category3__c"] = this.data[i].Prod.Category3__c;
                    this.data[i]["Category4__c"] = this.data[i].Prod.Category4__c;
                    this.data[i]["Category5__c"] = this.data[i].Prod.Category5__c;
                    this.data[i]["Box_Piece__c"] = this.data[i].orderdetails1.Box_Piece__c;
                    this.data[i]["shipmentAmount"] = this.data[i].orderdetails1.Shipment_amount__c;
                    this.data[i]["Shipment_amount__c"] = this.data[i].orderdetails1.Shipment_amount__c;
                    this.data[i]["Shipment_Count__c"] = this.data[i].orderdetails1.Shipment_Count__c;
                    if (this.data[i]['check']) {
                        this.selectedRows.push(this.data[i].Id);
                    }
                }
                console.log("this.data = " + JSON.stringify(this.data));
                //show
                if (r.entity.EditDelCommitBtnDisabled || r.entity.EditAble) {
                    this.isSaveShow = true;
                } else {
                    this.isEditShow = true;
                    this.isDeliveryShow = true;
                    this.isOpenToInvoiceShow = true;
                    this.isPraseToPDFShow = true;
                    this.isOpenReportShow = true;
                    this.isDeleteShow = true;
                }
                this.Existarrive = r.entity.Existarrive;
                console.log("this.EditAble = " + this.EditAble);
                this.hasHosPro = r.entity.hasHosPro;
                //disable
                if (Object.values(r.entity.coc).length > 0) {
                    this.cocLwc = r.entity.coc;
                    console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
                    var coc = r.entity.coc;
                    this.cocId = coc.Id;
                    console.log('cocId = ' + this.cocId);
                    coc.SummonsStatus = coc.SummonsStatus_c__c;
                    if (coc.SummonsStatus_c__c == "已完成") {
                        this.isEditDisabled = true;
                    }
                    if (
                        coc.SummonsStatus_c__c == "批准" ||
                        coc.SummonsStatus_c__c == "已销售待上传纳品书" ||
                        coc.SummonsStatus_c__c == "出库单已打印" ||
                        coc.SummonsStatus_c__c == "已完成"
                    ) {
                        this.isDeliveryDisabled = true;
                    }
                    if (
                        ((coc.Billed_Status__c != "全部开票" &&
                            coc.SummonsStatus_c__c == "已完成") ||
                            coc.Onchange_order__c == true) &&
                        coc.SummonsForDirction__c != "互相调货"
                    ) {
                        this.isOpenToInvoiceDisabled = false;
                    }
                    if (
                        coc.SummonsStatus_c__c == "已销售待上传纳品书" ||
                        coc.SummonsStatus_c__c == "批准" ||
                        coc.SummonsStatus_c__c == "出库单已打印" ||
                        coc.SummonsStatus_c__c == "草案中"
                    ) {
                        this.isPraseToPDFDisabled = false;
                    }
                    if (
                        coc.Billed_Status__c != "还没开票" ||
                        coc.SummonsStatus_c__c == "已完成"
                    ) {
                        this.isOpenReportDisabled = false;
                    }
                    if (
                        coc.SummonsStatus_c__c == "已销售待上传纳品书" ||
                        coc.SummonsStatus_c__c == "价格未定" ||
                        coc.SummonsStatus_c__c == "批准" ||
                        coc.SummonsStatus_c__c == "出库单已打印" ||
                        coc.SummonsStatus_c__c == "已完成"
                    ) {
                        this.isDeleteDisabled = true;
                    }
                    this.isConInvoiceShow =
                        coc.SummonsStatus_c__c == "已完成" &&
                            coc.SummonsForDirction__c != "互相调货"
                    this.isShowOutboundProductDetails =
                        r.entity.consumableorderdetails2Count > 0
                            ? true
                            : false;
                    this.summonsStatusPriceNotDetermined =
                        coc.SummonsStatus_c__c == "价格未定" ? true : false;
                    this.isSummonsForDirctionTwoShow =
                        coc.SummonsForDirction__c == "销售给二级经销商" ? true : false;
                }
                this.isSearchShow =
                    !this.Existarrive &&
                        r.entity.coc.SummonsStatus_c__c != "价格未定" &&
                        r.entity.EditAble
                        ? true
                        : false;
                this.hidecheckboxcolumn = !this.isSearchShow;
                this.arriveorder = r.entity.arriveorder;
                this.is345Show =
                    this.arriveorder == "" && this.Existarrive == false && this.EditAble
                        ? true
                        : false;
                //如果不显示345分类,columns里面删除3,4,5分类
                if (!this.is345Show) {
                    for (var i = 0; i < this.columns.length; i++) {
                        if (this.columns[i].label == "第3分类") {
                            this.columns.splice(i, 1);
                        }
                    console.log('this.agencyProType = ' + this.agencyProType);
                    console.log('this.EditAble = ' + this.EditAble);
                    //查询附件
                    if (!this.EditAble) this.getFiles();
                    //第3分类
                    for (var key in r.entity.categoryOptionMap) {
                        let object = {};
                        object['label'] = r.entity.categoryOptionMap[key];
                        object['value'] = key;
                        this.category3Options.push(object);
                    }
                    for (var i = 0; i < this.columns.length; i++) {
                        if (this.columns[i].label == "第4分类") {
                            this.columns.splice(i, 1);
                        }
                    console.log(
                        'this.category3Options = ' +
                            JSON.stringify(this.category3Options)
                    );
                    //第4分类
                    for (var key in r.entity.category4OptionMap) {
                        let object = {};
                        object['label'] = r.entity.category4OptionMap[key];
                        object['value'] = key;
                        this.category4Options.push(object);
                    }
                    for (var i = 0; i < this.columns.length; i++) {
                        if (this.columns[i].label == "第5分类") {
                            this.columns.splice(i, 1);
                        }
                    console.log(
                        'this.category4Options = ' + this.category4Options
                    );
                    //第5分类
                    for (var key in r.entity.category5OptionMap) {
                        let object = {};
                        object['label'] = r.entity.category5OptionMap[key];
                        object['value'] = key;
                        this.category5Options.push(object);
                    }
                    for (var i = 0; i < this.editColumns.length; i++) {
                        if (this.editColumns[i].label == "第3分类") {
                            this.editColumns.splice(i, 1);
                        }
                    }
                    for (var i = 0; i < this.editColumns.length; i++) {
                        if (this.editColumns[i].label == "第4分类") {
                            this.editColumns.splice(i, 1);
                        }
                    }
                    for (var i = 0; i < this.editColumns.length; i++) {
                        if (this.editColumns[i].label == "第5分类") {
                            this.editColumns.splice(i, 1);
                        }
                    }
                }
                //如果EditAble==false,删除 出货金额(元) 有效期内库存(盒) 有效期内库存(个) 3列 展示 还没发票数量 返品数量 已发票数量
                //type : "number",
                // typeAttributes:{
                //     minimumFractionDigits:2,
                // },
                if (!this.EditAble) {
                    let object1 = {
                        label: this.InvoiceProNotLabel,
                        fieldName: "InvoiceProNot_count__c",
                        type: "number",
                        typeAttributes: {
                            minimumFractionDigits: 2,
                        },
                        hideDefaultActions: true,
                    };
                    let object2 = {
                        label: this.RrturnProLabel,
                        fieldName: "RrturnPro_count__c",
                        hideDefaultActions: true,
                    };
                    let object3 = {
                        label: this.InvoicedLabel,
                        fieldName: "Invoiced_Procount__c",
                        type: "number",
                        typeAttributes: {
                            minimumFractionDigits: 2,
                        },
                        hideDefaultActions: true,
                    };
                    this.editColumns.push(object1);
                    this.editColumns.push(object2);
                    this.editColumns.push(object3);
                } else {
                    this.ForCustomerText = this.cocLwc.Order_ForCustomerText__c;
                    console.log('EditAble = true this.ForCustomerText = ' + this.ForCustomerText);
                    this.summonsForDirction = this.cocLwc.SummonsForDirction__c;
                    console.log('EditAble = true this.summonsForDirction = ' + this.summonsForDirction);
                    let value = this.summonsForDirction;
                    switch (value) {
                        case "直接销售给医院":
                            this.isDisabledHospitalName = false;
                            this.isDisabledForCustomerText = false;
                            this.secondaryDistributor = "";
                            this.ForDealerText = "";
                            this.isDisabledForDealerText = true;
                            this.isDisabledSecondaryDistributor = true;
                            break;
                        case "医院试用":
                            this.isDisabledHospitalName = false;
                            this.isDisabledForCustomerText = false;
                            this.isDisabledForDealerText = false;
                            this.isDisabledSecondaryDistributor = false;
                            break;
                        case "销售给二级经销商":
                            this.isDisabledHospitalName = false;
                            this.isDisabledForCustomerText = false;
                            this.isDisabledForDealerText = false;
                            this.isDisabledSecondaryDistributor = false;
                            break;
                        case "互相调货":
                            this.isDisabledHospitalName = true;
                            this.HospitalName = "";
                            this.OECId = "";
                            this.isDisabledForCustomerText = true;
                            this.ForCustomerText = "";
                            this.isDisabledForDealerText = false;
                            this.isDisabledSecondaryDistributor = false;
                            this.isMutualTransferGoods = true;
                            break;
                        default:
                            this.isDisabledHospitalName = false;
                            this.isDisabledForCustomerText = false;
                            this.isDisabledForDealerText = false;
                            this.isDisabledSecondaryDistributor = false;
                    }
                }
                    console.log(
                        'this.category5Options = ' + this.category5Options
                    );
                //如果hasHosPro = true 医院特价
                if (this.hasHosPro) {
                    let object1 = {
                        label: "医院特价",
                        fieldName: "InvoiceProNot_count__c",
                        hideDefaultActions: true,
                    };
                    this.columns.push(object1);
                    this.editColumns.push(object1);
                    this.data = r.entity.pageRecords;
                    this.editData = r.entity.pageRecords;
                    console.log(
                        'this.data start = ' + JSON.stringify(this.data)
                    );
                    if (this.EditAble) {
                        for (var i in this.data) {
                            let unitOptions = [];
                            for (var key in this.data[i].boxorpieceMap) {
                                let unitOption = {};
                                unitOption['label'] =
                                    this.data[i].boxorpieceMap[key];
                                unitOption['value'] = key;
                                unitOptions.push(unitOption);
                            }
                            this.data[i]['unitOptions'] = unitOptions;
                            this.data[i]['unitValue'] =
                                this.data[i]['unitValue'] == null
                                    ? unitOptions[0].value
                                    : this.data[i]['unitValue'];
                            if (this.EditAble) {
                                this.data[i].orderdetails1['Box_Piece__c'] =
                                    this.data[i].orderdetails1[
                                        'Box_Piece__c'
                                    ] == null
                                        ? unitOptions[0].value
                                        : this.data[i].orderdetails1[
                                              'Box_Piece__c'
                                          ];
                                this.data[i].orderdetails1[
                                    'Shipment_Count__c'
                                ] =
                                    this.data[i].orderdetails1[
                                        'Shipment_Count__c'
                                    ] == null
                                        ? 0
                                        : this.data[i].orderdetails1[
                                              'Shipment_Count__c'
                                          ];
                                this.data[i].orderdetails1[
                                    'Delivery_List_RMB__c'
                                ] =
                                    this.data[i].orderdetails1[
                                        'Delivery_List_RMB__c'
                                    ] == null
                                        ? 0.0
                                        : this.data[i].orderdetails1[
                                              'Delivery_List_RMB__c'
                                          ];
                            } else {
                                this.data[i]['InvoiceProNot_count__c'] =
                                    this.data[
                                        i
                                    ].orderdetails1.InvoiceProNot_count__c;
                                this.data[i]['RrturnPro_count__c'] =
                                    this.data[
                                        i
                                    ].orderdetails1.RrturnPro_count__c;
                                this.data[i]['Invoiced_Procount__c'] =
                                    this.data[
                                        i
                                    ].orderdetails1.Invoiced_Procount__c;
                            }
                            // this.data[i]["shipmentNumber"] = 0;
                            // this.data[i]["shippingUnitPrice"] = 0.0;
                            //this.data[i]["shipmentNumber"] = this.data[i].orderdetails1["Shipment_Count__c"] == 0 ? '' : this.data[i].orderdetails1["Shipment_Count__c"];
                            //this.data[i]["shippingUnitPrice"] = this.data[i].orderdetails1["Delivery_List_RMB__c"] == 0 ? '' : this.data[i].orderdetails1["Delivery_List_RMB__c"];
                            this.data[i]['shipmentNumber'] =
                                this.data[i].orderdetails1['Shipment_Count__c'];
                            this.data[i]['shippingUnitPrice'] =
                                this.data[i].orderdetails1[
                                    'Delivery_List_RMB__c'
                                ];
                            this.data[i]['recordId'] = this.data[i].Prod.Id;
                            this.data[i]['Id'] = this.data[i].Prod.Id;
                            this.data[i]['Name__c'] = this.data[i].Prod.Name__c;
                            this.data[i]['SFDA_Status__c'] =
                                this.data[i].Prod.SFDA_Status__c;
                            this.data[i]['Category3__c'] =
                                this.data[i].Prod.Category3__c;
                            this.data[i]['Category4__c'] =
                                this.data[i].Prod.Category4__c;
                            this.data[i]['Category5__c'] =
                                this.data[i].Prod.Category5__c;
                            this.data[i]['Box_Piece__c'] =
                                this.data[i].orderdetails1.Box_Piece__c;
                            this.data[i]['shipmentAmount'] =
                                this.data[i].orderdetails1.Shipment_amount__c;
                            this.data[i]['Shipment_amount__c'] =
                                this.data[i].orderdetails1.Shipment_amount__c;
                            this.data[i]['Shipment_Count__c'] =
                                this.data[i].orderdetails1.Shipment_Count__c;
                            if (this.data[i]['check']) {
                                this.selectedRows.push(this.data[i].Id);
                            }
                        }
                    } else {
                        for (var i in this.editData) {
                            this.editData[i]['unitValue'] =
                                this.editData[i]['unitValue'];
                            this.editData[i]['InvoiceProNot_count__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.InvoiceProNot_count__c;
                            this.editData[i]['RrturnPro_count__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.RrturnPro_count__c;
                            this.editData[i]['Invoiced_Procount__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.Invoiced_Procount__c;
                            this.editData[i]['shipmentNumber'] =
                                this.editData[i].orderdetails1[
                                    'Shipment_Count__c'
                                ];
                            this.editData[i]['shippingUnitPrice'] =
                                this.editData[i].orderdetails1[
                                    'Delivery_List_RMB__c'
                                ];
                            this.editData[i]['recordId'] =
                                this.editData[i].Prod.Id;
                            this.editData[i]['Id'] = this.editData[i].Prod.Id;
                            this.editData[i]['Name__c'] =
                                this.editData[i].Prod.Name__c;
                            this.editData[i]['SFDA_Status__c'] =
                                this.editData[i].Prod.SFDA_Status__c;
                            this.editData[i]['Category3__c'] =
                                this.editData[i].Prod.Category3__c;
                            this.editData[i]['Category4__c'] =
                                this.editData[i].Prod.Category4__c;
                            this.editData[i]['Category5__c'] =
                                this.editData[i].Prod.Category5__c;
                            this.editData[i]['Box_Piece__c'] =
                                this.editData[i].orderdetails1.Box_Piece__c;
                            this.editData[i]['shipmentAmount'] =
                                this.editData[
                                    i
                                ].orderdetails1.Shipment_amount__c;
                            this.editData[i]['Shipment_amount__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.Shipment_amount__c;
                            this.editData[i]['Shipment_Count__c'] =
                                this.editData[
                                    i
                                ].orderdetails1.Shipment_Count__c;
                        }
                    }
                    console.log('this.data = ' + JSON.stringify(this.data));
                    //show
                    if (
                        r.entity.EditDelCommitBtnDisabled ||
                        r.entity.EditAble
                    ) {
                        this.isSaveShow = true;
                    } else {
                        this.isEditShow = true;
                        this.isDeliveryShow = true;
                        this.isOpenToInvoiceShow = true;
                        this.isPraseToPDFShow = true;
                        this.isOpenReportShow = true;
                        this.isDeleteShow = true;
                    }
                    this.Existarrive = r.entity.Existarrive;
                    console.log('this.EditAble = ' + this.EditAble);
                    this.hasHosPro = r.entity.hasHosPro;
                    //disable
                    if (Object.values(r.entity.coc).length > 0) {
                        this.cocLwc = r.entity.coc;
                        console.log(
                            'this.cocLwc = ' + JSON.stringify(this.cocLwc)
                        );
                        var coc = r.entity.coc;
                        this.cocId = coc.Id;
                        console.log('cocId = ' + this.cocId);
                        coc.SummonsStatus = coc.SummonsStatus_c__c;
                        if (coc.SummonsStatus_c__c == '已完成') {
                            this.isEditDisabled = true;
                        }
                        if (
                            coc.SummonsStatus_c__c == '批准' ||
                            coc.SummonsStatus_c__c == '已销售待上传纳品书' ||
                            coc.SummonsStatus_c__c == '出库单已打印' ||
                            coc.SummonsStatus_c__c == '已完成'
                        ) {
                            this.isDeliveryDisabled = true;
                        }
                        if (
                            ((coc.Billed_Status__c != '全部开票' &&
                                coc.SummonsStatus_c__c == '已完成') ||
                                coc.Onchange_order__c == true) &&
                            coc.SummonsForDirction__c != '互相调货'
                        ) {
                            this.isOpenToInvoiceDisabled = false;
                        }
                        if (
                            coc.SummonsStatus_c__c == '已销售待上传纳品书' ||
                            coc.SummonsStatus_c__c == '批准' ||
                            coc.SummonsStatus_c__c == '出库单已打印' ||
                            coc.SummonsStatus_c__c == '草案中'
                        ) {
                            this.isPraseToPDFDisabled = false;
                        }
                        if (
                            coc.Billed_Status__c != '还没开票' ||
                            coc.SummonsStatus_c__c == '已完成'
                        ) {
                            this.isOpenReportDisabled = false;
                        }
                        if (
                            coc.SummonsStatus_c__c == '已销售待上传纳品书' ||
                            coc.SummonsStatus_c__c == '价格未定' ||
                            coc.SummonsStatus_c__c == '批准' ||
                            coc.SummonsStatus_c__c == '出库单已打印' ||
                            coc.SummonsStatus_c__c == '已完成'
                        ) {
                            this.isDeleteDisabled = true;
                        }
                        this.isConInvoiceShow =
                            coc.SummonsStatus_c__c == '已完成' &&
                            coc.SummonsForDirction__c != '互相调货'
                                ? true
                                : false;
                        this.summonsStatusPriceNotDetermined =
                            coc.SummonsStatus_c__c == '价格未定' ? true : false;
                        this.isSummonsForDirctionTwoShow =
                            coc.SummonsForDirction__c == '销售给二级经销商'
                                ? true
                                : false;
                    }
                    this.isSearchShow =
                        !this.Existarrive &&
                        r.entity.coc.SummonsStatus_c__c != '价格未定' &&
                        r.entity.EditAble
                            ? true
                            : false;
                    this.hidecheckboxcolumn = !this.isSearchShow;
                    this.arriveorder = r.entity.arriveorder;
                    this.is345Show =
                        this.arriveorder == '' &&
                        this.Existarrive == false &&
                        this.EditAble
                            ? true
                            : false;
                    //如果不显示345分类,columns里面删除3,4,5分类
                    if (!this.is345Show) {
                        for (var i = 0; i < this.columns.length; i++) {
                            if (this.columns[i].label == '第3分类') {
                                this.columns.splice(i, 1);
                            }
                        }
                        for (var i = 0; i < this.columns.length; i++) {
                            if (this.columns[i].label == '第4分类') {
                                this.columns.splice(i, 1);
                            }
                        }
                        for (var i = 0; i < this.columns.length; i++) {
                            if (this.columns[i].label == '第5分类') {
                                this.columns.splice(i, 1);
                            }
                        }
                        for (var i = 0; i < this.editColumns.length; i++) {
                            if (this.editColumns[i].label == '第3分类') {
                                this.editColumns.splice(i, 1);
                            }
                        }
                        for (var i = 0; i < this.editColumns.length; i++) {
                            if (this.editColumns[i].label == '第4分类') {
                                this.editColumns.splice(i, 1);
                            }
                        }
                        for (var i = 0; i < this.editColumns.length; i++) {
                            if (this.editColumns[i].label == '第5分类') {
                                this.editColumns.splice(i, 1);
                            }
                        }
                    }
                    //如果EditAble==false,删除 出货金额(元) 有效期内库存(盒) 有效期内库存(个) 3列 展示 还没发票数量 返品数量 已发票数量
                    //type : "number",
                    // typeAttributes:{
                    //     minimumFractionDigits:2,
                    // },
                    if (!this.EditAble) {
                        let object1 = {
                            label: this.InvoiceProNotLabel,
                            fieldName: 'InvoiceProNot_count__c',
                            type: 'number',
                            typeAttributes: {
                                minimumFractionDigits: 2
                            },
                            hideDefaultActions: true
                        };
                        let object2 = {
                            label: this.RrturnProLabel,
                            fieldName: 'RrturnPro_count__c',
                            hideDefaultActions: true
                        };
                        let object3 = {
                            label: this.InvoicedLabel,
                            fieldName: 'Invoiced_Procount__c',
                            type: 'number',
                            typeAttributes: {
                                minimumFractionDigits: 2
                            },
                            hideDefaultActions: true
                        };
                        this.editColumns.push(object1);
                        this.editColumns.push(object2);
                        this.editColumns.push(object3);
                    } else {
                        this.ForCustomerText =
                            this.cocLwc.Order_ForCustomerText__c;
                        console.log(
                            'EditAble = true this.ForCustomerText = ' +
                                this.ForCustomerText
                        );
                        this.summonsForDirction =
                            this.cocLwc.SummonsForDirction__c;
                        console.log(
                            'EditAble = true this.summonsForDirction = ' +
                                this.summonsForDirction
                        );
                        let value = this.summonsForDirction;
                        switch (value) {
                            case '直接销售给医院':
                                this.isDisabledHospitalName = false;
                                this.isDisabledForCustomerText = false;
                                this.secondaryDistributor = '';
                                this.ForDealerText = '';
                                this.isDisabledForDealerText = true;
                                this.isDisabledSecondaryDistributor = true;
                                break;
                            case '医院试用':
                                this.isDisabledHospitalName = false;
                                this.isDisabledForCustomerText = false;
                                this.isDisabledForDealerText = false;
                                this.isDisabledSecondaryDistributor = false;
                                break;
                            case '销售给二级经销商':
                                this.isDisabledHospitalName = false;
                                this.isDisabledForCustomerText = false;
                                this.isDisabledForDealerText = false;
                                this.isDisabledSecondaryDistributor = false;
                                break;
                            case '互相调货':
                                this.isDisabledHospitalName = true;
                                this.HospitalName = '';
                                this.OECId = '';
                                this.isDisabledForCustomerText = true;
                                this.ForCustomerText = '';
                                this.isDisabledForDealerText = false;
                                this.isDisabledSecondaryDistributor = false;
                                this.isMutualTransferGoods = true;
                                break;
                            default:
                                this.isDisabledHospitalName = false;
                                this.isDisabledForCustomerText = false;
                                this.isDisabledForDealerText = false;
                                this.isDisabledSecondaryDistributor = false;
                        }
                    }
                    //如果hasHosPro = true 医院特价
                    if (this.hasHosPro) {
                        let object1 = {
                            label: '医院特价',
                            fieldName: 'hospitalSpecialOffer',
                            type: 'boolean',
                            hideDefaultActions: true
                        };
                        this.columns.push(object1);
                        this.editColumns.push(object1);
                    }
                    //出库单信息
                    this.isSummonsFlag =
                        r.entity.SummonsFlag == 'visible' ? true : false;
                    console.log(
                        'r.entity.provinceOptsMap = ' + r.entity.provinceOptsMap
                    );
                    for (var key in r.entity.provinceOptsMap) {
                        let object = {};
                        object['label'] = r.entity.provinceOptsMap[key];
                        object['value'] = key;
                        this.secondaryDistributorOptions.push(object);
                    }
                    for (var key in r.entity.outOutPatternOptionMap) {
                        let object = {};
                        object['label'] = r.entity.outOutPatternOptionMap[key];
                        object['value'] = key;
                        this.outOutPatternOptionList.push(object);
                    }
                    console.log(
                        'this.secondaryDistributorOptions = ' +
                            JSON.stringify(this.secondaryDistributorOptions)
                    );
                    this.HospitalName = r.entity.HospitalName;
                    this.sumPrice = r.entity.sumPrice.toFixed(2) + '元';
                    this.isShowSpinner = false;
                    this.showTable = true;
                    console.log('ESetid = ' + this.ESetid);
                } else {
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
                }
                //出库单信息
                this.isSummonsFlag = r.entity.SummonsFlag == "visible" ? true : false;
                console.log("r.entity.provinceOptsMap = " + r.entity.provinceOptsMap);
                for (var key in r.entity.provinceOptsMap) {
                    let object = {};
                    object["label"] = r.entity.provinceOptsMap[key];
                    object["value"] = key;
                    this.secondaryDistributorOptions.push(object);
                }
                for (var key in r.entity.outOutPatternOptionMap) {
                    let object = {};
                    object["label"] = r.entity.outOutPatternOptionMap[key];
                    object["value"] = key;
                    this.outOutPatternOptionList.push(object);
                }
                console.log(
                    "this.secondaryDistributorOptions = " +
                    JSON.stringify(this.secondaryDistributorOptions)
                );
                this.HospitalName = r.entity.HospitalName;
                this.sumPrice = r.entity.sumPrice.toFixed(2) + "元";
                this.isShowSpinner = false;
                this.showTable = true;
                console.log("ESetid = " + this.ESetid);
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
            }
        }).catch((error) => {
            console.log("error = " + JSON.stringify(error));
        });
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
    ChangeDirction(event) {
        let value = event.target.value;
        this.summonsForDirction = value;
        this.cocLwc["SummonsForDirction__c"] = value;
        console.log("选择了 = " + value);
        this.cocLwc['SummonsForDirction__c'] = value;
        console.log('选择了 = ' + value);
        switch (value) {
            case "直接销售给医院":
            case '直接销售给医院':
                this.isDisabledHospitalName = false;
                this.isDisabledForCustomerText = false;
                this.secondaryDistributor = "";
                this.ForDealerText = "";
                this.secondaryDistributor = '';
                this.ForDealerText = '';
                this.isDisabledForDealerText = true;
                this.isDisabledSecondaryDistributor = true;
                this.isMutualTransferGoods = false;
                break;
            case "医院试用":
            case '医院试用':
                this.isDisabledHospitalName = false;
                this.isDisabledForCustomerText = false;
                this.isDisabledForDealerText = false;
                this.isDisabledSecondaryDistributor = false;
                break;
            case "销售给二级经销商":
            case '销售给二级经销商':
                this.isDisabledHospitalName = false;
                this.isDisabledForCustomerText = false;
                this.isDisabledForDealerText = false;
                this.isDisabledSecondaryDistributor = false;
                break;
            case "互相调货":
            case '互相调货':
                this.isDisabledHospitalName = true;
                this.HospitalName = "";
                this.OECId = "";
                this.HospitalName = '';
                this.OECId = '';
                this.isDisabledForCustomerText = true;
                this.ForCustomerText = "";
                this.ForCustomerText = '';
                this.isDisabledForDealerText = false;
                this.isDisabledSecondaryDistributor = false;
                this.isMutualTransferGoods = true;
@@ -974,39 +1163,39 @@
    }
    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 = " + value);
        console.log('fieldName = ' + fieldName + ' value = ' + value);
        switch (fieldName) {
            case "summonsForDirction":
            case 'summonsForDirction':
                this.summonsForDirction = value;
                break;
            case "secondaryDistributor":
            case 'secondaryDistributor':
                this.secondaryDistributor = value;
                break;
            case "HospitalName":
            case 'HospitalName':
                this.HospitalName = value;
                break;
            case "ForDealerText":
            case 'ForDealerText':
                this.ForDealerText = value;
                this.cocLwc["Order_ForDealerText__c"] = value;
                this.cocLwc['Order_ForDealerText__c'] = value;
                break;
            case "ForCustomerText":
                this.cocLwc["Order_ForCustomerText__c"] = value;
            case 'ForCustomerText':
                this.cocLwc['Order_ForCustomerText__c'] = value;
                this.ForCustomerText = value;
                break;
            case "sumPrice":
            case 'sumPrice':
                this.sumPrice = value.toFixed(2);
                break;
            case "NoConfirmedPrice":
            case 'NoConfirmedPrice':
                this.NoConfirmedPrice = !this.NoConfirmedPrice;
                this.cocLwc["NoConfirmedPrice__c"] = this.NoConfirmedPrice;
                console.log("this.NoConfirmedPrice = " + this.NoConfirmedPrice);
                this.cocLwc['NoConfirmedPrice__c'] = this.NoConfirmedPrice;
                console.log('this.NoConfirmedPrice = ' + this.NoConfirmedPrice);
                break;
            case "consumableName":
            case 'consumableName':
                this.consumableName = value;
                break;
            case "Category3":
            case 'Category3':
                this.Category3 = value;
                //调用后台显示第四五分类
                this.showAllCate();
@@ -1015,7 +1204,7 @@
                    this.Category5 = '';
                }
                break;
            case "Category4":
            case 'Category4':
                this.Category4 = value;
                //调用后台显示第五分类
                this.showCate();
@@ -1023,85 +1212,93 @@
                    this.Category5 = '';
                }
                break;
            case "Category5":
            case 'Category5':
                this.Category5 = value;
                break;
            case "searchHospitalName":
            case 'searchHospitalName':
                this.searchHospitalName = value;
                break;
            case "Barcode":
            case 'Barcode':
                this.Barcode = value;
                break;
        }
    }
    showAllCate() {
        console.log('showAllCate')
        console.log('showAllCate');
        categoryAllload({
            category3Lwc: this.Category3
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                this.category4Options = [];
                this.category5Options = [];
                //第4分类
                for (var key in r.entity.category4OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category4OptionMap[key];
                    object["value"] = key;
                    this.category4Options.push(object);
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.category4Options = [];
                    this.category5Options = [];
                    //第4分类
                    for (var key in r.entity.category4OptionMap) {
                        let object = {};
                        object['label'] = r.entity.category4OptionMap[key];
                        object['value'] = key;
                        this.category4Options.push(object);
                    }
                    console.log(
                        'this.category4Options = ' + this.category4Options
                    );
                    //第5分类
                    for (var key in r.entity.category5OptionMap) {
                        let object = {};
                        object['label'] = r.entity.category5OptionMap[key];
                        object['value'] = key;
                        this.category5Options.push(object);
                    }
                } else {
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
                }
                console.log("this.category4Options = " + this.category4Options);
                //第5分类
                for (var key in r.entity.category5OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category5OptionMap[key];
                    object["value"] = key;
                    this.category5Options.push(object);
                }
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
            }
        }).catch((error) => {
            console.log("error" + JSON.stringify(error));
        });
            })
            .catch((error) => {
                console.log('error' + JSON.stringify(error));
            });
    }
    showCate() {
        console.log('showAllCate')
        console.log('showAllCate');
        categoryload({
            category3Lwc: this.Category3,
            category4Lwc: this.Category4
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                this.category4Options = [];
                this.category5Options = [];
                //第4分类
                for (var key in r.entity.category4OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category4OptionMap[key];
                    object["value"] = key;
                    this.category4Options.push(object);
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.category4Options = [];
                    this.category5Options = [];
                    //第4分类
                    for (var key in r.entity.category4OptionMap) {
                        let object = {};
                        object['label'] = r.entity.category4OptionMap[key];
                        object['value'] = key;
                        this.category4Options.push(object);
                    }
                    console.log(
                        'this.category4Options = ' + this.category4Options
                    );
                    //第5分类
                    for (var key in r.entity.category5OptionMap) {
                        let object = {};
                        object['label'] = r.entity.category5OptionMap[key];
                        object['value'] = key;
                        this.category5Options.push(object);
                    }
                } else {
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
                }
                console.log("this.category4Options = " + this.category4Options);
                //第5分类
                for (var key in r.entity.category5OptionMap) {
                    let object = {};
                    object["label"] = r.entity.category5OptionMap[key];
                    object["value"] = key;
                    this.category5Options.push(object);
                }
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
            }
        }).catch((error) => {
            console.log("error" + JSON.stringify(error));
        });
            })
            .catch((error) => {
                console.log('error' + JSON.stringify(error));
            });
    }
    invoiceChange(event) {
@@ -1112,38 +1309,41 @@
    showToast(type, msg) {
        this.isShowSpinner = false;
        this.showLoadingSpinner = false;
        this.isEditShowSpinner = false;
        const event = new ShowToastEvent({
            title: type,
            variant: type,
            message: msg,
            message: msg
        });
        this.dispatchEvent(event);
    }
    searchProductJs() {
        this.isShowSpinner = true;
        this.isEditShowSpinner = true;
        //this.showTable = false;
        //查询有哪些选择了的然后check
        const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        const selectedRows = this.template
            .querySelector('c-lex-custom-lightning-datatable')
            .getSelectedRows();
        console.log('selectedRows = ' + selectedRows);
        for (var i in this.data) {
            this.data[i]["check"] = false;
            this.data[i]['check'] = false;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                    this.data[i]['check'] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
            cloneData[i]["Category4"] = cloneData[i].Category4__c;
            cloneData[i]["Category5"] = cloneData[i].Category5__c;
            cloneData[i]["BoxPiece"] = cloneData[i].Box_Piece__c;
            cloneData[i]['Name'] = cloneData[i].Name__c;
            cloneData[i]['Category3'] = cloneData[i].Category3__c;
            cloneData[i]['Category4'] = cloneData[i].Category4__c;
            cloneData[i]['Category5'] = cloneData[i].Category5__c;
            cloneData[i]['BoxPiece'] = cloneData[i].Box_Piece__c;
            delete cloneData[i].Name__c;
            delete cloneData[i].Category3__c;
            delete cloneData[i].Category4__c;
@@ -1151,7 +1351,7 @@
            delete cloneData[i].Box_Piece__c;
        }
        console.log("cloneData = " + JSON.stringify(cloneData));
        console.log('cloneData = ' + JSON.stringify(cloneData));
        searchConsumableorderdetails({
            agencyProTypeLwc: this.agencyProType,
            accountNameLwc: this.accountName,
@@ -1163,161 +1363,194 @@
            category5: this.Category5,
            editAbleLwc: this.EditAble,
            pageRecordsLwcLwc: cloneData,
            consumableproductdetailsRecordsLwc: this.consumableproductdetailsRecords,
            consumableproductdetailsRecordsLwc:
                this.consumableproductdetailsRecords,
            arriveorderLwc: this.arriveorder,
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                //分页
                console.log(
                    'r.entity.paginatedAccounts = ' +
                        JSON.stringify(r.entity.paginatedAccounts)
                );
                this.nextPageToken = r.entity.paginatedAccounts.nextPageToken;
                this.totalRecords = r.entity.paginatedAccounts.totalRecords;
                this.recordStart = r.entity.paginatedAccounts.recordStart;
                this.recordEnd = r.entity.paginatedAccounts.recordEnd;
                this.totalPages = Math.ceil(
                    r.entity.paginatedAccounts.totalRecords / this.pageSize
                );
                console.log('this.totalPages = ' + this.totalPages);
                this.SearchDone = r.entity.SearchDone;
                let tempData = [];
                //this.data = r.entity.pageRecords;
                this.selectedRows = [];
                tempData = r.entity.pageRecords;
                for (var i in tempData) {
                    let unitOptions = [];
                    for (var key in tempData[i].boxorpieceMap) {
                        let unitOption = {};
                        unitOption["label"] = tempData[i].boxorpieceMap[key];
                        unitOption["value"] = key;
                        unitOption['label'] = tempData[i].boxorpieceMap[key];
                        unitOption['value'] = key;
                        unitOptions.push(unitOption);
                    }
                    tempData[i]["unitOptions"] = unitOptions;
                    tempData[i]["unitValue"] = tempData[i]["unitValue"] == null ? unitOptions[0].value : tempData[i]["unitValue"];
                    tempData[i]['unitOptions'] = unitOptions;
                    tempData[i]['unitValue'] =
                        tempData[i]['unitValue'] == null
                            ? unitOptions[0].value
                            : tempData[i]['unitValue'];
                    if (this.EditAble) {
                        tempData[i].orderdetails1["Box_Piece__c"] = tempData[i].orderdetails1["Box_Piece__c"] == null ? unitOptions[0].value : tempData[i].orderdetails1["Box_Piece__c"];
                        tempData[i].orderdetails1["Shipment_Count__c"] = tempData[i].orderdetails1["Shipment_Count__c"] == null ? 0 : tempData[i].orderdetails1["Shipment_Count__c"];
                        tempData[i].orderdetails1["Delivery_List_RMB__c"] = tempData[i].orderdetails1["Delivery_List_RMB__c"] == null ? 0.0 : tempData[i].orderdetails1["Delivery_List_RMB__c"];
                        tempData[i].orderdetails1['Box_Piece__c'] =
                            tempData[i].orderdetails1['Box_Piece__c'] == null
                                ? unitOptions[0].value
                                : tempData[i].orderdetails1['Box_Piece__c'];
                        tempData[i].orderdetails1['Shipment_Count__c'] =
                            tempData[i].orderdetails1['Shipment_Count__c'] ==
                            null
                                ? 0
                                : tempData[i].orderdetails1[
                                      'Shipment_Count__c'
                                  ];
                        tempData[i].orderdetails1['Delivery_List_RMB__c'] =
                            tempData[i].orderdetails1['Delivery_List_RMB__c'] ==
                            null
                                ? 0.0
                                : tempData[i].orderdetails1[
                                      'Delivery_List_RMB__c'
                                  ];
                    } else {
                        tempData[i]["InvoiceProNot_count__c"] =
                        tempData[i]['InvoiceProNot_count__c'] =
                            tempData[i].orderdetails1.InvoiceProNot_count__c;
                        tempData[i]["RrturnPro_count__c"] =
                        tempData[i]['RrturnPro_count__c'] =
                            tempData[i].orderdetails1.RrturnPro_count__c;
                        tempData[i]["Invoiced_Procount__c"] =
                        tempData[i]['Invoiced_Procount__c'] =
                            tempData[i].orderdetails1.Invoiced_Procount__c;
                    }
                    tempData[i]["shipmentNumber"] = tempData[i].orderdetails1["Shipment_Count__c"];
                    tempData[i]["shippingUnitPrice"] = tempData[i].orderdetails1["Delivery_List_RMB__c"];
                    tempData[i]['shipmentNumber'] =
                        tempData[i].orderdetails1['Shipment_Count__c'];
                    tempData[i]['shippingUnitPrice'] =
                        tempData[i].orderdetails1['Delivery_List_RMB__c'];
                    tempData[i]["recordId"] = tempData[i].Prod.Id;
                    tempData[i]["Id"] = tempData[i].Prod.Id;
                    tempData[i]["Name__c"] = tempData[i].Prod.Name__c;
                    tempData[i]["SFDA_Status__c"] = tempData[i].Prod.SFDA_Status__c;
                    tempData[i]["Category3__c"] = tempData[i].Prod.Category3__c;
                    tempData[i]["Category4__c"] = tempData[i].Prod.Category4__c;
                    tempData[i]["Category5__c"] = tempData[i].Prod.Category5__c;
                    tempData[i]["Box_Piece__c"] = tempData[i].orderdetails1.Box_Piece__c;
                    tempData[i]["shipmentAmount"] = tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]["Shipment_amount__c"] = tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]["Shipment_Count__c"] = tempData[i].orderdetails1.Shipment_Count__c;
                    tempData[i]['recordId'] = tempData[i].Prod.Id;
                    console.log(
                        'tempData[i]["hospitalSpecialOffer"] = ' +
                            tempData[i]['hospitalSpecialOffer']
                    );
                    if (tempData[i]['hospitalSpecialOffer']) {
                        tempData[i]['Id'] = tempData[i].Prod.Id + 'ishos';
                    } else {
                        tempData[i]['Id'] = tempData[i].Prod.Id + 'nothos';
                    }
                    tempData[i]['Name__c'] = tempData[i].Prod.Name__c;
                    tempData[i]['SFDA_Status__c'] =
                        tempData[i].Prod.SFDA_Status__c;
                    tempData[i]['Category3__c'] = tempData[i].Prod.Category3__c;
                    tempData[i]['Category4__c'] = tempData[i].Prod.Category4__c;
                    tempData[i]['Category5__c'] = tempData[i].Prod.Category5__c;
                    tempData[i]['Box_Piece__c'] =
                        tempData[i].orderdetails1.Box_Piece__c;
                    tempData[i]['shipmentAmount'] =
                        tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]['Shipment_amount__c'] =
                        tempData[i].orderdetails1.Shipment_amount__c;
                    tempData[i]['Shipment_Count__c'] =
                        tempData[i].orderdetails1.Shipment_Count__c;
                    if (tempData[i]["shippingUnitPrice"] && tempData[i]["shipmentNumber"])
                        tempData[i]["shipmentAmount"] = this.amend(
                            tempData[i]["shipmentNumber"],
                            tempData[i]["shippingUnitPrice"],
                            "*"
                    if (
                        tempData[i]['shippingUnitPrice'] &&
                        tempData[i]['shipmentNumber']
                    )
                        tempData[i]['shipmentAmount'] = this.amend(
                            tempData[i]['shipmentNumber'],
                            tempData[i]['shippingUnitPrice'],
                            '*'
                        );
                    if (tempData[i]['check']) {
                        this.selectedRows.push(tempData[i].Id);
                    }
                }
                // for (var i in tempData) {
                //     let unitOptions = [];
                //     for (var key in tempData[i].boxorpieceMap) {
                //         let unitOption = {};
                //         unitOption["label"] = tempData[i].boxorpieceMap[key];
                //         unitOption["value"] = key;
                //         unitOptions.push(unitOption);
                //     }
                //     tempData[i]["unitOptions"] = unitOptions;
                //     tempData[i]["unitValue"] = unitOptions[0].value;
                //     tempData[i]["recordId"] = tempData[i].Prod.Id;
                //     tempData[i]["Id"] = tempData[i].Prod.Id;
                //     tempData[i]["Name__c"] = tempData[i].Prod.Name__c;
                //     tempData[i]["SFDA_Status__c"] = tempData[i].Prod.SFDA_Status__c;
                //     tempData[i]["Category3__c"] = tempData[i].Prod.Category3__c;
                //     tempData[i]["Category4__c"] = tempData[i].Prod.Category4__c;
                //     tempData[i]["Category5__c"] = tempData[i].Prod.Category5__c;
                //     tempData[i]["Box_Piece__c"] = tempData[i].orderdetails1.Box_Piece__c;
                //     tempData[i]["shipmentNumber"] = tempData[i].orderdetails1.Shipment_Count__c;
                //     tempData[i]["shippingUnitPrice"] = tempData[i].orderdetails1.Delivery_List_RMB__c;
                //     console.log(
                //         "shippingUnitPrice = " + tempData[i]["shippingUnitPrice"]
                //     );
                // if (tempData[i]["shippingUnitPrice"] && tempData[i]["shipmentNumber"])
                //     tempData[i]["shipmentAmount"] = this.amend(
                //         tempData[i]["shipmentNumber"],
                //         tempData[i]["shippingUnitPrice"],
                //         "*"
                //     );
                // }
                this.data = tempData;
                console.log("this.data = " + JSON.stringify(this.data));
                console.log('this.data = ' + JSON.stringify(this.data));
                console.log(
                    ' this.selectedRows = ' + JSON.stringify(this.selectedRows)
                );
                //this.showTable = true;
                this.isShowSpinner = false;
                this.isEditShowSpinner = false;
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
                console.log('r = ' + JSON.stringify(r));
                this.showToast('Error', r.msg);
            }
        });
    }
    searchHospitalNameModal() {
        console.log("searchHospitalNameModal");
        console.log('searchHospitalNameModal');
        hospitalInit({
            ctype: this.agencyProType,
            ctype: this.agencyProType
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            if (r.status == "Success") {
            if (r.status == 'Success') {
                this.hospitalList = r.entity.at;
                for (var i in this.hospitalList) {
                    this.hospitalList[i]["stateMasterName"] =
                    this.hospitalList[i]['stateMasterName'] =
                        this.hospitalList[i].State_Master__r.Name;
                }
                console.log("hospitalInit r = " + JSON.stringify(this.hospitalList));
                console.log(
                    'hospitalInit r = ' + JSON.stringify(this.hospitalList)
                );
                this.isModalOpen = true;
            }
        });
    }
    searchHospital() {
        console.log("this.searchHospitalName = " + this.searchHospitalName);
        console.log('this.searchHospitalName = ' + this.searchHospitalName);
        serContact({
            searchName: this.searchHospitalName,
            ctype: this.agencyProType,
            ctype: this.agencyProType
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            if (r.status == "Success") {
            if (r.status == 'Success') {
                this.hospitalList = r.entity.at;
                for (var i in this.hospitalList) {
                    this.hospitalList[i]["stateMasterName"] =
                    this.hospitalList[i]['stateMasterName'] =
                        this.hospitalList[i].State_Master__r.Name;
                }
                console.log("hospitalInit r = " + JSON.stringify(this.hospitalList));
                console.log(
                    'hospitalInit r = ' + JSON.stringify(this.hospitalList)
                );
            }
        });
    }
    searchHandleRowAction(event) {
        console.log("searchHandleRowAction");
        console.log('searchHandleRowAction');
        let row = event.detail.row;
        this.OECId = row.Id;
        this.HospitalName = row.Name;
        console.log(
            "this.OECId = " + this.OECId + " this.HospitalName = " + this.HospitalName
            'this.OECId = ' +
                this.OECId +
                ' this.HospitalName = ' +
                this.HospitalName
        );
        this.isModalOpen = false;
        console.log("this.isModalOpen = " + this.isModalOpen);
        console.log('this.isModalOpen = ' + this.isModalOpen);
    }
    clearAgencyI(event) {
        this.HospitalName = event.target.value;
        if (this.HospitalName == "" || this.HospitalName == null) {
            this.OECId = "";
        if (this.HospitalName == '' || this.HospitalName == null) {
            this.OECId = '';
        }
        console.log("this.HospitalName = " + this.HospitalName);
        console.log("this.OECId = " + this.OECId);
        if (this.OECId != null && this.OECId != "") {
        console.log('this.HospitalName = ' + this.HospitalName);
        console.log('this.OECId = ' + this.OECId);
        if (this.OECId != null && this.OECId != '') {
            this.checkOutPattern();
        }
    }
@@ -1334,9 +1567,9 @@
            }
        }
        if (ishos > 0) {
            this.cocLwc["OutPattern__c"] = true;
            this.cocLwc['OutPattern__c'] = true;
        } else {
            this.cocLwc["OutPattern__c"] = false;
            this.cocLwc['OutPattern__c'] = false;
        }
    }
@@ -1345,28 +1578,31 @@
    }
    handleUnitChange(event) {
        console.log("handleUnitChange");
        console.log('handleUnitChange');
        const unitDetail = event.detail;
        console.log("unitDetail = " + JSON.stringify(unitDetail));
        console.log('unitDetail = ' + JSON.stringify(unitDetail));
        for (var i in this.data) {
            if (this.data[i].recordId == unitDetail.data.recordId) {
                this.data[i].unitValue = unitDetail.data.unitValue;
                this.data[i].orderdetails1["Box_Piece__c"] = unitDetail.data.unitValue;
                this.data[i].orderdetails1['Box_Piece__c'] =
                    unitDetail.data.unitValue;
            }
        }
        console.log("this.data = " + JSON.stringify(this.data));
        console.log('this.data = ' + JSON.stringify(this.data));
    }
    handleShipmentNumber(event) {
        console.log("handleShipmentNumber");
        console.log('handleShipmentNumber');
        const numberDetail = event.detail;
        console.log("numberDetail = " + JSON.stringify(numberDetail));
        console.log('numberDetail = ' + JSON.stringify(numberDetail));
        let index = 0;
        for (var i in this.data) {
            if (this.data[i].recordId == numberDetail.data.recordId) {
                index = i;
                this.data[i].shipmentNumber = Number(numberDetail.data.shipmentnumber);
                this.data[i].orderdetails1["Shipment_Count__c"] = Number(
                this.data[i].shipmentNumber = Number(
                    numberDetail.data.shipmentnumber
                );
                this.data[i].orderdetails1['Shipment_Count__c'] = Number(
                    numberDetail.data.shipmentnumber
                );
            }
@@ -1379,7 +1615,7 @@
    }
    handleShipmentUnitPrice(event) {
        console.log("handleShipmentUnitPrice");
        console.log('handleShipmentUnitPrice');
        const priceDetail = event.detail;
        let index = 0;
        for (var i in this.data) {
@@ -1388,7 +1624,7 @@
                this.data[i].shippingUnitPrice = Number(
                    priceDetail.data.shipmentunitprice
                );
                this.data[i].orderdetails1["Delivery_List_RMB__c"] = Number(
                this.data[i].orderdetails1['Delivery_List_RMB__c'] = Number(
                    priceDetail.data.shipmentunitprice
                );
            }
@@ -1401,20 +1637,21 @@
    }
    ComputePrice(index, number, price) {
        console.log("index = " + index);
        console.log("number = " + number);
        console.log("price = " + price);
        let shipmentAmount = this.amend(number, price, "*");
        console.log("shipmentAmount = " + shipmentAmount);
        console.log('index = ' + index);
        console.log('number = ' + number);
        console.log('price = ' + price);
        let shipmentAmount = this.amend(number, price, '*');
        console.log('shipmentAmount = ' + shipmentAmount);
        let sumPrice = 0.0;
        this.data[index].shipmentAmount = shipmentAmount;
        for (var i in this.data) {
            if (this.data[i].shipmentAmount) sumPrice += this.data[i].shipmentAmount;
            if (this.data[i].shipmentAmount)
                sumPrice += this.data[i].shipmentAmount;
        }
        this.sumPrice = sumPrice.toFixed(2) + "元";
        this.sumPrice = sumPrice.toFixed(2) + '元';
        //存下选择行,不会被清空
        if (this.selectedRows.indexOf(this.data[index].Id) == -1)
            this.selectedRows.push(this.data[index].Id);
        // if (this.selectedRows.indexOf(this.data[index].Id) == -1)
        //     this.selectedRows.push(this.data[index].Id);
        // this.selectedRows = [];
        // for (var i in this.data) {
        //     if (this.data[i].check) {
@@ -1422,9 +1659,9 @@
        //     }
        // }
        this.data = [...this.data];
        this.selectedRows = [...this.selectedRows]
        console.log("this.selectedRows = " + JSON.stringify(this.selectedRows));
        console.log("this.data = " + JSON.stringify(this.data));
        this.selectedRows = [...this.selectedRows];
        console.log('this.selectedRows = ' + JSON.stringify(this.selectedRows));
        console.log('this.data = ' + JSON.stringify(this.data));
    }
    //num1 num2传入两个值  symbol +-*/符号
@@ -1436,12 +1673,12 @@
            str2Length;
        //解决整数没有小数点方法
        try {
            str1Length = str1.split(".")[1].length;
            str1Length = str1.split('.')[1].length;
        } catch (error) {
            str1Length = 0;
        }
        try {
            str2Length = str2.split(".")[1].length;
            str2Length = str2.split('.')[1].length;
        } catch (error) {
            str2Length = 0;
        }
@@ -1449,16 +1686,16 @@
        //
        console.log(step);
        switch (symbol) {
            case "+":
            case '+':
                result = (num1 * step + num2 * step) / step;
                break;
            case "-":
            case '-':
                result = (num1 * step - num2 * step) / step;
                break;
            case "*":
            case '*':
                result = (num1 * step * (num2 * step)) / step / step;
                break;
            case "/":
            case '/':
                result = (num1 * step) / (num2 * step);
                break;
            default:
@@ -1469,10 +1706,27 @@
    getSelectedRows(event) {
        let selectedRowsEvent = event.detail.selectedRows;
        console.log('selectedRowsEvent = ' + JSON.stringify(selectedRowsEvent));
        this.selectedRows = [];
        for (var i in selectedRowsEvent) {
            this.selectedRows.push(selectedRowsEvent[i].Id)
            this.selectedRows.push(selectedRowsEvent[i].Id);
        }
        // for (var i in this.data) {
        //     for (var j in selectedRowsEvent) {
        //         if (this.data[i].Id == selectedRowsEvent[j].Prod.Id) {
        //             this.ComputePrice(
        //                 i,
        //                 this.data[i].shipmentNumber,
        //                 this.data[i].shippingUnitPrice
        //             );
        //         }
        //     }
        // }
        // this.ComputePrice(
        //     index,
        //     this.data[index].shipmentNumber,
        //     this.data[index].shippingUnitPrice
        // );
        // const selectedRows = event.detail.selectedRows;
        // console.log("this.selectedRows = " + this.selectedRows);
        // for (var i in this.data) {
@@ -1488,8 +1742,8 @@
    }
    saveConfirmJs() {
        let msg = "出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!";
        if (this.SummonsStatus == "价格未定") {
        let msg = '出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!';
        if (this.SummonsStatus == '价格未定') {
            if (confirm(msg) == true) {
                this.saveConfirm();
            }
@@ -1502,42 +1756,44 @@
        this.isShowSpinner = true;
        //查询有哪些选择了的然后check
        const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        const selectedRows = this.template
            .querySelector('c-lex-custom-lightning-datatable')
            .getSelectedRows();
        console.log('selectedRows = ' + selectedRows);
        for (var i in this.data) {
            this.data[i]["check"] = false;
            this.data[i]['check'] = false;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                    this.data[i]['check'] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
            cloneData[i]["Category4"] = cloneData[i].Category4__c;
            cloneData[i]["Category5"] = cloneData[i].Category5__c;
            cloneData[i]["BoxPiece"] = cloneData[i].Box_Piece__c;
            cloneData[i]['Name'] = cloneData[i].Name__c;
            cloneData[i]['Category3'] = cloneData[i].Category3__c;
            cloneData[i]['Category4'] = cloneData[i].Category4__c;
            cloneData[i]['Category5'] = cloneData[i].Category5__c;
            cloneData[i]['BoxPiece'] = cloneData[i].Box_Piece__c;
            delete cloneData[i].Name__c;
            delete cloneData[i].Category3__c;
            delete cloneData[i].Category4__c;
            delete cloneData[i].Category5__c;
            delete cloneData[i].Box_Piece__c;
        }
        console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log("this.OECId = " + this.OECId);
        console.log("this.HospitalName = " + this.HospitalName);
        console.log("this.secondaryDistributor = " + this.secondaryDistributor);
        console.log("this.pageRecordsLwc = " + JSON.stringify(cloneData));
        console.log("this.accountid = " + this.accountid);
        console.log("this.ESetid = " + this.ESetid);
        console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
        console.log('this.OECId = ' + this.OECId);
        console.log('this.HospitalName = ' + this.HospitalName);
        console.log('this.secondaryDistributor = ' + this.secondaryDistributor);
        console.log('this.pageRecordsLwc = ' + JSON.stringify(cloneData));
        console.log('this.accountid = ' + this.accountid);
        console.log('this.ESetid = ' + this.ESetid);
        console.log(
            "this.consumableproductdetailsRecords = " +
            JSON.stringify(this.consumableproductdetailsRecords)
            'this.consumableproductdetailsRecords = ' +
                JSON.stringify(this.consumableproductdetailsRecords)
        );
        save({
            cocLwc: this.cocLwc,
@@ -1547,79 +1803,87 @@
            pageRecordsLwc: cloneData,
            accountidLwc: this.accountid,
            ESetIdLwc: this.ESetid,
            consumableproductdetailsRecordsLwc: this.consumableproductdetailsRecords,
            consumableproductdetailsRecordsLwc:
                this.consumableproductdetailsRecords,
            agencyProTypeLwc: this.agencyProType,
            userWorkLocationLwc: this.userWorkLocation
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            debugger
            if (r.status == "Success") {
                let url = "/lexsummonscreat?ESetid=" + r.entity.ESetId;
                this[NavigationMixin.Navigate]({
                    type: "standard__webPage",
                    attributes: {
                        url: url,
                    },
                });
            } else {
                console.log("r.msg = " + r.msg);
                this.showToast("Error", r.msg);
            }
        }).catch((error) => {
            console.log("error = " + JSON.stringify(error));
        });
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                debugger;
                if (r.status == 'Success') {
                    let url = '/lexsummonscreat?ESetid=' + r.entity.ESetId;
                    this[NavigationMixin.Navigate]({
                        type: 'standard__webPage',
                        attributes: {
                            url: url
                        }
                    });
                } else {
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
    //打印指示单
    PraseToPDFJs() {
        console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log("this.ESetId = " + this.ESetid);
        console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
        console.log('this.ESetId = ' + this.ESetid);
        PraseToPDF({
            cocLwc: this.cocLwc,
            ESetId: this.ESetid,
            ESetId: this.ESetid
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                window.open("/customer/summonsPDF?ESetid=" + r.entity.ESetId);
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                window.open('/customer/summonsPDF?ESetid=' + r.entity.ESetId);
            } else {
                console.log("r.msg = " + r.msg);
                this.showToast("Error", r.msg);
                console.log('r.msg = ' + r.msg);
                this.showToast('Error', r.msg);
            }
        });
    }
    //显示明细
    openReportJs() {
        console.log("openReportJs");
        console.log('openReportJs');
        var reportId = this.ESetid;
        reportId = reportId.substring(0, 15);
        let reportFilters = '[{"operator":"equals","value":"' + reportId + '","column":"FK_CUSTENT_ID"}]';
        let url = "/report/00O0l000000zZtpEAE?reportFilters=" + encodeURIComponent(reportFilters);
        console.log("url = " + url);
        let reportFilters =
            '[{"operator":"equals","value":"' +
            reportId +
            '","column":"FK_CUSTENT_ID"}]';
        let url =
            '/report/00O0l000000zZtpEAE?reportFilters=' +
            encodeURIComponent(reportFilters);
        console.log('url = ' + url);
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            type: 'standard__webPage',
            attributes: {
                url: url,
            },
                url: url
            }
        });
    }
    vpClear2Delay(event) {
        console.log("vpClear2Delay");
        if (this.summonsForDirction != "互相调货") {
            this.cocLwc["Order_ForDealerText__c"] = event.target.value;
            console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log('vpClear2Delay');
        if (this.summonsForDirction != '互相调货') {
            this.cocLwc['Order_ForDealerText__c'] = event.target.value;
            console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
        } else {
            //console.log('Order_ForDealerTextID__c = ' + this.cocLwc['Order_ForDealerTextID__c'])
            this.cocLwc["Order_ForDealerText__c"] =
                this.cocLwc["Order_ForDealerTextID__c"] == "" ||
                    this.cocLwc["Order_ForDealerTextID__c"] == null ||
                    this.cocLwc["Order_ForDealerTextID__c"] == undefined
                    ? ""
                    : this.cocLwc["Order_ForDealerText__c"];
            console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
            this.cocLwc['Order_ForDealerText__c'] =
                this.cocLwc['Order_ForDealerTextID__c'] == '' ||
                this.cocLwc['Order_ForDealerTextID__c'] == null ||
                this.cocLwc['Order_ForDealerTextID__c'] == undefined
                    ? ''
                    : this.cocLwc['Order_ForDealerText__c'];
            console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
            // console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
            // this.ForDealerText = this.cocLwc['Order_ForDealerText__c'];
            // event.target.value = this.cocLwc['Order_ForDealerText__c'];
@@ -1628,28 +1892,28 @@
    }
    handleSearch(event) {
        const lookupElement = event.target;
        console.log("event.detail = " + JSON.stringify(event.detail));
        console.log('event.detail = ' + JSON.stringify(event.detail));
        apexSearch({
            searchTerm: event.detail.searchTerm,
            searchTerm: event.detail.searchTerm
        })
            .then((results) => {
                lookupElement.setSearchResults(results);
            })
            .catch((error) => {
                console.log("error" + JSON.stringify(error));
                console.log('error' + JSON.stringify(error));
            });
    }
    handleSelectionChange(event) {
        const selection = event.target.getSelection();
        console.log("selection = " + JSON.stringify(selection));
        this.cocLwc["Order_ForDealerTextID__c"] = selection[0].id;
        this.cocLwc["Order_ForDealerText__c"] = selection[0].title;
        console.log("this.cocLwc = " + JSON.stringify(this.cocLwc));
        console.log('selection = ' + JSON.stringify(selection));
        this.cocLwc['Order_ForDealerTextID__c'] = selection[0].id;
        this.cocLwc['Order_ForDealerText__c'] = selection[0].title;
        console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc));
    }
    handleFilesChange(event) {
        console.log("handleFilesChange");
        console.log('handleFilesChange');
        if (event.target.files.length > 0) {
            this.filesUploaded = event.target.files;
            this.fileName = event.target.files[0].name;
@@ -1657,11 +1921,11 @@
    }
    handleSave() {
        console.log("saveFile");
        console.log('saveFile');
        if (this.filesUploaded.length > 0) {
            this.file = this.filesUploaded[0];
            if (this.file.size > this.MAX_FILE_SIZE) {
                this.showToast("Error", "文件过大");
                this.showToast('Error', '文件过大');
                return;
            }
            this.showPopSpinner = true;
@@ -1669,60 +1933,62 @@
            this.fileReader.onloadend = () => {
                this.fileContents = this.fileReader.result;
                let base64 = "base64,";
                this.content = this.fileContents.indexOf(base64) + base64.length;
                let base64 = 'base64,';
                this.content =
                    this.fileContents.indexOf(base64) + base64.length;
                this.fileContents = this.fileContents.substring(this.content);
                this.saveToFile();
            };
            this.fileReader.readAsDataURL(this.file);
        } else {
            this.fileName = "选择一个文件上传";
            this.fileName = '选择一个文件上传';
        }
    }
    saveToFile() {
        console.log("saveToFile");
        console.log("base64Data = " + encodeURIComponent(this.fileContents));
        console.log('saveToFile');
        console.log('base64Data = ' + encodeURIComponent(this.fileContents));
        saveFile({
            recordId: this.ESetid,
            fileName: this.fileName,
            base64Data: encodeURIComponent(this.fileContents),
            base64Data: encodeURIComponent(this.fileContents)
        })
            .then((r) => {
                this.showPopSpinner = false;
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                this.closePop();
                this.showToast("Success", "上传成功");
                this.showToast('Success', '上传成功');
                this.getFiles();
            })
            .catch((error) => {
                this.showPopSpinner = false;
                console.log("error = " + error.message);
                this.showToast("Error", "上传失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '上传失败');
            });
    }
    getFiles() {
        console.log("getFiles");
        console.log('getFiles');
        this.showLoadingSpinner = true;
        getFiles({
            recordId: this.ESetid,
            recordId: this.ESetid
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                this.fileData = r.entity.cvList;
                for (var i in this.fileData) {
                    this.fileData[i]["CreatedByName"] = this.fileData[i].CreatedBy.Name;
                    this.fileData[i]["url"] = "/" + this.fileData[i].Id;
                    this.fileData[i]['CreatedByName'] =
                        this.fileData[i].CreatedBy.Name;
                    this.fileData[i]['url'] = '/' + this.fileData[i].Id;
                }
                console.log("this.fileData = " + this.fileData);
                console.log('this.fileData = ' + this.fileData);
                this.showLoadingSpinner = false;
            })
            .catch((error) => {
                console.log("error = " + error.message);
                this.showToast("Error", "获取附件失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '获取附件失败');
            });
    }
@@ -1730,93 +1996,100 @@
        this.isShowSpinner = true;
        //查询有哪些选择了的然后check
        const selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        const selectedRows = this.template
            .querySelector('c-lex-custom-lightning-datatable')
            .getSelectedRows();
        console.log('selectedRows = ' + selectedRows);
        for (var i in this.data) {
            this.data[i]["check"] = false;
            this.data[i]['check'] = false;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                    this.data[i]['check'] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
            cloneData[i]["Category4"] = cloneData[i].Category4__c;
            cloneData[i]["Category5"] = cloneData[i].Category5__c;
            cloneData[i]["BoxPiece"] = cloneData[i].Box_Piece__c;
            cloneData[i]['Name'] = cloneData[i].Name__c;
            cloneData[i]['Category3'] = cloneData[i].Category3__c;
            cloneData[i]['Category4'] = cloneData[i].Category4__c;
            cloneData[i]['Category5'] = cloneData[i].Category5__c;
            cloneData[i]['BoxPiece'] = cloneData[i].Box_Piece__c;
            delete cloneData[i].Name__c;
            delete cloneData[i].Category3__c;
            delete cloneData[i].Category4__c;
            delete cloneData[i].Category5__c;
            delete cloneData[i].Box_Piece__c;
        }
        console.log("cloneData = " + JSON.stringify(cloneData));
        console.log('cloneData = ' + JSON.stringify(cloneData));
        GoodsDelivery({
            cocLwc: this.cocLwc,
            ESetId: this.ESetid,
            pageRecordsLwcLwc: cloneData,
            pageRecordsLwcLwc: cloneData
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log(
                        "Summons_Order_type__c = " + this.cocLwc["Summons_Order_type__c"]
                        'Summons_Order_type__c = ' +
                            this.cocLwc['Summons_Order_type__c']
                    );
                    this.isSales =
                        this.cocLwc["Summons_Order_type__c"] == "销售" ? true : false;
                        this.cocLwc['Summons_Order_type__c'] == '销售'
                            ? true
                            : false;
                    this.GoodsDeliveryInit();
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
                this.isShippingSales = true;
            })
            .catch((error) => {
                console.log("error = " + error.message);
                this.showToast("Error", "跳转失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '跳转失败');
            });
    }
    GoodsDeliveryInit() {
        console.log("GoodsDeliveryInit");
        console.log('GoodsDeliveryInit');
        GoodsDeliveryInit({
            ESetId: this.ESetid,
            ESetId: this.ESetid
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.salesCoc = r.entity.coc;
                    this.salesAccountName = r.entity.accountName;
                    this.salesUserWorkLocation = r.entity.userWorkLocation;
                    this.salesAccountid = r.entity.accountid;
                    this.salesOrderdetails = r.entity.orderdetails;
                    this.salesData = r.entity.consumableorderdetailsRecords;
                    this.salesErrorData = r.entity.consumableorderdetailsRecordserror;
                    this.salesErrorData =
                        r.entity.consumableorderdetailsRecordserror;
                    this.salesOrderpieceorboxMap = r.entity.orderpieceorboxMap;
                    this.salesOrderpriceMap = r.entity.orderpriceMap;
                    this.salesOrderagencypriceMap = r.entity.orderagencypriceMap;
                    this.salesOrderagencypriceMap =
                        r.entity.orderagencypriceMap;
                    this.isShowSpinner = false;
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + error.message);
                this.showToast("Error", "初始化失败");
                console.log('error = ' + error.message);
                this.showToast('Error', '初始化失败');
            });
    }
    SalesearchProductJs() {
        console.log("this.Barcode = " + this.Barcode);
        console.log('this.Barcode = ' + this.Barcode);
        this.isShowSpinner = true;
        SearchPro({
            cocLwc: this.salesCoc,
@@ -1825,55 +2098,65 @@
            userWorkLocation: this.salesUserWorkLocation,
            accountid: this.salesAccountid,
            orderdetails: this.salesOrderdetails,
            orderpieceorboxMap: this.salesOrderpieceorboxMap,
            orderpieceorboxMap: this.salesOrderpieceorboxMap
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                    console.log("SearchPro success");
                    this.salesErrorData = r.entity.consumableorderdetailsRecordserror;
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log('SearchPro success');
                    this.salesErrorData =
                        r.entity.consumableorderdetailsRecordserror;
                    this.salesData = r.entity.consumableorderdetailsRecords;
                    for (var i in this.salesErrorData) {
                        this.salesErrorData[i]["Consumable_order_minor__c"] =
                            this.salesErrorData[i].orderdetails2.Consumable_order_minor__c;
                        this.salesErrorData[i]["orderdetails2Name"] =
                        this.salesErrorData[i]['Consumable_order_minor__c'] =
                            this.salesErrorData[
                                i
                            ].orderdetails2.Consumable_order_minor__c;
                        this.salesErrorData[i]['orderdetails2Name'] =
                            this.salesErrorData[i].orderdetails2.Name;
                        this.salesErrorData[i]["ProdName"] =
                        this.salesErrorData[i]['ProdName'] =
                            this.salesErrorData[i].Prod.Name;
                        this.salesErrorData[i]["Box_Piece__c"] =
                        this.salesErrorData[i]['Box_Piece__c'] =
                            this.salesErrorData[i].orderdetails2.Box_Piece__c;
                        this.salesErrorData[i]["Bar_Code__c"] =
                        this.salesErrorData[i]['Bar_Code__c'] =
                            this.salesErrorData[i].orderdetails2.Bar_Code__c;
                        this.salesErrorData[i]["Sterilization_limit__c"] =
                            this.salesErrorData[i].orderdetails2.Sterilization_limit__c;
                        this.salesErrorData[i]['Sterilization_limit__c'] =
                            this.salesErrorData[
                                i
                            ].orderdetails2.Sterilization_limit__c;
                    }
                    for (var i in this.salesData) {
                        this.salesData[i]["Consumable_order_minor__c"] =
                            this.salesData[i].orderdetails2.Consumable_order_minor__c;
                        this.salesData[i]["orderdetails2Name"] =
                        this.salesData[i]['Consumable_order_minor__c'] =
                            this.salesData[
                                i
                            ].orderdetails2.Consumable_order_minor__c;
                        this.salesData[i]['orderdetails2Name'] =
                            this.salesData[i].orderdetails2.Name;
                        this.salesData[i]["orderdetails2NameUrl"] =
                            "/" + this.salesData[i].orderdetails2.Id;
                        this.salesData[i]["Box_Piece__c"] =
                        this.salesData[i]['orderdetails2NameUrl'] =
                            '/' + this.salesData[i].orderdetails2.Id;
                        this.salesData[i]['Box_Piece__c'] =
                            this.salesData[i].orderdetails2.Box_Piece__c;
                        this.salesData[i]["ProdName"] = this.salesData[i].Prod.Name;
                        this.salesData[i]["Deliver_date__c"] =
                        this.salesData[i]['ProdName'] =
                            this.salesData[i].Prod.Name;
                        this.salesData[i]['Deliver_date__c'] =
                            this.salesData[i].orderdetails2.Deliver_date__c;
                        this.salesData[i]["Bar_Code__c"] =
                        this.salesData[i]['Bar_Code__c'] =
                            this.salesData[i].orderdetails2.Bar_Code__c;
                        this.salesData[i]["Sterilization_limit__c"] =
                            this.salesData[i].orderdetails2.Sterilization_limit__c;
                        this.salesData[i]['Sterilization_limit__c'] =
                            this.salesData[
                                i
                            ].orderdetails2.Sterilization_limit__c;
                    }
                    this.isShowSpinner = false;
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + JSON.stringify(error.message));
                this.showToast("Error", "初始化失败");
                console.log('error = ' + JSON.stringify(error.message));
                this.showToast('Error', '初始化失败');
            });
    }
@@ -1888,7 +2171,7 @@
            delete cloneSalesData[i].Deliver_date__c;
            delete cloneSalesData[i].Bar_Code__c;
            delete cloneSalesData[i].Sterilization_limit__c;
            cloneSalesData[i]["ErrorReason"] = "";
            cloneSalesData[i]['ErrorReason'] = '';
        }
        this.isShowSpinner = true;
        ProSale({
@@ -1900,28 +2183,28 @@
            consumableorderdetailsRecordsLwc: JSON.stringify(cloneSalesData),
            orderdetails: this.salesOrderdetails,
            orderpriceMap: this.salesOrderpriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                    console.log("ProdElivery success");
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log('ProdElivery success');
                    this.isShowSpinner = false;
                    this[NavigationMixin.Navigate]({
                        type: "standard__webPage",
                        type: 'standard__webPage',
                        attributes: {
                            url: "/lexsaleanddelivery",
                        },
                            url: '/lexsaleanddelivery'
                        }
                    });
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + JSON.stringify(error.message));
                this.showToast("Error", "ProSale2失败");
                console.log('error = ' + JSON.stringify(error.message));
                this.showToast('Error', 'ProSale2失败');
            });
    }
@@ -1936,7 +2219,7 @@
            delete cloneSalesData[i].Deliver_date__c;
            delete cloneSalesData[i].Bar_Code__c;
            delete cloneSalesData[i].Sterilization_limit__c;
            cloneSalesData[i]["ErrorReason"] = "";
            cloneSalesData[i]['ErrorReason'] = '';
        }
        this.isShowSpinner = true;
        ProdElivery({
@@ -1948,28 +2231,28 @@
            consumableorderdetailsRecordsLwc: JSON.stringify(cloneSalesData),
            orderdetails: this.salesOrderdetails,
            orderpriceMap: this.salesOrderpriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap,
            orderagencypriceMap: this.salesOrderagencypriceMap
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                    console.log("ProdElivery success");
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    console.log('ProdElivery success');
                    this.isShowSpinner = false;
                    this[NavigationMixin.Navigate]({
                        type: "standard__webPage",
                        type: 'standard__webPage',
                        attributes: {
                            url: "/lexsaleanddelivery",
                        },
                            url: '/lexsaleanddelivery'
                        }
                    });
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showToast("Error", r.msg);
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log("error = " + JSON.stringify(error.message));
                this.showToast("Error", "初始化失败");
                console.log('error = ' + JSON.stringify(error.message));
                this.showToast('Error', '初始化失败');
            });
    }
@@ -1978,15 +2261,23 @@
        let url = '';
        console.log('this.invoiceId = ' + this.invoiceId);
        if (this.invoiceId.length > 0 && this.invoiceId != '000000000000000') {
            url = "/lexconinvoiceview?deliveryId=" + this.ESetid + "&invoiceId=" + this.invoiceId + "&KeyWords=Redirect";
            url =
                '/lexconinvoiceview?deliveryId=' +
                this.ESetid +
                '&invoiceId=' +
                this.invoiceId +
                '&KeyWords=Redirect';
        } else {
            url = "/lexconinvoiceview?deliveryId=" + this.ESetid + "&KeyWords=Redirect";
            url =
                '/lexconinvoiceview?deliveryId=' +
                this.ESetid +
                '&KeyWords=Redirect';
        }
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            type: 'standard__webPage',
            attributes: {
                url: url,
            },
                url: url
            }
        });
    }
@@ -1994,33 +2285,35 @@
    DeleteConsumable() {
        this.isShowSpinner = true;
        DelConsumable({
            ESetId: this.ESetid,
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                let url = "/lexsaleanddelivery";
                this[NavigationMixin.Navigate]({
                    type: "standard__webPage",
                    attributes: {
                        url: url,
                    },
                });
            } else {
                console.log("r.msg = " + r.msg);
                this.showToast("Error", r.msg);
            }
        }).catch((error) => {
            console.log("error = " + error.message);
            this.showToast("Error", "跳转失败");
        });
            ESetId: this.ESetid
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    let url = '/lexsaleanddelivery';
                    this[NavigationMixin.Navigate]({
                        type: 'standard__webPage',
                        attributes: {
                            url: url
                        }
                    });
                } else {
                    console.log('r.msg = ' + r.msg);
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log('error = ' + error.message);
                this.showToast('Error', '跳转失败');
            });
    }
    handleLoad() {
        console.log('handleLoad')
        console.log('handleLoad');
        try {
            const style = document.createElement('style');
            style.innerText = '.slds-button__icon {display: none;}';
            //style.innerText = '.slds-button__icon {display: none;}';
            this.template.querySelector('.hideHelpText').appendChild(style);
        } catch (error) {
            console.log(error);
@@ -2028,14 +2321,15 @@
    }
    handleLoad2() {
        console.log('handleLoad2')
        console.log('handleLoad2');
        try {
            const style = document.createElement('style');
            style.innerText = '.slds-button__icon {display: none;}';
            // style.innerText = '.slds-button__icon {display: none;}';
            this.template.querySelector('.hideHelpText').appendChild(style);
            const style2 = document.createElement('style');
            style2.innerText = '.hehe-layoutItem  .slds-form-element__label {padding : 0px}';
            style2.innerText =
                '.hehe-layoutItem  .slds-form-element__label {padding : 0px}';
            this.template.querySelector('.hideHelpText').appendChild(style2);
        } catch (error) {
            console.log(error);
@@ -2043,12 +2337,13 @@
    }
    //编辑出库单
    EditConsumable() {
        let url = "/lexsummonscreat?ESetid=" + this.ESetid + "&KeyWords=Redirect";
        let url =
            '/lexsummonscreat?ESetid=' + this.ESetid + '&KeyWords=Redirect';
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            type: 'standard__webPage',
            attributes: {
                url: url,
            },
                url: url
            }
        });
    }
@@ -2068,7 +2363,11 @@
    //是否显示附件移除
    get attDelBtn() {
        if (this.fileName != '' && this.fileName != null && this.fileName != '请选择一个文件上传') {
        if (
            this.fileName != '' &&
            this.fileName != null &&
            this.fileName != '请选择一个文件上传'
        ) {
            return true;
        } else {
            return false;
@@ -2095,4 +2394,211 @@
        this.Category5 = '';
        this.searchProductJs();
    }
}
    sortBy(field, reverse, primer) {
        const key = primer
            ? function (x) {
                  return primer(x[field]);
              }
            : function (x) {
                  return x[field];
              };
        return function (a, b) {
            a = key(a);
            b = key(b);
            return reverse * ((a > b) - (b > a));
        };
    }
    onHandleSort(event) {
        //将已经选好了的放到前面,不进行排序
        if (this.EditAble) {
            const { fieldName: sortedBy, sortDirection } = event.detail;
            const cloneData = [...this.data];
            cloneData.sort(
                this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)
            );
            let index = 0;
            let selectedRows = this.template
                .querySelector('c-lex-custom-lightning-datatable')
                .getSelectedRows();
            let selectedRowsIds = [];
            for (var i in selectedRows) {
                selectedRowsIds.push(selectedRows[i].Id);
            }
            console.log('selectedRowsIds = ' + JSON.stringify(selectedRowsIds));
            for (var i = 0; i < cloneData.length; i++) {
                if (selectedRowsIds.indexOf(cloneData[i].Id) != -1) {
                    if (i != 0) {
                        let temp = cloneData[index];
                        cloneData[index] = cloneData[i];
                        cloneData[i] = temp;
                    }
                    index++;
                }
            }
            this.data = cloneData;
            this.sortDirection = sortDirection;
            this.sortedBy = sortedBy;
        } else {
            const { fieldName: sortedBy, sortDirection } = event.detail;
            const cloneData = [...this.editData];
            cloneData.sort(
                this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)
            );
            this.editData = cloneData;
            this.sortDirection = sortDirection;
            this.sortedBy = sortedBy;
        }
    }
    handlePrevious() {
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.searchProductJs();
    }
    handleNext() {
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.searchProductJs();
    }
    handleFirst() {
        this.currentPageToken = 0;
        this.searchProductJs();
    }
    handleLast() {
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.searchProductJs();
    }
    handlePageschange(event) {
        console.log(event.detail);
        this.pageSize = event.detail;
        this.currentPageToken = 0;
        this.searchProductJs();
    }
    editHandlePrevious() {
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.searchEditProductJs();
    }
    editHandleNext() {
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.searchEditProductJs();
    }
    editHandleFirst() {
        this.currentPageToken = 0;
        this.searchEditProductJs();
    }
    editHandleLast() {
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.searchEditProductJs();
    }
    editHandlePageschange(event) {
        console.log(event.detail);
        this.pageSize = event.detail;
        this.currentPageToken = 0;
        this.searchEditProductJs();
    }
    searchEditProductJs() {
        this.isEditShowSpinner = true;
        this.showTable = false;
        init({
            ESetidJs: this.ESetid,
            statusEdit: this.statusEdit,
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    //分页
                    console.log(
                        'r.entity.paginatedAccounts = ' +
                            JSON.stringify(r.entity.paginatedAccounts)
                    );
                    this.nextPageToken =
                        r.entity.paginatedAccounts.nextPageToken;
                    this.totalRecords = r.entity.paginatedAccounts.totalRecords;
                    this.recordStart = r.entity.paginatedAccounts.recordStart;
                    this.recordEnd = r.entity.paginatedAccounts.recordEnd;
                    this.totalPages = Math.ceil(
                        r.entity.paginatedAccounts.totalRecords / this.pageSize
                    );
                    console.log('this.totalPages = ' + this.totalPages);
                    this.editData = r.entity.pageRecords;
                    console.log(
                        'this.data start = ' + JSON.stringify(this.data)
                    );
                    for (var i in this.editData) {
                        this.editData[i]['unitValue'] =
                            this.editData[i]['unitValue'];
                        this.editData[i]['InvoiceProNot_count__c'] =
                            this.editData[
                                i
                            ].orderdetails1.InvoiceProNot_count__c;
                        this.editData[i]['RrturnPro_count__c'] =
                            this.editData[i].orderdetails1.RrturnPro_count__c;
                        this.editData[i]['Invoiced_Procount__c'] =
                            this.editData[i].orderdetails1.Invoiced_Procount__c;
                        this.editData[i]['shipmentNumber'] =
                            this.editData[i].orderdetails1['Shipment_Count__c'];
                        this.editData[i]['shippingUnitPrice'] =
                            this.editData[i].orderdetails1[
                                'Delivery_List_RMB__c'
                            ];
                        this.editData[i]['recordId'] = this.editData[i].Prod.Id;
                        this.editData[i]['Id'] = this.editData[i].Prod.Id;
                        this.editData[i]['Name__c'] =
                            this.editData[i].Prod.Name__c;
                        this.editData[i]['SFDA_Status__c'] =
                            this.editData[i].Prod.SFDA_Status__c;
                        this.editData[i]['Category3__c'] =
                            this.editData[i].Prod.Category3__c;
                        this.editData[i]['Category4__c'] =
                            this.editData[i].Prod.Category4__c;
                        this.editData[i]['Category5__c'] =
                            this.editData[i].Prod.Category5__c;
                        this.editData[i]['Box_Piece__c'] =
                            this.editData[i].orderdetails1.Box_Piece__c;
                        this.editData[i]['shipmentAmount'] =
                            this.editData[i].orderdetails1.Shipment_amount__c;
                        this.editData[i]['Shipment_amount__c'] =
                            this.editData[i].orderdetails1.Shipment_amount__c;
                        this.editData[i]['Shipment_Count__c'] =
                            this.editData[i].orderdetails1.Shipment_Count__c;
                    }
                    this.showTable = true;
                    this.isEditShowSpinner = false;
                } else {
                    console.log('r = ' + JSON.stringify(r));
                    this.showToast('Error', r.msg);
                }
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
    get previousButtonDisabled() {
        return this.currentPageToken === 0;
    }
    get nextButtonDisabled() {
        return this.nextPageToken === undefined;
    }
}
force-app/main/default/lwc/paginatedList/paginatedList.html
@@ -1,6 +1,9 @@
<template>
    <template if:true={loader}>
        <lightning-spinner alternative-text="Loading..." size="small"></lightning-spinner>
        <lightning-spinner
            alternative-text="Loading..."
            size="small"
        ></lightning-spinner>
    </template>
    <template if:true={records}>
        <div class="table-container">
@@ -14,14 +17,13 @@
            >
            </lightning-datatable>
        </div>
        <c-paginator
            if:true={paginationVisibility}
        <c-paginator
            onprevious={handlePrevious}
            onnext={handleNext}
            onpageschange={handlePageschange}
            onfirst={handleFirst}
            onlast={handleLast}
            page-size-options={pageSizeOptions}
            page-size-options={pageSizeOptions}
            previous-button-disabled={previousButtonDisabled}
            next-button-disabled={nextButtonDisabled}
            record-start={recordStart}
@@ -32,4 +34,4 @@
    <template if:true={error}>
        <c-error-panel errors={error}></c-error-panel>
    </template>
</template>
</template>
force-app/main/default/lwc/paginatedList/paginatedList.js
@@ -1,36 +1,36 @@
import { LightningElement, api, track } from "lwc";
import getAccountsPaginated from "@salesforce/apex/PaginatedListControllerLwc.getAccountsPaginated";
import { LightningElement, api, track } from 'lwc';
import getAccountsPaginated from '@salesforce/apex/PaginatedListControllerLwc.getAccountsPaginated';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { reduceErrors } from 'c/ldsUtils';
import ACCOUNT_NAME_FIELD from "@salesforce/schema/Account.Name";
import ACCOUNT_TYPE_FIELD from "@salesforce/schema/Account.Type";
import ACCOUNT_PHONE_FIELD from "@salesforce/schema/Account.Type";
import ACCOUNT_EMPLOYEES_FIELD from "@salesforce/schema/Account.NumberOfEmployees";
import ACCOUNT_NAME_FIELD from '@salesforce/schema/Account.Name';
import ACCOUNT_TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_PHONE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_EMPLOYEES_FIELD from '@salesforce/schema/Account.NumberOfEmployees';
const COLUMNS = [
    {
        label: "Account Name",
        label: 'Account Name',
        fieldName: ACCOUNT_NAME_FIELD.fieldApiName,
        type: "text",
        sortable: "true"
        type: 'text',
        sortable: 'true'
    },
    { label: "Type", fieldName: ACCOUNT_TYPE_FIELD.fieldApiName, type: "text" },
    { label: 'Type', fieldName: ACCOUNT_TYPE_FIELD.fieldApiName, type: 'text' },
    {
        label: "Phone",
        label: 'Phone',
        fieldName: ACCOUNT_PHONE_FIELD.fieldApiName,
        type: "phone"
        type: 'phone'
    },
    {
        label: "Employees",
        label: 'Employees',
        fieldName: ACCOUNT_EMPLOYEES_FIELD.fieldApiName,
        type: "Number"
        type: 'Number'
    }
];
export default class PaginatedList extends LightningElement {
    columns = COLUMNS;
    @track sortBy = "Name";
    @track sortDirection = "asc";
    @track sortBy = 'Name';
    @track sortDirection = 'asc';
    @track pageSize = 10;
    error;
    records;
@@ -61,8 +61,11 @@
                    this.totalRecords = result.totalRecords;
                    this.recordStart = result.recordStart;
                    this.recordEnd = result.recordEnd;
                    this.totalPages = Math.ceil(result.totalRecords / this.pageSize);
                    this.paginationVisibility = this.totalPages > 1 ? true : false;
                    this.totalPages = Math.ceil(
                        result.totalRecords / this.pageSize
                    );
                    this.paginationVisibility =
                        this.totalPages > 1 ? true : false;
                }
            })
            .catch((error) => {
@@ -78,7 +81,7 @@
            });
    }
    doSorting(event) {
        console.log("Sort");
        console.log('Sort');
        this.sortBy = event.detail.fieldName;
        this.sortDirection = event.detail.sortDirection;
        this.currentPageToken = 0;
@@ -86,12 +89,14 @@
    }
    handlePrevious() {
        this.currentPageToken = Number(this.currentPageToken) - Number(this.pageSize);
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.getAccounts();
    }
    handleNext() {
        this.currentPageToken = Number(this.currentPageToken) + Number(this.pageSize);
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.getAccounts();
    }
    handleFirst() {
@@ -100,7 +105,8 @@
    }
    handleLast() {
        this.currentPageToken = this.totalPages > 1? (this.totalPages-1)* this.pageSize:0;
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.getAccounts();
    }
@@ -117,4 +123,4 @@
    get nextButtonDisabled() {
        return this.nextPageToken === undefined;
    }
}
}
force-app/main/default/pages/summonsCreat.page
@@ -1,489 +1,643 @@
<apex:page Controller="summonsCreatController" showHeader="true" tabStyle="SaleAndDelivery__tab" sidebar="true" id="allPage" action="{!init}" title="出库单管理">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<apex:includeScript value="{!URLFOR($Resource.summonsCreatJs)}"/>
<apex:stylesheet value="{!URLFOR($Resource.jquerysuggestcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquerysuggestjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<script type="text/javascript">
function setFocusOnLoad() {}
function bodyOnLoad(){setFocusOnLoad();}
function searchsearchAgencyH(str){
    //update by rentx 2021-3-1 start
    //先判断当前经销商下是否有维护特价医院 如果没有维护特价医院 那么直接查询所有医院
    var flag = j$(escapeVfId('allPage:allForm:allBlock:Editable:OutPattern01')).value();
    j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).attr('readonly',true);
    if ({!hasHos == false}) {
        openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos=', 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
    }else{
        var noOfRecords = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
        var ishosNum = 0;
        for (var i = 0; i < noOfRecords; i++) {
            var tempCheckVar = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:'+i+':variableinfo:consumablesCountproRowCheckbox')).value();
            var tempHosVar = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:'+i+':hosOffer')).value();
            var tempHosProVar = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:'+i+':hosPro')).value();
            console.log('tempHosProVar:'+tempHosProVar);
            if (((tempCheckVar == true || tempCheckVar == 'on') || {!Existarrive}) && (tempHosVar == true || tempHosVar == 'true') && (tempHosProVar == true || tempHosProVar == 'true')) {
                ishosNum ++;
            }
        }
        // alert({!Existarrive} + flag);
        console.log('34:'+ishosNum);
        if (ishosNum > 0 || ({!Existarrive} && flag == 'true')) {
        // if (ishosNum > 0) {
            openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos=true', 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
        }else{
            openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos=', 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
        }
    }
    //update by rentx 2021-01-29 start
    // j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).attr('readonly',true);
    // openPopup('/customer/searchAgencyHospital?Ctype=' + str, 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
    // var flag = j$(escapeVfId('allPage:allForm:allBlock:Editable:OutPattern01')).value();
    // j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).attr('readonly',true);
    // openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos='+flag, 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
    //update by rentx 2021-01-29 end
    //update by rentx 2021-3-1 end
}
function clearAgencyI(){
    var agencyname = j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).value();
    if (agencyname == '' || agencyname == null) {
        document.getElementById('allPage:allForm:allBlock:Editable:OECId').value = "";
    }
    var accid = j$(escapeVfId('allPage:allForm:allBlock:Editable:OECId')).value();
    if (accid != null && accid != '') {
        checkOutPatternFn();
    }
}
// vivek update start
function saveConfirmJs(str){
    var msg = "出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!";
    if(str == '价格未定'){
        if(confirm(msg)==true){
            saveJs();
        }
    }else{
        saveJs();
    }
}
// vivek update end
function setVisitorPlace(){
    var x = j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value();
    if (x == '互相调货') {
        try{
            var str = 'allPage:allForm:allBlock:Editable:Order_ForDealerText';
            var strPage = null;
            var options = {};
            var ros = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).value();
            strPage = '/customer/apex/ConSearchAgencyPlace?r=' + encodeURI(ros);
            options = {minchars:3, minwords:1, resultsClass:'visitorplace_results'};
            jQuery(escapeVfId(str)).unbind();
            if (strPage != null) {
                jQuery(escapeVfId(str)).suggest(strPage,options);
            }
        }catch(e){
            alert(e);
        }
    }
    else{
        var agencytext = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).value();
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).val(agencytext);
        //alert('1' + agencytext);
        //alert('2' + j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).value());
    }
}
function vpClear2_delay(){
    var x = j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value();
    if (x == '互相调货') {
        var vp = 'allPage:allForm:allBlock:Editable:Order_ForDealerText';
        var vpHidden = 'allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden';
        setTimeout(
            function() {
                if(j$(escapeVfId(vp)).attr("jquerysuggest_skip_flag") == "false") {
                    if (j$(escapeVfId(vp)).value() != j$(escapeVfId(vpHidden)).value()) {
                        vpClear2();
                    }
                }
            },
            200
        );
    }
    else{
        var agencytext = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).value();
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).val(agencytext);
    }
}
function vpClear2(){
  var vp = 'allPage:allForm:allBlock:Editable:Order_ForDealerText';
  var vpHidden = 'allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden';
  // alert('vp=' + j$(escapeVfId(vp)).value());
  // alert('vpHidden=' + j$(escapeVfId(vpHidden)).value());
  // if (j$(escapeVfId(vp)).value() != j$(escapeVfId(vpHidden)).value()) {
  //   changeFlg = 'false';
  //   //alert('changeFlg+' +changeFlg);
  //   if(changeFlg == 'true'){
  //       vpBefore = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).value();
  //       j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).val(vpBefore);
  //       document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').blur();
  //       return;
  //   }
  // }
  resetValue('allPage:allForm:allBlock:Editable:Order_ForDealerText');
}
function FilesUaplodJs(){
    //上传文件
    FilesUpload();
}
function refreshPageSizeJs() {
    refreshPageSize();
}
function CommitConsumable(){
    //确认提交
    approval();
    //openPDF();
}
function openPDF(){
    window.open("/customer/summonsPDF?ESetid="+'{!URLENCODE(IdCheck)}');
}
function openReportJs(){
    //打开报表
    var reportId = '{!IdCheck}';
    reportId = reportId.substring(0,15);
    window.open("/customer/" +'{!URLENCODE($Label.ConsumableOut_report)}'+ "?pv1="+ encodeURI(reportId));
}
function openToInvoiceJs(){
    //打开发票
    //upchangeorder();
    var invoiceId = j$(escapeVfId('allPage:allForm:allBlock:unEditable:ConInvoice_Code_lkid')).value();
    if (invoiceId.length > 0 && invoiceId != '000000000000000') {
        window.open("/customer/ConInvoiceView?deliveryId="+'{!URLENCODE(IdCheck)}' + "&invoiceId=" + encodeURI(invoiceId) + "&KeyWords=Redirect","_self");
    }else{
        window.open("/customer/ConInvoiceView?deliveryId="+'{!URLENCODE(IdCheck)}' + "&KeyWords=Redirect","_self");
    }
}
function PraseToPDFJs(){
    //打印成PDF
    PraseToPDF();
    window.open("/customer/summonsPDF?ESetid="+'{!URLENCODE(IdCheck)}');
}
function ChangeDirction(j){
    var a = j.id;
    var x = j$(escapeVfId(a)).value();
    var productCount = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
    if(x == '直接销售给医院'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:province').value = "";
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').value = "";
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
        //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
        // }
    }else if(x == '医院试用'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
        //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
        // }
    }else if(x == '销售给二级经销商'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',false);
        // }
    }else if(x == '互相调货'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:OEC').value = "";
        document.getElementById('allPage:allForm:allBlock:Editable:OECId').value = "";
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:Order_ForCustomer').value = "";
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
        //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
        // }
    }else{
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
        //document.getElementById('allPage:allForm:allBlock:Editable:province').value = "";
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
        //document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').value = "";
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',false);
        //     //document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
        // }
    }
}
//页面刷新重新计算金额
function CountCounttestPrice(){
    var numberDetails =j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
    for(var i = 0; i < numberDetails ; i++){
        var ckeck = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableinfo' + ':consumablesCountproRowCheckbox')).value();
        if (ckeck == 'on') {
            var a=document.getElementById ("allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:" + i +":variableAllprice:consumablesCounttestPrice");
            if ({!Existarrive}) {
                z  =  parseFloat(j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i +':consumablesCount_UnEditout:consumablesCount_UnEditin')).value());
<apex:page
    Controller="summonsCreatController"
    showHeader="true"
    tabStyle="SaleAndDelivery__tab"
    sidebar="true"
    id="allPage"
    action="{!init}"
    title="出库单管理"
>
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
    <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}" />
    <apex:includeScript value="{!URLFOR($Resource.summonsCreatJs)}" />
    <apex:stylesheet value="{!URLFOR($Resource.jquerysuggestcss)}" />
    <apex:includeScript value="{!URLFOR($Resource.jquerysuggestjs)}" />
    <apex:includeScript value="{!URLFOR($Resource.connection20)}" />
    <apex:includeScript value="{!URLFOR($Resource.apex20)}" />
    <script type="text/javascript">
        console.log('hasHosPro = ' + '{!hasHosPro}')
        console.log('EditAble = ' + '{!EditAble}')
        console.log('pageRecords = ' + '{!pageRecords}')
        console.log('coc = ' + '{!coc}')
        console.log('provinceOpts = ' + '{!provinceOpts}')
        console.log('Existarrive = ' + '{!Existarrive}')
        console.log('SecondDealer = ' + '{!SecondDealer}')
        function setFocusOnLoad() {}
        function bodyOnLoad(){setFocusOnLoad();}
        function searchsearchAgencyH(str){
            //update by rentx 2021-3-1 start
            //先判断当前经销商下是否有维护特价医院 如果没有维护特价医院 那么直接查询所有医院
            var flag = j$(escapeVfId('allPage:allForm:allBlock:Editable:OutPattern01')).value();
            j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).attr('readonly',true);
            if ({!hasHos == false}) {
                openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos=', 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
            }else{
                z  =  parseFloat(j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i+':variable:consumablesCount')).value());
                var noOfRecords = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
                var ishosNum = 0;
                for (var i = 0; i < noOfRecords; i++) {
                    var tempCheckVar = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:'+i+':variableinfo:consumablesCountproRowCheckbox')).value();
                    var tempHosVar = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:'+i+':hosOffer')).value();
                    var tempHosProVar = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:'+i+':hosPro')).value();
                    console.log('tempHosProVar:'+tempHosProVar);
                    if (((tempCheckVar == true || tempCheckVar == 'on') || {!Existarrive}) && (tempHosVar == true || tempHosVar == 'true') && (tempHosProVar == true || tempHosProVar == 'true')) {
                        ishosNum ++;
                    }
                }
                // alert({!Existarrive} + flag);
                console.log('34:'+ishosNum);
                if (ishosNum > 0 || ({!Existarrive} && flag == 'true')) {
                // if (ishosNum > 0) {
                    openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos=true', 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
                }else{
                    openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos=', 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
                }
            }
            //update by rentx 2021-01-29 start
            // j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).attr('readonly',true);
            // openPopup('/customer/searchAgencyHospital?Ctype=' + str, 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
            // var flag = j$(escapeVfId('allPage:allForm:allBlock:Editable:OutPattern01')).value();
            // j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).attr('readonly',true);
            // openPopup('/customer/searchAgencyHospital?Ctype=' + str+'&ishos='+flag, 'setsearch', 800, 600, 'width=800,height=600,scrollbars=yes', true);
            //update by rentx 2021-01-29 end
            //update by rentx 2021-3-1 end
        }
        function clearAgencyI(){
            var agencyname = j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).value();
            if (agencyname == '' || agencyname == null) {
                document.getElementById('allPage:allForm:allBlock:Editable:OECId').value = "";
            }
            var accid = j$(escapeVfId('allPage:allForm:allBlock:Editable:OECId')).value();
            if (accid != null && accid != '') {
                checkOutPatternFn();
            }
        }
        // vivek update start
        function saveConfirmJs(str){
            console.log('pageRecords = ' + '{!pageRecords}')
            debugger
            var msg = "出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!";
            if(str == '价格未定'){
                if(confirm(msg)==true){
                    saveJs();
                }
            }else{
                saveJs();
            }
        }
        // vivek update end
        function setVisitorPlace(){
            var x = j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value();
            if (x == '互相调货') {
                try{
                    var str = 'allPage:allForm:allBlock:Editable:Order_ForDealerText';
                    var strPage = null;
                    var options = {};
                    var ros = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).value();
                    strPage = '/customer/apex/ConSearchAgencyPlace?r=' + encodeURI(ros);
                    options = {minchars:3, minwords:1, resultsClass:'visitorplace_results'};
                    jQuery(escapeVfId(str)).unbind();
                    if (strPage != null) {
                        console.log('进入strPage != null')
                        jQuery(escapeVfId(str)).suggest(strPage,options);
                    }
                }catch(e){
                    alert(e);
                }
            }
            else{
                var agencytext = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).value();
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).val(agencytext);
                //alert('1' + agencytext);
                //alert('2' + j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).value());
            }
        }
        function vpClear2_delay(){
            var x = j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value();
            if (x == '互相调货') {
                var vp = 'allPage:allForm:allBlock:Editable:Order_ForDealerText';
                var vpHidden = 'allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden';
                setTimeout(
                    function() {
                        if(j$(escapeVfId(vp)).attr("jquerysuggest_skip_flag") == "false") {
                            if (j$(escapeVfId(vp)).value() != j$(escapeVfId(vpHidden)).value()) {
                                vpClear2();
                            }
                        }
                    },
                    200
                );
            }
            else{
                var agencytext = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).value();
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).val(agencytext);
            }
        }
        function vpClear2(){
          var vp = 'allPage:allForm:allBlock:Editable:Order_ForDealerText';
          var vpHidden = 'allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden';
          // alert('vp=' + j$(escapeVfId(vp)).value());
          // alert('vpHidden=' + j$(escapeVfId(vpHidden)).value());
          // if (j$(escapeVfId(vp)).value() != j$(escapeVfId(vpHidden)).value()) {
          //   changeFlg = 'false';
          //   //alert('changeFlg+' +changeFlg);
          //   if(changeFlg == 'true'){
          //       vpBefore = j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerTextHidden')).value();
          //       j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).val(vpBefore);
          //       document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').blur();
          //       return;
          //   }
          // }
          resetValue('allPage:allForm:allBlock:Editable:Order_ForDealerText');
        }
        function FilesUaplodJs(){
            //上传文件
            FilesUpload();
        }
        function refreshPageSizeJs() {
            refreshPageSize();
        }
        function CommitConsumable(){
            //确认提交
            approval();
            //openPDF();
        }
        function openPDF(){
            window.open("/customer/summonsPDF?ESetid="+'{!URLENCODE(IdCheck)}');
        }
        function openReportJs(){
            //打开报表
            var reportId = '{!IdCheck}';
            reportId = reportId.substring(0,15);
            window.open("/customer/" +'{!URLENCODE($Label.ConsumableOut_report)}'+ "?pv1="+ encodeURI(reportId));
        }
        function openToInvoiceJs(){
            //打开发票
            //upchangeorder();
            var invoiceId = j$(escapeVfId('allPage:allForm:allBlock:unEditable:ConInvoice_Code_lkid')).value();
            if (invoiceId.length > 0 && invoiceId != '000000000000000') {
                window.open("/customer/ConInvoiceView?deliveryId="+'{!URLENCODE(IdCheck)}' + "&invoiceId=" + encodeURI(invoiceId) + "&KeyWords=Redirect","_self");
            }else{
                window.open("/customer/ConInvoiceView?deliveryId="+'{!URLENCODE(IdCheck)}' + "&KeyWords=Redirect","_self");
            }
        }
        function PraseToPDFJs(){
            //打印成PDF
            PraseToPDF();
            window.open("/customer/summonsPDF?ESetid="+'{!URLENCODE(IdCheck)}');
        }
        function ChangeDirction(j){
            var a = j.id;
            var x = j$(escapeVfId(a)).value();
            var productCount = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
            if(x == '直接销售给医院'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:province').value = "";
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').value = "";
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
                //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
                // }
            }else if(x == '医院试用'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
                //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
                // }
            }else if(x == '销售给二级经销商'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',false);
                // }
            }else if(x == '互相调货'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:OEC').value = "";
                document.getElementById('allPage:allForm:allBlock:Editable:OECId').value = "";
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:Order_ForCustomer').value = "";
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
                //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
                // }
            }else{
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
                //document.getElementById('allPage:allForm:allBlock:Editable:province').value = "";
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
                //document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').value = "";
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',false);
                //     //document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
                // }
            }
        }
        //页面刷新重新计算金额
        function CountCounttestPrice(){
            var numberDetails =j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
            for(var i = 0; i < numberDetails ; i++){
                var ckeck = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableinfo' + ':consumablesCountproRowCheckbox')).value();
                if (ckeck == 'on') {
                    var a=document.getElementById ("allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:" + i +":variableAllprice:consumablesCounttestPrice");
                    if ({!Existarrive}) {
                        z  =  parseFloat(j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i +':consumablesCount_UnEditout:consumablesCount_UnEditin')).value());
                    }else{
                        z  =  parseFloat(j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i+':variable:consumablesCount')).value());
                    }
                    //z= z.replace(/,/g,'');
                    if(isNaN(z)){z=0.00;}
                    //alert(z);
                    x = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i +':variableMoneyinfo:productOrderMoneyinfo')).value().replace(/,/g,'');
                    c = parseFloat(z * x).toFixed(2);
                    //c = number_format_common (c,2,'.',',');
                    a.innerHTML = c;
                    SumCompute();
                }
            }
        }
        function ComputePriceCheck(j){ // FIXME lineNo にしてください
            var z,x,c;
            var a = j.id;
            var i=a.substring(0,a.lastIndexOf(':'));// <apex:variable value="{!1}" var="lineNo" />
            i=i.substring(0,i.lastIndexOf(':'));
            var a=document.getElementById (i+":variableAllprice:consumablesCounttestPrice");
            if ({!Existarrive}) {
                z  =  parseFloat(j$(escapeVfId(i+':consumablesCount_UnEditout:consumablesCount_UnEditin')).value());
            }else{
                z  =  parseFloat(j$(escapeVfId(i+':variable:consumablesCount')).value());
            }
            //z= z.replace(/,/g,'');
            if(isNaN(z)){z=0.00;}
            //alert(z);
            x = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i +':variableMoneyinfo:productOrderMoneyinfo')).value().replace(/,/g,'');
            x = j$(escapeVfId(i +':variableMoneyinfo:productOrderMoneyinfo')).value().replace(/,/g,'');
            c = parseFloat(z * x).toFixed(2);
            //c = number_format_common (c,2,'.',',');
            a.innerHTML = c;
            SumCompute();
        }
    }
}
function ComputePriceCheck(j){ // FIXME lineNo にしてください
    var z,x,c;
    var a = j.id;
    var i=a.substring(0,a.lastIndexOf(':'));// <apex:variable value="{!1}" var="lineNo" />
    i=i.substring(0,i.lastIndexOf(':'));
    var a=document.getElementById (i+":variableAllprice:consumablesCounttestPrice");
    if ({!Existarrive}) {
        z  =  parseFloat(j$(escapeVfId(i+':consumablesCount_UnEditout:consumablesCount_UnEditin')).value());
    }else{
        z  =  parseFloat(j$(escapeVfId(i+':variable:consumablesCount')).value());
    }
    //z= z.replace(/,/g,'');
    if(isNaN(z)){z=0.00;}
    //alert(z);
    x = j$(escapeVfId(i +':variableMoneyinfo:productOrderMoneyinfo')).value().replace(/,/g,'');
    c = parseFloat(z * x).toFixed(2);
    //c = number_format_common (c,2,'.',',');
    a.innerHTML = c;
    SumCompute();
}
        function showCate() {
            //var productCount = j$(escapeVfId('allPage:allForm:allBlock:searchBlock:category3Search')).value();
            categoryload();
        }
function showCate() {
    //var productCount = j$(escapeVfId('allPage:allForm:allBlock:searchBlock:category3Search')).value();
    categoryload();
}
        function showAllCate() {
            categoryAllload();
        }
function showAllCate() {
    categoryAllload();
}
        //页面加载 项目初始化
        function onLoadDirction(){
            var x = j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value();
            var productCount = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
//页面加载 项目初始化
function onLoadDirction(){
    var x = j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value();
    var productCount = j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount')).value();
            if(x == '直接销售给医院'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:province').value = "";
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').value = "";
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
                //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
                // }
            }else if(x == '医院试用'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
                //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
                // }
            }else if(x == '销售给二级经销商'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',false);
                // }
            }else if(x == '互相调货'){
                //医院
                j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:OEC').value = "";
                document.getElementById('allPage:allForm:allBlock:Editable:OECId').value = "";
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',true);
                document.getElementById('allPage:allForm:allBlock:Editable:Order_ForCustomer').value = "";
                //二级经销商
                j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
                j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
    if(x == '直接销售给医院'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:province').value = "";
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:Order_ForDealerText').value = "";
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
        //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
        // }
    }else if(x == '医院试用'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
        //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
        // }
    }else if(x == '销售给二级经销商'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',false);
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',false);
        // }
    }else if(x == '互相调货'){
        //医院
        j$(escapeVfId('allPage:allForm:allBlock:Editable:OEC')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:OEC').value = "";
        document.getElementById('allPage:allForm:allBlock:Editable:OECId').value = "";
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForCustomer')).prop('disabled',true);
        document.getElementById('allPage:allForm:allBlock:Editable:Order_ForCustomer').value = "";
        //二级经销商
        j$(escapeVfId('allPage:allForm:allBlock:Editable:province')).prop('disabled',false);
        j$(escapeVfId('allPage:allForm:allBlock:Editable:Order_ForDealerText')).prop('disabled',false);
                // for (var i = 0; i < productCount; i++) {
                //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
                //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
                // }
            }
        }
        // for (var i = 0; i < productCount; i++) {
        //     j$(escapeVfId('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency')).prop('disabled',true);
        //     document.getElementById('allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsTable:' + i + ':variableMoneyinfo:Unitpriceagency').value = "";
        // }
    }
}
window.sfdcPage.appendToOnloadQueue(function() { onLoadDirction(); });
</script>
<style>
    .visitorplace_results {
        border: 1px solid gray;
        background-color: white;
        padding: 0;
        margin: 0;
        list-style: none;
        position: absolute;
        z-index: 10000;
        display: none;
        overflow:auto;
        white-space:nowrap;
        width:400px;
        height:250px;
    }
    .visitorplace_results li {
        padding: 2px 5px 2px 0px;
        margin-left : 2px;
        color: #101010;
        text-align: left;
    }
    .panelGridCenter td,.panelGridCenter tr {
        text-align: center;
    }
    .dateFormat  {
        display: none;
    }
    tr.dataRow {
        background-color:white;
    }
    td.columus {
        background-color:white;
        text-align: right;
    }
    tr.dataRow:hover {
        background-color: #e3f3ff;
    }
</style>
        window.sfdcPage.appendToOnloadQueue(function() { onLoadDirction(); });
    </script>
    <style>
        .visitorplace_results {
            border: 1px solid gray;
            background-color: white;
            padding: 0;
            margin: 0;
            list-style: none;
            position: absolute;
            z-index: 10000;
            display: none;
            overflow: auto;
            white-space: nowrap;
            width: 400px;
            height: 250px;
        }
        .visitorplace_results li {
            padding: 2px 5px 2px 0px;
            margin-left: 2px;
            color: #101010;
            text-align: left;
        }
        .panelGridCenter td,
        .panelGridCenter tr {
            text-align: center;
        }
        .dateFormat {
            display: none;
        }
        tr.dataRow {
            background-color: white;
        }
        td.columus {
            background-color: white;
            text-align: right;
        }
        tr.dataRow:hover {
            background-color: #e3f3ff;
        }
    </style>
    <apex:form id="allForm">
    <!-- //add  by rentx 2021-2-26 -->
        <apex:actionFunction name="checkOutPatternFn" action="{!checkOutPattern}" status="fetchStatus" reRender="ConsumableorderdetailsSection,message,OutPattern01" onComplete="CountCounttestPrice();onLoadDirction();"/>
    <!-- //add by rentx 2021-2-26 -->
        <apex:actionFunction name="refreshPageSize" action="{!refreshPageSize}" status="fetchStatus" reRender="ConsumableorderdetailsSection,message" onComplete="CountCounttestPrice();onLoadDirction();"/>
        <apex:actionFunction name="save" action="{!save}" rerender=" message,Editable,ConsumableorderdetailsSection" onComplete="unblockUI();CountCounttestPrice();onLoadDirction();">
        <!-- //add  by rentx 2021-2-26 -->
        <apex:actionFunction
            name="checkOutPatternFn"
            action="{!checkOutPattern}"
            status="fetchStatus"
            reRender="ConsumableorderdetailsSection,message,OutPattern01"
            onComplete="CountCounttestPrice();onLoadDirction();"
        />
        <!-- //add by rentx 2021-2-26 -->
        <apex:actionFunction
            name="refreshPageSize"
            action="{!refreshPageSize}"
            status="fetchStatus"
            reRender="ConsumableorderdetailsSection,message"
            onComplete="CountCounttestPrice();onLoadDirction();"
        />
        <apex:actionFunction
            name="save"
            action="{!save}"
            rerender=" message,Editable,ConsumableorderdetailsSection"
            onComplete="unblockUI();CountCounttestPrice();onLoadDirction();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="categoryload" action="{!categoryload}" rerender="searchBlock" onComplete="unblockUI();">
        <apex:actionFunction
            name="categoryload"
            action="{!categoryload}"
            rerender="searchBlock"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
         <apex:actionFunction name="categoryAllload" action="{!categoryAllload}" rerender="searchBlock" onComplete="unblockUI();">
        <apex:actionFunction
            name="categoryAllload"
            action="{!categoryAllload}"
            rerender="searchBlock"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="searchConsumableorderdetails" action="{!searchConsumableorderdetails}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CountCounttestPrice();onLoadDirction();">
        <apex:actionFunction
            name="searchConsumableorderdetails"
            action="{!searchConsumableorderdetails}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();CountCounttestPrice();onLoadDirction();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="setEditAble" action="{!setEditAble}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="setEditAble"
            action="{!setEditAble}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="approval" action="{!approval}" rerender="allForm" onComplete="unblockUI();openPDF();">
        <apex:actionFunction
            name="approval"
            action="{!approval}"
            rerender="allForm"
            onComplete="unblockUI();openPDF();"
        >
        </apex:actionFunction>
         <apex:actionFunction name="DelConsumable" action="{!DelConsumable}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="DelConsumable"
            action="{!DelConsumable}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="PraseToPDF" action="{!PraseToPDF}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="PraseToPDF"
            action="{!PraseToPDF}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="GoodsDelivery" action="{!GoodsDelivery}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="GoodsDelivery"
            action="{!GoodsDelivery}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:actionFunction name="SortLimited" action="{!SortLimited}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CountCounttestPrice();onLoadDirction();">
        <apex:actionFunction
            name="SortLimited"
            action="{!SortLimited}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();CountCounttestPrice();onLoadDirction();"
        >
            <apex:param name="firstParam" assignTo="{!sortKey}" value="" />
        </apex:actionFunction>
        <!--<apex:actionFunction name="SortStore" action="{!SortStore}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
            <apex:param name="firstParam" assignTo="{!sortKey}" value="" />
        </apex:actionFunction>-->
        <apex:actionFunction name="FilesUpload" action="{!FilesUpload}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();">
        <apex:actionFunction
            name="FilesUpload"
            action="{!FilesUpload}"
            rerender="ConsumableorderdetailsSection, message"
            onComplete="unblockUI();"
        >
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
        <input type="hidden" id="userState" value="{!localuser.State_Hospital__c}"/>
            <apex:pageBlock id="allBlock" >
            <input
                type="hidden"
                id="userState"
                value="{!localuser.State_Hospital__c}"
            />
            <apex:pageBlock id="allBlock">
                <table>
                    <colgroup>
                        <col width="150px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="200px"/>
                        <col width="90px"/>
                        <col width="100px"/>
                        <col width="10px"/>
                        <col width="85px"/>
                        <col width="100px"/>
                        <col width="10px"/>
                        <col width="70px"/>
                        <col width="100px"/>
                        <col width="150px" />
                        <col width="200px" />
                        <col width="200px" />
                        <col width="200px" />
                        <col width="200px" />
                        <col width="200px" />
                        <col width="90px" />
                        <col width="100px" />
                        <col width="10px" />
                        <col width="85px" />
                        <col width="100px" />
                        <col width="10px" />
                        <col width="70px" />
                        <col width="100px" />
                    </colgroup>
                    <tr>
                        <td></td>
                        <td  colspan="4"><apex:commandButton onclick="saveConfirmJs('{!coc.SummonsStatus_c__c}');" value="保存" style="width:150px" rerender="dummy" rendered="{!(EditDelCommitBtnDisabled||EditAble)}"/></td>
                        <td colspan="4">
                            <apex:commandButton
                                onclick="saveConfirmJs('{!coc.SummonsStatus_c__c}');"
                                value="保存"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!(EditDelCommitBtnDisabled||EditAble)}"
                            />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td ><apex:commandButton onclick="EditConsumable();"   value="编辑出库单" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已完成',true,false)}"/></td>
                        <td>
                            <apex:commandButton
                                onclick="EditConsumable();"
                                value="编辑出库单"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已完成',true,false)}"
                            />
                        </td>
                        <!--CHAN-B65CAZ 20181105 UpdateStart-->
                        <!-- <td ><apex:commandButton onclick="CommitConsumable();" value="提交出库单" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='已完成',true,false)}"/></td> -->
                        <td ><apex:commandButton onclick="GoodsDeliveryJs();"  value="出货/销售"     style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='已完成'||coc.SummonsStatus_c__c='价格未定',true,false)}"/></td>
                        <td>
                            <apex:commandButton
                                onclick="GoodsDeliveryJs();"
                                value="出货/销售"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='已完成'||coc.SummonsStatus_c__c='价格未定',true,false)}"
                            />
                        </td>
                        <!-- CHAN-B65CAZ 20181105 UpdateEnd-->
                        <td ><apex:commandButton onclick="openToInvoiceJs();return false;" value="开票" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(((coc.Billed_Status__c !='全部开票' &&coc.SummonsStatus_c__c='已完成') || coc.Onchange_order__c = true) && coc.SummonsForDirction__c!='互相调货',false,true)}"/></td>
                        <td>
                            <apex:commandButton
                                onclick="openToInvoiceJs();return false;"
                                value="开票"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(((coc.Billed_Status__c !='全部开票' &&coc.SummonsStatus_c__c='已完成') || coc.Onchange_order__c = true) && coc.SummonsForDirction__c!='互相调货',false,true)}"
                            />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <!--CHAN-B65CAZ 20181105 UpdateStart-->
                        <td ><apex:commandButton onclick="PraseToPDFJs();" value="打印指示单" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='草案中',false,true)}"/></td>
                        <!-- CHAN-B65CAZ 20181105 UpdateEnd-->
                        <td ><apex:commandButton onclick="openReportJs(); return false;" value="显示明细" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.Billed_Status__c !='还没开票' || coc.SummonsStatus_c__c='已完成',false,true)}"/></td>
                        <td ><apex:commandButton onclick="DeleteConsumable();" value="删除" style="width:150px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}" disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='价格未定'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='已完成',true,false)}"/></td>
                        <td >
                        <td>
                            <apex:commandButton
                                onclick="PraseToPDFJs();"
                                value="打印指示单"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='草案中',false,true)}"
                            />
                        </td>
                        <!-- CHAN-B65CAZ 20181105 UpdateEnd-->
                        <td>
                            <apex:commandButton
                                onclick="openReportJs(); return false;"
                                value="显示明细"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.Billed_Status__c !='还没开票' || coc.SummonsStatus_c__c='已完成',false,true)}"
                            />
                        </td>
                        <td>
                            <apex:commandButton
                                onclick="DeleteConsumable();"
                                value="删除"
                                style="width: 150px"
                                rerender="dummy"
                                rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                                disabled="{!IF(coc.SummonsStatus_c__c='已销售待上传纳品书'||coc.SummonsStatus_c__c='价格未定'||coc.SummonsStatus_c__c='批准'||coc.SummonsStatus_c__c='出库单已打印'||coc.SummonsStatus_c__c='已完成',true,false)}"
                            />
                        </td>
                        <td></td>
                    </tr>
                </table>
                <apex:outputPanel id="message">
                    <apex:pageMessages />
                 </apex:outputPanel>
<!--==============20160314====INSERT_CODE_END=======================================-->
                <apex:pageBlock title="出库单信息" id="Editable" rendered="{!EditAble}">
                <!-- update start by vivek 2019-7-15 -->
                </apex:outputPanel>
                <!--==============20160314====INSERT_CODE_END=======================================-->
                <apex:pageBlock
                    title="出库单信息"
                    id="Editable"
                    rendered="{!EditAble}"
                >
                    <!-- update start by vivek 2019-7-15 -->
                    <!-- <table>
                        <colgroup>
                            <col width="150px"/>
@@ -501,162 +655,308 @@
                            <col width="70px"/>
                            <col width="100px"/>
                        </colgroup> -->
                <!-- update end by vivek 2019-7-15 -->
                        <!-- update start by vivek 2019-7-15 -->
                        <apex:outputPanel rendered="{! If(coc.SummonsStatus_c__c == '价格未定',true,false) }">
                    <!-- update end by vivek 2019-7-15 -->
                    <!-- update start by vivek 2019-7-15 -->
                    <apex:outputPanel
                        rendered="{! If(coc.SummonsStatus_c__c == '价格未定',true,false) }"
                    >
                        <table>
                        <colgroup>
                            <col width="150px"/>
                            <col width="300px"/>
                            <col width="150px"/>
                            <col width="300px"/>
                            <col width="80px"/>
                            <col width="10px"/>
                            <col width="90px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="85px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                        </colgroup>
                                <tr>
                            <colgroup>
                                <col width="150px" />
                                <col width="300px" />
                                <col width="150px" />
                                <col width="300px" />
                                <col width="80px" />
                                <col width="10px" />
                                <col width="90px" />
                                <col width="100px" />
                                <col width="10px" />
                                <col width="85px" />
                                <col width="100px" />
                                <col width="10px" />
                                <col width="70px" />
                                <col width="100px" />
                            </colgroup>
                            <tr>
                                <td align="right">出库单号:</td>
                                <td align="left"><apex:outputField id="OrderCode_out2"  value="{!coc.Name}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderCode_out2"
                                        value="{!coc.Name}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right">出库单状态:</td>
                                <td align="left"><apex:outputField id="OrderStatus_out2" value="{!coc.SummonsStatus_c__c}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderStatus_out2"
                                        value="{!coc.SummonsStatus_c__c}"
                                        style="width: 300px"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">目的:</td>
                                <td align="left"><apex:outputField id="OrderDirction_out2"  value="{!coc.SummonsForDirction__c}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderDirction_out2"
                                        value="{!coc.SummonsForDirction__c}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right">开票状态:</td>
                                <td align="left">
                                <apex:outputField id="SecondDealer_level22" value="{!coc.Billed_Status__c}" style="width:300px"/>
                                    <apex:outputField
                                        id="SecondDealer_level22"
                                        value="{!coc.Billed_Status__c}"
                                        style="width: 300px"
                                    />
                                </td>
                            </tr>
                            <tr style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}">
                            <tr
                                style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}"
                            >
                                <td align="right">二级经销商:</td>
                                <td align="left"><apex:outputField id="SecondDealer_out2" value="{!coc.Order_Dealer_Info__c}" style="width:300px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="SecondDealer_out2"
                                        value="{!coc.Order_Dealer_Info__c}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right"></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="right">客户名:</td>
                                <td align="left"><apex:outputField id="OrderForHospital_out2" value="{!coc.ShipmentAccount__c}" style="width:300px"/></td>
                                <td align="right"><apex:outputText value="发票:" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/></td>
                                <td align="left"><apex:inputField value="{!coc.ConInvoice_Code__c}" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}" id="ConInvoice_Code2"/>
                                <c:helpicon helpText="已开票的换货的时候,选择已开票的发票。" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderForHospital_out2"
                                        value="{!coc.ShipmentAccount__c}"
                                        style="width: 300px"
                                    />
                                </td>
                                <td align="right">
                                    <apex:outputText
                                        value="发票:"
                                        rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                    />
                                </td>
                                <td align="left">
                                    <apex:inputField
                                        value="{!coc.ConInvoice_Code__c}"
                                        rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                        id="ConInvoice_Code2"
                                    />
                                    <c:helpicon
                                        helpText="已开票的换货的时候,选择已开票的发票。"
                                        rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">科室:</td>
                                <td align="left">
                                    <apex:outputField id="Order_ForDealerText2" value="{!coc.Order_ForCustomerText__c}" style="width:170px"/>
                                    <apex:outputField
                                        id="Order_ForDealerText2"
                                        value="{!coc.Order_ForCustomerText__c}"
                                        style="width: 170px"
                                    />
                                </td>
                                <td align="right">出库金额:</td>
                                <td align="left"><apex:outputField id="sumPrice_buttom2" value="{!coc.Shipment_total_amount__c}" style="width:300px"/> 元</td>
                                <td align="left">
                                    <apex:outputField
                                        id="sumPrice_buttom2"
                                        value="{!coc.Shipment_total_amount__c}"
                                        style="width: 300px"
                                    />
                                    元
                                </td>
                            </tr>
                            <tr>
                                <td align="right">没有确定价格:</td>
                                <td align="left">
                                    <apex:inputCheckbox id="NoConfirmedPrice_out2" value="{!coc.NoConfirmedPrice__c}" disabled="true" />
                                    <apex:inputCheckbox
                                        id="NoConfirmedPrice_out2"
                                        value="{!coc.NoConfirmedPrice__c}"
                                        disabled="true"
                                    />
                                </td>
                                <!-- ===add by rentx 2020-12-04 start -->
                                <!-- <apex:detail rendered="{!agencyProType == 'ENG'}"> -->
                                    <!-- <td align="right">是否医院特价出库 : </td> -->
                                    <!-- <td align="left"> -->
                                        <apex:inputHidden id="OutPattern02" value="{!coc.OutPattern__c}"  />
                                        <!-- <apex:outputField id="OutPattern02" value="{!coc.OutPattern__c}"  /> -->
                                        <!-- <apex:inputCheckbox id="OutPattern02" value="{!coc.OutPattern__c}" disabled="true"  /> -->
                                <!-- <td align="right">是否医院特价出库 : </td> -->
                                <!-- <td align="left"> -->
                                <apex:inputHidden
                                    id="OutPattern02"
                                    value="{!coc.OutPattern__c}"
                                />
                                <!-- <apex:outputField id="OutPattern02" value="{!coc.OutPattern__c}"  /> -->
                                <!-- <apex:inputCheckbox id="OutPattern02" value="{!coc.OutPattern__c}" disabled="true"  /> -->
                                        <!-- <apex:inputField id="OutPattern" value="{!coc.DeliveryMode__c}" style="width:160px"/> -->
                                    <!-- </td> -->
                                <!-- <apex:inputField id="OutPattern" value="{!coc.DeliveryMode__c}" style="width:160px"/> -->
                                <!-- </td> -->
                                <!-- </apex:detail> -->
                                <!-- ===add by rentx 2020-12-04 end -->
                            </tr>
                        </table>
                            </apex:outputPanel>
                        <apex:outputPanel rendered="{! If(coc.SummonsStatus_c__c != '价格未定',true,false) }">
                    </apex:outputPanel>
                    <apex:outputPanel
                        rendered="{! If(coc.SummonsStatus_c__c != '价格未定',true,false) }"
                    >
                        <table>
                        <colgroup>
                            <col width="150px"/>
                            <col width="300px"/>
                            <col width="150px"/>
                            <col width="300px"/>
                            <col width="80px"/>
                            <col width="10px"/>
                            <col width="90px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="85px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                        </colgroup>
                            <tr id = "SummonsFlag" style="visibility:{!SummonsFlag}">
                            <colgroup>
                                <col width="150px" />
                                <col width="300px" />
                                <col width="150px" />
                                <col width="300px" />
                                <col width="80px" />
                                <col width="10px" />
                                <col width="90px" />
                                <col width="100px" />
                                <col width="10px" />
                                <col width="85px" />
                                <col width="100px" />
                                <col width="10px" />
                                <col width="70px" />
                                <col width="100px" />
                            </colgroup>
                            <tr
                                id="SummonsFlag"
                                style="visibility:{!SummonsFlag}"
                            >
                                <td align="right">出库单号:</td>
                                <td align="left"><apex:outputField id="OrderCode"  value="{!coc.Name}" style="width:100px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="OrderCode"
                                        value="{!coc.Name}"
                                        style="width: 100px"
                                    />
                                </td>
                                <td align="right">出库单状态:</td>
                                <td align="left"><apex:outputField id="SummonsStatus_c__c" value="{!coc.SummonsStatus_c__c}" style="width:100px"/></td>
                                <td align="left">
                                    <apex:outputField
                                        id="SummonsStatus_c__c"
                                        value="{!coc.SummonsStatus_c__c}"
                                        style="width: 100px"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">目的:</td>
                                <td align="left"><div style="width:3px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div>
                                <apex:inputField onchange="ChangeDirction(this)" id="SummonsForDirction__c" value="{!coc.SummonsForDirction__c}" style="width:160px"/></td>
                                <td align="left">
                                    <div
                                        style="
                                            width: 3px;
                                            height: 20px;
                                            background-color: red;
                                            position: absolute;
                                            margin-right: 5px;
                                        "
                                    ></div>
                                    <apex:inputField
                                        onchange="ChangeDirction(this)"
                                        id="SummonsForDirction__c"
                                        value="{!coc.SummonsForDirction__c}"
                                        style="width: 160px"
                                    />
                                </td>
                                <td align="right">二级经销商:</td>
                                <td align="left">
                                <apex:selectList id="province" value="{!SecondDealer}" style="width:160px" size="1" >
                                    <apex:selectOptions value="{!provinceOpts}"/>
                                </apex:selectList>
                                    <apex:selectList
                                        id="province"
                                        value="{!SecondDealer}"
                                        style="width: 160px"
                                        size="1"
                                    >
                                        <apex:selectOptions
                                            value="{!provinceOpts}"
                                        />
                                    </apex:selectList>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">客户名:</td>
                                <td align="left">
                                    <apex:inputText id="OEC" value="{!HospitalName}" onclick="searchsearchAgencyH('{!agencyProType}'); return false;" onblur="clearAgencyI();return false;" style="width:155px"  />
                                    <apex:inputHidden value="{!HospitalInfo}" id="OECId" />
                                    <apex:inputText
                                        id="OEC"
                                        value="{!HospitalName}"
                                        onclick="searchsearchAgencyH('{!agencyProType}'); return false;"
                                        onblur="clearAgencyI();return false;"
                                        style="width: 155px"
                                    />
                                    <apex:inputHidden
                                        value="{!HospitalInfo}"
                                        id="OECId"
                                    />
                                </td>
                                <td align="right">经销商(录入):</td>
                                <td align="left">
                                    <apex:inputField id="Order_ForDealerText" value="{!coc.Order_ForDealerText__c}" onfocus="setVisitorPlace();" style="width:155px" onblur="if (j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value() == '互相调货'){vpClear2_delay();}"/>
<!--                                    <apex:inputField id="Order_ForDealerText" value="{!coc.Order_ForDealerText__c}"  style="width:155px" onblur="if (j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value() == '互相调货'){vpClear2_delay();}"/>-->
                                    <apex:inputHidden id="Order_ForDealerTextHidden" value="{!coc.Order_ForDealerText__c}" />
                                    <apex:inputHidden id="Order_ForDealerTextId" value="{!coc.Order_ForDealerTextID__c}" />
                                    <apex:inputHidden id="Order_ForDealerTextHiddenId" value="{!coc.Order_ForDealerTextID__c}" />
                                    <apex:inputField
                                        id="Order_ForDealerText"
                                        value="{!coc.Order_ForDealerText__c}"
                                        onfocus="setVisitorPlace();"
                                        style="width: 155px"
                                        onblur="if (j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value() == '互相调货'){vpClear2_delay();}"
                                    />
                                    <!--                                    <apex:inputField id="Order_ForDealerText" value="{!coc.Order_ForDealerText__c}"  style="width:155px" onblur="if (j$(escapeVfId('allPage:allForm:allBlock:Editable:SummonsForDirction__c')).value() == '互相调货'){vpClear2_delay();}"/>-->
                                    <apex:inputHidden
                                        id="Order_ForDealerTextHidden"
                                        value="{!coc.Order_ForDealerText__c}"
                                    />
                                    <apex:inputHidden
                                        id="Order_ForDealerTextId"
                                        value="{!coc.Order_ForDealerTextID__c}"
                                    />
                                    <apex:inputHidden
                                        id="Order_ForDealerTextHiddenId"
                                        value="{!coc.Order_ForDealerTextID__c}"
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">科室:</td>
                                <td align="left">
                                    <apex:inputField id="Order_ForCustomer" value="{!coc.Order_ForCustomerText__c}" style="width:155px"/>
                                    <apex:inputField
                                        id="Order_ForCustomer"
                                        value="{!coc.Order_ForCustomerText__c}"
                                        style="width: 155px"
                                    />
                                </td>
                                <td align="right">总金额:</td>
                                <td align="left"><apex:outputText id="sumPrice_buttom" value="{!sumPrice}"/> 元</td>
                                <td align="left">
                                    <apex:outputText
                                        id="sumPrice_buttom"
                                        value="{!sumPrice}"
                                    />
                                    元
                                </td>
                            </tr>
                            <tr>
                                <td align="right">没有确定价格:</td>
                                <td align="left">
                                    <apex:inputCheckbox id="NoConfirmedPrice" value="{!coc.NoConfirmedPrice__c}" />
                                    <apex:inputCheckbox
                                        id="NoConfirmedPrice"
                                        value="{!coc.NoConfirmedPrice__c}"
                                    />
                                </td>
                                <!-- ===add by rentx 2020-12-04 start 因为目前维护了特价产品的医院都是ENG医院,所以只有ENG的时候展示 是否医院特价出库 即可-->
                                <!-- <apex:detail rendered="{!agencyProType == 'ENG'}"> -->
                                    <!-- <td align="right" >是否医院特价出库 : </td> -->
                                    <!-- <td align="left"> -->
                                        <!-- <apex:outputField id="OutPattern01" value="{!coc.OutPattern__c}" /> -->
                                        <apex:inputHidden id="OutPattern01" value="{!coc.OutPattern__c}" />
                                <!-- <td align="right" >是否医院特价出库 : </td> -->
                                <!-- <td align="left"> -->
                                <!-- <apex:outputField id="OutPattern01" value="{!coc.OutPattern__c}" /> -->
                                <apex:inputHidden
                                    id="OutPattern01"
                                    value="{!coc.OutPattern__c}"
                                />
                                    <!-- </td> -->
                                <!-- </td> -->
                                <!-- </apex:detail> -->
                                <!-- ===add by rentx 2020-12-04 end -->
                            </tr>
                        </table>
                        </apex:outputPanel>
                    </apex:outputPanel>
                    <!-- <tr id = "SummonsFlag" style="visibility:{!SummonsFlag}">
                            <td align="right">出库单号:</td>
@@ -704,193 +1004,374 @@
                    </table> -->
                    <!-- update end by vivek2019-7-12 -->
                </apex:pageBlock>
<!--==============20160314====INSERT_CODE_START=======================================-->
                 <apex:pageBlock title="出库单信息" id="unEditable" rendered="{!!EditAble}">
                <!--==============20160314====INSERT_CODE_START=======================================-->
                <apex:pageBlock
                    title="出库单信息"
                    id="unEditable"
                    rendered="{!!EditAble}"
                >
                    <table>
                        <colgroup>
                            <col width="150px"/>
                            <col width="300px"/>
                            <col width="150px"/>
                            <col width="300px"/>
                            <col width="100px"/>
                            <col width="70px"/>
                            <col width="90px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="85px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                            <col width="150px" />
                            <col width="300px" />
                            <col width="150px" />
                            <col width="300px" />
                            <col width="100px" />
                            <col width="70px" />
                            <col width="90px" />
                            <col width="100px" />
                            <col width="10px" />
                            <col width="85px" />
                            <col width="100px" />
                            <col width="10px" />
                            <col width="70px" />
                            <col width="100px" />
                        </colgroup>
                        <tr>
                            <td align="right">出库单号:</td>
                            <td align="left"><apex:outputField id="OrderCode_out"  value="{!coc.Name}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="OrderCode_out"
                                    value="{!coc.Name}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right">出库单状态:</td>
                            <td align="left"><apex:outputField id="OrderStatus_out" value="{!coc.SummonsStatus_c__c}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="OrderStatus_out"
                                    value="{!coc.SummonsStatus_c__c}"
                                    style="width: 300px"
                                />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">目的:</td>
                            <td align="left"><apex:outputField id="OrderDirction_out"  value="{!coc.SummonsForDirction__c}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="OrderDirction_out"
                                    value="{!coc.SummonsForDirction__c}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right">开票状态:</td>
                            <td align="left">
                            <apex:outputField id="SecondDealer_level2" value="{!coc.Billed_Status__c}" style="width:300px"/>
                                <apex:outputField
                                    id="SecondDealer_level2"
                                    value="{!coc.Billed_Status__c}"
                                    style="width: 300px"
                                />
                            </td>
                        </tr>
                        <tr style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}">
                        <tr
                            style="{!IF(coc.SummonsForDirction__c='销售给二级经销商','','display:none')}"
                        >
                            <td align="right">二级经销商:</td>
                            <td align="left"><apex:outputField id="SecondDealer_out" value="{!coc.Order_Dealer_Info__c}" style="width:300px"/></td>
                            <td align="left">
                                <apex:outputField
                                    id="SecondDealer_out"
                                    value="{!coc.Order_Dealer_Info__c}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right"></td>
                            <td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right">客户名:</td>
                            <td align="left"><apex:outputField id="OrderForHospital_out" value="{!coc.ShipmentAccount__c}" style="width:300px"/></td>
                            <td align="right"><apex:outputText value="发票:" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/></td>
                            <td align="left"><apex:inputField value="{!coc.ConInvoice_Code__c}" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}" id="ConInvoice_Code"/>
                            <c:helpicon helpText="已开票的换货的时候,选择已开票的发票。" rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"/>
                            <td align="left">
                                <apex:outputField
                                    id="OrderForHospital_out"
                                    value="{!coc.ShipmentAccount__c}"
                                    style="width: 300px"
                                />
                            </td>
                            <td align="right">
                                <apex:outputText
                                    value="发票:"
                                    rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                />
                            </td>
                            <td align="left">
                                <apex:inputField
                                    value="{!coc.ConInvoice_Code__c}"
                                    rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                    id="ConInvoice_Code"
                                />
                                <c:helpicon
                                    helpText="已开票的换货的时候,选择已开票的发票。"
                                    rendered="{!IF(coc.SummonsStatus_c__c='已完成' && coc.SummonsForDirction__c!='互相调货',true,false)}"
                                />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">科室:</td>
                            <td align="left">
                                <apex:outputField id="Order_ForDealerText" value="{!coc.Order_ForCustomerText__c}" style="width:170px"/>
                                <apex:outputField
                                    id="Order_ForDealerText"
                                    value="{!coc.Order_ForCustomerText__c}"
                                    style="width: 170px"
                                />
                            </td>
                            <td align="right">出库金额:</td>
                            <td align="left"><apex:outputField id="sumPrice_buttom" value="{!coc.Shipment_total_amount__c}" style="width:300px"/> 元</td>
                        <!--    <td/>
                            <td align="left">
                                <apex:outputField
                                    id="sumPrice_buttom"
                                    value="{!coc.Shipment_total_amount__c}"
                                    style="width: 300px"
                                />
                                元
                            </td>
                            <!--    <td/>
                            <td align="right" style="visibility:hidden">出库单日期:</td>
                            <td align="right" style="visibility:hidden"><apex:outputField id="OrderDate_out" value="{!coc.Order_date__c}" style="width:300px"/></td> -->
                        </tr>
                        <!-- update start by vivek2019-7-12 -->
                        <tr>
                            <td align="right">没有确定价格:</td>
                            <td align="left">
                                <apex:inputCheckbox id="NoConfirmedPrice_out" value="{!coc.NoConfirmedPrice__c}" disabled="true" />
                                <apex:inputCheckbox
                                    id="NoConfirmedPrice_out"
                                    value="{!coc.NoConfirmedPrice__c}"
                                    disabled="true"
                                />
                            </td>
                            <!-- ===add by rentx 2020-12-04 start -->
                            <!-- <apex:detail rendered="{!agencyProType == 'ENG'}"> -->
                                <!-- <td align="right">是否医院特价出库 : </td> -->
                                <!-- <td align="left"> -->
                                    <!-- <apex:outputField id="OutPattern" value="{!coc.OutPattern__c}"/> -->
                                    <apex:inputHidden id="OutPattern" value="{!coc.OutPattern__c}"/>
                                <!-- </td> -->
                            <!-- <td align="right">是否医院特价出库 : </td> -->
                            <!-- <td align="left"> -->
                            <!-- <apex:outputField id="OutPattern" value="{!coc.OutPattern__c}"/> -->
                            <apex:inputHidden
                                id="OutPattern"
                                value="{!coc.OutPattern__c}"
                            />
                            <!-- </td> -->
                            <!-- </apex:detail> -->
                            <!-- ===add by rentx 2020-12-04 end -->
                        </tr>
                        <!-- update end by vivek2019-7-12 -->
                    </table>
                </apex:pageBlock>
<!--==============20160314====INSERT_CODE_END=======================================-->
                <!--==============20160314====INSERT_CODE_END=======================================-->
<!--==============20160310====到货联动时不需要检索====================================-->
                <!--==============20160310====到货联动时不需要检索====================================-->
                <!-- update start by vivek 2019-7-15 -->
                <apex:pageBlock id="searchBlock" rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}">
                <!-- apex:pageBlock id="searchBlock" rendered="{!IF(!Existarrive && EditAble,true,false)}"> -->
                <!-- update end by vivek 2019-7-15 -->
                <apex:pageBlock
                    id="searchBlock"
                    rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                >
                    <!-- apex:pageBlock id="searchBlock" rendered="{!IF(!Existarrive && EditAble,true,false)}"> -->
                    <!-- update end by vivek 2019-7-15 -->
                    <table>
                        <colgroup>
                            <col width="160px"/>
                            <col width="200"/>
                            <col width="15px"/>
                            <col width="120px"/>
                            <col width="200px"/>
                            <col width="20px"/>
                            <col width="120px"/>
                            <col width="200px"/>
                            <col width="20px"/>
                            <col width="120px"/>
                            <col width="200px"/>
                            <col width="20px"/>
                            <col width="90px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="85px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                            <col width="160px" />
                            <col width="200" />
                            <col width="15px" />
                            <col width="120px" />
                            <col width="200px" />
                            <col width="20px" />
                            <col width="120px" />
                            <col width="200px" />
                            <col width="20px" />
                            <col width="120px" />
                            <col width="200px" />
                            <col width="20px" />
                            <col width="90px" />
                            <col width="100px" />
                            <col width="10px" />
                            <col width="85px" />
                            <col width="100px" />
                            <col width="10px" />
                            <col width="70px" />
                            <col width="100px" />
                        </colgroup>
                        <tr>
                            <td align="right">消耗品名称</td>
                            <td><apex:inputText id="OrderDateSearch" value="{!category1}" style="width:100px"/></td>
                            <td/>
                            <td>
                                <apex:inputText
                                    id="OrderDateSearch"
                                    value="{!category1}"
                                    style="width: 100px"
                                />
                            </td>
                            <td />
                            <td align="right">第3分类</td>
                            <td>
                             <apex:selectList id="category3Search" value="{!category3}" style="width:100px" size="1" onchange="showAllCate();">
                                <apex:selectOptions value="{!categoryOptionList}"/>
                            </apex:selectList>
                                <apex:selectList
                                    id="category3Search"
                                    value="{!category3}"
                                    style="width: 100px"
                                    size="1"
                                    onchange="showAllCate();"
                                >
                                    <apex:selectOptions
                                        value="{!categoryOptionList}"
                                    />
                                </apex:selectList>
                            </td>
                            <td/>
                             <td align="right">第4分类</td>
                            <td />
                            <td align="right">第4分类</td>
                            <td>
                             <apex:selectList id="category4Search" value="{!category4}" style="width:100px" size="1" onchange="showCate();">
                                <apex:selectOptions value="{!category4OptionList}"/>
                            </apex:selectList>
                                <apex:selectList
                                    id="category4Search"
                                    value="{!category4}"
                                    style="width: 100px"
                                    size="1"
                                    onchange="showCate();"
                                >
                                    <apex:selectOptions
                                        value="{!category4OptionList}"
                                    />
                                </apex:selectList>
                            </td>
                            <td/>
                             <td align="right">第5分类</td>
                             <td>
                             <apex:selectList id="category5Search" value="{!category5}" style="width:100px" size="1">
                                <apex:selectOptions value="{!category5OptionList}"/>
                            </apex:selectList>
                            <td />
                            <td align="right">第5分类</td>
                            <td>
                                <apex:selectList
                                    id="category5Search"
                                    value="{!category5}"
                                    style="width: 100px"
                                    size="1"
                                >
                                    <apex:selectOptions
                                        value="{!category5OptionList}"
                                    />
                                </apex:selectList>
                            </td>
                            <td/>
                            <td />
                            <!-- //add by rentx start -->
                            <apex:detail rendered="{!hasHosPro}">
                                <td align="right" width="120px">医院特价</td>
                                 <td>
                                 <apex:selectList id="outOutPattern" value="{!outOutPattern}" style="width:100px" size="1">
                                    <apex:selectOptions value="{!outOutPatternOptionList}"/>
                                </apex:selectList>
                                <td>
                                    <apex:selectList
                                        id="outOutPattern"
                                        value="{!outOutPattern}"
                                        style="width: 100px"
                                        size="1"
                                    >
                                        <apex:selectOptions
                                            value="{!outOutPatternOptionList}"
                                        />
                                    </apex:selectList>
                                </td>
                                </apex:detail>
                            <td/>
                            </apex:detail>
                            <td />
                            <!-- //add by rentx end -->
                            <!-- <td align="right">产品型号</td>
                            <td><apex:inputText id="OrderCodeSearch" value="{!category_Goods}" style="width:100px"/></td> -->
                            <td align="right"></td>
                            <td><apex:commandButton value="检索" style="width: 100px;" onclick="searchProductJs(); return false;" /></td>
                            <td><input type="button" value="清空" style="width: 100px;" onclick="ClearJs()" class="btn"/></td>
                            <td/>
                            <td>
                                <apex:commandButton
                                    value="检索"
                                    style="width: 100px"
                                    onclick="searchProductJs(); return false;"
                                />
                            </td>
                            <td>
                                <input
                                    type="button"
                                    value="清空"
                                    style="width: 100px"
                                    onclick="ClearJs()"
                                    class="btn"
                                />
                            </td>
                            <td />
                        </tr>
                        <tr>
                            <td></td>
                        </tr>
                    </table>
                </apex:pageBlock>
                <div id="ErrorName" style="color: red;font-weight: bold;">{!alertMessage}</div>
                <apex:pageBlock title="出库单明细" id="ConsumableorderdetailsSection">
                <div id="ErrorName" style="color: red; font-weight: bold">
                    {!alertMessage}
                </div>
                <apex:pageBlock
                    title="出库单明细"
                    id="ConsumableorderdetailsSection"
                >
                    <!--<apex:inputHidden id="consumableorderdetailsCnt" value="{!consumableorderdetailsCount}"/>-->
                    <input type="hidden" id="allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount" value="{!consumableorderdetailsCount}" />
                    <table class="list" border="0" cellpadding="0" cellspacing="0" id="ConsumableorderdetailsTable">
                         <tr class="headerRow">
                    <input
                        type="hidden"
                        id="allPage:allForm:allBlock:ConsumableorderdetailsSection:consumableorderdetailsCount"
                        value="{!consumableorderdetailsCount}"
                    />
                    <table
                        class="list"
                        border="0"
                        cellpadding="0"
                        cellspacing="0"
                        id="ConsumableorderdetailsTable"
                    >
                        <tr class="headerRow">
                            <!-- update start by vivek 2019-7-15 -->
                            <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}">
                            <!-- <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble,true,false)}"> -->
                            <!-- update start by vivek 2019-7-15 -->
                                <th><input type='checkbox' onClick='checkAll()' id='checker'/>选择</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                            >
                                <!-- <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble,true,false)}"> -->
                                <!-- update start by vivek 2019-7-15 -->
                                <th>
                                    <input
                                        type="checkbox"
                                        onClick="checkAll()"
                                        id="checker"
                                    />选择
                                </th>
                            </apex:variable>
                            <th><a href="#" onclick="SortLimitedJs('0');return false;" style="text-decoration: underline;">消耗品名称</a>{!sortOrder[0]}</th>
                        <!--    <th><a href="#" onclick="SortLimitedJs('1');return false;" style="text-decoration: underline;">产品型号</a>{!sortOrder[1]}</th>-->
                            <th>
                                <a
                                    href="#"
                                    onclick="SortLimitedJs('0');return false;"
                                    style="text-decoration: underline"
                                    >消耗品名称</a
                                >{!sortOrder[0]}
                            </th>
                            <!--    <th><a href="#" onclick="SortLimitedJs('1');return false;" style="text-decoration: underline;">产品型号</a>{!sortOrder[1]}</th>-->
                            <!-- TODO 本番暂不显示 -->
                            <apex:variable var="v" value="">
                            <th style="width: 80px;text-align:center;">规格</th>
                                <th style="width: 80px; text-align: center">
                                    规格
                                </th>
                            </apex:variable>
                            <th>CFDA状态</th>
                            <th>注册证编码号</th>
                            <th>注册证效期</th>
                            <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}">
                             <th><a href="#" onclick="SortLimitedJs('5');return false;" style="text-decoration: underline;">第3分类</a>{!sortOrder[5]}</th>
                            <th><a href="#" onclick="SortLimitedJs('6');return false;" style="text-decoration: underline;">第4分类</a>{!sortOrder[6]}</th>
                            <th><a href="#" onclick="SortLimitedJs('7');return false;" style="text-decoration: underline;">第5分类</a>{!sortOrder[7]}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}"
                            >
                                <th>
                                    <a
                                        href="#"
                                        onclick="SortLimitedJs('5');return false;"
                                        style="text-decoration: underline"
                                        >第3分类</a
                                    >{!sortOrder[5]}
                                </th>
                                <th>
                                    <a
                                        href="#"
                                        onclick="SortLimitedJs('6');return false;"
                                        style="text-decoration: underline"
                                        >第4分类</a
                                    >{!sortOrder[6]}
                                </th>
                                <th>
                                    <a
                                        href="#"
                                        onclick="SortLimitedJs('7');return false;"
                                        style="text-decoration: underline"
                                        >第5分类</a
                                    >{!sortOrder[7]}
                                </th>
                            </apex:variable>
                            <th>单位</th>
                            <th>出货数量</th>
@@ -906,23 +1387,50 @@
                                <th>出货单价(元)</th>
                            </apex:variable>-->
                            <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="BoxPiece_UnEditout">
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}"
                                id="BoxPiece_UnEditout"
                            >
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!if(EditAble,true,false)}">
                            <th>出货金额(元)</th>
                            <!--<th><a href="#" onclick="SortStoreJs('3');return false;" style="text-decoration: underline;width: 100px;text-align: center;">有效期内库存</a>{!sortOrder[3]}</th>-->
                            <th>有效期内库存(盒)</th>
                            <th>有效期内库存(个)</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!if(EditAble,true,false)}"
                            >
                                <th>出货金额(元)</th>
                                <!--<th><a href="#" onclick="SortStoreJs('3');return false;" style="text-decoration: underline;width: 100px;text-align: center;">有效期内库存</a>{!sortOrder[3]}</th>-->
                                <th>有效期内库存(盒)</th>
                                <th>有效期内库存(个)</th>
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!!EditAble}">
                                <th>{!$ObjectType.Consumable_Orderdetails__c.fields.InvoiceProNot_count__c.label}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!!EditAble}"
                            >
                                <th>
                                    {!$ObjectType.Consumable_Orderdetails__c.fields.InvoiceProNot_count__c.label}
                                </th>
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!!EditAble}">
                                <th>{!$ObjectType.Consumable_Orderdetails__c.fields.RrturnPro_count__c.label}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!!EditAble}"
                            >
                                <th>
                                    {!$ObjectType.Consumable_Orderdetails__c.fields.RrturnPro_count__c.label}
                                </th>
                            </apex:variable>
                            <apex:variable var="v" value="" rendered="{!!EditAble}">
                                <th>{!$ObjectType.Consumable_Orderdetails__c.fields.Invoiced_Procount__c.label}</th>
                            <apex:variable
                                var="v"
                                value=""
                                rendered="{!!EditAble}"
                            >
                                <th>
                                    {!$ObjectType.Consumable_Orderdetails__c.fields.Invoiced_Procount__c.label}
                                </th>
                            </apex:variable>
                            <!-- //add by rentx 2020-11-27 start -->
@@ -931,117 +1439,294 @@
                            </apex:detail>
                            <!-- //add by rentx 2020-11-27 end -->
                        </tr>
                        <apex:repeat value="{!pageRecords}" var="records" id="ConsumableorderdetailsTable">
                        <apex:repeat
                            value="{!pageRecords}"
                            var="records"
                            id="ConsumableorderdetailsTable"
                        >
                            <tr class="dataRow">
                                <!-- update start by vivek 2019-7-15 -->
                                <!-- <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble,true,false)}" id="variableinfo"> -->
                                <apex:variable var="v" value="" rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}" id="variableinfo">
                                <!-- update end by vivek 2019-7-15 -->
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!IF(!Existarrive && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                                    id="variableinfo"
                                >
                                    <!-- update end by vivek 2019-7-15 -->
                                    <td>
                                    <apex:inputCheckbox value="{!records.check}" id="consumablesCountproRowCheckbox" disabled="{!!records.canSelect}"/>
                                     <apex:inputCheckbox value="{!records.oldCheck}" id="proRowOldCheckbox" style="display:none"/></td>
                                 </apex:variable>
                                        <apex:inputCheckbox
                                            value="{!records.check}"
                                            id="consumablesCountproRowCheckbox"
                                            disabled="{!!records.canSelect}"
                                        />
                                        <apex:inputCheckbox
                                            value="{!records.oldCheck}"
                                            id="proRowOldCheckbox"
                                            style="display: none"
                                        />
                                    </td>
                                </apex:variable>
                                <td class="dataCell">
                                    <apex:outputText id="ProductName" value="{!IF(records.oldCheck=false,records.Prod.Name__c,records.orderdetails1.Consumable_Product__r.Name__c)}"/>
                                    <apex:outputText
                                        id="ProductName"
                                        value="{!IF(records.oldCheck=false,records.Prod.Name__c,records.orderdetails1.Consumable_Product__r.Name__c)}"
                                    />
                                </td>
                            <!--    <td>{!records.Prod.Asset_Model_No__c}</td>
                                <!--    <td>{!records.Prod.Asset_Model_No__c}</td>
                                 -->
                                <td style="width: 80px;text-align:center;">{!records.packinglist}</td>
                                <td class="dataCell">{!records.Prod.SFDA_Status__c}</td>
                                <td class="dataCell">{!records.approbation_No}</td>
                                <td style="width: 80px; text-align: center">
                                    {!records.packinglist}
                                </td>
                                <td class="dataCell">
                                    <apex:outputText value="{0, date, yyyy/MM/dd}">
                                        <apex:param value="{!records.expiration_Date}" />
                                    {!records.Prod.SFDA_Status__c}
                                </td>
                                <td class="dataCell">
                                    {!records.approbation_No}
                                </td>
                                <td class="dataCell">
                                    <apex:outputText
                                        value="{0, date, yyyy/MM/dd}"
                                    >
                                        <apex:param
                                            value="{!records.expiration_Date}"
                                        />
                                    </apex:outputText>
                                </td>
                                <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}" id="variableCategory3">
                                 <td class="dataCell">{!records.Prod.Category3__c}</td>
                                 <td class="dataCell">{!records.Prod.Category4__c}</td>
                                 <td class="dataCell">{!records.Prod.Category5__c}</td>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}" id="BoxPiece_UnEditout1">
                                 <td class="dataCell">
                                    <apex:selectList value="{!records.orderdetails1.Box_Piece__c}" size="1" style="width:60px;" id="BoxPiece">
                                    <apex:selectOptions value="{!records.boxorpiece}"/>
                                    </apex:selectList>
                                </td>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}"
                                    id="variableCategory3"
                                >
                                    <td class="dataCell">
                                        {!records.Prod.Category3__c}
                                    </td>
                                    <td class="dataCell">
                                        {!records.Prod.Category4__c}
                                    </td>
                                    <td class="dataCell">
                                        {!records.Prod.Category5__c}
                                    </td>
                                    <!-- update start by vivek 2019-7-15 -->
                                    <apex:variable
                                        var="v"
                                        value=""
                                        rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                                        id="BoxPiece_UnEditout1"
                                    >
                                        <td class="dataCell">
                                            <apex:selectList
                                                value="{!records.orderdetails1.Box_Piece__c}"
                                                size="1"
                                                style="width: 60px"
                                                id="BoxPiece"
                                            >
                                                <apex:selectOptions
                                                    value="{!records.boxorpiece}"
                                                />
                                            </apex:selectList>
                                        </td>
                                    </apex:variable>
                                    <!-- update end by vivek 2019-7-15 -->
                                </apex:variable>
                                <!-- update end by vivek 2019-7-15 -->
                                 </apex:variable>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}" id="BoxPiece_UnEditout1">
                                <!-- <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="BoxPiece_UnEditout"> -->
                                <!-- update end by vivek 2019-7-15 -->
                                <td><apex:outputField id="BoxPiece_UnEditin" value="{!records.orderdetails1.Box_Piece__c}"/></td>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}"
                                    id="BoxPiece_UnEditout1"
                                >
                                    <!-- <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="BoxPiece_UnEditout"> -->
                                    <!-- update end by vivek 2019-7-15 -->
                                    <td>
                                        <apex:outputField
                                            id="BoxPiece_UnEditin"
                                            value="{!records.orderdetails1.Box_Piece__c}"
                                        />
                                    </td>
                                </apex:variable>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}" id="consumablesCount_UnEditout">
                                <!-- <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="consumablesCount_UnEditout"> -->
                                <!-- update start by vivek 2019-7-15 -->
                                <!--<td style="text-align:right;"><apex:outputField id="consumablesCount_Unagency" value="{!records.orderdetails1.Unitprice_To_agency__c}"/></td>-->
                                <td style="text-align:center;"><apex:outputField id="consumablesCount_UnEditin" value="{!records.orderdetails1.Shipment_Count__c}"/></td>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false))}"
                                    id="consumablesCount_UnEditout"
                                >
                                    <!-- <apex:variable var="v" value="" rendered="{!NOT(IF(arriveorder ='' && Existarrive = false && EditAble,true,false))}" id="consumablesCount_UnEditout"> -->
                                    <!-- update start by vivek 2019-7-15 -->
                                    <!--<td style="text-align:right;"><apex:outputField id="consumablesCount_Unagency" value="{!records.orderdetails1.Unitprice_To_agency__c}"/></td>-->
                                    <td style="text-align: center">
                                        <apex:outputField
                                            id="consumablesCount_UnEditin"
                                            value="{!records.orderdetails1.Shipment_Count__c}"
                                        />
                                    </td>
                                </apex:variable>
                                <!-- update start by vivek 2019-7-15 -->
                                <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}" id="variable">
                                 <!-- <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}" id="variable"> -->
                                <!-- update end by vivek 2019-7-15 -->
                                <td class="dataCell">
                                    <div style="width:2px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div>
                                    <apex:inputField onblur="ComputePrice(this)" id="consumablesCount" value="{!records.orderdetails1.Shipment_Count__c}" style="width: 100px;" /></td>
                                 </apex:variable>
                                <apex:variable var="v" value="" rendered="{!EditAble}" id="variableMoneyinfo">
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble && coc.SummonsStatus_c__c != '价格未定',true,false)}"
                                    id="variable"
                                >
                                    <!-- <apex:variable var="v" value="" rendered="{!IF(arriveorder ='' && Existarrive = false && EditAble,true,false)}" id="variable"> -->
                                    <!-- update end by vivek 2019-7-15 -->
                                    <td class="dataCell">
                                    <div style="width:2px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div>
                                    <apex:inputField onblur="ComputePriceCheck(this)" value="{!records.orderdetails1.Delivery_List_RMB__c}" style="width: 100px;" id="productOrderMoneyinfo"/>
                                        <div
                                            style="
                                                width: 2px;
                                                height: 20px;
                                                background-color: red;
                                                position: absolute;
                                                margin-right: 5px;
                                            "
                                        ></div>
                                        <apex:inputField
                                            onblur="ComputePrice(this)"
                                            id="consumablesCount"
                                            value="{!records.orderdetails1.Shipment_Count__c}"
                                            style="width: 100px"
                                        />
                                    </td>
                                </apex:variable>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!EditAble}"
                                    id="variableMoneyinfo"
                                >
                                    <td class="dataCell">
                                        <div
                                            style="
                                                width: 2px;
                                                height: 20px;
                                                background-color: red;
                                                position: absolute;
                                                margin-right: 5px;
                                            "
                                        ></div>
                                        <apex:inputField
                                            onblur="ComputePriceCheck(this)"
                                            value="{!records.orderdetails1.Delivery_List_RMB__c}"
                                            style="width: 100px"
                                            id="productOrderMoneyinfo"
                                        />
                                    </td>
                                    <!-- <td class="dataCell">
                                    <apex:inputField id="Unitpriceagency" value="{!records.orderdetails1.Unitprice_To_agency__c}"  style="width: 100px;"/>
                                    </td> -->
                                </apex:variable>
                                <apex:variable var="v" value="" rendered="{!!EditAble}">
                                    <td class="dataCell" style="text-align:center;">
                                    <apex:outputText id="consumablesCountDealerPrice_Unedit" value="{!IF(records.orderdetails1.Delivery_List_RMB__c==null,0.00,records.orderdetails1.Delivery_List_RMB__c)}"/>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!!EditAble}"
                                >
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputText
                                            id="consumablesCountDealerPrice_Unedit"
                                            value="{!IF(records.orderdetails1.Delivery_List_RMB__c==null,0.00,records.orderdetails1.Delivery_List_RMB__c)}"
                                        />
                                    </td>
                                    <!-- <td style="text-align:center;"><apex:outputField id="consumablesCount_Unagency" value="{!records.orderdetails1.Unitprice_To_agency__c}"/></td> -->
                                </apex:variable>
                                <apex:variable var="v" value="" id="variableAllprice" rendered="{!EditAble}">
                                <td class="dataCell" style="text-align:center;">
                                    <apex:outputField id="consumablesCounttestPrice" value="{!records.orderdetails1.Shipment_amount__c}"/>
                                </td>
                                <!--<td class="dataCell" style="text-align:right;width: 50px;">{!records.allnumber}</td>-->
                                <td class="dataCell" style="text-align:center;width: 50px;">{!records.Boxnumber}</td>
                                <td class="dataCell" style="text-align:center;width: 50px;">{!records.Piecenumber}</td>
                                <apex:variable
                                    var="v"
                                    value=""
                                    id="variableAllprice"
                                    rendered="{!EditAble}"
                                >
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            id="consumablesCounttestPrice"
                                            value="{!records.orderdetails1.Shipment_amount__c}"
                                        />
                                    </td>
                                    <!--<td class="dataCell" style="text-align:right;width: 50px;">{!records.allnumber}</td>-->
                                    <td
                                        class="dataCell"
                                        style="text-align: center; width: 50px"
                                    >
                                        {!records.Boxnumber}
                                    </td>
                                    <td
                                        class="dataCell"
                                        style="text-align: center; width: 50px"
                                    >
                                        {!records.Piecenumber}
                                    </td>
                                </apex:variable>
                                <apex:variable var="v" value="" rendered="{!!EditAble}">
                                    <td class="dataCell" style="text-align:center;"><apex:outputField value="{!records.orderdetails1.InvoiceProNot_count__c}"/></td>
                                    <td class="dataCell" style="text-align:center;"><apex:outputField value="{!records.orderdetails1.RrturnPro_count__c}"/></td>
                                    <td class="dataCell" style="text-align:center;"><apex:outputField value="{!records.orderdetails1.Invoiced_Procount__c}"/></td>
                                <apex:variable
                                    var="v"
                                    value=""
                                    rendered="{!!EditAble}"
                                >
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            value="{!records.orderdetails1.InvoiceProNot_count__c}"
                                        />
                                    </td>
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            value="{!records.orderdetails1.RrturnPro_count__c}"
                                        />
                                    </td>
                                    <td
                                        class="dataCell"
                                        style="text-align: center"
                                    >
                                        <apex:outputField
                                            value="{!records.orderdetails1.Invoiced_Procount__c}"
                                        />
                                    </td>
                                </apex:variable>
                                    <!-- add by rentx 2020-11-26 start -->
                                <apex:detail rendered="{!hasHosPro}" >
                                <!-- add by rentx 2020-11-26 start -->
                                <apex:detail rendered="{!hasHosPro}">
                                    <td>
                                        <!-- <apex:outputField value="{!records.orderdetails2.hospitalSpecialOffer__c}"/> -->
                                        <apex:detail rendered="{!records.hospitalSpecialOffer}" >
                                            <apex:inputHidden value="{!records.hospitalSpecialOffer}"  id="hosOffer"/>
                                            <apex:inputHidden value="{!records.hosPro}"  id="hosPro"/>
                                        <apex:detail
                                            rendered="{!records.hospitalSpecialOffer}"
                                        >
                                            <apex:inputHidden
                                                value="{!records.hospitalSpecialOffer}"
                                                id="hosOffer"
                                            />
                                            <apex:inputHidden
                                                value="{!records.hosPro}"
                                                id="hosPro"
                                            />
                                            √
                                        </apex:detail>
                                    </td>
                                </apex:detail>
                            <!-- add by rentx 2020-11-26 end -->
                                <!-- add by rentx 2020-11-26 end -->
                            </tr>
                        </apex:repeat>
                    </table>
                    <table style="width: 100%">
                         <tr>
                        <tr>
                            <td>
                                <!-- Page X of Y -->
                                <!-- PageNumber:当前页面所在位置,ResultSize:记录总条数,PageSize:每页记录条数 -->
                                <apex:outputText value="{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,
                                 (setCon.pageNumber * size))} 共 {!noOfRecords} 个" />
                                 <!--<apex:outputPanel >
                                <apex:outputText
                                    value="{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,
                                 (setCon.pageNumber * size))} 共 {!noOfRecords} 个"
                                />
                                <!--<apex:outputPanel >
                                    <apex:actionStatus id="fetchStatus" >
                                        <apex:facet name="start" >
                                          <img src="/img/loading.gif" />
@@ -1051,64 +1736,162 @@
                            </td>
                            <td align="center">
                                <div class="paginator line1">
                                <span class="prevNextLinks">
                                <!-- 有连接 -->
                                <apex:outputPanel rendered="{!setCon.hasPrevious}">
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!setCon.first}" oncomplete="refreshPageSizeJs();" title="首页" >
                                <img src="/s.gif" title="首页" alt="首页" class="{!if((setCon.hasPrevious),'first','firstoff')}"/>
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection"  action="{!setCon.previous}" oncomplete="refreshPageSizeJs();"  title="上一页">
                                <img src="/s.gif" title="上一页" alt="上一页" class="{!if((setCon.hasPrevious),'prev','prevoff')}"/>上一页
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                <!-- 无连接 -->
                                <apex:outputPanel rendered="{!!setCon.hasPrevious}">
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection" title="首页" >
                                <img src="/s.gif" title="首页" alt="首页" class="{!if((setCon.hasPrevious),'first','firstoff')}"/>
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection"  title="上一页">
                                <img src="/s.gif" title="上一页" alt="上一页" class="{!if((setCon.hasPrevious),'prev','prevoff')}"/>上一页
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                <!-- 有连接 -->
                                <apex:outputPanel rendered="{!setCon.hasNext}">
                                <span class="prevNext" rendered = "{!!setCon.hasNext}">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!setCon.next}" oncomplete="refreshPageSizeJs();" title="下一页" rendered="{!setCon.hasNext}">下一页
                                <img src="/s.gif" title="下一页" alt="下一页" class="{!if((setCon.hasNext),'next','nextoff')}" />
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!setCon.last}"  oncomplete="refreshPageSizeJs();" title="尾页">
                                <img src="/s.gif" title="尾页" alt="尾页" class="{!if((setCon.hasNext),'last','lastoff')}"/>
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                <!-- 无连接 -->
                                <apex:outputPanel rendered="{!!setCon.hasNext}">
                                <span class="prevNext" rendered = "{!setCon.hasNext}">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection"  title="下一页">下一页
                                <img src="/s.gif" title="下一页" alt="下一页" class="{!if((setCon.hasNext),'next','nextoff')}" />
                                </apex:commandLink>
                                </span>
                                <span class="prevNext">
                                <apex:commandLink status="fetchStatus" oncomplete="onLoadDirction();" reRender="ConsumableorderdetailsSection" title="尾页">
                                <img src="/s.gif" title="尾页" alt="尾页" class="{!if((setCon.hasNext),'last','lastoff')}"/>
                                </apex:commandLink>
                                </span>
                                </apex:outputPanel>
                                </span>
                                    <span class="prevNextLinks">
                                        <!-- 有连接 -->
                                        <apex:outputPanel
                                            rendered="{!setCon.hasPrevious}"
                                        >
                                            <span class="prevNext">
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.first}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="首页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="首页"
                                                        alt="首页"
                                                        class="{!if((setCon.hasPrevious),'first','firstoff')}"
                                                    />
                                                </apex:commandLink>
                                            </span>
                                            <span class="prevNext">
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.previous}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="上一页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="上一页"
                                                        alt="上一页"
                                                        class="{!if((setCon.hasPrevious),'prev','prevoff')}"
                                                    />上一页
                                                </apex:commandLink>
                                            </span>
                                        </apex:outputPanel>
                                        <!-- 无连接 -->
                                        <apex:outputPanel
                                            rendered="{!!setCon.hasPrevious}"
                                        >
                                            <span class="prevNext">
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="首页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="首页"
                                                        alt="首页"
                                                        class="{!if((setCon.hasPrevious),'first','firstoff')}"
                                                    />
                                                </apex:commandLink>
                                            </span>
                                            <span class="prevNext">
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="上一页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="上一页"
                                                        alt="上一页"
                                                        class="{!if((setCon.hasPrevious),'prev','prevoff')}"
                                                    />上一页
                                                </apex:commandLink>
                                            </span>
                                        </apex:outputPanel>
                                        <!-- 有连接 -->
                                        <apex:outputPanel
                                            rendered="{!setCon.hasNext}"
                                        >
                                            <span
                                                class="prevNext"
                                                rendered="{!!setCon.hasNext}"
                                            >
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.next}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="下一页"
                                                    rendered="{!setCon.hasNext}"
                                                    >下一页
                                                    <img
                                                        src="/s.gif"
                                                        title="下一页"
                                                        alt="下一页"
                                                        class="{!if((setCon.hasNext),'next','nextoff')}"
                                                    />
                                                </apex:commandLink>
                                            </span>
                                            <span class="prevNext">
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    reRender="ConsumableorderdetailsSection"
                                                    action="{!setCon.last}"
                                                    oncomplete="refreshPageSizeJs();"
                                                    title="尾页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="尾页"
                                                        alt="尾页"
                                                        class="{!if((setCon.hasNext),'last','lastoff')}"
                                                    />
                                                </apex:commandLink>
                                            </span>
                                        </apex:outputPanel>
                                        <!-- 无连接 -->
                                        <apex:outputPanel
                                            rendered="{!!setCon.hasNext}"
                                        >
                                            <span
                                                class="prevNext"
                                                rendered="{!setCon.hasNext}"
                                            >
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="下一页"
                                                    >下一页
                                                    <img
                                                        src="/s.gif"
                                                        title="下一页"
                                                        alt="下一页"
                                                        class="{!if((setCon.hasNext),'next','nextoff')}"
                                                    />
                                                </apex:commandLink>
                                            </span>
                                            <span class="prevNext">
                                                <apex:commandLink
                                                    status="fetchStatus"
                                                    oncomplete="onLoadDirction();"
                                                    reRender="ConsumableorderdetailsSection"
                                                    title="尾页"
                                                >
                                                    <img
                                                        src="/s.gif"
                                                        title="尾页"
                                                        alt="尾页"
                                                        class="{!if((setCon.hasNext),'last','lastoff')}"
                                                    />
                                                </apex:commandLink>
                                            </span>
                                        </apex:outputPanel>
                                    </span>
                                </div>
                             </td>
                             <td align="right" width="20%">
                            </td>
                            <td align="right" width="20%"></td>
                        </tr>
                    </table>
                    <!--
@@ -1138,49 +1921,87 @@
            </apex:panelGrid>-->
                </apex:pageBlock>
                <apex:pageBlock title="发票明细" rendered="{!IF((coc.Billed_Status__c !='还没开票') && IdCheck != null,true,false)}">
                     <apex:pageblocksection columns="1" id="consumableInvoiceRecordsSection">
                        <apex:pageblocktable value="{!consumableInvoiceRecords}" var="records" id="consumableInvoiceRecordsTable">
                             <apex:column width="80">
                                 <apex:facet name="header">发票号</apex:facet>
                                 <apex:outputField value="{!records.Name}"/>
                             </apex:column>
                              <apex:column width="80">
                                 <apex:facet name="header">发票日</apex:facet>
                                 <apex:outputField value="{!records.Invoice_Date__c}"/>
                             </apex:column>
                             <apex:column width="80" style="text-align: center;">
                                 <apex:facet name="header">发票票面金额(元)</apex:facet>
                                 <apex:outputField value="{!records.Invoice_total_amount__c}"/>
                             </apex:column>
                             <apex:column width="80">
                                 <apex:facet name="header">发票状态</apex:facet>
                                 <apex:outputField value="{!records.Invoice_status__c}"/>
                             </apex:column>
                <apex:pageBlock
                    title="发票明细"
                    rendered="{!IF((coc.Billed_Status__c !='还没开票') && IdCheck != null,true,false)}"
                >
                    <apex:pageblocksection
                        columns="1"
                        id="consumableInvoiceRecordsSection"
                    >
                        <apex:pageblocktable
                            value="{!consumableInvoiceRecords}"
                            var="records"
                            id="consumableInvoiceRecordsTable"
                        >
                            <apex:column width="80">
                                <apex:facet name="header">发票号</apex:facet>
                                <apex:outputField value="{!records.Name}" />
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">发票日</apex:facet>
                                <apex:outputField
                                    value="{!records.Invoice_Date__c}"
                                />
                            </apex:column>
                            <apex:column width="80" style="text-align: center">
                                <apex:facet name="header"
                                    >发票票面金额(元)</apex:facet
                                >
                                <apex:outputField
                                    value="{!records.Invoice_total_amount__c}"
                                />
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">发票状态</apex:facet>
                                <apex:outputField
                                    value="{!records.Invoice_status__c}"
                                />
                            </apex:column>
                        </apex:pageblocktable>
                    </apex:pageblocksection>
                </apex:pageBlock>
                <apex:pageBlock title="出库产品明细" rendered="{!IF(consumableorderdetails2Count > 0,true,false)}">
                <apex:pageblocksection columns="1" id="Consumableorderdetails2Section">
                    <apex:pageblocktable value="{!consumableorderdetails2Records}" var="records" id="Consumableorderdetails2Table">
                         <apex:column width="80">
                             <apex:facet name="header">消耗品名称</apex:facet>
                             <apex:outputField value="{!records.Prod.name}"/>
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">批次号</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.SerialLotNo__c}" />
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">管理编码</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.TracingCode__c}"/>
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">使用期限</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.Sterilization_limit__c}"/>
                         </apex:column>
                        <!-- <apex:column width="80">
                <apex:pageBlock
                    title="出库产品明细"
                    rendered="{!IF(consumableorderdetails2Count > 0,true,false)}"
                >
                    <apex:pageblocksection
                        columns="1"
                        id="Consumableorderdetails2Section"
                    >
                        <apex:pageblocktable
                            value="{!consumableorderdetails2Records}"
                            var="records"
                            id="Consumableorderdetails2Table"
                        >
                            <apex:column width="80">
                                <apex:facet name="header"
                                    >消耗品名称</apex:facet
                                >
                                <apex:outputField
                                    value="{!records.Prod.name}"
                                />
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">批次号</apex:facet>
                                <apex:outputField
                                    value="{!records.orderdetails2.SerialLotNo__c}"
                                />
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">管理编码</apex:facet>
                                <apex:outputField
                                    value="{!records.orderdetails2.TracingCode__c}"
                                />
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">使用期限</apex:facet>
                                <apex:outputField
                                    value="{!records.orderdetails2.Sterilization_limit__c}"
                                />
                            </apex:column>
                            <!-- <apex:column width="80">
                             <apex:facet name="header">开票日</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.Invoice_Date__c}" />
                         </apex:column>
@@ -1190,28 +2011,39 @@
                                <apex:outputText value="{!records.orderdetails2.Invoice_No__r.Name}" />
                             </apex:outputLink>
                         </apex:column> -->
                    </apex:pageblocktable>
                </apex:pageblocksection>
            </apex:pageBlock>
                        </apex:pageblocktable>
                    </apex:pageblocksection>
                </apex:pageBlock>
            </apex:pageBlock>
        </apex:outputPanel>
        <apex:pageBlock title="附件" id="ConsumableConsumeSection" rendered="{!!editAble}">
        <apex:pageBlockTable value="{!AttachmentRecoeds}" var="a" >
        <apex:column headerValue="标题" style="width: 33%">
        <apex:outputLink value="{!a.Concc.Id}" target="LINK_{!a.Concc.Id}">
            {!a.Concc.name}
        </apex:outputLink>
        </apex:column>
        <apex:column headerValue="创建人">
            <apex:outputField value="{!a.Concc.OwnerId}"/>
        </apex:column>
        </apex:pageBlockTable>
        <apex:pageBlockButtons location="top" >
            <apex:commandButton onclick="FilesUaplodJs();" value="上传附件" style="margin-left:30px;width:100px" rerender="dummy" rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
        <apex:pageBlock
            title="附件"
            id="ConsumableConsumeSection"
            rendered="{!!editAble}"
        >
            <apex:pageBlockTable value="{!AttachmentRecoeds}" var="a">
                <apex:column headerValue="标题" style="width: 33%">
                    <apex:outputLink
                        value="{!a.Concc.Id}"
                        target="LINK_{!a.Concc.Id}"
                    >
                        {!a.Concc.name}
                    </apex:outputLink>
                </apex:column>
                <apex:column headerValue="创建人">
                    <apex:outputField value="{!a.Concc.OwnerId}" />
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="top">
                <apex:commandButton
                    onclick="FilesUaplodJs();"
                    value="上传附件"
                    style="margin-left: 30px; width: 100px"
                    rerender="dummy"
                    rendered="{!!(EditDelCommitBtnDisabled||EditAble)}"
                />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
<script>
</script>
</apex:page>
    <script></script>
</apex:page>
manifest/packageForSign.xml
@@ -9,7 +9,8 @@
        <members>DNUpsertBatchTest</members>
        <members>SyncProvinceWIndowToSignForm</members>
        <members>SyncProvinceWIndowToSignFormTest</members>
        <members>LexArriveGoodsController</members>
        <name>ApexClass</name>
    </types>
    <version>52.0</version>
</Package>
</Package>