/* 备品智能化 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';
|
// 事件补充 事件相关新增方法 start
|
import initEvent from '@salesforce/apex/lexCreateEventButton.initEvent';
|
// 事件补充 事件相关新增方法 end
|
|
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 isStartDis = false;
|
@track isEndDis = false;
|
@track isVisitDis = false;
|
@track isActivityPurposeDis = false;
|
@track isSubjectDis = false;
|
@track isPurposeTypeDis = 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 showServicefalg = 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},
|
];
|
|
// 事件补充 参数 start
|
@api event_in;
|
@api taskId;
|
@api accid;
|
@api cid;
|
@api oid;
|
@api mid;
|
@api source;
|
@api isDelay;
|
@api isBefore;
|
@track eveData;
|
// 事件补充 参数 end
|
@track allDisable = false; //20240228 sx add 询价置灰
|
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},
|
];
|
}
|
|
// 事件补充 初始化事件 start
|
@wire(initEvent, { eventid: '$recordId', taskId: '$taskId', accid: '$accid', cid: '$cid', oid: '$oid', mid: '$mid', source: '$source'})
|
wiredEvent({error, data}) {
|
console.log('isBefore is ' + this.isBefore);
|
console.log('recordid is ' + this.recordId);
|
console.log('event data is ' + JSON.stringify(data));
|
if (data) {
|
// 原始数据记录
|
console.log('data: ' + data);
|
this.eveData = data.eventData;
|
// 画面字段初始化
|
this.StartTime = data.eventData.StartDateTime;
|
console.log('data.StartDateTime: ' + this.eveData.StartDateTime);
|
this.EndTime = data.eventData.EndDateTime;
|
console.log('this.visit before init set:' + this.visit);
|
if (data.eventData.Activity_Type2__c) {
|
this.visit = data.eventData.Activity_Type2__c;
|
}
|
console.log('this.visit after init set:' + this.visit);
|
if (data.eventData.Activity_PurposeFSE__c) {
|
this.ActivityPurposeFSE = data.eventData.Activity_PurposeFSE__c
|
} else {
|
this.ActivityPurposeFSE = data.eventData.Activity_PurposeEscFSE__c;
|
}
|
this.filter = data.eventData.whatid__c;
|
if (data.eventData.Activity_PurposeFSE__c) {
|
this.PurposeTypeFSE = data.eventData.Purpose_TypeFSE__c;
|
} else {
|
this.PurposeTypeFSE = data.eventData.Purpose_TypeEscFSE__c;
|
}
|
this.Subject = data.eventData.Subject;
|
console.log('this.Subject after init set:' + this.Subject);
|
this.contactId1 = data.eventData.Visitor1_ID__c;
|
this.Related_Opportunity1_ID = data.eventData.Related_Opportunity1_ID__c;
|
console.log('oppid:' + data.eventData.Related_Opportunity1_ID__c);
|
console.log('this.Related_Opportunity1_ID after init set:' + this.Related_Opportunity1_ID);
|
this.Related_Service1_ID = data.eventData.Related_Service1_ID__c;
|
this.NoOppReason = data.eventData.noOpp_Reason__c;
|
if (data.eventData.OPDPlan_Flag__c) {
|
this.IsOPDPlan = data.eventData.OPDPlan_Flag__c;
|
}
|
//20240229 sx 事件修复bug start
|
if(data.eventData.Opd_Plan__c){
|
this.IsOPDPlan = true;
|
this.showEventfalg = true;
|
this.getOppQuoteItemsExecute();
|
}
|
//20240229 sx 事件修复bug end
|
this.Infrastructure_Project1 = data.eventData.Related_Opportunity4_ID__c;
|
// alldisbale增加
|
this.allDisable = data.allDisable; //20240228 sx add 询价置灰
|
if (data.allDisable) {
|
console.log('all disable');
|
this.isStartDis = true;
|
this.isEndDis = true;
|
this.isVisitDis = true;
|
this.isActivityPurposeDis = true;
|
this.isSubjectDis = true;
|
this.isPurposeTypeDis = true;
|
this.isAccDis = true;
|
this.isConDis = true;
|
this.isOppDis = true;
|
this.isProjectDis = true;
|
this.isNoOppDis = true;
|
this.isOpdPlanDis = true;
|
this.isServiceDis = true;
|
}
|
if (data.eventData.OPDPlan_Flag__c) {
|
console.log('opd flag');
|
this.isVisitDis = true;
|
this.isAccDis = true;
|
this.isOpdPlanDis = true;
|
}
|
if (data.isDisActivityPurposeFSE) {
|
this.isPurposeTypeDis = true;
|
}
|
// 所有编辑时都不允许修改拜访区分、科室
|
if(this.recordId || this.isDelay ==='true' || this.taskId){
|
console.log('is modify');
|
this.isVisitDis = true;
|
this.isAccDis = true;
|
this.isOppDis = true;
|
}
|
if (this.mid !== undefined) {
|
this.isServiceDis = true;
|
}
|
|
|
if(this.Related_Opportunity1_ID) {
|
this.isNoOppDis = true;
|
}
|
|
getOppQuoteItems({ records: '',recordId: this.Related_Opportunity1_ID }).then(result => {
|
// console.log('getOppQuoteItems处理结果:', result.length);
|
if(this.Related_Opportunity1_ID && this.Related_Opportunity1_ID !== ''){ //zzm 20240426 不关联询价时不能选择OPD计划bug修复
|
if(!result || result.length === 0 ){
|
this.isOpdPlanDis = true;
|
this.IsOPDPlan = false;
|
this.showEventfalg = false;
|
}else{
|
//20240228 sx opd是否能勾选start
|
if(this.recordId){
|
this.isOpdPlanDis = true;
|
}else{
|
this.isOpdPlanDis = false;
|
}
|
//20240228 sx opd是否能勾选end
|
}
|
}else{
|
if(this.visit === '病院'
|
&& this.isDelay!='true' && this.isDelay!=true && this.isBefore!='true' && this.isBefore!=true && this.allDisable!=true){ //zzm 20240228 延期和提前不能更改OPD计划
|
this.isOpdPlanDis = false;
|
} else {
|
this.isOpdPlanDis = true; //zzm 20240228 延期和提前不能更改OPD计划
|
}
|
}
|
}).catch(error => {
|
// 处理错误
|
console.error('getOppQuoteItems发生错误:', error);
|
|
});
|
} else if (error) {
|
console.log('initEvent错误------' + JSON.stringify(error));
|
}
|
}
|
// 事件补充 初始化事件 end
|
|
//页面计划出借备品数据
|
@wire(initPRE, { recordId: '$recordId' })
|
wiredPREItems({error,data}) {
|
this.data = data;
|
console.log('event_in:' + this.event_in);
|
if(this.recordId !== undefined){
|
console.log('this.recordId-----------' + this.recordId);
|
if(this.event_in == 'event'){
|
this.showEvent = true;
|
if (data !== undefined) {
|
if (data.length > 0) {
|
this.IsOPDPlan = true;
|
this.showEventfalg = true;
|
this.dataEvent = data;
|
}
|
}
|
}else{
|
this.showOPDPlan = true;
|
}
|
|
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));
|
//zzm 20240226 事件产品bug修复
|
getProductData({ recordId: this.recordId,event_in:this.event_in, 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 !== '' && this.Related_Opportunity1_ID){ //zzm 20240228 延期和提前不能更改OPD计划
|
if(result.length === 0 ){
|
this.isOpdPlanDis = true;
|
this.IsOPDPlan = false;
|
this.showEventfalg = false;
|
// this.Alert('询价下不存在报价或符合借出条件的报价行项目为空,不允许勾选OPD计划。','warning');
|
alert('询价下不存在报价或符合借出条件的报价行项目为空,不允许勾选OPD计划。');
|
}else{
|
//20240228 sx opd是否能勾选start
|
if(this.recordId){
|
this.isOpdPlanDis = true;
|
}else{
|
this.isOpdPlanDis = false;
|
}
|
//20240228 sx opd是否能勾选end
|
this.dataEvent = result;
|
this.data = result;
|
this.oppEventData = result;
|
}
|
}else{
|
if(this.visit === '病院'
|
&& this.isDelay!='true' && this.isDelay!=true && this.isBefore!='true' && this.isBefore!=true && this.allDisable!=true){ //zzm 20240228 延期和提前不能更改OPD计划
|
this.isOpdPlanDis = false;
|
} else {
|
this.isOpdPlanDis = true; //zzm 20240228 延期和提前不能更改OPD计划
|
}
|
this.oppEventData = result;
|
this.dataEvent = result;
|
this.data = result;
|
}
|
}).catch(error => {
|
// 处理错误
|
console.error('getOppQuoteItems发生错误:', error);
|
|
});
|
}
|
|
//删除备品数据
|
DeletetProduct(event) {
|
if(this.selectDeleteProductLine.length == 0) {
|
alert('请选择可以操作的行');
|
// 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');
|
alert('选中的备品已经绑定报价,不允许删除。');
|
// this.Alert('选中的备品已经绑定报价,不允许删除。');
|
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)) {
|
alert('有询价时,至少存在一个报价产品。');
|
// this.Alert('有询价时,至少存在一个报价产品。','error');
|
return;
|
}else{
|
this.dataEvent = itemsToKeep;
|
this.data = itemsToKeep;
|
}
|
this.selectDeleteProductLine = [];
|
}
|
}
|
}
|
|
//关闭产品查询页
|
//清空特定查询条件数据
|
CancelProductPage() {
|
if(this.event_in !== '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 = [];
|
var newEventDataArrayTmp = [...this.dataEvent];
|
if(this.selectCreateProductLine.length == 0){
|
// this.Alert('请选择可以操作的行','error');
|
alert('请选择可以操作的行');
|
return;
|
}
|
this.data.forEach(item => {
|
dataAdd.push(item);
|
});
|
console.log('dataAdd:' + dataAdd.length);
|
console.log('showEvent:' + this.showEvent);
|
console.log('selectCreateProductLine:' + this.selectCreateProductLine.length);
|
this.selectCreateProductLine.forEach(item => {
|
console.log('item:' + item);
|
if(this.showEvent == true){
|
newEventDataArrayTmp.push(item);
|
// 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.dataEvent = newEventDataArrayTmp;
|
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');
|
|
|
});
|
alert('追加成功');
|
}
|
|
@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
|
});
|
}
|
//zzm 20240226 事件产品bug修复
|
getProductData({ recordId: this.recordId,event_in:this.event_in, 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');
|
alert('保存成功');
|
location.reload();
|
}).catch(error => {
|
// 处理错误
|
console.error('saveProductData发生错误:', error);
|
});
|
}
|
connectedCallback(){
|
getNowDateTime().then(res=>{
|
if (res!=null) {
|
console.log('starttime:' + res);
|
if (this.recordId) {
|
} else {
|
this.StartTime = res;
|
}
|
}
|
});
|
getEndDateTime().then(res=>{
|
if (res!=null) {
|
console.log('endtime:' + res);
|
if (this.recordId) {
|
} else {
|
this.EndTime = res;
|
}
|
}
|
});
|
getUserJobCategory().then(res=>{
|
if (res!=null) {
|
if(res === '销售推广' && !this.allDisable && !this.isBefore && !this.isDelay){
|
this.isOppDis = false;
|
}
|
if(res === '销售服务'){
|
this.showServicefalg = true;
|
this.IsFSE = true;
|
}
|
}
|
});
|
this.visit = '病院';
|
this.visitorPalceObjName = 'SearchVisitorPlace';
|
this.isAccDis = false;
|
this.isConDis = false;
|
this.isOppDis = true;
|
//2024 add by dzk 编辑时,延期不可修改询价
|
if(this.isDelay === "true"){
|
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 === '基建项目'){
|
if(this.PurposeTypeFSE === '基建项目'){ //zzm 240115 事件基建项目bug修复
|
this.isProjectDis = false;
|
}
|
}
|
|
handleNoOppReasonChange(event){
|
this.NoOppReason = event.detail.value;
|
}
|
|
handleIsOPDPlanChange(event){
|
this.IsOPDPlan = event.detail.checked;
|
//zzm 20240131 勾选OPD计划时,提醒无询价的提示信息 start
|
if(this.IsOPDPlan==true && !this.Related_Opportunity1_ID) {
|
// this.Alert('您创建的OPD计划没有关联询价,需要审批到副总裁','error');
|
alert('您创建的OPD计划没有关联询价,需要审批到副总裁');
|
}
|
//zzm 20240131 勾选OPD计划时,提醒无询价的提示信息 end
|
this.showEventfalg = event.detail.checked;
|
|
this.getOppQuoteItemsExecute();
|
|
}
|
|
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;
|
}
|
console.log('check visit change:' + changeFlg);
|
|
this.isVisitDis = changeFlg;
|
}
|
|
SaveAndEventData(){
|
const CreateAndSave = true;
|
this.SaveOrCreateEventData(CreateAndSave);
|
}
|
SaveEventData() {
|
const CreateAndSave = false;
|
this.SaveOrCreateEventData(CreateAndSave);
|
}
|
//追加备品数据
|
SaveOrCreateEventData(CreateAndSave) {
|
let recordId;
|
console.log('this.visit--------' + this.Subject);
|
let screenData = {
|
"EventId" : this.recordId,
|
"TaskId" : this.taskId,
|
"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,
|
"isDelay" : this.isDelay,
|
"isBefore" : this.isBefore,
|
"Subject" : this.Subject
|
};
|
console.log('ActivityType2 :' + this.visit);
|
console.log('ActivityPurposeFSE :' + this.ActivityPurposeFSE);
|
console.log('====zzzm=====this.isBefore :' + this.isBefore);
|
this.showSpinner = true;
|
saveLogic({ records: JSON.stringify(screenData),products: JSON.stringify(this.dataEvent) }).then(result => {
|
console.log('result:' + result);
|
if(result === 'Success'){
|
saveEvent({ records: JSON.stringify(screenData),products: JSON.stringify(this.dataEvent) }).then(result => {
|
if(result.indexOf('ERROR') >= 0){
|
// this.Alert(result,'error');
|
alert(result);
|
this.showSpinner = false;
|
return;
|
}else{
|
// this.Alert('保存成功','success');
|
alert('保存成功');
|
if(CreateAndSave === true){
|
window.open("/lightning/o/Event/new",'_self');
|
}else{
|
// DB202312502818 zzm 20240110 start
|
// window.open("/lightning/r/Event/"+result+"/view",'_self');
|
window.open("/lightning/o/Event/home",'_self');
|
// DB202312502818 zzm 20240110 end
|
}
|
}
|
// 处理 Apex 方法的返回结果
|
}).catch(error => {
|
// 处理错误
|
console.error('saveEvent发生错误:', error);
|
// this.Alert(result,'error');
|
alert(result);
|
this.showSpinner = false;
|
return;
|
});
|
}else{
|
// this.Alert(result,'error');
|
alert(result);
|
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);
|
}
|
}
|