binxie
2023-06-16 da42e2995c00293af89c71fe5ba6e16cbb77e1b3
force-app/main/default/lwc/lexSummonsCreat/lexSummonsCreat.js
@@ -19,7 +19,7 @@
import { getObjectInfo } from "lightning/uiObjectInfoApi";
import hospitalInit from "@salesforce/apex/lexSearchAgencyHospitalController.init";
import serContact from "@salesforce/apex/lexSearchAgencyHospitalController.serContact";
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";
@@ -87,7 +87,7 @@
            label: "注册证编码号",
            fieldName: "approbation_No",
            wrapText: true,
            initialWidth: 115,
            initialWidth: 130,
            hideDefaultActions: true,
        },
        {
@@ -130,7 +130,7 @@
                unitValue: { fieldName: "unitValue" },
                unitOptions: { fieldName: "unitOptions" },
                recordId: { fieldName: "Id" },
            },
            }
        },
        {
            label: "出货数量",
@@ -207,6 +207,7 @@
            label: "注册证编码号",
            fieldName: "approbation_No",
            hideDefaultActions: true,
            initialWidth: 130,
            wrapText: true,
        },
        {
@@ -270,9 +271,20 @@
    @track hospitalList = [];
    @track hospitalColumns = [
        {
            label: "",
            fieldName: "Id1",
            type: "button",
            hideDefaultActions: true,
            initialWidth: 90,
            typeAttributes: {
                label: "选择",
                name: "Id2",
                size: 1,
            },
        },
        {
            label: "医院名称",
            fieldName: "Name",
            initialWidth: 400,
            hideDefaultActions: true,
            wrapText: true,
        },
@@ -280,18 +292,7 @@
            label: "省份",
            fieldName: "stateMasterName",
            hideDefaultActions: true,
        },
        {
            label: "选择",
            fieldName: "Id1",
            type: "button",
            hideDefaultActions: true,
            typeAttributes: {
                label: "选择",
                name: "Id2",
                size: 1,
            },
        },
        }
    ];
    @track accountid = "";
