Commit c1f7aded authored by neo's avatar neo

[DEV] add import manual inport excel

parent 3bb9aedf
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
$scope.voucherComments = ""; $scope.voucherComments = "";
$scope.voucherFileName = ""; $scope.voucherFileName = "";
$scope.voucherFileID = ""; $scope.voucherFileID = "";
$scope.manualSpread = {};
//Notice: ************************************ //Notice: ************************************
//$scope.templateCode, $scope.reportId, $scope.initRow, $scope.initCol等都是外部传递进来的数据。 //$scope.templateCode, $scope.reportId, $scope.initRow, $scope.initCol等都是外部传递进来的数据。
...@@ -1484,7 +1485,7 @@ ...@@ -1484,7 +1485,7 @@
}; };
//单元格详细信息点击确定时执行 //单元格详细信息点击确定时执行
$scope.confirm = function () { $scope.Confirm = function () {
$scope.handInputModel.name = $scope.taxCellDetail.inputMemo; $scope.handInputModel.name = $scope.taxCellDetail.inputMemo;
$scope.handInputModel.amount = $scope.taxCellDetail.inputValue; $scope.handInputModel.amount = $scope.taxCellDetail.inputValue;
$scope.handInputModel.description = $scope.taxCellDetail.inputMemo; $scope.handInputModel.description = $scope.taxCellDetail.inputMemo;
...@@ -1516,6 +1517,9 @@ ...@@ -1516,6 +1517,9 @@
return $q.reject(); return $q.reject();
}; };
$scope.saveReportCache = function () { $scope.saveReportCache = function () {
if (!$scope.reportData) { if (!$scope.reportData) {
return $q.reject(); return $q.reject();
...@@ -2674,28 +2678,104 @@ ...@@ -2674,28 +2678,104 @@
$log.debug(text); $log.debug(text);
if(text == '海关专用缴款书' || text =='代扣代缴税收通用缴款书取数'){ if(text == '海关专用缴款书' || text =='代扣代缴税收通用缴款书取数'){
var excelIo = new GC.Spread.Excel.IO(); var excelIo = new GC.Spread.Excel.IO();
var excelFilePath = 'resources/Excel/importExcel.xlsx'; $("#importExcellFile").modal('show');
var xhr = new XMLHttpRequest();
xhr.open('GET', excelFilePath, true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
if (this.status == 200) {
// get binary data as a response
var blob = this.response;
// convert Excel to JSON
excelIo.open(blob, function (json) {
var workbookObj = json;
spread.fromJSON(workbookObj);
}, function (e) {
// process error
alert(e.errorMessage);
}, {});
}
};
}else{ }else{
SweetAlert.warning("仅支持海关专用缴款书或代扣代缴税收通用缴款书取数"); SweetAlert.warning("仅支持海关专用缴款书或代扣代缴税收通用缴款书取数");
} }
}; };
$scope.loadMyExcel = function(){
$scope.manualSpread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount: 1});
var excelIo = new GC.Spread.Excel.IO();
var excelFile = document.getElementById("fileDemo").files[0];
excelIo.open(excelFile, function(json) {
var workbookObj = json;
$scope.manualSpread.fromJSON(workbookObj);
}, function(e) {
alert(e.errorMessage);
if (e.errorCode === 2 /*noPassword*/ || e.errorCode === 3 /*invalidPassword*/ ) {
document.getElementById('password').onselect = null;
}
}, {
});
};
$scope.multiWrite = function(){
var manualSheet = $scope.manualSpread.getActiveSheet();
var currentSheet = $scope.spread.getActiveSheet()
currentSheet.options.isProtected=false;
for (var rowIndex = 0; rowIndex < currentSheet.getRowCount(); rowIndex++) {
for (var columnIndex = 0; columnIndex < currentSheet.getColumnCount(); columnIndex++) {
var tagInfo = currentSheet.getTag(rowIndex, columnIndex);
if (tagInfo) {
var jsonTagInfo = JSON.parse(tagInfo);
if (jsonTagInfo.isReadOnly)
continue;
var cellValue= manualSheet.getValue(rowIndex,columnIndex);
if(typeof(cellValue) == "string") cellValue = cellValue.trim();
var r = /^00\d*|^\.\d+|\.$/;
if (typeof cellValue == "undefined" || cellValue == null || cellValue == "" || cellValue == "NaN")continue;
if (cellValue && (isNaN(cellValue) || r.test(cellValue))) {
SweetAlert.warning($translate.instant('CheckInputValueFormat'));
return;
} else if (cellValue && parseFloat(cellValue).toFixed(2) > 9999999999999) {
SweetAlert.warning($translate.instant('CheckInputValueLength'));
return;
}
cellValue = jsonTagInfo.dataType === 5 ? parseInt(cellValue): parseFloat(cellValue).toFixed(2);
var handInputModel = {
cellID: jsonTagInfo.cellID,
cellTemplateID: jsonTagInfo.cellTemplateID,
reportID: jsonTagInfo.reportID,
amount:cellValue
};
$scope.myConfirm(handInputModel);
}
}
}
};
$scope.myConfirm = function (handInputModel) {
handInputModel.projectID = vatSessionService.project.id;
handInputModel.serviceTypeID = vatSessionService.project.serviceTypeID;
handInputModel.period = vatSessionService.month;
if (handInputModel.amount || handInputModel.name) {
//日志对象
logDto.ID = PWC.newGuid();
logDto.CreateTime = new Date();
logDto.UpdateTime = new Date();
logDto.OperationContent = "Amount: " + handInputModel.amount
+ "; Description: " + handInputModel.description;
logDto.OperationName = $translate.instant('ManualInputDataSource');
logDto.Comment = comment + "(Cell ID:" + handInputModel.cellID
+ ", Cell Template ID:" + handInputModel.cellTemplateID + ")";
logDto.OperationType = enums.vatLogOperationTypeEnum.RV_ManualInput;
// 前端保存数据
return vatReportService.addCellManualData(handInputModel, logDto).then(function (manualData) {
var obj = manualData.data.data;
obj.dataSourceType = manualData.dataSourceType;
$scope.updateCellByManualChange(obj);
return $q.when();
});
}
return $q.reject();
};
$scope.cleanManual = function(){
$scope.manualSpread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount: 1});
$('#ss').html('');
document.getElementById("fileDemo").value="";
};
/****************************************证据文件function Ended*************************************************/ /****************************************证据文件function Ended*************************************************/
/****************************************证据文件function Ended*************************************************/ /****************************************证据文件function Ended*************************************************/
/****************************************证据文件function Ended*************************************************/ /****************************************证据文件function Ended*************************************************/
......
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
<span ng-if="!isBSPL" ng-click="doApprove();"><i <span ng-if="!isBSPL" ng-click="doApprove();"><i
class="fa fa-floppy-o"></i>&nbsp;{{'报表审批'}}</span> class="fa fa-floppy-o"></i>&nbsp;{{'报表审批'}}</span>
<span ng-if="!isBSPL" ng-click="upLoadManual();"><i <span ng-if="!isBSPL" ng-click="upLoadManual();"><i
class="fa fa-floppy-o"></i>&nbsp;{{'上传手工数据'}}</span> class="fa fa-floppy-o"></i>&nbsp;{{'上传手工数据'}}
</span>
<!--<span ng-if="!isBSPL" ng-click="saveReportCache();"><i--> <!--<span ng-if="!isBSPL" ng-click="saveReportCache();"><i-->
<!--class="fa fa-floppy-o"></i>&nbsp;{{'Save' | translate}}</span>--> <!--class="fa fa-floppy-o"></i>&nbsp;{{'Save' | translate}}</span>-->
</div> </div>
<div class='report-container' id="reportContainer"> <div class='report-container' id="reportContainer">
<vat-report-sheet id='report-view' report-source="reportData" formula-blocks="formulaBlocks" <vat-report-sheet id='report-view' report-source="reportData" formula-blocks="formulaBlocks"
is-read-only="!isDocumentList" is-read-only="!isDocumentList"
...@@ -186,4 +188,32 @@ ...@@ -186,4 +188,32 @@
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" id="importExcellFile" tabindex="-1" role="dialog" aria-labelledby="myModal"
data-backdrop="static" data-keyboard="false">
<div class="modal-dialog" style="width:850px;height:500px" role="document" >
<div class="modal-content">
<div class="modal-header">
<span class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeModal()">×</span>
<span>批量录入手工数据</span>
</div>
<br/>
<div class="row" style="margin-left:12px; margin-right:12px;width:850px;height:500px">
<div id="ss" class="sample-spreadsheets" style="height:100%;width:100%"></div>
</div>
<div class="row" style="margin-left:12px; margin-right:12px;">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="inputContainer">
<input type="file" id="fileDemo" class="btn btn-sm" name="选择文件">
<input type="button" id="loadExcel" value="加载文件" class="btn btn-sm" ng-click="loadMyExcel()">
<button class="btn btn-sm" ng-click="multiWrite()">批量录入</button>
<button class="btn btn-sm" ng-click="cleanManual()">清空</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div> </div>
\ No newline at end of file
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
height: calc(~"100% - 20px"); height: calc(~"100% - 20px");
min-height: 500px; min-height: 500px;
margin: 10px 10px 10px 20px; margin: 10px 10px 10px 20px;
.report-container { .report-container {
border: @thin-border solid @color-border; border: @thin-border solid @color-border;
height: calc(~"100% - 36px"); height: calc(~"100% - 36px");
......
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