|  |  |  | 
|---|
|  |  |  | ({ | 
|---|
|  |  |  | doinit : function(component, event, helper) { | 
|---|
|  |  |  | this.report_date_list(component, event, helper, 5); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | component.set('v.login',true); | 
|---|
|  |  |  | var action = component.get('c.getalldata'); | 
|---|
|  |  |  | action.setCallback(this,function(response){ | 
|---|
|  |  |  | 
|---|
|  |  |  | component.set('v.fieldsmap',res.fieldsMap); | 
|---|
|  |  |  | component.set('v.allselectlist',res.allselectlist); | 
|---|
|  |  |  | component.set('v.doclist',res.doclist); | 
|---|
|  |  |  | component.find('select_agency_person').set('v.options', this.conv_selected(res.allselectlist.AgencyPerson__c)); | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 start | 
|---|
|  |  |  | // component.find('select_agency_person').set('v.options', this.conv_selected(res.allselectlist.AgencyPerson__c)); | 
|---|
|  |  |  | this.search_contact(component, event, helper,res.allselectlist.AgencyPerson__c); | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 end | 
|---|
|  |  |  | component.find('select_department').set('v.options', this.conv_selected(res.allselectlist.Department_Cateogy__c)); | 
|---|
|  |  |  | component.find('select_purpose_type').set('v.options', this.conv_selected(res.allselectlist.Purpose_Type__c)); | 
|---|
|  |  |  | component.find('select_result').set('v.options', this.conv_selected(res.allselectlist.Result__c)); | 
|---|
|  |  |  | component.find('select_stageName').set('v.options', this.conv_selected(res.allselectlist.StageName__c)); | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start | 
|---|
|  |  |  | component.find('SupportNeeds__c').set('v.options', this.conv_selected(res.allselectlist.SupportNeeds__c)); | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end | 
|---|
|  |  |  | component.set('v.selected_agency_person', res.allselectlist.AgencyPerson__c[0].label); | 
|---|
|  |  |  | component.set('v.dialog_type', '新建'); | 
|---|
|  |  |  | component.set('v.awsurl', res.awsurl);// 20220222 PI改造 by Bright | 
|---|
|  |  |  | component.set('v.contactawsurl', res.contactawsurl);// 20220222 PI改造 by Bright | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.get_reports(component, event, helper, component.find('select_date').get('v.value'), component.find('select_agency_person').get('v.value')); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | $A.enqueueAction(action); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 start | 
|---|
|  |  |  | search_contact : function(component, event, helper, resobj) { | 
|---|
|  |  |  | let contactData = Object.create(null); | 
|---|
|  |  |  | var dataArr = new Array(); | 
|---|
|  |  |  | for (let i = 0; i < resobj.length; i++) { | 
|---|
|  |  |  | if (resobj[i].awsid != null && resobj[i].awsid != ''){ | 
|---|
|  |  |  | contactData[resobj[i].awsid] = resobj[i]; | 
|---|
|  |  |  | dataArr.push(resobj[i].awsid); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | let obj= Object.create(null); | 
|---|
|  |  |  | obj['dataIds'] = dataArr; | 
|---|
|  |  |  | var payload = JSON.stringify(obj); | 
|---|
|  |  |  | this.search_contact_url(component, 'Contact', (result)=>{ | 
|---|
|  |  |  | var token = result.token; | 
|---|
|  |  |  | var searchUrl = result.searchUrl; | 
|---|
|  |  |  | this.search_core(token,searchUrl,payload,(result)=>{ | 
|---|
|  |  |  | if(result.status == '0'){ | 
|---|
|  |  |  | this.to_contact_list(result,contactData,component); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | this.error('AWS search status : ' + result.status); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | },component); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | to_contact_list : function(result,retMap,component) { | 
|---|
|  |  |  | var resls = result.object; | 
|---|
|  |  |  | var res = []; | 
|---|
|  |  |  | var space = {}; | 
|---|
|  |  |  | space['label'] = ''; | 
|---|
|  |  |  | space['selected'] = true; | 
|---|
|  |  |  | space['value'] = ''; | 
|---|
|  |  |  | res.push(space); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (var i = 0; i < resls.length; i++) { | 
|---|
|  |  |  | var t = {}; | 
|---|
|  |  |  | t['label'] = resls[i].lastName; | 
|---|
|  |  |  | t['selected'] = false; | 
|---|
|  |  |  | t['Doctor_Division1__c'] = resls[i].doctorDivision1; | 
|---|
|  |  |  | t['value'] = retMap[resls[i].dataId].value; | 
|---|
|  |  |  | res.push(t); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | component.find('select_agency_person').set('v.options',res); | 
|---|
|  |  |  | component.set('v.allselectlistAgencyPerson',res); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | search_contact_url : function(component, sobject, callback) { | 
|---|
|  |  |  | var action = component.get('c.getAwsurl'); | 
|---|
|  |  |  | action.setParams({ | 
|---|
|  |  |  | "sobj" : sobject, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | action.setCallback(this,function(response){ | 
|---|
|  |  |  | var state = response.getState(); | 
|---|
|  |  |  | if(state == 'SUCCESS'){ | 
|---|
|  |  |  | var result = response.getReturnValue(); | 
|---|
|  |  |  | if(callback)callback(result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else{ | 
|---|
|  |  |  | this.error('AWS url/token error.'); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | $A.enqueueAction(action); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 end | 
|---|
|  |  |  |  | 
|---|
|  |  |  | select_department : function(component, event, helper) { | 
|---|
|  |  |  | var dc = component.find("select_department").get("v.value"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (dc != '' || purpose_type != '') { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var action = component.get('c.getProductList'); | 
|---|
|  |  |  | action.setParams({ | 
|---|
|  |  |  | "dc" : dc, | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | action.setCallback(this,function(response){ | 
|---|
|  |  |  | var state = response.getState(); | 
|---|
|  |  |  | alert(state); | 
|---|
|  |  |  | if(state == 'SUCCESS'){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var res = response.getReturnValue(); | 
|---|
|  |  |  | component.find('select_Product1').set("v.options", JSON.parse(JSON.stringify(res))); | 
|---|
|  |  |  | component.find('select_Product2').set("v.options", JSON.parse(JSON.stringify(res))); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(state == 'SUCCESS'){ | 
|---|
|  |  |  | var res = response.getReturnValue(); | 
|---|
|  |  |  | component.set('v.reports', res.reports); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 20220222 PI改造 by Bright--start | 
|---|
|  |  |  | let dataIds = []; | 
|---|
|  |  |  | let dataIds1 = []; | 
|---|
|  |  |  | let mm = {}; | 
|---|
|  |  |  | let b = false; | 
|---|
|  |  |  | let b1 = false; | 
|---|
|  |  |  | for (const rep of res.reports) { | 
|---|
|  |  |  | if (rep.doctor2__r && rep.doctor2__r.AWS_Data_Id__c) { | 
|---|
|  |  |  | dataIds.push(rep.doctor2__r.AWS_Data_Id__c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (rep.Person_In_Charge2__r && rep.Person_In_Charge2__r.AWS_Data_Id__c) { | 
|---|
|  |  |  | dataIds1.push(rep.Person_In_Charge2__r.AWS_Data_Id__c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | let Foo = null; | 
|---|
|  |  |  | Foo = function(){ | 
|---|
|  |  |  | if(b && b1){ | 
|---|
|  |  |  | for (const rep of res.reports) { | 
|---|
|  |  |  | if (rep.doctor2__r && rep.doctor2__r.AWS_Data_Id__c && mm.hasOwnProperty(rep.doctor2__r.AWS_Data_Id__c)) { | 
|---|
|  |  |  | rep.doctor2__r.awsdata = mm[rep.doctor2__r.AWS_Data_Id__c]; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (rep.Person_In_Charge2__r && rep.Person_In_Charge2__r.AWS_Data_Id__c && mm.hasOwnProperty(rep.Person_In_Charge2__r.AWS_Data_Id__c)) { | 
|---|
|  |  |  | rep.Person_In_Charge2__r.awsdata = mm[rep.Person_In_Charge2__r.AWS_Data_Id__c]; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | $A.getCallback(()=>component.set('v.reports', res.reports))(); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | console.log('b='+b + ',b1='+b1+',continue'); | 
|---|
|  |  |  | setTimeout(Foo,100); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(dataIds.length > 0){ | 
|---|
|  |  |  | let awsurl = component.get('v.awsurl'); | 
|---|
|  |  |  | helper.search_core(awsurl.token,awsurl.searchUrl,JSON.stringify({ | 
|---|
|  |  |  | "dataIds":dataIds | 
|---|
|  |  |  | }),(result)=>{ | 
|---|
|  |  |  | if(result.status == '0'){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (const m of result.object) { | 
|---|
|  |  |  | mm[m.dataId] = m; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | b = true; | 
|---|
|  |  |  | Foo(); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | this.error('AWS search status : ' + result.status); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | },component); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | b = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(dataIds1.length > 0){ | 
|---|
|  |  |  | let contactawsurl = component.get('v.contactawsurl'); | 
|---|
|  |  |  | helper.search_core(contactawsurl.token,contactawsurl.searchUrl,JSON.stringify({ | 
|---|
|  |  |  | "dataIds":dataIds1 | 
|---|
|  |  |  | }),(result)=>{ | 
|---|
|  |  |  | if(result.status == '0'){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (const m of result.object) { | 
|---|
|  |  |  | mm[m.dataId] = m; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | b1 = true; | 
|---|
|  |  |  | Foo(); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | this.error('AWS search status : ' + result.status); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | },component); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | b1 = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 20220222 PI改造 by Bright--end | 
|---|
|  |  |  |  | 
|---|
|  |  |  | component.set('v.report_count', res.reports.length); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新保存後のselect_data用 | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | get_agency_person_name : function(component, agency_person_value) { | 
|---|
|  |  |  | var allselectlist = component.get('v.allselectlist.AgencyPerson__c'); | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 start | 
|---|
|  |  |  | // var allselectlist = component.get('v.allselectlist.AgencyPerson__c'); | 
|---|
|  |  |  | var allselectlist = component.get('v.allselectlistAgencyPerson'); | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 end | 
|---|
|  |  |  | var new_label = ''; | 
|---|
|  |  |  | for (var i = 0; i < allselectlist.length; i++) { | 
|---|
|  |  |  | if (agency_person_value == allselectlist[i].value) { | 
|---|
|  |  |  | 
|---|
|  |  |  | if (select_data['Department_Cateogy__c'] != '') { | 
|---|
|  |  |  | this.set_selected(component, 'select_department', select_data['Department_Cateogy__c']); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 拜访人 | 
|---|
|  |  |  | component.set('v.default_select_doctor_id', select_data['doctor2__c']); | 
|---|
|  |  |  | this.set_doctor_list(component); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (reportDate != null) { | 
|---|
|  |  |  | component.set('v.data.Report_Date__c', reportDate); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | component.set('v.edit_copy_select_report_id', ""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | component.set('v.edit_copy_select_report_id', ""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // CLOSE | 
|---|
|  |  |  | 
|---|
|  |  |  | component.set('v.selected_date', select_date); | 
|---|
|  |  |  | var name = component.get('v.selected_agency_person'); | 
|---|
|  |  |  | var ret = this.create_report_header(component, name, select_agency, select_date); | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 start | 
|---|
|  |  |  | this.set_aws_url(component,'Agency_Contact__c') | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 end | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | copy_button : function(component, event, helper) { | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | save_report : function(component, event, helper) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 20220222 PI改造  by Bright--start | 
|---|
|  |  |  | let doctor2Name = ''; | 
|---|
|  |  |  | let visitortitle = ''; | 
|---|
|  |  |  | for(let op of component.find('select_doctor').get('v.options')){ | 
|---|
|  |  |  | if (op.selected) { | 
|---|
|  |  |  | doctor2Name = op.label; | 
|---|
|  |  |  | visitortitle = op.Doctor_Division1__c; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 20220222 PI改造  by Bright--end | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | component.find('save_button').set('v.disabled', true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var Report_Date__c = component.get('v.data.Report_Date__c'); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 活动区分 Purpose_Type__c | 
|---|
|  |  |  | var Purpose_Type__c = component.find('select_purpose_type').get('v.value'); | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start | 
|---|
|  |  |  | // 支援需求 SupportNeeds__c | 
|---|
|  |  |  | var SupportNeeds__c = component.find('SupportNeeds__c').get('v.value'); | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end | 
|---|
|  |  |  | // 询价 Opportunity__c | 
|---|
|  |  |  | var Opportunity__c = component.get('v.data.Opportunity__c'); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!Department_Cateogy__c) { error.push("科室 不存在"); } | 
|---|
|  |  |  | if (!doctor2__c) { error.push("拜访人 不存在"); } | 
|---|
|  |  |  | if (!Purpose_Type__c) { error.push("活动区分 不存在"); } | 
|---|
|  |  |  | if (!SupportNeeds__c) { error.push("支援需求 不存在"); } | 
|---|
|  |  |  | if (!Opportunity__c) { Opportunity__c = ""; } | 
|---|
|  |  |  | if (!Product_Category1__c) { error.push("产品区分1 不存在"); } | 
|---|
|  |  |  | if (Purpose_Type__c && (Purpose_Type__c.substr(-3) == 'SIS' || Purpose_Type__c.substr(-3) == 'OPD')) { | 
|---|
|  |  |  | 
|---|
|  |  |  | if (component.get('v.mode') == 'edit') { | 
|---|
|  |  |  | var Agency_Report__c = component.get('v.select_report_data').Id; | 
|---|
|  |  |  | var action = component.get('c.editAgencyReport'); | 
|---|
|  |  |  | alert("Purpose_Type:"+Purpose_Type__c+","+"SupportNeedsc:"+SupportNeeds__c); | 
|---|
|  |  |  | action.setParams({ | 
|---|
|  |  |  | "Agency_Report_Id" : Agency_Report__c, | 
|---|
|  |  |  | "Department_Cateogy" : Department_Cateogy__c, | 
|---|
|  |  |  | "Purpose_Type" : Purpose_Type__c, | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start | 
|---|
|  |  |  | "SupportNeedsc" : SupportNeeds__c, | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end | 
|---|
|  |  |  | "Agency_Report_Header" : Agency_Report_Header__c, | 
|---|
|  |  |  | "Agency_Hospital" : Agency_Hospital__c, | 
|---|
|  |  |  | "Person_In_Charge2" : Person_In_Charge2__c, | 
|---|
|  |  |  | 
|---|
|  |  |  | action.setParams({ | 
|---|
|  |  |  | "Department_Cateogy" : Department_Cateogy__c, | 
|---|
|  |  |  | "Purpose_Type" : Purpose_Type__c, | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start | 
|---|
|  |  |  | "SupportNeedsc" : SupportNeeds__c, | 
|---|
|  |  |  | //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end | 
|---|
|  |  |  | "Agency_Report_Header" : Agency_Report_Header__c, | 
|---|
|  |  |  | "Agency_Hospital" : Agency_Hospital__c, | 
|---|
|  |  |  | "Person_In_Charge2" : Person_In_Charge2__c, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // Save&New時のウィンドウ内データ一覧 | 
|---|
|  |  |  | if (res.length > 0) { | 
|---|
|  |  |  | // 20220222 PI改造  by Bright--start | 
|---|
|  |  |  | res[0].doctor2NameOrigin = doctor2Name; | 
|---|
|  |  |  | res[0].visitorTitleOrigin = visitortitle; | 
|---|
|  |  |  | // 20220222 PI改造  by Bright--end | 
|---|
|  |  |  | reports_now[reports_now_count] = res[0]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | reports_now.sort(function(a,b) { | 
|---|
|  |  |  | 
|---|
|  |  |  | var ret_obj = []; | 
|---|
|  |  |  | var now = new Date(); | 
|---|
|  |  |  | for (var i = 0; i < count; i++) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var start_day = new Date(now.getFullYear(), now.getMonth(), (now.getDate() - now.getDay() + 1 - (i * 7))); | 
|---|
|  |  |  | var end_day = new Date(now.getFullYear(), now.getMonth(), now.getDate() + (7 - now.getDay()) - (i * 7)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var start_day_show = new Date(now.getFullYear(), now.getMonth(), (now.getDate() - now.getDay() - (i * 7))); | 
|---|
|  |  |  | var end_day_show = new Date(now.getFullYear(), now.getMonth(), now.getDate() + (6 - now.getDay()) - (i * 7)); | 
|---|
|  |  |  | var date_text = start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate() + '~' + end_day.getFullYear() + '/' + (end_day.getMonth() + 1) + '/' + end_day.getDate(); | 
|---|
|  |  |  | 
|---|
|  |  |  | var result = component.find('result'); | 
|---|
|  |  |  | $A.util.addClass(result, 'disp_none'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.select_department(component, null, null); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | component.set('v.doctor_title', ''); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 start | 
|---|
|  |  |  | set_aws_url : function(component,sobject) { | 
|---|
|  |  |  | var action = component.get('c.getAwsurl'); | 
|---|
|  |  |  | action.setParams({ | 
|---|
|  |  |  | "sobj" : sobject, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | action.setCallback(this,function(response){ | 
|---|
|  |  |  | var state = response.getState(); | 
|---|
|  |  |  | if(state == 'SUCCESS'){ | 
|---|
|  |  |  | var awsmap = this.conv_selected(response.getReturnValue()); | 
|---|
|  |  |  | component.set('v.AWStoken',awsmap.token); | 
|---|
|  |  |  | component.set('v.AWSinsert',awsmap.newUrl); | 
|---|
|  |  |  | component.set('v.AWSsearch',awsmap.searchUrl); | 
|---|
|  |  |  | component.set('v.AWStransactionURL',awsmap.transactionURL); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else{ | 
|---|
|  |  |  | this.error('AWS url/token error.'); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | $A.enqueueAction(action); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | insert_agencycontact : function(component,token,newUrl,payload,agencyHospitalid,helper) { | 
|---|
|  |  |  | fetch(newUrl, { | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | body: payload, | 
|---|
|  |  |  | headers: { | 
|---|
|  |  |  | 'Content-Type': 'application/json', | 
|---|
|  |  |  | 'pi-token': token | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).then((data) => { | 
|---|
|  |  |  | return data.json(); | 
|---|
|  |  |  | }).then((result) => { | 
|---|
|  |  |  | if(result.status == '0'){ | 
|---|
|  |  |  | $A.getCallback(function(){ | 
|---|
|  |  |  | helper.to_agencycontact(component,result,agencyHospitalid); | 
|---|
|  |  |  | })(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | console.log('AWS status error:' + result) | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | component.find('OppMessage').setError('AWS insert error.'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).catch(error => { | 
|---|
|  |  |  | console.log('AWS insert error:' + error) | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | component.find('OppMessage').setError('AWS insert error.'); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | to_agencycontact : function(component,result,agencyHospitalid) { | 
|---|
|  |  |  | var action = component.get('c.saveAgencyContact'); | 
|---|
|  |  |  | action.setParams({ | 
|---|
|  |  |  | "name" : result.object[0].name, | 
|---|
|  |  |  | "nameEncrypt" : result.object[0].nameEncrypt, | 
|---|
|  |  |  | "type" : result.object[0].type, | 
|---|
|  |  |  | "typeEncrypt" : result.object[0].typeEncrypt, | 
|---|
|  |  |  | "doctorDivision1" : result.object[0].doctorDivision1, | 
|---|
|  |  |  | "doctorDivision1Encrypt" : result.object[0].doctorDivision1Encrypt, | 
|---|
|  |  |  | "agencyHospitalid" : agencyHospitalid, | 
|---|
|  |  |  | "awsid" : result.object[0].dataId, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | action.setCallback(this,function(response){ | 
|---|
|  |  |  | var state = response.getState(); | 
|---|
|  |  |  | if(state == 'SUCCESS'){ | 
|---|
|  |  |  | var acMap = this.conv_selected(response.getReturnValue()); | 
|---|
|  |  |  | console.log(acMap); | 
|---|
|  |  |  | if(acMap.AgencyContactId != ''){ | 
|---|
|  |  |  | //确认事务 | 
|---|
|  |  |  | var token = component.get('v.AWStoken'); | 
|---|
|  |  |  | var confirmUrl = component.get('v.AWStransactionURL'); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let data = Object.create(null); | 
|---|
|  |  |  | data['isSuccess'] = 1; | 
|---|
|  |  |  | data['sfRecordId'] = ''; | 
|---|
|  |  |  | data['txId'] = result.txId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.to_confirm(component,token,confirmUrl,JSON.stringify(data)); | 
|---|
|  |  |  | }else if(acMap.errormsg != ''){ | 
|---|
|  |  |  | this.error(acMap.errormsg); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | this.error('agency contact insert id error.'); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else{ | 
|---|
|  |  |  | this.error('agency contact insert error.'); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | $A.enqueueAction(action); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | to_confirm : function(component,token,confirmUrl,payload) { | 
|---|
|  |  |  | fetch(confirmUrl, { | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | body: payload, | 
|---|
|  |  |  | headers: { | 
|---|
|  |  |  | 'Content-Type': 'application/json', | 
|---|
|  |  |  | 'pi-token': token | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).then((data) => { | 
|---|
|  |  |  | return data.json(); | 
|---|
|  |  |  | }).then((result) => { | 
|---|
|  |  |  | if(result.status == '0' && result.hasOwnProperty('success') && result.success){ | 
|---|
|  |  |  | component.set('v.truthy', false); | 
|---|
|  |  |  | var modal_newAC = component.find('modal_newAC') | 
|---|
|  |  |  | $A.util.addClass(modal_newAC, 'disp_none'); | 
|---|
|  |  |  | this.success('.客户人员已创建。'); | 
|---|
|  |  |  | this.set_doctor_list(component); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | this.error('AWS confirm error.'); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).catch(error => { | 
|---|
|  |  |  | this.error('AWS confirm error.'); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 end | 
|---|
|  |  |  |  | 
|---|
|  |  |  | set_doctor_list : function(component) { | 
|---|
|  |  |  | var hospital_id = component.get('v.hospitalLinkId'); | 
|---|
|  |  |  | if (hospital_id) { | 
|---|
|  |  |  | 
|---|
|  |  |  | action.setCallback(this,function(response){ | 
|---|
|  |  |  | var state = response.getState(); | 
|---|
|  |  |  | if(state == 'SUCCESS'){ | 
|---|
|  |  |  | var res = this.conv_selected(response.getReturnValue()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var retMap = this.conv_selected(response.getReturnValue()); | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 start | 
|---|
|  |  |  | this.AWS_search(retMap,component); | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | var default_doctor = component.get('v.default_select_doctor_id'); | 
|---|
|  |  |  | if (default_doctor != '' && res.length > 0) { | 
|---|
|  |  |  | var doctor_title = ''; | 
|---|
|  |  |  | 
|---|
|  |  |  | component.set('v.default_select_doctor_id', ''); | 
|---|
|  |  |  | component.set('v.doctor_list', res); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 end | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else{ | 
|---|
|  |  |  | this.error('set_doctor_list failed.'); | 
|---|
|  |  |  | 
|---|
|  |  |  | $A.enqueueAction(action); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 start | 
|---|
|  |  |  | AWS_search : function(retMap,component) { | 
|---|
|  |  |  | var token = retMap.sre.token; | 
|---|
|  |  |  | var searchUrl = retMap.sre.searchUrl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var dataArr = new Array(); | 
|---|
|  |  |  | for (const key in retMap) { | 
|---|
|  |  |  | if (key == 'sre') {continue;} | 
|---|
|  |  |  | dataArr.push(key); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | let obj= Object.create(null); | 
|---|
|  |  |  | obj['dataIds'] = dataArr; | 
|---|
|  |  |  | var data = JSON.stringify(obj); | 
|---|
|  |  |  | this.search_agency_contact(token,searchUrl,data,retMap,component); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | search_agency_contact : function(token,searchUrl,payload,retMap,component) { | 
|---|
|  |  |  | this.search_core(token,searchUrl,payload,(result)=>{ | 
|---|
|  |  |  | if(result.status == '0'){ | 
|---|
|  |  |  | this.to_doctor_list(result,retMap,component); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | this.error('AWS search status : ' + result.status); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | },component); | 
|---|
|  |  |  | // fetch(searchUrl, { | 
|---|
|  |  |  | //     method: 'POST', | 
|---|
|  |  |  | //     body: payload, | 
|---|
|  |  |  | //     headers: { | 
|---|
|  |  |  | //         'Content-Type': 'application/json', | 
|---|
|  |  |  | //         'pi-token': token | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | // }).then((data) => { | 
|---|
|  |  |  | //     return data.json(); | 
|---|
|  |  |  | // }).then((result) => { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // }).catch(error => { | 
|---|
|  |  |  | //     this.error('AWS search error.'); | 
|---|
|  |  |  | //     component.set('v.login',false); | 
|---|
|  |  |  | // }); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | search_core : function(token,searchUrl,payload,callback,component) { | 
|---|
|  |  |  | fetch(searchUrl, { | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | body: payload, | 
|---|
|  |  |  | headers: { | 
|---|
|  |  |  | 'Content-Type': 'application/json', | 
|---|
|  |  |  | 'pi-token': token | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).then((data) => { | 
|---|
|  |  |  | return data.json(); | 
|---|
|  |  |  | }).then((result) => { | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | if(callback)callback(result); | 
|---|
|  |  |  | }).catch(error => { | 
|---|
|  |  |  | this.error('AWS search error.'); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | to_doctor_list : function(result,retMap,component) { | 
|---|
|  |  |  | var resls = result.object; | 
|---|
|  |  |  | var res = []; | 
|---|
|  |  |  | var space = {}; | 
|---|
|  |  |  | space['label'] = ''; | 
|---|
|  |  |  | space['selected'] = true; | 
|---|
|  |  |  | space['value'] = ''; | 
|---|
|  |  |  | res.push(space); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (var i = 0; i < resls.length; i++) { | 
|---|
|  |  |  | var t = {}; | 
|---|
|  |  |  | t['label'] = resls[i].name; | 
|---|
|  |  |  | t['selected'] = false; | 
|---|
|  |  |  | t['Doctor_Division1__c'] = resls[i].doctorDivision1; | 
|---|
|  |  |  | t['value'] = retMap[resls[i].dataId].value; | 
|---|
|  |  |  | res.push(t); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var default_doctor = component.get('v.default_select_doctor_id'); | 
|---|
|  |  |  | if (default_doctor != '' && res.length > 0) { | 
|---|
|  |  |  | var doctor_title = ''; | 
|---|
|  |  |  | for (var i = 0; i < res.length; i++) { | 
|---|
|  |  |  | if (res[i].value == default_doctor) { | 
|---|
|  |  |  | res[i].selected = true; | 
|---|
|  |  |  | doctor_title = res[i].Doctor_Division1__c; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | res[i].selected = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | component.find('select_doctor').set('v.options', res); | 
|---|
|  |  |  | component.set('v.doctor_title', doctor_title); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | component.find('select_doctor').set('v.options', res); | 
|---|
|  |  |  | if (res.length > 0) { | 
|---|
|  |  |  | component.set('v.doctor_title', res[0].Doctor_Division1__c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | component.set('v.default_select_doctor_id', ''); | 
|---|
|  |  |  | component.set('v.doctor_list', res); | 
|---|
|  |  |  | component.set('v.login',false); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // PIPL update Yin Mingjie 21/02/2022 end | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // stageNameChange : function(component, event, helper) { | 
|---|
|  |  |  | //     var options = component.find('input-oppstage').get("v.body")[0].get('v.options'); | 
|---|
|  |  |  | 
|---|
|  |  |  | this.set_doctor_list(component); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | createCancel : function(component, event, helper) { | 
|---|
|  |  |  | component.set('v.truthy', false); | 
|---|
|  |  |  | createCancel : function(component, event, helper) { | 
|---|
|  |  |  | component.set('v.truthy', false); | 
|---|
|  |  |  | var modal_newAC = component.find('modal_newAC') | 
|---|
|  |  |  | $A.util.addClass(modal_newAC, 'disp_none'); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | var selectDate = component.find('select_date').get('v.value'); | 
|---|
|  |  |  | var fieldsList=['Name','Phone','AccountNumber']; //Please write your code dynamic fields | 
|---|
|  |  |  | action.setParams({ | 
|---|
|  |  |  | fileData : component.get("v.fileContentData"), | 
|---|
|  |  |  | //selectDateselectDate :component.find('select_date').get('v.value'), | 
|---|
|  |  |  | sobjectName:'Account', //Any object | 
|---|
|  |  |  | fields:fieldsList | 
|---|
|  |  |  |  | 
|---|
|  |  |  | fileData : component.get("v.fileContentData"), | 
|---|
|  |  |  | //selectDateselectDate :component.find('select_date').get('v.value'), | 
|---|
|  |  |  | sobjectName:'Account', //Any object | 
|---|
|  |  |  | fields:fieldsList | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | action.setCallback(this, function(response) { | 
|---|
|  |  |  | var state = response.getState(); | 
|---|
|  |  |  | if (state === "SUCCESS") { | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | showExportDate : function(component,objectRecords){ | 
|---|
|  |  |  | console.log('进入showexceportdate'+objectRecords); | 
|---|
|  |  |  | alert(777); | 
|---|
|  |  |  | var keys = ['Submit_date__c','Person_In_Charge2__c','Report_Date__c','Agency_Hospital__c','Department_Cateogy__c','doctor2__c','visitor_title__c','Product_Category1__c','Product_Category2__c','Product_Category3__c','Purpose_Type__c','Result__c']; | 
|---|
|  |  |  | var headers = ['周','担当','活动日','医院','科室','拜访人','职位','产品区分1','产品区分2','产品区分3','活动区分','结果'] | 
|---|
|  |  |  | var content = "<table class=\"table slds-table slds-table--bordered slds-table--cell-buffer\">"; | 
|---|
|  |  |  | 
|---|
|  |  |  | $A.util.addClass(modalimport, 'disp_none'); | 
|---|
|  |  |  | $A.util.addClass(modalimportbg,'disp_none'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // searchAgencyContact : function(res) { | 
|---|
|  |  |  | //     var agencyContacts = []; | 
|---|
|  |  |  | //     for (let idx = 0; idx < res.length; idx++) { | 
|---|
|  |  |  | //         agencyContacts.push(res[idx].awsid); | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | //     var action = component.get('c.getAWStoken'); | 
|---|
|  |  |  | //     action.setCallback(this,function(response){ | 
|---|
|  |  |  | //         var state = response.getState(); | 
|---|
|  |  |  | //         console.log('state : ' + state); | 
|---|
|  |  |  | //         if(state === 'SUCCESS') { | 
|---|
|  |  |  | //             console.log('get name : ' + action.getName()); | 
|---|
|  |  |  | //         } | 
|---|
|  |  |  | //         else if(state === 'INCOMPLETE') { | 
|---|
|  |  |  | //             console.log('incomplete state'); | 
|---|
|  |  |  | //         } else if(state === 'ERROR') { | 
|---|
|  |  |  | //             if (errors) { | 
|---|
|  |  |  | //                 if (errors[0] && errors[0].message) { | 
|---|
|  |  |  | //                     console.log("Error message: " + | 
|---|
|  |  |  | //                              errors[0].message); | 
|---|
|  |  |  | //                 } | 
|---|
|  |  |  | //             } else { | 
|---|
|  |  |  | //                 console.log("Unknown error"); | 
|---|
|  |  |  | //             } | 
|---|
|  |  |  | //         } | 
|---|
|  |  |  | //     }); | 
|---|
|  |  |  | //     $A.enqueueAction(action); | 
|---|
|  |  |  | //     // var requestSearchPayload = new Map(); | 
|---|
|  |  |  | //     // requestSearchPayload.set("dataIds",agencyContacts); | 
|---|
|  |  |  | //     var data = '{"dataIds": ["944233643042144256", "943645353649897473"]}'; | 
|---|
|  |  |  | //     var token = 'eyJhbGciOiJIUzUxMiJ9.eyJjcmVhdGVkIjoxNjQ0NzY4MTIwNjc2LCJhcHBpZCI6IjZMeml6Y1JmN2g4eUx4MjgiLCJleHAiOjE2NDk5NTIxMjB9.6vORDP8BRaf_beCt4SEXrl3DEuYZ3owotkUqh27r8YhfmKDDWrv_NpVVpjTPeFjvzlQqaJMcFobZeAmPxpmq2A'; | 
|---|
|  |  |  | //     var searchUrl = 'https://52.83.101.205/api/agencycontact/search'; | 
|---|
|  |  |  | //     var data = this.search(searchUrl,data,token); | 
|---|
|  |  |  | //     return data;searchUrl,requestSearchPayload,token | 
|---|
|  |  |  | // }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }) | 
|---|