@@ -312,6 +313,7 @@
            label: "消耗品名称",
            fieldName: "ProdName",
            hideDefaultActions: true,
            wrapText: true,
        },
        {
            label: "批次号",
@@ -337,6 +339,7 @@
            label: "消耗品订单",
            fieldName: "ConsumableorderminorUrl",
            hideDefaultActions: true,
            initialWidth: 210,
            type: "url",
            typeAttributes: {
                label: { fieldName: "Consumable_order_minor__c" },
@@ -404,6 +407,7 @@
            fieldName: "ConsumableorderminorUrl",
            hideDefaultActions: true,
            type: "url",
            initialWidth: 210,
            typeAttributes: {
                label: { fieldName: "Consumable_order_minor__c" },
                target: "_blank",
@@ -434,6 +438,7 @@
            label: "BarCode",
            fieldName: "Bar_Code__c",
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 400
        },
        {
@@ -607,6 +612,7 @@
    @track recordEnd = 0;
    //end
    @track SearchDone = '';
    @track hideCheckboxColumn = false;
    stylesLoaded = false;
    renderedCallback() {
@@ -652,8 +658,12 @@
        //statusEdit
        this.statusEdit = this.getQueryString("KeyWords");
        this.statusEdit = this.statusEdit == null ? "" : this.statusEdit;
        //arriveorder
        this.arriveorder = this.getQueryString("arriveorder");
        this.arriveorder = this.arriveorder == null ? "" : this.arriveorder;
        console.log("this.ESetid = " + this.ESetid);
        console.log("this.statusEdit = " + this.statusEdit);
        console.log("this.arriveorder = " + this.arriveorder);
        if (this.ESetid == "") {
            this.isShowInformation = false;
        }
@@ -662,7 +672,8 @@
            ESetidJs: this.ESetid,
            statusEdit: this.statusEdit,
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
            pageTokenLWC: this.currentPageToken,
            arriveorderLWC: this.arriveorder
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
@@ -830,7 +841,7 @@
                this.Existarrive = r.entity.Existarrive;
                console.log("this.EditAble = " + this.EditAble);
                //disable
                if (Object.values(r.entity.coc).length > 0) {
@@ -870,7 +881,7 @@
                    ) {
                        this.isPraseToPDFDisabled = false;
                    }
                    if ((coc.Billed_Status__c != "还没开票" || coc.SummonsStatus_c__c == "已完成") && this.agencyProType != 'ET') {
                    if ((coc.Billed_Status__c != "还没开票" || coc.SummonsStatus_c__c == "已完成")) {
                        this.isOpenReportDisabled = false;
                    }
                    if (
@@ -986,6 +997,7 @@
                            this.secondaryDistributor = "";
                            this.ForDealerText = "";
                            this.accountValue = "";
                            this.cocLwc['Order_ForDealerText__c'] = '';
                            this.isDisabledForDealerText = true;
                            this.isDisabledSecondaryDistributor = true;
                            break;
@@ -1055,6 +1067,28 @@
                );
                this.HospitalName = r.entity.HospitalName;
                this.sumPrice = r.entity.sumPrice.toFixed(2) + "元";
                debugger
                console.log('this.Existarrive = ' + this.Existarrive);
                console.log('this.EditAble = ' + this.EditAble);
                console.log('r.entity.coc.SummonsStatus_c__c = ' + r.entity.coc.SummonsStatus_c__c);
                if (!this.Existarrive && this.EditAble && r.entity.coc.SummonsStatus_c__c != '价格未定') {
                    this.hideCheckboxColumn = false;
                } else {
                    this.hideCheckboxColumn = true;
                }
                if (!(this.arriveorder == '' && this.Existarrive == false && this.EditAble && this.cocLwc.SummonsStatus_c__c != '价格未定')) {
                    //让单位,出货数量 变为不可选的text类型
                    for (var i in this.columns) {
                        if (this.columns[i].label == '单位') {
                            this.columns[i].type = 'text';
                            this.columns[i].fieldName = 'unitValue';
                        }
                        if (this.columns[i].label == '出货数量') {
                            this.columns[i].type = 'text';
                            this.columns[i].fieldName = 'shipmentNumber';
                        }
                    }
                }
                this.isShowSpinner = false;
                this.showTable = true;
                console.log("ESetid = " + this.ESetid);
@@ -1079,6 +1113,7 @@
                this.isDisabledForCustomerText = false;
                this.secondaryDistributor = "";
                this.ForDealerText = "";
                this.cocLwc['Order_ForDealerText__c'] = '';
                this.isDisabledForDealerText = true;
                this.isDisabledSecondaryDistributor = true;
                this.isMutualTransferGoods = false;
@@ -1296,7 +1331,7 @@
            }
        }
        let cloneData = this.data;
        let cloneData = this.deepClone(this.data);
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
@@ -1340,6 +1375,8 @@
                this.totalPages = Math.ceil(r.entity.paginatedAccounts.totalRecords / this.pageSize);
                console.log('this.totalPages = ' + this.totalPages);
                this.hasHosPro = r.entity.hasHosPro;
                console.log("this.hasHosPro = " + this.hasHosPro);
                this.SearchDone = r.entity.SearchDone;
                let tempData = [];
@@ -1371,13 +1408,17 @@
                    tempData[i]["shipmentNumber"] = tempData[i].orderdetails1["Shipment_Count__c"];
                    tempData[i]["shippingUnitPrice"] = tempData[i].orderdetails1["Delivery_List_RMB__c"];
                    tempData[i]["Id"] = 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';
                    if (this.hasHosPro) {
                        if (tempData[i]["hospitalSpecialOffer"]) {
                            tempData[i]["Id"] = tempData[i].Prod.Id + 'ishos';
                        } else {
                            tempData[i]["Id"] = tempData[i].Prod.Id + 'nothos';
                        }
                    }
                    tempData[i]["recordId"] = tempData[i]["Id"];
                    tempData[i]["Name__c"] = tempData[i].Prod.Name__c;
                    tempData[i]["SFDA_Status__c"] = tempData[i].Prod.SFDA_Status__c;
@@ -1402,6 +1443,23 @@
                }
                this.data = tempData;
                //如果hasHosPro = true 医院特价
                console.log('this.hasHosPro = ' + this.hasHosPro);
                if (this.hasHosPro) {
                    let object1 = {
                        label: "医院特价",
                        fieldName: "hospitalSpecialOffer",
                        type: 'boolean',
                        initialWidth: 100,
                        hideDefaultActions: true,
                    };
                    this.columns.push(object1);
                    this.editColumns.push(object1);
                }
                this.columns = [...this.columns];
                this.editColumns = [...this.editColumns];
                console.log("this.columns = " + JSON.stringify(this.columns));
                console.log("this.data = " + JSON.stringify(this.data));
                console.log(" this.selectedRows = " + JSON.stringify(this.selectedRows));
                //this.showTable = true;
@@ -1517,9 +1575,7 @@
            if (this.data[i].Id == numberDetail.data.recordId) {
                index = i;
                this.data[i].shipmentNumber = Number(numberDetail.data.shipmentnumber);
                this.data[i].orderdetails1["Shipment_Count__c"] = Number(
                    numberDetail.data.shipmentnumber
                );
                this.data[i].orderdetails1["Shipment_Count__c"] = Number(numberDetail.data.shipmentnumber);
                console.log('this.data[i].orderdetails1["Shipment_Count__c"] = ' + this.data[i].orderdetails1["Shipment_Count__c"]);
                console.log('this.selectedRows.indexOf(this.data[i].Id) = ' + this.selectedRows.indexOf(this.data[i].Id));
                if (this.data[i].orderdetails1["Shipment_Count__c"] != '') {
@@ -1537,6 +1593,7 @@
                console.log('this.selectedRows = ' + JSON.stringify(this.selectedRows));
            }
        }
        this.data = [...this.data];
        this.ComputePrice(
            index,
            this.data[index].shipmentNumber,
@@ -1681,6 +1738,10 @@
        }
    }
    deepClone(obj) {
        return JSON.parse(JSON.stringify(obj));
    }
    saveConfirm() {
        this.isShowSpinner = true;
@@ -1698,13 +1759,14 @@
            }
        }
        let cloneData = this.data;
        let cloneData = this.deepClone(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]["shippingUnitPrice"] = cloneData[i]["shippingUnitPrice"] == '' ? 0 : cloneData[i]["shippingUnitPrice"];
            delete cloneData[i].Name__c;
            delete cloneData[i].Category3__c;
            delete cloneData[i].Category4__c;
