From 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 14 七月 2023 14:56:14 +0800
Subject: [PATCH] lex community

---
 force-app/main/default/lwc/lexConsumableAccount/lexConsumableAccount.js |  959 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 554 insertions(+), 405 deletions(-)

diff --git a/force-app/main/default/lwc/lexConsumableAccount/lexConsumableAccount.js b/force-app/main/default/lwc/lexConsumableAccount/lexConsumableAccount.js
index 8687cd2..270892f 100644
--- a/force-app/main/default/lwc/lexConsumableAccount/lexConsumableAccount.js
+++ b/force-app/main/default/lwc/lexConsumableAccount/lexConsumableAccount.js
@@ -1,220 +1,234 @@
-import { LightningElement, wire, api, track } from "lwc";
-import { ShowToastEvent } from "lightning/platformShowToastEvent";
-import init from "@salesforce/apex/LexConsumableAccountController.init";
-import changeFiscalYearView from "@salesforce/apex/LexConsumableAccountController.changeFiscalYearView";
-import changelistView from "@salesforce/apex/LexConsumableAccountController.changelistView";
-import accountInit from "@salesforce/apex/LexConsumableAccountInfoController.init";
+import { LightningElement, wire, api, track } from 'lwc';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import init from '@salesforce/apex/LexConsumableAccountController.init';
+import changeFiscalYearView from '@salesforce/apex/LexConsumableAccountController.changeFiscalYearView';
+import changelistView from '@salesforce/apex/LexConsumableAccountController.changelistView';
+import accountInit from '@salesforce/apex/LexConsumableAccountInfoController.init';
 //table css
