/* 备品智能化 add by dzk
|
OPD计划备品明细页面功能
|
日历-新建事件页面功能重构
|
*/
|
|
import { LightningElement ,api, wire, track } from 'lwc';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { CurrentPageReference } from 'lightning/navigation';
|
import initPRE from '@salesforce/apex/LexOPDPlanProdController.initPRE';
|
import getEditPermission from '@salesforce/apex/LexOPDPlanProdController.getEditPermission';
|
import getProductData from '@salesforce/apex/LexOPDPlanProdController.getProductData';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import initOriginal from '@salesforce/apex/LexOPDPlanProdController.initOriginal';
|
import getPicklistValues from '@salesforce/apex/LexOPDPlanProdController.getPicklistValues';
|
import getNowDateTime from '@salesforce/apex/lexCreateEventButton.getNowDateTime';
|
import getEndDateTime from '@salesforce/apex/lexCreateEventButton.getEndDateTime';
|
import saveEvent from '@salesforce/apex/lexCreateEventButton.saveEvent';
|
import saveLogic from '@salesforce/apex/lexCreateEventButton.saveLogic';
|
import saveProductData from '@salesforce/apex/LexOPDPlanProdController.saveProductData';
|
import getUserJobCategory from '@salesforce/apex/lexCreateEventButton.getUserJobCategory';
|
import getOppQuoteItems from '@salesforce/apex/lexCreateEventButton.getOppQuoteItems';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
|
export default class lexOPDPlanProd extends NavigationMixin(LightningElement) {
|
@api recordId;
|
@track SearchModelName = '';
|
@track data;
|
@track edit;
|
@track originalOpd;
|
@track oppEventData;
|
@track IsOPDPlan = false;
|
@track showEventfalg = false;
|
@track showEvent = false;
|
@track isLoading = false;
|
@track showOPDPlan = false;
|
@track showproductfalg = false;
|
@track dataProduct = [];
|
@track selectDeleteProductLine = [];
|
@track selectCreateProductLine = [];
|
@track visit = '';
|
@track ActivityPurposeFSE = '';
|
@track PurposeTypeFSE = '';
|
@track NoOppReason = '';
|
@api theIndex;
|
@track isVisitDis = false;
|
@track isAccDis = true;
|
@track isConDis = true;
|
@track isOppDis = true;
|
@track isProjectDis = true;
|
@track isNoOppDis = false;
|
@track isOpdPlanDis = false;
|
@track isServiceDis = true;
|
@track showSpinner = false;
|
@track filter = '';
|
@track visitorPalceObjName = '';
|
@track visitorPalceFields = ['Account.Name'];
|
@track opportunityFields = ['Opportunity.Name'];
|
@track mcFields = ['Maintenance_Contract__c.Name'];
|
@track infrastructureProjectFields = ['Infrastructure_Project__c.Name'];
|
@track Related_Opportunity1_ID = '';
|
|
@track contactId1 = '';
|
@track objectName = 'Contact';
|
@track fields=['Contact.Name','Contact.AWS_Data_Id__c'];
|
@track StartTime;
|
@track EndTime;
|
@track Subject;
|
@track visible = false;
|
@track IsFSETG = false;
|
@track IsFSE = false;
|
@track columns = [
|
{
|
label: '计划借出备品',
|
fieldName: 'Name',
|
type: 'text',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
},
|
{
|
label: '借出数量',
|
fieldName: 'Quantity',
|
type: 'number',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
},
|
{
|
label: '产品代码',
|
fieldName: 'ProductCode',
|
type: 'text',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
},
|
{
|
label: '产品型号',
|
fieldName: 'ProductModel',
|
type: 'text',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
// headerAttributes: { class: 'custom-header-cell' }
|
},
|
|
];
|
|
@track columnProduct = [
|
{label: '计划借出备品',fieldName: 'Name',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '借出数量',fieldName: 'Quantity',type: 'number',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '产品代码',fieldName: 'ProductCode',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '产品型号',fieldName: 'ProductModel',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
];
|
connectedCallback(){
|
this.columnProduct = [
|
{label: '计划借出备品',fieldName: 'Name',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '借出数量',fieldName: 'Quantity',type: 'number',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '产品代码',fieldName: 'ProductCode',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '产品型号',fieldName: 'ProductModel',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
];
|
}
|
|
//页面计划出借备品数据
|
@wire(initPRE, { recordId: '$recordId' })
|
wiredPREItems({error,data}) {
|
this.data = data;
|
if(this.recordId !== undefined){
|
console.log('this.recordId-----------' + this.recordId);
|
if(this.recordId == 'event'){
|
this.showEvent = true;
|
}else{
|
this.showOPDPlan = true;
|
}
|
|
if(this.recordId.substring(0,3) !== '701'){
|
this.columns = [{
|
label: '计划借出备品',
|
fieldName: 'Name',
|
type: 'text',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
},
|
{
|
label: '借出数量',
|
fieldName: 'Quantity',
|
type: 'number',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
},
|
{
|
label: '报价编码',
|
fieldName: 'QuoteNo',
|
type: 'text',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
},
|
{
|
label: '产品代码',
|
fieldName: 'ProductCode',
|
type: 'text',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
},
|
{
|
label: '产品型号',
|
fieldName: 'ProductModel',
|
type: 'text',
|
cellAttributes: {
|
alignment: 'left'
|
},
|
hideDefaultActions: true,
|
|
},
|
];
|
this.columnProduct = [
|
{label: '计划借出备品',fieldName: 'Name',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '借出数量',fieldName: 'Quantity',type: 'number',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '产品代码',fieldName: 'ProductCode',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
{label: '产品型号',fieldName: 'ProductModel',type: 'text',cellAttributes: {alignment: 'left'},hideDefaultActions: true},
|
];
|
}
|
}
|
}
|
|
//当前用户是否拥有编辑OPD计划权限
|
@wire(getEditPermission, { recordId: '$recordId' })
|
wiredEditPermission({error,data}) {
|
if (data) {
|
this.edit = data;
|
} else if (error) {
|
console.log('getEditPermission错误------' + JSON.stringify(error));
|
}
|
}
|
|
@wire(initOriginal, { recordId: '$recordId' })
|
wiredOriginalItems({error,data}) {
|
if (data) {
|
this.OriginalOpd = data.OriginalOpdPlanApplication__c;
|
|
} else if (error) {
|
console.log('init------' + JSON.stringify(error));
|
}
|
}
|
//产品选择复选框勾选
|
handleRowSelect(event) {
|
const selectedRows = event.detail.selectedRows;
|
this.selectCreateProductLine = selectedRows;
|
// 在这里处理选中的行数据
|
}
|
|
//计划备品复选框勾选
|
handleRowData(event) {
|
const selectedRows = event.detail.selectedRows;
|
this.selectDeleteProductLine = selectedRows;
|
}
|
|
|
//展开数据查询页
|
//显示符合条件的奥林巴斯产品
|
SelectProducts(event){
|
this.showproductfalg = true;
|
// let trimmedString = this.SearchModelName.trim();
|
console.log('recordId-----------' + JSON.stringify(this.data));
|
getProductData({ recordId: this.recordId, records: JSON.stringify(this.data), productmodel: this.SearchModelName }).then(result => {
|
// 处理 Apex 方法的返回结果
|
this.dataProduct = result;
|
}).catch(error => {
|
// 处理错误
|
console.error('发生错误:', error);
|
});
|
}
|
|
|
getOppQuoteItemsExecute(){
|
getOppQuoteItems({ records: JSON.stringify(this.dataEvent),recordId: this.Related_Opportunity1_ID }).then(result => {
|
console.log('getOppQuoteItems处理结果:', result.length);
|
if(this.isNoOppDis === true && this.Related_Opportunity1_ID !== ''){
|
if(result.length === 0 ){
|
this.isOpdPlanDis = true;
|
this.IsOPDPlan = false;
|
this.showEventfalg = false;
|
this.Alert('询价下不存在报价或符合借出条件的报价行项目为空,不允许勾选OPD计划。','warning');
|
}else{
|
this.isOpdPlanDis = false;
|
this.dataEvent = result;
|
this.data = result;
|
this.oppEventData = result;
|
}
|
}else{
|
if(this.visit === '病院'){
|
this.isOpdPlanDis = false;
|
}
|
this.oppEventData = result;
|
this.dataEvent = result;
|
this.data = result;
|
}
|
}).catch(error => {
|
// 处理错误
|
console.error('getOppQuoteItems发生错误:', error);
|
|
});
|
}
|
|
//删除备品数据
|
DeletetProduct(event) {
|
if(this.selectDeleteProductLine.length == 0) {
|
this.Alert('请选择可以操作的行','error');
|
} else{
|
if(this.showEvent == false){
|
for (var i = 0; i < this.selectDeleteProductLine.length; i++) {
|
var selectQuoteNo = this.selectDeleteProductLine[i].QuoteNo;
|
console.log('this.OriginalOpd-----------' + this.OriginalOpd);
|
if(selectQuoteNo != null && (this.OriginalOpd === null || this.OriginalOpd === '' || this.OriginalOpd === undefined)) {
|
this.Alert('选中的备品已经绑定报价,不允许删除。','error');
|
return;
|
}
|
}
|
const dataDelete = [];
|
|
this.data.forEach(item => {
|
dataDelete.push(item);
|
});
|
this.selectDeleteProductLine.forEach(item => {
|
const index = dataDelete.findIndex(data => data.ProductCode === item.ProductCode);
|
if(index !== -1){
|
dataDelete.splice(index,1);
|
this.data = dataDelete
|
this.selectDeleteProductLine = [];
|
}
|
});
|
}
|
else{
|
|
for(var de = 0; de < this.selectDeleteProductLine.length; de++) {
|
for(var event = 0; event < this.dataEvent.length; event++) {
|
if(this.selectDeleteProductLine[de].ProductCode == this.dataEvent[event].ProductCode){
|
var itemsToKeep = this.dataEvent.filter(item => !this.selectDeleteProductLine.some(selectedItem => selectedItem.ProductCode === item.ProductCode));
|
}
|
}
|
}
|
var quoteNum = 0;
|
itemsToKeep.forEach((row,index) => {
|
if(row.QuoteNo !== null && row.QuoteNo !== '' && row.QuoteNo !== undefined){
|
quoteNum++;
|
}
|
});
|
if(quoteNum === 0 && (this.Related_Opportunity1_ID !== '' && this.Related_Opportunity1_ID !== null && this.Related_Opportunity1_ID !== undefined)) {
|
this.Alert('有询价时,至少存在一个报价产品。','error');
|
return;
|
}else{
|
this.dataEvent = itemsToKeep;
|
this.data = itemsToKeep;
|
}
|
this.selectDeleteProductLine = [];
|
}
|
}
|
}
|
|
//关闭产品查询页
|
//清空特定查询条件数据
|
CancelProductPage() {
|
if(this.recordId !== 'event'){
|
this.showOPDPlan = true;
|
this.showproductfalg = false;
|
}else{
|
this.showEventfalg = true;
|
this.showproductfalg = false;
|
}
|
this.dataProduct = null;
|
this.SearchModelName = null;
|
}
|
|
//产品型号输入框获取输入值
|
ProductModelChange(event){
|
if(this.SearchModelName != event.target.value){
|
this.SearchModelName = event.target.value;
|
}
|
}
|
|
@track dataEvent = [];
|
|
//追加备品数据
|
AddProduct() {
|
const dataAdd = [];
|
if(this.selectCreateProductLine.length == 0){
|
this.Alert('请选择可以操作的行','error');
|
return;
|
}
|
this.data.forEach(item => {
|
dataAdd.push(item);
|
});
|
this.selectCreateProductLine.forEach(item => {
|
if(this.showEvent == true){
|
|
this.dataEvent.push(item);
|
console.log('this.oppEventData-----------' + JSON.stringify(this.oppEventData));
|
if(this.oppEventData === null || this.oppEventData === '' || this.oppEventData === undefined){
|
|
}else{
|
// console.log('this.oppEventData-----------' + JSON.stringify(this.oppEventData));
|
for (let i = 0; i < this.dataEvent.length; i++) {
|
let productCode1 = this.dataEvent[i].ProductCode;
|
let matchingItem = this.oppEventData.find(item => item.ProductCode === productCode1);
|
if (matchingItem) {
|
this.dataEvent[i].QuoteNo = matchingItem.QuoteNo;
|
this.dataEvent[i].QuoteId = matchingItem.QuoteId;
|
}
|
}
|
}
|
|
const newEventDataArray = [...this.dataEvent];
|
this.dataEvent = newEventDataArray;
|
this.data = this.dataEvent;
|
}else{
|
dataAdd.push(item);
|
this.data = dataAdd;
|
}
|
const index = this.dataProduct.findIndex(data => data.ProductCode === item.ProductCode);
|
if(index !== -1){
|
this.dataProduct.splice(index,1);
|
const newDataArray = [...this.dataProduct];
|
this.dataProduct = newDataArray;
|
}
|
|
this.Alert('追加成功','success');
|
});
|
}
|
|
@track dataChecked = [];
|
//查询符合条件的产品数据
|
SelectProductItem(event){
|
|
const modifiedData = [];
|
for (const change of this.selectCreateProductLine) {
|
modifiedData.push({ Name: change.Name,
|
Quantity: change.Quantity,
|
ProductCode: change.ProductCode,
|
FixtureModel: change.FixtureModel,
|
ProductModel: change.ProductModel,
|
_selected: true
|
});
|
}
|
getProductData({ recordId: this.recordId, records: JSON.stringify(this.data), productmodel: this.SearchModelName }).then(result => {
|
// 处理 Apex 方法的返回结果
|
|
result.forEach(item => {
|
const index = this.selectCreateProductLine.findIndex(data => data.ProductCode === item.ProductCode);
|
if(index === -1){
|
modifiedData.push(item);
|
}
|
});
|
|
this.dataProduct = modifiedData;
|
this.applySelectedRows();
|
}).catch(error => {
|
// 处理错误
|
console.error('getProductData发生错误:', error);
|
});
|
}
|
|
applySelectedRows() {
|
// 在新数据中标记已选中的行
|
this.dataProduct = this.dataProduct.map(row => {
|
if (this.selectCreateProductLine.some(selectedRow => selectedRow.ProductCode === row.ProductCode)) {
|
row._selected = true;
|
}
|
return row;
|
});
|
}
|
|
SavetProduct(event){
|
saveProductData({ records: JSON.stringify(this.data) ,recordId: this.recordId}).then(result => {
|
// 处理 Apex 方法的返回结果
|
this.Alert('保存成功','success');
|
location.reload();
|
}).catch(error => {
|
// 处理错误
|
console.error('saveProductData发生错误:', error);
|
});
|
}
|
connectedCallback(){
|
getNowDateTime().then(res=>{
|
if (res!=null) {
|
console.log(res);
|
this.StartTime = res;
|
}
|
});
|
getEndDateTime().then(res=>{
|
if (res!=null) {
|
console.log(res);
|
this.EndTime = res;
|
}
|
});
|
getUserJobCategory().then(res=>{
|
if (res!=null) {
|
if(res !== '销售推广'){
|
this.IsFSETG = true;
|
this.isServiceDis = false;
|
}
|
if(res === '销售服务'){
|
this.IsFSE = true;
|
}
|
}
|
});
|
this.visit = '病院';
|
this.visitorPalceObjName = 'SearchVisitorPlace';
|
this.isAccDis = false;
|
this.isConDis = false;
|
this.isOppDis = true;
|
|
}
|
//询价
|
handleOppertunity1Selection(event) {
|
this.Related_Opportunity1_ID = event.detail.selectedId;
|
if(this.Related_Opportunity1_ID !== '' && this.Related_Opportunity1_ID !== undefined && this.Related_Opportunity1_ID !== null){
|
this.isNoOppDis = true;
|
this.NoOppReason = '';
|
this.getOppQuoteItemsExecute();
|
}else{
|
this.isNoOppDis = false;
|
this.getOppQuoteItemsExecute();
|
}
|
this.checkVisitChange();
|
}
|
|
//访问对象
|
handleAccSelection(event) {
|
this.filter = event.detail.selectedId;
|
if(this.filter !== null && this.filter !== '' && this.filter !== undefined){
|
this.isOppDis = false;
|
}else{
|
this.isOppDis = true;
|
this.Related_Opportunity1_ID = '';
|
}
|
this.changeAccId();
|
this.checkVisitChange();
|
}
|
|
changeAccId(){
|
//清空访问对象
|
const childComponents = this.template.querySelectorAll('c-look-up-util-event');
|
console.log(childComponents.length);
|
if (childComponents.length > 0) {
|
childComponents.forEach(childComponent => {
|
childComponent.handleRemovePill();
|
});
|
}
|
//清空其他查询组件
|
const otherComponents = this.template.querySelectorAll('c-other-look-up-event');
|
console.log(otherComponents.length);
|
if (otherComponents.length > 0) {
|
otherComponents.forEach(otherComponent => {
|
console.log('清空其他查询组件:')
|
console.log(otherComponent['uniqueKey'])
|
if(otherComponent['uniqueKey'] !='AccountID') {
|
otherComponent.handleRemovePill();
|
|
}
|
});
|
}
|
this.visitDis = false;
|
|
}
|
//拜访区分列表值
|
@track optionsActivityType2 = [];
|
@wire(getPicklistValues, { objstr:'Event',fld:'Activity_Type2__c' })
|
wiredType2PicklistValues({error,data}) {
|
this.optionsActivityType2 = data;
|
}
|
|
//拜访目的(FSE外)列表值
|
@track optionsActivityPurposeFSE = [];
|
@wire(getPicklistValues, { objstr:'Event',fld:'Activity_PurposeEscFSE__c' })
|
wiredEscFSEPicklistValues({error,data}) {
|
this.optionsActivityPurposeFSE = data;
|
}
|
|
//活动区分FSE外列表值
|
@track optionsActivityPurposeEscFSE = [];
|
@wire(getPicklistValues, { objstr:'Event',fld:'Purpose_TypeEscFSE__c' })
|
wiredTypeEscFSEPicklistValues({error,data}) {
|
this.optionsActivityPurposeEscFSE = data;
|
}
|
|
//无询价申请理由列表值
|
@track optionsNoOppReason = [];
|
@wire(getPicklistValues, { objstr:'Event',fld:'noOpp_Reason__c' })
|
wiredReasonPicklistValues({error,data}) {
|
this.optionsNoOppReason = data;
|
}
|
|
handleStartTimeChange(event){
|
this.StartTime = event.detail.value;
|
}
|
|
handleEndTimeChange(event){
|
this.EndTime = event.detail.value;
|
}
|
handleSubjectChange(event){
|
this.Subject = event.detail.value;
|
}
|
|
handleActivityType2Change(event){
|
|
this.isAccDis = true;
|
this.isConDis = true;
|
this.isOppDis = true;
|
this.isProjectDis = true;
|
this.isOpdPlanDis = true;
|
this.isServiceDis = true;
|
this.visit = event.detail.value;
|
this.PurposeTypeFSE = '';
|
this.ActivityPurposeFSE = '';
|
this.NoOppReason = '';
|
this.IsOPDPlan = false;
|
this.filter = '';
|
this.contactId1 = '';
|
this.Related_Opportunity1_ID = '';
|
this.Infrastructure_Project1 = '';
|
this.Related_Service1_ID = '';
|
this.showEventfalg = false;
|
this.dataEvent = [];
|
this.data = [];
|
const otherComponents = this.template.querySelectorAll('c-other-look-up-event');
|
if (otherComponents.length > 0) {
|
otherComponents.forEach(otherComponent => {
|
console.log('清空访问场所组件:')
|
console.log(otherComponent['uniqueKey'])
|
if(otherComponent['uniqueKey'] =='AccountID') {
|
otherComponent.handleRemovePill();
|
}
|
});
|
}
|
if(this.visit === '病院'){
|
this.visitorPalceObjName = 'SearchVisitorPlace';
|
this.isAccDis = false;
|
this.isConDis = false;
|
// this.isOppDis = true;
|
this.isNoOppDis = false;
|
this.isOpdPlanDis = false;
|
this.isServiceDis = false;
|
}else if(this.visit === '販売店'){
|
this.visitorPalceObjName = 'SearchVisitorPlace_Sales';
|
this.isAccDis = false;
|
// this.isOppDis = true;
|
this.isNoOppDis = false;
|
}else if(this.visit === '社内活動'){
|
this.visitorPalceObjName = 'SearchVisitorPlace_Training';
|
this.isAccDis = false;
|
this.isNoOppDis = true;
|
}else if(this.visit === '社外イベント'){
|
this.visitorPalceObjName = 'SearchVisitorPlace_Campaign';
|
this.visitorPalceFields = ['Campaign.Name'];
|
this.isAccDis = false;
|
this.isNoOppDis = true;
|
}else {
|
this.isAccDis = true;
|
this.isNoOppDis = true;
|
}
|
this.filter = '';
|
}
|
|
handleActivityPurposeFSEChange(event){
|
this.ActivityPurposeFSE = event.detail.value;
|
}
|
|
handleActivityPurposeEscFSEChange(event){
|
this.PurposeTypeFSE = event.detail.value;
|
if(this.visit === '基建项目'){
|
this.isProjectDis = false;
|
}
|
}
|
|
handleNoOppReasonChange(event){
|
this.NoOppReason = event.detail.value;
|
}
|
|
handleIsOPDPlanChange(event){
|
this.IsOPDPlan = event.detail.checked;
|
this.showEventfalg = event.detail.checked;
|
}
|
|
handleNewRecord(event){
|
const openPageEvent = new CustomEvent('openpage', {
|
detail: { activeContentIndex:this.theIndex,lookUpKey:event.detail.key },
|
});
|
this.dispatchEvent(openPageEvent);
|
}
|
|
//访问对象
|
handleSelection(event) {
|
var key = event.detail.key;
|
if(key==='AgencyContact1'){
|
this.requiredVisitor = '';
|
this.contactId1 = event.detail.selectedId;
|
}
|
|
this.checkVisitChange();
|
}
|
|
|
|
@track Infrastructure_Project1;
|
//基建项目
|
handleInfrastructureProject1Selection(event) {
|
this.Infrastructure_Project1 = event.detail.selectedId;
|
this.checkVisitChange();
|
}
|
|
//维修合同
|
@track Related_Service1_ID;
|
handleMCSelection(event) {
|
this.Related_Service1_ID = event.detail.selectedId;
|
this.checkVisitChange();
|
|
}
|
|
//设置拜访区分是否可点击
|
checkVisitChange() {
|
console.log('checkVisitChange start');
|
var changeFlg = false;
|
if(this.contactId1){
|
changeFlg = true;
|
}
|
|
this.isVisitDis = changeFlg;
|
}
|
|
SaveAndEventData(){
|
const CreateAndSave = true;
|
this.SaveOrCreateEventData(CreateAndSave);
|
}
|
SaveEventData() {
|
const CreateAndSave = false;
|
this.SaveOrCreateEventData(CreateAndSave);
|
}
|
//追加备品数据
|
SaveOrCreateEventData(CreateAndSave) {
|
let recordId;
|
let screenData = {
|
"StartTime" : this.StartTime,
|
"EndTime" : this.EndTime,
|
"ActivityType2" : this.visit,
|
"PurposeTypeFSE" : this.PurposeTypeFSE,//活动区分
|
"ActivityPurposeFSE" : this.ActivityPurposeFSE,//拜访目的
|
"NoOppReason" : this.NoOppReason,
|
"IsOPDPlan" : this.IsOPDPlan,
|
"AccountId" : this.filter,
|
"ContactId" : this.contactId1,
|
"OpportunityId" : this.Related_Opportunity1_ID,
|
"ProjectId" : this.Infrastructure_Project1,
|
"ServiceId" : this.Related_Service1_ID,
|
"Subject" : this.Subject
|
};
|
this.showSpinner = true;
|
saveLogic({ records: JSON.stringify(screenData),products: JSON.stringify(this.dataEvent) }).then(result => {
|
if(result == 'Success'){
|
saveEvent({ records: JSON.stringify(screenData),products: JSON.stringify(this.dataEvent) }).then(result => {
|
if(result.length !== 18){
|
this.Alert(result,'error');
|
this.showSpinner = false;
|
return;
|
}else{
|
this.Alert('保存成功','success');
|
if(CreateAndSave === true){
|
window.open("/lightning/o/Event/new",'_self');
|
}else{
|
window.open("/lightning/r/Event/"+result+"/view",'_self');
|
}
|
}
|
// 处理 Apex 方法的返回结果
|
}).catch(error => {
|
// 处理错误
|
console.error('saveEvent发生错误:', error);
|
this.Alert(result,'error');
|
this.showSpinner = false;
|
return;
|
});
|
}else{
|
this.Alert(result,'error');
|
this.showSpinner = false;
|
return;
|
}
|
|
// 处理 Apex 方法的返回结果
|
}).catch(error => {
|
// 处理错误
|
console.error('saveLogic发生错误:', error);
|
});
|
|
}
|
|
CancelEventData(){
|
this.showSpinner = true;
|
window.open("/lightning/o/Event/home",'_self');
|
// this.showSpinner = false;
|
}
|
|
Alert(msg,type) {
|
const customEvent = new CustomEvent('customEventName', {
|
detail: {
|
message: msg,
|
type: type,
|
},
|
});
|
window.dispatchEvent(customEvent);
|
}
|
}
|