buli
2023-07-07 85f6fb6227a84936e192936ba480b4e03834df03
force-app/main/default/lwc/lexDealerInquiryModifyState/lexDealerInquiryModifyState.js
@@ -5,11 +5,13 @@
// 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';
//table css
import { loadStyle } from "lightning/platformResourceLoader";
import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
export default class LexDealerInquiryModifyState extends LightningElement {
    @track showSpinner = true;
    //表头样式
    stylesLoaded = false;
@@ -26,7 +28,7 @@
    @track strRtColumus = '';
    //分页start
    @track sortBy = '';
    @track sortBy = "";
    //@track sortDirection = "asc";
    @track pageSize = 10;
    error;
@@ -42,14 +44,17 @@
    @track recordStart = 0;
    @track recordEnd = 0;
    //end
    defaultSortDirection = 'asc';
    sortDirection = 'asc';
    sortedBy;
    defaultSortDirection = "asc";
   sortDirection = "asc";
   sortedBy;
    @track hidecheckboxcolumn = true;
    @track changeFlg;
    @track canEdit;
    @track saveType;
    @track sortKey;
    // @track colmLeft = [
    //     {label:"OCSM询价编码",fieldName:"field1",hideDefaultActions: true},
@@ -115,366 +120,234 @@
    @track colms = [
        {
            label: 'OCSM询价编码',
            fieldName: 'OCSM_Opportunity_No__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 140,
            sortable: true,
            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' },
                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,
            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' },
                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,
            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' },
                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,
            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' },
                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,
            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' },
                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,
            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' },
                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,
            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' },
                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,
            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' },
                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,
            label: "是否次月预测询价", fieldName: "Oly_NM_Forecast__c", hideDefaultActions: true, wrapText: true, initialWidth: 150,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Oly_NM_Forecast__c' },
                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,
            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' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Oly_Authorized_DB_No__c" },
                showType: 'outputField'
            }
            },
        },
        // -----------------------------------------------
        {
            label: '询价名',
            fieldName: 'NameLink',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            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,
            label: "经销商询价编码", fieldName: "Agency_Opportunity_No__c", hideDefaultActions: true, wrapText: true, initialWidth: 130,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Agency_Opportunity_No__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Agency_Opportunity_No__c" },
                showType: 'outputField'
            }
            },
        },
        {
            label: '经销商医院',
            fieldName: 'Agency_Hospital__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            label: "经销商医院", fieldName: "Agency_Hospital__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Agency_Hospital__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Agency_Hospital__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '科室分类',
            fieldName: 'Department_Cateogy__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            label: "科室分类", fieldName: "Department_Cateogy__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Department_Cateogy__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Department_Cateogy__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '科室名称',
            fieldName: 'Department_Name_Text__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            label: "科室名称", fieldName: "Department_Name_Text__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Department_Cateogy__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Department_Cateogy__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '市',
            fieldName: 'Hospital_City_Master__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            label: "市", fieldName: "Hospital_City_Master__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Hospital_City_Master__c' },
                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,
            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' },
                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,
            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' },
                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,
            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' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Product_Category3_P__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '客户人员',
            fieldName: 'Agency_Contact__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            label: "客户人员", fieldName: "Agency_Contact__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Agency_Contact__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Agency_Contact__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '销售担当',
            fieldName: 'Agency_PersonName__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            label: "销售担当", fieldName: "Agency_PersonName__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Agency_PersonName__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Agency_PersonName__c" },
                showType: 'outputField'
            }
            },
        },
        {
            label: '医院采购预算(不含税,元)',
            fieldName: 'Amount__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 200,
            sortable: true,
            label: "医院采购预算(不含税,元)", fieldName: "Amount__c", hideDefaultActions: true, wrapText: true, initialWidth: 200,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Amount__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Amount__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '订货金额(不含税,元)',
            fieldName: 'OCMSale_Price__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 190,
            sortable: true,
            label: "订货金额(不含税,元)", fieldName: "OCMSale_Price__c", hideDefaultActions: true, wrapText: true, initialWidth: 190,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'OCMSale_Price__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "OCMSale_Price__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '预测与OCSM签约日',
            fieldName: 'Close_Forecasted_Date__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 190,
            sortable: true,
            label: "预测与OCSM签约日", fieldName: "Close_Forecasted_Date__c", hideDefaultActions: true, wrapText: true, initialWidth: 190,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Close_Forecasted_Date__c' },
                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,
            label: "预测招标日", fieldName: "Bid_Planned_Date__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'Bid_Planned_Date__c' },
                recordId: { fieldName: "recordId" },
                inputValue: { fieldName: "Bid_Planned_Date__c" },
                showType: 'inputField'
            }
            },
        },
        {
            label: '询价阶段',
            fieldName: 'StageName__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 110,
            sortable: true,
            label: "询价阶段", fieldName: "StageName__c", hideDefaultActions: true, wrapText: true, initialWidth: 110,sortable: true,
            typeAttributes: {
                recordId: { fieldName: 'recordId' },
                inputValue: { fieldName: 'StageName__c' },
                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,
            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' },
                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');
                    console.log("Custom styles loaded");
                    this.stylesLoaded = true;
                })
                .catch((error) => {
                    console.error('Error loading custom styles');
                    console.error("Error loading custom styles");
                });
        }
    }
