diff --git a/app/teacher/controller/Index.php b/app/teacher/controller/Index.php index d4cfb206..a254a1a9 100644 --- a/app/teacher/controller/Index.php +++ b/app/teacher/controller/Index.php @@ -158,6 +158,7 @@ class Index extends AdminBase ,'quanpin' ,'shoupin' ,'shengri' + ,'phone' ,'zhiwu_id' ,'zhicheng_id' ,'xueli_id' @@ -173,7 +174,14 @@ class Index extends AdminBase $result = $validate->scene('create')->check($list); $msg = $validate->getError(); if(!$result){ - return json(['msg' => $msg, 'val' => 0]);; + return json(['msg' => $msg, 'val' => 0]); + } + + $tc = new TC(); + $temp = $tc->phoneSrc($list['phone']); + if($temp) + { + return json(['msg' => '手机号已经存在', 'val' => 0]); } $list['quanpin'] = trim(strtolower(str_replace(' ', '', $list['quanpin']))); @@ -232,7 +240,7 @@ class Index extends AdminBase public function edit($id) { // 获取教师信息 - $list['data'] = TC::field('id, xingming, sex, quanpin, shoupin, shengri, zhiwu_id, zhicheng_id, xueli_id, biye, worktime, zhuanye, danwei_id, tuixiu') + $list['data'] = TC::field('id, xingming, sex, quanpin, shoupin, shengri, phone, zhiwu_id, zhicheng_id, xueli_id, biye, worktime, zhuanye, danwei_id, tuixiu') ->find($id); // 设置页面标题 @@ -260,6 +268,7 @@ class Index extends AdminBase ,'quanpin' ,'shoupin' ,'shengri' + ,'phone' ,'zhiwu_id' ,'zhicheng_id' ,'xueli_id' @@ -278,17 +287,26 @@ class Index extends AdminBase if(!$result){ return json(['msg' => $msg, 'val' => 0]);; } + $tc = new TC(); + $temp = $tc->phoneSrc($list['phone']); + if($temp) + { + return json(['msg' => '手机号已经存在', 'val' => 0]); + } $list['quanpin'] = trim(strtolower(str_replace(' ', '', $list['quanpin']))); $list['shoupin'] = trim(strtolower($list['shoupin'])); + // 更新数据 $teacher = new TC(); $teacherlist = $teacher->find($id); + $teacherlist->xingming = $list['xingming']; $teacherlist->sex = $list['sex']; $teacherlist->quanpin = $list['quanpin']; $teacherlist->shoupin = $list['shoupin']; $teacherlist->shengri = $list['shengri']; + $teacherlist->phone = $list['phone']; $teacherlist->zhiwu_id = $list['zhiwu_id']; $teacherlist->zhicheng_id = $list['zhicheng_id']; $teacherlist->xueli_id = $list['xueli_id']; diff --git a/app/teacher/model/Teacher.php b/app/teacher/model/Teacher.php index 19d39a4e..8c13985b 100644 --- a/app/teacher/model/Teacher.php +++ b/app/teacher/model/Teacher.php @@ -138,17 +138,28 @@ class Teacher extends BaseModel $i = 0; $teacherlist = array(); foreach ($arr as $key => $value) { + $phone = str_replace(' ', '', $value[4]); + $temp = $this->phoneSrc($phone); + if($temp) + { + if($temp->delete_time > 0) + { + $temp->restore(); + } + $teacherlist[$i]['id'] = $temp->id; + } $teacherlist[$i]['xingming'] = $value[1]; $teacherlist[$i]['sex'] = $this->cutStr($value[2]); $teacherlist[$i]['shengri'] = $value[3]; - $teacherlist[$i]['worktime'] = $value[4]; - $teacherlist[$i]['zhiwu_id'] = $this->cutStr($value[5]); - $teacherlist[$i]['zhicheng_id'] = $this->cutStr($value[6]); + $teacherlist[$i]['phone'] = $phone; + $teacherlist[$i]['worktime'] = $value[5]; + $teacherlist[$i]['zhiwu_id'] = $this->cutStr($value[6]); + $teacherlist[$i]['zhicheng_id'] = $this->cutStr($value[7]); $teacherlist[$i]['danwei_id'] = $School_id; - $teacherlist[$i]['biye'] = $value[8]; - $teacherlist[$i]['subject_id'] = $this->cutStr($value[7]); + $teacherlist[$i]['biye'] = $value[9]; + $teacherlist[$i]['subject_id'] = $this->cutStr($value[8]); $teacherlist[$i]['zhuanye'] = $value[9]; - $teacherlist[$i]['xueli_id'] = $this->cutStr($value[10]); + $teacherlist[$i]['xueli_id'] = $this->cutStr($value[11]); $quanpin = $pinyin->sentence($value[1]); $jianpin = $pinyin->abbr($value[1]); $teacherlist[$i]['quanpin'] = trim(strtolower(str_replace(' ', '', $quanpin))); @@ -196,6 +207,18 @@ class Teacher extends BaseModel } + + // 根据手机号查询教师 + public function phoneSrc($phone) + { + $data = self::withTrashed() + ->where('phone', $phone) + ->field('id, delete_time') + ->find(); + return $data; + } + + // 查询教师荣誉 public function srcRongyu($teacher_id) { diff --git a/app/teacher/validate/Teacher.php b/app/teacher/validate/Teacher.php index 7057d985..db438bd7 100644 --- a/app/teacher/validate/Teacher.php +++ b/app/teacher/validate/Teacher.php @@ -20,6 +20,7 @@ class Teacher extends Validate 'sex|性别' => 'require|number|max:2', 'danwei_id|单位' => 'require|number', 'shengri|出生日期' => 'date', + 'phone|手机号' => 'require|mobile', 'zhiwu_id|职务' => 'number', 'zhicheng_id|职称' => 'number', 'xueli_id|学历' => 'number', @@ -45,6 +46,7 @@ class Teacher extends Validate ,'sex' ,'danwei_id' ,'shengri' + ,'phone' ,'zhiwu_id' ,'zhicheng_id' ,'xueli_id' @@ -61,6 +63,7 @@ class Teacher extends Validate ,'sex' ,'danwei_id' ,'shengri' + ,'phone' ,'zhiwu_id' ,'zhicheng_id' ,'xueli_id' diff --git a/app/teacher/view/index/create.html b/app/teacher/view/index/create.html index 47018e56..cdc64e62 100644 --- a/app/teacher/view/index/create.html +++ b/app/teacher/view/index/create.html @@ -56,6 +56,15 @@ +