MicroCommunityWeb/public/components/admin/addPropertyCommunity/addPropertyCommunity.js

131 lines
5.3 KiB
JavaScript

(function (vc) {
vc.extends({
data: {
addPropertyCommunityInfo: {
memberId: '',
menuGroups: [],
groupIds: [],
communitys: [],
communityIds: [],
isAll: true
}
},
watch: {
'addPropertyCommunityInfo.communitys': function () { //'goodList'是我要渲染的对象,也就是我要等到它渲染完才能调用函数
this.$nextTick(function () {
$('#communityCommunityIds').selectpicker({
title: '选填,请选择开通小区',
styleBase: 'form-control',
width: 'auto'
});
$('#communityCommunityIds').selectpicker('refresh');
})
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('addPropertyCommunity', 'openAddPropertyCommunityModal', function (_param) {
$that._listPropertyCommunityMenuGroups();
$that._listCommunityFreeCommunitys();
$that.addPropertyCommunityInfo.memberId = _param.storeId;
$('#addPropertyCommunityModel').modal('show');
});
},
methods: {
savePropertyCommunityInfo: function () {
vc.http.apiPost(
'/member.join.community',
JSON.stringify(vc.component.addPropertyCommunityInfo), {
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#addPropertyCommunityModel').modal('hide');
vc.component.clearAddPropertyCommunityInfo();
vc.emit('propertyCommunity', 'listCommunity', {});
vc.toast("操作成功");
return;
} else {
vc.toast(_json.msg);
}
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
clearAddPropertyCommunityInfo: function () {
vc.component.addPropertyCommunityInfo = {
storeId: '',
menuGroups: [],
groupIds: [],
communitys: [],
communityIds: [],
isAll: true
};
},
changeAllCommunity: function () {
if ($that.addPropertyCommunityInfo.isAll) {
for (var i = 0; i < $that.addPropertyCommunityInfo.menuGroups.length; i++) {
let _value = $that.addPropertyCommunityInfo.menuGroups[i].gId;
$that.addPropertyCommunityInfo.groupIds.push(_value);
}
} else {
$that.addPropertyCommunityInfo.groupIds = [];
}
},
changeItemCommunity: function () {
if ($that.addPropertyCommunityInfo.groupIds.length < $that.addPropertyCommunityInfo.menuGroups.length) {
$that.addPropertyCommunityInfo.isAll = false;
return;
}
$that.addPropertyCommunityInfo.isAll = true;
},
_listPropertyCommunityMenuGroups: function () {
let param = {
params: {
page: 1,
row: 100,
storeType: '800900000003'
}
};
//发送get请求
vc.http.apiGet('/menuGroup.listMenuGroup',
param,
function (json, res) {
let _propertyCompanyManageInfo = JSON.parse(json);
$that.addPropertyCommunityInfo.menuGroups = _propertyCompanyManageInfo.data;
_propertyCompanyManageInfo.data.forEach(item => {
$that.addPropertyCommunityInfo.groupIds.push(item.gId)
})
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_listCommunityFreeCommunitys: function () {
let param = {
params: {
communityName: ''
}
}
//发送get请求
vc.http.get('storeEnterCommunity',
'listNoEnterCommunity',
param,
function (json, res) {
vc.component.addPropertyCommunityInfo.communitys = JSON.parse(json);
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
}
});
})(window.vc);