加入历史缴费导入功能

This commit is contained in:
java110 2020-09-09 17:02:50 +08:00
parent a0de956772
commit b41f67f9cb
3 changed files with 163 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,46 @@
<div>
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="ibox-title">
<h5>资产信息</h5>
<div class="ibox-tools" style="top:10px;">
<button type="button" class="btn btn-primary btn-sm"
v-on:click="_openDownloadHcExcelTemplate()">
<i class="glyphicon glyphicon-download-alt"></i>
模板
</button>
</div>
</div>
<div class="ibox-content">
<div>
<div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">选择文件</label>
<div class="col-sm-10">
<div class="custom-file">
<input id="excelTemplate" ref="excelTemplate" type="file" class="custom-file-input form-control"
name="excelTemplate"
v-on:change="getExcelTemplate($event)"
accept=".xls,.xlsx"
>
<label for="excelTemplate" class="custom-file-label">{{historyFeeDetailImportInfo.excelTemplate==''?'必填,请选择数据文件':historyFeeDetailImportInfo.excelTemplate.name}}</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10"></div>
<div class="col-md-2 " style="margin-bottom:10px; text-align:right">
<button type="button" class="btn btn-primary"
v-on:click="_importData()">导入
</button>
</div>
</div>
</div>

View File

@ -0,0 +1,117 @@
/**
权限组
**/
(function (vc) {
vc.extends({
data: {
historyFeeDetailImportInfo: {
communityId: vc.getCurrentCommunity().communityId,
excelTemplate: '',
}
},
_initMethod: function () {
},
_initEvent: function () {
},
methods: {
historyFeeDetailImportValidate: function () {
return vc.validate.validate({
historyFeeDetailImportInfo: vc.component.historyFeeDetailImportInfo
}, {
'historyFeeDetailImportInfo.excelTemplate': [
{
limit: "required",
param: "",
errInfo: "文件不能为空"
}
],
'historyFeeDetailImportInfo.communityId': [
{
limit: "required",
param: "",
errInfo: "还未入驻小区,请先入驻小区"
}
]
});
},
_openDownloadHcExcelTemplate: function () {
//下载 模板
vc.jumpToPage('/import/importFeeDetail.xlsx')
},
getExcelTemplate: function (e) {
//console.log("getExcelTemplate 开始调用")
vc.component.historyFeeDetailImportInfo.excelTemplate = e.target.files[0];
},
_importData: function () {
if (!vc.component.historyFeeDetailImportValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
// 导入数据
if (!vc.component.checkFileType(vc.component.historyFeeDetailImportInfo.excelTemplate.name.split('.')[1])) {
vc.toast('不是有效的Excel格式');
return;
}
if (!vc.component.checkFileSize(vc.component.historyFeeDetailImportInfo.excelTemplate.size)) {
vc.toast('Excel文件大小不能超过2M');
return;
}
var param = new FormData();
param.append("uploadFile", vc.component.historyFeeDetailImportInfo.excelTemplate);
param.append('communityId', vc.component.historyFeeDetailImportInfo.communityId);
vc.http.upload(
'importFeeDetail',
'importData',
param,
{
emulateJSON: true,
//添加请求头
headers: {
"Content-Type": "multipart/form-data"
}
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
if (res.status == 200) {
//关闭model
vc.toast("处理成功");
vc.jumpToPage('/admin.html#/pages/property/roomCreateFee')
return;
}
vc.toast(json,10000);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo,10000);
});
},
checkFileType: function (fileType) {
const acceptTypes = ['xls', 'xlsx'];
for (var i = 0; i < acceptTypes.length; i++) {
if (fileType === acceptTypes[i]) {
return true;
}
}
return false;
},
checkFileSize: function (fileSize) {
//2M
const MAX_SIZE = 2 * 1024 * 1024;
if (fileSize > MAX_SIZE) {
return false;
}
return true;
}
}
});
})(window.vc);