优化费用导入功能

This commit is contained in:
java110 2020-08-05 23:43:07 +08:00
parent 8ade02bbbc
commit 89be25cd48
5 changed files with 232 additions and 4 deletions

8
app.js
View File

@ -34,10 +34,10 @@ let opts = {
//app.use('/callComponent',proxy('https://app.demo.winqi.cn/',opts));
//app.use('/callComponent',proxy('http://api.demo.winqi.cn:8012/',opts));
//app.use('/callComponent',proxy('http://api.demo.winqi.cn:8012',opts));
//app.use('/callComponent',proxy('http://api.demo.winqi.cn:8012',opts));
//app.use('/app',proxy('http://api.demo.winqi.cn:8012',opts));
app.use('/callComponent',proxy('http://192.168.1.16:8012',opts));
app.use('/app',proxy('http://192.168.1.16:8012',opts));
app.use('/callComponent',proxy('http://api.demo.winqi.cn:8012',opts));
app.use('/app',proxy('http://api.demo.winqi.cn:8012',opts));
//app.use('/callComponent',proxy('http://192.168.1.16:8012',opts));
//app.use('/app',proxy('http://192.168.1.16:8012',opts));
//app.listen(3000);
app.use(express.json());

View File

@ -0,0 +1,60 @@
<div id="importRoomFeeModel" class="modal fade" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<h3 class="m-t-none m-b ">费用导入</h3>
<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">
<select class="custom-select" v-model="importRoomFeeInfo.feeTypeCd"
@change="_changeFeeTypeCd(importRoomFeeInfo.feeTypeCd)">
<option selected disabled value="">必填,请选择费用类型</option>
<option v-for="(item,index) in importRoomFeeInfo.feeTypeCds" :key="index"
v-bind:value="item.statusCd" v-if="item.statusCd !='888800010008'">
{{item.name}}
</option>
</select></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">{{importRoomFeeInfo.excelTemplate==''?'必填,请选择数据文件':importRoomFeeInfo.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">
请先下载
<a href="javascript:void(0)" target="_blank" v-on:click="_exportRoomFeeTemplate()">导入模板
</a>
准备数据后,上传导入
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="_importData()"><i
class="fa fa-check"></i>&nbsp;导入
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">取消
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,159 @@
(function (vc) {
vc.extends({
data: {
importRoomFeeInfo: {
communityId: vc.getCurrentCommunity().communityId,
excelTemplate: '',
feeTypeCd: '',
feeConfigs: []
}
},
_initMethod: function () {
vc.getDict('pay_fee_config', "fee_type_cd", function (_data) {
vc.component.importRoomFeeInfo.feeTypeCds = _data;
});
},
_initEvent: function () {
vc.on('importRoomFee', 'openImportRoomFeeModal',
function (_room) {
$('#importRoomFeeModel').modal('show');
});
},
methods: {
importRoomFeeValidate() {
return vc.validate.validate({
importRoomFeeInfo: vc.component.importRoomFeeInfo
},
{
'importRoomFeeInfo.communityId': [{
limit: "required",
param: "",
errInfo: "数据异常还没有入驻小区"
}
],
'importRoomFeeInfo.feeTypeCd': [{
limit: "required",
param: "",
errInfo: "费用类型不能为空"
}
],
'importRoomFeeInfo.excelTemplate': [
{
limit: "required",
param: "",
errInfo: "文件不能为空"
}
]
});
},
_importData: function () {
if (!vc.component.importRoomFeeValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
// 导入数据
if (!vc.component.checkFileType(vc.component.importRoomFeeInfo.excelTemplate.name.split('.')[1])) {
vc.toast('不是有效的Excel格式');
return;
}
if (!vc.component.checkFileSize(vc.component.importRoomFeeInfo.excelTemplate.size)) {
vc.toast('Excel文件大小不能超过2M');
return;
}
var param = new FormData();
param.append("uploadFile", vc.component.importRoomFeeInfo.excelTemplate);
param.append('communityId', vc.component.importRoomFeeInfo.communityId);
vc.http.upload(
'importRoomFee',
'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);
});
},
_exportRoomFeeTemplate:function(){
vc.jumpToPage('/callComponent/importRoomFee/exportData?communityId='+vc.getCurrentCommunity().communityId);
},
clearAddFeeConfigInfo: function () {
var _feeTypeCds = vc.component.importRoomFeeInfo.feeTypeCds;
vc.component.importRoomFeeInfo = {
communityId: vc.getCurrentCommunity().communityId,
excelTemplate: '',
feeTypeCd: '',
feeConfigs: []
};
vc.component.importRoomFeeInfo.feeTypeCds = _feeTypeCds;
},
_changeFeeTypeCd: function (_feeTypeCd) {
var param = {
params: {
page: 1,
row: 20,
communityId: vc.getCurrentCommunity().communityId,
feeTypeCd: _feeTypeCd,
isDefault: 'F'
}
};
//发送get请求
vc.http.get('importRoomFee', 'list', param,
function (json, res) {
var _feeConfigManageInfo = JSON.parse(json);
vc.component.importRoomFeeInfo.feeConfigs = _feeConfigManageInfo.feeConfigs;
},
function (errInfo, error) {
console.log('请求失败处理');
});
},
getExcelTemplate: function (e) {
//console.log("getExcelTemplate 开始调用")
vc.component.importRoomFeeInfo.excelTemplate = e.target.files[0];
},
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);

View File

@ -76,6 +76,10 @@
<div class="ibox-title">
<h5>房屋信息</h5>
<div class="ibox-tools" style="top:10px;">
<button type="button" class="btn btn-primary btn-sm" style="margin-left:10px"
v-on:click="_openRoomFeeImport(null,true)">
费用导入
</button>
<button type="button" class="btn btn-primary btn-sm" style="margin-left:10px"
v-on:click="_openRoomCreateFeeAddModal(null,true)">
<i class="fa fa-plus"></i> 批量创建
@ -162,4 +166,6 @@
<vc:create path="property/searchFloor" emitChooseFloor="room" emitLoadData="room"></vc:create>
<vc:create path="property/roomCreateFeeAdd"></vc:create>
<vc:create path="property/importRoomFee"></vc:create>
</div>

View File

@ -170,6 +170,9 @@
_toOwnerPayFee:function(_room){
let roomName = _room.floorNum + "栋"+_room.unitNum+"单元"+_room.roomNum+"室"
vc.jumpToPage('/admin.html#/pages/property/owePayFeeOrder?payObjId='+_room.roomId+"&payObjType=3333&roomName="+roomName);
},
_openRoomFeeImport:function(){
vc.emit('importRoomFee','openImportRoomFeeModal',{});
}
}
});