-import { loadStyle } from "lightning/platformResourceLoader";
-import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
+import { loadStyle } from 'lightning/platformResourceLoader';
+import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable';
 
 const columns = [
     {
-        label: "瀹㈡埛鍚�",
-        fieldName: "NameUrl",
+        label: '瀹㈡埛鍚�',
+        fieldName: 'NameUrl',
         hideDefaultActions: true,
         wrapText: true,
-        initialWidth: 345,
+        initialWidth: 200,
         sortable: true,
-        type: "url",
+        type: 'url',
         typeAttributes: {
             label: {
-                fieldName: "Name",
+                fieldName: 'Name'
             },
-        },
+            target: '_blank'
+        }
+    },
+    // {
+    //     label: "鐪�",
+    //     fieldName: "StateMasterUrl",
+    //     hideDefaultActions: true,
+    //     wrapText: true,
+    //     sortable: true,
+    //     type: "url",
+    //     typeAttributes: {
+    //         label: {
+    //             fieldName: "StateMasterName",
+    //         },
+    //         target: "_blank",
+    //     },
+    // },
+    {
+        label: '鐪�',
+        fieldName: 'StateMasterName',
+        hideDefaultActions: true,
+        wrapText: true,
+        sortable: true
     },
     {
-        label: "鐪�",
-        fieldName: "StateMasterUrl",
+        label: '閿�鍞湰閮ㄥ尰闄�',
+        fieldName: 'Salesdepartment_HP__c',
         hideDefaultActions: true,
-        initialWidth: 80,
-        wrapText: true,
         sortable: true,
-        type: "url",
+        wrapText: true
+    },
+    {
+        label: '鍒涘缓鏃ユ湡',
+        fieldName: 'CreatedDate',
+        hideDefaultActions: true,
+        sortable: true,
+        wrapText: true,
+        type: 'date',
         typeAttributes: {
-            label: {
-                fieldName: "StateMasterName",
-            },
-            target: "_blank",
-        },
+            timeZone: 'Asia/Shanghai',
+            day: 'numeric',
+            month: 'numeric',
+            year: 'numeric'
+        }
     },
     {
-        label: "閿�鍞湰閮ㄥ尰闄�",
-        fieldName: "Salesdepartment_HP__c",
-        initialWidth: 115,
+        label: '鏈夋晥/鏃犳晥',
+        fieldName: 'Is_Active__c',
         hideDefaultActions: true,
         sortable: true,
-        wrapText: true,
+        wrapText: true
+    },
+    // {
+    //     label: "瀹㈡埛璁板綍绫诲瀷",
+    //     fieldName: "RecordTypeName",
+    //     hideDefaultActions: true,
+    //     sortable: true,
+    //     wrapText: true,
+    //     initialWidth: 130,
+    // },
+    {
+        label: '鏀垮簻绛夌骇',
+        fieldName: 'Grade__c',
+        hideDefaultActions: true,
+        sortable: true,
+        wrapText: true
+    },
+    // {
+    //     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: 'CityMasterName',
+        hideDefaultActions: true,
+        sortable: true,
+        wrapText: true
     },
     {
-        label: "鍒涘缓鏃ユ湡",
-        fieldName: "CreatedDate",
+        label: '鍘�/鍖�',
+        fieldName: 'Town__c',
         hideDefaultActions: true,
         sortable: true,
-        wrapText: true,
-        type: "date",
-        typeAttributes: {
-            timeZone: "Asia/Shanghai",
-            day: "numeric",
-            month: "numeric",
-            year: "numeric",
-        },
-        initialWidth: 100,
+        wrapText: true
     },
     {
-        label: "鏈夋晥/鏃犳晥",
-        fieldName: "Is_Active__c",
+        label: '瀹㈡埛鐢佃瘽',
+        fieldName: 'Phone',
         hideDefaultActions: true,
         sortable: true,
-        wrapText: true,
-        initialWidth: 91,
-    },
-    {
-        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: "甯�",
-        fieldName: "CityMasterNameUrl",
-        hideDefaultActions: true,
-        sortable: true,
-        wrapText: true,
-        type: "url",
-        typeAttributes: {
-            label: {
-                fieldName: "CityMasterName",
-            },
-            target: "_blank",
-        },
-    },
-    {
-        label: "鍘�/鍖�",
-        fieldName: "Town__c",
-        hideDefaultActions: true,
-        sortable: true,
-        wrapText: true,
-    },
-    {
-        label: "瀹㈡埛鐢佃瘽",
-        fieldName: "Phone",
-        hideDefaultActions: true,
-        sortable: true,
-        wrapText: true,
-    },
+        wrapText: true
+    }
 ];
 
 const topColumns = [
     {
-        label: "瀹㈡埛鍚�",
-        fieldName: "NameUrl",
+        label: '瀹㈡埛鍚�',
         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",
+        label: '甯�',
+        fieldName: 'CityMasterName',
         hideDefaultActions: true,
-        wrapText: true,
-        type: "url",
-        typeAttributes: {
-            label: {
-                fieldName: "CityMasterName",
-            },
-            target: "_blank",
-        },
+        wrapText: true
     },
     {
-        label: "鍘�/鍖�",
-        fieldName: "Town__c",
+        label: '鍘�/鍖�',
+        fieldName: 'Town__c',
         hideDefaultActions: true,
-        wrapText: true,
+        wrapText: true
     },
     {
-        label: "閿�閲忓崰姣�",
-        fieldName: "proportion",
+        label: '閿�閲忓崰姣�',
+        fieldName: 'proportion',
         hideDefaultActions: true,
         wrapText: true,
         initialWidth: 100,
-        cellAttributes: { alignment: "right" },
+        cellAttributes: { alignment: 'right' }
     },
     {
-        label: "鎿嶄綔",
-        fieldName: "Town__c",
+        label: '鎿嶄綔',
+        fieldName: 'Town__c',
         type: 'weeklyReport',
         initialWidth: 150,
         typeAttributes: {
-            recordId: { fieldName: "Id" },
-            hospitalName: { fieldName: "Name" },
-            isShowButton: { fieldName: "isShowButton" },
+            recordId: { fieldName: 'Id' },
+            hospitalName: { fieldName: 'Name' },
+            isShowButton: { fieldName: 'isShowButton' }
         },
-        hideDefaultActions: true,
+        hideDefaultActions: true
     }
 ];
 export default class LexConsumableAccount extends LightningElement {
     columns = columns;
     topColumns = topColumns;
-    @track isShowSpinner = true;
+    @track isShowSpinner = false;
     @track pageRecords = [];
-    @track accountId = "";
-    @track agencyProType = "";
-    @track agencyProTypestr = "";
+    @track accountId = '';
+    @track agencyProType = '';
+    @track agencyProTypestr = '';
     @track listViewOptions = [
         {
-            label: "01. 鍖婚櫌_Hospital",
-            value: "01. 鍖婚櫌_Hospital",
+            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涓婂懆鍒涘缓鐨勫尰闄�",
-        },
+            label: '63. 鍖婚櫌_Hospital涓婂懆鍒涘缓鐨勫尰闄�',
+            value: '63. 鍖婚櫌_Hospital涓婂懆鍒涘缓鐨勫尰闄�'
+        }
     ];
