mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-27 00:20:01 +08:00
110 lines
4.4 KiB
JavaScript
110 lines
4.4 KiB
JavaScript
(function(vc) {
|
|
vc.extends({
|
|
data: {
|
|
doImportCreateFeeInfo: {
|
|
communityId: vc.getCurrentCommunity().communityId,
|
|
excelTemplate: ''
|
|
}
|
|
},
|
|
_initMethod: function() {},
|
|
_initEvent: function() {
|
|
vc.on('doImportCreateFee', 'openDoImportCreateFeeModal', function(_param) {
|
|
$('#doImportCreateFeeModel').modal('show');
|
|
});
|
|
},
|
|
methods: {
|
|
doImportCreateFeeValidate() {
|
|
return vc.validate.validate({
|
|
doImportCreateFeeInfo: $that.doImportCreateFeeInfo
|
|
}, {
|
|
'doImportCreateFeeInfo.communityId': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "数据异常还没有入驻小区"
|
|
}],
|
|
'doImportCreateFeeInfo.excelTemplate': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "文件不能为空"
|
|
}]
|
|
});
|
|
},
|
|
_doImportCreateFeeData: function() {
|
|
if (!$that.doImportCreateFeeValidate()) {
|
|
vc.toast(vc.validate.errInfo);
|
|
return;
|
|
}
|
|
// 导入数据
|
|
if (!$that.checkOwnerFileType($that.doImportCreateFeeInfo.excelTemplate.name.split('.')[1])) {
|
|
vc.toast('不是有效的Excel格式');
|
|
return;
|
|
}
|
|
if (!$that.checkOwnerFileSize($that.doImportCreateFeeInfo.excelTemplate.size)) {
|
|
vc.toast('Excel文件大小不能超过2M');
|
|
return;
|
|
}
|
|
|
|
let param = new FormData();
|
|
param.append("uploadFile", $that.doImportCreateFeeInfo.excelTemplate);
|
|
param.append('communityId', $that.doImportCreateFeeInfo.communityId);
|
|
param.append('importAdapt', "importCustomFee");
|
|
|
|
|
|
vc.http.upload(
|
|
'assetImport',
|
|
'importData',
|
|
param, {
|
|
emulateJSON: true,
|
|
//添加请求头
|
|
headers: {
|
|
"Content-Type": "multipart/form-data"
|
|
}
|
|
},
|
|
function (json, res) {
|
|
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
|
let _json = JSON.parse(json);
|
|
if (_json.code == 0) {
|
|
//关闭model
|
|
vc.toast("处理成功");
|
|
$('#doImportCreateFeeModel').modal('hide');
|
|
vc.jumpToPage('/#/pages/property/assetImportLogDetail?logId=' + _json.data.logId + '&logType=importCustomFee');
|
|
return;
|
|
}
|
|
vc.toast(_json.msg, 10000);
|
|
},
|
|
function (errInfo, error) {
|
|
console.log('请求失败处理');
|
|
vc.toast(errInfo, 10000);
|
|
});
|
|
},
|
|
clearAddFeeConfigInfo: function() {
|
|
// var _feeTypeCds = $that.importRoomFeeInfo.feeTypeCds;
|
|
$that.doImportCreateFeeInfo = {
|
|
communityId: vc.getCurrentCommunity().communityId,
|
|
excelTemplate: ''
|
|
};
|
|
},
|
|
getExcelTemplate: function(e) {
|
|
//console.log("getExcelTemplate 开始调用")
|
|
$that.doImportCreateFeeInfo.excelTemplate = e.target.files[0];
|
|
},
|
|
checkOwnerFileType: function(fileType) {
|
|
const acceptTypes = ['xlsx', 'xls'];
|
|
for (var i = 0; i < acceptTypes.length; i++) {
|
|
if (fileType === acceptTypes[i]) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
checkOwnerFileSize: function(fileSize) {
|
|
//2M
|
|
const MAX_SIZE = 2 * 1024 * 1024;
|
|
if (fileSize > MAX_SIZE) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
});
|
|
})(window.vc); |