You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
13 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>编辑</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="../../static/css/font.css">
<link rel="stylesheet" href="../../static/css/weadmin.css">
<link rel="stylesheet" href="../../lib/layui/css/layui.css">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
select {
width: 180px;
height: 38px;
line-height: 38px;
border: 1px solid #ccc;
border-radius: 3px;
font-size: 15px;
padding-left: 6px;
color: #666;
}
</style>
</head>
<body>
<div class="weadmin-body">
<form class="layui-form">
<div class="layui-form-item">
<div id="div3" class="layui-form-item">
<label for="" class="layui-form-label">
<span class="we-red">*</span>学校类型:
</label>
<div class="layui-input-inline" id="select_3"></div>
<script type="text/html" id="test3">
<select name="service_type" id="sel3">
{{#layui.each(d.data,function(index,item){ }}
<option value={{item.school_type_id}}>{{item.school_type_name}}</option>
{{# }) }}
{{# if(d.data.length === 0){ }}
无数据
{{# } }}
</select>
</script>
</div>
<div id="div4" class="layui-form-item">
<label class="layui-form-label">
<span class="we-red">*</span>学校办别:
</label>
<div class="layui-input-inline" id="select_4"></div>
<script type="text/html" id="test4">
<select name="service_type" id="sel4">
{{#layui.each(d.data,function(index,item){ }}
<option value={{item.property_id}}>{{item.property_name}}</option>
{{# }) }}
{{# if(d.data.length === 0){ }}
无数据
{{# } }}
</select>
</script>
</div>
<div id="div5" class="layui-form-item">
<label class="layui-form-label">
<span class="we-red">*</span>隶属关系:
</label>
<div class="layui-input-inline" id="select_5" style="width: 400px;"></div>
<script type="text/html" id="test5">
{{# layui.each(d, function(index,item){ }}
<span style="margin-right:0">
<input type="radio" value={{item.level_id}} name="level" title={{item.level_name}} lay-verify="required">
</span>
{{# }); }}
</script>
</div>
</div>
<div class="layui-form-item">
<label for="name" class="layui-form-label">
<span class="we-red">*</span>城乡类型:
</label>
<div class="layui-input-block">
<input type="radio" name="chengxiang" value="1" title="城区" checked="">
<input type="radio" name="chengxiang" value="2" title="镇区">
<input type="radio" name="chengxiang" value="3" title="乡村">
</div>
</div>
<div class="layui-form-item">
<label for="name" class="layui-form-label">
<span class="we-red">*</span>学校名称:
</label>
<div class="layui-input-inline textinput">
<input type="text" id="name" name="name" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="sort_id" class="layui-form-label">
<span class="we-red">*</span>排序号:
</label>
<div class="layui-input-inline textinput">
<input type="text" id="sort_id" name="sort_id" lay-verify="required|number" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="code" class="layui-form-label">
<span class="we-red">*</span>学校编码:
</label>
<div class="layui-input-inline textinput">
<input type="text" id="code" name="code" lay-verify="required|string" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="" class="layui-form-label">
</label>
<button class="layui-btn" lay-filter="save" lay-submit="" id="save">确定</button>
</div>
</form>
</div>
<script src="../../lib/layui/layui.js"></script>
<script>
layui.extend({
admin: '{/}../../static/js/admin'
});
layui.use(['form', 'jquery', 'admin', 'layer', 'laytpl'], function () {
var form = layui.form,
$ = layui.jquery,
admin = layui.admin,
layer = layui.layer,
laytpl = layui.laytpl;
var area_id = "";
var org_id = "";
var level_id = "";
var org_type_id = "";
// 获取市、区类型
window.getOrgTypePrincipalshipByParentId = function () {
$.ajax({
type: "GET",
async: false,
dataType: "json",
url: "/baseService/base/getOrgTypePrincipalshipByParentId?parent_id=1",
success: function (data) {
var getTpl = test1.innerHTML
, select_1 = document.getElementById('select_1');
laytpl(getTpl).render(data, function (html) {
select_1.innerHTML = html;
});
form.render();
getOrgtype();
}
})
};
// 获取市区下单位类型
window.getOrgtype = function (level_id) {
$("#div2").removeClass("hide");
$.ajax({
type: "GET",
async: false,
dataType: "json",
url: "/baseService/base/getOrgTypePrincipalshipByParentId?parent_id=" + level_id,
success: function (data) {
var lis = [];
var list = {};
for (var i = 0; i < data.data.length; i++) {
if (data.data[i].is_school == 1) {
lis.push(data.data[i])
}
}
list = {
data: lis
};
var getTpl = test2.innerHTML
, select_2 = document.getElementById('select_2');
laytpl(getTpl).render(list, function (html) {
select_2.innerHTML = html;
});
form.render();
}
})
};
// 获取学校类型
window.getSchoolType = function () {
$.ajax({
type: "GET",
dataType: "json",
url: "/baseService/organization/getSchoolType?org_type_id=" + org_type_id,
success: function (data) {
var getTpl = test3.innerHTML
, select_3 = document.getElementById('select_3');
laytpl(getTpl).render(data, function (html) {
select_3.innerHTML = html;
});
form.render();
getDmSchoolProperty();
}
})
};
// 获取学校办别
window.getDmSchoolProperty = function () {
$.ajax({
type: "GET",
dataType: "json",
url: "/baseService/dm/getDmSchoolProperty",
success: function (data) {
var getTpl = test4.innerHTML
, select_4 = document.getElementById('select_4');
laytpl(getTpl).render(data, function (html) {
select_4.innerHTML = html;
});
form.render();
getDmSchoolLevel();
}
});
};
// 获取隶属关系
window.getDmSchoolLevel = function () {
$.ajax({
type: "GET",
dataType: "json",
url: "/baseService/dm/getDmSchoolLevel",
success: function (data) {
var getTpl = test5.innerHTML
, select_5 = document.getElementById('select_5');
laytpl(getTpl).render(data, function (html) {
select_5.innerHTML = html;
});
form.render();
getOrgInfoById(org_id);
}
});
};
window.getOrgInfoById = function (id) {
$.ajax({
type: "GET",
dataType: "json",
url: "/baseService/organization/getOrgInfoById?org_id=" + id,
success: function (data) {
$("#name").val(data.data[0].org_name);
$("#code").val(data.data[0].org_code);
$("#sort_id").val(data.data[0].sort_id);
$("#sel3 option[value='" + data.data[0].school_type_id + "']").attr("selected", 'checked');
$("#sel3").attr("disabled", true);
$("#sel4 option[value='" + data.data[0].property_id + "']").attr("selected", 'checked');
$('input:radio[name="level"][value="'+data.data[0].level_id+'"]').attr('checked','checked');
$('input:radio[name="property"][value="'+data.data[0].property_id+'"]').attr('checked','checked');
//设置城乡的数据库记录值
var n=data.data[0].chengxiang_id-1;
$("input[name='chengxiang']").eq(n).attr('checked', 'true');
form.render();
}
})
};
$(function () {
level_id = GetQueryString("level_id");
area_id = GetQueryString("area_id");
org_id = GetQueryString("org_id");
org_type_id = GetQueryString("org_type_id");
getSchoolType();
});
verifyLength();
//监听提交
form.on('submit(save)', function (data) {
var f=data.field;
var org_code = $("#code").val();
var org_name = $("#name").val();
var sort_id = $("#sort_id").val();
//城乡类型
var chengxiang=$("input[name='chengxiang']:checked").val();
var data = {};
data = {
bureau_id: org_id,
org_code: org_code,
bureau_name: org_name,
parent_org_id: area_id,
org_type_id: org_type_id,
sort_id: sort_id,
main_school_id: -1,
master_id: -1,
school_type_id: $("#sel3 option:selected").val(),
level_id:f.level,
property_id:f.property,
chengxiang:chengxiang,
};
if (org_name == "") {
layer.alert("请输入学校名称", {icon: 0})
return;
}
if (sort_id == "") {
layer.alert("请输入排序号", {icon: 0})
return;
}
if (org_code == "") {
layer.alert("请输入学校编码", {icon: 0});
return;
}
$.ajax({
type: "POST",
async: false,
dataType: "json",
url: "/baseService/organization/updateBureau",
data: data,
success: function (data) {
if (data.success) {
layer.msg("编辑成功", {icon: 1, time: 1000, shade: [0.5, '#000', true]}, function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
window.parent.reloadTable();
});
} else {
layer.alert(data.message, {icon: 0})
}
}
});
return false;
});
});
</script>
</body>
</html>