@@ -1779,17 +1841,20 @@
        console.log("openReportJs");
        var reportId = this.ESetid;
        reportId = reportId.substring(0, 15);
        console.log("reportId = " + reportId);
        let reportFilters = '[{"operator":"equals","value":"' + reportId + '","column":"FK_CUSTENT_ID"}]';
        let reportUrl = this.label.ConsumableOutboundReportId;
        console.log("reportUrl = " + reportUrl);
        let url = "/report/" + reportUrl + "?reportFilters=" + encodeURIComponent(reportFilters);
        let url = "/s/report/" + reportUrl + "?reportFilters=" + encodeURIComponent(reportFilters);
        console.log("url = " + url);
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            attributes: {
                url: url,
            },
        });
        window.open(url);
        // this[NavigationMixin.Navigate]({
        //     type: "standard__webPage",
        //     attributes: {
        //         url: url,
        //         target: '_blank'
        //     },
        // });
    }
    vpClear2Delay(event) {
@@ -1872,17 +1937,17 @@
            fileName: this.fileName,
            base64Data: encodeURIComponent(this.fileContents),
        }).then((r) => {
                this.showPopSpinner = false;
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                this.closePop();
                this.showMyToast('成功', '上传成功', 'Success');
                this.getFiles();
            }).catch((error) => {
                this.showPopSpinner = false;
                console.log("error = " + error.message);
                this.showMyToast('失败', '上传失败', 'Error');
            });
            this.showPopSpinner = false;
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            this.closePop();
            this.showMyToast('上传成功', '', 'Success');
            this.getFiles();
        }).catch((error) => {
            this.showPopSpinner = false;
            console.log("error = " + error.message);
            this.showMyToast('失败', '上传失败', 'Error');
        });
    }
    getFiles() {
@@ -1891,24 +1956,24 @@
        getFiles({
            recordId: this.ESetid,
        }).then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                this.fileData = r.entity.cvList;
                console.log("this.fileData = " + JSON.stringify(this.fileData));
                for (var i in this.fileData) {
                    this.fileData[i]["Id"] = this.fileData[i].Id;
                    this.fileData[i]["recordId"] = this.fileData[i].Id;
                    this.fileData[i]["url"] = "/" + this.fileData[i].Id;
                    this.fileData[i]["Title"] = this.fileData[i].Title;
                    this.fileData[i]["attUrl"] = '/' + this.fileData[i].Id;
                    this.fileData[i]['downloadUrl'] = '/sfc/servlet.shepherd/document/download/' + this.fileData[i].ContentDocumentId + '?operationContext=S1';
                }
                console.log("this.fileData = " + this.fileData);
                this.showLoadingSpinner = false;
            }).catch((error) => {
                console.log("error = " + error.message);
                this.showMyToast('失败', '获取附件失败', 'Error');
            });
            r = JSON.parse(JSON.stringify(r));
            console.log("r = " + JSON.stringify(r));
            this.fileData = r.entity.cvList;
            console.log("this.fileData = " + JSON.stringify(this.fileData));
            for (var i in this.fileData) {
                this.fileData[i]["Id"] = this.fileData[i].Id;
                this.fileData[i]["recordId"] = this.fileData[i].Id;
                this.fileData[i]["url"] = "/" + this.fileData[i].Id;
                this.fileData[i]["Title"] = this.fileData[i].Title;
                this.fileData[i]["attUrl"] = '/' + this.fileData[i].Id;
                this.fileData[i]['downloadUrl'] = '/sfc/servlet.shepherd/document/download/' + this.fileData[i].ContentDocumentId + '?operationContext=S1';
            }
            console.log("this.fileData = " + this.fileData);
            this.showLoadingSpinner = false;
        }).catch((error) => {
            console.log("error = " + error.message);
            this.showMyToast('失败', '获取附件失败', 'Error');
        });
    }
    GoodsDeliveryJs() {
@@ -1928,7 +1993,7 @@
            }
        }
        let cloneData = this.data;
        let cloneData = this.deepClone(this.data);
        for (var i in cloneData) {
            cloneData[i]["Name"] = cloneData[i].Name__c;
            cloneData[i]["Category3"] = cloneData[i].Category3__c;
@@ -1971,29 +2036,29 @@
        GoodsDeliveryInit({
            ESetId: this.ESetid,
        }).then((r) => {
                r = JSON.parse(JSON.stringify(r));
                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;
                    console.log('this.salesOrderdetails = ' + JSON.stringify(this.salesOrderdetails))
                    this.salesData = r.entity.consumableorderdetailsRecords;
                    this.salesErrorData = r.entity.consumableorderdetailsRecordserror;
                    this.salesOrderpieceorboxMap = r.entity.orderpieceorboxMap;
                    this.salesOrderpriceMap = r.entity.orderpriceMap;
                    this.salesOrderagencypriceMap = r.entity.orderagencypriceMap;
                    this.isShowSpinner = false;
                } else {
                    console.log("r.msg = " + r.msg);
                    this.showMyToast('初始化失败', r.msg, 'Error');
                }
            }).catch((error) => {
                console.log("error = " + error.message);
                this.showMyToast('错误', '初始化失败', 'Error');
            });
            r = JSON.parse(JSON.stringify(r));
            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;
                console.log('this.salesOrderdetails = ' + JSON.stringify(this.salesOrderdetails))
                this.salesData = r.entity.consumableorderdetailsRecords;
                this.salesErrorData = r.entity.consumableorderdetailsRecordserror;
                this.salesOrderpieceorboxMap = r.entity.orderpieceorboxMap;
                this.salesOrderpriceMap = r.entity.orderpriceMap;
                this.salesOrderagencypriceMap = r.entity.orderagencypriceMap;
                this.isShowSpinner = false;
            } else {
                console.log("r.msg = " + r.msg);
                this.showMyToast('初始化失败', r.msg, 'Error');
            }
        }).catch((error) => {
            console.log("error = " + error.message);
            this.showMyToast('错误', '初始化失败', 'Error');
        });
    }
    SalesearchProductJs() {
@@ -2178,16 +2243,18 @@
        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 = "/s/lexconinvoiceview?deliveryId=" + this.ESetid + "&invoiceId=" + this.invoiceId + "&KeyWords=Redirect";
        } else {
            url = "/lexconinvoiceview?deliveryId=" + this.ESetid + "&KeyWords=Redirect";
            url = "/s/lexconinvoiceview?deliveryId=" + this.ESetid + "&KeyWords=Redirect";
        }
        this[NavigationMixin.Navigate]({
            type: "standard__webPage",
            attributes: {
                url: url,
            },
        });
        window.open(url);
        // this[NavigationMixin.Navigate]({
        //     type: "standard__webPage",
        //     attributes: {
        //         url: url,
        //         target:'_blank'
        //     },
        // });
    }
    //删除
@@ -2468,23 +2535,22 @@
    //删除附件
    deleteAtt(event) {
        this.showLoadingSpinner = true;
        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');
        deleteAtt({
            contentVersionId: recordId
        }).then(r => {
            r = JSON.parse(JSON.stringify(r));
            if (r.status == "Success") {
                this.showMyToast('删除成功', '', 'Success');
                this.getFiles();
            } else {
                this.showMyToast('删除失败', result.errorMsg, 'Error');
                this.showMyToast('删除失败', r.msg, 'Error');
            }
        }).catch(error => {
            this.showMyToast('错误', '删除失败', 'Error');
            this.showMyToast('错误', error.message, 'Error');
        })
    }
}