From 91f850751b85ab0125679a6ea446cbd8a622b46d Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 05 六月 2023 14:38:16 +0800
Subject: [PATCH] LEX Community UpdateComponent

---
 force-app/main/default/lwc/lexConInvoiceView/lexConInvoiceView.js |  419 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 310 insertions(+), 109 deletions(-)

diff --git a/force-app/main/default/lwc/lexConInvoiceView/lexConInvoiceView.js b/force-app/main/default/lwc/lexConInvoiceView/lexConInvoiceView.js
index 768f6af..eeb2a3f 100644
--- a/force-app/main/default/lwc/lexConInvoiceView/lexConInvoiceView.js
+++ b/force-app/main/default/lwc/lexConInvoiceView/lexConInvoiceView.js
@@ -13,7 +13,12 @@
 import serContact from "@salesforce/apex/lexSearchAgencyHospitalController.serContact";
 import detailsInit from "@salesforce/apex/LexConInvoicedetailsController.init";
 import detailsSave from "@salesforce/apex/LexConInvoicedetailsController.save";
+import deleteAtt from '@salesforce/apex/LexConsumableController.deleteAtt';
 import { NavigationMixin } from "lightning/navigation";
+//table css 
+import { loadStyle } from "lightning/platformResourceLoader";
+import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
+import LexConInvoiceViewReport from '@salesforce/label/c.LexConInvoiceViewReport';
 
 const hospitalColumns = [
     {
@@ -21,6 +26,7 @@
         fieldName: "Name",
         initialWidth: 400,
         hideDefaultActions: true,
+        wrapText: true,
     },
     {
         label: "鐪佷唤",
@@ -44,41 +50,53 @@
         label: "鍑哄簱鏃ユ湡",
         fieldName: "esdetProductOutDate",
         hideDefaultActions: true,
+        wrapText: true,
     },
     {
         label: "鍑哄簱鍗曠紪鐮�",
         fieldName: "esdetInvoicedet1ODlinkName",
         wrapText: true,
         hideDefaultActions: true,
+        wrapText: true,
     },
     {
         label: "浜у搧鍨嬪彿",
         fieldName: "esdetAssetModelNo",
         hideDefaultActions: true,
+        wrapText: true,
+        initialWidth: 400,
     },
     {
         label: "鍗曚綅",
         fieldName: "esdetInvoiceUnit",
         hideDefaultActions: true,
+        wrapText: true,
+        initialWidth: 50,
     },
     {
         label: "鍙戠エ鍗曚环",
         fieldName: "esdetInvoiceUnitprice",
         hideDefaultActions: true,
+        wrapText: true,
         type: "number",
         typeAttributes: {
-            minimumFractionDigits: 8,
+            minimumFractionDigits: 2,
         },
     },
     {
         label: "鍙戠エ鏁伴噺",
         fieldName: "esdetInvoicedCount",
+        cellAttributes: { alignment: 'right' },
         hideDefaultActions: true,
+        wrapText: true,
     },
     {
         label: "鍙戠エ绁ㄩ潰閲戦(鍏�)",
         fieldName: "esdetInvoicedProCostRMB",
         hideDefaultActions: true,
+        wrapText: true,
+        cellAttributes: { alignment: 'right' },
+        
         type: "number",
         typeAttributes: {
             minimumFractionDigits: 2,
@@ -90,6 +108,7 @@
         label: "鍙戠エ鏃ユ湡",
         fieldName: "Invoice_Date__c",
         hideDefaultActions: true,
+        initialWidth: 150
     },
     {
         label: "鍙戠エ鍙�",
@@ -110,6 +129,7 @@
         label: "鍙戠エ鐘舵��",
         fieldName: "Invoice_status__c",
         hideDefaultActions: true,
+        initialWidth: 100
     },
     {
         label: "鍙戠エ璐﹂潰閲戦(鍏�)",
@@ -119,18 +139,21 @@
         typeAttributes: {
             minimumFractionDigits: 2,
         },
+        initialWidth: 180
     },
     {
         label: "鍙戠エ闄勪欢",
         fieldName: "Invoice_attachment__c",
         type: 'boolean',
         hideDefaultActions: true,
+        initialWidth: 120
     },
     {
         label: "鍙戠エ鏄庣粏闄勪欢",
         fieldName: "Invoicedet_attachment__c",
         type: 'boolean',
         hideDefaultActions: true,
+        initialWidth: 120
     },
 ];
 const detailsColumns = [
@@ -138,12 +161,13 @@
         label: "浜у搧鍨嬪彿",
         fieldName: "esdAssetModelNo",
         hideDefaultActions: true,
+        wrapText: true,
     },
     {
         label: "瑙勬牸",
         fieldName: "packingListManual",
         hideDefaultActions: true,
-        initialWidth : 30
+        initialWidth: 30
     },
     {
         label: "鍑鸿揣鍗曚环(鍏�)",
@@ -189,13 +213,13 @@
     },
     {
         label: "寮�绁ㄥ崟浣�",
-        //fieldName: "esdInvoiceUnit",
         hideDefaultActions: true,
         type: "customUnit",
         typeAttributes: {
             unitValue: { fieldName: "unitValue" },
             unitOptions: { fieldName: "unitOptions" },
             recordId: { fieldName: "recordId" },
+            isDisabled: { fieldName: "isDisabled" },
         },
     },
     {
@@ -204,15 +228,16 @@
         hideDefaultActions: true,
         type: "number",
         typeAttributes: {
-            minimumFractionDigits: 8,
+            minimumFractionDigits: 2,
         },
-        initialWidth : 130
+        initialWidth: 130
     },
     {
         label: "鍙戠エ鏁伴噺",
         //fieldName: "invoiceCount",
         hideDefaultActions: true,
         type: "customShipment",
+        cellAttributes: { alignment: 'right' },
         typeAttributes: {
             recordId: { fieldName: "recordId" },
             shipmentNumber: { fieldName: "shipmentNumber" },
@@ -220,16 +245,22 @@
     },
     {
         label: "鍙戠エ绁ㄩ潰閲戦(鍏�)",
+        cellAttributes: { alignment: 'right' },
         fieldName: "invoiceAllprice",
         hideDefaultActions: true,
         type: "number",
+        initialWidth: 150,
         typeAttributes: {
             minimumFractionDigits: 2,
         },
     },
 ]
+const customLabel = {
+    LexConInvoiceViewReport
+}
 export default class LexConInvoiceView extends NavigationMixin(LightningElement) {
 
+    @track label=customLabel;
     invoiceColumns = invoiceColumns;
     detailsColumns = detailsColumns;
     @track outboundColumns = [
@@ -256,6 +287,7 @@
     @track invoiceData = [];
     @track invoiceAllpriceData = [];
     @track detailsSelectedRows = [];
+    @track showAttPop = false;
 
     @track invoiceId = '';
     @track orderId = '';
@@ -335,6 +367,7 @@
     @track isDisabledReopen = false;
     @track isDisabledDelete = false;
     @track isDisabledAttachment = false;
+    @track isOpenReportDisabled = true;
 
     //鏂囦欢涓婁紶
     @track showLoadingSpinner = false;
@@ -380,12 +413,38 @@
             },
             hideDefaultActions: true,
         },
+        {
+            label: '',
+            type: 'tableCellIcon',
+            typeAttributes: {
+                iconName: 'utility:delete',
+                recordId: {
+                    fieldName: 'Id'
+                }
+            },
+            initialWidth: 50,
+            hideDefaultActions: true
+        },
     ];
     filesUploaded = [];
     fileContents;
     fileReader;
     content;
     MAX_FILE_SIZE = 1500000;