@@ -483,14 +356,15 @@
    connectedCallback() {
        this.loader = true;
        this.init();
    }
    init() {
    init(){
        this.showSpinner = true;
        init({
        init({
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        })
            .then((result) => {
            .then(result => {
                if (result.result == 'Success') {
                    console.log('result==>' + JSON.stringify(result));
                    //分页start
@@ -498,13 +372,10 @@
                    this.totalRecords = result.paginatedAccounts.totalRecords;
                    this.recordStart = result.paginatedAccounts.recordStart;
                    this.recordEnd = result.paginatedAccounts.recordEnd;
                    this.totalPages = Math.ceil(
                        result.paginatedAccounts.totalRecords / this.pageSize
                    );
                    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.paginationVisibility = this.totalPages > 1 ? true : false;
                     console.log('this.sortDirection = ' + this.sortDirection);
                    this.loader = false;
                    //分页end
                    this.limits = result.limits;
@@ -520,66 +391,35 @@
                    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]['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.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;
@@ -588,15 +428,12 @@
                    this.showMyToast('初始化页面失败', result.Msg, 'error');
                }
            })
            .catch((error) => {
            .catch(error => {
                this.showSpinner = false;
                console.log('Error:' + JSON.stringify(error));
                this.showMyToast(
                    '初始化页面失败',
                    JSON.stringify(error),
                    'error'
                );
            });
                console.log("Error:" + JSON.stringify(error));
                this.showMyToast('初始化页面失败', JSON.stringify(error), 'error');
            })
    }
    // renderedCallback() {
@@ -636,16 +473,14 @@
        var inputValue = event.detail.data.inputValue;
        var recordId = event.detail.data.recordId;
        var fieldName = event.detail.data.fieldName;
        console.log(
            'valueChange:' + recordId + '---' + fieldName + '---' + inputValue
        );
        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;
                this.datas[i]['changeFlg'] =  this.changeFlg;
            }
        }
        console.log(' this.datas==>' + JSON.stringify(this.datas));
        console.log(" this.datas==>" + JSON.stringify(this.datas));
    }
    accSearchChange(event) {
@@ -672,31 +507,31 @@
        this.numtext = event.detail.value;
    }
    expandAll() {}
    expandAll() {
    search() {
    }
    search(){
        console.log('搜索');
        this.showSpinner = true;
        if (this.changeFlg == 1) {
            if (
                window.confirm(
                    '画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并检索\n点击 [取消] 只检索,放弃保存'
                )
            ) {
        if(this.changeFlg == 1){
            if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并检索\n点击 [取消] 只检索,放弃保存')) {
                this.save();
                this.searchOpp();
                this.showSpinner = false;
            } else {
            }else{
                console.log('搜索1');
                this.searchOpp();
                this.showSpinner = false;
            }
        } else {
        }else{
            this.searchOpp();
            this.showSpinner = false;
        }
    }
    searchOpp() {
    searchOpp(){
        console.log('this.accSearch==>' + this.accSearch);
        console.log('this.aooSearch==>' + this.aooSearch);
        console.log('this.numtext==>' + this.numtext);
@@ -709,118 +544,91 @@
            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');
            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;
                }
            })
            .catch((error) => {
                this.showSpinner = false;
                console.log('error = ' + JSON.stringify(error));
            });
                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) => {
            sortKeyLWC:this.sortKey
        }).then((result) => {
            if (result.result == 'Success') {
                this.datas = result.oppRecords;
                console.log('result==>' + JSON.stringify(result));
                this.showSpinner = false;
                console.log('error = ' + JSON.stringify(error));
            });
                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) {
@@ -833,18 +641,12 @@
            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) {
@@ -863,71 +665,55 @@
        };
    }
    onHandleSort(event) {
        console.log('Sort');
        console.log('this.changeFlg' + this.changeFlg);
        if (this.changeFlg == 1) {
            if (
                window.confirm(
                    '画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并排序\n点击 [取消] 只排序,放弃保存'
                )
            ) {
   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);
                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
                    )
                );
                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 {
            }else{
                this.sortBy = event.detail.fieldName;
                console.log('this.sortBy==>' + this.sortBy);
                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);
                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
                    )
                );
                cloneData.sort(this.sortByMethod(sortedBy, sortDirection === 'asc' ? 1 : -1));
                this.datas = cloneData;
                this.sortDirection = sortDirection;
                this.sortedBy = sortedBy;
            }
        } else {
        }else{
            this.sortBy = event.detail.fieldName;
            console.log('this.sortBy==>' + this.sortBy);
            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);
            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)
            );
            cloneData.sort(this.sortByMethod(sortedBy, sortDirection === 'asc' ? 1 : -1));
            this.datas = cloneData;
            this.sortDirection = sortDirection;
            this.sortedBy = sortedBy;
        }
    }
    //分页
    handlePaginatorChange(event) {
   }
      //分页
      handlePaginatorChange(event) {
        this.recordsToDisplay = event.detail.recordsToDisplay;
        this.preSelected = event.detail.preSelected;
        if (this.recordsToDisplay && this.recordsToDisplay > 0) {
@@ -937,14 +723,12 @@
        }
    }
    handlePrevious() {
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.currentPageToken = Number(this.currentPageToken) - Number(this.pageSize);
        this.init();
    }
    handleNext() {
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.currentPageToken = Number(this.currentPageToken) + Number(this.pageSize);
        this.init();
    }
    handleFirst() {
@@ -953,8 +737,7 @@
    }
    handleLast() {
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.currentPageToken = this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.init();
    }