buli
2023-04-26 d6a096fadfe9c8f261f56a827cfceed663c36b8b
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.js
@@ -169,6 +169,7 @@
            fieldName: "Name__c",
            hideDefaultActions: true,
            initialWidth: 250,
            wrapText: true,
        },
        {
            label: "规格",
@@ -230,6 +231,10 @@
        {
            label: "出货单价(元)",
            fieldName: "Shipment_amount__c",
            type: "number",
            typeAttributes: {
                minimumFractionDigits: 2,
            },
            initialWidth: 150,
            hideDefaultActions: true,
        },
@@ -315,6 +320,7 @@
            },
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 240
        },
        {
            label: "单位",
@@ -339,6 +345,7 @@
            fieldName: "Bar_Code__c",
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 500
        },
        {
            label: "使用期限",
@@ -422,6 +429,8 @@
    @track isBarcode = true;
    @track isShowInformation = true;
    @track isShowOutboundProductDetails = false;
    @track showAttPop = false;
    @track showPopSpinner = false;
    //disable按钮
    @track isEditDisabled = false;
@@ -520,10 +529,6 @@
    content;
    MAX_FILE_SIZE = 1500000;
    get acceptedFormats() {
        return [".xlsx"];
    }
    //InvoiceProNotLabel    RrturnProLabel  InvoicedLabel
    @wire(getObjectInfo, { objectApiName: OPPORTUNITY_OBJECT })
    oppInfo({ data, error }) {
@@ -568,6 +573,7 @@
            console.log("r = " + JSON.stringify(r));
            if (r.status == "Success") {
                this.OECId = r.entity.HospitalInfo == null ? '' : r.entity.HospitalInfo;
                console.log("this.OECId = " + this.OECId);
                this.ConsumableOut_report = r.entity.ConsumableOut_report;
@@ -657,6 +663,8 @@
                    }
                    // 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"];
@@ -801,10 +809,18 @@
                    }
                }
                //如果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 = {
@@ -815,6 +831,10 @@
                    let object3 = {
                        label: this.InvoicedLabel,
                        fieldName: "Invoiced_Procount__c",
                        type: "number",
                        typeAttributes: {
                            minimumFractionDigits: 2,
                        },
                        hideDefaultActions: true,
                    };
                    this.editColumns.push(object1);
@@ -895,7 +915,7 @@
                    JSON.stringify(this.secondaryDistributorOptions)
                );
                this.HospitalName = r.entity.HospitalName;
                this.sumPrice = r.entity.sumPrice + "元";
                this.sumPrice = r.entity.sumPrice.toFixed(2) + "元";
                this.isShowSpinner = false;
                this.showTable = true;
                console.log("ESetid = " + this.ESetid);
@@ -903,6 +923,8 @@
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
            }
        }).catch((error) => {
            console.log("error = " + JSON.stringify(error));
        });
    }
@@ -919,6 +941,7 @@
                this.ForDealerText = "";
                this.isDisabledForDealerText = true;
                this.isDisabledSecondaryDistributor = true;
                this.isMutualTransferGoods = false;
                break;
            case "医院试用":
                this.isDisabledHospitalName = false;
@@ -973,7 +996,7 @@
                this.ForCustomerText = value;
                break;
            case "sumPrice":
                this.sumPrice = value;
                this.sumPrice = value.toFixed(2);
                break;
            case "NoConfirmedPrice":
                this.NoConfirmedPrice = !this.NoConfirmedPrice;