-    @track viewOption = "01. 鍖婚櫌_Hospital";
+    @track viewOption = '01. 鍖婚櫌_Hospital';
 
     @track isShowAccountInfo = false;
     @track topAccountData = [];
 
     //鍓嶇鎺掑簭
-    defaultSortDirection = "asc";
-    sortDirection = "asc";
+    defaultSortDirection = 'asc';
+    sortDirection = 'asc';
     sortedBy;
 
     //鍒嗛〉start
-    @track sortBy = "";
-    @track pageSize = 10;
+    @track sortBy = '';
+    @track pageSize = 200;
     error;
     records;
     currentPageToken = 0;
@@ -224,36 +238,35 @@
     @track pageNumber = 1;
     @track paginationVisibility = false;
     @track totalPages = 1;
-    pageSizeOptions = [10, 25, 50, 100];
+    pageSizeOptions = [100, 200, 300];
     @track recordStart = 0;
     @track recordEnd = 0;
     //end
 
-    @track AccId = "";
-    @track printUrl = "";
+    @track AccId = '';
+    @track printUrl = '';
     @track accountDataInfo = {
-        name: "",
-        ownerName: "",
-        site: "",
-        isActive: "",
-        aliasName2: "",
-        banOnUseReason: "",
-        grade: "",
-        attributeType: "",
-        oCMCategory: "",
-        specialityType: "",
-        stateMasterName: "",
-        phone: "",
-        cityMasterName: "",
-        phoneCall: "",
-        town: "",
-        fax: "",
-        street: "",
-        postalCode: "",
-        address: "",
-        parentName: "",
+        name: '',
+        ownerName: '',
+        site: '',
+        isActive: '',
+        aliasName2: '',
+        banOnUseReason: '',
+        grade: '',
+        attributeType: '',
+        oCMCategory: '',
+        specialityType: '',
+        stateMasterName: '',
+        phone: '',
+        cityMasterName: '',
+        phoneCall: '',
+        town: '',
+        fax: '',
+        street: '',
+        postalCode: '',
+        address: '',
+        parentName: ''
     };
-
 
     stylesLoaded = false;
 
@@ -261,7 +274,7 @@
     @track fiscalYearOptions = [
         { label: '鏈储骞�', value: 'thisYear' },
         { label: '涓婁竴璐㈠勾', value: 'lastYear' },
-        { label: '涓婁竴璐㈠勾+鏈储骞�', value: 'allYear' },
+        { label: '涓婁竴璐㈠勾+鏈储骞�', value: 'allYear' }
     ];
     @track fiscalYearOption = 'thisYear';
     @track topInfo = [];
