$(function() {
|
cheackForm("from");
|
$("title").text("行政区划管理 - " + systemTitle);
|
});
|
var vm = new Vue({
|
el:'#rapp',
|
data:{
|
showList: true,
|
title: null,
|
region: {},
|
parentid:null
|
},
|
methods: {
|
query: function () {
|
vm.reload();
|
},
|
add: function(){
|
vm.showList = false;
|
vm.title = "新增";
|
vm.region = {};
|
},
|
saveOrUpdate: function () {
|
//校验必填
|
// 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 || $("#areausegrade").val() == "") {
|
// return false;
|
// }
|
var url = "";
|
if (vm.title == "新增") {
|
url = "org/region/save";
|
if (vm.parentid != '' && vm.parentid != null) {
|
vm.region.parentid = vm.parentid;
|
}else{
|
vm.region.parentid = "000000";
|
}
|
}else{
|
url = "org/region/update";
|
}
|
vm.region.isenable = $("#isenable")[0].checked==true ? 1 : 0;
|
vm.region.isorganization = $("#isorganization")[0].checked==true ? 1 : 0;
|
vm.region.approvelevel = $("#approvelevel").val();
|
vm.region.areausegrade = $("#areausegrade").val();
|
if($("#from").valid()) {
|
$.ajax({
|
type: "POST",
|
url: restServerBaseURL + url,
|
contentType: "application/json",
|
data: JSON.stringify(vm.region),
|
success: function (r) {
|
if (r.code === 0) {
|
alert('操作成功', function () {
|
if (vm.title == "新增") {
|
var href = window.location.href;
|
var pid = "";
|
var newurl = href.substring(0, href.indexOf('?')) + "?Id=" + r.regionid;
|
if (vm.parentid != '' && vm.parentid != null) {
|
pid = vm.parentid;
|
}
|
newurl += "&parentid=" + pid;
|
window.location.href = newurl;
|
} else {
|
window.location.reload();
|
}
|
if (parent.opener.vm && parent.opener.vm.reload) {
|
parent.opener.vm.reload();
|
}
|
if (parent.opener.vm && parent.opener.vm.refresh) {
|
parent.opener.vm.refresh();
|
}
|
});
|
} else {
|
alert(r.msg);
|
}
|
}
|
});
|
}
|
},
|
del: function () {
|
var regionids = getSelectedRows();
|
if(regionids == null){
|
return ;
|
}
|
|
confirm('确定要删除选中的记录?', function(){
|
$.ajax({
|
type: "POST",
|
url: restServerBaseURL + "org/region/delete",
|
contentType: "application/json",
|
data: JSON.stringify(regionids),
|
success: function(r){
|
if(r.code == 0){
|
alert('操作成功', function(){
|
window.close();
|
if(parent.opener.vm && parent.opener.vm.reload){
|
parent.opener.vm.reload();
|
}
|
});
|
}else{
|
alert(r.msg);
|
}
|
}
|
});
|
});
|
},
|
getInfo: function(regionid){
|
$.get(restServerBaseURL + "org/region/info/"+regionid, function(r){
|
vm.region = r.region;
|
if (vm.region != null) {
|
if(vm.region.isenable != null && vm.region.isenable==1){
|
$("#isenable").attr("checked", true);
|
}
|
if(vm.region.isorganization != null && vm.region.isorganization==1){
|
$("#isorganization").attr("checked", true);
|
}
|
$("#approvelevel").val(vm.region.approvelevel);
|
$("#areausegrade").val(vm.region.areausegrade);
|
}
|
});
|
},
|
reload: function () {
|
vm.showList = true;
|
var page = $("#jqGrid").jqGrid('getGridParam','page');
|
$("#jqGrid").jqGrid('setGridParam',{
|
page:page
|
}).trigger("reloadGrid");
|
},
|
refresh: function () {
|
vm.showList = true;
|
window.location.reload();
|
}
|
},
|
created: function(){
|
var search = window.location.search;
|
var regionid = "";
|
if(search.indexOf("?") > -1){
|
regionid = T.p('Id');
|
this.parentid = T.p('parentid');
|
}
|
if(regionid == "" || regionid == null || regionid == undefined){
|
this.title = "新增";
|
this.region = {};
|
} else {
|
this.title = "编辑";
|
this.getInfo(regionid);
|
//编辑时,行政区划编号不可编辑
|
$("#regionid").attr("readonly",true);
|
}
|
}
|
});
|
|
$(function () {
|
$("[validate='{required:true}']").on("input propertychange keydown change",function(){
|
if ($(this).val() != '') {
|
$(this).css("borderColor",'');
|
}
|
})
|
})
|
|
//根据名称获取首字母值
|
function changeToPinYin(){
|
var name = $("#regionname").val();
|
if(name == "" || name == null){
|
return;
|
}
|
$.ajax({
|
type: "GET",
|
url: restServerBaseURL + "org/unit/changeToPinYin?name="+ encodeURI(name),
|
contentType: "application/json",
|
success: function(msg) {
|
var pinyin = msg.pinyin;
|
if(pinyin != "") pinyin = decodeURI(pinyin);
|
$("#spellfirst").val("");
|
$("#spellfirst").val(pinyin);
|
vm.region.spellfirst = pinyin;
|
}
|
});
|
}
|
|
function ShowParent()
|
{
|
$("#rowparent").show();
|
}
|