$(function() {
|
cheackForm("from");
|
$("title").text("群组管理 - " + systemTitle);
|
});
|
var vm = new Vue({
|
el: '#rapp',
|
data: {
|
title: null,
|
group: {}
|
},
|
methods: {
|
saveOrUpdate: function() {
|
vm.group.appId = $("#systemNames").val();
|
//校验必填
|
// var isVaild = true;
|
// $(":input").each(function () {
|
// if ($(this).attr('validate')) {
|
// var text = $(this).val();
|
// if (text == '' || text == null || text == 'None') {
|
// $(this).css("borderColor","red");
|
// isVaild = false;
|
// }
|
// }
|
// })
|
// if (!isVaild) {
|
// return false;
|
// }
|
if (vm.title == "新增") {
|
var url = "org/group/save";
|
}
|
if (vm.title == "编辑") {
|
var url = "org/group/update";
|
}
|
if($("#from").valid()) {
|
$.ajax({
|
type: "POST",
|
url: restServerBaseURL + url,
|
contentType: "application/json",
|
data: JSON.stringify(vm.group),
|
success: function (r) {
|
if (r.code === 0) {
|
alert('操作成功', function () {
|
if (vm.title == "新增") {
|
window.location.href = window.location.href + "?groupId=" + r.groupid;
|
} else {
|
window.location.reload();
|
}
|
if (parent.opener.vm && parent.opener.vm.reload) {
|
parent.opener.vm.reload();
|
}
|
});
|
} else {
|
alert(r.msg);
|
}
|
}
|
});
|
}
|
},
|
getInfo: function(groupid) {
|
var id = parseInt(groupid);
|
$.get(restServerBaseURL + "org/group/info/" + id, function(r) {
|
vm.group = r.group;
|
var appid = r.group!=null ? r.group.appId:""
|
initSystemName(1,appid);
|
});
|
}
|
},
|
created: function(){
|
var search = window.location.search;
|
var groupId = "";
|
if(search.indexOf("?") > -1){
|
search = search.replace("?", "");
|
groupId = search.split('=')[1];
|
}
|
if(groupId == ""){
|
this.title = "新增";
|
this.group = {};
|
initSystemName(0);
|
} else {
|
this.title = "编辑";
|
this.getInfo(groupId);
|
}
|
}
|
});
|
|
function initSystemName(type,appid) {
|
$.get(restServerBaseURL + "sys/systeminfo/queryListAll", function(r) {
|
var systemList = r.systemList;
|
jQuery("#systemNames").empty().append("<option value='0'>全部</option>");
|
jQuery.each(systemList, function(i, item) {
|
jQuery("#systemNames").append("<option value=" + item.appid + ">" + item.appfullname + "</option>");
|
});
|
if (type == 0 && getAppId()!=null) {
|
jQuery("#systemNames").val(getAppId());
|
}else{
|
jQuery("#systemNames").val(appid);
|
}
|
});
|
}
|
|
$(function () {
|
$("[validate='{required:true}']").on("input propertychange keydown change",function(){
|
if ($(this).val() != '') {
|
$(this).css("borderColor",'');
|
}
|
})
|
})
|