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.

414 lines
15 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>
.layui-form-label {
width: 90px !important;
}
input {
width: 320px !important;
}
.layui-form-select {
width: 320px !important;
}
</style>
</head>
<body>
<div class="weadmin-body">
<form class="layui-form" lay-filter="editForm" id="editForm">
<div class="layui-form-item">
<label for="name" class="layui-form-label">
<span class="we-red">*</span>人员姓名:
</label>
<div class="layui-input-inline ">
<input type="text" id="name" name="name" lay-verify="required|contentLength" min="2" max="32"
autocomplete="off" class="layui-input">
</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 " id="view"></div>
<script type="text/html" id="demo">
{{# layui.each(d.data, function(index,item){ }}
<span style="margin-right:55px">
<input type="radio" value={{item.xb_id}} name="sex" title={{item.xb_name}}
lay-verify="required">
</span>
{{# }); }}
</script>
</div>
<div class="layui-form-item">
<label for="name" class="layui-form-label">
<span class="we-red">*</span>手机:
</label>
<div class="layui-input-inline ">
<input type="text" id="telephone" name="telephone" lay-verify="required|contentLength" min="11" max="11"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="" class="layui-form-label">
<span class="we-red">*</span>民族:
</label>
<div class="layui-input-inline " id="select_type"></div>
<script type="text/html" id="select_type_script">
<select name="mz" lay-filter="mz" lay-verify="required">
{{#layui.each(d.data,function(index,item){ }}
<option value={{item.mz_id}}>{{item.mz_name}}</option>
{{# }) }}
</select>
</script>
</div>
<div class="layui-form-item">
<label for="" class="layui-form-label">
<span class="we-red">*</span>政治面貌:
</label>
<div class="layui-input-inline " id="zzmm_type"></div>
<script type="text/html" id="zzmm_type_script">
<select name="zzmm" lay-filter="zzmm" lay-verify="required">
{{#layui.each(d.data,function(index,item){ }}
<option value={{item.zzmm_id}}>{{item.zzmm_name}}</option>
{{# }) }}
</select>
</script>
</div>
<div class="layui-form-item">
<label for="duty_charge" class="layui-form-label">
职务分管:
</label>
<div class="layui-input-inline duty">
<div class="layui-btn layui-btn-normal hide" lay-filter="duty_charge" id="duty_charge"
title="点击选择职务与分管工作">职务与分管工作
</div>
</div>
</div>
<div class="layui-form-item dutys">
<label for="select_6" class="layui-form-label">
已配置职务:
</label>
<div id="select_6" style="padding-top:9px;margin-left: 120px"></div>
<script type="text/html" id="test6">
{{#layui.each(d,function(index,item){ }}
<div style="display:inline-block;margin:0 25px 5px 0">
<i title="删除" class="layui-icon" style="cursor:pointer" onclick="delDuty(this)" id={{item.nodeId}}
pId={{item.pId}}>&#x1007;</i><span>{{item.nodeName}}</span>--<span>{{item.treeNodeName}}</span>
</div>
{{# }) }}
</script>
</div>
<div class="layui-form-item">
<label for="" class="layui-form-label">
</label>
<button class="layui-btn" lay-filter="add" 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', 'laydate'], function () {
var form = layui.form,
$ = layui.jquery,
admin = layui.admin,
layer = layui.layer,
laytpl = layui.laytpl,
laydate = layui.laydate,
dep_id;
$(function () {
dep_id = GetQueryString("dep_id");
bureau_id = GetQueryString('bureau_id');
// 出生日期
laydate.render({
elem: '#test'
});
laydate.render({
elem: '#rjrq'
});
getSex();
getDmMz();
getZzmm();
$.ajax({
type: "GET",
async: false,
url: '/dsBase/base/getPrincipalshipTreeByBureauId?bureau_id=' + bureau_id,
dataType: "json",
success: function (data) {
if (data.code == 0) {
for (var i = 0; i < data.data.length; i++) {
if (data.data[i].parent_id == -1) {
if (data.data[i].is_leaf == 0) {
$("#duty_charge").hide();
var ht = "<p style='padding-top:10px'>暂无职务分管工作</p>";
$(".duty").html(ht);
$(".dutys").hide();
}
}
}
}
}
});
})
// 获取性别
function getSex() {
$.ajax({
type: 'GET',
dataType: 'json',
url: '/dsBase/dm/getDmXb',
success: function (data) {
var getTpl = demo.innerHTML
, view = document.getElementById('view');
laytpl(getTpl).render(data, function (html) {
view.innerHTML = html;
});
$('input:radio[name=sex]')[0].checked = true;
form.render();
}
})
}
// 获取民族
function getDmMz() {
$.ajax({
type: 'GET',
dataType: 'json',
url: ' /dsBase/dm/getDmMz',
success: function (data) {
var getTpl = select_type_script.innerHTML
, select_type = document.getElementById('select_type');
laytpl(getTpl).render(data, function (html) {
select_type.innerHTML = html;
});
form.render();
}
})
}
// 获取政治面貌
function getZzmm() {
$.ajax({
type: 'GET',
dataType: 'json',
url: '/dsBase/dm/getDmZzmm',
success: function (data) {
var getTpl = zzmm_type_script.innerHTML
, zzmm_type = document.getElementById('zzmm_type');
laytpl(getTpl).render(data, function (html) {
zzmm_type.innerHTML = html;
});
form.render();
}
})
}
$("#duty_charge").click(function () {
WeAdminShow('职务与分管工作', './selectIdentity.html?bureau_id=' + bureau_id, 350, window.height);
});
$("#card").blur(function () {
var Card = $("#card").val();
if (Card != null && Card != '') {
if (Card.length == 15) {
var birthdayValue = Card.charAt(6) + Card.charAt(7);//年份
if (parseInt(birthdayValue) < 14) {
birthdayValue = '20' + birthdayValue;//年份
} else {
birthdayValue = '19' + birthdayValue;//年份
}
var birthday = birthdayValue + "-" + Card.substring(8, 10) + "-" + Card.substring(10, 12);
} else {
var birthday = Card.substring(6, 10) + "-" + Card.substring(10, 12) + "-" + Card.substring(12, 14);
}
form.val('editForm', {
birthday: birthday
})
}
});
var jsonData = [];
var saveIdList = [];
// 选择职务分管后处理
window.chooseIds = function (str) {
jsonData = [];
var jsonStr = JSON.parse(str);
for (var i = 0; i < jsonStr.length; i++) {
jsonData.push(jsonStr[i])
}
}
// 前台保存选择的id信息
window.setSaveList = function (ids) {
saveIdList = ids;
}
window.getSaveProductList = function () {
var dataListObj = {};
dataListObj.saveIdList = newArr;
return dataListObj;
};
// var saveDutyList=[];//保存职务分管name列表
var newArr = [];
window.addDuty = function (saveProductList) {
var modelList = [];
newArr = [];
for (var i = 0; i < saveProductList.length; i++) {
for (var j = 0; j < saveProductList.length; j++) {
if (saveProductList[i].id == saveProductList[j].parent_id) {
modelList.push({
nodeName: saveProductList[i].name,
treeNodeName: saveProductList[j].name,
nodeId: saveProductList[j].id,
pId: saveProductList[i].id
})
}
}
if (!saveProductList[i].isParent && saveProductList[i].level == 1 || saveProductList[i].isParent && saveProductList[i].check_Child_State == 0) {
modelList.push({
nodeName: saveProductList[i].name,
treeNodeName: "",
nodeId: -1,
pId: saveProductList[i].id
})
}
newArr.push(saveProductList[i].id)
}
var getTpl = test6.innerHTML
, select_duty = document.getElementById('select_6');
laytpl(getTpl).render(modelList, function (html) {
select_duty.innerHTML = html;
});
form.render();
jsonData = [];
for (var i = 0; i < modelList.length; i++) {
jsonData.push({
duties_id: modelList[i].pId,
in_charge_id: modelList[i].nodeId
})
}
}
window.delDuty = function (tag) {
$(tag).parent()[0].remove();
var id = $(tag).attr("id");
var pId = $(tag).attr("pId");
for (var i = 0; i < jsonData.length; i++) {
if (jsonData[i].in_charge_id == -1) {
if (jsonData[i].duties_id == pId) {
jsonData.splice(i, 1);
}
} else {
if (jsonData[i].in_charge_id == id) {
jsonData.splice(i, 1);
}
}
}
newArr = [];
for (var i = 0; i < jsonData.length; i++) {
newArr.push(jsonData[i].duties_id, jsonData[i].in_charge_id)
}
}
verifyLength();
//监听提交
form.on('submit(add)', function (data) {
var f = data.field;
if (parseInt(f.rjrq) < parseInt(f.birthday)) {
layer.msg("从教日期不能早于出生日期", {icon: 0});
return false;
}
$.ajax({
type: "POST",
async: false,
dataType: "json",
url: "/dsBase/teacher/addTeacher",
data: {
org_id: dep_id,
person_name: f.name,
xb: f.sex,
mz: f.mz,
id_card: "",
birthday: "1990-10-10",
sort_id: "1",
xl_id: "01",
stage_id: "4",
subject_id: "2",
zc_id: "01",
t_teaching_date: "1990-10-10",
t_duty_charge: JSON.stringify(jsonData),
zzmm: f.zzmm,
telephone:f.telephone
},
success: function (data) {
if (data.success) {
//发异步把数据提交给php
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.document.getElementById("click_id").value = dep_id;
parent.layui.table.reload('idTest', {
page: {
curr: 1
}
});
});
} else {
layer.alert(data.message, {icon: 0})
return;
}
}
})
return false;
});
});
</script>
</body>
</html>