| | |
| | | ({ |
| | | doinit: function (component, event, helper) { |
| | | document.title = "追溯日报"; |
| | | debugger |
| | | this.report_date_list(component, event, helper, 5); |
| | | component.set('v.login', true); |
| | |
| | | }, |
| | | |
| | | insert_agencycontact : function(component,token,newUrl,payload,agencyHospitalid,helper,hospitalName) { |
| | | debugger |
| | | console.log('newUrl = ' + newUrl); |
| | | console.log('payload = ' + payload); |
| | | console.log('token = ' + token); |
| | | fetch(newUrl, { |
| | | method: 'POST', |
| | | body: payload, |
| | |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | console.log('result = ' + JSON.stringify(result)); |
| | | if(result.status == '0'){ |
| | | $A.getCallback(function(){ |
| | | helper.to_agencycontact(component,result,agencyHospitalid); |
| | |
| | | this.search_contact_url(component, 'Agency_Contact__c', (result)=>{ |
| | | var token = result.token; |
| | | var searchUrl = result.searchUrl; |
| | | console.log('token = ' + token); |
| | | console.log('searchUrl = ' + searchUrl); |
| | | console.log('payload = ' + payload); |
| | | this.search_core(token,searchUrl,payload,(result)=>{ |
| | | console.log('result = ' + JSON.stringify(result)); |
| | | if(result.status == '0'){ |
| | | if(result.object != null&&result.object.length != 0){ |
| | | component.set('v.login',true); |
| | |
| | | } |
| | | |
| | | if (error != '') { |
| | | console.log('zhj error = ' + error); |
| | | let errorArray = error.split('error1'); |
| | | let errorDatas = []; |
| | | console.log('errorArray = ' + JSON.stringify(errorArray)) |
| | | for (var i in errorArray) { |
| | | if (errorArray[i] != '') { |
| | | let errorData = {} |
| | | errorData.errorRow = errorArray[i].trim().substring(1, 2); |
| | | errorData.errorInfo = errorArray[i].trim().substring(5); |
| | | errorDatas.push(errorData); |
| | | } |
| | | } |
| | | console.log('errorDatas =' + JSON.stringify(errorDatas)) |
| | | component.set('v.errorData', errorDatas); |
| | | component.set("v.showErrorInfo", true); |
| | | |
| | | console.log('error = ' + error); |
| | | component.set('v.errorMessage', error); |
| | | this.showErrorToast01(component); |
| | | console.log('error='+error); |
| | | component.set('v.login',false); |
| | | console.log('error=' + error); |
| | | component.set('v.login', false); |
| | | return; |
| | | } |
| | | |
| | |
| | | if (res != 'success') { |
| | | var ress = res.split('='); |
| | | console.log(ress); |
| | | |
| | | let errorDatas = []; |
| | | for (var i = 0; i < ress.length; i++) { |
| | | res1 += ress[i].substr(7) + '\n'; |
| | | if (ress[i] != '') { |
| | | let errorData = {} |
| | | errorData.errorRow = ress[i].substr(7).substring(1, 2); |
| | | errorData.errorInfo = ress[i].substr(7).substring(5); |
| | | errorDatas.push(errorData); |
| | | } |
| | | } |
| | | component.set('v.errorData', errorDatas); |
| | | component.set("v.showErrorInfo", true); |
| | | |
| | | console.log("==" + res1); |
| | | component.set('v.errorMessage', res1 + "请修改后重新上传"); |
| | | this.showErrorToast01(component); |
| | |
| | | $A.enqueueAction(action); |
| | | }, |
| | | //zhj MEBG新方案改造 2022-11-29 end |
| | | |
| | | //zhj 导出错误信息 2023-05-16 start |
| | | exportErrorInfoHelper: function (component) { |
| | | var errorData = component.get('v.errorData'); |
| | | |
| | | var datas = [ |
| | | ['错误行', '错误信息'] |
| | | ]; |
| | | for (var i in errorData) { |
| | | let data = []; |
| | | data.push(errorData[i].errorRow) |
| | | data.push(errorData[i].errorInfo) |
| | | datas.push(data); |
| | | } |
| | | |
| | | console.log('datas = ' + JSON.stringify(datas)); |
| | | var csv = this.convertToCSV(component,datas); |
| | | console.log('csv = ' + JSON.stringify(csv)) |
| | | this.downloadCSV(component,csv); |
| | | }, |
| | | |
| | | convertToCSV: function (component,data) { |
| | | console.log('enter convertToCSV') |
| | | console.log('data = ' + data); |
| | | var csv = ''; |
| | | for (var i = 0; i < data.length; i++) { |
| | | var row = data[i]; |
| | | console.log('row = ' + JSON.stringify(row)); |
| | | for (var j = 0; j < row.length; j++) { |
| | | var val = ''; |
| | | val = row[j] === null ? '' : row[j].toString(); |
| | | console.log('val = ' + val); |
| | | if (val.indexOf(',') !== -1 || val.indexOf('"') !== -1 || val.indexOf('\n') !== -1) { |
| | | //val = '"' + val.replace(/"/g,'""') + '"'; |
| | | } |
| | | if (j > 0) { |
| | | csv += ','; |
| | | } |
| | | csv += val; |
| | | } |
| | | csv += '\n'; |
| | | } |
| | | return csv; |
| | | }, |
| | | |
| | | downloadCSV: function (component,csv) { |
| | | var link = document.createElement('a'); |
| | | link.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv); |
| | | link.download = 'data.csv'; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | }, |
| | | //zhj 导出错误信息 2023-05-16 end |
| | | }) |