(function (vc) {
|
vc.extends({
|
data: {
|
importMeterWaterFeeInfo: {
|
communityId: vc.getCurrentCommunity().communityId,
|
excelTemplate: '',
|
configId: '',
|
feeConfigs: [],
|
secondaryFeeTypeCds: [],
|
secondaryFeeTypeCd: '',
|
feeTypeCd: '',
|
meterTypes: [],
|
meterType: ''
|
}
|
},
|
_initMethod: function () {
|
vc.getDict('pay_fee_config', "fee_type_cd", function (_data) {
|
$that.importMeterWaterFeeInfo.feeTypeCds = _data;
|
});
|
},
|
_initEvent: function () {
|
vc.on('importMeterWaterFee', 'openImportMeterWaterFeeModal',
|
function (_room) {
|
$that._listImportMeterTypes();
|
$('#importMeterWaterFeeModel').modal('show');
|
}
|
);
|
},
|
methods: {
|
importMeterWaterFeeValidate() {
|
return vc.validate.validate({
|
importMeterWaterFeeInfo: $that.importMeterWaterFeeInfo
|
}, {
|
'importMeterWaterFeeInfo.communityId': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "数据异常还没有入驻小区"
|
}
|
],
|
'importMeterWaterFeeInfo.excelTemplate': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "文件不能为空"
|
}
|
]
|
});
|
},
|
_importMeterWaterData: function () {
|
if (!$that.importMeterWaterFeeValidate()) {
|
vc.toast(vc.validate.errInfo);
|
return;
|
}
|
// 导入数据
|
if (!$that.checkFileType($that.importMeterWaterFeeInfo.excelTemplate.name.split('.')[1])) {
|
vc.toast('不是有效的Excel格式');
|
return;
|
}
|
if (!$that.checkFileSize($that.importMeterWaterFeeInfo.excelTemplate.size)) {
|
vc.toast('Excel文件大小不能超过20M');
|
return;
|
}
|
let param = new FormData();
|
param.append("uploadFile", $that.importMeterWaterFeeInfo.excelTemplate);
|
param.append('communityId', $that.importMeterWaterFeeInfo.communityId);
|
param.append('feeTypeCd', $that.importMeterWaterFeeInfo.feeTypeCd);
|
param.append('configId', $that.importMeterWaterFeeInfo.configId);
|
param.append('meterType', $that.importMeterWaterFeeInfo.meterType);
|
param.append('userId', '-1'); // 添加userId参数
|
param.append('USER-ID', '-1'); // 添加USER-ID参数(大写形式)
|
// 根据费用类型选择对应的适配器
|
if ($that.importMeterWaterFeeInfo.feeTypeCd === '630000017') {
|
// 水费使用 importMeterWaterFeeV2
|
param.append('importAdapt', "importMeterWaterFeeV2");
|
} else if ($that.importMeterWaterFeeInfo.feeTypeCd === '630000007') {
|
// 电费使用 importElectricityFeeV2
|
param.append('importAdapt', "importElectricityFeeV2");
|
} else {
|
// 其他费用使用原有适配器
|
param.append('importAdapt', "importMeterWaterFee");
|
}
|
vc.http.upload(
|
'assetImport',
|
'importData',
|
param, {
|
// 移除emulateJSON,避免与Content-Type冲突
|
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("处理成功");
|
$('#importMeterWaterFeeModel').modal('hide');
|
vc.jumpToPage('/#/pages/property/assetImportLogDetail?logId=' + _json.data.logId + '&logType=importMeterWaterFee');
|
return;
|
}
|
vc.toast(_json.msg, 10000);
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
vc.toast(errInfo, 10000);
|
});
|
},
|
_exportMeterWaterFeeTemplate: function () {
|
let _feeTypeCd = $that.importMeterWaterFeeInfo.feeTypeCd;
|
|
if (!vc.notNull(_feeTypeCd)) {
|
vc.toast('请选择费用类型');
|
return;
|
}
|
|
// 根据费用类型选择对应的模板
|
let templateUrl = '';
|
if (_feeTypeCd === '630000017') {
|
// 水费模板(对应 sheet:水费流水模板)
|
templateUrl = '/import/Z4水费流水模版.xlsx';
|
} else if (_feeTypeCd === '630000007') {
|
// 电费模板(对应 sheet:电费流水模版)
|
templateUrl = '/import/Z4电费流水模板.xlsx';
|
} else {
|
// 其他费用使用默认模板
|
templateUrl = '/import/抄表导入模板.xlsx';
|
}
|
|
// 直接下载模板文件
|
window.open(templateUrl, '_blank');
|
},
|
_listImportMeterTypes: function (_page, _rows) {
|
var param = {
|
params: {
|
page: 1,
|
row: 50,
|
communityId: vc.getCurrentCommunity().communityId
|
}
|
};
|
//发送get请求
|
vc.http.apiGet('meterType.listMeterType',
|
param,
|
function (json, res) {
|
var _meterTypeManageInfo = JSON.parse(json);
|
$that.importMeterWaterFeeInfo.meterTypes = _meterTypeManageInfo.data;
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
clearAddFeeConfigInfo: function () {
|
$that.importMeterWaterFeeInfo = {
|
communityId: vc.getCurrentCommunity().communityId,
|
excelTemplate: '',
|
secondaryFeeTypeCd: '',
|
configId: '',
|
feeConfigs: [],
|
feeTypeCd: '',
|
meterTypes: [],
|
meterType: ''
|
};
|
},
|
getExcelTemplate: function (e) {
|
//console.log("getExcelTemplate 开始调用")
|
$that.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 = 20 * 1024 * 1024;
|
if (fileSize > MAX_SIZE) {
|
return false;
|
}
|
return true;
|
},
|
_changeImportMeterWaterFeeTypeCd: function (_feeTypeCd){
|
$that.importMeterWaterFeeInfo.secondaryFeeTypeCd='';
|
$that.importMeterWaterFeeInfo.configId = '';
|
let param = {
|
params: {
|
feeTypeCd: _feeTypeCd,
|
}
|
};
|
vc.http.apiGet('/secondaryFeeTypeCdGl.list.show', param,
|
function (json, res) {
|
let result = JSON.parse(json);
|
if (result.length ) {
|
$that.$set($that.importMeterWaterFeeInfo, 'secondaryFeeTypeCds', result);
|
} else {
|
$that.$set($that.importMeterWaterFeeInfo, 'secondaryFeeTypeCds', [{
|
secondaryFeeTypeCd: "",
|
secondaryFeeTypeName: "无关联子类型,请直接选择收费项目"
|
}]);
|
}
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
vc.toast(errInfo);
|
}
|
);
|
$that._changeSecondaryFeeTypeCdx(_feeTypeCd, '');
|
},
|
_changeSecondaryFeeTypeCdx: function(_feeTypeCd,_secondaryFeeTypeCd) {
|
$that.importMeterWaterFeeInfo.configId = '';
|
var param = {
|
params: {
|
page: 1,
|
row: 20,
|
communityId: vc.getCurrentCommunity().communityId,
|
feeTypeCd: _feeTypeCd,
|
secondaryFeeTypeCd: _secondaryFeeTypeCd,
|
isDefault: 'F',
|
valid: '1'
|
}
|
};
|
//发送get请求
|
vc.http.apiGet('/feeConfig.listFeeConfigs', param,
|
function (json, res) {
|
var _feeConfigManageInfo = JSON.parse(json);
|
$that.importMeterWaterFeeInfo.feeConfigs = _feeConfigManageInfo.feeConfigs;
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
}
|
});
|
})(window.vc);
|