binxie
2023-06-20 6d14c34d9a4e304bf3289e4ad957b091f27ef3b8
force-app/main/default/lwc/lexConInvoiceView/lexConInvoiceView.js
@@ -13,7 +13,7 @@
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 deleteAtt from '@salesforce/apex/LexSummonsCreatController.deleteAtt';
import { NavigationMixin } from "lightning/navigation";
//table css 
import { loadStyle } from "lightning/platformResourceLoader";
@@ -22,21 +22,10 @@
const hospitalColumns = [
    {
        label: "医院名称",
        fieldName: "Name",
        initialWidth: 400,
        hideDefaultActions: true,
        wrapText: true,
    },
    {
        label: "省份",
        fieldName: "stateMasterName",
        hideDefaultActions: true,
    },
    {
        label: "选择",
        label: "",
        fieldName: "Id1",
        type: "button",
        initialWidth: 90,
        hideDefaultActions: true,
        typeAttributes: {
            label: "选择",
@@ -44,6 +33,17 @@
            size: 1,
        },
    },
    {
        label: "医院名称",
        fieldName: "Name",
        hideDefaultActions: true,
        wrapText: true,
    },
    {
        label: "省份",
        fieldName: "stateMasterName",
        hideDefaultActions: true,
    }
];
const invoiceDetailsColumns = [
    {
@@ -96,6 +96,7 @@
        hideDefaultActions: true,
        wrapText: true,
        cellAttributes: { alignment: 'right' },
        initialWidth:145,
        type: "number",
        typeAttributes: {
            minimumFractionDigits: 2,
@@ -160,6 +161,7 @@
        label: "产品型号",
        fieldName: "esdAssetModelNo",
        hideDefaultActions: true,
        initialWidth: 200,
        wrapText: true,
    },
    {
@@ -240,6 +242,8 @@
        typeAttributes: {
            recordId: { fieldName: "recordId" },
            shipmentNumber: { fieldName: "shipmentNumber" },
            isConinvoice: { fieldName: "isConinvoice" },
            esdInvoiceProNotCount: { fieldName: "esdInvoiceProNotCount" },
        },
    },
    {
@@ -248,6 +252,7 @@
        fieldName: "invoiceAllprice",
        hideDefaultActions: true,
        type: "number",
        initialWidth: 150,
        typeAttributes: {
            minimumFractionDigits: 2,
        },
@@ -258,7 +263,7 @@
}
export default class LexConInvoiceView extends NavigationMixin(LightningElement) {
    @track label=customLabel;
    @track label = customLabel;
    invoiceColumns = invoiceColumns;
    detailsColumns = detailsColumns;
    @track outboundColumns = [
@@ -369,6 +374,7 @@
    //文件上传
    @track showLoadingSpinner = false;
    @track showPopSpinner = false;
    @track UploadFile = "Upload File";
    @track fileName = "";
    @track fileData = [];
@@ -517,6 +523,7 @@
                        this.detailsData[i]['esdInvoiceUnitprice'] = this.detailsData[i].esd.Invoice_Unitprice__c;
                        //发票数量
                        this.detailsData[i]['shipmentNumber'] = this.detailsData[i].invoiceCount;
                        this.detailsData[i]['isConinvoice'] = true;
                        this.detailsData[i]['invoiceAllprice'] = this.detailsData[i].invoiceAllprice;
                        if (this.detailsData[i].check) {
@@ -552,7 +559,7 @@
                    this.ConInvoiceListUserWorkLocation = r.entity.userWorkLocation;
                    this.ConInvoiceListAgencyProType = r.entity.agencyProType;
                    if (this.ConInvoiceListAgencyProType != 'ET')
                    //if (this.ConInvoiceListAgencyProType != 'ET')
                        this.isOpenReportDisabled = false;
                    this.invoiceData = r.entity.raesList;
                    for (var i in this.invoiceData) {
@@ -660,7 +667,7 @@
                    this.HospitalName = r.entity.HospitalName;
                    this.HospitalInfo = r.entity.HospitalInfo;
                    this.agencyProType = r.entity.agencyProType;
                    if (this.agencyProType != 'ET')
                    //if (this.agencyProType != 'ET')
                        this.isOpenReportDisabled = false;
                    //科室
                    this.ForCustomerText = this.coc.Order_ForCustomerText__c;
@@ -681,6 +688,7 @@
                            label: '客户名',
                            fieldName: "hospitalName",
                            hideDefaultActions: true,
                            wrapText: true,
                        };
                        let object2 = {
                            label: '出货金额(元)',
@@ -829,6 +837,15 @@
        this.fileName = '';
    }
    //是否显示附件移除
    get attDelBtn() {
        if (this.fileName != '' && this.fileName != null && this.fileName != '选择一个文件上传') {
            return true;
        } else {
            return false;
        }
    }
    keepTwoDecimalStr(num) {
        const result = Number(num.toString().match(/^\d+(?:\.\d{0,2})?/));
        let s = result.toString();
@@ -970,7 +987,7 @@
                    cloneData[i].check = true;
                }
            }
            if(!b){
            if (!b) {
                cloneData[i].check = false;
            }
            delete cloneData[i].esdOutboundDate;
@@ -1034,22 +1051,21 @@
        console.log("handleFilesChange");
        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;
            //     this.filesUploaded = event.target.files;
            //     this.fileName = event.target.files[0].name;
            //     this.handleSave();
            // }
        }
        handleSave() {
        console.log("saveFile");
        if (this.filesUploaded.length > 0) {
            this.showPopSpinner = true;
            this.file = this.filesUploaded[0];
            if (this.file.size > this.MAX_FILE_SIZE) {
                this.showMyToast('保存失败', '文件过大', 'Error');
                return;
            }
            this.showLoadingSpinner = true;
            this.fileReader = new FileReader();
            this.fileReader.onloadend = () => {
@@ -1078,8 +1094,8 @@
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            if (r != '') {
                this.showLoadingSpinner = false;
                this.showMyToast('附件上传成功', '', 'Success');
                this.showPopSpinner = false;
                this.showMyToast('上传成功', '', 'Success');
                this.closePop();
                this.init();
            } else {
@@ -1117,8 +1133,9 @@
    }
    saveAttachmentJs() {
        debugger
        this.showLoadingSpinner = true;
        let cloneData = this.fileData
        let cloneData = this.deepClone(this.fileData)
        for (var i in cloneData) {
            delete cloneData[i].Id;
            delete cloneData[i].recordId;
@@ -1245,7 +1262,7 @@
                    cloneData[i].check = true;
                }
            }
            if(!b){
            if (!b) {
                cloneData[i].check = false;
            }
            delete cloneData[i].esdOutboundDate;
@@ -1286,8 +1303,8 @@
                let index = 0;
                this.selectedRows = [];
                for (var i in this.outboundData) {
                    if(this.outboundData[i].check)
                    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;
@@ -1435,13 +1452,15 @@
        let reportUrl = this.label.LexConInvoiceViewReport;
        let reportFilters = '[{"operator":"equals","value":"' + this.OrderCode + '","column":"FK_NAME"}]';
        console.log('reportUrl = ' + reportUrl);
        let url = "/report/"+ reportUrl +"?reportFilters=" + encodeURIComponent(reportFilters);
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            attributes: {
                url: url,
            },
        });
        let url = "/s/report/" + reportUrl + "?reportFilters=" + encodeURIComponent(reportFilters);
        window.open(url);
        // this[NavigationMixin.Navigate]({
        //     type: "standard__webPage",
        //     attributes: {
        //         url: url,
        //         target: '_blank'
        //     },
        // });
    }
    reopenJs() {
@@ -1461,6 +1480,7 @@
    showMyToast(title, message, variant) {
        this.isShowSpinner = false;
        this.showLoadingSpinner = false;
        this.showPopSpinner = false;
        this.showAttPop = false;
        this.filesUploaded = [];
        this.fileName = null;
@@ -1645,9 +1665,13 @@
        console.log("this.data = " + JSON.stringify(this.data));
    }
    deepClone(obj) {
        return JSON.parse(JSON.stringify(obj));
    }
    detailsSaveJs() {
        this.isShowSpinner = true;
        let cloneData = this.detailsData;
        let cloneData = this.deepClone(this.detailsData);
        let selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows();
        console.log('selectedRows = ' + JSON.stringify(selectedRows));
@@ -1747,18 +1771,19 @@
        console.log('attid:' + recordId);
        deleteAtt({
            contentVersionId: recordId
        }).then(result => {
            if (result.result == 'Success') {
        }).then(r => {
            r = JSON.parse(JSON.stringify(r));
            if (r.status == "Success") {
                this.showMyToast('删除成功', '', 'Success');
                if (this.fileData.length == 1)
                    window.location.reload();
                else
                    this.init();
            } else {
                this.showMyToast('删除失败', result.errorMsg, 'Error');
                this.showMyToast('删除失败', r.msg, 'Error');
            }
        }).catch(error => {
            this.showMyToast('错误', '删除失败', 'Error');
            this.showMyToast('错误', error.message, 'Error');
        })
    }
}