From cdc841baf164e6ecc42e04b1e60653645c52c36b Mon Sep 17 00:00:00 2001 From: java110 <928255095@qq.com> Date: Sun, 22 Nov 2020 16:25:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=20=E6=8A=84=E8=A1=A8Excel?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../property/addMeterWater/addMeterWater.html | 2 +- .../property/addMeterWater/addMeterWater.js | 2 +- .../importMeterWaterFee.html | 72 +++++++ .../importMeterWaterFee.js | 175 ++++++++++++++++++ .../meterWaterManage/meterWaterManage.html | 12 +- .../meterWaterManage/meterWaterManage.js | 5 +- .../property/roomFeeImport/roomFeeImport.html | 2 - 7 files changed, 257 insertions(+), 13 deletions(-) create mode 100644 public/components/property/importMeterWaterFee/importMeterWaterFee.html create mode 100644 public/components/property/importMeterWaterFee/importMeterWaterFee.js diff --git a/public/components/property/addMeterWater/addMeterWater.html b/public/components/property/addMeterWater/addMeterWater.html index 8c1d58f8a..50913ac1f 100644 --- a/public/components/property/addMeterWater/addMeterWater.html +++ b/public/components/property/addMeterWater/addMeterWater.html @@ -10,7 +10,7 @@
+ + + + +
+ +
+ +
+ +
+
+
+ +
+
+ + +
+
+
+ +
+ +
+ 请先下载 + 导入模板 + + 准备数据后,上传导入 +
+
+ + + +
+ + +
+ + + + + + + \ No newline at end of file diff --git a/public/components/property/importMeterWaterFee/importMeterWaterFee.js b/public/components/property/importMeterWaterFee/importMeterWaterFee.js new file mode 100644 index 000000000..5115c800f --- /dev/null +++ b/public/components/property/importMeterWaterFee/importMeterWaterFee.js @@ -0,0 +1,175 @@ +(function (vc) { + + vc.extends({ + data: { + importMeterWaterFeeInfo: { + communityId: vc.getCurrentCommunity().communityId, + excelTemplate: '', + configId: '', + feeConfigs: [], + feeTypeCd:'' + } + }, + _initMethod: function () { + vc.getDict('pay_fee_config', "fee_type_cd", function (_data) { + vc.component.importMeterWaterFeeInfo.feeTypeCds = _data; + }); + + }, + _initEvent: function () { + vc.on('importMeterWaterFee', 'openImportMeterWaterFeeModal', + function (_room) { + $('#importMeterWaterFeeModel').modal('show'); + + }); + }, + methods: { + + importMeterWaterFeeValidate() { + return vc.validate.validate({ + importMeterWaterFeeInfo: vc.component.importMeterWaterFeeInfo + }, + { + 'importMeterWaterFeeInfo.communityId': [{ + limit: "required", + param: "", + errInfo: "数据异常还没有入驻小区" + } + ], + 'importMeterWaterFeeInfo.configId': [{ + limit: "required", + param: "", + errInfo: "费用类型不能为空" + } + ], + 'importMeterWaterFeeInfo.excelTemplate': [ + { + limit: "required", + param: "", + errInfo: "文件不能为空" + } + ] + }); + }, + _importMeterWaterData: function () { + + if (!vc.component.importMeterWaterFeeValidate()) { + vc.toast(vc.validate.errInfo); + return; + } + // 导入数据 + if (!vc.component.checkFileType(vc.component.importMeterWaterFeeInfo.excelTemplate.name.split('.')[1])) { + vc.toast('不是有效的Excel格式'); + return; + } + if (!vc.component.checkFileSize(vc.component.importMeterWaterFeeInfo.excelTemplate.size)) { + vc.toast('Excel文件大小不能超过2M'); + return; + } + var param = new FormData(); + param.append("uploadFile", vc.component.importMeterWaterFeeInfo.excelTemplate); + param.append('communityId', vc.component.importMeterWaterFeeInfo.communityId); + param.append('feeTypeCd', vc.component.importMeterWaterFeeInfo.feeTypeCd); + + + vc.http.upload( + 'importMeterWaterFee', + '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("处理成功"); + $('#importMeterWaterFeeModel').modal('hide'); + vc.jumpToPage('/admin.html#/pages/property/listOwner') + + vc.emit('roomFeeImport', 'listFee', {}); + return; + } + vc.toast(json, 10000); + }, + function (errInfo, error) { + console.log('请求失败处理'); + vc.toast(errInfo, 10000); + }); + }, + _exportMeterWaterFeeTemplate: function () { + let _meterType = '1010'; + + let _feeTypeCd = $that.importMeterWaterFeeInfo.feeTypeCd; + + if(!vc.notNull(_feeTypeCd)){ + vc.toast('请选择费用类型'); + return ; + } + + if(_feeTypeCd == '888800010015'){ + _meterType = '2020'; + } + vc.jumpToPage('/callComponent/importMeterWaterFee/exportData?communityId=' + vc.getCurrentCommunity().communityId+'&meterType='+_meterType); + }, + clearAddFeeConfigInfo: function () { + vc.component.importMeterWaterFeeInfo = { + communityId: vc.getCurrentCommunity().communityId, + excelTemplate: '', + configId: '', + feeConfigs: [], + feeTypeCd:'' + }; + + }, + getExcelTemplate: function (e) { + //console.log("getExcelTemplate 开始调用") + vc.component.importMeterWaterFeeInfo.excelTemplate = e.target.files[0]; + }, + checkFileType: function (fileType) { + const acceptTypes = ['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; + }, + _changeImportMeterWaterFeeTypeCd: function (_feeTypeCd) { + + var param = { + params: { + page: 1, + row: 20, + communityId: vc.getCurrentCommunity().communityId, + feeTypeCd: _feeTypeCd, + isDefault: 'F', + valid: '1' + } + }; + //发送get请求 + vc.http.get('roomCreateFeeAdd', 'list', param, + function (json, res) { + var _feeConfigManageInfo = JSON.parse(json); + vc.component.importMeterWaterFeeInfo.feeConfigs = _feeConfigManageInfo.feeConfigs; + }, + function (errInfo, error) { + console.log('请求失败处理'); + }); + }, + } + }); + +})(window.vc); \ No newline at end of file diff --git a/public/pages/property/meterWaterManage/meterWaterManage.html b/public/pages/property/meterWaterManage/meterWaterManage.html index 8a253c95d..998be0ec5 100644 --- a/public/pages/property/meterWaterManage/meterWaterManage.html +++ b/public/pages/property/meterWaterManage/meterWaterManage.html @@ -53,6 +53,10 @@ 抄表 +
@@ -69,13 +73,10 @@ 本期读表时间 创建时间 操作 - - - {{meterWater.meterType == '1010'?'电表':'水表'}} {{meterWater.objName}} {{meterWater.preDegrees}} @@ -93,7 +94,6 @@ v-on:click="_openDeleteMeterWaterModel(meterWater)">删除
- @@ -110,11 +110,9 @@ - - - + \ No newline at end of file diff --git a/public/pages/property/meterWaterManage/meterWaterManage.js b/public/pages/property/meterWaterManage/meterWaterManage.js index 7d0831d1e..8d4e1919d 100644 --- a/public/pages/property/meterWaterManage/meterWaterManage.js +++ b/public/pages/property/meterWaterManage/meterWaterManage.js @@ -78,9 +78,10 @@ } else { vc.component.meterWaterManageInfo.moreCondition = true; } + }, + _openMeterWaterImport:function(){ + vc.emit('importMeterWaterFee', 'openImportMeterWaterFeeModal',{}); } - - } }); })(window.vc); diff --git a/public/pages/property/roomFeeImport/roomFeeImport.html b/public/pages/property/roomFeeImport/roomFeeImport.html index 0a012b75c..308ce5ee4 100644 --- a/public/pages/property/roomFeeImport/roomFeeImport.html +++ b/public/pages/property/roomFeeImport/roomFeeImport.html @@ -65,8 +65,6 @@ 创建时间 备注 操作 - -