mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-06-12 18:11:00 +08:00
水费导入页面
This commit is contained in:
parent
cc7edabd6c
commit
7ff8ecccfb
66
public/pages/property/waterFeeImport/waterFeeImport.html
Normal file
66
public/pages/property/waterFeeImport/waterFeeImport.html
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<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>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-primary btn-sm"
|
||||||
|
v-on:click="_exitCommunityData()">
|
||||||
|
<i class="glyphicon glyphicon-floppy-save"></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">
|
||||||
|
<!--<input ref="excelTemplate" type="file" placeholder="必填,请选择数据文件"
|
||||||
|
class="form-control"
|
||||||
|
name="excelTemplate"
|
||||||
|
v-on:change="getExcelTemplate($event)"
|
||||||
|
accept=".xls,.xlsx"
|
||||||
|
>-->
|
||||||
|
|
||||||
|
<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">{{assetImportInfo.excelTemplate==''?'必填,请选择数据文件':assetImportInfo.excelTemplate.name}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-sm-2 col-form-label">备注</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea v-model="assetImportInfo.remark" type="text" placeholder="请填写备注信息" rows="3"
|
||||||
|
class="form-control"></textarea>
|
||||||
|
</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>
|
||||||
122
public/pages/property/waterFeeImport/waterFeeImport.js
Normal file
122
public/pages/property/waterFeeImport/waterFeeImport.js
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/**
|
||||||
|
权限组
|
||||||
|
**/
|
||||||
|
(function (vc) {
|
||||||
|
|
||||||
|
vc.extends({
|
||||||
|
data: {
|
||||||
|
assetImportInfo: {
|
||||||
|
communityId: vc.getCurrentCommunity().communityId,
|
||||||
|
excelTemplate: '',
|
||||||
|
remark: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_initMethod: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
_initEvent: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
assetImportValidate: function () {
|
||||||
|
return vc.validate.validate({
|
||||||
|
assetImportInfo: vc.component.assetImportInfo
|
||||||
|
}, {
|
||||||
|
|
||||||
|
'assetImportInfo.excelTemplate': [
|
||||||
|
{
|
||||||
|
limit: "required",
|
||||||
|
param: "",
|
||||||
|
errInfo: "文件不能为空"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'assetImportInfo.communityId': [
|
||||||
|
{
|
||||||
|
limit: "required",
|
||||||
|
param: "",
|
||||||
|
errInfo: "还未入驻小区,请先入驻小区"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
_openDownloadHcExcelTemplate: function () {
|
||||||
|
//下载 模板
|
||||||
|
vc.jumpToPage('/import/hc.xlsx')
|
||||||
|
},
|
||||||
|
getExcelTemplate: function (e) {
|
||||||
|
//console.log("getExcelTemplate 开始调用")
|
||||||
|
vc.component.assetImportInfo.excelTemplate = e.target.files[0];
|
||||||
|
},
|
||||||
|
_importData: function () {
|
||||||
|
|
||||||
|
if (!vc.component.assetImportValidate()) {
|
||||||
|
vc.toast(vc.validate.errInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 导入数据
|
||||||
|
if (!vc.component.checkFileType(vc.component.assetImportInfo.excelTemplate.name.split('.')[1])) {
|
||||||
|
vc.toast('不是有效的Excel格式');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!vc.component.checkFileSize(vc.component.assetImportInfo.excelTemplate.size)) {
|
||||||
|
vc.toast('Excel文件大小不能超过2M');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var param = new FormData();
|
||||||
|
param.append("uploadFile", vc.component.assetImportInfo.excelTemplate);
|
||||||
|
param.append('communityId', vc.component.assetImportInfo.communityId);
|
||||||
|
param.append('meterType', "2020");
|
||||||
|
|
||||||
|
|
||||||
|
vc.http.upload(
|
||||||
|
'feeImport',
|
||||||
|
'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/listOwner')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vc.toast(json,10000);
|
||||||
|
},
|
||||||
|
function (errInfo, error) {
|
||||||
|
console.log('请求失败处理');
|
||||||
|
vc.toast(errInfo,10000);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
_exitCommunityData: function () {
|
||||||
|
vc.jumpToPage('/callComponent/assetImport/exitCommunityData?communityId='+vc.getCurrentCommunity().communityId);
|
||||||
|
},
|
||||||
|
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);
|
||||||
Loading…
Reference in New Issue
Block a user