@@ -270,19 +283,19 @@
         if (!this.stylesLoaded) {
             Promise.all([loadStyle(this, WrappedHeaderTable)])
                 .then(() => {
-                    console.log("Custom styles loaded");
+                    console.log('Custom styles loaded');
                     this.stylesLoaded = true;
                 })
                 .catch((error) => {
-                    console.error("Error loading custom styles");
+                    console.error('Error loading custom styles');
                 });
         }
     }
 
     //鑾峰彇閾炬帴鍙傛暟
     getQueryString(name) {
-        console.log("getQueryString name " + name);
-        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+        console.log('getQueryString name ' + name);
+        let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
         let r = window.location.search.substr(1).match(reg);
         if (r != null) {
             return decodeURIComponent(r[2]);
@@ -291,154 +304,247 @@
     }
 
     connectedCallback() {
-        this.AccId = this.getQueryString("AccId");
-        this.AccId = this.AccId == null ? "" : this.AccId;
-        if (this.AccId != "") {
-            console.log("this.AccId = " + this.AccId);
+        this.isShowSpinner = true;
+        this.AccId = this.getQueryString('AccId');
+        this.AccId = this.AccId == null ? '' : this.AccId;
+        if (this.AccId != '') {
+            console.log('this.AccId = ' + this.AccId);
             accountInit({
-                accId: this.AccId,
-            }).then((r) => {
-                r = JSON.parse(JSON.stringify(r));
-                console.log("r = " + JSON.stringify(r));
-                if (r.status == "Success") {
-                    this.accountDataInfo.name = r.entity.obj.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.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.phone = r.entity.obj.Phone;
-                    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.isShowAccountInfo = true;
-                    this.isShowSpinner = false;
-                } else {
-                    console.log("r = " + JSON.stringify(r));
-                    this.showMyToast('Error', r.msg, 'Error');
-                }
-            }).catch((error) => {
-                console.log("error = " + JSON.stringify(error));
-                this.showMyToast('Error', '鍒濆鍖栧け璐�', 'Error');
-            });
+                accId: this.AccId
+            })
+                .then((r) => {
+                    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.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.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.phone = r.entity.obj.Phone;
+                        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.isShowAccountInfo = true;
+                        this.isShowSpinner = false;
+                    } else {
+                        console.log('r = ' + JSON.stringify(r));
+                        this.showMyToast('Error', r.msg, 'Error');
+                    }
+                })
+                .catch((error) => {
+                    console.log('error = ' + JSON.stringify(error));
+                    this.showMyToast('Error', '鍒濆鍖栧け璐�', 'Error');
+                });
         } else {
             init({
                 pageSizeLWC: this.pageSize,
                 pageTokenLWC: this.currentPageToken,
                 fiscalYear: this.fiscalYearOption
-            }).then((r) => {
-                r = JSON.parse(JSON.stringify(r));
-                console.log("r = " + JSON.stringify(r));
-                if (r.status == "Success") {
-                    //鍒嗛〉
-                    this.nextPageToken = r.entity.paginatedAccounts.nextPageToken;
-                    this.totalRecords = r.entity.paginatedAccounts.totalRecords;
-                    this.recordStart = r.entity.paginatedAccounts.recordStart;
-                    this.recordEnd = r.entity.paginatedAccounts.recordEnd;
-                    this.totalPages = Math.ceil(
-                        r.entity.paginatedAccounts.totalRecords / this.pageSize
-                    );
-                    console.log("this.totalPages = " + this.totalPages);
-                    this.paginationVisibility = this.totalPages > 1 ? true : false;
+            })
+                .then((r) => {
+                    r = JSON.parse(JSON.stringify(r));
+                    console.log('r = ' + JSON.stringify(r));
+                    if (r.status == 'Success') {
+                        //鍒嗛〉
+                        this.nextPageToken =
+                            r.entity.paginatedAccounts.nextPageToken;
+                        this.totalRecords =
+                            r.entity.paginatedAccounts.totalRecords;
+                        this.recordStart =
+                            r.entity.paginatedAccounts.recordStart;
+                        this.recordEnd = r.entity.paginatedAccounts.recordEnd;
+                        this.totalPages = Math.ceil(
+                            r.entity.paginatedAccounts.totalRecords /
+                            this.pageSize
+                        );
+                        console.log('this.totalPages = ' + this.totalPages);
+                        this.paginationVisibility =
+                            this.totalPages > 1 ? true : false;
 
-                    this.pageRecords = r.entity.pageRecords;
-                    this.accountId = r.entity.accountId;
-                    this.agencyProType = r.entity.agencyProType;
-                    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]["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;
-                    }
-                    console.log(
-                        "this.listViewOptions = " + JSON.stringify(this.listViewOptions)
-                    );
-
-                    console.log('r.entity.topInfo = ' + JSON.stringify(r.entity.topInfo))
-                    //top10瀹㈡埛
-                    this.topInfo = r.entity.topInfo;
-                    console.log("this.topInfo = " + JSON.stringify(this.topInfo));
-                    this.topAccountData = this.topInfo.acList;
-                    console.log(
-                        "this.topAccountData = " + JSON.stringify(this.topAccountData)
-                    );
-                    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 + '%';
-                    }
-
-                    // //鍏朵粬
-                    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.pageRecords = r.entity.pageRecords;
+                        this.accountId = r.entity.accountId;
+                        this.agencyProType = r.entity.agencyProType;
+                        this.agencyProTypestr = r.entity.agencyProTypestr;
+                        console.log(
+                            'this.agencyProTypestr = ' + this.agencyProTypestr
+                        );
+                        for (var i in this.pageRecords) {
+                            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.showMyToast(title, '鏃犳暟鎹�', 'Error');
+                        console.log(
+                            'this.listViewOptions = ' +
+                            JSON.stringify(this.listViewOptions)
+                        );
+
+                        console.log(
+                            'r.entity.topInfo = ' +
+                            JSON.stringify(r.entity.topInfo)
+                        );
+                        //top10瀹㈡埛
+                        this.topInfo = r.entity.topInfo;
+                        console.log(
+                            'this.topInfo = ' + JSON.stringify(this.topInfo)
+                        );
+                        this.topAccountData = this.topInfo.acList;
+                        console.log(
+                            'this.topAccountData = ' +
+                            JSON.stringify(this.topAccountData)
+                        );
+                        console.log(
+                            '9/3 = ' +
+                            this.keepTwoDecimalStr(
+                                this.amend(9, 3, '/').toFixed(2)
+                            )
+                        );
+                        let total = 100;
+                        try {
+                            for (var i in this.topAccountData) {
+                                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)
+                                );
+                                console.log('this.amend = ' +  this.amend(this.topInfo.deList[i],this.topInfo.saleAmount,'/') * 100);
+                                total -= number;
+                                this.topAccountData[i]['proportion'] =
+                                    number + '%';
+                            }
+
+                            console.log(
+                                'this.topAccountData = ' +
+                                JSON.stringify(this.topAccountData)
+                            );
+
+                            //鍏朵粬
+                            console.log('(total.toFixed(2) > 0.00 ? total.toFixed(2) : 0.00) = ' + (total.toFixed(2) > 0.00 ? total.toFixed(2) : '0.00'))
+                            if (total != 100) {
+                                this.topAccountData.push({
+                                    accountName: '...',
+                                    accountUrl: '/s/lexconsumableaccount',
+                                    isDisable: true,
+                                    proportion: (total.toFixed(2) > 0.00 ? total.toFixed(2) : '0.00') + '%',
+                                    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);
+                        }
+                    } else {
+                        console.log('r = ' + JSON.stringify(r));
+                        this.showMyToast('Error', r.msg, 'Error');
                     }
-                    this.isShowSpinner = false;
-                } else {
-                    console.log("r = " + JSON.stringify(r));
-                    this.showMyToast('Error', r.msg, 'Error');
-                }
-            }).catch((error) => {
-                console.log("error = " + JSON.stringify(error));
-                this.showMyToast('Error', '閿�閲忓墠鍗佸鎴峰垵濮嬪寲澶辫触', 'Error');
-            });
+                })
+                .catch((error) => {
+                    console.log('error = ' + JSON.stringify(error));
+                    this.showMyToast(
+                        'Error',
+                        '閿�閲忓墠鍗佸鎴峰垵濮嬪寲澶辫触',
+                        'Error'
+                    );
+                });
         }
     }
 
     amend(num1, num2, symbol) {
+        console.log('num1 = ' + num1);
+        console.log('num2 = ' + num2);
+        console.log('symbol = ' + symbol);
         var str1 = num1.toString(),
             str2 = num2.toString(),
             result,
@@ -446,28 +552,28 @@
             str2Length;
         //瑙e喅鏁存暟娌℃湁灏忔暟鐐规柟娉�
         try {
-            str1Length = str1.split(".")[1].length;
+            str1Length = str1.split('.')[1].length;
         } catch (error) {
             str1Length = 0;
         }
         try {
-            str2Length = str2.split(".")[1].length;
+            str2Length = str2.split('.')[1].length;
         } catch (error) {
             str2Length = 0;
         }
         var step = Math.pow(10, Math.max(str1Length, str2Length));
         console.log(step);
         switch (symbol) {
-            case "+":
+            case '+':
                 result = (num1 * step + num2 * step) / step;
                 break;
-            case "-":
+            case '-':
                 result = (num1 * step - num2 * step) / step;
                 break;
-            case "*":
+            case '*':
                 result = (num1 * step * (num2 * step)) / step / step;
                 break;
-            case "/":
+            case '/':
                 result = (num1 * step) / (num2 * step);
                 break;
             default:
@@ -475,7 +581,6 @@
         }
         return result;
     }