+
+    stylesLoaded = false;
+    renderedCallback() {
+        if (!this.stylesLoaded) {
+            Promise.all([loadStyle(this, WrappedHeaderTable)])
+                .then(() => {
+                    console.log("Custom styles loaded");
+                    this.stylesLoaded = true;
+                })
+                .catch((error) => {
+                    console.error("Error loading custom styles");
+                });
+        }
+    }
 
     //鑾峰彇閾炬帴鍙傛暟
     getQueryString(name) {
@@ -403,6 +462,7 @@
     }
 
     init() {
+        this.isShowSpinner = true;
         this.deliveryId = this.getQueryString("deliveryId");
         this.deliveryId = this.deliveryId == null ? "" : this.deliveryId;
         this.invoiceId = this.getQueryString("invoiceId");
@@ -429,7 +489,7 @@
                     this.detailsData = r.entity.consumableorderdetails1Records;
                     for (var i in this.detailsData) {
                         this.detailsData[i]['Id'] = this.detailsData[i].esd.Id;
-                        
+
                         this.detailsData[i]['esdAssetModelNo'] = this.detailsData[i].esd.Asset_Model_No__c;
                         this.detailsData[i]['packingListManual'] = this.detailsData[i].Packing_list_manual;
                         this.detailsData[i]['esdDeliveryListRMB'] = this.detailsData[i].esd.Delivery_List_RMB__c;
@@ -440,8 +500,14 @@
                         this.detailsData[i]['esdInvoicedProcount'] = this.detailsData[i].esd.Invoiced_Procount__c;
                         this.detailsData[i]['esdInvoiceProNotCount'] = this.detailsData[i].esd.InvoiceProNot_count__c;
                         //寮�绁ㄥ崟浣�
-                        this.detailsData[i]['unitValue'] = this.detailsData[i].esd.Invoice_Unit__c;
+                        //this.detailsData[i].esd.Box_Piece__c
+                        //this.detailsData[i]['unitValue'] = this.detailsData[i].esd.Invoice_Unit__c;
+                        this.detailsData[i]['unitValue'] = this.detailsData[i].esd.Box_Piece__c;
+                        console.log('unitValue = ' + this.detailsData[i]['unitValue']);
                         this.detailsData[i]['recordId'] = this.detailsData[i].esd.Id;
+                        //disabled="{!IF(records.esd.Box_Piece__c =='涓�' || (records.esd.Box_Piece__c =='鐩�' && records.Packing_list_manual ==1),true,false)}"
+                        //this.detailsData[i]['isDisabled'] = (this.detailsData[i].esd.Box_Piece__c == '涓�' || (this.detailsData[i].esd.Box_Piece__c =='鐩�' && this.detailsData[i].Packing_list_manual ==1)) ? true:false;
+                        this.detailsData[i]['isDisabled'] = true;
                         let unitOptions = [];
                         for (var key in this.detailsData[i].Invoice_UnitOptsMap) {
                             let unitOption = {};
@@ -455,7 +521,7 @@
                         this.detailsData[i]['shipmentNumber'] = this.detailsData[i].invoiceCount;
                         this.detailsData[i]['invoiceAllprice'] = this.detailsData[i].invoiceAllprice;
 
-                        if(this.detailsData[i].check){
+                        if (this.detailsData[i].check) {
                             this.detailsSelectedRows.push(this.detailsData[i]['Id']);
                             this.invoiceAllprice += this.detailsData[i]['invoiceAllprice'];
                         }
@@ -472,7 +538,7 @@
                     this.isShowSpinner = false;
                     this.isDetailsShow = true;
                 } else {
-                    this.showToast("Error", r.msg);
+                    this.showMyToast('鍒濆鍖栧け璐�', r.msg, 'Error');
                 }
             }).catch((error) => {
                 this.isShowSpinner = false;
@@ -488,6 +554,8 @@
                     this.ConInvoiceListUserWorkLocation = r.entity.userWorkLocation;
 
                     this.ConInvoiceListAgencyProType = r.entity.agencyProType;
+                    if (this.ConInvoiceListAgencyProType != 'ET')
+                        this.isOpenReportDisabled = false;
                     this.invoiceData = r.entity.raesList;
                     for (var i in this.invoiceData) {
                         this.invoiceData[i]['NameUrl'] = '/lexconinvoiceview?invoiceId=' + this.invoiceData[i].Id;
@@ -503,7 +571,7 @@
                     console.log("this.invoiceStatusOptions = " + JSON.stringify(this.invoiceStatusOptions));
                     this.isShowSpinner = false;
                 } else {
-                    this.showToast("Error", r.msg);
+                    this.showMyToast('鍒濆鍖栧け璐�', r.msg, 'Error');
                 }
             }).catch((error) => {
                 console.log("error = " + JSON.stringify(error));
@@ -526,6 +594,7 @@
                     this.isChange = r.entity.isChange;
                     this.ExistOutbound = r.entity.ExistOutbound;
                     this.outboundData = r.entity.invoiceOrderRecoeds;
+                    console.log('this.outboundData = ' + JSON.stringify(this.outboundData))
                     this.done = r.entity.done;
                     this.accountid = r.entity.accountid;
                     this.userWorkLocation = r.entity.userWorkLocation;
@@ -545,6 +614,7 @@
                             this.selectedRows.push(this.outboundData[i].esd.Id);
                     }
                     this.selectedRows = [...this.selectedRows];
+                    console.log('r.entity.attachmentRecoeds = ' + JSON.stringify(r.entity.attachmentRecoeds))
                     if (!this.EditAble) {
                         //闄勪欢鏄剧ず
                         this.showLoadingSpinner = true;
@@ -557,6 +627,8 @@
                             this.fileData[i]["CreatedByName"] = this.fileData[i].cvInfo.Owner.Name;
                             this.fileData[i]["CreatedByNameUrl"] = "/" + this.fileData[i].cvInfo.OwnerId;;
                             this.fileData[i]["CreatedDate"] = this.fileData[i].cvInfo.CreatedDate;
+                            this.fileData[i]["attUrl"] = '/' + this.fileData[i].cvInfo.Id;
+                            this.fileData[i]['downloadUrl'] = '/sfc/servlet.shepherd/document/download/' + this.fileData[i].cvInfo.ContentDocumentId + '?operationContext=S1';
                             if (this.isDisabledAttachment) {
                                 console.log('杩涘叆this.isDisabledAttachment')
                                 this.fileData[i]["isDisabledAttachment"] = true;
@@ -572,8 +644,8 @@
                             this.fileData[i]["typeOptions"] = typeOptions;
                             this.fileData[i]["mailSelectOptsin"] = this.fileData[i].mailSelectOptsin == null ? typeOptions[0].value : this.fileData[i].mailSelectOptsin;
                         }
+                        console.log('this.fileData = ' + JSON.stringify(this.fileData))
                     }
-                    console.log('this.fileData = ' + JSON.stringify(this.fileData));
 
                     //鍙戠エ鏄庣粏
                     this.invoiceOrderdetail1Recoeds = r.entity.invoiceOrderdetail1Recoeds;
@@ -590,6 +662,8 @@
                     this.HospitalName = r.entity.HospitalName;
                     this.HospitalInfo = r.entity.HospitalInfo;
                     this.agencyProType = r.entity.agencyProType;
+                    if (this.agencyProType != 'ET')
+                        this.isOpenReportDisabled = false;
                     //绉戝
                     this.ForCustomerText = this.coc.Order_ForCustomerText__c;
                     //澶囨敞
@@ -602,8 +676,8 @@
                         this.provinceOptsMap.push(object);
                     }
                     //鍑鸿揣涓�瑙坈olumns
-                    
-                    
+
+
                     if (this.EditAble) {
                         let object1 = {
                             label: '瀹㈡埛鍚�',
@@ -655,7 +729,7 @@
                             this.outboundData[i]['returnAmount'] = this.outboundData[i].esd.RrturnPro_total_amount__c;
                         }
                         this.outboundData[i]['uninvoicedAmount'] = this.outboundData[i].esd.InvoiceNotPro_money__c;
-                        this.outboundData[i]['invoiceFaceAmount'] = this.outboundData[i].needInvoiceCount.toFixed(2);
+                        this.outboundData[i]['invoiceFaceAmount'] = this.keepTwoDecimalStr(this.outboundData[i].needInvoiceCount);
                         if (!(this.outboundData[i].esd.Billed_Status__c == '鍏ㄩ儴寮�绁�' || this.EditAble || this.coc.Invoice_status__c != '鑽夋涓�')) {
                             console.log('杩涘叆 if')
                             let url = "/lexconinvoiceview?orderId=" + this.outboundData[i].esd.Id + "&invoiceId=" + this.invoiceId;
@@ -663,6 +737,7 @@
                             if (index == 0) {
                                 let object5 = {
                                     label: '鍙戠エ绁ㄩ潰閲戦(鍏�)',
+                                    cellAttributes: { alignment: 'right' },
                                     type: 'url',
                                     fieldName: "invoiceFaceAmountUrl",
                                     typeAttributes: {
@@ -679,8 +754,13 @@
                             if (index == 0) {
                                 let object5 = {
                                     label: '鍙戠エ绁ㄩ潰閲戦(鍏�)',
+                                    cellAttributes: { alignment: 'right' },
                                     fieldName: "invoiceFaceAmount",
                                     hideDefaultActions: true,
+                                    type: "number",
+                                    typeAttributes: {
+                                        minimumFractionDigits: 2,
+                                    },
                                 };
                                 this.outboundColumns.push(object5)
                                 index++;
@@ -689,13 +769,13 @@
                         //璁$畻鍙戠エ绁ㄩ潰閲戦
                         this.sumPrice += this.outboundData[i].needInvoiceCount;
                     }
-                    
+
                     //鍥涜垗浜斿叆
                     //this.sumPrice = this.sumPrice.toFixed(2);
                     //濡傛灉涓嶅洓鑸嶄簲鍏�
-                    // console.log('start keepTwoDecimalStr')
-                    // this.sumPrice = keepTwoDecimalStr(this.sumPrice);
-                    // console.log('end keepTwoDecimalStr = ' + this.sumPrice)
+                    console.log('start keepTwoDecimalStr')
+                    this.sumPrice = this.keepTwoDecimalStr(this.sumPrice);
+                    console.log('end keepTwoDecimalStr = ' + this.sumPrice)
                     //鍔犳渶鍚庝竴琛屾樉绀洪噾棰�
                     if (this.EditAble) {
                         let lastOutboundData = {
@@ -704,7 +784,7 @@
                         this.outboundDataSumPrice.push(lastOutboundData);
                     }
                     this.outboundColumns = [...this.outboundColumns];
-                    
+
 
                     this.isEditInvoice = !(!this.EditAble || this.isChange);
                     if (this.coc.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�')
@@ -714,7 +794,7 @@
                     this.isShowSpinner = false;
                     this.showLoadingSpinner = false;
                 } else {
-                    this.showToast("Error", r.msg);
+                    this.showMyToast('澶辫触', r.msg, 'Error');
                 }
             }).catch((error) => {
                 console.log("error = " + JSON.stringify(error));
@@ -722,6 +802,48 @@
         }
 
     }
+
+
+    //涓婁紶閰嶇疆鍗�
+    uploadOrder(event) {
+        this.showAttPop = true;
+    }
+
+    //鍏抽棴闄勪欢寮圭獥
+    closePop() {
+        this.showAttPop = false;
+        this.filesUploaded = [];
+        this.fileName = null;
+    }
+
+    //闄勪欢change浜嬩欢
+    attChange(event) {
+        if (event.target.files.length > 0) {
+            this.filesUploaded = event.target.files;
+            this.fileName = event.target.files[0].name;
+            console.log('this.fileName:' + this.fileName);
+        }
+    }
+
+    //绉婚櫎闄勪欢
+    removeAtt() {
+        this.filesUploaded = [];
+        this.fileName = '';
+    }
+
+    keepTwoDecimalStr(num) {
+        const result = Number(num.toString().match(/^\d+(?:\.\d{0,2})?/));
+        let s = result.toString();
+        let rs = s.indexOf('.');
+        if (rs < 0) {
+            rs = s.length;
+            s += '.';
+        }
+        while (s.length <= rs + 2) {
+            s += '0';
+        }
+        return s;
+    };
 
     dataChange(event) {
         let fieldName = event.target.getAttribute("data-field");
@@ -837,7 +959,22 @@
     SaveJs() {
         this.isShowSpinner = true;
         let cloneData = this.outboundData
+
+        debugger
+        const selectedRows = this.template.querySelector("[data-field='outbound']").getSelectedRows();
+        console.log('selectedRows = ' + JSON.stringify(selectedRows));
+
         for (var i in cloneData) {
+            let b = false;
+            for (var j in selectedRows) {
+                if (cloneData[i].esd.Id == selectedRows[j].esd.Id) {
+                    b = true;
+                    cloneData[i].check = true;
+                }
+            }
+            if(!b){
+                cloneData[i].check = false;
+            }
             delete cloneData[i].esdOutboundDate;
             delete cloneData[i].esdNameUrl;
             delete cloneData[i].esdName;
@@ -887,30 +1024,31 @@
                     },
                 });
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('淇濆瓨澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + JSON.stringify(error));
-            this.showToast("Error", error.message);
         });
     }
 
     //涓婁紶闄勪欢锛岀洿鎺ュ氨淇濆瓨濂斤紝鐒跺悗灞曠ず
     handleFilesChange(event) {
         console.log("handleFilesChange");
-        if (event.target.files.length > 0) {
-            this.filesUploaded = event.target.files;
-            this.fileName = event.target.files[0].name;
-            this.handleSave();
-        }
+        this.handleSave();
+        // if (event.target.files.length > 0) {
+        //     this.filesUploaded = event.target.files;
+        //     this.fileName = event.target.files[0].name;
+        //     this.handleSave();
+        // }
     }
 
     handleSave() {
+        this.isShowSpinner = true;
         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.showMyToast('淇濆瓨澶辫触', '鏂囦欢杩囧ぇ', 'Error');
                 return;
             }
             this.showLoadingSpinner = true;
@@ -931,8 +1069,8 @@
 
     saveToFile() {
         console.log("saveToFile");
-        console.log("invoiceId = " +this.invoiceId);
-        console.log("fileName = " +this.fileName);
+        console.log("invoiceId = " + this.invoiceId);
+        console.log("fileName = " + this.fileName);
         console.log("base64Data = " + encodeURIComponent(this.fileContents));
         saveFile({
             recordId: this.invoiceId,
@@ -943,14 +1081,15 @@
             console.log("r = " + JSON.stringify(r));
             if (r != '') {
                 this.showLoadingSpinner = false;
-                this.showToast("Success", "涓婁紶鎴愬姛");
+                this.showMyToast('闄勪欢涓婁紶鎴愬姛', '', 'Success');
+                this.closePop();
                 this.init();
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('涓婁紶澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
-                console.log("error = " + error.message);
-                this.showToast("Error", "涓婁紶澶辫触");
+            console.log("error = " + error.message);
+            this.showMyToast('閿欒', '涓婁紶澶辫触', 'Error');
         });
     }
 
@@ -997,21 +1136,22 @@
         console.log('cloneData = ' + JSON.stringify(cloneData));
         saveAttachment({
             attachmentRecoedsLwc: JSON.stringify(cloneData),
-            invoiceId : this.invoiceId
+            invoiceId: this.invoiceId
         }).then((r) => {
             r = JSON.parse(JSON.stringify(r));
             console.log("r = " + JSON.stringify(r));
             if (r.status == "Success") {
                 this.showLoadingSpinner = false;
                 this.isShowSpinner = true;
-                const event = new ShowToastEvent({
-                    title: 'Success',
-                    variant: 'Success',
-                    message: '涓婁紶鎴愬姛',
-                });
-                this.dispatchEvent(event);
+                // const event = new ShowToastEvent({
+                //     title: 'Success',
+                //     variant: 'Success',
+                //     message: '淇濆瓨鎴愬姛',
+                // });
+                // this.dispatchEvent(event);
+                this.showMyToast('闄勪欢淇濆瓨鎴愬姛', '', 'Success');
                 //this.init();
-                setTimeout(function(){
+                setTimeout(function () {
                     //1绉掑悗鎵ц鍒锋柊
                     window.location.reload();
                 }, 2000); //鍗曚綅鏄绉�                
@@ -1024,11 +1164,11 @@
                 //     },
                 // });
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('涓婁紶澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + error.message);
-            this.showToast("Error", "涓婁紶澶辫触");
+            this.showMyToast('閿欒', '涓婁紶澶辫触', 'Error');
         });
     }
 
@@ -1054,16 +1194,16 @@
                 console.log("this.invoiceData = " + JSON.stringify(this.invoiceData));
                 this.isShowSpinner = false;
                 if (r.entity.raesListSize > 0) {
-                    this.showToast("Success", "鍏辨绱㈠埌" + r.entity.raesListSize + "涓彂绁�");
+                    this.showMyToast('鎼滅储鎴愬姛', '鍏辨绱㈠埌' + r.entity.raesListSize + '涓彂绁�', 'Success');
                 } else {
-                    this.showToast("Warning", "娌℃湁鎼滅储鍒扮浉鍏冲彂绁ㄣ��");
+                    this.showMyToast('鎼滅储澶辫触', '娌℃湁鎼滅储鍒扮浉鍏冲彂绁�', 'Error');
                 }
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('鎼滅储澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + error.message);
-            this.showToast("Error", "鎼滅储澶辫触");
+            this.showMyToast('閿欒', '鎼滅储澶辫触', 'Error');
         });
     }
 
@@ -1085,7 +1225,7 @@
                 console.log("this.invoiceData = " + JSON.stringify(this.invoiceData));
                 this.isShowSpinner = false;
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('鎼滅储澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + JSON.stringify(error));
@@ -1095,8 +1235,21 @@
     InvoiceorderSearchJs() {
         this.isShowSpinner = true;
 
+        debugger
         let cloneData = this.outboundData
+        const selectedRows = this.template.querySelector("[data-field='outbound']").getSelectedRows();
+        console.log('selectedRows ' + JSON.stringify(selectedRows));
         for (var i in cloneData) {
+            let b = false;
+            for (var j in selectedRows) {
+                if (cloneData[i].esd.Id == selectedRows[j].esd.Id) {
+                    b = true;
+                    cloneData[i].check = true;
+                }
+            }
+            if(!b){
+                cloneData[i].check = false;
+            }
             delete cloneData[i].esdOutboundDate;
             delete cloneData[i].esdNameUrl;
             delete cloneData[i].esdName;
@@ -1116,6 +1269,7 @@
         console.log('this.HospitalInfo = ' + this.HospitalInfo);
         console.log('SecondDealer = ' + this.secondaryDistributor);
         console.log('invoiceOrderRecoedsLwc = ' + JSON.stringify(cloneData));
+
         InvoiceorderSearch({
             cocLwc: this.coc,
             invoiceIdLwc: this.invoiceId,
@@ -1130,8 +1284,14 @@
             console.log("r = " + JSON.stringify(r));
             if (r.status == "Success") {
                 this.outboundData = r.entity.invoiceOrderRecoeds;
+                console.log('this.outboundData = ' + JSON.stringify(this.outboundData));
                 let index = 0;
+                this.selectedRows = [];
                 for (var i in this.outboundData) {
+                    
+                    if(this.outboundData[i].check)
+                        this.selectedRows.push(this.outboundData[i].esd.Id)
+                    this.outboundData[i].Id = this.outboundData[i].esd.Id;
                     this.outboundData[i]['esdOutboundDate'] = this.outboundData[i].esd.Outbound_Date__c;
                     this.outboundData[i]['esdNameUrl'] = '/s/lexsummonscreat?ESetid=' + this.outboundData[i].esd.Id;
                     this.outboundData[i]['esdName'] = this.outboundData[i].esd.Name;
@@ -1150,6 +1310,7 @@
                         if (index == 0) {
                             let object5 = {
                                 label: '鍙戠エ绁ㄩ潰閲戦(鍏�)',
+                                cellAttributes: { alignment: 'right' },
                                 type: 'url',
                                 fieldName: "invoiceFaceAmountUrl",
                                 typeAttributes: {
@@ -1165,6 +1326,7 @@
                         if (index == 0) {
                             let object5 = {
                                 label: '鍙戠エ绁ㄩ潰閲戦(鍏�)',
+                                cellAttributes: { alignment: 'right' },
                                 fieldName: "invoiceFaceAmount",
                                 hideDefaultActions: true,
                             };
@@ -1175,31 +1337,32 @@
                     //璁$畻鍙戠エ绁ㄩ潰閲戦
                     this.sumPrice += this.outboundData[i].needInvoiceCount;
                 }
+                console.log('this.selectedRows = ' + JSON.stringify(this.selectedRows))
                 this.isShowSpinner = false;
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('鎼滅储澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + error.message);
-            this.showToast("Error", "鎼滅储澶辫触");
+            this.showMyToast('閿欒', '鎼滅储澶辫触', 'Error');
         });
     }
 
     getSelectedRows(event) {
-        console.log("getSelectedRows ");
-        for (var i in this.outboundData) {
-            this.outboundData[i].check = false;
-        }
-        const selectedRows = event.detail.selectedRows;
-        for (var i in this.outboundData) {
-            for (var j in selectedRows) {
-                if (this.outboundData[i].esd.Id == selectedRows[j].esd.Id) {
-                    //this.outboundData[i].check = !this.outboundData[i].check;
-                    this.outboundData[i].check = true;
-                }
-            }
-        }
-        console.log('this.outboundData = ' + JSON.stringify(this.outboundData));
+        // console.log("getSelectedRows ");
+        // for (var i in this.outboundData) {
+        //     this.outboundData[i].check = false;
+        // }
+        // const selectedRows = event.detail.selectedRows;
+        // for (var i in this.outboundData) {
+        //     for (var j in selectedRows) {
+        //         if (this.outboundData[i].esd.Id == selectedRows[j].esd.Id) {
+        //             //this.outboundData[i].check = !this.outboundData[i].check;
+        //             this.outboundData[i].check = true;
+        //         }
+        //     }
+        // }
+        // console.log('this.outboundData = ' + JSON.stringify(this.outboundData));
     }
 
     deleteButtonJs() {
@@ -1221,11 +1384,10 @@
                     },
                 });
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('鍒犻櫎澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + error.message);
-            this.showToast("Error", error.message);
         });
     }
 
@@ -1246,34 +1408,36 @@
         approval({
             outOrderStringListLwc: this.outOrderStringListLwc,
             outordercountMapLwc: this.outordercountMapLwc,
-            invoiceIdLwc : this.invoiceId
+            invoiceIdLwc: this.invoiceId
+
         }).then((r) => {
             r = JSON.parse(JSON.stringify(r));
             console.log("r = " + JSON.stringify(r));
             if (r.status == "Success") {
                 this.isShowSpinner = false
-                let url = "/lexconinvoiceview?invoiceId=" + this.invoiceId;
+                let url = "/s/lexconinvoiceview?invoiceId=" + this.invoiceId;
                 console.log('url = ' + url);
-                this[NavigationMixin.Navigate]({
-                    type: "standard__webPage",
-                    attributes: {
-                        url: url,
-                    },
-                });
+                window.open(url, '_self');
+                // this[NavigationMixin.Navigate]({
+                //     type: "standard__webPage",
+                //     attributes: {
+                //         url: url,
+                //     },
+                // });
             } else {
-                this.showToast("Error", r.msg);
+                this.showMyToast('閿欒', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + error.message);
-            this.showToast("Error", error.message);
         });
     }
 
     openReportJs() {
         console.log("openReportJs");
-        //let url = "/report/00O100000058VzB?fv1=" + this.OrderCode;
+        let reportUrl = this.label.LexConInvoiceViewReport;
         let reportFilters = '[{"operator":"equals","value":"' + this.OrderCode + '","column":"FK_NAME"}]';
-        let url = "/report/00O0l000000zaGcEAI?reportFilters=" + encodeURIComponent(reportFilters);
+        console.log('reportUrl = ' + reportUrl);
+        let url = "/report/"+ reportUrl +"?reportFilters=" + encodeURIComponent(reportFilters);
         this[NavigationMixin.Navigate]({
             type: "standard__webPage",
             attributes: {
@@ -1296,27 +1460,42 @@
         });
     }
 
-    showToast(type, msg) {
+    showMyToast(title, message, variant) {
         this.isShowSpinner = false;
         this.showLoadingSpinner = false;
-        const event = new ShowToastEvent({
-            title: type,
-            variant: type,
-            message: msg,
-        });
-        this.dispatchEvent(event);
+        this.showAttPop = false;
+        this.filesUploaded = [];
+        this.fileName = null;
+        console.log('show custom message');
+        var iconName = '';
+        var content = '';
+        if (variant.toLowerCase() == 'success') {
+            iconName = 'utility:check';
+        } else {
+            iconName = 'utility:error';
+        }
+        if (message != '') {
+            content = '<h2><strong>' + title + '<strong/></h2><h5>' + message + '</h5>';
+        } else {
+            content = '<h2><strong>' + title + '<strong/></h2>';
+        }
+        this.template.querySelector('c-common-toast').showToast(variant, content, iconName, 10000);
     }
 
     handleLoad() {
         console.log('handleLoad')
         try {
             const style = document.createElement('style');
-            style.innerText = '.slds-button__icon {display: none;}';
+            style.innerText = '.hehe-layoutItem .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}';
             this.template.querySelector('.hideHelpText').appendChild(style2);
+
+            const style3 = document.createElement('style');
+            style3.innerText = '.readOnly  .slds-form-element__label {padding-top: 7px;}';
+            this.template.querySelector('.hideHelpText').appendChild(style3);
         } catch (error) {
             console.log(error);
         }
@@ -1340,7 +1519,7 @@
         console.log('handleLoad2')
         try {
             const style = document.createElement('style');
-            style.innerText = '.slds-button__icon {display: none;}';
+            style.innerText = '.hehe-layoutItem .slds-button__icon {display: none;}';
             this.template.querySelector('.hideHelpText').appendChild(style);
 
             const style2 = document.createElement('style');
@@ -1374,24 +1553,24 @@
                 console.log('this.detailsData[i].Id = ' + this.detailsData[i].Id);
                 console.log('this.detailsSelectedRows[j] = ' + this.detailsSelectedRows[j]);
                 if (this.detailsData[i].Id == this.detailsSelectedRows[j]) {
-                    this.detailsData[i].invoiceAllprice = this.amend(this.detailsData[i].shipmentNumber,this.detailsData[i].esdInvoiceUnitprice,'*');
+                    this.detailsData[i].invoiceAllprice = this.amend(this.detailsData[i].shipmentNumber, this.detailsData[i].esdInvoiceUnitprice, '*');
                     console.log('this.detailsData[i].invoiceAllprice = ' + this.detailsData[i].invoiceAllprice);
                 }
             }
-            this.invoiceAllpriceData[0].invoiceAllprice = this.amend(this.invoiceAllpriceData[0].invoiceAllprice,this.detailsData[i].invoiceAllprice,'+');
+            this.invoiceAllpriceData[0].invoiceAllprice = this.amend(this.invoiceAllpriceData[0].invoiceAllprice, this.detailsData[i].invoiceAllprice, '+');
         }
         this.detailsData = [...this.detailsData];
         this.invoiceAllpriceData = [...this.invoiceAllpriceData];
     }
 
-    handleShipmentNumber(event){
+    handleShipmentNumber(event) {
         console.log("handleShipmentNumber");
         this.invoiceAllpriceData[0].invoiceAllprice = 0.00;
         const numberDetail = event.detail;
-        console.log('numberDetail = '  + JSON.stringify(numberDetail))
-        if(numberDetail.data.shipmentnumber == 0){
-            if(this.detailsSelectedRows.indexOf(numberDetail.data.recordId) != -1){
-                this.detailsSelectedRows.splice(this.detailsSelectedRows.indexOf(numberDetail.data.recordId),1);
+        console.log('numberDetail = ' + JSON.stringify(numberDetail))
+        if (numberDetail.data.shipmentnumber == 0) {
+            if (this.detailsSelectedRows.indexOf(numberDetail.data.recordId) != -1) {
+                this.detailsSelectedRows.splice(this.detailsSelectedRows.indexOf(numberDetail.data.recordId), 1);
             }
         }
         console.log("start this.detailsSelectedRows = " + JSON.stringify(this.detailsSelectedRows));
@@ -1416,17 +1595,17 @@
                 console.log('this.detailsData[i].Id = ' + this.detailsData[i].Id);
                 console.log('this.detailsSelectedRows[j] = ' + this.detailsSelectedRows[j]);
                 if (this.detailsData[i].Id == this.detailsSelectedRows[j]) {
-                    this.detailsData[i].invoiceAllprice = this.amend(this.detailsData[i].shipmentNumber,this.detailsData[i].esdInvoiceUnitprice,'*');
+                    this.detailsData[i].invoiceAllprice = this.amend(this.detailsData[i].shipmentNumber, this.detailsData[i].esdInvoiceUnitprice, '*');
                     console.log('this.detailsData[i].invoiceAllprice = ' + this.detailsData[i].invoiceAllprice);
                 }
             }
-            this.invoiceAllpriceData[0].invoiceAllprice = this.amend(this.invoiceAllpriceData[0].invoiceAllprice,this.detailsData[i].invoiceAllprice,'+');
+            this.invoiceAllpriceData[0].invoiceAllprice = this.amend(this.invoiceAllpriceData[0].invoiceAllprice, this.detailsData[i].invoiceAllprice, '+');
         }
         this.detailsData = [...this.detailsData];
         this.invoiceAllpriceData = [...this.invoiceAllpriceData];
     }
 
-    detailsGetSelectedRows(event){
+    detailsGetSelectedRows(event) {
         console.log("detailsGetSelectedRows ");
         this.invoiceAllpriceData[0].invoiceAllprice = 0.00;
         let selectedRows = event.detail.selectedRows;
@@ -1434,11 +1613,11 @@
             this.detailsData[i].invoiceAllprice = 0.00;
             for (var j in selectedRows) {
                 if (this.detailsData[i].Id == selectedRows[j].esd.Id) {
-                    this.detailsData[i].invoiceAllprice = this.amend(this.detailsData[i].shipmentNumber,this.detailsData[i].esdInvoiceUnitprice,'*');
+                    this.detailsData[i].invoiceAllprice = this.amend(this.detailsData[i].shipmentNumber, this.detailsData[i].esdInvoiceUnitprice, '*');
                     console.log('this.detailsData[i].invoiceAllprice = ' + this.detailsData[i].invoiceAllprice);
                 }
             }
-            this.invoiceAllpriceData[0].invoiceAllprice = this.amend(this.invoiceAllpriceData[0].invoiceAllprice,this.detailsData[i].invoiceAllprice,'+');
+            this.invoiceAllpriceData[0].invoiceAllprice = this.amend(this.invoiceAllpriceData[0].invoiceAllprice, this.detailsData[i].invoiceAllprice, '+');
             console.log('this.invoiceAllpriceData[0].invoiceAllprice = ' + this.invoiceAllpriceData[0].invoiceAllprice);
         }
         console.log('start this.detailsData = ' + JSON.stringify(this.detailsData));
@@ -1468,7 +1647,7 @@
         console.log("this.data = " + JSON.stringify(this.data));
     }
 
-    detailsSaveJs(){
+    detailsSaveJs() {
         this.isShowSpinner = true;
         let cloneData = this.detailsData;
 
@@ -1491,20 +1670,20 @@
             delete cloneData[i].esdInvoiceUnitprice;
             delete cloneData[i].shipmentNumber;
             delete cloneData[i].invoiceAllprice;
-            for(var j in selectedRows){
-                if(cloneData[i].esd.Id == selectedRows[j].esd.Id){
+            for (var j in selectedRows) {
+                if (cloneData[i].esd.Id == selectedRows[j].esd.Id) {
                     cloneData[i]['check'] = true;
                 }
             }
         }
         console.log('cloneData = ' + JSON.stringify(cloneData));
 
-        
+
 
         detailsSave({
             consumableorderdetails1RecordsLwc: JSON.stringify(cloneData),
-            invoiceIdLwc : this.invoiceId,
-            orderIdLwc : this.orderId
+            invoiceIdLwc: this.invoiceId,
+            orderIdLwc: this.orderId
         }).then((r) => {
             r = JSON.parse(JSON.stringify(r));
             console.log("r = " + JSON.stringify(r));
@@ -1516,12 +1695,11 @@
                         url: url,
                     },
                 });
-            }else {
-                this.showToast("Error", r.msg);
+            } else {
+                this.showMyToast('淇濆瓨澶辫触', r.msg, 'Error');
             }
         }).catch((error) => {
             console.log("error = " + error.message);
-            this.showToast("Error", error.message);
         });
     }
 
@@ -1562,4 +1740,27 @@
         }
         return result;
     }
+
+    //鍒犻櫎闄勪欢
+    deleteAtt(event) {
+        this.isShowSpinner = true;
+        //var recordId = event.detail.data.recordId;
+        var recordId = event.target.getAttribute("data-fileid");
+        console.log('attid:' + recordId);
+        deleteAtt({
+            contentVersionId: recordId
+        }).then(result => {
+            if (result.result == 'Success') {
+                this.showMyToast('鍒犻櫎鎴愬姛', '', 'Success');
+                if (this.fileData.length == 1)
+                    window.location.reload();
+                else
+                    this.init();
+            } else {
+                this.showMyToast('鍒犻櫎澶辫触', result.errorMsg, 'Error');
+            }
+        }).catch(error => {
+            this.showMyToast('閿欒', '鍒犻櫎澶辫触', 'Error');
+        })
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1