$(function() {
|
cheackForm("from");
|
$("title").text("系统字典管理 - " + systemTitle);
|
});
|
var vm = new Vue({
|
el: '#rapp',
|
data: {
|
showList: true,
|
title: null,
|
field: {},
|
form2: null
|
},
|
methods: {
|
saveOrUpdate: function () {
|
if ($("#from").valid()) {
|
if (vm.title == "新增") {
|
var url = "sys/field/save";
|
}
|
if (vm.title == "编辑") {
|
var url = "sys/field/update";
|
}
|
$.ajax({
|
type: "POST",
|
url: restServerBaseURL + url,
|
contentType: "application/json",
|
data: JSON.stringify(vm.field),
|
success: function (r) {
|
if (r.code === 0) {
|
alert('操作成功', function () {
|
if (vm.title == "新增") {
|
window.location.href = "fieldedit.html?fkey="+r.key;
|
}else{
|
window.location.reload();
|
}
|
if (parent.opener.vm && parent.opener.vm.reload) {
|
parent.opener.vm.reload();
|
}
|
});
|
} else {
|
alert(r.msg);
|
}
|
}
|
});
|
}
|
},
|
getInfo: function(fkey) {
|
$.get(restServerBaseURL + "sys/field/info/" + fkey, function (r) {
|
vm.field = r.field;
|
});
|
},
|
getUser: function() {
|
$.ajax({
|
type: "get",
|
url: restServerBaseURL + "org/user/info",
|
async: true,
|
dataType: 'json',
|
success: function (data) {
|
if (data.code != 0) {
|
alert(data.msg);
|
return;
|
} else {
|
vm.field.rcreateuser = data.user.nickname;
|
}
|
}
|
});
|
}
|
},
|
created: function(){
|
var search = window.location.search;
|
var fkey = "";
|
if(search.indexOf("?") > -1){
|
search = search.replace("?", "");
|
fkey = search.split('=')[1];
|
}
|
if(fkey == ""){
|
this.title = "新增";
|
this.user = {};
|
this.getUser();
|
} else {
|
this.title = "编辑";
|
|
this.getInfo(fkey);
|
}
|
}
|
});
|