-
 
     keepTwoDecimalStr(num) {
         const result = Number(num.toString().match(/^\d+(?:\.\d{0,2})?/));
@@ -489,12 +594,12 @@
             s += '0';
         }
         return s;
-    };
+    }
 
     dataChange(event) {
-        let fieldName = event.target.getAttribute("data-field");
+        let fieldName = event.target.getAttribute('data-field');
         let value = event.detail.value;
-        console.log("fieldName = " + fieldName + " value = " + value);
+        console.log('fieldName = ' + fieldName + ' value = ' + value);
         switch (fieldName) {
             case 'viewOption':
                 this.viewOption = value;
@@ -511,61 +616,88 @@
         this.isShowSpinner = true;
         changeFiscalYearView({
             fiscalYear: this.fiscalYearOption
-        }).then((r) => {
-            r = JSON.parse(JSON.stringify(r));
-            console.log("r = " + JSON.stringify(r));
-            if (r.status == "Success") {
-                //top10瀹㈡埛
-                this.topInfo = r.entity.topInfo;
-                console.log("this.topInfo = " + JSON.stringify(this.topInfo));
-                this.topAccountData = this.topInfo.acList;
-                console.log(
-                    "this.topAccountData = " + JSON.stringify(this.topAccountData)
-                );
-                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 + '%';
-                }
-
-                // //鍏朵粬
-                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;;
+        })
+            .then((r) => {
+                r = JSON.parse(JSON.stringify(r));
+                console.log('r = ' + JSON.stringify(r));
+                if (r.status == 'Success') {
+                    //top10瀹㈡埛
+                    this.topInfo = r.entity.topInfo;
+                    console.log(
+                        'this.topInfo = ' + JSON.stringify(this.topInfo)
+                    );
+                    this.topAccountData = this.topInfo.acList;
+                    console.log(
+                        'this.topAccountData = ' +
+                        JSON.stringify(this.topAccountData)
+                    );
+                    let total = 100;
+                    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 + '%';
                     }
-                    this.showMyToast(title, '鏃犳暟鎹�', 'Error');
-                }
 
-                this.isShowSpinner = false;
-            } else {
-                console.log("r = " + JSON.stringify(r));
-                this.showMyToast('Error', r.msg, 'Error');
-            }
-        }).catch((error) => {
-            console.log("error = " + JSON.stringify(error));
-            this.showMyToast('Error', '閿�閲忓墠鍗佸鎴峰垵濮嬪寲澶辫触', 'Error');
-        });
+                    // //鍏朵粬
+                    if (total != 100) {
+                        this.topAccountData.push({
+                            accountName: '...',
+                            accountUrl: '/s/lexconsumableaccount',
+                            isDisable: true,
+                            proportion: (total.toFixed(2) > 0.00 ? total.toFixed(2) : '0.00') + '%',
+                            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');
+                }
+            })
+            .catch((error) => {
+                console.log('error = ' + JSON.stringify(error));
+                this.showMyToast('Error', '閿�閲忓墠鍗佸鎴峰垵濮嬪寲澶辫触', 'Error');
+            });
     }
 
     changelistView() {
@@ -577,45 +709,54 @@
             pageSizeLWC: this.pageSize,
             pageTokenLWC: this.currentPageToken,
             sortFieldLWC: this.sortBy,
-            sortOrderLWC: this.sortDirection,
+            sortOrderLWC: this.sortDirection
         })
             .then((r) => {
                 r = JSON.parse(JSON.stringify(r));
-                console.log("r = " + JSON.stringify(r));
-                if (r.status == "Success") {
+                console.log('r = ' + JSON.stringify(r));
+                if (r.status == 'Success') {
                     //鍒嗛〉
-                    this.nextPageToken = r.entity.paginatedAccounts.nextPageToken;
+                    this.nextPageToken =
+                        r.entity.paginatedAccounts.nextPageToken;
                     this.totalRecords = r.entity.paginatedAccounts.totalRecords;
                     this.recordStart = r.entity.paginatedAccounts.recordStart;
                     this.recordEnd = r.entity.paginatedAccounts.recordEnd;
                     this.totalPages = Math.ceil(
                         r.entity.paginatedAccounts.totalRecords / this.pageSize
                     );
-                    console.log("this.totalPages = " + this.totalPages);
-                    this.paginationVisibility = this.totalPages > 1 ? true : false;
+                    console.log('this.totalPages = ' + this.totalPages);
+                    this.paginationVisibility =
+                        this.totalPages > 1 ? true : false;
 
                     this.pageRecords = r.entity.pageRecords;
-                    console.log("this.pageRecords = " + JSON.stringify(this.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]['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]['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]['CityMasterNameUrl'] =
+                            '/' + this.pageRecords[i].City_Master__c;
+                        this.pageRecords[i]['RecordTypeName'] =
                             this.pageRecords[i].RecordType.Name;
                     }
                     this.isShowSpinner = false;
                 } else {
                     this.showMyToast('Error', r.msg, 'Error');
                 }
-            }).catch((error) => {
-                console.log('error = ' + JSON.stringify(error.message))
+            })
+            .catch((error) => {
+                console.log('error = ' + JSON.stringify(error.message));
             });
     }
 