@@ -987,7 +1010,7 @@
                this.Category3 = value;
                //调用后台显示第四五分类
                this.showAllCate();
                if(this.Category3 == ''){
                if (this.Category3 == '') {
                    this.Category4 = '';
                    this.Category5 = '';
                }
@@ -996,7 +1019,7 @@
                this.Category4 = value;
                //调用后台显示第五分类
                this.showCate();
                if(this.Category4 == ''){
                if (this.Category4 == '') {
                    this.Category5 = '';
                }
                break;
@@ -1012,10 +1035,10 @@
        }
    }
    showAllCate(){
    showAllCate() {
        console.log('showAllCate')
        categoryAllload({
            category3Lwc : this.Category3
            category3Lwc: this.Category3
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
@@ -1037,7 +1060,7 @@
                    object["value"] = key;
                    this.category5Options.push(object);
                }
            }else {
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
            }
@@ -1046,11 +1069,11 @@
        });
    }
    showCate(){
    showCate() {
        console.log('showAllCate')
        categoryload({
            category3Lwc : this.Category3,
            category4Lwc : this.Category4
            category3Lwc: this.Category3,
            category4Lwc: this.Category4
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
@@ -1072,7 +1095,7 @@
                    object["value"] = key;
                    this.category5Options.push(object);
                }
            }else {
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
            }
@@ -1100,6 +1123,19 @@
    searchProductJs() {
        this.isShowSpinner = true;
        //this.showTable = false;
        //查询有哪些选择了的然后check
        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;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
@@ -1145,7 +1181,22 @@
                        unitOptions.push(unitOption);
                    }
                    tempData[i]["unitOptions"] = unitOptions;
                    tempData[i]["unitValue"] = unitOptions[0].value;
                    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"];
                    } else {
                        tempData[i]["InvoiceProNot_count__c"] =
                            tempData[i].orderdetails1.InvoiceProNot_count__c;
                        tempData[i]["RrturnPro_count__c"] =
                            tempData[i].orderdetails1.RrturnPro_count__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]["recordId"] = tempData[i].Prod.Id;
                    tempData[i]["Id"] = tempData[i].Prod.Id;
                    tempData[i]["Name__c"] = tempData[i].Prod.Name__c;
@@ -1154,23 +1205,57 @@
                    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"]
                    );
                    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]['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));
                //this.showTable = true;
                this.isShowSpinner = false;
            }else {
            } else {
                console.log("r = " + JSON.stringify(r));
                this.showToast("Error", r.msg);
            }
@@ -1284,9 +1369,6 @@
                this.data[i].orderdetails1["Shipment_Count__c"] = Number(
                    numberDetail.data.shipmentnumber
                );
                console.log(
                    "this.data[i].shipmentNumber = " + this.data[i].shipmentNumber
                );
            }
        }
        this.ComputePrice(
@@ -1309,9 +1391,6 @@
                this.data[i].orderdetails1["Delivery_List_RMB__c"] = Number(
                    priceDetail.data.shipmentunitprice
                );
                console.log(
                    "this.data[i].shippingUnitPrice = " + this.data[i].shippingUnitPrice
                );
            }
        }
        this.ComputePrice(
@@ -1332,15 +1411,18 @@
        for (var i in this.data) {
            if (this.data[i].shipmentAmount) sumPrice += this.data[i].shipmentAmount;
        }
        this.sumPrice = sumPrice + "元";
        this.sumPrice = sumPrice.toFixed(2) + "元";
        //存下选择行,不会被清空
        this.selectedRows = [];
        for (var i in this.data) {
            if (this.data[i].check) {
                this.selectedRows.push(this.data[i].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) {
        //         this.selectedRows.push(this.data[i].Id);
        //     }
        // }
        this.data = [...this.data];
        this.selectedRows = [...this.selectedRows]
        console.log("this.selectedRows = " + JSON.stringify(this.selectedRows));
        console.log("this.data = " + JSON.stringify(this.data));
    }
@@ -1386,18 +1468,23 @@
    }
    getSelectedRows(event) {
        const selectedRows = event.detail.selectedRows;
        console.log("this.selectedRows = " + this.selectedRows);
        for (var i in this.data) {
            this.data[i]["check"] = false;
        let selectedRowsEvent = event.detail.selectedRows;
        this.selectedRows = [];
        for (var i in selectedRowsEvent) {
            this.selectedRows.push(selectedRowsEvent[i].Id)
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                }
            }
        }
        // const selectedRows = event.detail.selectedRows;
        // console.log("this.selectedRows = " + this.selectedRows);
        // for (var i in this.data) {
        //     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;
        //         }
        //     }
        // }
    }
    saveConfirmJs() {
@@ -1413,6 +1500,21 @@
    saveConfirm() {
        this.isShowSpinner = true;
        //查询有哪些选择了的然后check
        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;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
@@ -1441,32 +1543,32 @@
            cocLwc: this.cocLwc,
            hospitalInfoLwc: this.OECId,
            hospitalNameLwc: this.HospitalName,
            secondaryDistributor: this.secondaryDistributor,
            secondaryDistributorLwc: this.secondaryDistributor,
            pageRecordsLwc: cloneData,
            accountid: this.accountid,
            ESetId: this.ESetid,
            accountidLwc: this.accountid,
            ESetIdLwc: this.ESetid,
            consumableproductdetailsRecordsLwc: this.consumableproductdetailsRecords,
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                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));
            });
            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));
        });
    }
    //打印指示单
