学生课程作业
This commit is contained in:
parent
2e6631047a
commit
30acbd887b
@ -48,8 +48,8 @@ class StudentHomework extends BaseModel
|
|||||||
public function subject()
|
public function subject()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Subject::class, 'id', 'subject_id')->bind([
|
return $this->hasOne(Subject::class, 'id', 'subject_id')->bind([
|
||||||
'teacher_name',
|
'subject_name',
|
||||||
'teacher_account' => 'account'
|
'english_name'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ class StudentHomeworkService
|
|||||||
|
|
||||||
$data = $request->post();
|
$data = $request->post();
|
||||||
|
|
||||||
// $teacher_schedule_time = TeacherScheduleTime::where(['id' => $data['subject_homework_id']])->findOrEmpty();
|
|
||||||
|
|
||||||
|
|
||||||
$subject_homework = SubjectHomework::where(['teacher_schedule_time_id' => $data['subject_homework_id'], 'is_publish' => 1])->findOrEmpty();
|
$subject_homework = SubjectHomework::where(['teacher_schedule_time_id' => $data['subject_homework_id'], 'is_publish' => 1])->findOrEmpty();
|
||||||
if ($subject_homework->isEmpty()) {
|
if ($subject_homework->isEmpty()) {
|
||||||
@ -53,12 +51,23 @@ class StudentHomeworkService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StudentHomework::create([
|
$homework = StudentHomework::where(['student_id' => $student->id, 'subject_homework_id'=> $subject_homework->id])->findOrEmpty();
|
||||||
|
if($homework->isEmpty()){
|
||||||
|
$homework = new StudentHomework();
|
||||||
|
}
|
||||||
|
|
||||||
|
$homework->save([
|
||||||
'student_id' => $student->id,
|
'student_id' => $student->id,
|
||||||
'subject_homework_id' => $subject_homework->id,
|
'subject_homework_id' => $subject_homework->id,
|
||||||
'teacher_id' => $subject_homework->teacher_id,
|
'teacher_id' => $subject_homework->teacher_id,
|
||||||
'teacher_schedule_time_id' => $subject_homework->teacher_schedule_time_id,
|
'teacher_schedule_time_id' => $subject_homework->teacher_schedule_time_id,
|
||||||
'subject_id' => $subject_homework->subject_id,
|
'subject_id' => $subject_homework->subject_id,
|
||||||
|
'date'=> $subject_homework->date,
|
||||||
|
'time'=> $subject_homework->time,
|
||||||
|
'hour'=> $subject_homework->hour,
|
||||||
|
'start_time'=> $subject_homework->start_time,
|
||||||
|
'end_time'=> $subject_homework->end_time,
|
||||||
|
'month'=> $subject_homework->month,
|
||||||
'feedback_file_url' => $feedback_file_url,
|
'feedback_file_url' => $feedback_file_url,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ class SubjectHomeworkService
|
|||||||
'teacher_schedule_time_id' => $data['teacher_schedule_time_id'],
|
'teacher_schedule_time_id' => $data['teacher_schedule_time_id'],
|
||||||
'date' => $teacher_schedule_time->date,
|
'date' => $teacher_schedule_time->date,
|
||||||
'time' => $teacher_schedule_time->time,
|
'time' => $teacher_schedule_time->time,
|
||||||
|
'hour' => $teacher_schedule_time->hour,
|
||||||
'start_time' => $teacher_schedule_time->start_time,
|
'start_time' => $teacher_schedule_time->start_time,
|
||||||
'end_time' => $teacher_schedule_time->end_time,
|
'end_time' => $teacher_schedule_time->end_time,
|
||||||
'month' => $teacher_schedule_time->month,
|
'month' => $teacher_schedule_time->month,
|
||||||
|
192
plugin/admin/app/controller/StudentHomeworkController.php
Normal file
192
plugin/admin/app/controller/StudentHomeworkController.php
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\controller;
|
||||||
|
|
||||||
|
use app\common\model\Student;
|
||||||
|
use app\common\model\Subject;
|
||||||
|
use app\common\model\Teacher;
|
||||||
|
use app\constant\ResponseCode;
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use plugin\admin\app\model\StudentHomework;
|
||||||
|
use plugin\admin\app\controller\Crud;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
use think\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 家庭作业
|
||||||
|
*/
|
||||||
|
class StudentHomeworkController extends Crud
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var StudentHomework
|
||||||
|
*/
|
||||||
|
protected $model = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->model = new StudentHomework;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
//获取所有老师
|
||||||
|
$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();
|
||||||
|
//
|
||||||
|
$student = Student::order('id asc')->field('id,student_name,account')->select()->toArray();
|
||||||
|
|
||||||
|
return view('student-homework/index', [
|
||||||
|
'teacher' => $teacher,
|
||||||
|
'subject' => $subject,
|
||||||
|
'student' => $student,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function select(Request $request): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$homework = \app\common\model\StudentHomework::order('id desc');
|
||||||
|
$data = $request->get();
|
||||||
|
if (isset($data['student_id']) && !empty($data['student_id'])) {
|
||||||
|
$homework->where('student_id', $data['student_id']);
|
||||||
|
}
|
||||||
|
if (isset($data['teacher_id']) && !empty($data['teacher_id'])) {
|
||||||
|
$homework->where('teacher_id', $data['teacher_id']);
|
||||||
|
}
|
||||||
|
if (isset($data['teacher_id']) && !empty($data['teacher_id'])) {
|
||||||
|
$homework->where('teacher_id', $data['teacher_id']);
|
||||||
|
}
|
||||||
|
if (isset($data['is_publish']) && $data['is_publish'] !== '') {
|
||||||
|
$homework->where('is_publish', $data['is_publish']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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->with(['student', 'subject', 'teacher'])->page($page, $limit)->select()->toArray();
|
||||||
|
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
if ($item['feedback_file_url']) {
|
||||||
|
$item['feedback_file_url'] = json_decode($item['feedback_file_url'], true);
|
||||||
|
}
|
||||||
|
if ($item['feedback_version_file_url']) {
|
||||||
|
$item['feedback_version_file_url'] = json_decode($item['feedback_version_file_url'], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
'data' => $list,
|
||||||
|
'count' => $total,
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
} 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('student-homework/insert');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public function update(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
$data = $request->post();
|
||||||
|
$feedback_file_url = [];
|
||||||
|
if (isset($data['feedback_file_url'])) {
|
||||||
|
foreach ($data['feedback_file_url'] as $key => $value) {
|
||||||
|
$feedback_file_url[] = [
|
||||||
|
'url' => $value,
|
||||||
|
'name' => $data['feedback_file_url_name'][$key]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$feedback_version_file_url = [];
|
||||||
|
if (isset($data['feedback_version_file_url'])) {
|
||||||
|
foreach ($data['feedback_version_file_url'] as $key => $value) {
|
||||||
|
$feedback_version_file_url[] = [
|
||||||
|
'url' => $value,
|
||||||
|
'name' => $data['feedback_version_file_url_name'][$key]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$homework = \app\common\model\StudentHomework::where(['id'=>$data['id']])->findOrEmpty();
|
||||||
|
$homework->save([
|
||||||
|
'is_publish' => $data['is_publish'],
|
||||||
|
'feedback_file_url' => empty($feedback_file_url) ? '' : json_encode($feedback_file_url, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||||
|
'feedback_version_file_url' => empty($feedback_version_file_url) ? '' : json_encode($feedback_version_file_url, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$homework = \app\common\model\StudentHomework::where('id', $request->get('id'))->with(['student', 'subject', 'teacher'])->findOrEmpty()->toArray();
|
||||||
|
|
||||||
|
if($homework['feedback_file_url']){
|
||||||
|
$homework['feedback_file_url'] = json_decode($homework['feedback_file_url'], true);
|
||||||
|
}
|
||||||
|
if($homework['feedback_version_file_url']){
|
||||||
|
$homework['feedback_version_file_url'] = json_decode($homework['feedback_version_file_url'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('student-homework/update', ['homework' => $homework]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 更改作业状态
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function changePublishStatus(Request $request)
|
||||||
|
{
|
||||||
|
$subject_homework = \app\common\model\StudentHomework::where('id', $request->post('id'))->findOrEmpty();
|
||||||
|
$subject_homework->save([
|
||||||
|
'is_publish' => $request->post('is_publish')
|
||||||
|
]);
|
||||||
|
return json([
|
||||||
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
45
plugin/admin/app/model/StudentHomework.php
Normal file
45
plugin/admin/app/model/StudentHomework.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\model;
|
||||||
|
|
||||||
|
use plugin\admin\app\model\Base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property integer $id (主键)
|
||||||
|
* @property integer $student_id 学生
|
||||||
|
* @property integer $subject_homework_id 家庭作业id
|
||||||
|
* @property integer $teacher_id 教师
|
||||||
|
* @property integer $teacher_schedule_time_id 教师排课id
|
||||||
|
* @property integer $subject_id 课程id
|
||||||
|
* @property mixed $feedback_file_url 家庭作业反馈地址
|
||||||
|
* @property mixed $feedback_version_file_url 新版家庭作业反馈地址
|
||||||
|
* @property integer $is_publish 是否发布
|
||||||
|
* @property mixed $created_at 创建时间
|
||||||
|
* @property string $update_at 更新时间
|
||||||
|
* @property string $deleted_at
|
||||||
|
*/
|
||||||
|
class StudentHomework extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'wa_student_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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
386
plugin/admin/app/view/student-homework/index.html
Normal file
386
plugin/admin/app/view/student-homework/index.html
Normal file
@ -0,0 +1,386 @@
|
|||||||
|
|
||||||
|
<!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="student_id" value="" class="layui-input">-->
|
||||||
|
<select lay-search="" name="student_id">
|
||||||
|
<option value="">请选择或搜索</option>
|
||||||
|
{foreach $student as $item}
|
||||||
|
<option value="{$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">
|
||||||
|
<select lay-search="" name="teacher_id">
|
||||||
|
<option value="">请选择或搜索</option>
|
||||||
|
{foreach $teacher as $item}
|
||||||
|
<option value="{$item['id']}">{$item['teacher_name']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">课程</label>
|
||||||
|
<div class="layui-input-block" style="width: 250px">
|
||||||
|
<select lay-search="" name="subject_id">
|
||||||
|
<option value="">请选择或搜索</option>
|
||||||
|
{foreach $subject as $item}
|
||||||
|
<option value="{$item['id']}">{$item['subject_name']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">是否发布</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<select lay-search="" name="is_publish">
|
||||||
|
<option value="">请选择</option>
|
||||||
|
<option value="0">未发布</option>
|
||||||
|
<option value="1">已发布</option>
|
||||||
|
</select>
|
||||||
|
</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.studenthomework.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.studenthomework.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.studenthomework.update">编辑</button>
|
||||||
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.studenthomework.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/student-homework/select";
|
||||||
|
const UPDATE_API = "/app/admin/student-homework/update";
|
||||||
|
const DELETE_API = "/app/admin/student-homework/delete";
|
||||||
|
const INSERT_URL = "/app/admin/student-homework/insert";
|
||||||
|
const UPDATE_URL = "/app/admin/student-homework/update";
|
||||||
|
|
||||||
|
// 字段 是否发布 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: "student_name",
|
||||||
|
},{
|
||||||
|
title: "教师",align: "center",
|
||||||
|
field: "teacher_name",
|
||||||
|
},{
|
||||||
|
title: "日期",align: "center",
|
||||||
|
field: "date",
|
||||||
|
},{
|
||||||
|
title: "时间",align: "center",
|
||||||
|
field: "time",
|
||||||
|
},{
|
||||||
|
title: "课程",align: "center",
|
||||||
|
field: "time",
|
||||||
|
},{
|
||||||
|
title: "家庭作业反馈地址",align: "center",
|
||||||
|
field: "feedback_file_url",
|
||||||
|
hide: true
|
||||||
|
},{
|
||||||
|
title: "新版家庭作业反馈地址",align: "center",
|
||||||
|
field: "feedback_version_file_url",
|
||||||
|
hide: true
|
||||||
|
},{
|
||||||
|
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('/app/admin/student-homework/changePublishStatus', 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: "更新时间",align: "center",
|
||||||
|
field: "update_at",
|
||||||
|
hide: true,
|
||||||
|
},{
|
||||||
|
title: "deleted_at",align: "center",
|
||||||
|
field: "deleted_at",
|
||||||
|
hide: true,
|
||||||
|
},{
|
||||||
|
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%":"750px", common.isModile()?"100%":"650px"],
|
||||||
|
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>
|
144
plugin/admin/app/view/student-homework/insert.html
Normal file
144
plugin/admin/app/view/student-homework/insert.html
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
<!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="student_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="text" name="subject_homework_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="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="text" name="teacher_schedule_time_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="text" name="subject_id" value="0" 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="feedback_file_url" value="" required lay-verify="required" 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="feedback_version_file_url" 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="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>
|
||||||
|
</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/student-homework/insert";
|
||||||
|
|
||||||
|
// 字段 是否发布 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);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
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>
|
260
plugin/admin/app/view/student-homework/update.html
Normal file
260
plugin/admin/app/view/student-homework/update.html
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
<!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="student_name" disabled value="{$homework['student_name']}" class="layui-input">
|
||||||
|
<input type="hidden" name="id" value="{$homework['id']}" 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="teacher_name" disabled value="{$homework['teacher_name']}" 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" disabled value="{$homework['date']}" 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="time" disabled value="{$homework['time']}" 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="subject_name" disabled value="{$homework['subject_name']}" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">家庭作业反馈地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-input-block" id="feedback_file_url">
|
||||||
|
{if !empty($homework['feedback_file_url'])}
|
||||||
|
{foreach $homework['feedback_file_url'] as $index => $item}
|
||||||
|
<div style="margin-top: 10px;display: inline-block;">
|
||||||
|
<div style="width: 250px;">
|
||||||
|
<span><a href="{$item['url']}" target="_blank" download="{$item['name']}">{$item['name']}</a></span>
|
||||||
|
<input type="hidden" name="feedback_file_url[{$index}]" value="{$item['url']}">
|
||||||
|
<input type="hidden" name="feedback_file_url_name[{$index}]" value="{$item['name']}">
|
||||||
|
<button type="button" class="layui-btn layui-btn-xs layui-bg-red remove_feedback_file_url"
|
||||||
|
lay-event="remove" permission="app.admin.teacher.delete">删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/foreach}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="layui-input-inline" style="margin-left: 100px;padding-top: 10px;">
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="feedback_file_url_upload"
|
||||||
|
permission="app.admin.upload.file">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传文件
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">新版家庭作业反馈地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-input-block" id="feedback_version_file_url">
|
||||||
|
{if !empty($homework['feedback_version_file_url'])}
|
||||||
|
{foreach $homework['feedback_version_file_url'] as $index => $item}
|
||||||
|
<div style="margin-top: 10px;display: inline-block;">
|
||||||
|
<div style="width: 250px;">
|
||||||
|
<span><a href="{$item['url']}" target="_blank" download="{$item['name']}">{$item['name']}</a></span>
|
||||||
|
<input type="hidden" name="feedback_version_file_url[{$index}]" value="{$item['url']}">
|
||||||
|
<input type="hidden" name="feedback_version_file_url_name[{$index}]" value="{$item['name']}">
|
||||||
|
<button type="button" class="layui-btn layui-btn-xs layui-bg-red remove_feedback_version_file_url"
|
||||||
|
lay-event="remove" permission="app.admin.teacher.delete">删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/foreach}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="layui-input-inline" style="margin-left: 100px;padding-top: 10px;">
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="feedback_version_file_url_upload"
|
||||||
|
permission="app.admin.upload.file">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传文件
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</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="{$homework['is_publish']}"/>
|
||||||
|
</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/student-homework/select" + location.search;
|
||||||
|
const UPDATE_API = "/app/admin/student-homework/update";
|
||||||
|
|
||||||
|
// 获取数据库记录
|
||||||
|
layui.use(["form", "util", "popup"], function () {
|
||||||
|
let $ = layui.$;
|
||||||
|
|
||||||
|
// 字段 是否发布 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);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// 家庭作业 feedback_file_url
|
||||||
|
layui.use(["upload", "layer", "popup", "util"], function () {
|
||||||
|
let input = layui.$("#feedback_file_url").prev();
|
||||||
|
input.prev().html(layui.util.escape(input.val()));
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#feedback_file_url_upload",
|
||||||
|
accept: "file",
|
||||||
|
url: "/app/admin/upload/uploadFile",
|
||||||
|
field: "file",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code) return layui.popup.failure(res.msg);
|
||||||
|
$('#feedback_file_url').append('<div style="margin-top: 10px;display: inline-block;">\n' +
|
||||||
|
'<div style="width: 250px;">\n' +
|
||||||
|
'<span><a href="' + res.data.url + '">' + res.data.name + '</a></span>\n' +
|
||||||
|
'<input type="hidden" name="feedback_file_url[]" value="' + res.data.url + '">\n' +
|
||||||
|
'<input type="hidden" name="feedback_file_url_name[]" value="' + res.data.name + '">\n' +
|
||||||
|
'<button type="button" class="layui-btn layui-btn-xs layui-bg-red remove_feedback_file_url" permission="app.admin.teacher.delete">删除</button>\n' +
|
||||||
|
'</div>\n' +
|
||||||
|
'</div>');
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#feedback_file_url').on('click', '.remove_feedback_file_url', function () {
|
||||||
|
$(this).parent().parent().remove();
|
||||||
|
})
|
||||||
|
|
||||||
|
// 家庭作业 feedback_file_url
|
||||||
|
layui.use(["upload", "layer", "popup", "util"], function () {
|
||||||
|
let input = layui.$("#feedback_version_file_url").prev();
|
||||||
|
input.prev().html(layui.util.escape(input.val()));
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#feedback_version_file_url_upload",
|
||||||
|
accept: "file",
|
||||||
|
url: "/app/admin/upload/uploadFile",
|
||||||
|
field: "file",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code) return layui.popup.failure(res.msg);
|
||||||
|
$('#feedback_version_file_url').append('<div style="margin-top: 10px;display: inline-block;">\n' +
|
||||||
|
'<div style="width: 250px;">\n' +
|
||||||
|
'<span><a href="' + res.data.url + '">' + res.data.name + '</a></span>\n' +
|
||||||
|
'<input type="hidden" name="feedback_version_file_url[]" value="' + res.data.url + '">\n' +
|
||||||
|
'<input type="hidden" name="feedback_version_file_url_name[]" value="' + res.data.name + '">\n' +
|
||||||
|
'<button type="button" class="layui-btn layui-btn-xs layui-bg-red remove_feedback_version_file_url" permission="app.admin.teacher.delete">删除</button>\n' +
|
||||||
|
'</div>\n' +
|
||||||
|
'</div>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#feedback_version_file_url').on('click', '.remove_feedback_version_file_url', function () {
|
||||||
|
$(this).parent().parent().remove();
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
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>
|
Loading…
x
Reference in New Issue
Block a user