@@ -630,11 +771,18 @@
             iconName = 'utility:error';
         }
         if (message != '') {
-            content = '<h2><strong>' + title + '<strong/></h2><h5>' + message + '</h5>';
+            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);
+        this.template
+            .querySelector('c-common-toast')
+            .showToast(variant, content, iconName, 10000);
     }
 
     sortByMethod(field, reverse, primer) {
@@ -654,28 +802,29 @@
     }
 
     onHandleSort(event) {
+        console.log('event.detail.fieldName = ' + event.detail.fieldName)
         this.sortBy = event.detail.fieldName;
         switch (this.sortBy) {
-            case "NameUrl":
-                this.sortBy = "Name";
+            case 'NameUrl':
+                this.sortBy = 'Name';
                 break;
-            case "StateMasterUrl":
-                this.sortBy = "State_Master__r.Name";
+            case 'StateMasterName':
+                this.sortBy = 'State_Master__r.Name';
                 break;
-            case "RecordTypeName":
-                this.sortBy = "RecordType.Name";
+            case 'RecordTypeName':
+                this.sortBy = 'RecordType.Name';
                 break;
-            case "CityMasterNameUrl":
-                this.sortBy = "City_Master__r.Name";
+            case 'CityMasterName':
+                this.sortBy = 'City_Master__r.Name';
                 break;
         }
         this.sortDirection = event.detail.sortDirection;
         this.currentPageToken = 0;
-        console.log("this.sortBy = " + this.sortBy);
-        console.log("this.sortDirection = " + this.sortDirection);
+        console.log('this.sortBy = ' + this.sortBy);
+        console.log('this.sortDirection = ' + this.sortDirection);
         this.changelistView();
         const { fieldName: sortedBy, sortDirection } = event.detail;
-        this.sortByMethod(sortedBy, sortDirection === "asc" ? 1 : -1);
+        this.sortByMethod(sortedBy, sortDirection === 'asc' ? 1 : -1);
         this.sortDirection = sortDirection;
         this.sortedBy = sortedBy;
     }

--
Gitblit v1.9.1