import { LightningElement , wire, api} from 'lwc';
|
import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { updateRecord } from 'lightning/uiRecordApi';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import LightningConfirm from 'lightning/confirm';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
|
import init from '@salesforce/apex/ConsumApplyApprovalProcessController.initSubmitApprovalProcessController';
|
import selectCampaignById from '@salesforce/apex/ConsumApplyApprovalProcessController.selectCampaignById';
|
import selectReportById from '@salesforce/apex/ConsumApplyApprovalProcessController.selectReportById';
|
import selectEquipmentById from '@salesforce/apex/ConsumApplyApprovalProcessController.selectEquipmentById';
|
import approvalCheck from '@salesforce/apex/ConsumApplyApprovalProcessController.approvalCheck';
|
// import setSObjectShare from '@salesforce/apex/ConsumApplyApprovalProcessController.setSObjectShare';
|
import setSObjectShare from '@salesforce/apex/ControllerUtil.setSObjectShare';
|
import updateConsumApply from '@salesforce/apex/ConsumApplyApprovalProcessController.updateConsumApply';
|
// import setSObjectShare from '@salesforce/apex/ControllerUtil.setSObjectShare';
|
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';//kk 贸易合规2期 20240125 add
|
import IFTradeComplianceAlert2 from '@salesforce/label/c.IFTradeComplianceAlert2'; //kk 贸易合规2期 20240125 add
|
import tradeConsumTempleSend from '@salesforce/apex/SendEmailUtil.tradeConsumTempleSend'; //贸易合规二期 发邮件20240130
|
|
export default class LexConsumApplySubmitApprovalProcess extends LightningElement {
|
|
@api recordId;
|
id;
|
shippingDays;//希望到货日前7个工作日
|
shippingDay;//希望到货日
|
campaign ;//学会
|
qISNumber;//QIS
|
qISIDLine;//QIS的ID值
|
status;// 状态
|
minApprovalDate;//最小可以提交申请日期
|
applyUser;//操作者
|
jingliManager;//CL6 经理级(服务)
|
salesManager;//CL6 经理级
|
buchangManager;//CL5 总监级(服务)
|
buchangManagerSale;//CL5 总监级
|
zongjianManager;//CL4 高级总监
|
accDealerBlacklistc;//客户是否为黑名单
|
tradeComplianceStatusFlagBP;//贸易合规开关
|
iFTradeComplianceAlertBP;//贸易合规提醒
|
owner;//所有人
|
directSend;//发送方
|
// 20240103 fy DB202312530994 start
|
medicalInstitutionAddress;//医疗机构地址
|
medicalInstitutionAddresssup;//医疗机构地址补充
|
createdDate;//创建日期
|
// 20240103 fy DB202312530994 end
|
accountTradeStatus;//kk 20240121 贸易合规2 add
|
hgerqi;//kk 20240121 贸易合规2 add
|
accountName;//kk 20240121 贸易合规2 add
|
IsLoading = true;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
console.log("str:"+str);
|
this.recordId = str;
|
}
|
}
|
}
|
|
|
connectedCallback(){
|
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
|
init({recordId : this.recordId}).then( result => {
|
this.IsLoading = false;
|
console.log('result'+result);
|
if(result!= null){
|
this.IsLoading = false;
|
this.id = result.id;
|
this.shippingDays = result.shippingDays;
|
this.shippingDay = result.shippingDay;
|
this.campaign = result.campaign;
|
this.qISNumber = result.qISNumber;
|
this.qISIDLine = result.qISIDLine;
|
this.status = result.status;
|
this.minApprovalDate = result.minApprovalDate;
|
this.applyUser = result.applyUser;
|
this.jingliManager = result.jingliManager;
|
this.salesManager = result.salesManager;
|
this.buchangManager = result.buchangManager;
|
this.buchangManagerSale = result.buchangManagerSale;
|
this.zongjianManager = result.zongjianManager;
|
this.accDealerBlacklistc = result.accDealerBlacklistc;
|
this.tradeComplianceStatusFlagBP = result.tradeComplianceStatusFlagBP;
|
this.iFTradeComplianceAlertBP = result.iFTradeComplianceAlertBP;
|
this.owner = result.owner;
|
this.directSend = result.directSend;
|
// 20240103 fy DB202312530994 start
|
this.medicalInstitutionAddress = result.medicalInstitutionAddress;
|
this.medicalInstitutionAddresssup = result.medicalInstitutionAddresssup;
|
this.createdDate = result.createdDate;
|
// 20240103 fy DB202312530994 end
|
//kk 20240121 贸易合规2 add start
|
this.accountTradeStatus = result.accountTradeStatus;
|
this.hgerqi = result.hgerqi;
|
this.accountName = result.accountName;
|
//kk 20240121 贸易合规2 add end
|
|
//kk 20240121 贸易合规一期的东西 暂时注释掉
|
// if(this.tradeComplianceStatusFlagBP == 'true' && this.accDealerBlacklistc =='1'){
|
// this.showToast(this.iFTradeComplianceAlertBP,'error');
|
// return;
|
// }
|
console.log('hgerqi=='+this.hgerqi);
|
//kk 20240121 贸易合规2 add start
|
if(this.tradeComplianceStatusFlagBP == 'true' &&this.accountTradeStatus == '黑名单'){
|
this.showToast('医院在黑名单中,存在贸易合规风险,无法继续提交待审批,'+IFTradeComplianceAlert,'error');
|
tradeConsumTempleSend({consumlId: this.recordId, stepName:'提交待审批'}); //贸易合规二期 发邮件20240130
|
return;
|
}
|
if(this.tradeComplianceStatusFlagBP == 'true' &&this.accountTradeStatus == '冻结,人工审批中'){
|
this.showToast( '医院在冻结清单中,可能存在贸易合规风险,目前正在评估中(一般需5-10个工作日),暂时无法提交待审批,'+IFTradeComplianceAlert,'error');
|
tradeConsumTempleSend({consumlId: this.recordId, stepName:'提交待审批'}); //贸易合规二期 发邮件20240130
|
return;
|
}
|
if(this.tradeComplianceStatusFlagBP == 'true' &&this.hgerqi == 'true'){
|
LightningConfirm.open({
|
message: '您此次申请的业务可能存在贸易合规风险,是否继续提交待审批,'+IFTradeComplianceAlert2+'(一般需5-10个工作日)。',
|
variant: 'headerless',
|
label: 'this is the aria-label value'
|
}).then(confirm=>{
|
if(!confirm){
|
this.IsLoading = false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
else{
|
var today = new Date();
|
var shipping = new Date(this.shippingDays);
|
console.log('shipping'+shipping);
|
console.log('today'+today);
|
if(shipping < today){
|
this.showToast('此申请已不满足(希望到货日-7工作日)前完成审批的情况,请重新修改申请。','error');
|
return;
|
}
|
|
LightningConfirm.open({
|
message: "一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?\n\n※ 需要在"
|
+this.shippingDays+"前完成审批,否则申请单自动取消。",
|
variant: 'headerless',
|
}).then(submit=>{
|
if(!submit){
|
this.IsLoading = false;
|
this.showToast('已取消','error')
|
return;
|
}else{
|
console.log('shippingDay-----'+this.shippingDay);
|
|
if(shipping < today){
|
this.showToast('希望到货日不能早于申请提交日','error');
|
return;
|
}
|
this.applySubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
|
}
|
}).catch(error => {
|
this.showToast(error,'error')
|
})
|
}
|
});
|
}
|
else{
|
var today = new Date();
|
var shipping = new Date(this.shippingDays);
|
console.log('shipping'+shipping);
|
console.log('today'+today);
|
if(shipping < today){
|
this.showToast('此申请已不满足(希望到货日-7工作日)前完成审批的情况,请重新修改申请。','error');
|
return;
|
}
|
|
LightningConfirm.open({
|
message: "一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?\n\n※ 需要在"
|
+this.shippingDays+"前完成审批,否则申请单自动取消。",
|
variant: 'headerless',
|
}).then(submit=>{
|
if(!submit){
|
this.IsLoading = false;
|
this.showToast('已取消','error')
|
return;
|
}else{
|
console.log('shippingDay-----'+this.shippingDay);
|
|
if(shipping < today){
|
this.showToast('希望到货日不能早于申请提交日','error');
|
return;
|
}
|
this.applySubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
|
}
|
}).catch(error => {
|
this.showToast(error,'error')
|
})
|
}
|
//kk 20240121 贸易合规2 add end
|
}else{
|
this.IsLoading = false;
|
this.showToast('result为空','error')
|
return;
|
}
|
|
})
|
|
}
|
|
async applySubmit(){
|
console.log('directSend==='+this.directSend);
|
//20231106 sx 课题DB202310484652 add start
|
if(this.directSend =='办事处' || this.directSend =='经销商' || this.directSend =='上门自提'){
|
const directResult = await LightningConfirm.open({
|
message: "备品发送地为非医疗机构或会场,还请确认是否继续提交?",
|
variant: 'headerless',
|
label: '提示信息',
|
});
|
if(!directResult){
|
return;
|
}
|
}
|
//20231106 sx 课题DB202310484652 add end
|
// 20240103 fy DB202312530994 start
|
debugger
|
var creatDate = new Date(this.createdDate);
|
var GoLiveDate = new Date("2024-01-02");
|
if(this.directSend == '医疗机构' && creatDate >= GoLiveDate && ((this.medicalInstitutionAddress == '' || this.medicalInstitutionAddress == undefined) || (this.medicalInstitutionAddresssup == '' || this.medicalInstitutionAddresssup == undefined ))){
|
this.showToast('医疗机构地址和医疗机构地址补充不能为空,请点击按钮【选择医疗地址】进行选择','error');
|
return;
|
}
|
// 20240103 fy DB202312530994 end
|
|
if(this.campaign != null && this.campaign != ''){
|
console.log('selectCampaignById');
|
let dataList = await selectCampaignById({recordId: this.campaign});
|
var interval = dataList[0].Status;
|
if (interval == '草案中') {
|
this.showToast('学会状态为草案中,不能提交','error');
|
return;
|
}
|
if (interval == '申请中') {
|
this.showToast('学会状态为申请中,不能提交','error');
|
return;
|
}
|
if (interval == '已结束') {
|
this.showToast('学会状态为已结束,不能提交','error');
|
return;
|
}
|
if (interval == '已提交报告') {
|
this.showToast('学会状态为已提交报告,不能提交','error');
|
return;
|
}
|
if (interval == '取消申请中') {
|
this.showToast('学会状态为取消申请中,不能提交','error');
|
return;
|
}
|
if (interval == '取消') {
|
this.showToast('学会状态为取消,不能提交','error');
|
return;
|
}
|
}
|
if(this.qISNumber != null && this.qISNumber != ''){
|
console.log('selectReportById');
|
let resList = await selectReportById({recordId:this.qISIDLine});
|
var interval = resList[0].next_action__c;
|
if (interval == '送回') {
|
this.showToast('QIS 已送回,不能再申请备品了','error');
|
return;
|
}
|
}
|
var userAccess = new Array();
|
// 20231012 ljh update 判断空 start
|
if(this.applyUser != undefined){userAccess.push(this.applyUser+'_Edit');}
|
if(this.jingliManager != undefined){userAccess.push(this.jingliManager+'_Edit');}
|
if(this.salesManager != undefined){userAccess.push(this.salesManager+'_Edit');}
|
if(this.buchangManager != undefined){userAccess.push(this.buchangManager+'_Edit');}
|
if(this.buchangManagerSale != undefined){userAccess.push(this.buchangManagerSale+'_Edit');}
|
if(this.zongjianManager != undefined){userAccess.push(this.zongjianManager+'_Edit');}
|
// 20231012 ljh update 判断空 end
|
console.log('setSObjectShare');
|
let res = await setSObjectShare({
|
sobjectName:'Consum_Apply__Share',
|
rowCause:'ApplyUserShare__c',
|
parentId:this.id,
|
userAccess:userAccess,
|
ownerId:this.owner
|
});
|
if(res!='OK'){
|
console.log('111111');
|
this.showToast(res,'error');
|
return;
|
}
|
|
if(this.status == '填写完毕' || this.status == '申请中' || this.status == '已批准'
|
|| this.status == '已出库指示' || this.status == '删除' || this.status == '取消'){
|
this.showToast('请备品申请状态确认,已经提交过的申请,不能重复提交','error');
|
return;
|
}
|
var today = new Date();
|
var approvalDate = new Date(this.minApprovalDate);
|
if(approvalDate > today){
|
this.showToast('申请提交日到预计使用日必须在22个工作日以内才可以','error');
|
return;
|
}
|
console.log('selectEquipmentById');
|
let raesList = await selectEquipmentById({recordId:this.id});
|
if(raesList.length > 0){
|
this.showToast('有没有明细的耗材备品配套一览,不能提交','error');
|
return;
|
}
|
console.log('approvalCheck');
|
let re1 = await approvalCheck({recordId:this.id});
|
if(re1 != '1'){
|
this.showToast(re1,'error');
|
return;
|
}
|
console.log('updateConsumApply');
|
let re2 = await updateConsumApply({recordId:this.id});
|
// console.log(re2);
|
if(re2 != '1'){
|
// 20231013 ljh update start
|
// this.showToast(re1,'error');
|
this.showToast(re2,'error');
|
// 20231013 ljh update end
|
return;
|
}else{
|
console.log("success");
|
this.showToast('已提交','success');
|
}
|
|
}
|
|
updateRecordView(recordId) {
|
updateRecord({fields: { Id: recordId }});
|
}
|
|
showToast(msg,type) {
|
console.log("type-----"+type);
|
if(type == "success"){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode:'sticky'
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
if(type == "success"){
|
console.log("type2-----"+type);
|
this.updateRecordView(this.recordId);
|
setTimeout(function(){
|
window.location.href = window.location;
|
}, 1500 )
|
}
|
}
|
//20240124 sx lightning上线遗漏 start
|
closeAction() {
|
window.open("/"+this.recordId,'_self');
|
}
|
//20240124 sx lightning上线遗漏 end
|
}
|