import { LightningElement,track } from 'lwc'; import GetNormalProductDataNotSave from '@salesforce/apex/OpportunityService.GetNormalProductDataNotSave'; import GetNormalProductDataIsSave from '@salesforce/apex/OpportunityService.GetNormalProductDataIsSave'; import GetNormalProductDataSearch from '@salesforce/apex/OpportunityService.GetNormalProductDataSearch'; import SaveData from '@salesforce/apex/OpportunityService.SaveData'; import SearchYY from '@salesforce/apex/InspectCheckController.SearchYY'; import SearchZLKS from '@salesforce/apex/InspectCheckController.SearchZLKS'; import SearchParent from '@salesforce/apex/InspectCheckController.SearchParent'; import SearchAccountById from '@salesforce/apex/InspectCheckController.SearchAccountById'; import GetInspectById from '@salesforce/apex/InspectCheckController.GetInspectById'; export default class test02 extends LightningElement { //加载 IsLoading = false; OnLoading(flag){ this.IsLoading = flag; } //加载 Tongzhishow=false; //提示显示的标识 SaveShowText="操作成功"; //提示框的文本 TongzhiIcon = 'standard:account' //提示框的图标 IsLeftStyle = "" //提示框的样式 BgColorStyle = "" Alert(content,error = false,left = false){ this.SaveShowText = content; this.Tongzhishow = true; if (error) { this.TongzhiIcon = "standard:first_non_empty"; this.BgColorStyle = "background-color:#f88568"; }else{ this.TongzhiIcon = "standard:account"; this.BgColorStyle = "background-color:#69e669"; } if (left) { this.IsLeftStyle = "left: 0.25rem;" }else{ this.IsLeftStyle = "" } } CloseAlert() { if (this.Tongzhishow == true) { this.Tongzhishow = false; } if (this.SaveShowText != "") { this.SaveShowText = ""; } } //==================获取招投标项目id================ ParamIdStr = ''; // url 参数Id getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i{ var Datas = JSON.parse(response); var accountData = Datas[0].account__c; if (Datas[0].Hospital__c !=undefined) { this.hisotryData.push(Datas[0].Hospital__c); } if (Datas[0].Hospital1__c !=undefined) { this.hisotryData.push(Datas[0].Hospital1__c); } if (Datas[0].Hospital2__c !=undefined) { this.hisotryData.push(Datas[0].Hospital2__c); } if (Datas[0].Hospital3__c !=undefined) { this.hisotryData.push(Datas[0].Hospital3__c); } if (Datas[0].Hospital4__c !=undefined) { this.hisotryData.push(Datas[0].Hospital4__c); } this.accountIdTemp = accountData; this.departmentId = Datas[0].department__c; // this.yyId = Datas[0].Hospital__c; // 20210914 战略科室修改 this.depart_sels = Datas[0].department_selection__c; // 20210914 战略科室修改 GetNormalProductDataNotSave({IdStr:this.ParamIdStr,hospital:this.hisotryData,departments:this.depart_sels}).then(response=>{ var datas = JSON.parse(response); this.notselectdata = datas; this.notselectdata.forEach(item=>{ if (item.Bidding_Project_Name_Bid__c != undefined && item.Bidding_Project_Name_Bid__c != "") { item.Bidding_Project_Name_Bid__c_show = '已关联' }else{ item.Bidding_Project_Name_Bid__c_show = '未关联' } }) this.InitNotSelectdata = datas; this.template.querySelector('[data-parent-id="table1"]').refreshdata(this.selectdata,this.notselectdata); isloading++; if (isloading == 2) { this.OnLoading(false); if (flag) { this.Alert("保存成功",false,true); } } }) GetNormalProductDataIsSave({IdStr:this.ParamIdStr}).then(response=>{ var dataTemp = JSON.parse(response); this.selectdata = dataTemp; this.selectdata.forEach(item=>{ if (item.Bidding_Project_Name_Bid__c != undefined && item.Bidding_Project_Name_Bid__c != "") { item.Bidding_Project_Name_Bid__c_show = '已关联' }else{ item.Bidding_Project_Name_Bid__c_show = '未关联' } }) this.InitSelectdata = dataTemp; this.template.querySelector('[data-parent-id="table1"]').refreshdata(this.selectdata,this.notselectdata); isloading++; if (isloading == 2) { this.OnLoading(false); if (flag) { this.Alert("保存成功",false,true); } } }) }) } // 询价 //table 列表的数据 @track optionsdata=[ { label:"询价名称", props:"Name", url:"Id", Type:"url", }, { label:"询价编码", props:"Opportunity_No__c", Type:"text", }, { label:"客户名", props:"Account_Name_F__c", url:"Id", Type:"url", }, { label:"询价阶段", props:"Opportunity_stage__c", Type:"text", }, { label:"关联招标项目", props:"Bidding_Project_Name_Bid__c_show", Type:"text", }, { label:"状态1", props:"StageName__c", Type:"text", }, ] //table 表单数据 @track selectdata=[ ] // table 未选中的数据 @track notselectdata=[ ] // table 时候选中的判断 @track isselectedtable = true; // 初始化搜索的方法 initsearchdata(event){ var detail = event.detail; return []; } datachange(event) { console.warn("datachange"); console.warn(event.detail.Id); } selected = []; // 选中的数据 notselected = [];// 未选择的数据 selectedchange(event) { console.warn("selectedchange"); console.warn(event.detail); this.selected = event.detail.selected; this.notselected = event.detail.notselected; } @track selecttitle ="已关联的询价" @track notselecttitle ="未关联的询价" // TableEnd XJBMValue = ''; handleXJBMFn(event){ var value = event.target.value; this.XJBMValue = value; } SearchFn(event){ debugger; if (this.yyId != undefined && this.yyId != '') { this.YYSelectedId = this.yyId; } if ((this.XJBMValue == '' || this.XJBMValue == ' ') && (this.YYSelectedId == '' || this.YYSelectedId == ' ')) { this.OnLoading(true); GetNormalProductDataSearch({noStr:undefined,IdStr:this.ParamIdStr,hospital:this.YYSelectedId,hospitalArr:this.hisotryData,departments:this.depart_sels}).then(response=>{ var datas = JSON.parse(response); this.notselectdata = datas; this.template.querySelector('[data-parent-id="table1"]').refreshdata(this.selectdata,this.notselectdata); this.OnLoading(false); }) return ; } this.OnLoading(true); GetNormalProductDataSearch({noStr:this.XJBMValue,IdStr:this.ParamIdStr,hospital:this.YYSelectedId,hospitalArr:this.hisotryData,departments:this.depart_sels}).then(response=>{ var datas = JSON.parse(response); this.notselectdata = datas; this.template.querySelector('[data-parent-id="table1"]').refreshdata(this.selectdata,this.notselectdata); this.OnLoading(false); }) } SaveInits(){ this.OnLoading(true); var isloading = 0; if (this.yyId != undefined && this.yyId != '') { this.YYSelectedId = this.yyId; } GetNormalProductDataIsSave({IdStr:this.ParamIdStr}).then(response=>{ var dataTemp = JSON.parse(response); this.selectdata = dataTemp; this.InitSelectdata = dataTemp; this.template.querySelector('[data-parent-id="table1"]').refreshdata(this.selectdata,this.notselectdata); isloading ++; if (isloading == 2) { this.OnLoading(false); this.Alert("保存成功",false,true); } }) GetNormalProductDataSearch({noStr:this.XJBMValue,IdStr:this.ParamIdStr,hospital:this.YYSelectedId,hospitalArr:this.hisotryData,departments:this.depart_sels}).then(response=>{ var datas = JSON.parse(response); this.notselectdata = datas; this.template.querySelector('[data-parent-id="table1"]').refreshdata(this.selectdata,this.notselectdata); isloading ++; if (isloading == 2) { this.OnLoading(false); this.Alert("保存成功",false,true); } }) } SaveFn(event) { this.OnLoading(true); // 担当/助理操作关联的招标项目不能再取消 20210824 var selectedJson = JSON.stringify([]); var notselectJson = JSON.stringify(this.notselected); var flag = this.compareSelected(); if (flag == false) { this.OnLoading(false); this.Alert("医院不匹配,保存失败!",true); return; } debugger; SaveData({JsonSelected:selectedJson,JsonNotSelected:notselectJson,BiddingId:this.ParamIdStr,flag:true}).then(response=>{ debugger; this.XJBMValue = ''; if (response == '成功') { // this.SaveInits(); this.UpdateDatas(this.notselected); window.location.hash = "Refresh"+"=="+this.ParamIdStr; this.OnLoading(false); }else{ this.OnLoading(false); this.Alert(response,true,false); } }); } UpdateDatas(ids) { var selectDataArr = []; //新集合 var selectData = []; //已选中的集合 this.notselectdata.forEach(element => { var flag = true; ids.forEach(item=>{ if(element.Id == item.Id) { flag = false; } }); var tempData = {...element,...{}}; if (flag) { selectDataArr.push(tempData); }else{ selectData.push(tempData); } }); this.notselectdata = selectDataArr; selectData.forEach(item=>{ this.selectdata.push(item); }) this.template.querySelector('[data-parent-id="table1"]').refreshdata(this.selectdata,this.notselectdata); } //校验是否有重复的 compareSelected() { var temp = ''; var flag = true; if (this.selectdata.length>0) { temp = this.selectdata[0].Hospital__c; } if (this.notselected.length>0) { temp = this.notselected[0].Hospital__c; } //如果没有保存 任何医院 if(!this.hisotryData.length > 0) { var TempArr = []; this.selectdata.forEach(item=>{ let fTemp = TempArr.find(fItem=>{ return fItem.Hospital__c == item.Hospital__c; }) if (fTemp == undefined) { TempArr.push(item); } }) this.notselected.forEach(item=>{ let fTemp = TempArr.find(fItem=>{ return fItem.Hospital__c == item.Hospital__c; }) if (fTemp == undefined) { TempArr.push(item); } }) debugger; if (TempArr.length > 5) { return false; }else{ return true; } } // if (temp == '') { // flag = false; // } this.selectdata.forEach(item=>{ let findResult = this.hisotryData.find((fItem=>{ return fItem == item.Hospital__c; })) if (!findResult) { flag = false; } }) this.notselected.forEach(item=>{ let findResult = this.hisotryData.find((fItem=>{ return fItem == item.Hospital__c; })) if (!findResult) { flag = false; } }) return flag; } urlClickFn(event) { var a =event; } //关联医院 option = [{lableOne:"Name",lableTwo:"Acc_Record_Type__c"}] searchdata=[]; isErrorShowYY=false; onsearchchange(event){ var searchContentStr = event.detail.searchContent; SearchYY({content:searchContentStr}).then(response=>{ var datas = JSON.parse(response); this.searchdata = datas; this.template.querySelector('[data-parent-id="lookup1"]').refreshdata(this.searchdata); }) if (searchContentStr == undefined || searchContentStr == '') { this.YYSelectedId = ''; } } YYSelectedId = ''; selectedFn(event) { console.warn(event.detail.selectdata.Id); this.YYSelectedId = event.detail.selectdata.Id; } onsearchchange1(event){ this.YYSelectedId = event.detail.value; } //关联医院 }