From af908216bb0012fe849e3b49b3039c7ba238f8f0 Mon Sep 17 00:00:00 2001
From: liangxiaozhen <liangxiaozhen>
Date: 星期五, 11 八月 2023 14:35:43 +0800
Subject: [PATCH] 补充controller,修改变量,主页bug修改

---
 force-app/main/default/lwc/lexDealerInquiryModifyState/lexDealerInquiryModifyState.js |  959 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 935 insertions(+), 24 deletions(-)

diff --git a/force-app/main/default/lwc/lexDealerInquiryModifyState/lexDealerInquiryModifyState.js b/force-app/main/default/lwc/lexDealerInquiryModifyState/lexDealerInquiryModifyState.js
index e452656..6525803 100644
--- a/force-app/main/default/lwc/lexDealerInquiryModifyState/lexDealerInquiryModifyState.js
+++ b/force-app/main/default/lwc/lexDealerInquiryModifyState/lexDealerInquiryModifyState.js
@@ -1,63 +1,974 @@
-import { LightningElement,track } from 'lwc';
+import { LightningElement, track } from 'lwc';
+import init from '@salesforce/apex/LexDealerInquiryModifyStateController.init';
+import searchOppInner from '@salesforce/apex/LexDealerInquiryModifyStateController.searchOppInner';
+import save from '@salesforce/apex/LexDealerInquiryModifyStateController.save';
+// import { loadScript , loadStyle } from 'lightning/platformResourceLoader';
+// import jQueryMin from '@salesforce/resourceUrl/lexJQuery';
+// import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
+//table css
+import { loadStyle } from 'lightning/platformResourceLoader';
+import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable';
 
 export default class LexDealerInquiryModifyState extends LightningElement {
-
-    @track accSearch;
-    @track aooSearch;
+    @track showSpinner = true;
+    //琛ㄥご鏍峰紡
+    stylesLoaded = false;
+    @track accSearch = '';
+    @track aooSearch = '';
     @track limits;
     @track limitOpts = [];
-    @track numtext1;
-    @track numtext2;
+    @track numtext1 = '';
+    @track numtext2 = '=';
     @track numtext;
     @track textOpts = [];
     @track equalOpts = [];
+    @track strColumus = '';
+    @track strRtColumus = '';
+
+    //鍒嗛〉start
+    @track sortBy = '';
+    //@track sortDirection = "asc";
+    @track pageSize = 10;
+    error;
+    records;
+    currentPageToken = 0;
+    nextPageToken = this.pageSize;
+    @track totalRecords = 0;
+    @track loader = false;
+    @track pageNumber = 1;
+    @track paginationVisibility = false;
+    @track totalPages = 1;
+    pageSizeOptions = [10, 25, 50, 100];
+    @track recordStart = 0;
+    @track recordEnd = 0;
+    //end
+    defaultSortDirection = 'asc';
+    sortDirection = 'asc';
+    sortedBy;
+    @track hidecheckboxcolumn = true;
+    @track changeFlg;
+    @track canEdit;
+    @track saveType;
+    @track sortKey;
+
+    // @track colmLeft = [
+    //     {label:"OCSM璇环缂栫爜",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"OCSM璇环",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"绉戝鍒嗙被",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"鐘舵��1",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"Oly璇环闃舵",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"棰勬祴OCSM绛剧害鏃�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"鏄惁涓婃湀棰勬祴璇环",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"鏄惁鏈湀棰勬祴璇环",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"鏄惁娆℃湀棰勬祴璇环",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"鎺堟潈鐢宠缂栫爜",fieldName:"field1",hideDefaultActions: true}
+    // ];
+    // @track colmRight = [
+    //     {label:"璇环鍚�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"缁忛攢鍟嗚浠风紪鐮�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"缁忛攢鍟嗗尰闄�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"绉戝鍒嗙被",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"绉戝鍚嶇О",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"甯�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"浜у搧鍖哄垎1",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"浜у搧鍖哄垎2",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"浜у搧鍖哄垎3",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"瀹㈡埛浜哄憳",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"閿�鍞媴褰�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"鍖婚櫌閲囪喘棰勭畻(涓嶅惈绋�,鍏�)",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"璁㈣揣閲戦(涓嶅惈绋�,鍏�)",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"棰勬祴涓嶰CSM绛剧害鏃�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"棰勬祴鎷涙爣鏃�",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"璇环闃舵",fieldName:"field1",hideDefaultActions: true},
+    //     {label:"鏄惁OCSM鍏变韩璇环",fieldName:"field1",hideDefaultActions: true}
+    // ];
+    // @track dataLeft = [
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"}
+    // ];
+    // @track dataRight = [
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"},
+    //     {field1:"test"}
+    // ];
+
+    @track colms = [
+        {
+            label: 'OCSM璇环缂栫爜',
+            fieldName: 'OCSM_Opportunity_No__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 140,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'OCSM_Opportunity_No__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: 'OCSM璇环',
+            fieldName: 'Change_To_Opportunity_T__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 100,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Change_To_Opportunity_T__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '绉戝鍒嗙被',
+            fieldName: 'Strategic_department_Class_Name__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 105,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Strategic_department_Class_Name__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '鐘舵��1',
+            fieldName: 'Oly_Inquiry_Status1__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 100,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Oly_Inquiry_Status1__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: 'Oly璇环闃舵',
+            fieldName: 'Oly_Inquiry_Stage__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Oly_Inquiry_Stage__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '棰勬祴OCSM绛剧害鏃�',
+            fieldName: 'Oly_Forecasted_Date__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 150,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Oly_Forecasted_Date__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '鏄惁涓婃湀棰勬祴璇环',
+            fieldName: 'Oly_Forecast_last_month__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 150,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Oly_Forecast_last_month__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '鏄惁鏈湀棰勬祴璇环',
+            fieldName: 'Oly_Forecast_this_month__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 150,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Oly_Forecast_this_month__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '鏄惁娆℃湀棰勬祴璇环',
+            fieldName: 'Oly_NM_Forecast__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 150,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Oly_NM_Forecast__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '鎺堟潈鐢宠缂栫爜',
+            fieldName: 'Oly_Authorized_DB_No__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Oly_Authorized_DB_No__c' },
+                showType: 'outputField'
+            }
+        },
+        // -----------------------------------------------
+        {
+            label: '璇环鍚�',
+            fieldName: 'NameLink',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            type: 'url',
+            typeAttributes: { label: { fieldName: 'Name' }, target: '_blank' }
+        },
+        {
+            label: '缁忛攢鍟嗚浠风紪鐮�',
+            fieldName: 'Agency_Opportunity_No__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 130,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Agency_Opportunity_No__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '缁忛攢鍟嗗尰闄�',
+            fieldName: 'Agency_Hospital__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Agency_Hospital__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '绉戝鍒嗙被',
+            fieldName: 'Department_Cateogy__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Department_Cateogy__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '绉戝鍚嶇О',
+            fieldName: 'Department_Name_Text__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Department_Cateogy__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '甯�',
+            fieldName: 'Hospital_City_Master__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Hospital_City_Master__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '浜у搧鍖哄垎1',
+            fieldName: 'Product_Category1_P__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Product_Category1_P__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '浜у搧鍖哄垎2',
+            fieldName: 'Product_Category2_P__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Product_Category2_P__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '浜у搧鍖哄垎3',
+            fieldName: 'Product_Category3_P__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Product_Category3_P__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '瀹㈡埛浜哄憳',
+            fieldName: 'Agency_Contact__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Agency_Contact__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '閿�鍞媴褰�',
+            fieldName: 'Agency_PersonName__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Agency_PersonName__c' },
+                showType: 'outputField'
+            }
+        },
+        {
+            label: '鍖婚櫌閲囪喘棰勭畻(涓嶅惈绋�,鍏�)',
+            fieldName: 'Amount__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 200,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Amount__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '璁㈣揣閲戦(涓嶅惈绋�,鍏�)',
+            fieldName: 'OCMSale_Price__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 190,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'OCMSale_Price__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '棰勬祴涓嶰CSM绛剧害鏃�',
+            fieldName: 'Close_Forecasted_Date__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 190,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Close_Forecasted_Date__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '棰勬祴鎷涙爣鏃�',
+            fieldName: 'Bid_Planned_Date__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'Bid_Planned_Date__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '璇环闃舵',
+            fieldName: 'StageName__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 110,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'StageName__c' },
+                showType: 'inputField'
+            }
+        },
+        {
+            label: '鏄惁OCSM鍏变韩璇环',
+            fieldName: 'OCM_Change_To_Opportunity_Flg__c',
+            hideDefaultActions: true,
+            wrapText: true,
+            initialWidth: 190,
+            sortable: true,
+            typeAttributes: {
+                recordId: { fieldName: 'recordId' },
+                inputValue: { fieldName: 'OCM_Change_To_Opportunity_Flg__c' },
+                showType: 'inputField'
+            }
+        }
+    ];
+    @track datas = [];
+
+    renderedCallback() {
+        if (!this.stylesLoaded) {
+            Promise.all([loadStyle(this, WrappedHeaderTable)])
+                .then(() => {
+                    console.log('Custom styles loaded');
+                    this.stylesLoaded = true;
+                })
+                .catch((error) => {
+                    console.error('Error loading custom styles');
+                });
+        }
+    }
 
     //鍒濆鍖�
