fix 教师添加批量发布排课
This commit is contained in:
parent
627c01652f
commit
50387c6b29
@ -357,6 +357,7 @@ class TeacherScheduleTimeController extends Crud
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @desc 时间列表
|
||||
* @param Request $request
|
||||
@ -504,6 +505,54 @@ class TeacherScheduleTimeController extends Crud
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 更改教师排课状态
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function changePublishStatus(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$list = \app\common\model\TeacherScheduleTime::where(['id' => $data['ids']])->select();
|
||||
|
||||
if($data['status']){
|
||||
foreach ($list as $item) {
|
||||
if (empty($item->subject_id)) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => '请先选择课程再发布-ID' . $item->id
|
||||
]);
|
||||
}
|
||||
$student_schedule = StudentSchedule::where(['teacher_schedule_time_id' => $item->id])->select();
|
||||
if ($student_schedule->isEmpty()) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => '请先安排学生后再发布-ID' . $item->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($list as $item) {
|
||||
$item->save(['is_publish' => $data['status']]);
|
||||
if($data['status']){
|
||||
(new SendMsgCronJobService())->teacherScheduleTimePublishMsgToTeacher($item->id);
|
||||
}
|
||||
}
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => 'success'
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 导出排课页面
|
||||
|
@ -117,7 +117,14 @@
|
||||
|
||||
<!-- 表格顶部工具栏 -->
|
||||
<script type="text/html" id="table-toolbar">
|
||||
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="publish"
|
||||
permission="app.admin.teacherscheduletime.delete">
|
||||
<i class="layui-icon layui-icon-up"></i>发布
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="unpublished"
|
||||
permission="app.admin.teacherscheduletime.delete">
|
||||
<i class="layui-icon layui-icon-down"></i>取消发布
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove"
|
||||
permission="app.admin.teacherscheduletime.delete">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
@ -306,6 +313,10 @@
|
||||
add();
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === "publish") {
|
||||
publish(obj, 1);
|
||||
} else if (obj.event === "unpublished") {
|
||||
publish(obj, 0);
|
||||
} else if (obj.event === "export-schedule") {
|
||||
exportSchedule();
|
||||
} else if (obj.event === "batchRemove") {
|
||||
@ -365,6 +376,46 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 删除多行
|
||||
let publish = function (obj, status) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
let ids = checkIds;
|
||||
// doRemove(checkIds.split(","));
|
||||
let data = {ids: checkIds.split(","), status: status};
|
||||
let msg = '';
|
||||
if (status) {
|
||||
msg = '确定批量【发布】教师排课?';
|
||||
} else {
|
||||
msg = '确定批量【取消发布】学生排课?';
|
||||
}
|
||||
layer.confirm(msg, {
|
||||
icon: 3,
|
||||
title: "提示"
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/teacherScheduleTime/changePublishStatus',
|
||||
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);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 表格新增数据
|
||||
let exportSchedule = function () {
|
||||
let index = layer.open({
|
||||
|
Loading…
x
Reference in New Issue
Block a user