import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; import init from '@salesforce/apex/lexTransferRoomCompoentController.init'; import transferTenderSumbit from '@salesforce/apex/lexTransferRoomCompoentController.transferTenderSumbit'; import getCurrentUserProfileName from '@salesforce/apex/lexTransferRoomCompoentController.getCurrentUserProfileName'; import tender_4 from '@salesforce/label/c.tender_4'; import tender_5 from '@salesforce/label/c.tender_5'; import tender_6 from '@salesforce/label/c.tender_6'; import tender_7 from '@salesforce/label/c.tender_7'; import tender_8 from '@salesforce/label/c.tender_8'; import tender_9 from '@salesforce/label/c.tender_9'; export default class lexTransferRoomInTenderInfo extends LightningElement { @track tender4 = tender_4; @track tender5 = tender_5; @track tender6 = tender_6; @track tender7 = tender_7; @track tender8 = tender_8; @track tender9 = tender_9; // 初始不展示 @track flag = false; //每一个医院和其关联战略科室 @track showFlag=false; @track showFlag1=false; @track showFlag2=false; @track showFlag3=false; @track showFlag4=false; @track showButton =false; IsLoading = true; @api recordId; // 关联医院 @track value; @track value1; @track value2; @track value3; @track value4; @track valueOld; @track value1Old; @track value2Old; @track value3Old; @track value4Old; Tender_information; // 关联战略科室 checkboxValue=""; // kk add checkboxValue1=""; checkboxValue2=""; checkboxValue3=""; checkboxValue4=""; checkboxValueMap1=new Map(); checkboxValueMap2=new Map(); checkboxValueMap3=new Map(); checkboxValueMap4=new Map(); // kk end checkboxValueMap=new Map(); @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; this.recordId = str; } } } connectedCallback(){ Promise.all([ loadStyle(this, lwcCSS) ]); console.log(this.recordId); init({recordId : this.recordId}).then(result=>{ this.Tender_information=result; console.log(result); console.log(this.Tender_information); this.powerCheck(); this.initGetData(); //保存初始战略科室数据 this.saveOldDepartment(); }) } //简档判断 不满足弹出提示信息 powerCheck(){ getCurrentUserProfileName().then(result=>{ if(result != '2S1_销售医院担当' && result != 'OBA7_询价+招标管理' && result != 'OBA8_医院新建+招标/报价委托' && result != '2S1_销售医院担当(非单点)' && result != '2S6-1_销售本部窗口' && result != '2S6-1_销售本部窗口(暂停)' && result != '2S6-2_营业助理' && result != '2S6-2_营业助理 Without SSO' && result != '系统管理员' ){ this.dispatchEvent(new CloseActionScreenEvent()); this.showToastEvent('error','当前用户没有进行转科室的权限'); return; } }).catch(error=>{ console.log(error); }); if(this.Tender_information.status__c !='05.询价中' && this.Tender_information.status__c !='04.待关联询价'){ this.dispatchEvent(new CloseActionScreenEvent()); this.showToastEvent('error','招标项目的内部确认状态为:04.待关联询价或05.询价中时,才能进行转科室'); return; } } // 当数据加载完后,设置isLoading为false // handleLoad() { // this.isLoading = false; // } // 初始化赋值 关联医院、关联战略科室 initGetData(){ this.value=this.Tender_information.Hospital__c; console.log('kktset'+this.value); this.value1=this.Tender_information.Hospital1__c; this.value2=this.Tender_information.Hospital2__c; this.value3=this.Tender_information.Hospital3__c; this.value4=this.Tender_information.Hospital4__c; this.checkBeforShowFlag(); this.IsLoading=false; this.flag=true; //这里按钮比上面的组件先显示,暂时没找到好办法 this.showButton=true; if(this.Tender_information.department_selection__c!=null&&this.Tender_information.department_selection__c!=''&&this.Tender_information.department_selection__c!=undefined){ setTimeout(()=>{ this.CheckBoxAssignment(this.Tender_information.department_selection__c); },1); } if(this.Tender_information.department_selection1__c!=null&&this.Tender_information.department_selection1__c!=''&&this.Tender_information.department_selection1__c!=undefined){ setTimeout(()=>{ this.CheckBoxAssignment1(this.Tender_information.department_selection1__c); },1); } if(this.Tender_information.department_selection2__c!=null&&this.Tender_information.department_selection2__c!=''&&this.Tender_information.department_selection2__c!=undefined){ setTimeout(()=>{ this.CheckBoxAssignment2(this.Tender_information.department_selection2__c); },1); } if(this.Tender_information.department_selection3__c!=null&&this.Tender_information.department_selection3__c!=''&&this.Tender_information.department_selection3__c!=undefined){ setTimeout(()=>{ this.CheckBoxAssignment3(this.Tender_information.department_selection3__c); },1); } if(this.Tender_information.department_selection4__c!=null&&this.Tender_information.department_selection4__c!=''&&this.Tender_information.department_selection4__c!=undefined){ setTimeout(()=>{ this.CheckBoxAssignment4(this.Tender_information.department_selection4__c); },1); } } saveOldDepartment(){ this.valueOld = this.Tender_information.department_selection__c; this.value1Old = this.Tender_information.department_selection1__c; this.value2Old = this.Tender_information.department_selection2__c; this.value3Old = this.Tender_information.department_selection3__c; this.value4Old = this.Tender_information.department_selection4__c; } // 取消 doNotGoPage(){ this.dispatchEvent(new CloseActionScreenEvent()); } pushMehtod(arr,value){ if(value === undefined){ arr.push('1'); } else{ arr.push(value); } } // 走后台方法提交审批 goSubmit(){ console.log('进入goSubmit'); var arrayNew = []; // this.pushMehtod(arrayNew,this.Tender_information.department_selection__c); // this.pushMehtod(arrayNew,this.Tender_information.department_selection1__c); // this.pushMehtod(arrayNew,this.Tender_information.department_selection2__c); // this.pushMehtod(arrayNew,this.Tender_information.department_selection3__c); // this.pushMehtod(arrayNew,this.Tender_information.department_selection4__c); arrayNew.push(this.Tender_information.department_selection__c); arrayNew.push(this.Tender_information.department_selection1__c); arrayNew.push(this.Tender_information.department_selection2__c); arrayNew.push(this.Tender_information.department_selection3__c); arrayNew.push(this.Tender_information.department_selection4__c); console.log(arrayNew); console.log(arrayNew[0]); console.log(arrayNew[1]); console.log(arrayNew[2]); console.log(arrayNew[3]); console.log(arrayNew[4]); var arrayOld = []; // this.pushMehtod(arrayOld,this.valueOld); // this.pushMehtod(arrayOld,this.valueOld1); // this.pushMehtod(arrayOld,this.valueOld2); // this.pushMehtod(arrayOld,this.valueOld3); // this.pushMehtod(arrayOld,this.valueOld4); arrayOld.push(this.valueOld); arrayOld.push(this.value1Old); arrayOld.push(this.value2Old); arrayOld.push(this.value3Old); arrayOld.push(this.value4Old); console.log(arrayOld[0]); console.log(arrayOld[1]); console.log(arrayOld[2]); console.log(arrayOld[3]); console.log(arrayOld[4]); this.flag=false; this.IsLoading=true; transferTenderSumbit({recordId:this.recordId, arrayOld: arrayOld, arrayNew: arrayNew}).then(result=>{ console.log(result); if(result === 'success'){ console.log(result); this.IsLoading=false; this.dispatchEvent(new CloseActionScreenEvent()); this.showToastEvent('success','成功发起转科室审批'); setTimeout(function () { //2秒后执行刷新 window.location.reload(); }, 2000); //单位是毫秒 } else{ this.IsLoading=false; this.flag=true; console.log(result); this.showToastEvent('error',result); } }).catch(error=>{ console.log(error); console.log(error.message); this.showToastEvent('error',error.message); }) } checkBeforShowFlag(){ if(this.value){ this.showFlag=true; } if(this.value1){ this.showFlag1=true; } if(this.value2){ this.showFlag2=true; } if(this.value3){ this.showFlag3=true; } if(this.value4){ this.showFlag4=true; } } //提示 showToastEvent(type,message){ if(type !='success'){ const event = new ShowToastEvent({ message:message, variant : type, mode :'sticky' }); this.dispatchEvent(event); } else{ const event = new ShowToastEvent({ message:message, variant : type, }); this.dispatchEvent(event); } } //添加或删除科室 splieStr(checked,e,i,number){ if(number === 0){ if(checked){ var tianjia =[]; this.checkboxValueMap.set(i,e.srcElement.defaultValue); for (let [k, v] of this.checkboxValueMap) { tianjia.push(v); } this.checkboxValue=tianjia.join(';'); }else{ var shanchu=[]; for (let [k, v] of this.checkboxValueMap) { if(k!=i){ shanchu.push(v); }else{ this.checkboxValueMap.delete(k); debugger } } if(shanchu.length!=0){ this.checkboxValue=shanchu.join(';'); }else{ this.checkboxValue=''; } } var chek=this.checkboxValue; this.Tender_information.department_selection__c=chek; debugger } //kk add if(number === 1){ if(checked){ var tianjia =[]; this.checkboxValueMap1.set(i,e.srcElement.defaultValue); for (let [k, v] of this.checkboxValueMap1) { tianjia.push(v); } this.checkboxValue1=tianjia.join(';'); }else{ var shanchu=[]; for (let [k, v] of this.checkboxValueMap1) { if(k!=i){ shanchu.push(v); }else{ this.checkboxValueMap1.delete(k); debugger } } if(shanchu.length!=0){ this.checkboxValue1=shanchu.join(';'); }else{ this.checkboxValue1=''; } } var chek=this.checkboxValue1; this.Tender_information.department_selection1__c=chek; debugger } if(number === 2){ if(checked){ var tianjia =[]; this.checkboxValueMap2.set(i,e.srcElement.defaultValue); for (let [k, v] of this.checkboxValueMap2) { tianjia.push(v); } this.checkboxValue2=tianjia.join(';'); }else{ var shanchu=[]; for (let [k, v] of this.checkboxValueMap2) { if(k!=i){ shanchu.push(v); }else{ this.checkboxValueMap2.delete(k); debugger } } if(shanchu.length!=0){ this.checkboxValue2=shanchu.join(';'); }else{ this.checkboxValue2=''; } } var chek=this.checkboxValue2; this.Tender_information.department_selection2__c=chek; debugger } if(number === 3){ if(checked){ var tianjia =[]; this.checkboxValueMap3.set(i,e.srcElement.defaultValue); for (let [k, v] of this.checkboxValueMap3) { tianjia.push(v); } this.checkboxValue3=tianjia.join(';'); }else{ var shanchu=[]; for (let [k, v] of this.checkboxValueMap3) { if(k!=i){ shanchu.push(v); }else{ this.checkboxValueMap3.delete(k); debugger } } if(shanchu.length!=0){ this.checkboxValue3=shanchu.join(';'); }else{ this.checkboxValue3=''; } } var chek=this.checkboxValue3; this.Tender_information.department_selection3__c=chek; debugger } if(number === 4){ if(checked){ var tianjia =[]; this.checkboxValueMap4.set(i,e.srcElement.defaultValue); for (let [k, v] of this.checkboxValueMap4) { tianjia.push(v); } this.checkboxValue4=tianjia.join(';'); }else{ var shanchu=[]; for (let [k, v] of this.checkboxValueMap4) { if(k!=i){ shanchu.push(v); }else{ this.checkboxValueMap4.delete(k); debugger } } if(shanchu.length!=0){ this.checkboxValue4=shanchu.join(';'); }else{ this.checkboxValue4=''; } } var chek=this.checkboxValue4; this.Tender_information.department_selection4__c=chek; debugger } //kk end } //给复选框赋值 //关联战略科室 CheckBoxAssignment(department_selection__c){ console.log('CheckBoxAssignment方法'); console.log(department_selection__c); if(department_selection__c === null || department_selection__c === undefined || this.value === null || this.value === undefined){ return; } this.checkboxValue=department_selection__c; var department_selection__cList =department_selection__c.split(";"); department_selection__cList.forEach(ticl=>{ debugger if(ticl==tender_4){ this.template.querySelector('[data-parent-id="unique297"]').checked=true; this.checkboxValueMap.set(1,ticl); }else if(ticl==tender_5){ this.template.querySelector('[data-parent-id="unique298"]').checked=true; this.checkboxValueMap.set(2,ticl); }else if(ticl==tender_6){ this.template.querySelector('[data-parent-id="unique299"]').checked=true; this.checkboxValueMap.set(3,ticl); }else if(ticl==tender_7){ this.template.querySelector('[data-parent-id="unique300"]').checked=true; this.checkboxValueMap.set(4,ticl); }else if(ticl==tender_8){ this.template.querySelector('[data-parent-id="unique301"]').checked=true; this.checkboxValueMap.set(5,ticl); }else if(ticl==tender_9){ this.template.querySelector('[data-parent-id="unique302"]').checked=true; this.checkboxValueMap.set(6,ticl); } }); } //kk 20231124 start //关联战略科室1 CheckBoxAssignment1(department_selection1__c){ console.log('CheckBoxAssignment1'); console.log(department_selection1__c); if(department_selection1__c === null || department_selection1__c === undefined || this.value1 === null || this.value1 === undefined){ return; } this.checkboxValue1=department_selection1__c; var department_selection1__cList =department_selection1__c.split(";"); department_selection1__cList.forEach(ticl=>{ debugger if(ticl=='消化科'){ this.template.querySelector('[data-parent-id="unique11"]').checked=true; this.checkboxValueMap1.set(1,ticl); }else if(ticl=='呼吸科'){ this.template.querySelector('[data-parent-id="unique12"]').checked=true; this.checkboxValueMap1.set(2,ticl); }else if(ticl=='普外科'){ this.template.querySelector('[data-parent-id="unique13"]').checked=true; this.checkboxValueMap1.set(3,ticl); }else if(ticl=='泌尿科'){ this.template.querySelector('[data-parent-id="unique14"]').checked=true; this.checkboxValueMap1.set(4,ticl); }else if(ticl=='妇科'){ this.template.querySelector('[data-parent-id="unique15"]').checked=true; this.checkboxValueMap1.set(5,ticl); }else if(ticl=='耳鼻喉科'){ this.template.querySelector('[data-parent-id="unique16"]').checked=true; this.checkboxValueMap1.set(6,ticl); } }); } //关联战略科室2 CheckBoxAssignment2(department_selection2__c){ console.log('department_selection2__c'+department_selection2__c); if(department_selection2__c === null || department_selection2__c === undefined || this.value2 === null || this.value2 === undefined){ console.log('department_selection2__c'+department_selection2__c); return; } this.checkboxValue2=department_selection2__c; var department_selection2__cList =department_selection2__c.split(";"); department_selection2__cList.forEach(ticl=>{ debugger if(ticl=='消化科'){ this.template.querySelector('[data-parent-id="unique21"]').checked=true; this.checkboxValueMap2.set(1,ticl); }else if(ticl=='呼吸科'){ this.template.querySelector('[data-parent-id="unique22"]').checked=true; this.checkboxValueMap2.set(2,ticl); }else if(ticl=='普外科'){ this.template.querySelector('[data-parent-id="unique23"]').checked=true; this.checkboxValueMap2.set(3,ticl); }else if(ticl=='泌尿科'){ this.template.querySelector('[data-parent-id="unique24"]').checked=true; this.checkboxValueMap2.set(4,ticl); }else if(ticl=='妇科'){ this.template.querySelector('[data-parent-id="unique25"]').checked=true; this.checkboxValueMap2.set(5,ticl); }else if(ticl=='耳鼻喉科'){ this.template.querySelector('[data-parent-id="unique26"]').checked=true; this.checkboxValueMap2.set(6,ticl); } }); } //关联战略科室3 CheckBoxAssignment3(department_selection3__c){ if(department_selection3__c === null || department_selection3__c === undefined || this.value3 === null || this.value3 === undefined){ return; } this.checkboxValue3=department_selection3__c; var department_selection3__cList =department_selection3__c.split(";"); department_selection3__cList.forEach(ticl=>{ debugger if(ticl=='消化科'){ this.template.querySelector('[data-parent-id="unique31"]').checked=true; this.checkboxValueMap3.set(1,ticl); }else if(ticl=='呼吸科'){ this.template.querySelector('[data-parent-id="unique32"]').checked=true; this.checkboxValueMap3.set(2,ticl); }else if(ticl=='普外科'){ this.template.querySelector('[data-parent-id="unique33"]').checked=true; this.checkboxValueMap3.set(3,ticl); }else if(ticl=='泌尿科'){ this.template.querySelector('[data-parent-id="unique34"]').checked=true; this.checkboxValueMap3.set(4,ticl); }else if(ticl=='妇科'){ this.template.querySelector('[data-parent-id="unique35"]').checked=true; this.checkboxValueMap3.set(5,ticl); }else if(ticl=='耳鼻喉科'){ this.template.querySelector('[data-parent-id="unique36"]').checked=true; this.checkboxValueMap3.set(6,ticl); } }); } //关联战略科室4 CheckBoxAssignment4(department_selection4__c){ if(department_selection4__c === null || department_selection4__c === undefined || this.value4 === null || this.value4 === undefined){ return; } this.checkboxValue4=department_selection4__c; var department_selection4__cList =department_selection4__c.split(";"); department_selection4__cList.forEach(ticl=>{ debugger if(ticl=='消化科'){ this.template.querySelector('[data-parent-id="unique41"]').checked=true; this.checkboxValueMap4.set(1,ticl); }else if(ticl=='呼吸科'){ this.template.querySelector('[data-parent-id="unique42"]').checked=true; this.checkboxValueMap4.set(2,ticl); }else if(ticl=='普外科'){ this.template.querySelector('[data-parent-id="unique43"]').checked=true; this.checkboxValueMap4.set(3,ticl); }else if(ticl=='泌尿科'){ this.template.querySelector('[data-parent-id="unique44"]').checked=true; this.checkboxValueMap4.set(4,ticl); }else if(ticl=='妇科'){ this.template.querySelector('[data-parent-id="unique45"]').checked=true; this.checkboxValueMap4.set(5,ticl); }else if(ticl=='耳鼻喉科'){ this.template.querySelector('[data-parent-id="unique46"]').checked=true; this.checkboxValueMap4.set(6,ticl); } }); } //关联战略科室 checkbox297(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique297"]').checked; this.splieStr(checked,e,1,0); } checkbox298(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique298"]').checked; this.splieStr(checked,e,2,0); } checkbox299(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique299"]').checked; this.splieStr(checked,e,3,0); } checkbox300(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique300"]').checked; this.splieStr(checked,e,4,0); } checkbox301(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique301"]').checked; this.splieStr(checked,e,5,0); } checkbox302(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique302"]').checked; this.splieStr(checked,e,6,0); } //kk 20231124 add //关联战略科室1 checkbox11(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique11"]').checked; this.splieStr(checked,e,1,1); } checkbox12(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique12"]').checked; this.splieStr(checked,e,2,1); } checkbox13(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique13"]').checked; this.splieStr(checked,e,3,1); } checkbox14(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique14"]').checked; this.splieStr(checked,e,4,1); } checkbox15(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique15"]').checked; this.splieStr(checked,e,5,1); } checkbox16(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique16"]').checked; this.splieStr(checked,e,6,1); } //关联战略科室2 checkbox21(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique21"]').checked; this.splieStr(checked,e,1,2); } checkbox22(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique22"]').checked; this.splieStr(checked,e,2,2); } checkbox23(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique23"]').checked; this.splieStr(checked,e,3,2); } checkbox24(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique24"]').checked; this.splieStr(checked,e,4,2); } checkbox25(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique25"]').checked; this.splieStr(checked,e,5,2); } checkbox26(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique26"]').checked; this.splieStr(checked,e,6,2); } //关联战略科室3 checkbox31(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique31"]').checked; this.splieStr(checked,e,1,3); } checkbox32(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique32"]').checked; this.splieStr(checked,e,2,3); } checkbox33(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique33"]').checked; this.splieStr(checked,e,3,3); } checkbox34(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique34"]').checked; this.splieStr(checked,e,4,3); } checkbox35(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique35"]').checked; this.splieStr(checked,e,5,3); } checkbox36(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique36"]').checked; this.splieStr(checked,e,6,3); } //关联战略科室4 checkbox41(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique41"]').checked; this.splieStr(checked,e,1,4); } checkbox42(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique42"]').checked; this.splieStr(checked,e,2,4); } checkbox43(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique43"]').checked; this.splieStr(checked,e,3,4); } checkbox44(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique44"]').checked; this.splieStr(checked,e,4,4); } checkbox45(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique45"]').checked; this.splieStr(checked,e,5,4); } checkbox46(e){ debugger var checked=this.template.querySelector('[data-parent-id="unique46"]').checked; this.splieStr(checked,e,6,4); } //kk 20231124 end }