@@ -1493,7 +1595,8 @@
        console.log("openReportJs");
        var reportId = this.ESetid;
        reportId = reportId.substring(0, 15);
        let url = "/report/00O100000058VzB?fv1=" + reportId;
        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",
@@ -1561,7 +1664,7 @@
                this.showToast("Error", "文件过大");
                return;
            }
            this.showLoadingSpinner = true;
            this.showPopSpinner = true;
            this.fileReader = new FileReader();
            this.fileReader.onloadend = () => {
@@ -1586,13 +1689,15 @@
            base64Data: encodeURIComponent(this.fileContents),
        })
            .then((r) => {
                this.showPopSpinner = false;
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                this.showLoadingSpinner = false;
                this.closePop();
                this.showToast("Success", "上传成功");
                this.getFiles();
            })
            .catch((error) => {
                this.showPopSpinner = false;
                console.log("error = " + error.message);
                this.showToast("Error", "上传失败");
            });
@@ -1623,6 +1728,21 @@
    GoodsDeliveryJs() {
        this.isShowSpinner = true;
        //查询有哪些选择了的然后check
        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;
        }
        for (var i in this.data) {
            for (var j in selectedRows) {
                if (this.data[i].Id == selectedRows[j].Id) {
                    this.data[i]["check"] = true;
                }
            }
        }
        let cloneData = this.data;
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
@@ -1896,6 +2016,31 @@
        });
    }
    handleLoad() {
        console.log('handleLoad')
        try {
            const style = document.createElement('style');
            style.innerText = '.slds-button__icon {display: none;}';
            this.template.querySelector('.hideHelpText').appendChild(style);
        } catch (error) {
            console.log(error);
        }
    }
    handleLoad2() {
        console.log('handleLoad2')
        try {
            const style = document.createElement('style');
            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}';
            this.template.querySelector('.hideHelpText').appendChild(style2);
        } catch (error) {
            console.log(error);
        }
    }
    //编辑出库单
    EditConsumable() {
        let url = "/lexsummonscreat?ESetid=" + this.ESetid + "&KeyWords=Redirect";
@@ -1906,4 +2051,48 @@
            },
        });
    }
    //显示上传附件
    uploadOrder(event) {
        this.showAttPop = true;
    }
    //附件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);
        }
    }
    //是否显示附件移除
    get attDelBtn() {
        if (this.fileName != '' && this.fileName != null && this.fileName != '请选择一个文件上传') {
            return true;
        } else {
            return false;
        }
    }
    //关闭附件弹窗
    closePop() {
        this.showAttPop = false;
        this.filesUploaded = [];
        this.fileName = null;
    }
    //移除附件
    removeAtt() {
        this.filesUploaded = [];
        this.fileName = '';
    }
    ClearJs() {
        this.consumableName = '';
        this.Category3 = '';
        this.Category4 = '';
        this.Category5 = '';
        this.searchProductJs();
    }
}