优化代码

This commit is contained in:
java110 2021-12-08 15:36:50 +08:00
parent c7886cf4f5
commit c9eca8cc96
3 changed files with 62 additions and 81 deletions

View File

@ -1,4 +1,4 @@
(function (vc) {
(function(vc) {
vc.extends({
propTypes: {
@ -16,11 +16,11 @@
remark: ''
}
},
_initMethod: function () {
_initMethod: function() {
},
_initEvent: function () {
vc.on('addAccountBond', 'openAddAccountBondModal', function () {
_initEvent: function() {
vc.on('addAccountBond', 'openAddAccountBondModal', function() {
$('#addAccountBondModel').modal('show');
});
},
@ -29,8 +29,7 @@
return vc.validate.validate({
addAccountBondInfo: vc.component.addAccountBondInfo
}, {
'addAccountBondInfo.bondName': [
{
'addAccountBondInfo.bondName': [{
limit: "required",
param: "",
errInfo: "保证金名称不能为空"
@ -41,8 +40,7 @@
errInfo: "保证金名称超长了"
},
],
'addAccountBondInfo.amount': [
{
'addAccountBondInfo.amount': [{
limit: "required",
param: "",
errInfo: "保证金金额不能为空"
@ -53,34 +51,29 @@
errInfo: "保证金金额格式有误"
},
],
'addAccountBondInfo.bondMonth': [
{
limit: "num",
param: "",
errInfo: "有效月份格式错误"
},
],
'addAccountBondInfo.objId': [
{
limit: "maxin",
param: "1,30",
errInfo: "类型ID超长了"
},
],
'addAccountBondInfo.bondMonth': [{
limit: "num",
param: "",
errInfo: "有效月份格式错误"
}, ],
'addAccountBondInfo.objId': [{
limit: "maxin",
param: "1,30",
errInfo: "类型ID超长了"
}, ],
});
},
saveAccountBondInfo: function () {
saveAccountBondInfo: function() {
if (!vc.component.addAccountBondValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.component.addAccountBondInfo.communityId = vc.getCurrentCommunity().communityId;
//不提交数据将数据 回调给侦听处理
if (vc.notNull($props.callBackListener)) {
vc.emit($props.callBackListener, $props.callBackFunction, vc.component.addAccountBondInfo);
@ -90,11 +83,10 @@
vc.http.apiPost(
'/accountBond/saveAccountBond',
JSON.stringify(vc.component.addAccountBondInfo),
{
JSON.stringify(vc.component.addAccountBondInfo), {
emulateJSON: true
},
function (json, res) {
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
@ -108,21 +100,21 @@
vc.message(_json.msg);
},
function (errInfo, error) {
function(errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
},
setAddBondName:function(_objId){
setAddBondName: function(_objId) {
$that.accountBondManageInfo.shopTypes.forEach(item => {
if (item.shopTypeId == _objId) {
$that.addAccountBondInfo.bondName = item.typeName;
}
});
},
clearAddAccountBondInfo: function () {
clearAddAccountBondInfo: function() {
vc.component.addAccountBondInfo = {
bondName: '',
amount: '',
@ -136,4 +128,4 @@
}
});
})(window.vc);
})(window.vc);

View File

@ -1,4 +1,4 @@
(function (vc, vm) {
(function(vc, vm) {
vc.extends({
data: {
@ -6,11 +6,11 @@
}
},
_initMethod: function () {
_initMethod: function() {
},
_initEvent: function () {
vc.on('deleteAccountBond', 'openDeleteAccountBondModal', function (_params) {
_initEvent: function() {
vc.on('deleteAccountBond', 'openDeleteAccountBondModal', function(_params) {
vc.component.deleteAccountBondInfo = _params;
$('#deleteAccountBondModel').modal('show');
@ -18,15 +18,13 @@
});
},
methods: {
deleteAccountBond: function () {
vc.component.deleteAccountBondInfo.communityId = vc.getCurrentCommunity().communityId;
deleteAccountBond: function() {
vc.http.apiPost(
'/accountBond/deleteAccountBond',
JSON.stringify(vc.component.deleteAccountBondInfo),
{
JSON.stringify(vc.component.deleteAccountBondInfo), {
emulateJSON: true
},
function (json, res) {
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
@ -37,16 +35,16 @@
}
vc.message(_json.msg);
},
function (errInfo, error) {
function(errInfo, error) {
console.log('请求失败处理');
vc.message(json);
});
},
closeDeleteAccountBondModel: function () {
closeDeleteAccountBondModel: function() {
$('#deleteAccountBondModel').modal('hide');
}
}
});
})(window.vc, window.vc.component);
})(window.vc, window.vc.component);

View File

@ -1,4 +1,4 @@
(function (vc, vm) {
(function(vc, vm) {
vc.extends({
data: {
@ -13,24 +13,22 @@
}
},
_initMethod: function () {
_initMethod: function() {
},
_initEvent: function () {
vc.on('editAccountBond', 'openEditAccountBondModal', function (_params) {
_initEvent: function() {
vc.on('editAccountBond', 'openEditAccountBondModal', function(_params) {
vc.component.refreshEditAccountBondInfo();
$('#editAccountBondModel').modal('show');
vc.copyObject(_params, vc.component.editAccountBondInfo);
vc.component.editAccountBondInfo.communityId = vc.getCurrentCommunity().communityId;
});
},
methods: {
editAccountBondValidate: function () {
editAccountBondValidate: function() {
return vc.validate.validate({
editAccountBondInfo: vc.component.editAccountBondInfo
}, {
'editAccountBondInfo.bondName': [
{
'editAccountBondInfo.bondName': [{
limit: "required",
param: "",
errInfo: "保证金名称不能为空"
@ -41,8 +39,7 @@
errInfo: "保证金名称超长了"
},
],
'editAccountBondInfo.amount': [
{
'editAccountBondInfo.amount': [{
limit: "required",
param: "",
errInfo: "保证金金额不能为空"
@ -53,30 +50,25 @@
errInfo: "保证金金额格式有误"
},
],
'editAccountBondInfo.bondMonth': [
{
limit: "num",
param: "",
errInfo: "有效月份格式错误"
},
],
'editAccountBondInfo.objId': [
{
limit: "maxin",
param: "1,30",
errInfo: "类型ID超长了"
},
],
'editAccountBondInfo.bondId': [
{
limit: "required",
param: "",
errInfo: "保证金ID不能为空"
}]
'editAccountBondInfo.bondMonth': [{
limit: "num",
param: "",
errInfo: "有效月份格式错误"
}, ],
'editAccountBondInfo.objId': [{
limit: "maxin",
param: "1,30",
errInfo: "类型ID超长了"
}, ],
'editAccountBondInfo.bondId': [{
limit: "required",
param: "",
errInfo: "保证金ID不能为空"
}]
});
},
editAccountBond: function () {
editAccountBond: function() {
if (!vc.component.editAccountBondValidate()) {
vc.toast(vc.validate.errInfo);
return;
@ -84,11 +76,10 @@
vc.http.apiPost(
'/accountBond/updateAccountBond',
JSON.stringify(vc.component.editAccountBondInfo),
{
JSON.stringify(vc.component.editAccountBondInfo), {
emulateJSON: true
},
function (json, res) {
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
@ -99,13 +90,13 @@
}
vc.message(_json.msg);
},
function (errInfo, error) {
function(errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
},
refreshEditAccountBondInfo: function () {
refreshEditAccountBondInfo: function() {
vc.component.editAccountBondInfo = {
bondId: '',
bondName: '',
@ -120,4 +111,4 @@
}
});
})(window.vc, window.vc.component);
})(window.vc, window.vc.component);