-    connectedCallback(){}
+    connectedCallback() {
+        this.loader = true;
+        this.init();
+    }
+    init() {
+        this.showSpinner = true;
+        init({
+            pageSizeLWC: this.pageSize,
+            pageTokenLWC: this.currentPageToken
+        })
+            .then((result) => {
+                if (result.result == 'Success') {
+                    console.log('result==>' + JSON.stringify(result));
+                    //鍒嗛〉start
+                    this.nextPageToken = result.paginatedAccounts.nextPageToken;
+                    this.totalRecords = result.paginatedAccounts.totalRecords;
+                    this.recordStart = result.paginatedAccounts.recordStart;
+                    this.recordEnd = result.paginatedAccounts.recordEnd;
+                    this.totalPages = Math.ceil(
+                        result.paginatedAccounts.totalRecords / this.pageSize
+                    );
+                    console.log('this.totalPages = ' + this.totalPages);
+                    this.paginationVisibility =
+                        this.totalPages > 1 ? true : false;
+                    console.log('this.sortDirection = ' + this.sortDirection);
+                    this.loader = false;
+                    //鍒嗛〉end
+                    this.limits = result.limits;
+                    this.limitOpts = result.limitCusOpts;
+                    // this.numtext1 = result.numtext1;
+                    // this.numtext2 = result.numtext2;
+                    // this.numtext = result.numtext;
+                    this.textOpts = result.textCusOpts;
+                    this.equalOpts = result.equalCusOpts;
+                    this.datas = result.oppRecords;
+                    this.strColumus = result.strColumus;
+                    this.strRtColumus = result.strRtColumus;
+                    this.changeFlg = result.oppRecords.changeFlg;
+                    for (var i in this.datas) {
+                        this.datas[i]['recordId'] = this.datas[i].opp.Id;
+                        this.datas[i]['OCSM_Opportunity_No__c'] =
+                            this.datas[i].opp.OCSM_Opportunity_No__c;
+                        this.datas[i]['Change_To_Opportunity_T__c'] =
+                            this.datas[i].opp.Change_To_Opportunity_T__c;
+                        this.datas[i]['Strategic_department_Class_Name__c'] =
+                            this.datas[
+                                i
+                            ].opp.Strategic_department_Class_Name__c;
+                        this.datas[i]['Oly_Inquiry_Status1__c'] =
+                            this.datas[i].opp.Oly_Inquiry_Status1__c;
+                        this.datas[i]['Oly_Inquiry_Stage__c'] =
+                            this.datas[i].opp.Oly_Inquiry_Stage__c;
+                        this.datas[i]['Oly_Forecasted_Date__c'] =
+                            this.datas[i].opp.Oly_Forecasted_Date__c;
+                        this.datas[i]['Oly_Forecast_last_month__c'] =
+                            this.datas[i].opp.Oly_Forecast_last_month__c;
+                        this.datas[i]['Oly_Forecast_this_month__c'] =
+                            this.datas[i].opp.Oly_Forecast_this_month__c;
+                        this.datas[i]['Oly_NM_Forecast__c'] =
+                            this.datas[i].opp.Oly_NM_Forecast__c;
+                        this.datas[i]['Oly_Authorized_DB_No__c'] =
+                            this.datas[i].opp.Oly_Authorized_DB_No__c;
+                        // -------
+                        this.datas[i]['Name'] = this.datas[i].AgcOpp.Name;
+                        this.datas[i]['Agency_Opportunity_No__c'] =
+                            this.datas[i].AgcOpp.Agency_Opportunity_No__c;
+                        this.datas[i]['Agency_Hospital__c'] =
+                            this.datas[i].AgcOpp.Agency_Hospital__c;
+                        this.datas[i]['Department_Cateogy__c'] =
+                            this.datas[i].AgcOpp.Department_Cateogy__c;
+                        this.datas[i]['Department_Name_Text__c'] =
+                            this.datas[i].AgcOpp.Department_Name_Text__c;
+                        this.datas[i]['Hospital_City_Master__c'] =
+                            this.datas[i].AgcOpp.Hospital_City_Master__c;
+                        this.datas[i]['Product_Category1_P__c'] =
+                            this.datas[i].AgcOpp.Product_Category1_P__c;
+                        this.datas[i]['Product_Category2_P__c'] =
+                            this.datas[i].AgcOpp.Product_Category2_P__c;
+                        this.datas[i]['Product_Category3_P__c'] =
+                            this.datas[i].AgcOpp.Product_Category3_P__c;
+                        this.datas[i]['Agency_Contact__c'] =
+                            this.datas[i].AgcOpp.Agency_Contact__c;
+                        this.datas[i]['Agency_PersonName__c'] =
+                            this.datas[i].AgcOpp.Agency_PersonName__c;
+                        this.datas[i]['Amount__c'] =
+                            this.datas[i].AgcOpp.Amount__c;
+                        this.datas[i]['OCMSale_Price__c'] =
+                            this.datas[i].AgcOpp.OCMSale_Price__c;
+                        this.datas[i]['Close_Forecasted_Date__c'] =
+                            this.datas[i].AgcOpp.Close_Forecasted_Date__c;
+                        this.datas[i]['Bid_Planned_Date__c'] =
+                            this.datas[i].AgcOpp.Bid_Planned_Date__c;
+                        this.datas[i]['StageName__c'] =
+                            this.datas[i].AgcOpp.StageName__c;
+                        this.datas[i]['OCM_Change_To_Opportunity_Flg__c'] =
+                            this.datas[
+                                i
+                            ].AgcOpp.OCM_Change_To_Opportunity_Flg__c;
+                        this.datas[i]['NameLink'] =
+                            '/s/agency-opportunity/' + this.datas[i].opp.Id;
+                    }
+                    this.showMyToast(result.Msg, '', 'success');
+                    this.showSpinner = false;
+                } else {
+                    this.showSpinner = false;
+                    this.showMyToast('鍒濆鍖栭〉闈㈠け璐�', result.Msg, 'error');
+                }
+            })
+            .catch((error) => {
+                this.showSpinner = false;
+                console.log('Error:' + JSON.stringify(error));
+                this.showMyToast(
+                    '鍒濆鍖栭〉闈㈠け璐�',
+                    JSON.stringify(error),
+                    'error'
+                );
+            });
+    }
 
