作者 anyv
1 个管道 的构建 通过 耗费 1 秒

学校管理模块

... ... @@ -32,7 +32,35 @@ class SchoolController extends WeChatBaseController{
*/
public function add_school(){
return $this -> fetch();
if($this -> request -> isPost()){
$class = explode(',',$_POST['str']);
foreach ($class as $key => $val){
if($val != '' && $val != 'undefined'){
$class_data[] = $val;
}
}
$school['uid'] = cmf_get_current_user_id();
$school['create_time'] = time();
$school['region'] = $_POST['region'];
$school['school'] = $_POST['school'];
$school['type'] = $_POST['type'];
$school_id = Db::name('school') -> insertGetId($school);
foreach ($class_data as $key => $val){
$grade_class = explode('-',$val);
$grade['school_id'] = $school_id;
$grade['grade'] = $grade_class[0];
$grade['class'] = $grade_class[1].'-'.$grade_class[2];
Db::name('grade_class') -> insert($grade);
}
if($school_id){
return true;
}else{
return false;
}
}else{
return $this -> fetch();
}
}
... ... @@ -41,7 +69,34 @@ class SchoolController extends WeChatBaseController{
*/
public function school_edit(){
return $this -> fetch();
if($this -> request -> isPost()){
$school['id'] = $_POST['id'];
$school['school'] = $_POST['school'];
$school['type'] = $_POST['type'];
$school['region'] = $_POST['region'];
$updae = Db::name('school') -> update($school);
Db::name('grade_class') -> where('school_id',$_POST['id']) -> delete();
$class = explode(',',$_POST['str']);
foreach ($class as $key => $val){
if($val != '' && $val != 'undefined'){
$class_data[] = $val;
}
}
foreach ($class_data as $key => $val){
$grade_class = explode('-',$val);
$grade['school_id'] = $_POST['id'];
$grade['grade'] = $grade_class[0];
$grade['class'] = $grade_class[1].'-'.$grade_class[2];
Db::name('grade_class') -> insert($grade);
}
return true;
}else{
$id = $this -> request -> param();
$data = Db::name('school') -> where('id',$id['id']) -> find();
$data_class = Db::name('grade_class') -> where('school_id',$id['id']) -> select();
$this -> assign('data',$data);
return $this -> fetch();
}
}
... ... @@ -50,7 +105,13 @@ class SchoolController extends WeChatBaseController{
*/
public function school_del(){
return $this -> fetch();
$data = Db::name('school') -> delete($_POST['id']);
Db::name('grade_class') -> where('school_id',$_POST['id']) -> delete();
if($data){
return true;
}else{
return false;
}
}
... ...
... ... @@ -10,7 +10,7 @@
// [ 入口文件 ]
// 调试模式开关
define("APP_DEBUG",false);
define("APP_DEBUG",true);
// 定义CMF根目录,可更改此目录
define('CMF_ROOT', __DIR__ . '/../');
... ...
... ... @@ -47,7 +47,7 @@
地区
</div>
<div class="log_four_input_one_center">
<input type="text" placeholder="请选择" id="city_text" />
<input type="text" placeholder="请选择" id="city_text" value="" />
</div>
<div class="log_four_input_one_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
... ... @@ -58,7 +58,7 @@
学校
</div>
<div class="log_four_input_one_center">
<input type="text" placeholder="请录入" />
<input type="text" placeholder="请录入" id="school" />
</div>
<div class="log_four_input_one_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
... ... @@ -69,7 +69,7 @@
类型
</div>
<div class="log_four_input_one_center">
<input type="text" id="four_inp" placeholder="小学" />
<input type="text" id="four_inp" placeholder="小学" value="小学" />
</div>
<div class="log_four_input_one_right log_four_input_select_type">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
... ... @@ -512,7 +512,7 @@
</div>
<!-- 按钮 -->
<div class="log_seven_btn">
<div class="log_seven_btn_contant">
<div class="log_seven_btn_contant" onclick="my_present()">
确定
</div>
</div>
... ... @@ -522,6 +522,41 @@
<script src="__TMPL__/public/assets/js/mui.picker.min.js"></script>
<script src="__TMPL__/public/assets/js/city.data-3.js"></script>
<script>
/**
*点击确定提交
*/
function my_present(){
school = $('#school').val();
type = $('#four_inp').val();
region = $('#city_text').val();
str = '';
for(var i=0;i<arr.length;i++){
str += arr[i]+',';
}
console.log(str);
if(school == ''){
alert('请选择学校');
}else if(type == ''){
alert('请选择类型');
}else if(str == ''){
alert('请添加班级');
}else{
$.post("{:url('School/add_school')}",{school:school,type:type,region:region,str:str},function(data){
if(data){
window.location.href="{:url('School/school')}";
}else{
alert('添加失败!');
}
});
}
}
</script>
<script>
let arr = []
let nianj = '';
let enternum = '';
let fir = '';
let sec = ''
$(".log_four_input_select_type").click(function() {
var block = $(".log_four_radio").css("display");
if(block == "none") {
... ... @@ -549,7 +584,7 @@
console.log(index);
var text1 = $(this).find(".log_four_contant_right").text();
console.log(text1)
$("#four_inp").attr("placeholder", text1);
$("#four_inp").attr("placeholder", text1).attr("value",text1);
xcg = $(this).find('.log_four_contant_right').text();
console.log(xcg)
$(".log_four_contant_one img").eq(index).attr("src", "__TMPL__/public/assets/images/73.png").parents(".log_four_contant_one").siblings().find("img").attr("src", "__TMPL__/public/assets/images/39_0.png");
... ... @@ -557,6 +592,7 @@
$(".log_four_radios").eq(index).css({
display: "block"
});
arr = [];
$(".log_four_radios").find('input').val('');
$(".log_four_radio").css({
display: "none"
... ... @@ -565,26 +601,6 @@
}
});
});
let arr = []
let nianj = '';
let enternum = '';
let fir = '';
let sec = ''
$('.log_four_radios').each(function() {
var index = $(this).index();
console.log(index);
$(this).find('.log_botms').click(function() {
if($(this).find('.log_Img9').attr("src") == '__TMPL__/public/assets/images/39_0.png') {
$(this).find('.log_Img9').attr("src", "__TMPL__/public/assets/images/73.png");
$(this).next('.log_four_contants_input_block').slideDown();
console.log($(this).find(".log_four_contants_right").text())
} else {
$(this).find('.log_Img9').attr("src", '__TMPL__/public/assets/images/39_0.png');
$(this).next('.log_four_contants_input_block').slideUp();
}
});
})
//添加地址
var city_picker = new mui.PopPicker({
... ... @@ -596,23 +612,61 @@
city_picker.show(function(items) {
$("#city_text").text((items[0] || {}).text + "," + (items[1] || {}).text + "," + (items[2] || {}).text); //该ID为接收城市ID字段
$('#city_text').css('color', '#333');
$("#city_text").attr("placeholder", ((items[0] || {}).text + ' ' + (items[1] || {}).text + ' ' + (items[2] || {}).text))
$("#city_text").attr("placeholder", ((items[0] || {}).text + ' ' + (items[1] || {}).text + ' ' + (items[2] || {}).text)).attr("value", ((items[0] || {}).text + ' ' + (items[1] || {}).text + ' ' + (items[2] || {}).text))
});
}, 200);
});
//輸入年级
$('.log_four_contants_input_block').on('change', 'input', function(e) {
var index = $(this).data('index');
var inputs = $(this).parents('.log_four_contants_input_block').find('input');
// var img = $(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img");
var tempData = '';
var classes = index == 0 ? '一年级' : index == 1 ? '二年级' : index == 2 ? '三年级' : index == 3 ? '四年级' : index == 4 ? '五年级' : index == 5 ? '六年级' : index == 6 ? '初一' : index == 7 ? '初二' : index == 8 ? '初三' : index == 9 ? '高一' : index == 10 ? '高二' : index == 11 ? '高三' : '';
if(inputs[0].value && inputs[1].value) {
tempData = classes + '-' + inputs[0].value + '-' + inputs[1].value
if($(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img").attr("src") == "__TMPL__/public/assets/images/73.png") {
if(inputs[0].value && inputs[1].value) {
tempData = classes + '-' + inputs[0].value + '-' + inputs[1].value
}
arr[index] = tempData;
console.log(arr)
} else {
tempData = ""
}
arr[index] = tempData;
console.log(arr)
})
$('.log_four_radios').on('click','.log_botms',function() {
var root = $(this).parents('.log_four_radios').index();
var index = $(this).parent().index();
console.log(index)
index = root == 0?index:root==1?index + 6:index+9
console.log(index)
if($(this).find('.log_Img9').attr("src") == '__TMPL__/public/assets/images/39_0.png') {
$(this).find('.log_Img9').attr("src", "__TMPL__/public/assets/images/73.png");
$(this).next('.log_four_contants_input_block').slideDown();
var inputs = $(this).siblings('.log_four_contants_input_block').find('input');
// var img = $(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img");
var tempData = '';
var classes = index == 0 ? '一年级' : index == 1 ? '二年级' : index == 2 ? '三年级' : index == 3 ? '四年级' : index == 4 ? '五年级' : index == 5 ? '六年级' : index == 6 ? '初一' : index == 7 ? '初二' : index == 8 ? '初三' : index == 9 ? '高一' : index == 10 ? '高二' : index == 11 ? '高三' : '';
if($(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img").attr("src") == "__TMPL__/public/assets/images/73.png") {
if(inputs[0].value && inputs[1].value) {
tempData = classes + '-' + inputs[0].value + '-' + inputs[1].value
}
arr[index] = tempData;
} else{
arr[index] = ''
}
} else {
$(this).find('.log_Img9').attr("src", '__TMPL__/public/assets/images/39_0.png');
$(this).next('.log_four_contants_input_block').slideUp();
arr[index] = ''
}
console.log(arr)
});
</script>
</body>
... ...
... ... @@ -25,7 +25,7 @@
<!-- 学校列表 -->
<div class="log_seven">
<volist name="school" id="val">
<div class="log_seven_list log_seven_list_one">
<div class="log_seven_list log_seven_list_one shanchu{$val.id}">
<div class="log_seven_left">
<div class="log_seven_left_one">{$val.school}</div>
<div class="log_seven_left_two">
... ... @@ -37,9 +37,9 @@
</div>
<div class="log_seven_right">
<div class="log_seven_right_one">
<img src="__TMPL__/public/assets/images/87.png" alt="" onclick="school_edit({$vo.id})" />
<img src="__TMPL__/public/assets/images/87.png" alt="" onclick="school_edit({$val.id})" />
</div>
<div class="log_seven_right_one log_seven_right_two" onclick="school_del({$vo.id})">
<div class="log_seven_right_one log_seven_right_two" onclick="school_del({$val.id})">
<img src="__TMPL__/public/assets/images/86.png" alt="" />
</div>
</div>
... ... @@ -64,8 +64,19 @@
/**
*点击删除学校
*/
function school_del(){
alert('11111');
function school_del(id){
$.post("{:url('School/school_del')}",{id:id},function(data){
if(data){
$('.shanchu'+id).remove();
}
});
}
/**
*点击编辑学习
*/
function school_edit(id){
window.location.href = "{:url('School/school_edit')}?id="+id;
}
</script>
<script>
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>学考无忧-添加学校</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.picker.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/log.css" />
<style>
.mui-poppicker-header,
.mui-picker {
background-color: white;
}
.mui-btn-blue,
.mui-btn-primary,
input[type=submit] {
background-color: #FF7700;
border: 0;
}
.mui-pciker-list li.highlight {
color: #FF7700;
}
</style>
</head>
<body>
<div class="log_top_co">
<!-- 顶部 -->
<div class=" order_top log_top_co">
<a href="javascript:history.back(-1)">
<img src="__TMPL__/public/assets/images/left.png" alt="" />
</a>
<p>添加学校</p>
</div>
</div>
<div class="school_ooo">
<!-- 地址信息 -->
<div class="log_four_input">
<div class="log_four_input_one">
<div class="log_four_input_one_left">
地区
</div>
<div class="log_four_input_one_center">
<input type="text" placeholder="{$data.region}" id="city_text" value="{$data.region}" />
<input type="hidden" name="id" id="idee" value="{$data.id}">
</div>
<div class="log_four_input_one_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
<div class="log_four_input_one">
<div class="log_four_input_one_left">
学校
</div>
<div class="log_four_input_one_center">
<input type="text" placeholder="{$data.school}" id="school" value="{$data.school}" />
</div>
<div class="log_four_input_one_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
<div class="log_four_input_one log_four_input_select_type">
<div class="log_four_input_one_left">
类型
</div>
<div class="log_four_input_one_center">
<input type="text" id="four_inp" placeholder="{$data.type}" value="{$data.type}" />
</div>
<div class="log_four_input_one_right log_four_input_select_type">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</div>
<!-- 选择框 -->
<div class="school">
<div class="log_four_radio">
<div class="log_four_contant">
<div class="log_four_contant_one">
<div class="log_four_contant_left">
<if condition="$data.type eq '小学'">
<img src="__TMPL__/public/assets/images/73.png" alt="" />
<else/>
<img src="__TMPL__/public/assets/images/39_0.png" alt="" />
</if>
</div>
<div class="log_four_contant_right">小学</div>
</div>
<div class="log_four_contant_one">
<div class="log_four_contant_left">
<if condition="$data.type eq '初中'">
<img src="__TMPL__/public/assets/images/73.png" alt="" />
<else/>
<img src="__TMPL__/public/assets/images/39_0.png" alt="" />
</if>
</div>
<div class="log_four_contant_right">初中</div>
</div>
<div class="log_four_contant_one">
<div class="log_four_contant_left">
<if condition="$data.type eq '高中'">
<img src="__TMPL__/public/assets/images/73.png" alt="" />
<else/>
<img src="__TMPL__/public/assets/images/39_0.png" alt="" />
</if>
</div>
<div class="log_four_contant_right">高中</div>
</div>
</div>
</div>
<div class="log_eight_school_class">
<div class="log_four_radios">
<div class="log_four_contants">
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/73.png" alt="" />
</div>
<div class="log_four_contants_right">一年级</div>
</div>
<div class="log_four_contants_input_block" style="display: block">
<div class="log_four_contants_input">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei">
<input type="text" data-index='0' placeholder="选择班级" name="" id="" value="" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='0' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
二年级
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input data-index='1' type="text" placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='1' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
三年级
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input data-index='2' type="text" placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='2' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
四年级
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input data-index='3' type="text" placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='3' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
五年级
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" data-index='4' placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='4' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
六年级
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" data-index='5' placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='5' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="log_four_radios" style="display: none">
<div class="log_four_contants">
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/73.png" alt="" />
</div>
<div class="log_four_contants_right">初一</div>
</div>
<div class="log_four_contants_input_block" style="display: block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" data-index='6' placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='6' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
初二
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" data-index='7' placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" data-index='7' placeholder=" 选择班级" />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
初三
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" data-index='8' placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" placeholder=" 选择班级" data-index='8' />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="log_four_radios" style="display: none">
<div class="log_four_contants">
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/73.png" alt="" />
</div>
<div class="log_four_contants_right">高一</div>
</div>
<div class="log_four_contants_input_block" style="display: block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" data-index='9' placeholder="选择班级" name="" id="" value="" /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" placeholder=" 选择班级" data-index='9' />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
高二
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" placeholder="选择班级" name="" id="" value="" data-index='10' /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" placeholder=" 选择班级" data-index='10' />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class=" log_four_contant_ones">
<div class="log_botms">
<div class="log_four_contants_left">
<img class="log_Img9" src="__TMPL__/public/assets/images/39_0.png" alt="" />
</div>
<div class="log_four_contants_right">
高三
</div>
</div>
<div class="log_four_contants_input_block">
<div class="log_four_contants_input ">
<div class="log_four_ooo">
<div class="log_four_xian_ban">
<div class="log_four_xian_nei"><input type="text" placeholder="选择班级" name="" id="" value="" data-index='11' /></div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
<div class="log_four_xian_wife">——</div>
<div class="log_four_ooo">
<div class="log_four_xian_ban2">
<div class="log_four_xian_nei">
<input type="text" placeholder=" 选择班级" data-index='11' />
</div>
<div class="log_four_xian_icon">
<img src="__TMPL__/public/assets/images/down.png" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 按钮 -->
<div class="log_seven_btn">
<div class="log_seven_btn_contant" onclick="my_present()">
确定
</div>
</div>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/mui.min.js"></script>
<script src="__TMPL__/public/assets/js/mui.picker.min.js"></script>
<script src="__TMPL__/public/assets/js/city.data-3.js"></script>
<script>
/**
*点击确定提交
*/
function my_present(){
school = $('#school').val();
type = $('#four_inp').val();
region = $('#city_text').val();
str = '';
for(var i=0;i<arr.length;i++){
str += arr[i]+',';
}
id = $('#idee').val();
if(school == ''){
alert('请选择学校');
}else if(type == ''){
alert('请选择类型');
}else if(str == ''){
alert('请添加班级');
}else{
$.post("{:url('School/school_edit')}",{id:id,school:school,type:type,region:region,str:str},function(data){
if(data){
window.location.href="{:url('School/school')}";
}else{
alert('更新失败!');
}
});
}
}
</script>
<script>
let arr = []
let nianj = '';
let enternum = '';
let fir = '';
let sec = ''
$(".log_four_input_select_type").click(function() {
var block = $(".log_four_radio").css("display");
if(block == "none") {
$(".log_four_input_select_type")
.find("img")
.attr("src", "__TMPL__/public/assets/images/75.png");
$(".log_four_radio").css({
display: "block"
});
$(".log_four_radios").css({
display: "none"
});
} else {
$(".log_four_input_select_type")
.find("img")
.attr("src", "__TMPL__/public/assets/images/29.png");
$(".log_four_radio").css({
display: "none"
});
}
});
$(".log_four_contant_one").each(function() {
$(this).click(function() {
var index = $(this).index();
console.log(index);
var text1 = $(this).find(".log_four_contant_right").text();
console.log(text1)
$("#four_inp").attr("placeholder", text1).attr("value",text1);
xcg = $(this).find('.log_four_contant_right').text();
console.log(xcg)
$(".log_four_contant_one img").eq(index).attr("src", "__TMPL__/public/assets/images/73.png").parents(".log_four_contant_one").siblings().find("img").attr("src", "__TMPL__/public/assets/images/39_0.png");
if($(".log_four_contant_one img").eq(index).attr("src") == "__TMPL__/public/assets/images/73.png") {
$(".log_four_radios").eq(index).css({
display: "block"
});
arr = [];
$(".log_four_radios").find('input').val('');
$(".log_four_radio").css({
display: "none"
});
}
});
});
//添加地址
var city_picker = new mui.PopPicker({
layer: 3
});
city_picker.setData(cityData3);
$("#city_text").on("tap", function() {
setTimeout(function() {
city_picker.show(function(items) {
$("#city_text").text((items[0] || {}).text + "," + (items[1] || {}).text + "," + (items[2] || {}).text); //该ID为接收城市ID字段
$('#city_text').css('color', '#333');
$("#city_text").attr("placeholder", ((items[0] || {}).text + ' ' + (items[1] || {}).text + ' ' + (items[2] || {}).text)).attr("value", ((items[0] || {}).text + ' ' + (items[1] || {}).text + ' ' + (items[2] || {}).text))
});
}, 200);
});
//輸入年级
$('.log_four_contants_input_block').on('change', 'input', function(e) {
var index = $(this).data('index');
var inputs = $(this).parents('.log_four_contants_input_block').find('input');
// var img = $(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img");
var tempData = '';
var classes = index == 0 ? '一年级' : index == 1 ? '二年级' : index == 2 ? '三年级' : index == 3 ? '四年级' : index == 4 ? '五年级' : index == 5 ? '六年级' : index == 6 ? '初一' : index == 7 ? '初二' : index == 8 ? '初三' : index == 9 ? '高一' : index == 10 ? '高二' : index == 11 ? '高三' : '';
if($(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img").attr("src") == "__TMPL__/public/assets/images/73.png") {
if(inputs[0].value && inputs[1].value) {
tempData = classes + '-' + inputs[0].value + '-' + inputs[1].value
}
arr[index] = tempData;
console.log(arr)
} else {
tempData = ""
}
})
$('.log_four_radios').on('click','.log_botms',function() {
var root = $(this).parents('.log_four_radios').index();
var index = $(this).parent().index();
console.log(index)
index = root == 0?index:root==1?index + 6:index+9
console.log(index)
if($(this).find('.log_Img9').attr("src") == '__TMPL__/public/assets/images/39_0.png') {
$(this).find('.log_Img9').attr("src", "__TMPL__/public/assets/images/73.png");
$(this).next('.log_four_contants_input_block').slideDown();
var inputs = $(this).siblings('.log_four_contants_input_block').find('input');
// var img = $(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img");
var tempData = '';
var classes = index == 0 ? '一年级' : index == 1 ? '二年级' : index == 2 ? '三年级' : index == 3 ? '四年级' : index == 4 ? '五年级' : index == 5 ? '六年级' : index == 6 ? '初一' : index == 7 ? '初二' : index == 8 ? '初三' : index == 9 ? '高一' : index == 10 ? '高二' : index == 11 ? '高三' : '';
if($(this).parents(".log_four_contant_ones").find(".log_four_contants_left").find("img").attr("src") == "__TMPL__/public/assets/images/73.png") {
if(inputs[0].value && inputs[1].value) {
tempData = classes + '-' + inputs[0].value + '-' + inputs[1].value
}
arr[index] = tempData;
} else{
arr[index] = ''
}
} else {
$(this).find('.log_Img9').attr("src", '__TMPL__/public/assets/images/39_0.png');
$(this).next('.log_four_contants_input_block').slideUp();
arr[index] = ''
}
console.log(arr)
});
</script>
</body>
</html>
\ No newline at end of file
... ...