binxie
2023-06-16 da42e2995c00293af89c71fe5ba6e16cbb77e1b3
force-app/main/default/lwc/lexConsumableAccount/lexConsumableAccount.js
@@ -14,34 +14,40 @@
        fieldName: "NameUrl",
        hideDefaultActions: true,
        wrapText: true,
        initialWidth: 345,
        initialWidth: 200,
        sortable: true,
        type: "url",
        typeAttributes: {
            label: {
                fieldName: "Name",
            },
            target:"_blank"
        },
    },
    // {
    //     label: "省",
    //     fieldName: "StateMasterUrl",
    //     hideDefaultActions: true,
    //     wrapText: true,
    //     sortable: true,
    //     type: "url",
    //     typeAttributes: {
    //         label: {
    //             fieldName: "StateMasterName",
    //         },
    //         target: "_blank",
    //     },
    // },
    {
        label: "省",
        fieldName: "StateMasterUrl",
        fieldName: "StateMasterName",
        hideDefaultActions: true,
        initialWidth: 80,
        wrapText: true,
        sortable: true,
        type: "url",
        typeAttributes: {
            label: {
                fieldName: "StateMasterName",
            },
            target: "_blank",
        },
    },
    {
        label: "销售本部医院",
        fieldName: "Salesdepartment_HP__c",
        initialWidth: 115,
        hideDefaultActions: true,
        sortable: true,
        wrapText: true,
@@ -59,7 +65,6 @@
            month: "numeric",
            year: "numeric",
        },
        initialWidth: 100,
    },
    {
        label: "有效/无效",
@@ -67,45 +72,49 @@
        hideDefaultActions: true,
        sortable: true,
        wrapText: true,
        initialWidth: 91,
    },
    {
        label: "客户记录类型",
        fieldName: "RecordTypeName",
        hideDefaultActions: true,
        sortable: true,
        wrapText: true,
        initialWidth: 130,
    },
    // {
    //     label: "客户记录类型",
    //     fieldName: "RecordTypeName",
    //     hideDefaultActions: true,
    //     sortable: true,
    //     wrapText: true,
    //     initialWidth: 130,
    // },
    {
        label: "政府等级",
        fieldName: "Grade__c",
        hideDefaultActions: true,
        sortable: true,
        wrapText: true,
        initialWidth: 86,
    },
    {
        label: "OCSM分类(医院)",
        fieldName: "OCM_Category__c",
        hideDefaultActions: true,
        sortable: true,
        wrapText: true,
        initialWidth: 150,
    },
    // {
    //     label: "OCSM分类(医院)",
    //     fieldName: "OCM_Category__c",
    //     hideDefaultActions: true,
    //     sortable: true,
    //     wrapText: true,
    // },
    // {
    //     label: "市",
    //     fieldName: "CityMasterNameUrl",
    //     hideDefaultActions: true,
    //     sortable: true,
    //     wrapText: true,
    //     type: "url",
    //     typeAttributes: {
    //         label: {
    //             fieldName: "CityMasterName",
    //         },
    //         target: "_blank",
    //     },
    // },
    {
        label: "市",
        fieldName: "CityMasterNameUrl",
        fieldName: "CityMasterName",
        hideDefaultActions: true,
        sortable: true,
        wrapText: true,
        type: "url",
        typeAttributes: {
            label: {
                fieldName: "CityMasterName",
            },
            target: "_blank",
        },
    },
    {
        label: "县/区",
@@ -126,28 +135,33 @@
const topColumns = [
    {
        label: "客户名",
        fieldName: "NameUrl",
        hideDefaultActions: true,
        fieldName : "accountName",
        wrapText: true,
        type: "url",
        type: "customShowAccountUrl",
        typeAttributes: {
            label: {
                fieldName: "Name",
            },
            accountName: { fieldName: "accountName" },
            accountUrl: { fieldName: "accountUrl" },
            isDisable: { fieldName: "isDisable" },
        },
    },
    // {
    //     label: "市",
    //     fieldName: "CityMasterName",
    //     hideDefaultActions: true,
    //     wrapText: true,
    //     type: "customShowAccountUrl",
    //     typeAttributes: {
    //         accountName: { fieldName: "CityMasterName" },
    //         accountUrl: { fieldName: "CityMasterNameUrl" },
    //         isDisable: { fieldName: "isDisable" },
    //     },
    // },
    {
        label: "市",
        fieldName: "CityMasterNameUrl",
        fieldName: "CityMasterName",
        hideDefaultActions: true,
        wrapText: true,
        type: "url",
        typeAttributes: {
            label: {
                fieldName: "CityMasterName",
            },
            target: "_blank",
        },
    },
    {
        label: "县/区",
@@ -179,7 +193,7 @@
export default class LexConsumableAccount extends LightningElement {
    columns = columns;
    topColumns = topColumns;
    @track isShowSpinner = true;
    @track isShowSpinner = false;
    @track pageRecords = [];
    @track accountId = "";
    @track agencyProType = "";
@@ -189,14 +203,14 @@
            label: "01. 医院_Hospital",
            value: "01. 医院_Hospital",
        },
        {
            label: "61. 医院_Hospital草案中的医院",
            value: "61. 医院_Hospital草案中的医院",
        },
        {
            label: "62. 医院_Hospital申请中的医院",
            value: "62. 医院_Hospital申请中的医院",
        },
        // {
        //     label: "61. 医院_Hospital草案中的医院",
        //     value: "61. 医院_Hospital草案中的医院",
        // },
        // {
        //     label: "62. 医院_Hospital申请中的医院",
        //     value: "62. 医院_Hospital申请中的医院",
        // },
        {
            label: "63. 医院_Hospital上周创建的医院",
            value: "63. 医院_Hospital上周创建的医院",
@@ -291,6 +305,7 @@
    }
    connectedCallback() {
        this.isShowSpinner = true;
        this.AccId = this.getQueryString("AccId");
        this.AccId = this.AccId == null ? "" : this.AccId;
        if (this.AccId != "") {
@@ -301,41 +316,29 @@
                r = JSON.parse(JSON.stringify(r));
                console.log("r = " + JSON.stringify(r));
                if (r.status == "Success") {
                    console.log('r.entity.obj = ' + JSON.stringify(r.entity.obj))
                    this.accountDataInfo.name = r.entity.obj.Name;
                    this.accountDataInfo.ownerName =
                        r.entity.obj.Owner == null ? "" : r.entity.obj.Owner.Name;
                    this.accountDataInfo.ownerName = r.entity.obj.Owner == null ? "" : r.entity.obj.Owner.Name;
                    this.accountDataInfo.site = r.entity.obj.site;
                    this.accountDataInfo.isActive = r.entity.obj.Is_Active__c;
                    this.accountDataInfo.aliasName2 = r.entity.obj.Alias_Name2__c;
                    this.accountDataInfo.banOnUseReason =
                        r.entity.obj.Ban_On_Use_Reason__c;
                    this.accountDataInfo.banOnUseReason = r.entity.obj.Ban_On_Use_Reason__c;
                    this.accountDataInfo.grade = r.entity.obj.Grade__c;
                    this.accountDataInfo.attributeType = r.entity.obj.Attribute_Type__c;
                    this.accountDataInfo.oCMCategory = r.entity.obj.OCM_Category__c;
                    this.accountDataInfo.specialityType =
                        r.entity.obj.Speciality_Type__c;
                    this.accountDataInfo.stateMasterName =
                        r.entity.obj.State_Master__r == null
                            ? ""
                            : r.entity.obj.State_Master__r.Name;
                    this.accountDataInfo.specialityType = r.entity.obj.Speciality_Type__c;
                    this.accountDataInfo.stateMasterName = r.entity.obj.State_Master__r == null ? "" : r.entity.obj.State_Master__r.Name;
                    this.accountDataInfo.phone = r.entity.obj.Phone;
                    this.accountDataInfo.cityMasterName =
                        r.entity.obj.City_Master__r == null
                            ? ""
                            : r.entity.obj.City_Master__r.Name;
                    this.accountDataInfo.cityMasterName = r.entity.obj.City_Master__r == null ? "" : r.entity.obj.City_Master__r.Name;
                    this.accountDataInfo.phoneCall = r.entity.obj.PhoneCall__c;
                    this.accountDataInfo.town = r.entity.obj.Town__c;
                    this.accountDataInfo.fax = r.entity.obj.Fax;
                    this.accountDataInfo.street = r.entity.obj.Street__c;
                    this.accountDataInfo.postalCode = r.entity.obj.Postal_Code__c;
                    this.accountDataInfo.address = r.entity.obj.Address__c;
                    this.accountDataInfo.parentName =
                        r.entity.obj.Parent == null ? "" : r.entity.obj.Parent.Name;
                    console.log(
                        "this.accountDataInfo = " + JSON.stringify(this.accountDataInfo)
                    );
                    this.printUrl =
                        "/lexconsumableaccountinfoprint?AccId=" + this.AccId;
                    this.accountDataInfo.parentName = r.entity.obj.Parent == null ? "" : r.entity.obj.Parent.Name;
                    console.log('this.accountDataInfo = ' + JSON.stringify(this.accountDataInfo))
                    this.printUrl = "/lexconsumableaccountinfoprint?AccId=" + this.AccId;
                    this.isShowAccountInfo = true;
                    this.isShowSpinner = false;
                } else {
@@ -372,7 +375,8 @@
                    this.agencyProTypestr = r.entity.agencyProTypestr;
                    console.log("this.agencyProTypestr = " + this.agencyProTypestr);
                    for (var i in this.pageRecords) {
                        this.pageRecords[i]["NameUrl"] = "/lexconsumableaccount?AccId=" + this.pageRecords[i].Id;
                        this.pageRecords[i]["Is_Active__c"] = this.pageRecords[i].Is_Active__c.replace('効','效');
                        this.pageRecords[i]["NameUrl"] = "/s/lexconsumableaccount?AccId=" + this.pageRecords[i].Id;
                        this.pageRecords[i]["StateMasterName"] = this.pageRecords[i].State_Master__r.Name;
                        this.pageRecords[i]["StateMasterUrl"] = "/" + this.pageRecords[i].State_Master__c;
                        this.pageRecords[i]["CityMasterName"] = this.pageRecords[i].City_Master__r.Name;
@@ -393,40 +397,50 @@
                    );
                    console.log('9/3 = ' + this.keepTwoDecimalStr(this.amend(9, 3, '/').toFixed(2)));
                    let total = 100;
                    for (var i in this.topAccountData) {
                        console.log('i = ' + i);
                        this.topAccountData[i]["NameUrl"] = "/lexconsumableaccount?AccId=" + this.topAccountData[i].Id;
                        this.topAccountData[i]["StateMasterName"] = this.topAccountData[i].State_Master__r.Name;
                        this.topAccountData[i]["StateMasterUrl"] = "/" + this.topAccountData[i].State_Master__c;
                        this.topAccountData[i]["CityMasterName"] = this.topAccountData[i].City_Master__r.Name;
                        this.topAccountData[i]["CityMasterNameUrl"] = "/" + this.topAccountData[i].City_Master__c;
                        this.topAccountData[i]["RecordTypeName"] = this.topAccountData[i].RecordType.Name;
                        this.topAccountData[i]["isShowButton"] = true;
                        let number = this.keepTwoDecimalStr((this.amend(this.topInfo.deList[i], this.topInfo.saleAmount, '/') * 100).toFixed(2));
                        total -= number;
                        this.topAccountData[i]["proportion"] = number + '%';
                    try {
                        for (var i in this.topAccountData) {
                            console.log('i = ' + i);
                            this.topAccountData[i]["accountName"] = this.topAccountData[i].Name;
                            this.topAccountData[i]["accountUrl"] = "/s/lexconsumableaccount?AccId=" + this.topAccountData[i].Id;
                            this.topAccountData[i]["isDisable"] = false;
                            this.topAccountData[i]["StateMasterName"] = this.topAccountData[i].State_Master__r.Name;
                            this.topAccountData[i]["StateMasterUrl"] = "/" + this.topAccountData[i].State_Master__c;
                            this.topAccountData[i]["CityMasterName"] = this.topAccountData[i].City_Master__r.Name;
                            this.topAccountData[i]["CityMasterNameUrl"] = "/" + this.topAccountData[i].City_Master__c;
                            this.topAccountData[i]["RecordTypeName"] = this.topAccountData[i].RecordType.Name;
                            this.topAccountData[i]["isShowButton"] = true;
                            let number = this.keepTwoDecimalStr((this.amend(this.topInfo.deList[i], this.topInfo.saleAmount, '/') * 100).toFixed(2));
                            total -= number;
                            this.topAccountData[i]["proportion"] = number + '%';
                        }
                        console.log('this.topAccountData = ' + JSON.stringify(this.topAccountData));
                        //其他
                        if (total != 100) {
                            this.topAccountData.push({
                                accountName: '...',
                                accountUrl: '/s/lexconsumableaccount',
                                isDisable: true,
                                proportion: total.toFixed(2) + '%',
                                CityMasterName: '...',
                                CityMasterNameUrl: '/lexconsumableaccount',
                                Town__c: '...',
                                isShowButton: false
                            })
                        } else {
                            let title = '';
                            for (var key in this.fiscalYearOptions) {
                                if (this.fiscalYearOption == this.fiscalYearOptions[key].value)
                                    title = this.fiscalYearOptions[key].label;
                            }
                            this.showMyToast(title, '无数据', 'Error');
                        }
                        this.isShowSpinner = false;
                    } catch (error) {
                        console.log('error = ' + error.message)
                    }
                    // //其他
                    if (total != 100) {
                        this.topAccountData.push({
                            Name: '...',
                            NameUrl: '/lexconsumableaccount',
                            proportion: total.toFixed(2) + '%',
                            CityMasterName: '...',
                            CityMasterNameUrl: '/lexconsumableaccount',
                            Town__c: '...',
                            isShowButton: false
                        })
                    } else {
                        let title = '';
                        for (var key in this.fiscalYearOptions) {
                            if (this.fiscalYearOption == this.fiscalYearOptions[key].value)
                                title = this.fiscalYearOptions[key].label;
                        }
                        this.showMyToast(title, '无数据', 'Error');
                    }
                    this.isShowSpinner = false;
                } else {
                    console.log("r = " + JSON.stringify(r));
                    this.showMyToast('Error', r.msg, 'Error');
@@ -525,7 +539,9 @@
                let total = 100;
                for (var i in this.topAccountData) {
                    console.log('i = ' + i);
                    this.topAccountData[i]["NameUrl"] = "/lexconsumableaccount?AccId=" + this.topAccountData[i].Id;
                    this.topAccountData[i]["accountName"] = this.topAccountData[i].Name;
                    this.topAccountData[i]["accountUrl"] = "/s/lexconsumableaccount?AccId=" + this.topAccountData[i].Id;
                    this.topAccountData[i]["isDisable"] = false;
                    this.topAccountData[i]["StateMasterName"] = this.topAccountData[i].State_Master__r.Name;
                    this.topAccountData[i]["StateMasterUrl"] = "/" + this.topAccountData[i].State_Master__c;
                    this.topAccountData[i]["CityMasterName"] = this.topAccountData[i].City_Master__r.Name;
@@ -540,8 +556,9 @@
                // //其他
                if (total != 100) {
                    this.topAccountData.push({
                        Name: '...',
                        NameUrl: '/lexconsumableaccount',
                        accountName: '...',
                        accountUrl: '/s/lexconsumableaccount',
                        isDisable: true,
                        proportion: total.toFixed(2) + '%',
                        CityMasterName: '...',
                        CityMasterNameUrl: '/lexconsumableaccount',
@@ -597,18 +614,13 @@
                    this.pageRecords = r.entity.pageRecords;
                    console.log("this.pageRecords = " + JSON.stringify(this.pageRecords));
                    for (var i in this.pageRecords) {
                        this.pageRecords[i]["NameUrl"] =
                            "/lexconsumableaccount?AccId=" + this.pageRecords[i].Id;
                        this.pageRecords[i]["StateMasterName"] =
                            this.pageRecords[i].State_Master__r.Name;
                        this.pageRecords[i]["StateMasterUrl"] =
                            "/" + this.pageRecords[i].State_Master__c;
                        this.pageRecords[i]["CityMasterName"] =
                            this.pageRecords[i].City_Master__r.Name;
                        this.pageRecords[i]["CityMasterNameUrl"] =
                            "/" + this.pageRecords[i].City_Master__c;
                        this.pageRecords[i]["RecordTypeName"] =
                            this.pageRecords[i].RecordType.Name;
                        this.pageRecords[i]["Is_Active__c"] = this.pageRecords[i].Is_Active__c.replace('効','效');
                        this.pageRecords[i]["NameUrl"] = "/s/lexconsumableaccount?AccId=" + this.pageRecords[i].Id;
                        this.pageRecords[i]["StateMasterName"] = this.pageRecords[i].State_Master__r.Name;
                        this.pageRecords[i]["StateMasterUrl"] = "/" + this.pageRecords[i].State_Master__c;
                        this.pageRecords[i]["CityMasterName"] = this.pageRecords[i].City_Master__r.Name;
                        this.pageRecords[i]["CityMasterNameUrl"] = "/" + this.pageRecords[i].City_Master__c;
                        this.pageRecords[i]["RecordTypeName"] = this.pageRecords[i].RecordType.Name;
                    }
                    this.isShowSpinner = false;
                } else {