Commit 30f3cf35 authored by kevin's avatar kevin

#

parent 4fdea1d5
...@@ -5,29 +5,18 @@ import org.springframework.context.annotation.Configuration; ...@@ -5,29 +5,18 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class FileServiceConfig { public class FileServiceConfig {
@Value("${file.server.url}")
private String serverUrl;
@Value("${file.server.upload}")
private String uploadUrl;
@Value("${file_upload_post_url}") @Value("${file_upload_post_url}")
private String upload_post_url; private String uploadUrl;
@Value("${file_upload_query_url}")
public String getUpload_post_url() { private String downloadUrl;
return upload_post_url;
}
public void setUpload_post_url(String upload_post_url) {
this.upload_post_url = upload_post_url;
}
public String getServerUrl() { public String getDownloadUrl() {
return serverUrl; return downloadUrl;
} }
public void setServerUrl(String serverUrl) { public void setDownloadUrl(String downloadUrl) {
this.serverUrl = serverUrl; this.downloadUrl = downloadUrl;
} }
public String getUploadUrl() { public String getUploadUrl() {
return uploadUrl; return uploadUrl;
} }
......
...@@ -7,9 +7,14 @@ import org.apache.commons.lang3.StringUtils; ...@@ -7,9 +7,14 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -18,75 +23,77 @@ import org.springframework.context.ApplicationContext; ...@@ -18,75 +23,77 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.config.FileServiceConfig; import pwc.taxtech.atms.common.config.FileServiceConfig;
import pwc.taxtech.atms.dto.ApiResultDto; import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.exception.ServiceException; import pwc.taxtech.atms.exception.ServiceException;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder;
import java.security.MessageDigest;
/** /**
* author kevin * author kevin
* ver 1.0 * ver 1.0
*/ */
@Configuration @Configuration
public class FileUploadUtil implements ApplicationContextAware { public class FileUploadUtil implements ApplicationContextAware {
protected static final Logger logger = LoggerFactory.getLogger(FileUploadUtil.class); protected static final Logger logger = LoggerFactory.getLogger(FileUploadUtil.class);
// Spring应用上下文环境 // Spring应用上下文环境
private static ApplicationContext applicationContext; private static ApplicationContext applicationContext;
private static FileServiceConfig config; private static FileServiceConfig config;
private static final String USER_TEMPLATE_PATH = "pwc/userTemplate/"; private static final String HTTP_SUCCESS_CODE = "200";
private static final String HTTP_HEADER = "application/json;charset=UTF-8";
public static String upload(MultipartFile file) throws ServiceException{ protected static char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
return upload( file, false);
}
public static String serverPath(boolean newUrl){ public static String getUploadUrl() {
config = (FileServiceConfig)applicationContext.getBean("fileServiceConfig"); config = (FileServiceConfig) applicationContext.getBean("fileServiceConfig");
if(newUrl) return config.getUploadUrl();
return config.getUpload_post_url();
return config.getServerUrl() + config.getUploadUrl();
} }
public static String serverPath(){
return serverPath(true); public static String downLoadUrl() {
config = (FileServiceConfig) applicationContext.getBean("fileServiceConfig");
return config.getDownloadUrl();
} }
/** /**
* 上传模板 * 上传模板
* *
* @param file MultipartFile * @param file MultipartFile
* @param fullPath 是否返回全路径 默认false ,如果为true返回的路径直接可以用于下载
* @return Boolean * @return Boolean
*/ */
public static String upload( MultipartFile file, boolean fullPath) throws ServiceException { public static String upload(MultipartFile file, String fileName) throws ServiceException {
if (StringUtils.isBlank(file.getOriginalFilename()) || null == file) { if (StringUtils.isBlank(file.getOriginalFilename()) || null == file) {
throw new IllegalArgumentException("上传参数为空"); throw new IllegalArgumentException("上传参数为空");
} }
if (fileName == null) {
fileName = file.getOriginalFilename();
}
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
String filePath = USER_TEMPLATE_PATH + file.getOriginalFilename(); String requestKey = CommonUtils.getUUID();
String requestUrl = getUploadUrl() + "/" + requestKey;
try { try {
String serverPath = serverPath(); /*String serverPath = serverPath();
httpClient = HttpClients.createDefault(); httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(serverPath); HttpPost httpPost = new HttpPost(serverPath);
httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());*/
httpClient = HttpClients.createDefault();
JSONObject param = new JSONObject(); HttpPost httpPost = new HttpPost(requestUrl);
param.put("path", filePath); String md5Str = getFileMD5String(file);
param.put("file", file.getBytes()); ByteArrayBody byteBody = new ByteArrayBody(file.getBytes(), ContentType.MULTIPART_FORM_DATA, StringUtils.isBlank(fileName) ? URLEncoder.encode(file.getOriginalFilename(), "UTF-8") : URLEncoder.encode(fileName, "UTF-8"));
StringBody md5 = new StringBody(md5Str, ContentType.create("text/plain"));
HttpEntity httpEntity = new StringEntity(param.toJSONString(), ContentType.APPLICATION_JSON); HttpEntity httpEntity = MultipartEntityBuilder.create().addPart("filecontent", byteBody).addPart("md5", md5).build();
httpPost.setEntity(httpEntity); httpPost.setEntity(httpEntity);
HttpResponse httpResponse = httpClient.execute(httpPost); HttpResponse httpResponse = httpClient.execute(httpPost);
ApiResultDto resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"), ApiResultDto.class); JSONObject resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"));
if (resultDto.getCode() == ApiResultDto.SUCCESS) { if (HTTP_SUCCESS_CODE.equals(resultDto.getString("status_code")))
if(fullPath) return requestKey;
return config.getServerUrl() + "/" + filePath; return null;
return filePath;
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.error("uploadTemplate error.", e); logger.error("uploadTemplate error.", e);
return null;
} finally { } finally {
if (null != httpClient) { if (null != httpClient) {
try { try {
...@@ -96,10 +103,23 @@ public class FileUploadUtil implements ApplicationContextAware { ...@@ -96,10 +103,23 @@ public class FileUploadUtil implements ApplicationContextAware {
} }
} }
} }
throw new ServiceException("uploadTemplate error.");
} }
public static boolean downLoad(String download_url) {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(downLoadUrl() + "/" + download_url);
HttpResponse httpResponse = null;
try {
httpResponse = httpClient.execute(httpGet);
JSONObject resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"));
if (resultDto.getString("status_code").equals(HTTP_SUCCESS_CODE))
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
return false;
}
/** /**
...@@ -110,10 +130,35 @@ public class FileUploadUtil implements ApplicationContextAware { ...@@ -110,10 +130,35 @@ public class FileUploadUtil implements ApplicationContextAware {
public void setApplicationContext(ApplicationContext applicationContext) { public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
} }
/** /**
* @return ApplicationContext * @return ApplicationContext
*/ */
public static ApplicationContext getApplicationContext() { public static ApplicationContext getApplicationContext() {
return applicationContext; return applicationContext;
} }
public static String getFileMD5String(MultipartFile file) throws Exception {
MessageDigest messagedigest = MessageDigest.getInstance("MD5");
messagedigest.update(file.getBytes());
byte bytes[] = messagedigest.digest();
return bufferToHex(bytes, 0, bytes.length);
}
private static String bufferToHex(byte bytes[], int m, int n) {
StringBuffer stringbuffer = new StringBuffer(2 * n);
int k = m + n;
for (int l = m; l < k; l++) {
appendHexPair(bytes[l], stringbuffer);
}
return stringbuffer.toString();
}
private static void appendHexPair(byte bt, StringBuffer stringbuffer) {
char c0 = hexDigits[(bt & 0xf0) >> 4];
char c1 = hexDigits[bt & 0xf];
stringbuffer.append(c0);
stringbuffer.append(c1);
}
} }
...@@ -6,6 +6,7 @@ import org.springframework.http.MediaType; ...@@ -6,6 +6,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.util.FileUploadUtil;
import pwc.taxtech.atms.constant.enums.EnumServiceType; import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dao.OrganizationMapper; import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.ProjectMapper; import pwc.taxtech.atms.dao.ProjectMapper;
...@@ -16,6 +17,7 @@ import pwc.taxtech.atms.entity.OrganizationExample; ...@@ -16,6 +17,7 @@ import pwc.taxtech.atms.entity.OrganizationExample;
import pwc.taxtech.atms.entity.Project; import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectExample; import pwc.taxtech.atms.entity.ProjectExample;
import pwc.taxtech.atms.service.impl.DataImportService; import pwc.taxtech.atms.service.impl.DataImportService;
import pwc.taxtech.atms.vat.dao.PwcReportAttachMapper;
import pwc.taxtech.atms.vat.entity.*; import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl; import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl;
...@@ -224,6 +226,21 @@ public class ReportController { ...@@ -224,6 +226,21 @@ public class ReportController {
return reportService.deleteAttach(id); return reportService.deleteAttach(id);
} }
@Autowired
private PwcReportAttachMapper pwcReportAttachMapper;
@RequestMapping("")
public OperationResultDto downLoadAttach(Long id){
OperationResultDto operationResultDto = new OperationResultDto();
PwcReportAttachExample example = new PwcReportAttachExample();
PwcReportAttachExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(id);
if(FileUploadUtil.downLoad(pwcReportAttachMapper.selectByExample(example).get(0).getFileUrl()) == true){
return operationResultDto.success();
};
operationResultDto.setResultMsg("附件导出失败");
return operationResultDto;
}
@Autowired @Autowired
private OrganizationMapper organizationMapper; private OrganizationMapper organizationMapper;
......
...@@ -52,7 +52,7 @@ public class HttpFileService extends BaseService { ...@@ -52,7 +52,7 @@ public class HttpFileService extends BaseService {
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
String filePath = USER_TEMPLATE_PATH + fileName; String filePath = USER_TEMPLATE_PATH + fileName;
try { try {
String serverPath = config.getServerUrl() + config.getUploadUrl(); String serverPath = config.getUploadUrl();
httpClient = HttpClients.createDefault(); httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(serverPath); HttpPost httpPost = new HttpPost(serverPath);
httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());
...@@ -68,7 +68,7 @@ public class HttpFileService extends BaseService { ...@@ -68,7 +68,7 @@ public class HttpFileService extends BaseService {
ApiResultDto resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"), ApiResultDto.class); ApiResultDto resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"), ApiResultDto.class);
if (resultDto.getCode() == ApiResultDto.SUCCESS) { if (resultDto.getCode() == ApiResultDto.SUCCESS) {
if(fullPath){ if(fullPath){
return config.getServerUrl() + "/" + filePath; return config.getUploadUrl() + "/" + filePath;
} }
return filePath; return filePath;
} }
...@@ -101,14 +101,14 @@ public class HttpFileService extends BaseService { ...@@ -101,14 +101,14 @@ public class HttpFileService extends BaseService {
if (StringUtils.isBlank(filePath)) { if (StringUtils.isBlank(filePath)) {
return null; return null;
} }
if (StringUtils.isNotBlank(config.getServerUrl())) { if (StringUtils.isNotBlank(config.getDownloadUrl())) {
CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpClient client = HttpClients.createDefault();
//先判断下是否是全域名 全域名代表是didi服务器url //先判断下是否是全域名 全域名代表是didi服务器url
String url; String url;
if(filePath.indexOf("http")>=0){ if(filePath.indexOf("http")>=0){
url = filePath; url = filePath;
}else{ }else{
url = StringUtils.appendIfMissing(config.getServerUrl(), "/") + filePath; url = StringUtils.appendIfMissing(config.getDownloadUrl(), "/") + filePath;
} }
HttpGet httpGet = new HttpGet(url); HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
......
...@@ -238,8 +238,14 @@ public class TemplateGroupServiceImpl extends AbstractService { ...@@ -238,8 +238,14 @@ public class TemplateGroupServiceImpl extends AbstractService {
ebitCellData.setRow(m); ebitCellData.setRow(m);
ebitCellData.setCreateTime(now); ebitCellData.setCreateTime(now);
try { try {
if(sheet.getRow(m).getCell(j) != null) if(sheet.getRow(m).getCell(j) != null){
ebitCellData.setData(sheet.getRow(m).getCell(j).getStringCellValue()); if(CellType.STRING == sheet.getRow(m).getCell(j).getCellTypeEnum()){
ebitCellData.setData(sheet.getRow(m).getCell(j).getStringCellValue());
}else if (CellType.NUMERIC == sheet.getRow(m).getCell(j).getCellTypeEnum()){
ebitCellData.setData(String.valueOf(sheet.getRow(m).getCell(j).getNumericCellValue()));
}
}
}catch (Exception e){ }catch (Exception e){
//遇到空行,略过 //遇到空行,略过
} }
......
...@@ -2096,7 +2096,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -2096,7 +2096,7 @@ public class ReportServiceImpl extends BaseService {
fileDto.setRemarks(remarks); fileDto.setRemarks(remarks);
} }
fileDto.setFileUrl(FileUploadUtil.upload(file, true)); fileDto.setFileUrl(FileUploadUtil.upload(file, null));
//绑定 //绑定
fileDto.setSize(String.valueOf(file.getSize() / 1024) + "KB"); fileDto.setSize(String.valueOf(file.getSize() / 1024) + "KB");
fileDto.setUploadUser(authUserHelper.getCurrentAuditor().get()); fileDto.setUploadUser(authUserHelper.getCurrentAuditor().get());
......
analysisModule.controller('tableReportSheetController', ['$scope', '$rootScope', '$log', '$translate', '$timeout', '$q', '$compile', '$state', '$stateParams', analysisModule.controller('tableReportSheetController', ['$scope', '$rootScope', '$log', '$translate', '$timeout', '$q', '$compile', '$state', '$stateParams',
'apiInterceptor', 'vatExportService', 'SweetAlert', 'BSPLService', 'vatReportService', 'vatReportCacheService', 'vatSessionService', 'apiInterceptor', 'vatExportService', 'SweetAlert', 'BSPLService', 'vatReportService', 'vatReportCacheService', 'vatSessionService',
'loginContext', 'enums', 'vatCommonService', 'vatWorkflowService', 'projectService', '$uibModal', '$cookies', 'Upload', 'vatImportService', 'vatApproveService','region', 'loginContext', 'enums', 'vatCommonService', 'vatWorkflowService', 'projectService', '$uibModal', '$cookies', 'Upload', 'vatImportService', 'vatApproveService','region','$http',
function ($scope, $rootScope, $log, $translate, $timeout, $q, $compile, $state, $stateParams, apiInterceptor, vatExportService, SweetAlert, BSPLService, function ($scope, $rootScope, $log, $translate, $timeout, $q, $compile, $state, $stateParams, apiInterceptor, vatExportService, SweetAlert, BSPLService,
vatReportService, vatReportCacheService, vatSessionService, loginContext, enums, vatCommonService, vatWorkflowService, projectService, vatReportService, vatReportCacheService, vatSessionService, loginContext, enums, vatCommonService, vatWorkflowService, projectService,
$uibModal, $cookies, Upload, vatImportService, vatApproveService, region) { $uibModal, $cookies, Upload, vatImportService, vatApproveService, region, $http) {
'use strict'; 'use strict';
$log.debug('VatReportViewController.ctor()...'); $log.debug('VatReportViewController.ctor()...');
...@@ -2883,7 +2883,7 @@ ...@@ -2883,7 +2883,7 @@
var date = new Date(); var date = new Date();
var year = date.getFullYear(); var year = date.getFullYear();
var mon = date.getMonth()+ 1; var mon = date.getMonth()+ 1;
$scope.selectedDate = new Date(year, date.getMonth() + 1, 1); $scope.selectedDate = new Date(year, date.getMonth() , 1);
$scope.startDate = new Date(year - 20, 1, 1); $scope.startDate = new Date(year - 20, 1, 1);
$scope.endDate = new Date(year + 20, 1, 1); $scope.endDate = new Date(year + 20, 1, 1);
var ele1 = $("#ebitDatepacker"); var ele1 = $("#ebitDatepacker");
...@@ -2925,6 +2925,8 @@ ...@@ -2925,6 +2925,8 @@
}).error(function(error){ }).error(function(error){
}); });
} }
//将spread保存到数据库
$scope.$watch('file', function (file) { $scope.$watch('file', function (file) {
$scope.upload($scope.file); $scope.upload($scope.file);
...@@ -2952,7 +2954,6 @@ ...@@ -2952,7 +2954,6 @@
.progress(function (evt) { .progress(function (evt) {
}) })
.success(function (data, status, headers, config) { .success(function (data, status, headers, config) {
debugger;
if(data.result){ if(data.result){
frontImport(file);//前端导入 frontImport(file);//前端导入
$('#busy-indicator-container').hide(); $('#busy-indicator-container').hide();
...@@ -2971,6 +2972,40 @@ ...@@ -2971,6 +2972,40 @@
SweetAlert.error(status + "上传失败") SweetAlert.error(status + "上传失败")
}) })
}; };
//加载Ebit数据
$scope.relation.loadEbitCell = function (sheet) {
if(($scope.relation.data == null))
return;
for (var r = 37; r <= 43; r++) {
//sheet.setFormatter(r, 1, '# ??/??');//设置格式
if (r == 37) {
sheet.setValue(r, 1, PWC.tryParseStringToNum($scope.relation.data.ebitSubtraction != null ? $scope.relation.data.ebitSubtraction : ""));
}
if (r == 38) {
sheet.setValue(r, 1, PWC.tryParseStringToNum($scope.relation.data.specialConsiderations != null ? $scope.relation.data.specialConsiderations : ""));
}
if (r == 39) {
sheet.setValue(r, 1, PWC.tryParseStringToNum($scope.relation.data.specialFactors != null ? $scope.relation.data.specialFactors : ""));
}
if (r == 40) {
sheet.setValue(r, 1, PWC.tryParseStringToNum($scope.relation.data.ebitRate != null ? $scope.relation.data.ebitRate : ""));
}
if (r == 41) {
sheet.setValue(r, 1, PWC.tryParseStringToNum($scope.relation.data.transactionAmount != null ? $scope.relation.data.transactionAmount : ""));
}
if (r == 42) {
sheet.setValue(r, 1, PWC.tryParseStringToNum($scope.relation.data.sixAddTa != null ? $scope.relation.data.sixAddTa : ""));
}
if (r == 43) {
sheet.setValue(r, 1, PWC.tryParseStringToNum($scope.relation.data.totalAmountTax != null ? $scope.relation.data.totalAmountTax : ""));
}
sheet.setFormatter(r, 1, '# ?/?');
}
}
//前端导入 //前端导入
var frontImport = function(file){ var frontImport = function(file){
...@@ -3000,7 +3035,7 @@ ...@@ -3000,7 +3035,7 @@
// here is excel IO API // here is excel IO API
excelIo.save(json, function (blob) { excelIo.save(json, function (blob) {
saveAs(blob, $scope.relation.orgName != undefined ? $scope.relation.orgName : "" + $scope.relation.period + fileName); saveAs(blob, ($scope.relation.orgName != undefined ? $scope.relation.orgName : "" + $scope.relation.period) + fileName);
}, function (e) { }, function (e) {
// process error // process error
console.log(e); console.log(e);
...@@ -3069,7 +3104,8 @@ ...@@ -3069,7 +3104,8 @@
searchEnabled: true, searchEnabled: true,
noDataText: $translate.instant('RevenueNoOrgData'), noDataText: $translate.instant('RevenueNoOrgData'),
showSelectionControls: false, showSelectionControls: false,
onInitialized : function(){ onInitialized : function(e){
}, },
onItemClick: function (e) { onItemClick: function (e) {
loadCellData($scope.relation.period, e.itemData.id,function(){ loadCellData($scope.relation.period, e.itemData.id,function(){
...@@ -3079,7 +3115,8 @@ ...@@ -3079,7 +3115,8 @@
} }
}; };
$scope.$watch('relation._orgId', function(n, o){ $scope.$watch('relation._orgId', function(n, o){
$scope.relation.orgId = n.pop(); if(n != undefined )
$scope.relation.orgId = n.pop();
}); });
var initCompanyList = function () { var initCompanyList = function () {
......
...@@ -2487,7 +2487,7 @@ ...@@ -2487,7 +2487,7 @@
{ {
caption: '文件名', dataField: "fileName", cellTemplate: function (container, options) { caption: '文件名', dataField: "fileName", cellTemplate: function (container, options) {
try { try {
$('<a href="' + options.data.fileUrl + '" target="_blank" style="cursor: pointer">"' + options.data.fileName + '"</a>&nbsp;&nbsp;') $('<a href="javascript:;" onClick = "downLoadAttach('+options.data.id+')" target="_blank" style="cursor: pointer">"' + options.data.fileName + '"</a>&nbsp;&nbsp;')
.appendTo(container); .appendTo(container);
} }
catch (e) { catch (e) {
...@@ -2526,28 +2526,25 @@ ...@@ -2526,28 +2526,25 @@
dataSource: '_gridData' dataSource: '_gridData'
} }
}; };
window.downLoadAttach = function(id){
vatReportService.downLoadAttach(id).success(function (res) {
if(res.result){
//导出成功
}else{
SweetAlert.error(res.resultMsg);
}
}).error();
}
window.deleteAttach = function (id, data) { window.deleteAttach = function (id, data) {
swal({ PWC.warning("警告", "确定删除该附件?" , function (tmpConfirm) {
title: "warning!", if (tmpConfirm) {
text: "确定删除该附件?", vatReportService.deleteAttach(id).success(function (res) {
type: "warning", if (res.resultMsg == "success") {
showCancelButton: true, $scope.loadAttach();
confirmButtonColor: "#DD6B55", }
confirmButtonText: $translate.instant('Yes'), });
cancelButtonText: $translate.instant('No'), }
closeOnConfirm: true, });
closeOnCancel: true
},
function (tmpConfirm) {
if (tmpConfirm) {
vatReportService.deleteAttach(id).success(function (res) {
if (res.resultMsg == "success") {
$scope.loadAttach();
}
});
}
});
} }
//加载附件信息列表 //加载附件信息列表
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<span ng-show="detail.validationErrorList && detail.validationErrorList.length > 0" ng-model="tabType" <span ng-show="detail.validationErrorList && detail.validationErrorList.length > 0" ng-model="tabType"
uib-btn-radio="3"><i class="fa fa-exclamation-circle red-color"></i>{{'ReportCheckResult' | translate}}</span> uib-btn-radio="3"><i class="fa fa-exclamation-circle red-color"></i>{{'ReportCheckResult' | translate}}</span>
<span ng-model="tabType" uib-btn-radio="4">{{'cellComment'|translate}}</span> <span ng-model="tabType" uib-btn-radio="4">{{'cellComment'|translate}}</span>
<span ng-model="tabType" uib-btn-radio="5" ng-click = "loadAttach()">{{'RelatedAttach'|translate}}</span> <span ng-model="tabType" uib-btn-radio="5" ng-click = "loadAttach()">{{'RelatedAttach'|translate}} dsdsdsdssd</span>
</div> </div>
<div class="content-info" ng-show="tabType === 1"> <div class="content-info" ng-show="tabType === 1">
......
...@@ -1128,7 +1128,36 @@ ...@@ -1128,7 +1128,36 @@
}, {}); }, {});
} }
}); });
} };
PWC.warning = function(title, text, callback){
swal({
title: title,
text: text,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: $translate.instant('Yes'),
cancelButtonText: $translate.instant('No'),
closeOnConfirm: true,
closeOnCancel: true
},
callback);
};
PWC.alert = function(title, text, callback){
swal({
title: title,
text: text,
type: "info",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: $translate.instant('Yes'),
cancelButtonText: $translate.instant('No'),
closeOnConfirm: true,
closeOnCancel: true
},
callback);
};
/------------------------------------------------kevin insert -----------------------------------/ /------------------------------------------------kevin insert -----------------------------------/
......
...@@ -242,6 +242,9 @@ ...@@ -242,6 +242,9 @@
}, },
saveEbitModule: function () { saveEbitModule: function () {
},
downLoadAttach : function(id){
return $http.get('/Report/downLoadAttach?id=' + id);
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment