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 showSpinner = true; //表头样式 stylesLoaded = false; @track accSearch = ''; @track aooSearch = ''; @track limits; @track limitOpts = []; @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:"预测与OCSM签约日",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: "预测与OCSM签约日", 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() { 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'); }) } // 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) { this.aooSearch = event.detail.value; } limitsChange(event) { this.limits = event.detail.value; } numtext1Change(event) { this.numtext1 = event.detail.value; } numtext2Change(event) { this.numtext2 = event.detail.value; } numtextChange(event) { this.numtext = event.detail.value; } 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 (message != '') { content = '

' + title + '

' + message + '
'; } else { content = '

' + title + '

'; } 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; } }