Commit 93233248 authored by kevin's avatar kevin

Merge branch 'dev_mysql' of http://code.tech.tax.asia.pwcinternal.com/root/atms into dev_mysql

parents f585cc0b 9bb49a2d
......@@ -13,7 +13,8 @@ public enum EnumImportType {
InvoiceRecord(9),
ExtractFinancialData(10),
ExtractInvoiceData(11),
RevenueMapping(12)
RevenueMapping(12),
RevenueConfig(13)
;
private Integer code;
......
......@@ -15,7 +15,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
AccountType(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -32,6 +32,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.AccountType accountType : RevenueConfEnum.AccountType.values()) {
MAPPING.put(accountType.getCode(), accountType.getName());
REVERSAL_MAPPING.put(accountType.getName(),accountType.getCode());
}
}
}
......@@ -48,7 +49,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
TaxBase(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -65,6 +66,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.TaxBase taxBase : RevenueConfEnum.TaxBase.values()) {
MAPPING.put(taxBase.getCode(), taxBase.getName());
REVERSAL_MAPPING.put(taxBase.getName(),taxBase.getCode());
}
}
}
......@@ -80,7 +82,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
TaxType(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -97,6 +99,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.TaxType taxType : RevenueConfEnum.TaxType.values()) {
MAPPING.put(taxType.getCode(), taxType.getName());
REVERSAL_MAPPING.put(taxType.getName(),taxType.getCode());
}
}
}
......@@ -110,7 +113,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
RevenueType(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -127,6 +130,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.RevenueType revenueType : RevenueConfEnum.RevenueType.values()) {
MAPPING.put(revenueType.getCode(), revenueType.getName());
REVERSAL_MAPPING.put(revenueType.getName(),revenueType.getCode());
}
}
}
......@@ -140,7 +144,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
Status(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -157,8 +161,48 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.Status status : RevenueConfEnum.Status.values()) {
MAPPING.put(status.getCode(), status.getName());
REVERSAL_MAPPING.put(status.getName(),status.getCode());
}
}
}
public enum EXECLColumn {
Column_1(0, "收入类型名称"),
Column_2(1, "适用公司"),
Column_3(2, "账载收入"),
Column_4(3, "科目代码"),
Column_5(4, "利润中心代码"),
Column_6(5, "产品代码"),
Column_7(6, "税率"),
Column_8(7, "计税收入"),
Column_9(8, "计税收入科目代码"),
Column_10(9, "收入类型"),
Column_11(10, "计税方法"),
Column_12(11, "状态"),
Column_13(12, "起始日期"),
Column_14(13, "终止日期")
;
private Integer index;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
EXECLColumn(Integer index, String name) {
this.index = index;
this.name = name;
}
public Integer getIndex() {
return index;
}
public String getName() {
return name;
}
static {
for (TaxesCalculateReportEnum.Column accountType : TaxesCalculateReportEnum.Column.values()) {
MAPPING.put(accountType.getIndex(), accountType.getName());
}
}
}
}
package pwc.taxtech.atms.controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
import pwc.taxtech.atms.dto.revenuconf.RevConfAddDto;
......@@ -48,4 +46,9 @@ public class RevenueConfController extends BaseController {
revenueConfService.delConfig(idList);
return ApiResultDto.success();
}
@PostMapping("upload")
public ApiResultDto upload(@RequestParam MultipartFile file, @RequestParam Integer type) throws Exception {
List<String> unSuccessList = revenueConfService.upload(file, type);
return ApiResultDto.success(unSuccessList);
}
}
......@@ -286,9 +286,9 @@ public class CitImportExcelServiceImpl extends BaseService {
}
citJournal.setAttribute3(CitCommonUtil.getValue(rowData.getCell(38)).toString());
citJournal.setAttribute4(CitCommonUtil.getValue(rowData.getCell(39)).toString());
citJournal.setAttribute5(CitCommonUtil.getValue(rowData.getCell(40)).toString());
citJournal.setAttribute6(CitCommonUtil.getValue(rowData.getCell(41)).toString());
citJournal.setAttribute7(CitCommonUtil.getValue(rowData.getCell(42)).toString());
citJournal.setAttribute5(CitCommonUtil.getValue(rowData.getCell(40)).toString().replace(".0",""));
citJournal.setAttribute6(CitCommonUtil.getValue(rowData.getCell(41)).toString().replace(".0",""));
citJournal.setAttribute7(CitCommonUtil.getValue(rowData.getCell(42)).toString().replace(".0",""));
citJournal.setAttribute8(CitCommonUtil.getValue(rowData.getCell(43)).toString());
citJournal.setAttribute9(CitCommonUtil.getValue(rowData.getCell(44)).toString());
citJournal.setAttribute10(CitCommonUtil.getValue(rowData.getCell(45)).toString());
......
......@@ -5,7 +5,14 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.constant.enums.RevenueConfEnum;
import pwc.taxtech.atms.dpo.OrgSelectDto;
import pwc.taxtech.atms.dto.ApiResultDto;
......@@ -17,7 +24,12 @@ import pwc.taxtech.atms.vat.entity.RevenueConfig;
import pwc.taxtech.atms.vat.entity.RevenueConfigExample;
import javax.annotation.Resource;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
......@@ -127,4 +139,131 @@ public class RevenueConfService extends BaseService {
return config;
}
public List<String> upload(MultipartFile file, Integer type) throws Exception {
List<String> unSuccessList = new ArrayList<>();
List<RevenueConfig> dataList = new ArrayList<>();
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0);
List<OrgSelectDto> orgDtoList = organizationService.getMyOrgList();
List<String> orgIds = new ArrayList<>();
String unSuccessMsg;
for (int r = sheet.getFirstRowNum()+1; r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r);
unSuccessMsg = "第"+(r+1)+"行:";
String orgName = POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_2.getIndex()));
Optional<OrgSelectDto> optional = orgDtoList.stream().filter(o -> StringUtils.equals(o.getName(), orgName)).findFirst();
if (!optional.isPresent()) {
unSuccessMsg +="|公司不存在|";
unSuccessList.add(unSuccessMsg);
continue;
}
String msg = verifyColumn(row);
if(StringUtils.isNotBlank(msg)){
unSuccessMsg+=msg;
unSuccessList.add(unSuccessMsg);
continue;
}
RevenueConfig revenueConfig = new RevenueConfig();
revenueConfig.setId(idService.nextId());
revenueConfig.setSerialNo("");
revenueConfig.setAccountName("");
revenueConfig.setOrgId(optional.get().getId());
orgIds.add(optional.get().getId());
revenueConfig.setName(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_1.getIndex())));
revenueConfig.setAccountType(RevenueConfEnum.AccountType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_3.getIndex()))));
revenueConfig.setTbSegment3(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_4.getIndex())));
if(StringUtils.isBlank(revenueConfig.getTbSegment3())){
revenueConfig.setTbSegment3("");
}
revenueConfig.setTbSegment5(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_5.getIndex())));
if(StringUtils.isBlank(revenueConfig.getTbSegment5())){
revenueConfig.setTbSegment5("");
}
revenueConfig.setTbSegment6(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_6.getIndex())));
if(StringUtils.isBlank(revenueConfig.getTbSegment6())){
revenueConfig.setTbSegment6("");
}
String taxRat = POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_7.getIndex()));
// taxRat = taxRat.replaceAll("%","");
revenueConfig.setTaxRate(new BigDecimal(taxRat));
revenueConfig.setTaxBase(RevenueConfEnum.TaxBase.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_8.getIndex()))));
if(revenueConfig.getTaxBase().intValue() == 4){
revenueConfig.setBaseDrCode(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_9.getIndex())));
revenueConfig.setBaseCrCode("");
}else if(revenueConfig.getTaxBase().intValue() == 5){
revenueConfig.setBaseCrCode(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_9.getIndex())));
revenueConfig.setBaseDrCode("");
}else{
revenueConfig.setBaseDrCode("");
revenueConfig.setBaseCrCode("");
}
revenueConfig.setRevenueType(RevenueConfEnum.RevenueType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_10.getIndex()))));
revenueConfig.setTaxType(RevenueConfEnum.TaxType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_11.getIndex()))));
revenueConfig.setStatus(RevenueConfEnum.Status.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_12.getIndex()))));
revenueConfig.setStartDate(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_13.getIndex())));
revenueConfig.setEndDate(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_14.getIndex())));
revenueConfig.setCreateBy("Admin");
revenueConfig.setUpdateBy("Admin");
revenueConfig.setUpdateTime(new Date());
revenueConfig.setCreateTime(new Date());
dataList.add(revenueConfig);
}
if (1 == type) {
if(CollectionUtils.isNotEmpty(orgIds)){
RevenueConfigExample delExample = new RevenueConfigExample();
delExample.createCriteria().andOrgIdIn(orgIds);
revenueConfigMapper.deleteByExample(delExample);
}
}
if (!CollectionUtils.isEmpty(dataList)) {
List<List<RevenueConfig>> batchList = CommonUtils.subListWithLen(dataList, CommonUtils.BATCH_NUM_2000);
batchList.forEach(l -> revenueConfigMapper.batchInsert(l));
}
return unSuccessList;
}
public String verifyColumn(Row row){
String msg = "";
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_1.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_1.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_7.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_7.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_13.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_13.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_14.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_14.getName()+"值有错误|";
}
if(!RevenueConfEnum.AccountType.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_3.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_3.getName()+"值有错误|";
}else{
if(RevenueConfEnum.AccountType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_3.getIndex()))).intValue()==1){
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_4.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_4.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_5.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_5.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_6.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_6.getName()+"值有错误|";
}
}
}
if(!RevenueConfEnum.TaxBase.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_8.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_8.getName()+"值有错误|";
}
if(!RevenueConfEnum.RevenueType.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_10.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_10.getName()+"值有错误|";
}
if(!RevenueConfEnum.TaxType.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_11.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_11.getName()+"值有错误|";
}
if(!RevenueConfEnum.Status.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_12.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_12.getName()+"值有错误|";
}
return msg;
}
}
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
......@@ -8,6 +7,8 @@ import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.RevenueConfig;
import pwc.taxtech.atms.vat.entity.RevenueConfigExample;
import java.util.List;
@Mapper
public interface RevenueConfigMapper extends MyVatMapper {
/**
......@@ -105,4 +106,6 @@ public interface RevenueConfigMapper extends MyVatMapper {
* @mbg.generated
*/
int updateByPrimaryKey(RevenueConfig record);
int batchInsert(List<RevenueConfig> list);
}
\ No newline at end of file
......@@ -418,7 +418,7 @@
attribute16,
created_by, created_date, late_updated_by,
late_updated_date, create_time, update_time,is_select
from cit_journal_entry_adjust where period like #{record.period}
from cit_journal_entry_adjust where period like CONCAT('%' ,#{record.period},'%')
<if test="orgList != null and orgList.size > 0">
AND organization_id in
<foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
......@@ -450,7 +450,7 @@
accounted_dr, accounted_cr, entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
attribute16, created_by, created_date, late_updated_by, late_updated_date, create_time, update_time, is_select
from journal_entry where tms_period like #{record.period}
from journal_entry where tms_period like CONCAT('%' ,#{record.period},'%')
<if test="orgList != null and orgList.size > 0">
AND organization_id in
<foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
......
......@@ -414,24 +414,4 @@
</if>
</select>
<insert id="batchInsert">
insert into revenue_type_mapping
(id, org_id, ou_name, content, tax_rate, revenue_type_name, start_date, end_date, status, create_by, update_by, create_time, update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},
#{item.orgId},
#{item.ouName},
#{item.content},
#{item.taxRate},
#{item.revenueTypeName},
#{item.startDate},
#{item.endDate},
#{item.status,jdbcType=TINYINT},
#{item.createBy},
#{item.updateBy},
#{item.createTime},
#{item.updateTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.vat.dao.RevenueConfigMapper">
<insert id="batchInsert">
insert into revenue_config
(id, serial_no, name, org_id, account_type, account_name, tax_rate, tax_base, revenue_type, tax_type, status, start_date, end_date, tb_segment3, tb_segment5, tb_segment6, update_time, create_time, update_by, create_by, base_cr_code, base_dr_code) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id,jdbcType=BIGINT},
#{item.serialNo,jdbcType=VARCHAR},
#{item.name,jdbcType=VARCHAR},
#{item.orgId,jdbcType=VARCHAR},
#{item.accountType,jdbcType=TINYINT},
#{item.accountName,jdbcType=VARCHAR},
#{item.taxRate,jdbcType=DECIMAL},
#{item.taxBase,jdbcType=TINYINT},
#{item.revenueType,jdbcType=TINYINT},
#{item.taxType,jdbcType=TINYINT},
#{item.status,jdbcType=TINYINT},
#{item.startDate,jdbcType=VARCHAR},
#{item.endDate,jdbcType=VARCHAR},
#{item.tbSegment3,jdbcType=VARCHAR},
#{item.tbSegment5,jdbcType=VARCHAR},
#{item.tbSegment6,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=TIMESTAMP},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.updateBy,jdbcType=VARCHAR},
#{item.createBy,jdbcType=VARCHAR},
#{item.baseCrCode,jdbcType=VARCHAR},
#{item.baseDrCode,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.vat.dao.RevenueTypeMappingMapper">
<insert id="batchInsert">
insert into revenue_type_mapping
(id, org_id, ou_name, content, tax_rate, revenue_type_name, start_date, end_date, status, create_by, update_by, create_time, update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},
#{item.orgId},
#{item.ouName},
#{item.content},
#{item.taxRate},
#{item.revenueTypeName},
#{item.startDate},
#{item.endDate},
#{item.status,jdbcType=TINYINT},
#{item.createBy},
#{item.updateBy},
#{item.createTime},
#{item.updateTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -1563,7 +1563,8 @@ constant.importFileType = {
invoiceRecord: 9,
ExtractFinancialData: 10,
ExtractInvoiceData: 11,
RevenueMapping: 12
RevenueMapping: 12,
RevenueConfig: 13
};
constant.citImportFileType = {
......
vatModule.controller('VatRevenueConfigController', ['$scope', '$log', '$translate', '$timeout', 'SweetAlert', '$q',
'$interval', 'dxDataGridService', '$http', 'apiConfig',
function ($scope, $log, $translate, $timeout, SweetAlert, $q, $interval, dxDataGridService, $http, apiConfig) {
'$interval', 'dxDataGridService', '$http', 'apiConfig','Upload','apiInterceptor','templateService',
function ($scope, $log, $translate, $timeout, SweetAlert, $q, $interval, dxDataGridService, $http, apiConfig,Upload,apiInterceptor,templateService) {
'use strict';
$scope.upload = function(uploadType) {
if (!$scope.uploadFile || !$scope.uploadFile.file.name) {
SweetAlert.warning($translate.instant('SelectUploadFileRequired'));
return;
}
$('#busy-indicator-container').show();
var deferred = $q.defer();
Upload.upload({
url: apiInterceptor.webApiHostUrl + '/revenueConf/upload',
data: {
type: uploadType,
},
file: $scope.uploadFile.file,
// resumeChunkSize: resumable ? $scope.chunkSize : null,
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken(),
withCredentials: true
},
withCredentials: true
}).then(function(res) {
$('#busy-indicator-container').hide();
deferred.resolve();
if (res && res.data && 0 === res.data.code) {
if(res.data.data.length==0){
SweetAlert.success($translate.instant('ImportSuccess'));
}else{
var msg = '';
angular.forEach(res.data.data,function (item) {
msg += item +" \n ";
});
SweetAlert.success(msg);
}
$scope.refreshConfigGrid();
} else {
SweetAlert.error($translate.instant('SystemError'));
}
}, function(resp) {
deferred.resolve();
if (resp.statusText === 'HttpRequestValidationException') {
SweetAlert.warning($translate.instant('HttpRequestValidationException'));
} else {
SweetAlert.warning($translate.instant('SaveFail'));
}
$('#busy-indicator-container').hide();
}, function(evt) {
deferred.resolve();
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
$log.debug('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
};
$scope.downloadTemplate = function () {
templateService.downloadTemplate(constant.importFileType.RevenueConfig).success(function (data, status, headers) {
var octetStreamMime = 'application/octet-stream';
var contentType = headers('content-type') || octetStreamMime;
if (window.navigator.msSaveBlob) {
var blob = new Blob([data], {
type: contentType
});
navigator.msSaveBlob(blob, "收入类型配置导入模板");
} else {
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
var a = document.createElement('a');
var blob = new Blob([data], {
type: contentType
});
var url = urlCreator.createObjectURL(blob);
a.href = url;
a.target = '_blank';
a.download = "收入类型配置导入模板.xlsx";
document.body.appendChild(a);
a.click();
}
}
}).error(function () {
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
});
};
//表格配置
$scope.revenueGridOptions = $.extend(true, {}, dxDataGridService.BASIC_GRID_OPTIONS, {
columns: [
......
......@@ -5,10 +5,19 @@
</div>
<div id="tab_total">
<form class="form-inline">
<div class="form-group" style="margin-top: 5px;"><div class="import-wrapper">
<button type="button" class="btn btn-primary" ng-click="addConfig()">{{'RevenueAddBtn' | translate }}</button>&nbsp;&nbsp;&nbsp;
<div class="form-group" style="margin-top: 5px;">
<button type="button" class="btn btn-secondary" ng-click="addConfig()">{{'RevenueAddBtn' | translate }}</button>&nbsp;&nbsp;&nbsp;
<button type="button" class="btn btn-third" ng-click="batchDelConfig()">{{'RevenueDelBtn' | translate }}</button>
</div></div>
<label class="control-label">文件:</label>
<input class="form-control" type="text" name="fileName" ng-model="uploadFile.file.name" readonly placeholder=""/>
<button type="button" type="file" ngf-select ng-model="uploadFile.file" accept=".xls,.xlsx" class="btn btn-secondary browse">{{'SelectFile' | translate }}</button>
<button type="button" class="btn btn-secondary" translate="CoverImportBtn" ng-click="upload(1)"></button>
<button type="button" class="btn btn-secondary" translate="AddImportBtn" ng-click="upload(2)"></button>
<button type="button" class="btn btn-in-grid inline-div" ng-click="downloadTemplate()"><i
class="fa fa-download" aria-hidden="true"></i>下载模板
</button>
</div>
</form>
<div class="dt-init-wrapper">
......
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