({
|
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){
|
var state = response.getState();
|
if(state == 'SUCCESS'){
|
var res = response.getReturnValue();
|
component.set('v.alldata',res.reports);
|
component.set('v.fieldsmap',res.fieldsMap);
|
component.set('v.allselectlist',res.allselectlist);
|
component.set('v.doclist',res.doclist);
|
// 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'));
|
|
component.set('v.login',false);
|
}
|
else{
|
this.error('doinit failed.');
|
component.set('v.login',false);
|
}
|
});
|
$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'){
|
if(result.object != null){
|
this.to_contact_list(result,contactData,component);
|
}else{
|
component.set('v.login',false);
|
}
|
}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");
|
dc = dc ? '%'+dc+'%' : '';
|
var purpose_type = component.find("select_purpose_type").get("v.value");
|
if (purpose_type) {
|
if (purpose_type.substr(-3) == 'OPD') {
|
purpose_type = 'OPD';
|
} else if (purpose_type.substr(-3) == 'SIS') {
|
purpose_type = 'SIS';
|
} else {
|
purpose_type = '';
|
}
|
}
|
if (dc != '' || purpose_type != '') {
|
|
var action = component.get('c.getProductList');
|
action.setParams({
|
"dc" : dc,
|
"opdsis" : purpose_type,
|
});
|
action.setCallback(this,function(response){
|
var state = response.getState();
|
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)));
|
component.find('select_Product3').set("v.options", JSON.parse(JSON.stringify(res)));
|
}
|
else{
|
this.error('getProductList failed.');
|
}
|
});
|
$A.enqueueAction(action);
|
} else {
|
component.find('select_Product1').set('v.options', []);
|
component.find('select_Product2').set('v.options', []);
|
component.find('select_Product3').set('v.options', []);
|
}
|
},
|
|
get_reports : function(component, event, helper, date_str, person_str) {
|
if (!date_str) {
|
return false;
|
}
|
|
date_str = this.get_date_string(date_str);
|
|
var action = component.get('c.getReports');
|
action.setParams({
|
"date_str" : date_str,
|
"person_str" : person_str,
|
});
|
|
component.set('v.login',true);
|
action.setCallback(this,function(response){
|
var state = response.getState();
|
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用
|
var report_id = component.get('v.update_select_report_data_id');
|
|
if (report_id != "") {
|
for (i = 0; i < res.reports.length; i++) {
|
if (res.reports[i]['Id'] == report_id) {
|
component.set('v.select_report_data', res.reports[i]);
|
break;
|
}
|
}
|
component.set('v.update_select_report_data_id', '');
|
}
|
|
if (res.reports.length > 0) {
|
component.set('v.list_message', '');
|
} else {
|
component.set('v.list_message', 'no_data');
|
}
|
component.set('v.login',false);
|
}
|
else{
|
this.error('get_reports failed.');
|
component.set('v.login',false);
|
}
|
});
|
$A.enqueueAction(action);
|
},
|
|
select_date_change : function(component, event, helper) {
|
this.get_reports(component, event, helper, component.find('select_date').get('v.value'), component.find('select_agency_person').get('v.value'));
|
this.new_button_disabled(component, event, helper);
|
|
component.set('v.select_report_data_radio', '');
|
component.find('copy_button').set('v.disabled', true);
|
},
|
|
select_agency_change : function(component, event, helper) {
|
var select_value = component.find('select_agency_person').get('v.value');
|
var new_label = this.get_agency_person_name(component, select_value);
|
component.set('v.selected_agency_person', new_label);
|
|
this.get_reports(component, event, helper, component.find('select_date').get('v.value'), select_value);
|
this.new_button_disabled(component, event, helper);
|
|
component.set('v.select_report_data_radio', '');
|
component.find('copy_button').set('v.disabled', true);
|
},
|
|
get_agency_person_name : function(component, agency_person_value) {
|
// 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) {
|
new_label = allselectlist[i].label;
|
break;
|
}
|
}
|
return new_label;
|
},
|
|
new_button_disabled : function(component, event, helper) {
|
var select_date = component.find('select_date').get('v.value');
|
var select_agency = component.find('select_agency_person').get('v.value');
|
if (select_date && select_agency) {
|
component.find('new_button').set('v.disabled', false);
|
} else {
|
component.find('new_button').set('v.disabled', true);
|
}
|
},
|
|
toggle_report : function(component) {
|
var modal_window = component.find('modal_window');
|
var modal_bg = component.find('modal_bg');
|
if ($A.util.hasClass(modal_window, 'disp_none')) {
|
// OPEN
|
$A.util.removeClass(modal_window, 'disp_none');
|
$A.util.removeClass(modal_bg, 'disp_none');
|
|
if (component.get('v.mode') == 'edit' || component.get('v.mode') == 'copy') {
|
var select_data = '';
|
if (component.get('v.mode') == 'edit') {
|
select_data = component.get('v.select_report_data');
|
} else if (component.get('v.mode') == 'copy') {
|
select_data = component.get('v.select_report_data_radio');
|
}
|
|
var reports = component.get('v.reports');
|
var Agency_Hospital_text = '';
|
var Agency_Hospital_parent_id = '';
|
|
// 医院名
|
if (select_data['Agency_Hospital__c'] != '') {
|
for (var i = 0; i < reports.length; i++) {
|
if (reports[i]['Agency_Hospital__c'] == select_data['Agency_Hospital__c']) {
|
Agency_Hospital_text = reports[i]['Agency_Hospital__r']['Name'];
|
Agency_Hospital_parent_id = reports[i]['Agency_Hospital__r']['Hospital__c'];
|
}
|
}
|
component.set('v.hospital', Agency_Hospital_text);
|
component.set('v.hospitalId', Agency_Hospital_parent_id);
|
component.set('v.hospitalLinkId', select_data['Agency_Hospital__c']);
|
component.find('new_con').set('v.disabled', false);
|
}
|
|
// 科室
|
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 (select_data['Purpose_Type__c'] != '') {
|
this.set_selected(component, 'select_purpose_type', select_data['Purpose_Type__c']);
|
this.select_purpose_type(component);
|
}
|
|
// 結果
|
if (select_data['Result__c'] != '' && typeof select_data['Result__c'] !== "undefined") {
|
component.find('select_result').set('v.value', select_data['Result__c']);
|
}
|
|
// 询价
|
var report_id = component.get('v.edit_copy_select_report_id');
|
if (report_id != "") {
|
var select_opp = '';
|
var select_product_category1 = '';
|
var select_product_category2 = '';
|
var select_product_category3 = '';
|
var reportDate;
|
var i = 0;
|
for (i = 0; i < reports.length; i++) {
|
if (report_id == reports[i]["Id"]) {
|
select_opp = reports[i]["Opportunity__c"];
|
select_product_category1 = reports[i]["Product_Category1__c"];
|
select_product_category2 = reports[i]["Product_Category2__c"];
|
select_product_category3 = reports[i]["Product_Category3__c"];
|
reportDate = reports[i]["Report_Date__c"];
|
break;
|
}
|
}
|
|
// 询价
|
if (select_opp != null && select_opp != '') {
|
var select_opp_name = component.get('v.reports')[i].OppName__c;
|
component.set('v.data.Opportunity__c', select_opp);
|
if ($A.get("$Browser.formFactor") == 'DESKTOP') {
|
var values = [{
|
type: 'Agency_Opportunity__c',
|
id: select_opp,
|
label: select_opp_name,
|
icon : {
|
url:'/img/icon/t4v35/custom/custom12_120.png',
|
backgroundColor:'dc71d1',
|
alt:'Agency_Opportunity__c'
|
}
|
}];
|
component.set('v.data.Opportunity__c', select_opp);
|
// component.find('input-opportunity').get("v.body")[0].set('v.values', values);
|
} else {
|
component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', select_opp_name);
|
}
|
}
|
|
// 产品区分
|
if (select_product_category1 != null && select_product_category1 != '') {
|
component.find('select_Product1').set('v.value', select_product_category1);
|
}
|
if (select_product_category2 != null && select_product_category2 != '') {
|
component.find('select_Product2').set('v.value', select_product_category2);
|
}
|
if (select_product_category3 != null && select_product_category3 != '') {
|
component.find('select_Product3').set('v.value', select_product_category3);
|
}
|
|
if (reportDate != null) {
|
component.set('v.data.Report_Date__c', reportDate);
|
}
|
|
component.set('v.edit_copy_select_report_id', "");
|
}
|
}
|
} else {
|
// CLOSE
|
|
var select_report_data = component.get('v.select_report_data');
|
var Report_Date__c = component.get('v.data.Report_Date__c');
|
var Agency_Hospital__c = component.get('v.hospitalLinkId');
|
var Department_Cateogy__c = component.find('select_department').get('v.value');
|
var doctor2__c = component.find('select_doctor').get('v.value');
|
var Purpose_Type__c = component.find('select_purpose_type').get('v.value');
|
var Opportunity__c = component.get('v.data.Opportunity__c');
|
var Product_Category1__c = component.find('select_Product1').get('v.value');
|
var Product_Category2__c = component.find('select_Product2').get('v.value');
|
var Product_Category3__c = component.find('select_Product3').get('v.value');
|
var Result__c = component.find('select_result').get('v.value');
|
|
if (select_report_data !== null) {
|
if (typeof select_report_data['Opportunity__c'] === "undefined") {
|
select_report_data['Opportunity__c'] = "";
|
}
|
if (typeof select_report_data['Product_Category1__c'] === "undefined") {
|
select_report_data['Product_Category1__c'] = "";
|
}
|
if (typeof select_report_data['Product_Category2__c'] === "undefined") {
|
select_report_data['Product_Category2__c'] = "";
|
}
|
if (typeof select_report_data['Product_Category3__c'] === "undefined") {
|
select_report_data['Product_Category3__c'] = "";
|
}
|
if (typeof select_report_data['Result__c'] === "undefined") {
|
select_report_data['Result__c'] = "";
|
}
|
}
|
|
if (component.get('v.mode') == 'new') {
|
var confirm_title = '警告!'
|
var confirm_text = '放弃新建周报?';
|
|
if (!Report_Date__c &&
|
!Agency_Hospital__c &&
|
!Department_Cateogy__c &&
|
!doctor2__c &&
|
!Purpose_Type__c &&
|
!Opportunity__c &&
|
!Product_Category1__c &&
|
!Product_Category2__c &&
|
!Product_Category3__c &&
|
!Result__c)
|
{
|
this.allclear(component);
|
$A.util.addClass(modal_window, 'disp_none');
|
$A.util.addClass(modal_bg, 'disp_none');
|
} else {
|
this.close_confirm(component, confirm_title, confirm_text);
|
}
|
} else if (component.get('v.mode') == 'copy') {
|
var confirm_title = '警告!'
|
var confirm_text = '放弃新建周报?';
|
|
if (select_report_data['Report_Date__c'] == Report_Date__c &&
|
select_report_data['Agency_Hospital__c'] == Agency_Hospital__c &&
|
select_report_data['Department_Cateogy__c'] == Department_Cateogy__c &&
|
select_report_data['doctor2__c'] == doctor2__c &&
|
select_report_data['Purpose_Type__c'] == Purpose_Type__c &&
|
select_report_data['Opportunity__c'] == Opportunity__c &&
|
select_report_data['Product_Category1__c'] == Product_Category1__c &&
|
select_report_data['Product_Category2__c'] == Product_Category2__c &&
|
select_report_data['Product_Category3__c'] == Product_Category3__c &&
|
select_report_data['Result__c'] == Result__c)
|
{
|
this.allclear(component);
|
$A.util.addClass(modal_window, 'disp_none');
|
$A.util.addClass(modal_bg, 'disp_none');
|
} else {
|
this.close_confirm(component, confirm_title, confirm_text);
|
}
|
} else if (component.get('v.mode') == 'edit') {
|
var confirm_title = '警告!'
|
var confirm_text = '放弃编辑周报?';
|
|
if (select_report_data['Report_Date__c'] == Report_Date__c &&
|
select_report_data['Agency_Hospital__c'] == Agency_Hospital__c &&
|
select_report_data['Department_Cateogy__c'] == Department_Cateogy__c &&
|
select_report_data['doctor2__c'] == doctor2__c &&
|
select_report_data['Purpose_Type__c'] == Purpose_Type__c &&
|
select_report_data['Opportunity__c'] == Opportunity__c &&
|
select_report_data['Product_Category1__c'] == Product_Category1__c &&
|
select_report_data['Product_Category2__c'] == Product_Category2__c &&
|
select_report_data['Product_Category3__c'] == Product_Category3__c &&
|
select_report_data['Result__c'] == Result__c)
|
{
|
this.allclear(component);
|
$A.util.addClass(modal_window, 'disp_none');
|
$A.util.addClass(modal_bg, 'disp_none');
|
} else {
|
this.close_confirm(component, confirm_title, confirm_text);
|
}
|
}
|
|
}
|
},
|
|
close_confirm : function(component, title, text) {
|
var confirm_status = component.get('v.confirm_status');
|
component.set('v.modal_confirm_title', title);
|
component.set('v.modal_confirm_text', text);
|
var modal_window = component.find('modal_window');
|
var modal_bg = component.find('modal_bg');
|
var modal_confirm = component.find('modal_confirm');
|
var modal_confirm_bg = component.find('modal_confirm_bg');
|
|
if (confirm_status == 0) {
|
$A.util.addClass(modal_window, 'disp_none');
|
$A.util.addClass(modal_bg, 'disp_none');
|
$A.util.removeClass(modal_confirm, 'disp_none');
|
$A.util.removeClass(modal_confirm_bg, 'disp_none');
|
} else if (confirm_status == 1) {
|
// 是
|
$A.util.addClass(modal_confirm, 'disp_none');
|
$A.util.addClass(modal_confirm_bg, 'disp_none');
|
component.set('v.mode', '');
|
this.allclear(component);
|
component.set('v.reports_now', "");
|
component.set('v.reports_now_count', 0);
|
component.set('v.confirm_status', 0);
|
} else if (confirm_status == 2) {
|
// 否
|
$A.util.removeClass(modal_window, 'disp_none');
|
$A.util.removeClass(modal_bg, 'disp_none');
|
$A.util.addClass(modal_confirm, 'disp_none');
|
$A.util.addClass(modal_confirm_bg, 'disp_none');
|
component.set('v.confirm_status', 0);
|
}
|
},
|
|
new_report : function(component, event, helper) {
|
component.set('v.mode', 'new');
|
component.set('v.dialog_type', '新建');
|
var select_date = component.find('select_date').get('v.value');
|
var select_agency = component.find('select_agency_person').get('v.value');
|
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) {
|
this.allclear(component);
|
component.set('v.mode', 'copy');
|
component.set('v.dialog_type', '新建');
|
var select_report_data = component.get('v.select_report_data_radio');
|
component.set('v.loadOpp', true);
|
// 週
|
var now = new Date();
|
var start_day = new Date(now.getFullYear(), now.getMonth(), (now.getDate() - now.getDay() + 1));
|
var select_date = start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate();
|
this.set_selected(component, 'select_date', select_date);
|
component.set('v.selected_date', select_date);
|
|
// 担当
|
var select_agency = select_report_data['Person_In_Charge2__c'];
|
var new_label = this.get_agency_person_name(component, select_agency);
|
component.set('v.selected_agency_person', new_label);
|
this.set_selected(component, 'select_agency_person', select_agency);
|
|
this.new_button_disabled(component, event, helper);
|
|
var name = component.get('v.selected_agency_person');
|
|
component.set('v.edit_copy_select_report_id', select_report_data['Id']);
|
component.set('v.select_report_data', select_report_data);
|
|
var ret = this.create_report_header(component, name, select_agency, select_date);
|
},
|
|
change_report_radio : function(component, event, helper) {
|
var reports = component.get('v.reports');
|
for (var i = 0; i < reports.length; i++) {
|
if (reports[i].Name == event.getSource().get('v.label')) {
|
component.set('v.select_report_data_radio', reports[i]);
|
component.find('copy_button').set('v.disabled', false);
|
break;
|
}
|
}
|
},
|
|
edit_button : function(component, event, helper) {
|
this.allclear(component);
|
component.set('v.loadOpp', true);
|
var index = event.getSource().get('v.value');
|
component.set('v.select_report_data', component.get('v.reports')[index]);
|
component.set('v.mode', 'edit');
|
component.set('v.dialog_type', '编辑');
|
|
var select_date = component.get('v.reports')[index].Submit_date__c;
|
var select_agency = component.get('v.reports')[index].Person_In_Charge2__c;
|
var text_tmp = select_date.split('-');
|
var select_date_text = text_tmp[0] + '/' + Number(text_tmp[1]) + '/' + Number(text_tmp[2]);
|
component.set('v.selected_date', select_date_text);
|
var name = component.get('v.reports')[index].Person_In_Charge2__r.Name;
|
|
this.set_selected(component, 'select_agency_person', select_agency);
|
this.new_button_disabled(component, event, helper);
|
|
var new_label = this.get_agency_person_name(component, select_agency);
|
component.set('v.selected_agency_person', new_label);
|
|
component.set('v.edit_copy_select_report_id', component.get('v.reports')[index].Id);
|
|
var ret = this.create_report_header(component, name, select_agency, select_date);
|
},
|
|
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');
|
// alert('Report_Date__c'+Report_Date__c);
|
var Person_In_Charge2__c = "";
|
var Submit_date__c = "";
|
if (component.get('v.mode') == 'edit') {
|
// 周 Submit_date__c
|
Submit_date__c = component.get('v.select_report_data').Submit_date__c;
|
// alert('Submit_date__c'+Submit_date__c);
|
|
|
// 担当 Person_In_Charge2__c
|
Person_In_Charge2__c = component.get('v.select_report_data').Person_In_Charge2__c;
|
} else {
|
// 周 Submit_date__c
|
Submit_date__c = this.get_date_string(component.find('select_date').get('v.value'));
|
// alert('Submit_date__c'+Submit_date__c);
|
|
// 担当 Person_In_Charge2__c
|
Person_In_Charge2__c = component.find('select_agency_person').get('v.value');
|
}
|
// Agency_Report_Header__c
|
var Agency_Report_Header__c = component.get('v.agency_report_header_id');
|
|
// 医院 Agency_Hospital__c (Agency_Hospital_Link__c)
|
var Agency_Hospital__c = component.get('v.hospitalLinkId');
|
|
// 科室 Department_Cateogy__c
|
var Department_Cateogy__c = component.find('select_department').get('v.value');
|
|
// 拜访人 doctor2__c
|
var doctor2__c = component.find('select_doctor').get('v.value');
|
|
// 活动区分 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');
|
|
var StageName__c = component.find('select_stageName').get('v.value');
|
var Amount__c = component.get('v.oppdata.Amount__c') != null ? component.get('v.oppdata.Amount__c').toString() : '';
|
var OCMSale_Price__c = component.get('v.oppdata.OCMSale_Price__c') != null ? component.get('v.oppdata.OCMSale_Price__c').toString() : '';
|
var Close_Forecasted_Date__c = component.get('v.oppdata.Close_Forecasted_Date__c');
|
|
var StageName__c_o = component.get('v.StageName__c_o');
|
var Amount__c_o = component.get('v.Amount__c_o');
|
var OCMSale_Price__c_o = component.get('v.OCMSale_Price__c_o');
|
var Close_Forecasted_Date__c_o = component.get('v.Close_Forecasted_Date__c_o');
|
if (StageName__c_o == undefined) StageName__c_o = '';
|
if (Amount__c_o == undefined) Amount__c_o = '';
|
if (OCMSale_Price__c_o == undefined) OCMSale_Price__c_o = '';
|
if (Close_Forecasted_Date__c_o == undefined) Close_Forecasted_Date__c_o = '';
|
if (StageName__c == StageName__c_o && OCMSale_Price__c_o == OCMSale_Price__c && Amount__c == Amount__c_o && Close_Forecasted_Date__c == Close_Forecasted_Date__c_o) {
|
StageName__c = '';
|
Amount__c = '';
|
OCMSale_Price__c = '';
|
Close_Forecasted_Date__c = '';
|
}
|
|
// 产品区分 Product_Category__c (ProductTypes__c)
|
var Product_Category1__c = component.find('select_Product1').get('v.value');
|
var Product_Category2__c = component.find('select_Product2').get('v.value');
|
var Product_Category3__c = component.find('select_Product3').get('v.value');
|
|
// 結果 Result__c
|
var Result__c = component.find('select_result').get('v.value');
|
|
// バリデーション
|
var error = [];
|
if (!Report_Date__c) { error.push("活动日 不存在"); }
|
if (!Submit_date__c) { error.push("周 不存在"); }
|
var rDate = new Date(Report_Date__c);
|
var sDate = new Date(Submit_date__c);
|
sDate.setDate(sDate.getDate() - 1);
|
if (rDate < sDate) {error.push('活动日必须是本周!'); }
|
sDate.setDate(sDate.getDate() + 7);
|
if (rDate >= sDate) {error.push('活动日必须是本周!'); }
|
|
if (!Person_In_Charge2__c) { error.push("担当 不存在"); }
|
if (!Agency_Report_Header__c) { this.error("Report Header Id 不存在"); }
|
if (!Agency_Hospital__c) { error.push("医院 不存在"); }
|
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 (!Result__c) { error.push("结果 不存在"); }
|
}
|
for (var i = 0; i < error.length; i++) {
|
this.warning(error[i]);
|
}
|
if (error.length > 0) {
|
component.find('save_button').set('v.disabled', false);
|
return false;
|
}
|
|
|
// 保存処理
|
component.set('v.login',true);
|
if (component.get('v.mode') == 'edit') {
|
var Agency_Report__c = component.get('v.select_report_data').Id;
|
var action = component.get('c.editAgencyReport');
|
debugger
|
// 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,
|
"doctor" : doctor2__c,
|
"Submit_date" : Submit_date__c,
|
"Product_Category1" : Product_Category1__c,
|
"Product_Category2" : Product_Category2__c,
|
"Product_Category3" : Product_Category3__c,
|
"Result" : Result__c,
|
"Opportunity" : Opportunity__c,
|
"StageName" : StageName__c,
|
"oppAmount" : Amount__c,
|
"oppOCMPrice" : OCMSale_Price__c,
|
"Close_Forecasted_Date" : Close_Forecasted_Date__c,
|
"Report_Date" : Report_Date__c,
|
});
|
|
action.setCallback(this,function(response){
|
var state = response.getState();
|
if(state == 'SUCCESS'){
|
this.success('编辑保存成功');
|
var report_id = response.getReturnValue();
|
component.set('v.create_agency_report_id', report_id);
|
|
var select_agency_list = component.get('v.allselectlist').AgencyPerson__c;
|
for (var i = 0; i < select_agency_list.length; i++) {
|
if (select_agency_list[i].value == component.get('v.select_report_data').Person_In_Charge2__c) {
|
select_agency_list[i].selected = true;
|
} else {
|
select_agency_list[i].selected = false;
|
}
|
}
|
component.find('select_agency_person').set('v.options', select_agency_list);
|
|
component.set('v.update_select_report_data_id', report_id);
|
this.get_reports(component, event, helper, component.get('v.select_report_data').Submit_date__c, component.get('v.select_report_data').Person_In_Charge2__c);
|
|
component.find('save_button').set('v.disabled', false);
|
component.set('v.login',false);
|
}
|
else{
|
// var error = response.getError();
|
// alert(JSON.stringify(error));
|
// alert(JSON.stringify(error[0].fieldErrors));
|
// alert(JSON.stringify(error[0].fieldErrors.next()));
|
// alert(JSON.stringify(error[0].fieldErrors.next()[0]));
|
// if (this.error(response.getError()[0].message))
|
// else () {
|
// error[0].fieldErrors[0]
|
// }
|
this.error('save_report failed.');
|
component.find('save_button').set('v.disabled', false);
|
component.set('v.login',false);
|
}
|
});
|
$A.enqueueAction(action);
|
} else {
|
/* Save (New & Copy) */
|
|
var action = component.get('c.saveAgencyReport');
|
debugger;
|
// alert(SupportNeeds__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,
|
"doctor" : doctor2__c,
|
"Submit_date" : Submit_date__c,
|
"Product_Category1" : Product_Category1__c,
|
"Product_Category2" : Product_Category2__c,
|
"Product_Category3" : Product_Category3__c,
|
"Result" : Result__c,
|
"Opportunity" : Opportunity__c,
|
"StageName" : StageName__c,
|
"oppAmount" : Amount__c,
|
"oppOCMPrice" : OCMSale_Price__c,
|
"Close_Forecasted_Date" : Close_Forecasted_Date__c,
|
"Report_Date" : Report_Date__c,
|
});
|
|
action.setCallback(this,function(response){
|
var state = response.getState();
|
if(state == 'SUCCESS'){
|
this.success('保存成功');
|
var report_id = response.getReturnValue();
|
component.set('v.create_agency_report_id', report_id);
|
|
this.get_reports(component, event, helper, component.find('select_date').get('v.value'), component.find('select_agency_person').get('v.value'));
|
|
// モーダルウィンドウ内の一覧用
|
var action2 = component.get('c.getReportsById');
|
action2.setParams({
|
"report_id" : report_id,
|
});
|
action2.setCallback(this,function(response){
|
var state = response.getState();
|
if(state == 'SUCCESS'){
|
var res = response.getReturnValue();
|
var reports_now = component.get('v.reports_now');
|
var reports_now_count = 0;
|
if (reports_now.length > 0 && reports_now != "") {
|
reports_now_count = reports_now.length;
|
}
|
|
// 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) {
|
if(a.Name>b.Name) return -1;
|
if(a.Name < b.Name) return 1;
|
return 0;
|
});
|
|
component.set('v.reports_now', reports_now);
|
component.set('v.reports_now_count', reports_now.length);
|
var data_list = component.find('modal_data_list_tr');
|
}
|
}
|
else{
|
this.error('get_reports_now failed.');
|
component.find('save_button').set('v.disabled', false);
|
component.set('v.login',false);
|
}
|
});
|
$A.enqueueAction(action2);
|
|
this.allclear(component);
|
component.find('save_button').set('v.disabled', false);
|
component.set('v.login',false);
|
}
|
else{
|
var error = response.getError();
|
// alert(JSON.stringify(error));
|
this.error('saveAgencyReport failed.');
|
component.find('save_button').set('v.disabled', false);
|
component.set('v.login',false);
|
}
|
});
|
$A.enqueueAction(action);
|
}
|
},
|
|
allclear : function(component) {
|
var clear = [{label:'', value:'', selected:true}];
|
component.set('v.hospital', '');
|
component.set('v.hospitalId', '');
|
component.set('v.hospitalLinkId', '');
|
component.find('new_con').set('v.disabled', true);
|
component.find('select_doctor').set('v.options', clear);
|
component.set('v.doctor_title', '');
|
component.find('select_department').set('v.options', this.conv_selected(component.get('v.allselectlist.Department_Cateogy__c')));
|
component.find('select_purpose_type').set('v.options', this.conv_selected(component.get('v.allselectlist.Purpose_Type__c')));
|
// ToDo需要测试手机上能运行不
|
component.set('v.data.Opportunity__c', '');
|
component.find('select_Product1').set('v.value','');
|
component.find('select_Product2').set('v.value','');
|
component.find('select_Product3').set('v.value','');
|
component.set('v.data.Report_Date__c', '');
|
component.set('v.oppdata.Close_Forecasted_Date__c', '');
|
component.set('v.oppdata.Amount__c', '');
|
component.set('v.oppdata.OCMSale_Price__c', '');
|
component.set('v.oppdata.StageName__c', '');
|
// component.set('v.oppdata', '');
|
component.set('v.Close_Forecasted_Date__c_o', '');
|
component.set('v.Amount__c_o', '');
|
component.set('v.OCMSale_Price__c_o', '');
|
component.set('v.StageName__c_o', '');
|
$A.util.addClass(component.find('input-opportunity-stage'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount1'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount2'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-date'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
|
// if ($A.get("$Browser.formFactor") == 'DESKTOP') {
|
// var values = [];
|
// component.find('input-opportunity').get("v.body")[0].set('v.values', values);
|
// } else {
|
// component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
|
// }
|
// component.find('input-opportunity').set("v.body",[]);
|
// if (component.find('input-product-category1'))
|
// component.find('input-product-category1').get("v.body")[0].set('v.values', values);
|
// if (component.find('input-product-category2'))
|
// component.find('input-product-category2').get("v.body")[0].set('v.values', values);
|
// if (component.find('input-product-category3'))
|
// component.find('input-product-category3').get("v.body")[0].set('v.values', values);
|
component.find('select_result').set('v.value', '');
|
this.select_purpose_type(component);
|
},
|
|
report_date_list : function(component, event, helper, count) {
|
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();
|
if (i == 0) {
|
ret_obj.push({
|
selected : true,
|
value : start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate(),
|
label : start_day_show.getFullYear() + '/' + (start_day_show.getMonth() + 1) + '/' + start_day_show.getDate() + '~' + end_day_show.getFullYear() + '/' + (end_day_show.getMonth() + 1) + '/' + end_day_show.getDate(),
|
});
|
} else {
|
ret_obj.push({
|
selected : false,
|
value : start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate(),
|
label : start_day_show.getFullYear() + '/' + (start_day_show.getMonth() + 1) + '/' + start_day_show.getDate() + '~' + end_day_show.getFullYear() + '/' + (end_day_show.getMonth() + 1) + '/' + end_day_show.getDate(),
|
});
|
}
|
}
|
|
component.find('select_date').set('v.options', ret_obj);
|
component.set('v.report_date_list', ret_obj);
|
},
|
|
create_report_header : function(component, name, s_agency, s_date) {
|
s_date = this.get_date_string(s_date);
|
if (s_date == false) {
|
this.error('get_date_string failed.');
|
return false;
|
}
|
|
var head_key = this.create_header_input_key(s_agency, s_date);
|
component.set('v.agency_report_header', head_key);
|
if (head_key == false) {
|
this.error('create_header_input_key failed.');
|
return false;
|
}
|
|
var key2 = s_date.replace(/-/g, '');
|
var action = component.get('c.createReportHeader');
|
|
action.setParams({
|
"name" : name,
|
"s_date" : s_date,
|
"s_agency" : s_agency,
|
"head_key" : head_key,
|
});
|
|
component.set('v.login',true);
|
action.setCallback(this,function(response){
|
var state = response.getState();
|
if(state == 'SUCCESS'){
|
var res = response.getReturnValue();
|
component.set('v.agency_report_header_id', res);
|
component.set('v.login',false);
|
this.toggle_report(component);
|
}
|
else{
|
this.error('createReportHeader callback failed.');
|
component.set('v.login',false);
|
}
|
});
|
$A.enqueueAction(action);
|
},
|
|
create_header_input_key : function(agency_id, s_date) {
|
if (typeof(s_date) != 'string') {
|
s_date = this.get_date_string(s_date);
|
if (s_date == false) {
|
this.error('get_date_string in create_header_input_key.')
|
return false;
|
}
|
}
|
if (!agency_id || !s_date) {
|
return false;
|
}
|
|
s_date = s_date.replace(/-/g, '');
|
var headkey = agency_id + ":" + s_date;
|
|
return headkey;
|
},
|
|
/* typeof is not cool
|
* @ret : String, Boolean, Date, Error, Array, Function, Null, Undefined, etc
|
*/
|
object_type : function(obj) {
|
var obj_type = Object.prototype.toString.call(obj).slice(8, -1);
|
return obj_type;
|
},
|
|
// create yyyy-mm-dd string
|
get_date_string : function(val) {
|
if (typeof(val) == 'string') {
|
if (val.match(/^\d{4}\/\d{1,2}\/\d{1,2}$/)) {
|
val = val.replace(/[\/]/g, '-');
|
var tmp = val.split('-');
|
if (tmp[1].length == 1) {
|
tmp[1] = '0' + tmp[1];
|
}
|
if (tmp[2].length == 1) {
|
tmp[2] = '0' + tmp[2];
|
}
|
val = tmp[0] + '-' + tmp[1] + '-' + tmp[2];
|
} else if (val.match(/^\d{4}-\d{1,2}-\d{1,2}$/)) {
|
//ok
|
} else {
|
return false;
|
}
|
} else if (this.object_type(val) == 'Date') {
|
var mm = val.getMonth() + 1;
|
if (String(mm).length == 1) {
|
mm = '0' + mm;
|
}
|
|
var dd = '';
|
if (String(val.getDate()).length == 1) {
|
dd = '0' + val.getDate();
|
} else {
|
dd = val.getDate();
|
}
|
|
val = val.getFullYear() + '-' + mm + '-' + dd;
|
} else {
|
return false;
|
}
|
|
return val;
|
},
|
|
searchHos : function(component, event, helper) {
|
var hospital_name = event.getParam("value");
|
var action = component.get("c.getHospitalList");
|
debugger;
|
action.setParams({"hospital_name": hospital_name});
|
|
action.setCallback(this, function(response) {
|
var state = response.getState();
|
if(state === "SUCCESS") {
|
var hospital_list = component.find('hospital_list');
|
var hosList = response.getReturnValue();
|
if (hosList.length > 0) {
|
$A.util.addClass(hospital_list, 'slds-is-open');
|
} else {
|
$A.util.removeClass(hospital_list, 'slds-is-open');
|
}
|
component.set("v.hospitalList", response.getReturnValue());
|
} else {
|
$A.util.removeClass(hospital_list, 'slds-is-open');
|
}
|
});
|
$A.enqueueAction(action);
|
},
|
|
hideSearch : function(component, event, helper) {
|
var hospital_list = component.find('hospital_list');
|
$A.util.removeClass(hospital_list, 'slds-is-open');
|
},
|
|
selectHos : function(component, event, helper) {
|
debugger
|
var hospital_list = component.find('hospital_list');
|
$A.util.removeClass(hospital_list, 'slds-is-open');
|
var accname = event.currentTarget.dataset.accname;
|
var accid = event.currentTarget.dataset.accid;
|
var hospital_data = component.get('v.hospitalList');
|
for (var i = 0; i < hospital_data.length; i++) {
|
if (hospital_data[i].Hospital__c == accid) {
|
component.set('v.hospitalLinkId', hospital_data[i].Id);
|
component.set('v.data.Agency_Hospital__c', hospital_data[i].Id);
|
component.find('new_con').set('v.disabled', false);
|
//break;
|
}
|
}
|
component.set("v.hospital", accname);
|
component.set("v.hospitalId", accid);
|
this.set_doctor_list(component);
|
this.opportunityChange(component, event, helper);
|
},
|
|
select_purpose_type : function(component) {
|
var purpose_type = component.find('select_purpose_type').get('v.value');
|
if (purpose_type != null && purpose_type != undefined && purpose_type.substr(-3) == 'OPD' || purpose_type.substr(-3) == 'SIS') {
|
var result = component.find('result');
|
$A.util.removeClass(result, 'disp_none');
|
} else {
|
component.find('select_result').set('v.value', '');
|
var result = component.find('result');
|
$A.util.addClass(result, 'disp_none');
|
}
|
this.select_department(component, null, null);
|
},
|
|
doctor_change : function(component, event, helper) {
|
var doctor_value = component.find('select_doctor').get('v.value');
|
var doctor_list = component.get('v.doctor_list');
|
var flg = false;
|
for (var i = 0; i < doctor_list.length; i++) {
|
if (doctor_list[i].value == doctor_value) {
|
component.set('v.doctor_title', doctor_list[i].Doctor_Division1__c);
|
flg = true;
|
break;
|
}
|
}
|
if (flg == false) {
|
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) {
|
|
AWSService.insert(newUrl,payload,function(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.');
|
}
|
},token);
|
/*
|
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) {
|
component.set('v.login',true);
|
var action = component.get('c.getDoctorList');
|
action.setParams({
|
"hospital_id" : hospital_id,
|
});
|
action.setCallback(this,function(response){
|
var state = response.getState();
|
if(state == 'SUCCESS'){
|
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 = '';
|
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
|
}
|
else{
|
this.error('set_doctor_list failed.');
|
component.set('v.login',false);
|
}
|
});
|
$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);
|
}
|
if(dataArr.length == 0){
|
component.set('v.login',false);
|
this.warning('没有找到符合条件的客户人员');
|
return;
|
}
|
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');
|
// var remove;
|
// for (var i = 0; i < options.length; i++) {
|
// if (options[i].label == '目标') {
|
// remove = i;
|
// break;
|
// }
|
// }
|
// options.splice(remove,1);
|
// },
|
|
opportunityChange : function(component, event, helper) {
|
var opp_id = component.get('v.data.Opportunity__c');
|
if (opp_id == '') {
|
$A.util.addClass(component.find('input-opportunity-stage'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount1'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount2'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-date'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
|
} else if (opp_id == 'MALFORMED_ID') {
|
component.set('v.data.Opportunity__c', '');
|
$A.util.addClass(component.find('input-opportunity-stage'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount1'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount2'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-date'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
|
} else if (opp_id != "") {
|
var hospital_link_id = component.get('v.hospitalLinkId');
|
if (hospital_link_id == '') {
|
this.warning('医院不存在');
|
// ToDo需要测试手机上能运行不
|
component.set('v.data.Opportunity__c', '');
|
$A.util.addClass(component.find('input-opportunity-stage'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount1'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount2'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-date'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
|
// if ($A.get("$Browser.formFactor") == 'DESKTOP') {
|
// var values = [];
|
// // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
|
// } else {
|
// component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
|
// }
|
return false;
|
}
|
var action = component.get('c.selectOpportunityByIdAndHospitalLinkId');
|
action.setParams({
|
"opportunity_id" : opp_id,
|
"agency_hospital_link_id" : component.get('v.hospitalLinkId'),
|
});
|
|
component.set('v.login',true);
|
action.setCallback(this,function(response){
|
var state = response.getState();
|
if(state == 'SUCCESS'){
|
var res = response.getReturnValue();
|
if (res.length <= 0) {
|
if (component.get('v.data.Opportunity__c')) {
|
this.warning('医院未匹配到');
|
}
|
// ToDo需要测试手机上能运行不
|
component.set('v.data.Opportunity__c', '');
|
$A.util.addClass(component.find('input-opportunity-stage'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount1'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount2'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-date'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
|
// if ($A.get("$Browser.formFactor") == 'DESKTOP') {
|
// var values = [];
|
// component.find('input-opportunity').get("v.body")[0].set('v.values', values);
|
// } else {
|
// component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
|
// }
|
component.set('v.login',false);
|
return false;
|
} else if (res[0]['StageName2__c'] != '3.询价' && !component.get('v.loadOpp')){
|
this.warning('请选择询价中的项目');
|
// ToDo需要测试手机上能运行不
|
component.set('v.data.Opportunity__c', '');
|
$A.util.addClass(component.find('input-opportunity-stage'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount1'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-amount2'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-date'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
|
// if ($A.get("$Browser.formFactor") == 'DESKTOP') {
|
// var values = [];
|
// component.find('input-opportunity').get("v.body")[0].set('v.values', values);
|
// } else {
|
// component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
|
// }
|
component.set('v.login',false);
|
return false;
|
} else {
|
component.set('v.loadOpp', false);
|
component.set('v.oppdata',res[0]);
|
this.set_selected(component, 'select_stageName', res[0].StageName__c);
|
component.set('v.Close_Forecasted_Date__c_o', res[0].Close_Forecasted_Date__c);
|
component.set('v.Amount__c_o', res[0].Amount__c);
|
component.set('v.OCMSale_Price__c_o', res[0].OCMSale_Price__c);
|
component.set('v.StageName__c_o', res[0].StageName__c);
|
|
$A.util.removeClass(component.find('input-opportunity-stage'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-amount1'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-amount2'), 'disp_none');
|
$A.util.removeClass(component.find('input-opportunity-date'), 'disp_none');
|
$A.util.addClass(component.find('input-opportunity-blank'), 'disp_none');
|
}
|
|
component.set('v.login',false);
|
}
|
else{
|
this.error('selectOpportunityByIdAndHospitalLinkId failed.');
|
component.set('v.login',false);
|
}
|
});
|
$A.enqueueAction(action);
|
}
|
},
|
|
productcategoryChange1 : function(component, event, helper) {
|
var product_category_id = component.find('select_Product1').get('v.value');
|
var pcId1 = component.find('select_Product2').get('v.value');
|
var pcId2 = component.find('select_Product3').get('v.value');
|
var p1bool = pcId1 != '' && pcId1 != null && pcId1 != undefined;
|
var p2bool = pcId2 != '' && pcId2 != null && pcId2 != undefined;
|
var p0bool = product_category_id != '' && product_category_id != null && product_category_id != undefined;
|
if ((p1bool && p0bool && product_category_id == pcId1) || (p2bool && p0bool && product_category_id == pcId2)) {
|
this.warning('不能选择同样的产品区分');
|
component.find('select_Product1').set('v.value','');
|
}
|
},
|
productcategoryChange2 : function(component, event, helper) {
|
var product_category_id = component.find('select_Product2').get('v.value');
|
var pcId1 = component.find('select_Product1').get('v.value');
|
var pcId2 = component.find('select_Product3').get('v.value');
|
var p1bool = pcId1 != '' && pcId1 != null && pcId1 != undefined;
|
var p2bool = pcId2 != '' && pcId2 != null && pcId2 != undefined;
|
var p0bool = product_category_id != '' && product_category_id != null && product_category_id != undefined;
|
if ((p1bool && p0bool && product_category_id == pcId1) || (p2bool && p0bool && product_category_id == pcId2)) {
|
this.warning('不能选择同样的产品区分');
|
component.find('select_Product2').set('v.value','');
|
}
|
},
|
productcategoryChange3 : function(component, event, helper) {
|
var product_category_id = component.find('select_Product3').get('v.value');
|
var pcId1 = component.find('select_Product1').get('v.value');
|
var pcId2 = component.find('select_Product2').get('v.value');
|
var p1bool = pcId1 != '' && pcId1 != null && pcId1 != undefined;
|
var p2bool = pcId2 != '' && pcId2 != null && pcId2 != undefined;
|
var p0bool = product_category_id != '' && product_category_id != null && product_category_id != undefined;
|
if ((p1bool && p0bool && product_category_id == pcId1) || (p2bool && p0bool && product_category_id == pcId2)) {
|
this.warning('不能选择同样的产品区分');
|
component.find('select_Product3').set('v.value','');
|
}
|
},
|
|
conv_selected : function(obj) {
|
for (var i = 0; i < obj.length; i++) {
|
if (obj[i].selected) {
|
if (obj[i].selected == 'true') {
|
obj[i].selected = true;
|
} else {
|
obj[i].selected = false;
|
}
|
}
|
}
|
|
return obj;
|
},
|
|
set_selected : function (component, aura_id_name, value) {
|
var select_tmp = component.find(aura_id_name).get('v.options');
|
if (select_tmp) {
|
for (var i = 0; i < select_tmp.length; i++) {
|
if (select_tmp[i].value == value) {
|
select_tmp[i].selected = true;
|
} else {
|
select_tmp[i].selected = false;
|
}
|
}
|
component.find(aura_id_name).set('v.options', select_tmp);
|
return true;
|
} else {
|
return false;
|
}
|
},
|
|
success : function(message) {
|
var toastEvent = $A.get("e.force:showToast");
|
toastEvent.setParams({
|
"title" : "成功!",
|
"message" : message,
|
"type" : "success",
|
"duration" : "5000"
|
});
|
toastEvent.fire();
|
},
|
|
warning : function(message) {
|
var toastEvent = $A.get("e.force:showToast");
|
toastEvent.setParams({
|
"title": "警告!",
|
"message": message,
|
"type":"warning",
|
"duration" : "10000"
|
});
|
toastEvent.fire();
|
},
|
|
error : function(message) {
|
// $('toastMessage.forceToastManager').css('white-space', 'pre-wrap');
|
var toastEvent = $A.get("e.force:showToast");
|
|
toastEvent.setParams({
|
"title": "错误!",
|
"message": message,
|
"type":"error",
|
"duration" : "sticky"
|
});
|
toastEvent.fire();
|
},
|
|
createCon : function(component, event, helper) {
|
var modal_newAC = component.find('modal_newAC')
|
$A.util.removeClass(modal_newAC, 'disp_none');
|
component.set('v.truthy', true);
|
// var modal_newAC = component.find('modal_newAC')
|
// $A.util.removeClass(modal_newAC, 'disp_none');
|
},
|
|
// vivek start 添加验证
|
// handleFormSubmit : function(component) {
|
// var showValidationError = false;
|
// var fields = component.find("newOpportunityField");
|
// var vaildationFailReason = '';
|
// var currentDate = new Date().toJSON().slice(0,10);
|
|
// fields.forEach(function (field) {
|
// if(field.get("v.fieldName") === 'Type__c' && $A.util.isEmpty(field.get("v.value"))){
|
// showValidationError = true;
|
// vaildationFailReason = "分类不能为空!";
|
// }else if(field.get("v.fieldName") === 'Doctor_Division1__c' && $A.util.isEmpty(field.get("v.value"))){
|
// showValidationError = true;
|
// vaildationFailReason = "医生区分(职务)不能为空!";
|
// }
|
// });
|
|
// if (showValidationError) {
|
// component.find('OppMessage').setError(vaildationFailReason);
|
// }
|
// },
|
// vivek end 添加验证
|
|
hideCmp : function(component, event, helper) {
|
var div1 = component.find('report')
|
var div2 = component.find('report_list')
|
$A.util.addClass(div1, 'disp_none');
|
$A.util.addClass(div2, 'disp_none');
|
},
|
|
handleSuccess : function(component, event, helper) {
|
var insertId = event.getParams().response.Id;
|
var displayValue = event.getParams().response.fields.Name.value;
|
event.setParams({});
|
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);
|
},
|
|
createCancel : function(component, event, helper) {
|
component.set('v.truthy', false);
|
var modal_newAC = component.find('modal_newAC')
|
$A.util.addClass(modal_newAC, 'disp_none');
|
},
|
setOpportunity_cfilter : function(component) {
|
var hosId = component.get('v.hospitalId');
|
var Department_Cateogy__c = component.find('select_department').get('v.value');
|
var opportunity_cfilter = '';
|
if (hosId != '' && hosId != null) {
|
opportunity_cfilter = ' Agency_Hospital__r.Hospital__c=' + '\'' + hosId + '\'';
|
}
|
if (Department_Cateogy__c != '' && Department_Cateogy__c != null) {
|
if (opportunity_cfilter != '' && opportunity_cfilter != null) {
|
opportunity_cfilter += ' AND ';
|
}
|
opportunity_cfilter += 'Department_Cateogy__c=' + '\'' + Department_Cateogy__c + '\'';
|
}
|
component.set('v.opportunity_cfilter', opportunity_cfilter);
|
component.set('v.data.Opportunity__c', null);
|
},
|
readFile: function(component, helper, file) {
|
if (!file) return;
|
// console.log('file'+file.name);
|
if(!file.name.match(/\.(csv||CSV)$/)){
|
return alert('only support csv files');
|
}else{
|
|
reader = new FileReader();
|
reader.onerror =function errorHandler(evt) {
|
switch(evt.target.error.code) {
|
case evt.target.error.NOT_FOUND_ERR:
|
alert('File Not Found!');
|
break;
|
case evt.target.error.NOT_READABLE_ERR:
|
alert('File is not readable');
|
break;
|
case evt.target.error.ABORT_ERR:
|
break; // noop
|
default:
|
alert('An error occurred reading this file.');
|
};
|
}
|
//reader.onprogress = updateProgress;
|
reader.onabort = function(e) {
|
alert('File read cancelled');
|
};
|
reader.onloadstart = function(e) {
|
|
var output = '<ui type=\"disc\"><li><strong>'+file.name +'</strong> ('+file.type+')- '+file.size+'bytes, last modified: '+file.lastModifiedDate.toLocaleDateString()+'</li></ui>';
|
component.set("v.filename",file.name);
|
component.set("v.TargetFileName",output);
|
|
};
|
reader.onload = function(e) {
|
var data=e.target.result;
|
component.set("v.fileContentData",data);
|
console.log("file data"+JSON.stringify(data));
|
// console.log("file data"+encodeURI(JSON.stringify(data),"utf-8"));
|
var allTextLines = data.split(/\r\n|\n/);
|
var dataRows=allTextLines.length-1;
|
var headers = allTextLines[0].split(',');
|
|
// console.log("Rows length::"+dataRows);
|
|
|
var numOfRows=component.get("v.NumOfRecords");
|
if(dataRows > numOfRows+1 || dataRows == 1 || dataRows== 0){
|
|
alert("File Rows between 1 to "+numOfRows+" .");
|
component.set("v.showMain",true);
|
|
}
|
else{
|
var lines = [];
|
var filecontentdata;
|
var content = "<table class=\"table slds-table slds-table--bordered slds-table--cell-buffer\">";
|
content += "<thead><tr class=\"slds-text-title--caps\">";
|
content += '<th scope=\"col"\>'+'行号'+'</th>';
|
for(i=0;i<headers.length; i++){
|
content += '<th scope=\"col"\>'+headers[i]+'</th>';
|
}
|
content += "</tr></thead>";
|
for (var i=1; i<allTextLines.length; i++) {
|
filecontentdata = allTextLines[i].split(',');
|
if(filecontentdata[0]!=''){
|
content +="<tr>";
|
content +="<td>"+i+"</td>";
|
for(var j=0;j<filecontentdata.length;j++){
|
content +='<td>'+filecontentdata[j]+'</td>';
|
}
|
content +="</tr>";
|
}
|
}
|
content += "</table>";
|
console.log(content);
|
component.set("v.TableContent",content);
|
component.set("v.showMain",false);
|
}
|
}
|
reader.readAsText(file,'gb2312');
|
|
}
|
var reader = new FileReader();
|
reader.onloadend = function() {
|
|
};
|
reader.readAsDataURL(file);
|
},
|
|
saveRecords : function(component,event){
|
component.set('v.login',true);
|
var action = component.get("c.processData");
|
var selectDate = component.find('select_date').get('v.value');
|
var fieldsList=['Name','Phone','AccountNumber']; //Please write your code dynamic
|
var sss=component.get("v.fileContentData");
|
action.setParams({
|
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") {
|
|
var res = response.getReturnValue();
|
var res1 = '';
|
console.log("[[[[[["+res);
|
if(res != 'success'){
|
var ress = res.split('=');
|
console.log(ress);
|
for (var i=0; i<ress.length; i++) {
|
res1 += ress[i].substr(7)+'\n';
|
}
|
// $('.forceToastManager').css('white-space', 'pre-wrap');
|
console.log("=="+res1);
|
this.error(res1+"请修改后重新上传");
|
component.set('v.login',false);
|
}else{
|
component.set("v.showMain",true);
|
this.success("导入成功");
|
// alert('saved successfully');
|
component.set('v.login',false);
|
}
|
|
}
|
else if (state === "INCOMPLETE") {
|
// do something
|
component.set('v.login',false);
|
}
|
else if (state === "ERROR") {
|
var errors = response.getError();
|
if (errors) {
|
if (errors[0] && errors[0].message) {
|
console.log("Error message: " +
|
errors[0].message);
|
component.set('v.login',false);
|
}
|
} else {
|
console.log("Unknown error");
|
component.set('v.login',false);
|
}
|
}
|
});
|
$A.enqueueAction(action);
|
|
},
|
convertArrayOfObjectsToCSV : function(component,objectRecords){
|
var csvStringResult, counter, keys, columnDivider, lineDivider,thkeys;
|
if (objectRecords == null || !objectRecords.length) {
|
return null;
|
}
|
columnDivider = ',';
|
lineDivider = '\n';
|
//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start ,'SupportNeeds__c' ,'支援需求'
|
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'];
|
thkeys = ['周','担当','活动日','医院','科室','拜访人','职位','产品区分1','产品区分2','产品区分3','活动区分','结果']
|
csvStringResult = '';
|
csvStringResult += thkeys.join(columnDivider);
|
csvStringResult += lineDivider;
|
console.log("进入导出helper");
|
for(var i=0; i < objectRecords.length; i++){
|
counter = 0;
|
for(var sTempkey in keys) {
|
var skey = keys[sTempkey];
|
if(counter > 0){
|
csvStringResult += columnDivider;
|
}
|
if(typeof objectRecords[i][skey] === "undefined"){
|
csvStringResult += '"'+''+'"';
|
continue;
|
}
|
if(skey == 'Person_In_Charge2__c'){
|
csvStringResult += '"'+ objectRecords[i].Person_In_Charge2__r.Name+'"';
|
}else if(skey == 'Agency_Hospital__c'){
|
csvStringResult += '"'+ objectRecords[i].Agency_Hospital__r.Name+'"';
|
}else if(skey == 'doctor2__c'){
|
csvStringResult += '"'+ objectRecords[i].doctor2__r.Name+'"';
|
}else if(skey == 'Product_Category1__c'){
|
csvStringResult += '"'+ objectRecords[i].Product_Category1__r.Name+'"';
|
}else if(skey == 'Product_Category2__c'){
|
csvStringResult += '"'+ objectRecords[i].Product_Category2__r.Name+'"';
|
}else if(skey == 'Product_Category3__c'){
|
csvStringResult += '"'+ objectRecords[i].Product_Category3__r.Name+'"';
|
}
|
// else if(skey == 'SupportNeeds__c'){//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
|
// csvStringResult += '"'+ objectRecords[i].SupportNeeds__c+'"';
|
// }
|
else{
|
csvStringResult += '"'+ objectRecords[i][skey]+'"';
|
}
|
counter++;
|
|
} // inner for loop close
|
console.log("导出循环结束");
|
csvStringResult += lineDivider;
|
}// outer main for loop close
|
|
// return the CSV formate String
|
return csvStringResult;
|
},
|
showExportDate : function(component,objectRecords){
|
console.log('进入showexceportdate'+objectRecords);//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start ,'SupportNeeds__c' ,'支援需求'
|
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\">";
|
content += "<thead><tr class=\"slds-text-title--caps\">";
|
for(i=0;i<headers.length; i++){
|
content += '<th scope=\"col"\>'+headers[i]+'</th>';
|
}
|
content += "</tr></thead>";
|
for(var i=0; i < objectRecords.length; i++){
|
console.log('for'+content);
|
content += '<tr>';
|
// content += '<td>'+(i+1)+'</td>';
|
for(var sTempkey in keys) {
|
console.log('for1'+sTempkey);
|
var skey = keys[sTempkey];
|
if(typeof objectRecords[i][skey] === "undefined"){
|
content += '<td>'+''+'</td>';
|
continue;
|
}
|
console.log('for2'+objectRecords[i].Person_In_Charge2__r.Name);
|
if(skey == 'Person_In_Charge2__c'){
|
content += '<td>'+ objectRecords[i].Person_In_Charge2__r.Name+'</td>';
|
}else if(skey == 'Agency_Hospital__c'){
|
content += '<td>'+ objectRecords[i].Agency_Hospital__r.Name+'</td>';
|
}else if(skey == 'doctor2__c'){
|
content += '<td>'+ objectRecords[i].doctor2__r.Name+'</td>';
|
}else if(skey == 'Product_Category1__c'){
|
content += '<td>'+ objectRecords[i].Product_Category1__r.Name+'</td>';
|
}else if(skey == 'Product_Category2__c'){
|
content += '<td>'+ objectRecords[i].Product_Category2__r.Name+'</td>';
|
}else if(skey == 'Product_Category3__c'){
|
content += '<td>'+ objectRecords[i].Product_Category3__r.Name+'</td>';
|
}
|
// else if(skey == 'SupportNeeds__c'){//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
|
// content += '<td>'+ objectRecords[i].SupportNeeds__c+'</td>';
|
// }
|
else{
|
content += '<td>'+ objectRecords[i][skey]+'</td>';
|
}
|
} // inner for loop close
|
content += '</tr>'
|
}// outer main for loop close
|
content += '</table>';
|
console.log("helper循环结束"+content);
|
component.set("v.TableContent2",content);
|
component.set("v.showMain",false);
|
},
|
|
select_repores_date : function(component,event,helper){
|
component.set('v.login',true);
|
var reportsdate1 = component.find('input-report-date1').get('v.value');
|
var reportsdate2 = component.find('input-report-date2').get('v.value');
|
console.log('输入的开始日期'+reportsdate1+'输入的结束日期'+reportsdate2);
|
var action = component.get("c.getReportsByDate");
|
console.log('输入的开始日期1');
|
action.setParams({
|
date1 : reportsdate1,
|
date2: reportsdate2
|
});
|
console.log('输入的开始日期2');
|
action.setCallback(this, function(response) {
|
var state = response.getState();
|
if (state === "SUCCESS") {
|
|
var res = response.getReturnValue();
|
console.log('输入的开始日期3'+res);
|
component.set('v.login',false);
|
|
// PI 改造 By Bright 20220328
|
if(true){
|
let awsids = [];
|
for (let ri in res) {
|
if(res[ri] && res[ri].doctor2__r && res[ri].doctor2__r.AWS_Data_Id__c){
|
awsids.push(res[ri].doctor2__r.AWS_Data_Id__c);
|
}
|
}
|
if(awsids.length > 0){
|
let awsurl = component.get('v.awsurl');
|
|
AWSService.search(awsurl.searchUrl,{
|
dataIds:awsids
|
}, function(data){
|
if(data && data.object && data.object.length){
|
let m = {};
|
for(let di in data.object){
|
if(data.object[di] && data.object[di].dataId){
|
m[data.object[di].dataId] = data.object[di];
|
}
|
}
|
|
for(let ri in res){
|
if(res[ri] && res[ri].doctor2__r && res[ri].doctor2__r.AWS_Data_Id__c && m.hasOwnProperty(res[ri].doctor2__r.AWS_Data_Id__c)){
|
res[ri].doctor2__r.Name = m[res[ri].doctor2__r.AWS_Data_Id__c].name;
|
res[ri].visitor_title__c = m[res[ri].doctor2__r.AWS_Data_Id__c].doctorDivision1;
|
|
}
|
}
|
}
|
helper.showExportDate(component, res);
|
|
component.set('v.login', false);
|
}, awsurl.token);
|
}else{
|
helper.showExportDate(component, res);
|
}
|
}
|
|
|
component.set('v.reports_date', res);
|
|
}else{
|
alert('导出失败,请检查活动日');
|
component.set('v.login',false);
|
}
|
});
|
$A.enqueueAction(action);
|
|
},
|
|
showImport : function(component){
|
// console.log('进入');
|
// component.find('file').click();
|
var modalimport = component.find('modal_import');
|
var modalimportbg = component.find('modal_importbg');
|
$A.util.removeClass(modalimport, 'disp_none');
|
$A.util.removeClass(modalimportbg,'disp_none');
|
},
|
|
showExport : function(component) {
|
var modalimport = component.find('modal_export');
|
var modalimportbg = component.find('modal_exportbg');
|
$A.util.removeClass(modalimport, 'disp_none');
|
$A.util.removeClass(modalimportbg,'disp_none');
|
},
|
|
close_import : function(component){
|
var modalimport = component.find('modal_import');
|
var modalimportbg = component.find('modal_importbg');
|
$A.util.addClass(modalimport, 'disp_none');
|
$A.util.addClass(modalimportbg,'disp_none');
|
},
|
|
close_export : function(component){
|
var modalimport = component.find('modal_export');
|
var modalimportbg = component.find('modal_exportbg');
|
$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
|
// },
|
})
|