优化问题
This commit is contained in:
parent
92b948fe4e
commit
c8fb9aef09
@ -100,7 +100,7 @@ class TeacherScheduleTimeController extends BaseController
|
||||
'filed_id_width' => 60,//序号列的宽度
|
||||
'filed_name_width' => 120,//玩家名称的宽度
|
||||
'filed_data_width' => 120,//数据列的宽度
|
||||
'table_header' => ['', '星期', '日期', '上课时间', '学科', '教师', '学生','课时'],//表头文字
|
||||
'table_header' => ['', 'Week', 'Date', 'Time', 'Subject', 'Teacher', 'Student','Duration'],//表头文字
|
||||
'column_text_offset_arr' => [45, 70, 70, 90, 55, 65, 65, 65],//表头文字左偏移量
|
||||
'row_text_offset_arr' => [50, 110, 90, 110, 90, 90, 90, 90],//数据列文字左偏移量
|
||||
];
|
||||
|
@ -32,5 +32,14 @@ class SubjectHomework extends BaseModel
|
||||
{
|
||||
return $this->hasMany(StudentHomework::class, 'subject_homework_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 安排学生
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function studentHomeworkOne()
|
||||
{
|
||||
return $this->hasOne(StudentHomework::class, 'subject_homework_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,17 @@ class TeacherScheduleTime extends BaseModel
|
||||
return $this->hasMany(StudentSchedule::class, 'teacher_schedule_time_id', 'id');
|
||||
}
|
||||
|
||||
public function studentScheduleOne1()
|
||||
{
|
||||
return $this->hasOne(StudentSchedule::class, 'teacher_schedule_time_id', 'id');
|
||||
}
|
||||
public function studentScheduleOne()
|
||||
{
|
||||
return $this->hasOne(StudentSchedule::class, 'teacher_schedule_time_id', 'id')->bind([
|
||||
'student_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public function studentHomework()
|
||||
{
|
||||
return $this->hasMany(StudentHomework::class, 'teacher_schedule_time_id', 'id');
|
||||
|
@ -47,6 +47,7 @@ class StudentScheduleController extends Crud
|
||||
$subject = Subject::order('sort desc,id asc')->field('id,subject_name,english_name')->select()->toArray();
|
||||
$student = Student::order('id asc')->field('id,student_name,account')->select()->toArray();
|
||||
|
||||
|
||||
return view('student-schedule/index', ['teacher' => $teacher, 'subject' => $subject, 'student' => $student]);
|
||||
}
|
||||
|
||||
@ -198,6 +199,8 @@ class StudentScheduleController extends Crud
|
||||
if (!$conflict->isEmpty()) {
|
||||
throw new Exception("该学生课程和【{$conflict->teacher_name}】的【{$conflict->subject_name} {$conflict->date} {$conflict->time} 】有冲突");
|
||||
}
|
||||
//删除其它学生的课程
|
||||
$student_schedule = StudentSchedule::where(['teacher_schedule_time_id' => $teacher_schedule_time->id])->delete();
|
||||
|
||||
$student = Student::where(['id'=>$data['student_id']])->findOrEmpty();
|
||||
$res = \app\common\model\StudentSchedule::create([
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use app\common\model\Student;
|
||||
use app\common\model\Subject;
|
||||
use app\common\model\Teacher;
|
||||
use app\common\service\SendMsgCronJobService;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
@ -37,23 +40,50 @@ class SubjectHomeworkController extends Crud
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
return view('subject-homework/index');
|
||||
$teacher = Teacher::order('id desc')->field('id,teacher_name')->select()->toArray();
|
||||
$subject = Subject::order('id desc')->field('id,subject_name, english_name')->select()->toArray();
|
||||
$student = Student::order('id desc')->field('id,student_name')->select()->toArray();
|
||||
|
||||
return view('subject-homework/index', compact('teacher', 'subject', 'student'));
|
||||
}
|
||||
|
||||
public function select(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$homework = \app\common\model\SubjectHomework::order('id desc');
|
||||
if (1) {
|
||||
|
||||
$homework = \app\common\model\SubjectHomework::order('wa_subject_homework.id desc')
|
||||
->alias('sh')
|
||||
->leftJoin('student_homework sth', 'sth.subject_homework_id = sh.id')
|
||||
->leftJoin('student s', 's.id = sth.student_id')
|
||||
->field('sh.*,s.student_name');
|
||||
$data = $request->get();
|
||||
if (isset($data['teacher_id']) && $data['teacher_id']) {
|
||||
$homework->where('sh.teacher_id', $data['teacher_id']);
|
||||
}
|
||||
if (isset($data['date']) && $data['date']) {
|
||||
$homework->where('sh.date', $data['date']);
|
||||
}
|
||||
if (isset($data['month']) && $data['month']) {
|
||||
$homework->where('sh.month', $data['month']);
|
||||
}
|
||||
if (isset($data['subject_id']) && $data['subject_id']) {
|
||||
$homework->where('sh.subject_id', $data['subject_id']);
|
||||
}
|
||||
if (isset($data['is_publish']) && $data['is_publish'] !== '') {
|
||||
$homework->where('sh.is_publish', $data['is_publish']);
|
||||
}
|
||||
if (isset($data['student_id']) && $data['student_id']) {
|
||||
$homework->where(['sth.student_id'=> $data['student_id']]);
|
||||
}
|
||||
|
||||
$limit = (int)$request->get('limit', 10);
|
||||
$limit = $limit <= 0 ? 10 : $limit;
|
||||
$page = (int)$request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
$total = $homework->count();
|
||||
$list = $homework->page($page, $limit)->with(['teacher', 'subject'])->select();
|
||||
$list = $homework
|
||||
->page($page, $limit)->with(['teacher', 'subject'])->select();
|
||||
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
|
@ -18,6 +18,7 @@ use support\Response;
|
||||
use plugin\admin\app\model\TeacherScheduleTime;
|
||||
use plugin\admin\app\controller\Crud;
|
||||
use support\exception\BusinessException;
|
||||
use think\db\Query;
|
||||
use think\Exception;
|
||||
use DateTime;
|
||||
use think\facade\Db;
|
||||
@ -52,14 +53,16 @@ class TeacherScheduleTimeController extends Crud
|
||||
$teacher = Teacher::order('id asc')->field('id,teacher_name,account')->select()->toArray();
|
||||
//所有课程
|
||||
$subject = Subject::order('sort desc,id asc')->field('id,subject_name,english_name')->select()->toArray();
|
||||
return view('teacher-schedule-time/index', ['teacher' => $teacher, 'subject' => $subject]);
|
||||
$student = Student::order('id asc')->field('id,student_name,account')->select()->toArray();
|
||||
|
||||
return view('teacher-schedule-time/index', ['teacher' => $teacher, 'subject' => $subject, 'student' => $student]);
|
||||
}
|
||||
|
||||
public function select(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
$teacherSchedule = \app\common\model\TeacherScheduleTime::order('id desc');
|
||||
$teacherSchedule = \app\common\model\TeacherScheduleTime::order('wa_teacher_schedule_time.id desc');
|
||||
if (isset($data['teacher_id']) && $data['teacher_id']) {
|
||||
$teacherSchedule->where(['teacher_id' => $data['teacher_id']]);
|
||||
}
|
||||
@ -75,13 +78,22 @@ class TeacherScheduleTimeController extends Crud
|
||||
if (isset($data['is_publish']) && $data['is_publish'] !== '') {
|
||||
$teacherSchedule->where(['is_publish' => $data['is_publish']]);
|
||||
}
|
||||
if (isset($data['student_id']) && $data['student_id']) {
|
||||
//查找该学生的排课id
|
||||
$teacherSchedule->hasWhere('studentScheduleOne1', function (Query $query) use ($data) {
|
||||
$query->where(['student_id' => $data['student_id']])->whereNull('deleted_at');
|
||||
});
|
||||
}
|
||||
$limit = (int)$request->get('limit', 10);
|
||||
$limit = $limit <= 0 ? 10 : $limit;
|
||||
$page = (int)$request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
$total = $teacherSchedule->count();
|
||||
$list = $teacherSchedule->with(['subject', 'teacher'])->page($page, $limit)->select();
|
||||
$list = $teacherSchedule->with(['subject', 'teacher', 'studentScheduleOne'])->page($page, $limit)->select();
|
||||
// print '<pre>';
|
||||
// print_r($list);
|
||||
// die;
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
@ -318,7 +330,7 @@ class TeacherScheduleTimeController extends Crud
|
||||
if (isset($data['is_publish'])) {
|
||||
$teacher_schedule_time->is_publish = $data['is_publish'];
|
||||
|
||||
if($data['is_publish']){
|
||||
if ($data['is_publish']) {
|
||||
(new SendMsgCronJobService())->teacherScheduleTimePublishMsgToTeacher($teacher_schedule_time->id);
|
||||
}
|
||||
}
|
||||
@ -452,18 +464,18 @@ class TeacherScheduleTimeController extends Crud
|
||||
$worksheet->setCellValue('H1', 'Note');
|
||||
$worksheet->getStyle('A1:H1')->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setRGB('4f81bd');
|
||||
->getStartColor()->setRGB('4f81bd');
|
||||
|
||||
|
||||
$month_days = get_dates_in_month(date('Y', strtotime($month)), date('m', strtotime($month)));
|
||||
|
||||
// $column = Coordinate::columnIndexFromString(2);
|
||||
|
||||
$offset_row =2;
|
||||
$offset_row = 2;
|
||||
foreach ($month_days as $index => $date) {
|
||||
$week = date('l', strtotime($date));
|
||||
|
||||
if($week == 'Sunday' && $index != 0){
|
||||
if ($week == 'Sunday' && $index != 0) {
|
||||
//合并单元格
|
||||
$merge_offset = $index + $offset_row;
|
||||
$worksheet->mergeCells("A{$merge_offset}:H{$merge_offset}");
|
||||
@ -475,7 +487,7 @@ class TeacherScheduleTimeController extends Crud
|
||||
$en_time = '';
|
||||
$subject_name = '';
|
||||
$teacher_name = '';
|
||||
$hour= '';
|
||||
$hour = '';
|
||||
if (isset($export_data[$date])) {
|
||||
$merge_count = count($export_data[$date]);
|
||||
foreach ($export_data[$date] as $schedule) {
|
||||
@ -512,7 +524,7 @@ class TeacherScheduleTimeController extends Crud
|
||||
$file_name = $month . '-' . time() . '.xlsx';
|
||||
$file_path = '/export_file/';
|
||||
$save_path = public_path($file_path);
|
||||
if(!is_dir($save_path)){
|
||||
if (!is_dir($save_path)) {
|
||||
mkdir($save_path, 0777, true);
|
||||
}
|
||||
$writer->save($save_path . $file_name);
|
||||
|
@ -16,7 +16,13 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">教师</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="teacher_id" value="" class="layui-input">
|
||||
<select lay-search="" name="teacher_id">
|
||||
<option value="">请选择或搜索教师</option>
|
||||
{foreach $teacher as $item}
|
||||
<option value="{$item['id']}">{$item['id']} - {$item['teacher_name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<!-- <input type="text" name="teacher_id" value="" class="layui-input">-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -27,19 +33,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">开始时间</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="start_time" id="start_time" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label">开始时间</label>-->
|
||||
<!-- <div class="layui-input-block">-->
|
||||
<!-- <input type="text" name="start_time" id="start_time" autocomplete="off" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">结束时间</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="end_time" id="end_time" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label">结束时间</label>-->
|
||||
<!-- <div class="layui-input-block">-->
|
||||
<!-- <input type="text" name="end_time" id="end_time" autocomplete="off" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">月份</label>
|
||||
@ -51,31 +57,28 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">课程id</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="subject_id" value="" class="layui-input">
|
||||
<select lay-search="" name="subject_id">
|
||||
<option value="">请选择或搜索课程</option>
|
||||
{foreach $subject as $item}
|
||||
<option value="{$item['id']}">{$item['subject_name']} / {$item['english_name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<!-- <input type="text" name="subject_id" value="" class="layui-input">-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">家庭作业文件名称</label>
|
||||
<label class="layui-form-label">学生</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" autocomplete="off" name="homework_file_name[]" value="like"
|
||||
class="layui-input inline-block">
|
||||
<input type="text" autocomplete="off" name="homework_file_name[]" class="layui-input">
|
||||
</div>
|
||||
<select lay-search="" name="student_id">
|
||||
<option value="">请选择或搜索学生</option>
|
||||
{foreach $student as $item}
|
||||
<option value="{$item['id']}">{$item['id']} - {$item['student_name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新版本家庭作业文件名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" autocomplete="off" name="homework_version_file_name[]" value="like"
|
||||
class="layui-input inline-block">
|
||||
<input type="text" autocomplete="off" name="homework_version_file_name[]" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否发布</label>
|
||||
@ -171,7 +174,7 @@
|
||||
layui.use(["laydate"], function () {
|
||||
layui.laydate.render({
|
||||
elem: "#month",
|
||||
|
||||
type: 'month'
|
||||
});
|
||||
})
|
||||
|
||||
@ -240,6 +243,9 @@
|
||||
}, {
|
||||
title: "月份", align: "center",
|
||||
field: "month",
|
||||
}, {
|
||||
title: "学生", align: "center",
|
||||
field: "student_name",
|
||||
}, {
|
||||
title: "课程id", align: "center",
|
||||
field: "subject_id",
|
||||
|
@ -66,6 +66,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">学生</label>
|
||||
<div class="layui-input-block">
|
||||
<select lay-search="" name="student_id">
|
||||
<option value="">请选择或搜索学生</option>
|
||||
{foreach $student as $item}
|
||||
<option value="{$item['id']}">{$item['id']} - {$item['student_name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<!-- <input type="number" name="subject_id" value="" class="layui-input">-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否发布</label>
|
||||
<div class="layui-input-block">
|
||||
@ -209,6 +222,9 @@
|
||||
}, {
|
||||
title: "课程", align: "center",
|
||||
field: "subject_name",
|
||||
}, {
|
||||
title: "学生", align: "center",
|
||||
field: "student_name",
|
||||
}, {
|
||||
title: "是否发布", align: "center",
|
||||
field: "is_publish",
|
||||
|
@ -85,11 +85,16 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">学生</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
<select lay-search="" lay-filter="check_student">
|
||||
<option value="">请选择或搜索学生</option>
|
||||
{foreach $student as $item}
|
||||
<input type="checkbox" name="student_id[]" title="{$item['student_name']}" lay-skin="tag"
|
||||
lay-filter="check_student" {if in_array($item['id'], $student_schedule_id)} checked {/if}
|
||||
value="{$item['id']}">
|
||||
<option value="{$item['id']}" {if in_array($item['id'], $student_schedule_id)} selected {/if} >{$item['id']} - {$item['student_name']}</option>
|
||||
<!-- <input type="checkbox" name="student_id[]" title="{$item['student_name']}" lay-skin="tag"-->
|
||||
<!-- lay-filter="check_student" {if in_array($item['id'], $student_schedule_id)} checked {/if}-->
|
||||
<!-- value="{$item['id']}">-->
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -165,10 +170,10 @@
|
||||
});
|
||||
})
|
||||
|
||||
form.on('checkbox(check_student)', function (data) {
|
||||
form.on('select(check_student)', function (data) {
|
||||
var elem = data.elem; // 获得 checkbox 原始 DOM 对象
|
||||
var othis = data.othis;
|
||||
var type = elem.checked ? 'add' : 'remove'; // 获得 checkbox 选中状态
|
||||
var type = elem.value ? 'add' : 'remove'; // 获得 checkbox 选中状态
|
||||
var student_id = elem.value; // 获得 checkbox 值
|
||||
let teacher_schedule_time_id = "{$schedule_time['id']}";
|
||||
var that = this;
|
||||
@ -188,6 +193,7 @@
|
||||
});
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refresh();
|
||||
// parent.refreshTable();
|
||||
// parent.refreshTable();
|
||||
// parent.location.reload();
|
||||
|
@ -212,10 +212,10 @@
|
||||
title: "空闲时间日历",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
area: [common.isModile() ? "100%" : "1080px", common.isModile() ? "100%" : "750px"],
|
||||
content: '/app/admin/teacherFreeTime/teacherFreeTimeSchedule?teacher_id=' + teacher_id + '&month=' + month
|
||||
});
|
||||
layer.full(index);
|
||||
// layer.full(index);
|
||||
}
|
||||
// 表格编辑数据
|
||||
let rest_password = function(obj) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user