MicroCommunityWeb/public/components/fee/editCommunityPayment/editCommunityPayment.js

239 lines
9.0 KiB
JavaScript

(function (vc, vm) {
vc.extends({
data: {
editCommunityPaymentInfo: {
ppId: '',
paymentName: '',
communityId: '',
paymentTypes: [],
paymentType: '',
certPath: '',
state: '',
remark: '',
paymentKeys: [],
payType: '',
feeConfigs: [],
configIds: []
}
},
_initMethod: function () {
$that._loadEditPaymentAdapt();
},
_initEvent: function () {
vc.on('editCommunityPayment', 'openEditCommunityPaymentModal', function (_params) {
$that.refreshEditCommunityPaymentInfo();
$that._loadEditConfigs();
$('#editCommunityPaymentModel').modal('show');
vc.copyObject(_params, $that.editCommunityPaymentInfo);
$that._editChangeToType();
if ($that.editCommunityPaymentInfo.certPath) {
vc.emit('editCommunityPayment', 'uploadFile', 'notifyVedio', $that.editCommunityPaymentInfo.certPath)
}
});
vc.on('editCommunityPayment', 'notifyCert', function (_param) {
$that.editCommunityPaymentInfo.certPath = _param.realFileName;
})
},
methods: {
editCommunityPaymentValidate: function () {
return vc.validate.validate({
editCommunityPaymentInfo: $that.editCommunityPaymentInfo
}, {
'editCommunityPaymentInfo.paymentName': [
{
limit: "required",
param: "",
errInfo: "名称不能为空"
},
{
limit: "maxLength",
param: "64",
errInfo: "名称不能超过64"
},
],
'editCommunityPaymentInfo.paymentType': [
{
limit: "required",
param: "",
errInfo: "支付厂家不能为空"
},
{
limit: "maxLength",
param: "64",
errInfo: "支付厂家不能超过64"
},
],
'editCommunityPaymentInfo.remark': [
{
limit: "maxLength",
param: "512",
errInfo: "使用说明不能超过512"
},
],
'editCommunityPaymentInfo.ppId': [
{
limit: "required",
param: "",
errInfo: "编号不能为空"
}]
});
},
editCommunityPayment: function () {
if (!$that.editCommunityPaymentValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/payment.updateAdminPaymentPool',
JSON.stringify($that.editCommunityPaymentInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#editCommunityPaymentModel').modal('hide');
vc.emit('communityPayment', 'listCommunityPayment', {});
return;
}
vc.toast(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
refreshEditCommunityPaymentInfo: function () {
let _paymentTypes = $that.editCommunityPaymentInfo.paymentTypes;
$that.editCommunityPaymentInfo = {
ppId: '',
paymentName: '',
communityId: '',
paymentType: '',
paymentTypes: _paymentTypes,
certPath: '',
state: '',
remark: '',
paymentKeys: [],
payType: '',
feeConfigs: [],
configIds: []
}
},
_editChangeToType: function () {
if (!$that.editCommunityPaymentInfo.paymentType) {
return;
}
let _param = {
params: {
paymentType: $that.editCommunityPaymentInfo.paymentType,
page: 1,
row: 100
}
}
//发送get请求
vc.http.apiGet('/payment.listPaymentKey',
_param,
function (json, res) {
let _json = JSON.parse(json);
_json.data.forEach(item => {
item.columnValue = '';
})
$that.editCommunityPaymentInfo.paymentKeys = _json.data;
//todo 查询 支付信息
$that._editLoadPaymentData();
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_loadEditConfigs: function () {
let param = {
params: {
page: 1,
row: 100,
isDefault: 'F',
communityId: $that.editCommunityPaymentInfo.communityId
}
};
//发送get请求
vc.http.apiGet('/feeConfig.queryAdminFeeConfigs', param,
function (json, res) {
let _json = JSON.parse(json);
$that.editCommunityPaymentInfo.feeConfigs = _json.feeConfigs;
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_loadEditPaymentAdapt:function(){
let param = {
params: {
page: 1,
row: 100,
}
};
//发送get请求
vc.http.apiGet('/payment.listPaymentAdapt', param,
function (json, res) {
let _json = JSON.parse(json);
$that.editCommunityPaymentInfo.paymentTypes = _json.data;
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_editLoadPaymentData: function () {
let param = {
params: {
page: 1,
row: 1,
ppId: $that.editCommunityPaymentInfo.ppId
}
};
$that.editCommunityPayment.configIds = [];
//发送get请求
vc.http.apiGet('/payment.listAdminPayment',
param,
function (json, res) {
let _json = JSON.parse(json);
let _values = _json.data[0].values;
_values.forEach(_value => {
$that.editCommunityPaymentInfo.paymentKeys.forEach(_key =>{
if(_value.columnKey == _key.columnKey){
_key.columnValue = _value.columnValue;
}
})
});
let _configs = _json.data[0].configs;
if(!_configs){
return;
}
_configs.forEach(_config =>{
$that.editCommunityPaymentInfo.configIds.push(_config.configId);
})
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
}
}
});
})(window.vc, window.$that);