用户登录,后台家庭作业
This commit is contained in:
parent
f6288dc9c6
commit
cce32a4203
@ -47,6 +47,11 @@ class SubjectHomeworkService
|
|||||||
$res = SubjectHomework::create([
|
$res = SubjectHomework::create([
|
||||||
'teacher_id' => $teacher->id,
|
'teacher_id' => $teacher->id,
|
||||||
'teacher_schedule_time_id' => $data['teacher_schedule_time_id'],
|
'teacher_schedule_time_id' => $data['teacher_schedule_time_id'],
|
||||||
|
'date' => $teacher_schedule_time->date,
|
||||||
|
'time' => $teacher_schedule_time->time,
|
||||||
|
'start_time' => $teacher_schedule_time->start_time,
|
||||||
|
'end_time' => $teacher_schedule_time->end_time,
|
||||||
|
'month' => $teacher_schedule_time->month,
|
||||||
'subject_id' => $teacher_schedule_time->subject_id,
|
'subject_id' => $teacher_schedule_time->subject_id,
|
||||||
'homework_file_url' => $data['homework_file_url'],
|
'homework_file_url' => $data['homework_file_url'],
|
||||||
'homework_file_name' => $data['homework_file_name'],
|
'homework_file_name' => $data['homework_file_name'],
|
||||||
|
@ -31,50 +31,89 @@ class TeacherFreeTimeService
|
|||||||
}
|
}
|
||||||
$data = $request->post();
|
$data = $request->post();
|
||||||
|
|
||||||
|
if(empty($data['free_time'])){
|
||||||
|
throw new Exception('请选择时间后提交');
|
||||||
|
}
|
||||||
|
|
||||||
$free_time = json_decode($data['free_time'], true);
|
$free_time = json_decode($data['free_time'], true);
|
||||||
|
|
||||||
|
|
||||||
if (empty($free_time)) {
|
|
||||||
throw new Exception('请选择时间段之后再提交');
|
|
||||||
}
|
|
||||||
$total_count = 0;
|
$total_count = 0;
|
||||||
$exit_count = 0;
|
$exit_count = 0;
|
||||||
$err_free_count = 0;
|
$err_free_count = 0;
|
||||||
|
|
||||||
foreach ($free_time as $free_date => $times) {
|
foreach ($free_time as $item) {
|
||||||
if ($times) {
|
$free_date = $item['day'];
|
||||||
foreach ($times as $time) {
|
foreach ($item['times'] as $val){
|
||||||
$time_period = explode(' - ', $time);
|
$time = $val['zh'];
|
||||||
$firstDate = new DateTime($free_date . ' ' . trim($time_period[0]));
|
$en_time = $val['en'];
|
||||||
$secondDate = new DateTime($free_date . ' ' . trim($time_period[1]));
|
$time_period = explode('-', $time);
|
||||||
$diff = $secondDate->diff($firstDate);
|
$en_time_period = explode('-', $en_time);
|
||||||
$h = $diff->h;
|
$firstDate = new DateTime($free_date . ' ' . trim($time_period[0]));
|
||||||
$m = round($diff->i / 60, 2);
|
$secondDate = new DateTime($free_date . ' ' . trim($time_period[1]));
|
||||||
$hour = round($h + $m, 2);
|
$diff = $secondDate->diff($firstDate);
|
||||||
$time = $time_period[0] . ' - ' . $time_period[1];
|
$h = $diff->h;
|
||||||
$free_data = [
|
$m = round($diff->i / 60, 2);
|
||||||
'teacher_id' => $request->teacher->id,
|
$hour = round($h + $m, 2);
|
||||||
'date' => $free_date,
|
$time = $time_period[0] . ' - ' . $time_period[1];
|
||||||
'time' => $time,
|
$free_data = [
|
||||||
'hour' => $hour,
|
'teacher_id' => $request->teacher->id,
|
||||||
'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()),
|
'date' => $free_date,
|
||||||
'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()),
|
'time' => $time,
|
||||||
'month' => date('Y-m', strtotime($free_date)),
|
'en_time' => implode(' - ', $en_time_period),
|
||||||
];
|
'hour' => $hour,
|
||||||
|
'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()),
|
||||||
|
'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()),
|
||||||
|
'month' => date('Y-m', strtotime($free_date)),
|
||||||
|
];
|
||||||
|
|
||||||
//判断是否已经存在
|
//判断是否已经存在
|
||||||
$exit = TeacherFreeTime::where($free_data)->findOrEmpty();
|
$exit = TeacherFreeTime::where($free_data)->findOrEmpty();
|
||||||
if(!$exit->isEmpty()){
|
if(!$exit->isEmpty()){
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
$res = TeacherFreeTime::create($free_data);
|
|
||||||
if(!$res){
|
|
||||||
throw new Exception('保存失败');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$res = TeacherFreeTime::create($free_data);
|
||||||
|
if(!$res){
|
||||||
|
throw new Exception('保存失败');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// foreach ($free_time as $free_date => $times) {
|
||||||
|
// if ($times) {
|
||||||
|
// foreach ($times as $time) {
|
||||||
|
// $time_period = explode(' - ', $time);
|
||||||
|
// $firstDate = new DateTime($free_date . ' ' . trim($time_period[0]));
|
||||||
|
// $secondDate = new DateTime($free_date . ' ' . trim($time_period[1]));
|
||||||
|
// $diff = $secondDate->diff($firstDate);
|
||||||
|
// $h = $diff->h;
|
||||||
|
// $m = round($diff->i / 60, 2);
|
||||||
|
// $hour = round($h + $m, 2);
|
||||||
|
// $time = $time_period[0] . ' - ' . $time_period[1];
|
||||||
|
// $free_data = [
|
||||||
|
// 'teacher_id' => $request->teacher->id,
|
||||||
|
// 'date' => $free_date,
|
||||||
|
// 'time' => $time,
|
||||||
|
// 'hour' => $hour,
|
||||||
|
// 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()),
|
||||||
|
// 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()),
|
||||||
|
// 'month' => date('Y-m', strtotime($free_date)),
|
||||||
|
// ];
|
||||||
|
//
|
||||||
|
// //判断是否已经存在
|
||||||
|
// $exit = TeacherFreeTime::where($free_data)->findOrEmpty();
|
||||||
|
// if(!$exit->isEmpty()){
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// $res = TeacherFreeTime::create($free_data);
|
||||||
|
// if(!$res){
|
||||||
|
// throw new Exception('保存失败');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'code' => ResponseCode::SUCCESS,
|
'code' => ResponseCode::SUCCESS,
|
||||||
'msg' => '保存成功'
|
'msg' => '保存成功'
|
||||||
|
@ -67,7 +67,7 @@ class UploadService
|
|||||||
|
|
||||||
if ($file && $file->isValid()) {
|
if ($file && $file->isValid()) {
|
||||||
$ext = $file->getUploadExtension();
|
$ext = $file->getUploadExtension();
|
||||||
if (in_array($ext, ['pdf', 'doc', 'docx', 'xlsx', 'xls', 'csv', 'pptx', 'ppt', 'zip', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PBG'])) {
|
if (in_array($ext, ['pdf', 'doc', 'docx', 'xlsx', 'xls', 'csv', 'pptx', 'ppt', 'zip', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PBG', 'txt'])) {
|
||||||
$type = 'files';
|
$type = 'files';
|
||||||
} else {
|
} else {
|
||||||
$type = 'other';
|
$type = 'other';
|
||||||
|
99
plugin/admin/app/controller/SubjectHomeworkController.php
Normal file
99
plugin/admin/app/controller/SubjectHomeworkController.php
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\controller;
|
||||||
|
|
||||||
|
use app\constant\ResponseCode;
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use plugin\admin\app\model\SubjectHomework;
|
||||||
|
use plugin\admin\app\controller\Crud;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
use think\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 课程作业
|
||||||
|
*/
|
||||||
|
class SubjectHomeworkController extends Crud
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SubjectHomework
|
||||||
|
*/
|
||||||
|
protected $model = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->model = new SubjectHomework;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
return view('subject-homework/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function select(Request $request): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$homework = \app\common\model\SubjectHomework::order('id desc');
|
||||||
|
if(1){
|
||||||
|
|
||||||
|
}
|
||||||
|
$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();
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
'data' => $list,
|
||||||
|
'count' => $total
|
||||||
|
]);
|
||||||
|
}catch (Exception $e){
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => ResponseCode::WEB_API_FAIL,
|
||||||
|
'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public function insert(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
return parent::insert($request);
|
||||||
|
}
|
||||||
|
return view('subject-homework/insert');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public function update(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
return parent::update($request);
|
||||||
|
}
|
||||||
|
return view('subject-homework/update');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace plugin\admin\app\controller;
|
namespace plugin\admin\app\controller;
|
||||||
|
|
||||||
|
use app\common\service\UploadService;
|
||||||
use app\constant\ResponseCode;
|
use app\constant\ResponseCode;
|
||||||
use app\utils\QiniuUtils;
|
use app\utils\QiniuUtils;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -132,6 +133,26 @@ class UploadController extends Crud
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 上传图片
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
*/
|
||||||
|
public function uploadFile(Request $request)
|
||||||
|
{
|
||||||
|
$service = new UploadService();
|
||||||
|
$res = $service->uploadFile($request->file('file'));
|
||||||
|
if($res['code'] == ResponseCode::SUCCESS){
|
||||||
|
return $this->json(0, '上传成功', [
|
||||||
|
'url' => $res['data']['url'],
|
||||||
|
'name' => $res['data']['origin_name']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $this->json($res);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件
|
* 上传文件
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
50
plugin/admin/app/model/SubjectHomework.php
Normal file
50
plugin/admin/app/model/SubjectHomework.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\model;
|
||||||
|
|
||||||
|
use plugin\admin\app\model\Base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property integer $id (主键)
|
||||||
|
* @property integer $teacher_id 教师
|
||||||
|
* @property integer $teacher_schedule_time_id 教师排课id
|
||||||
|
* @property string $date 日期
|
||||||
|
* @property string $time 时间
|
||||||
|
* @property string $start_time 开始时间
|
||||||
|
* @property string $end_time 结束时间
|
||||||
|
* @property string $month 月份
|
||||||
|
* @property integer $subject_id 课程id
|
||||||
|
* @property string $homework_file_url 家庭作业地址
|
||||||
|
* @property string $homework_file_name 家庭作业文件名称
|
||||||
|
* @property string $homework_version_file_url 新版本家庭作业
|
||||||
|
* @property string $homework_version_file_name 新版本家庭作业文件名称
|
||||||
|
* @property integer $is_publish 是否发布
|
||||||
|
* @property mixed $created_at 创建时间
|
||||||
|
* @property string $update_at 更新时间
|
||||||
|
* @property string $deleted_at
|
||||||
|
*/
|
||||||
|
class SubjectHomework extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'wa_subject_homework';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
466
plugin/admin/app/view/subject-homework/index.html
Normal file
466
plugin/admin/app/view/subject-homework/index.html
Normal file
@ -0,0 +1,466 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>浏览页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css"/>
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css"/>
|
||||||
|
</head>
|
||||||
|
<body class="pear-container">
|
||||||
|
|
||||||
|
<!-- 顶部查询表单 -->
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<form class="layui-form top-search-from">
|
||||||
|
|
||||||
|
<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">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">日期</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="date" id="date" 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="month" id="month" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
</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_file_name[]" value="like"
|
||||||
|
class="layui-input inline-block">
|
||||||
|
<input type="text" autocomplete="off" name="homework_file_name[]" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</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>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div name="is_publish" id="is_publish" value=""></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item layui-inline">
|
||||||
|
<label class="layui-form-label"></label>
|
||||||
|
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
|
||||||
|
<i class="layui-icon layui-icon-search"></i>查询
|
||||||
|
</button>
|
||||||
|
<button type="reset" class="pear-btn pear-btn-md" lay-submit lay-filter="table-reset">
|
||||||
|
<i class="layui-icon layui-icon-refresh"></i>重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="toggle-btn">
|
||||||
|
<a class="layui-hide">展开<i class="layui-icon layui-icon-down"></i></a>
|
||||||
|
<a class="layui-hide">收起<i class="layui-icon layui-icon-up"></i></a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 数据表格 -->
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<table id="data-table" lay-filter="data-table"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 表格顶部工具栏 -->
|
||||||
|
<script type="text/html" id="table-toolbar">
|
||||||
|
<!-- <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.subjecthomework.insert">-->
|
||||||
|
<!-- <i class="layui-icon layui-icon-add-1"></i>新增-->
|
||||||
|
<!-- </button>-->
|
||||||
|
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove"
|
||||||
|
permission="app.admin.subjecthomework.delete">
|
||||||
|
<i class="layui-icon layui-icon-delete"></i>删除
|
||||||
|
</button>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- 表格行工具栏 -->
|
||||||
|
<script type="text/html" id="table-bar">
|
||||||
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.subjecthomework.update">编辑
|
||||||
|
</button>
|
||||||
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.subjecthomework.delete">
|
||||||
|
删除
|
||||||
|
</button>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/common.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关常量
|
||||||
|
const PRIMARY_KEY = "id";
|
||||||
|
const SELECT_API = "/app/admin/subject-homework/select";
|
||||||
|
const UPDATE_API = "/app/admin/subject-homework/update";
|
||||||
|
const DELETE_API = "/app/admin/subject-homework/delete";
|
||||||
|
const INSERT_URL = "/app/admin/subject-homework/insert";
|
||||||
|
const UPDATE_URL = "/app/admin/subject-homework/update";
|
||||||
|
|
||||||
|
// 字段 日期 date
|
||||||
|
layui.use(["laydate"], function () {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#date",
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 开始时间 start_time
|
||||||
|
layui.use(["laydate"], function () {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#start_time",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 结束时间 end_time
|
||||||
|
layui.use(["laydate"], function () {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#end_time",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 月份 month
|
||||||
|
layui.use(["laydate"], function () {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#month",
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 是否发布 is_publish
|
||||||
|
layui.use(["jquery", "xmSelect"], function () {
|
||||||
|
let value = layui.$("#is_publish").attr("value");
|
||||||
|
let initValue = value ? value.split(",") : [];
|
||||||
|
layui.xmSelect.render({
|
||||||
|
el: "#is_publish",
|
||||||
|
name: "is_publish",
|
||||||
|
filterable: true,
|
||||||
|
initValue: initValue,
|
||||||
|
data: [{"value": "1", "name": "是"}, {"value": "0", "name": "否"}],
|
||||||
|
model: {"icon": "hidden", "label": {"type": "text"}},
|
||||||
|
clickClose: true,
|
||||||
|
radio: true,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格渲染
|
||||||
|
layui.use(["table", "form", "common", "popup", "util"], function () {
|
||||||
|
let table = layui.table;
|
||||||
|
let form = layui.form;
|
||||||
|
let $ = layui.$;
|
||||||
|
let common = layui.common;
|
||||||
|
let util = layui.util;
|
||||||
|
|
||||||
|
// 表头参数
|
||||||
|
let cols = [
|
||||||
|
{
|
||||||
|
type: "checkbox",
|
||||||
|
align: "center"
|
||||||
|
}, {
|
||||||
|
title: "id", align: "center",
|
||||||
|
field: "id",
|
||||||
|
}, {
|
||||||
|
title: "教师", align: "center",
|
||||||
|
field: "teacher_id",
|
||||||
|
}, {
|
||||||
|
title: "教师排课id", align: "center",
|
||||||
|
field: "teacher_schedule_time_id",
|
||||||
|
}, {
|
||||||
|
title: "日期", align: "center",
|
||||||
|
field: "date",
|
||||||
|
}, {
|
||||||
|
title: "时间", align: "center",
|
||||||
|
field: "time",
|
||||||
|
}, {
|
||||||
|
title: "开始时间", align: "center",
|
||||||
|
field: "start_time",
|
||||||
|
hide: true,
|
||||||
|
}, {
|
||||||
|
title: "结束时间", align: "center",
|
||||||
|
field: "end_time",
|
||||||
|
hide: true,
|
||||||
|
}, {
|
||||||
|
title: "月份", align: "center",
|
||||||
|
field: "month",
|
||||||
|
}, {
|
||||||
|
title: "课程id", align: "center",
|
||||||
|
field: "subject_id",
|
||||||
|
hide: true
|
||||||
|
}, {
|
||||||
|
title: "家庭作业地址", align: "center",
|
||||||
|
field: "homework_file_url",
|
||||||
|
hide: true,
|
||||||
|
templet: function (d) {
|
||||||
|
return '<a href="' + encodeURI(d['homework_file_url']) + '" target="_blank">' + util.escape(d['homework_file_url']) + '</a>';
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
title: "课程作业", align: "center",
|
||||||
|
field: "homework_file_name",
|
||||||
|
templet: function (d) {
|
||||||
|
return '<a href="' + encodeURI(d['homework_file_url']) + '" target="_blank">' + util.escape(d['homework_file_name']) + '</a>';
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
title: "新版本课程作业", align: "center",
|
||||||
|
field: "homework_version_file_url",
|
||||||
|
hide: true,
|
||||||
|
templet: function (d) {
|
||||||
|
return '<a href="' + encodeURI(d['homework_version_file_url']) + '" target="_blank">' + util.escape(d['homework_version_file_url']) + '</a>';
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
title: "新版本家庭作业文件名称", align: "center",
|
||||||
|
field: "homework_version_file_name",
|
||||||
|
templet: function (d) {
|
||||||
|
return '<a href="' + encodeURI(d['homework_version_file_url']) + '" target="_blank">' + util.escape(d['homework_version_file_name']) + '</a>';
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
title: "是否发布", align: "center",
|
||||||
|
field: "is_publish",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "is_publish";
|
||||||
|
form.on("switch(" + field + ")", function (data) {
|
||||||
|
let load = layer.load();
|
||||||
|
let postData = {};
|
||||||
|
postData[field] = data.elem.checked ? 1 : 0;
|
||||||
|
postData[PRIMARY_KEY] = this.value;
|
||||||
|
$.post(UPDATE_API, postData, function (res) {
|
||||||
|
layer.close(load);
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg, function () {
|
||||||
|
data.elem.checked = !data.elem.checked;
|
||||||
|
form.render();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功");
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let checked = d[field] === 1 ? "checked" : "";
|
||||||
|
return '<input type="checkbox" value="' + util.escape(d[PRIMARY_KEY]) + '" lay-filter="' + util.escape(field) + '" lay-skin="switch" lay-text="' + util.escape('') + '" ' + checked + '/>';
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
title: "创建时间", align: "center",
|
||||||
|
field: "created_at",
|
||||||
|
}, {
|
||||||
|
title: "操作",
|
||||||
|
toolbar: "#table-bar",
|
||||||
|
align: "center",
|
||||||
|
fixed: "right",
|
||||||
|
width: 120,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// 渲染表格
|
||||||
|
table.render({
|
||||||
|
elem: "#data-table",
|
||||||
|
url: SELECT_API,
|
||||||
|
page: true,
|
||||||
|
cols: [cols],
|
||||||
|
skin: "line",
|
||||||
|
size: "lg",
|
||||||
|
toolbar: "#table-toolbar",
|
||||||
|
autoSort: false,
|
||||||
|
defaultToolbar: [{
|
||||||
|
title: "刷新",
|
||||||
|
layEvent: "refresh",
|
||||||
|
icon: "layui-icon-refresh",
|
||||||
|
}, "filter", "print", "exports"],
|
||||||
|
done: function () {
|
||||||
|
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 编辑或删除行事件
|
||||||
|
table.on("tool(data-table)", function (obj) {
|
||||||
|
if (obj.event === "remove") {
|
||||||
|
remove(obj);
|
||||||
|
} else if (obj.event === "edit") {
|
||||||
|
edit(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部工具栏事件
|
||||||
|
table.on("toolbar(data-table)", function (obj) {
|
||||||
|
if (obj.event === "add") {
|
||||||
|
add();
|
||||||
|
} else if (obj.event === "refresh") {
|
||||||
|
refreshTable();
|
||||||
|
} else if (obj.event === "batchRemove") {
|
||||||
|
batchRemove(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部搜索事件
|
||||||
|
form.on("submit(table-query)", function (data) {
|
||||||
|
table.reload("data-table", {
|
||||||
|
page: {
|
||||||
|
curr: 1
|
||||||
|
},
|
||||||
|
where: data.field
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部搜索重置事件
|
||||||
|
form.on("submit(table-reset)", function (data) {
|
||||||
|
table.reload("data-table", {
|
||||||
|
where: []
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段允许为空
|
||||||
|
form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/, '只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格排序事件
|
||||||
|
table.on("sort(data-table)", function (obj) {
|
||||||
|
table.reload("data-table", {
|
||||||
|
initSort: obj,
|
||||||
|
scrollPos: "fixed",
|
||||||
|
where: {
|
||||||
|
field: obj.field,
|
||||||
|
order: obj.type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格新增数据
|
||||||
|
let add = function () {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "新增",
|
||||||
|
shade: 0.1,
|
||||||
|
maxmin: true,
|
||||||
|
area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"],
|
||||||
|
content: INSERT_URL
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格编辑数据
|
||||||
|
let edit = function (obj) {
|
||||||
|
let value = obj.data[PRIMARY_KEY];
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "修改",
|
||||||
|
shade: 0.1,
|
||||||
|
maxmin: true,
|
||||||
|
area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"],
|
||||||
|
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除一行
|
||||||
|
let remove = function (obj) {
|
||||||
|
return doRemove(obj.data[PRIMARY_KEY]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除多行
|
||||||
|
let batchRemove = function (obj) {
|
||||||
|
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||||
|
if (checkIds === "") {
|
||||||
|
layui.popup.warning("未选中数据");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
doRemove(checkIds.split(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行删除
|
||||||
|
let doRemove = function (ids) {
|
||||||
|
let data = {};
|
||||||
|
data[PRIMARY_KEY] = ids;
|
||||||
|
layer.confirm("确定删除?", {
|
||||||
|
icon: 3,
|
||||||
|
title: "提示"
|
||||||
|
}, function (index) {
|
||||||
|
layer.close(index);
|
||||||
|
let loading = layer.load();
|
||||||
|
$.ajax({
|
||||||
|
url: DELETE_API,
|
||||||
|
data: data,
|
||||||
|
dataType: "json",
|
||||||
|
type: "post",
|
||||||
|
success: function (res) {
|
||||||
|
layer.close(loading);
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", refreshTable);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新表格数据
|
||||||
|
window.refreshTable = function () {
|
||||||
|
table.reloadData("data-table", {
|
||||||
|
scrollPos: "fixed",
|
||||||
|
done: function (res, curr) {
|
||||||
|
if (curr > 1 && res.data && !res.data.length) {
|
||||||
|
curr = curr - 1;
|
||||||
|
table.reloadData("data-table", {
|
||||||
|
page: {
|
||||||
|
curr: curr
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
330
plugin/admin/app/view/subject-homework/insert.html
Normal file
330
plugin/admin/app/view/subject-homework/insert.html
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>新增页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form class="layui-form" action="">
|
||||||
|
|
||||||
|
<div class="mainBox">
|
||||||
|
<div class="main-container mr-5">
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">教师</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="teacher_id" value="0" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">教师排课id</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="teacher_schedule_time_id" value="0" 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="date" id="date" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="time" value="" required lay-verify="required" 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="month" id="month" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">课程id</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="subject_id" value="0" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">家庭作业地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<span></span>
|
||||||
|
<input type="text" style="display:none" name="homework_file_url" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="homework_file_url" permission="app.admin.upload.file">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传文件
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-homework_file_url" permission="app.admin.upload.attachment">
|
||||||
|
<i class="layui-icon layui-icon-align-left"></i>选择文件
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">家庭作业文件名称</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="homework_file_name" value="" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">新版本家庭作业</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<span></span>
|
||||||
|
<input type="text" style="display:none" name="homework_version_file_url" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="homework_version_file_url" permission="app.admin.upload.file">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传文件
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-homework_version_file_url" permission="app.admin.upload.attachment">
|
||||||
|
<i class="layui-icon layui-icon-align-left"></i>选择文件
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">新版本家庭作业文件名称</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="homework_version_file_name" value="" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">是否发布</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="checkbox" id="is_publish" lay-filter="is_publish" lay-skin="switch" />
|
||||||
|
<input type="text" style="display:none" name="is_publish" value="0" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">创建时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="created_at" id="created_at" 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="update_at" id="update_at" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">deleted_at</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="deleted_at" id="deleted_at" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bottom">
|
||||||
|
<div class="button-container">
|
||||||
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit=""
|
||||||
|
lay-filter="save">
|
||||||
|
提交
|
||||||
|
</button>
|
||||||
|
<button type="reset" class="pear-btn pear-btn-md">
|
||||||
|
重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关接口
|
||||||
|
const INSERT_API = "/app/admin/subject-homework/insert";
|
||||||
|
|
||||||
|
// 字段 日期 date
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#date",
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 开始时间 start_time
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#start_time",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 结束时间 end_time
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#end_time",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 月份 month
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#month",
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 家庭作业地址 homework_file_url
|
||||||
|
layui.use(["upload", "layer", "popup", "util"], function() {
|
||||||
|
let input = layui.$("#homework_file_url").prev();
|
||||||
|
input.prev().html(layui.util.escape(input.val()));
|
||||||
|
layui.$("#attachment-choose-homework_file_url").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().html(layui.util.escape(data.url));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#homework_file_url",
|
||||||
|
value: "",
|
||||||
|
accept: "file",
|
||||||
|
url: "/app/admin/upload/file",
|
||||||
|
field: "__file__",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code) return layui.popup.failure(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().html(layui.util.escape(res.data.url));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段 新版本家庭作业 homework_version_file_url
|
||||||
|
layui.use(["upload", "layer", "popup", "util"], function() {
|
||||||
|
let input = layui.$("#homework_version_file_url").prev();
|
||||||
|
input.prev().html(layui.util.escape(input.val()));
|
||||||
|
layui.$("#attachment-choose-homework_version_file_url").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().html(layui.util.escape(data.url));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#homework_version_file_url",
|
||||||
|
value: "",
|
||||||
|
accept: "file",
|
||||||
|
url: "/app/admin/upload/file",
|
||||||
|
field: "__file__",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code) return layui.popup.failure(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().html(layui.util.escape(res.data.url));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段 是否发布 is_publish
|
||||||
|
layui.use(["form"], function() {
|
||||||
|
layui.$("#is_publish").attr("checked", layui.$('input[name="is_publish"]').val() != 0);
|
||||||
|
layui.form.render();
|
||||||
|
layui.form.on("switch(is_publish)", function(data) {
|
||||||
|
layui.$('input[name="is_publish"]').val(this.checked ? 1 : 0);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 创建时间 created_at
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#created_at",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 更新时间 update_at
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#update_at",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 deleted_at deleted_at
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#deleted_at",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
layui.use(["form", "popup"], function () {
|
||||||
|
// 字段验证允许为空
|
||||||
|
layui.form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
layui.form.on("submit(save)", function (data) {
|
||||||
|
layui.$.ajax({
|
||||||
|
url: INSERT_API,
|
||||||
|
type: "POST",
|
||||||
|
dateType: "json",
|
||||||
|
data: data.field,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
366
plugin/admin/app/view/subject-homework/update.html
Normal file
366
plugin/admin/app/view/subject-homework/update.html
Normal file
@ -0,0 +1,366 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>更新页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form class="layui-form">
|
||||||
|
|
||||||
|
<div class="mainBox">
|
||||||
|
<div class="main-container mr-5">
|
||||||
|
|
||||||
|
<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">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">教师排课id</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="teacher_schedule_time_id" value="" 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="date" id="date" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="time" value="" required lay-verify="required" 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="month" id="month" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">家庭作业地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<span></span>
|
||||||
|
<input type="text" style="display:none" name="homework_file_url" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="homework_file_url" permission="app.admin.upload.file">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传文件
|
||||||
|
</button>
|
||||||
|
<!-- <button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-homework_file_url" permission="app.admin.upload.attachment">-->
|
||||||
|
<!-- <i class="layui-icon layui-icon-align-left"></i>选择文件-->
|
||||||
|
<!-- </button>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="layui-form-item">-->
|
||||||
|
<!-- <label class="layui-form-label">家庭作业文件名称</label>-->
|
||||||
|
<!-- <div class="layui-input-block">-->
|
||||||
|
<!-- <input type="text" name="homework_file_name" value="" class="layui-input">-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">新版本家庭作业</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<span></span>
|
||||||
|
<input type="text" style="display:none" name="homework_version_file_url" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="homework_version_file_url" permission="app.admin.upload.file">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传文件
|
||||||
|
</button>
|
||||||
|
<!-- <button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-homework_version_file_url" permission="app.admin.upload.attachment">-->
|
||||||
|
<!-- <i class="layui-icon layui-icon-align-left"></i>选择文件-->
|
||||||
|
<!-- </button>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="layui-form-item">-->
|
||||||
|
<!-- <label class="layui-form-label">新版本家庭作业文件名称</label>-->
|
||||||
|
<!-- <div class="layui-input-block">-->
|
||||||
|
<!-- <input type="text" name="homework_version_file_name" value="" class="layui-input">-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">是否发布</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="checkbox" id="is_publish" lay-filter="is_publish" lay-skin="switch" />
|
||||||
|
<input type="text" style="display:none" name="is_publish" value="0" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">创建时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="created_at" id="created_at" 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="update_at" id="update_at" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">deleted_at</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="deleted_at" id="deleted_at" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bottom">
|
||||||
|
<div class="button-container">
|
||||||
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
|
||||||
|
提交
|
||||||
|
</button>
|
||||||
|
<button type="reset" class="pear-btn pear-btn-md">
|
||||||
|
重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关接口
|
||||||
|
const PRIMARY_KEY = "id";
|
||||||
|
const SELECT_API = "/app/admin/subject-homework/select" + location.search;
|
||||||
|
const UPDATE_API = "/app/admin/subject-homework/update";
|
||||||
|
|
||||||
|
// 获取数据库记录
|
||||||
|
layui.use(["form", "util", "popup"], function () {
|
||||||
|
let $ = layui.$;
|
||||||
|
$.ajax({
|
||||||
|
url: SELECT_API,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (res) {
|
||||||
|
|
||||||
|
// 给表单初始化数据
|
||||||
|
layui.each(res.data[0], function (key, value) {
|
||||||
|
let obj = $('*[name="'+key+'"]');
|
||||||
|
if (key === "password") {
|
||||||
|
obj.attr("placeholder", "不更新密码请留空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||||
|
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||||
|
obj.val(value);
|
||||||
|
} else {
|
||||||
|
obj.attr("value", value);
|
||||||
|
obj[0].value = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段 日期 date
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#date",
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 开始时间 start_time
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#start_time",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 结束时间 end_time
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#end_time",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 月份 month
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#month",
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 家庭作业地址 homework_file_url
|
||||||
|
layui.use(["upload", "layer", "popup", "util"], function() {
|
||||||
|
let input = layui.$("#homework_file_url").prev();
|
||||||
|
input.prev().html(layui.util.escape(input.val()));
|
||||||
|
layui.$("#attachment-choose-homework_file_url").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().html(layui.util.escape(data.url));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#homework_file_url",
|
||||||
|
accept: "file",
|
||||||
|
url: "/app/admin/upload/uploadFile",
|
||||||
|
field: "file",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code) return layui.popup.failure(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().html(layui.util.escape(res.data.url));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段 新版本家庭作业 homework_version_file_url
|
||||||
|
layui.use(["upload", "layer", "popup", "util"], function() {
|
||||||
|
let input = layui.$("#homework_version_file_url").prev();
|
||||||
|
input.prev().html(layui.util.escape(input.val()));
|
||||||
|
layui.$("#attachment-choose-homework_version_file_url").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().html(layui.util.escape(data.url));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#homework_version_file_url",
|
||||||
|
accept: "file",
|
||||||
|
url: "/app/admin/upload/uploadFile",
|
||||||
|
field: "file",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code) return layui.popup.failure(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().html(layui.util.escape(res.data.url));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段 是否发布 is_publish
|
||||||
|
layui.use(["form"], function() {
|
||||||
|
layui.$("#is_publish").attr("checked", layui.$('input[name="is_publish"]').val() != 0);
|
||||||
|
layui.form.render();
|
||||||
|
layui.form.on("switch(is_publish)", function(data) {
|
||||||
|
layui.$('input[name="is_publish"]').val(this.checked ? 1 : 0);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 创建时间 created_at
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#created_at",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 更新时间 update_at
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#update_at",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字段 deleted_at deleted_at
|
||||||
|
layui.use(["laydate"], function() {
|
||||||
|
layui.laydate.render({
|
||||||
|
elem: "#deleted_at",
|
||||||
|
type: "datetime",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// ajax返回失败
|
||||||
|
if (res.code) {
|
||||||
|
layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
layui.use(["form", "popup"], function () {
|
||||||
|
// 字段验证允许为空
|
||||||
|
layui.form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
layui.form.on("submit(save)", function (data) {
|
||||||
|
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||||
|
layui.$.ajax({
|
||||||
|
url: UPDATE_API,
|
||||||
|
type: "POST",
|
||||||
|
dateType: "json",
|
||||||
|
data: data.field,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -153,8 +153,11 @@
|
|||||||
title: "日期",align: "center",
|
title: "日期",align: "center",
|
||||||
field: "date",
|
field: "date",
|
||||||
},{
|
},{
|
||||||
title: "时间",align: "center",
|
title: "中国时间",align: "center",
|
||||||
field: "time",
|
field: "time",
|
||||||
|
},{
|
||||||
|
title: "当地时间",align: "center",
|
||||||
|
field: "en_time",
|
||||||
},{
|
},{
|
||||||
title: "课时/h",align: "center",
|
title: "课时/h",align: "center",
|
||||||
field: "hour",
|
field: "hour",
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
123123132
|
@ -0,0 +1 @@
|
|||||||
|
123123132
|
@ -0,0 +1 @@
|
|||||||
|
123123132
|
Loading…
x
Reference in New Issue
Block a user