-    accSearchChange(event){
+    // renderedCallback() {
+    // if (!this.stylesLoaded) {
+    //     Promise.all([loadStyle(this, WrappedHeaderTable),loadScript(this, jQueryMin)])
+    //         .then(() => {
+    //             console.log("Custom styles loaded");
+    //             this.stylesLoaded = true;
+    //         })
+    //         .catch((error) => {
+    //             console.error("Error loading custom styles");
+    //         });
+    //     // loadScript(this, jQueryMin+'/lexJQuery183.js')
+    //     // .then(() => {
+    //     //     console.log('JQuery loaded.');
+    //     // })
+    //     // .catch(error=>{
+    //     //     console.log('Failed to load the JQuery : ' +error);
+    //     // });
+    //     // Promise.all([loadScript(this, jQueryMin)])
+    //     //     .then(() => {
+    //     //         console.log("Custom styles loaded");
+    //     //         this.stylesLoaded = true;
+    //     //         j$('.tableRight').scroll(function() {
+    //     //             j$('.tableLeft').scrollTop(j$(this).scrollTop());
+    //     //         });
+    //     //     })
+    //     //     .catch((error) => {
+    //     //         console.log(JSON.stringify(error));
+    //     //         console.error("Error loading custom styles");
+    //     //     });
+    // }
+    // }
+
+    agencyOppInputChange(event) {
+        this.changeFlg = 1;
+        var inputValue = event.detail.data.inputValue;
+        var recordId = event.detail.data.recordId;
+        var fieldName = event.detail.data.fieldName;
+        console.log(
+            'valueChange:' + recordId + '---' + fieldName + '---' + inputValue
+        );
+        for (var i in this.datas) {
+            if (this.datas[i]['recordId'] == recordId) {
+                this.datas[i]['fieldName'] = inputValue;
+                this.datas[i]['changeFlg'] = this.changeFlg;
+            }
+        }
+        console.log(' this.datas==>' + JSON.stringify(this.datas));
+    }
+
+    accSearchChange(event) {
         this.accSearch = event.detail.value;
     }
 
-    aooSearchChange(event){
+    aooSearchChange(event) {
         this.aooSearch = event.detail.value;
     }
 
-    limitsChange(event){
+    limitsChange(event) {
         this.limits = event.detail.value;
     }
 
-    numtext1Change(event){
+    numtext1Change(event) {
         this.numtext1 = event.detail.value;
     }
 
-    numtext2Change(event){
+    numtext2Change(event) {
         this.numtext2 = event.detail.value;
     }
 
-    numtextChange(event){
+    numtextChange(event) {
         this.numtext = event.detail.value;
     }
 
-    expandAll(){
+    expandAll() {}
 
+    search() {
+        console.log('鎼滅储');
+        this.showSpinner = true;
+        if (this.changeFlg == 1) {
+            if (
+                window.confirm(
+                    '鐢婚潰涓婄殑鏁版嵁鏈夊彉鍖栵紝瑕佷繚瀛樻墍鍋氱殑鍙樻洿鍚楋紵\n鐐瑰嚮 [纭畾] 淇濆瓨骞舵绱n鐐瑰嚮 [鍙栨秷] 鍙绱紝鏀惧純淇濆瓨'
+                )
+            ) {
+                this.save();
+                this.searchOpp();
+                this.showSpinner = false;
+            } else {
+                console.log('鎼滅储1');
+                this.searchOpp();
+                this.showSpinner = false;
+            }
+        } else {
+            this.searchOpp();
+            this.showSpinner = false;
+        }
+    }
+    searchOpp() {
+        console.log('this.accSearch==>' + this.accSearch);
+        console.log('this.aooSearch==>' + this.aooSearch);
+        console.log('this.numtext==>' + this.numtext);
+        console.log('this.numtext1==>' + this.numtext1);
+        console.log('this.numtext2==>' + this.numtext2);
+        searchOppInner({
+            strColumus: this.strColumus,
+            strRtColumus: this.strRtColumus,
+            accSearch: this.accSearch,
+            aooSearch: this.aooSearch,
+            numtext: this.numtext,
+            numtext1: this.numtext1,
+            numtext2: this.numtext2
+        })
+            .then((result) => {
+                if (result.result == 'Success') {
+                    //鍒嗛〉Start
+                    // this.nextPageToken = result.entity.paginatedAccounts.nextPageToken;
+                    // this.totalRecords = result.entity.paginatedAccounts.totalRecords;
+                    // this.recordStart = result.entity.paginatedAccounts.recordStart;
+                    // this.recordEnd = result.entity.paginatedAccounts.recordEnd;
+                    // this.totalPages = Math.ceil(result.entity.paginatedAccounts.totalRecords / this.pageSize);
+                    // console.log('this.totalPages = ' + this.totalPages);
+                    // this.paginationVisibility = this.totalPages > 1 ? true : false;
+                    //鍒嗛〉End
+                    this.datas = result.oppRecords;
+                    //change flag
+                    // this.changeFlg= result.oppRecords.changeFlg;
+                    console.log('result==>' + JSON.stringify(result));
+                    for (var i in this.datas) {
+                        this.datas[i]['recordId'] = this.datas[i].opp.Id;
+                        this.datas[i]['OCSM_Opportunity_No__c'] =
+                            this.datas[i].opp.OCSM_Opportunity_No__c;
+                        this.datas[i]['Change_To_Opportunity_T__c'] =
+                            this.datas[i].opp.Change_To_Opportunity_T__c;
+                        this.datas[i]['Strategic_department_Class_Name__c'] =
+                            this.datas[
+                                i
+                            ].opp.Strategic_department_Class_Name__c;
+                        this.datas[i]['Oly_Inquiry_Status1__c'] =
+                            this.datas[i].opp.Oly_Inquiry_Status1__c;
+                        this.datas[i]['Oly_Inquiry_Stage__c'] =
+                            this.datas[i].opp.Oly_Inquiry_Stage__c;
+                        this.datas[i]['Oly_Forecasted_Date__c'] =
+                            this.datas[i].opp.Oly_Forecasted_Date__c;
+                        this.datas[i]['Oly_Forecast_last_month__c'] =
+                            this.datas[i].opp.Oly_Forecast_last_month__c;
+                        this.datas[i]['Oly_Forecast_this_month__c'] =
+                            this.datas[i].opp.Oly_Forecast_this_month__c;
+                        this.datas[i]['Oly_NM_Forecast__c'] =
+                            this.datas[i].opp.Oly_NM_Forecast__c;
+                        this.datas[i]['Oly_Authorized_DB_No__c'] =
+                            this.datas[i].opp.Oly_Authorized_DB_No__c;
+                        // -------
+                        this.datas[i]['Name'] = this.datas[i].AgcOpp.Name;
+                        this.datas[i]['Agency_Opportunity_No__c'] =
+                            this.datas[i].AgcOpp.Agency_Opportunity_No__c;
+                        this.datas[i]['Agency_Hospital__c'] =
+                            this.datas[i].AgcOpp.Agency_Hospital__c;
+                        this.datas[i]['Department_Cateogy__c'] =
+                            this.datas[i].AgcOpp.Department_Cateogy__c;
+                        this.datas[i]['Department_Name_Text__c'] =
+                            this.datas[i].AgcOpp.Department_Name_Text__c;
+                        this.datas[i]['Hospital_City_Master__c'] =
+                            this.datas[i].AgcOpp.Hospital_City_Master__c;
+                        this.datas[i]['Product_Category1_P__c'] =
+                            this.datas[i].AgcOpp.Product_Category1_P__c;
+                        this.datas[i]['Product_Category2_P__c'] =
+                            this.datas[i].AgcOpp.Product_Category2_P__c;
+                        this.datas[i]['Product_Category3_P__c'] =
+                            this.datas[i].AgcOpp.Product_Category3_P__c;
+                        this.datas[i]['Agency_Contact__c'] =
+                            this.datas[i].AgcOpp.Agency_Contact__c;
+                        this.datas[i]['Agency_PersonName__c'] =
+                            this.datas[i].AgcOpp.Agency_PersonName__c;
+                        this.datas[i]['Amount__c'] =
+                            this.datas[i].AgcOpp.Amount__c;
+                        this.datas[i]['OCMSale_Price__c'] =
+                            this.datas[i].AgcOpp.OCMSale_Price__c;
+                        this.datas[i]['Close_Forecasted_Date__c'] =
+                            this.datas[i].AgcOpp.Close_Forecasted_Date__c;
+                        this.datas[i]['Bid_Planned_Date__c'] =
+                            this.datas[i].AgcOpp.Bid_Planned_Date__c;
+                        this.datas[i]['StageName__c'] =
+                            this.datas[i].AgcOpp.StageName__c;
+                        this.datas[i]['OCM_Change_To_Opportunity_Flg__c'] =
+                            this.datas[
+                                i
+                            ].AgcOpp.OCM_Change_To_Opportunity_Flg__c;
+                    }
+                    this.showSpinner = false;
+                    this.showMyToast('鎼滅储鎴愬姛', result.Msg, 'success');
+                } else {
+                    this.showSpinner = false;
+                    this.showMyToast('鎼滅储澶辫触', result.Msg, 'error');
+                }
+            })
+            .catch((error) => {
+                this.showSpinner = false;
+                console.log('error = ' + JSON.stringify(error));
+            });
+    }
+
+    save() {
+        this.showSpinner = true;
+        save({
+            oppRecordsLWC: this.datas,
+            sortKeyLWC: this.sortKey
+        })
+            .then((result) => {
+                if (result.result == 'Success') {
+                    this.datas = result.oppRecords;
+                    console.log('result==>' + JSON.stringify(result));
+                    this.showSpinner = false;
+                    this.showMyToast('淇濆瓨鎴愬姛', '', 'success');
+                } else {
+                    this.showSpinner = false;
+                    this.showMyToast('淇濆瓨澶辫触', result.Msg, 'error');
+                }
+            })
+            .catch((error) => {
+                this.showSpinner = false;
+                console.log('error = ' + JSON.stringify(error));
+            });
     }
 
     showMyToast(title, message, variant) {
         console.log('show custom message');
         var iconName = '';
         var content = '';
-        if(variant == 'success'){
-           iconName = 'utility:check';
-        }else{
-           iconName = 'utility:error';
+        if (variant == 'success') {
+            iconName = 'utility:check';
+        } else {
+            iconName = 'utility:error';
         }
-        if(message != ''){
-           content = '<h2><strong>'+title+'<strong/></h2><h5>'+message+'</h5>';
-        }else{
-           content = '<h2><strong>'+title+'<strong/></h2>';
+        if (message != '') {
+            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) {
+        const key = primer
+            ? function (x) {
+                  return primer(x[field]);
+              }
+            : function (x) {
+                  return x[field];
+              };
+
+        return function (a, b) {
+            a = key(a);
+            b = key(b);
+            return reverse * ((a > b) - (b > a));
+        };
+    }
+
+    onHandleSort(event) {
+        console.log('Sort');
+        console.log('this.changeFlg' + this.changeFlg);
+        if (this.changeFlg == 1) {
+            if (
+                window.confirm(
+                    '鐢婚潰涓婄殑鏁版嵁鏈夊彉鍖栵紝瑕佷繚瀛樻墍鍋氱殑鍙樻洿鍚楋紵\n鐐瑰嚮 [纭畾] 淇濆瓨骞舵帓搴廫n鐐瑰嚮 [鍙栨秷] 鍙帓搴忥紝鏀惧純淇濆瓨'
+                )
+            ) {
+                this.sortBy = event.detail.fieldName;
+                this.sortDirection = event.detail.sortDirection;
+                this.currentPageToken = 0;
+                console.log('this.sortBy = ' + this.sortBy);
+                console.log('this.sortDirection = ' + this.sortDirection);
+                const { fieldName: sortedBy, sortDirection } = event.detail;
+                const cloneData = [...this.datas];
+                cloneData.sort(
+                    this.sortByMethod(
+                        sortedBy,
+                        sortDirection === 'asc' ? 1 : -1
+                    )
+                );
+                this.datas = cloneData;
+                this.sortDirection = sortDirection;
+                this.sortedBy = sortedBy;
+                this.sortKey = this.sortBy;
+                this.save();
+            } else {
+                this.sortBy = event.detail.fieldName;
+                console.log('this.sortBy==>' + this.sortBy);
+                this.sortDirection = event.detail.sortDirection;
+                this.currentPageToken = 0;
+                console.log('this.sortBy = ' + this.sortBy);
+                console.log('this.sortDirection = ' + this.sortDirection);
+                const { fieldName: sortedBy, sortDirection } = event.detail;
+                const cloneData = [...this.datas];
+                cloneData.sort(
+                    this.sortByMethod(
+                        sortedBy,
+                        sortDirection === 'asc' ? 1 : -1
+                    )
+                );
+                this.datas = cloneData;
+                this.sortDirection = sortDirection;
+                this.sortedBy = sortedBy;
+            }
+        } else {
+            this.sortBy = event.detail.fieldName;
+            console.log('this.sortBy==>' + this.sortBy);
+            this.sortDirection = event.detail.sortDirection;
+            this.currentPageToken = 0;
+            console.log('this.sortBy = ' + this.sortBy);
+            console.log('this.sortDirection = ' + this.sortDirection);
+            const { fieldName: sortedBy, sortDirection } = event.detail;
+            const cloneData = [...this.datas];
+            cloneData.sort(
+                this.sortByMethod(sortedBy, sortDirection === 'asc' ? 1 : -1)
+            );
+            this.datas = cloneData;
+            this.sortDirection = sortDirection;
+            this.sortedBy = sortedBy;
+        }
+    }
+    //鍒嗛〉
+    handlePaginatorChange(event) {
+        this.recordsToDisplay = event.detail.recordsToDisplay;
+        this.preSelected = event.detail.preSelected;
+        if (this.recordsToDisplay && this.recordsToDisplay > 0) {
+            this.rowNumberOffset = this.recordsToDisplay[0].rowNumber - 1;
+        } else {
+            this.rowNumberOffset = 0;
+        }
+    }
+    handlePrevious() {
+        this.currentPageToken =
+            Number(this.currentPageToken) - Number(this.pageSize);
+        this.init();
+    }
+
+    handleNext() {
+        this.currentPageToken =
+            Number(this.currentPageToken) + Number(this.pageSize);
+        this.init();
+    }
+    handleFirst() {
+        this.currentPageToken = 0;
+        this.init();
+    }
+
+    handleLast() {
+        this.currentPageToken =
+            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
+        this.init();
+    }
+
+    handlePageschange(event) {
+        console.log(event.detail);
+        this.pageSize = event.detail;
+        this.currentPageToken = 0;
+        this.init();
+    }
+    get previousButtonDisabled() {
+        return this.currentPageToken === 0;
+    }
+
+    get nextButtonDisabled() {
+        return this.nextPageToken === undefined;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1