导出排期
This commit is contained in:
parent
f823bb5b45
commit
69990b5f5f
@ -60,3 +60,24 @@ if (!function_exists('random_str')) {
|
|||||||
return bin2hex(random_bytes(round($len / 2)));
|
return bin2hex(random_bytes(round($len / 2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('get_dates_in_month')) {
|
||||||
|
/**
|
||||||
|
* @desc 获取月份所有天
|
||||||
|
* @param $year
|
||||||
|
* @param $month
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_dates_in_month($year, $month) {
|
||||||
|
$dates = [];
|
||||||
|
$firstDayOfMonth = new DateTime("$year-$month-01");
|
||||||
|
$lastDayOfMonth = clone $firstDayOfMonth;
|
||||||
|
$lastDayOfMonth->modify('last day of this month');
|
||||||
|
|
||||||
|
for ($currentDate = $firstDayOfMonth; $currentDate <= $lastDayOfMonth; $currentDate->modify('+1 day')) {
|
||||||
|
$dates[] = $currentDate->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -8,6 +8,10 @@ use app\common\model\Subject;
|
|||||||
use app\common\model\Teacher;
|
use app\common\model\Teacher;
|
||||||
use app\common\model\TeacherFreeTime;
|
use app\common\model\TeacherFreeTime;
|
||||||
use app\constant\ResponseCode;
|
use app\constant\ResponseCode;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||||
|
use plugin\admin\app\model\TeacherSchedule;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
use plugin\admin\app\model\TeacherScheduleTime;
|
use plugin\admin\app\model\TeacherScheduleTime;
|
||||||
@ -15,6 +19,7 @@ use plugin\admin\app\controller\Crud;
|
|||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 教师空闲时间
|
* 教师空闲时间
|
||||||
@ -306,10 +311,10 @@ class TeacherScheduleTimeController extends Crud
|
|||||||
throw new Exception('未找到教师排课时间');
|
throw new Exception('未找到教师排课时间');
|
||||||
}
|
}
|
||||||
$changeData = [];
|
$changeData = [];
|
||||||
if(isset($data['subject_id'])){
|
if (isset($data['subject_id'])) {
|
||||||
$teacher_schedule_time->subject_id = $data['subject_id'];
|
$teacher_schedule_time->subject_id = $data['subject_id'];
|
||||||
}
|
}
|
||||||
if(isset($data['is_publish'])){
|
if (isset($data['is_publish'])) {
|
||||||
$teacher_schedule_time->is_publish = $data['is_publish'];
|
$teacher_schedule_time->is_publish = $data['is_publish'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,4 +333,198 @@ class TeacherScheduleTimeController extends Crud
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 导出排课页面
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function exportScheduleIndex(Request $request)
|
||||||
|
{
|
||||||
|
return view('teacher-schedule-time/export_schedule_index');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 所有教师排课汇总
|
||||||
|
* @param Request $request
|
||||||
|
*/
|
||||||
|
public function getTeacherScheduleTimeSummary(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$summary = \app\common\model\TeacherScheduleTime::order('ts.month desc')->alias('ts')
|
||||||
|
->leftJoin('teacher t', 'ts.teacher_id = t.id')
|
||||||
|
->leftJoin('student_schedule ss', 'ts.id = ss.teacher_schedule_time_id and t.id = ss.teacher_id')
|
||||||
|
// ->where(['ts.is_publish' => 1])
|
||||||
|
->field('
|
||||||
|
ts.month,
|
||||||
|
COUNT(DISTINCT ts.teacher_id) AS teacher_count,
|
||||||
|
|
||||||
|
SUM(ts.hour) AS total_scheduled_hours,
|
||||||
|
SUM(CASE WHEN ts.is_publish = 1 THEN ts.hour ELSE 0 END) AS publish_scheduled_hours,
|
||||||
|
COUNT(DISTINCT ts.id) AS total_scheduled_classes,
|
||||||
|
COUNT(DISTINCT CASE WHEN ts.is_publish = 1 THEN ts.id END) AS publish_scheduled_classes,
|
||||||
|
|
||||||
|
SUM(ss.hour) AS total_student_hours,
|
||||||
|
SUM(CASE WHEN ss.is_publish = 1 THEN ss.hour ELSE 0 END) AS publish_student_hours,
|
||||||
|
COUNT(DISTINCT ss.teacher_schedule_time_id) AS total_student_classes,
|
||||||
|
COUNT(DISTINCT CASE WHEN ss.is_publish = 1 THEN ss.teacher_schedule_time_id END ) AS publish_student_classes
|
||||||
|
')
|
||||||
|
->group('ts.month');
|
||||||
|
|
||||||
|
|
||||||
|
$limit = (int)$request->get('limit', 10);
|
||||||
|
$limit = $limit <= 0 ? 10 : $limit;
|
||||||
|
$page = (int)$request->get('page');
|
||||||
|
$page = $page > 0 ? $page : 1;
|
||||||
|
|
||||||
|
$total = $summary->count();
|
||||||
|
|
||||||
|
$list = $summary->select();
|
||||||
|
|
||||||
|
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()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 导出汇总
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function exportSummary(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$month = $request->get('month');
|
||||||
|
$summary = \app\common\model\TeacherScheduleTime::order('ts.start_time asc')->alias('ts')
|
||||||
|
->leftJoin('teacher t', 'ts.teacher_id = t.id')
|
||||||
|
->leftJoin('student_schedule ss', 'ts.id = ss.teacher_schedule_time_id and t.id = ss.teacher_id')
|
||||||
|
->leftJoin('subject sb', 'ts.subject_id = sb.id')
|
||||||
|
->where(['ts.is_publish' => 1, 'ts.month' => $month])
|
||||||
|
->field('
|
||||||
|
t.teacher_name,
|
||||||
|
ts.time,
|
||||||
|
ts.en_time,
|
||||||
|
ts.date,
|
||||||
|
ts.month,
|
||||||
|
ts.hour,
|
||||||
|
ts.start_time,
|
||||||
|
ts.end_time,
|
||||||
|
sb.subject_name,
|
||||||
|
sb.english_name,
|
||||||
|
ss.student_name
|
||||||
|
')
|
||||||
|
->group('ts.id')
|
||||||
|
->select()->toArray();
|
||||||
|
|
||||||
|
$export_data = [];
|
||||||
|
foreach ($summary as $item) {
|
||||||
|
$export_data[$item['date']][$item['time']][] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
//设置工作表标题名称
|
||||||
|
$worksheet->setTitle('教师排课汇总');
|
||||||
|
$worksheet->setCellValue('A1', 'Week');
|
||||||
|
$worksheet->setCellValue('B1', 'Date');
|
||||||
|
$worksheet->setCellValue('C1', 'China TIme');
|
||||||
|
$worksheet->setCellValue('D1', 'UK Time');
|
||||||
|
$worksheet->setCellValue('E1', 'Subject');
|
||||||
|
$worksheet->setCellValue('F1', 'Tutor');
|
||||||
|
$worksheet->setCellValue('G1', 'Duration');
|
||||||
|
$worksheet->setCellValue('H1', 'Note');
|
||||||
|
// $worksheet->getStyle('A1:H1')->();
|
||||||
|
|
||||||
|
|
||||||
|
$month_days = get_dates_in_month(date('Y', strtotime($month)), date('m', strtotime($month)));
|
||||||
|
|
||||||
|
// $column = Coordinate::columnIndexFromString(2);
|
||||||
|
|
||||||
|
$offset_row =2;
|
||||||
|
foreach ($month_days as $index => $date) {
|
||||||
|
$week = date('l', strtotime($date));
|
||||||
|
|
||||||
|
if($week == 'Sunday' && $index != 0){
|
||||||
|
//合并单元格
|
||||||
|
$merge_offset = $index + $offset_row;
|
||||||
|
$worksheet->mergeCells("A{$merge_offset}:H{$merge_offset}");
|
||||||
|
$offset_row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$merge_count = 1;
|
||||||
|
$china_time = '';
|
||||||
|
$en_time = '';
|
||||||
|
$subject_name = '';
|
||||||
|
$teacher_name = '';
|
||||||
|
$hour= '';
|
||||||
|
if (isset($export_data[$date])) {
|
||||||
|
$merge_count = count($export_data[$date]);
|
||||||
|
foreach ($export_data[$date] as $schedule) {
|
||||||
|
foreach ($schedule as $schedule_time) {
|
||||||
|
$china_time = $schedule_time['time'];
|
||||||
|
$en_time = $schedule_time['en_time'];
|
||||||
|
$subject_name = $schedule_time['english_name'];
|
||||||
|
$teacher_name = $schedule_time['teacher_name'];
|
||||||
|
$hour = $schedule_time['hour'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$row = $index + $offset_row;
|
||||||
|
if ($merge_count > 1) {
|
||||||
|
//合并单元格
|
||||||
|
$worksheet->mergeCells("A{$row}:A" . ($row + $merge_count - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A' . $row, $week);
|
||||||
|
$worksheet->setCellValue('B' . $row, date('m/d', strtotime($date)));
|
||||||
|
$worksheet->setCellValue('C' . $row, $china_time);
|
||||||
|
$worksheet->setCellValue('D' . $row, $en_time);
|
||||||
|
$worksheet->setCellValue('E' . $row, $subject_name);
|
||||||
|
$worksheet->setCellValue('F' . $row, $teacher_name);
|
||||||
|
$worksheet->setCellValue('G' . $row, $hour);
|
||||||
|
$worksheet->setCellValue('H' . $row, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$writer = new Xlsx($spreadsheet);
|
||||||
|
|
||||||
|
// $writer->save(public_path('/export_file/' . $month . '-' . time() . '.xlsx'));
|
||||||
|
|
||||||
|
$file_name = $month . '-' . time() . '.xlsx';
|
||||||
|
$file_path = '/export_file/';
|
||||||
|
$save_path = public_path($file_path);
|
||||||
|
if(!is_dir($save_path)){
|
||||||
|
mkdir($save_path, 0777, true);
|
||||||
|
}
|
||||||
|
$writer->save($save_path . $file_name);
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
'data' => [
|
||||||
|
// 'url' => getenv('SERVER_DOMAIN') . $file_path,
|
||||||
|
'file_url' => 'http://course.test' . $file_path . $file_name,
|
||||||
|
'file_name' => $file_name
|
||||||
|
],
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return json([
|
||||||
|
'code' => ResponseCode::WEB_API_FAIL,
|
||||||
|
'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,369 @@
|
|||||||
|
|
||||||
|
<!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">
|
||||||
|
<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.teacher.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.teacher.delete">-->
|
||||||
|
<!-- <i class="layui-icon layui-icon-delete"></i>删除-->
|
||||||
|
<!-- </button>-->
|
||||||
|
<!-- </script>-->
|
||||||
|
|
||||||
|
<!-- 表格行工具栏 -->
|
||||||
|
<script type="text/html" id="table-bar">
|
||||||
|
<!-- <button type="button" class="layui-btn layui-btn-xs" lay-event="edit" permission="app.admin.teacher.update">编辑</button>-->
|
||||||
|
<button type="button" class="layui-btn layui-btn-xs layui-bg-orange" lay-event="export_schedule" permission="app.admin.teacher.update">导出详情</button>
|
||||||
|
<!-- <button class="pear-btn pear-btn-xs tool-btn" lay-event="rest_password" permission="app.admin.teacher.update">重置密码</button>-->
|
||||||
|
<!-- <button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.teacher.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/teacher-schedule-time/getTeacherScheduleTimeSummary";
|
||||||
|
const UPDATE_API = "/app/admin/teacher/update";
|
||||||
|
const DELETE_API = "/app/admin/teacher/delete";
|
||||||
|
const INSERT_URL = "/app/admin/teacher/insert";
|
||||||
|
|
||||||
|
// 表格渲染
|
||||||
|
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: "月份",align: "center",
|
||||||
|
field: "month",
|
||||||
|
},{
|
||||||
|
title: "排课教师总数",align: "center",
|
||||||
|
field: "teacher_count",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "teacher_count";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'个</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "教师排课时长/总",align: "center",
|
||||||
|
field: "total_scheduled_hours",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "total_scheduled_hours";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'h</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "教师排课发布时长",align: "center",
|
||||||
|
field: "publish_scheduled_hours",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "publish_scheduled_hours";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'h</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "教师排课总节数",align: "center",
|
||||||
|
field: "total_scheduled_classes",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "total_scheduled_classes";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'节</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "教师排课发布节数",align: "center",
|
||||||
|
field: "publish_scheduled_classes",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "publish_scheduled_classes";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'节</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "学生排课时长/总",align: "center",
|
||||||
|
field: "total_student_hours",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "total_student_hours";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'h</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "学生排课发布时长",align: "center",
|
||||||
|
field: "publish_student_hours",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "publish_student_hours";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'h</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "学生排课总节数",align: "center",
|
||||||
|
field: "total_student_classes",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "total_student_classes";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'节</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "学生排课发布节数",align: "center",
|
||||||
|
field: "publish_student_classes",
|
||||||
|
templet: function (d) {
|
||||||
|
let field = "publish_student_classes";
|
||||||
|
return '<span class="layui-badge layui-bg-blue">'+ d[field] +'节</span>';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "deleted_at",align: "center",
|
||||||
|
field: "deleted_at",
|
||||||
|
hide: true,
|
||||||
|
},{
|
||||||
|
title: "操作",
|
||||||
|
toolbar: "#table-bar",
|
||||||
|
align: "center",
|
||||||
|
fixed: "right",
|
||||||
|
width: 180,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// 渲染表格
|
||||||
|
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);
|
||||||
|
}else if (obj.event === "export_schedule") {
|
||||||
|
export_schedule(obj);
|
||||||
|
} else if (obj.event === "rest_password") {
|
||||||
|
rest_password(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 export_schedule = function(obj) {
|
||||||
|
let month = obj.data['month'];
|
||||||
|
layui.$.ajax({
|
||||||
|
url: '/app/admin/teacherScheduleTime/exportSummary?month=' + month,
|
||||||
|
type: "POST",
|
||||||
|
dateType: "json",
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
console.log(111,res.data)
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.style.display = 'none';
|
||||||
|
// 设置下载地址
|
||||||
|
link.setAttribute('href', res.date.file_url);
|
||||||
|
// 设置文件名
|
||||||
|
link.setAttribute('download', res.data.file_name);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 表格编辑数据
|
||||||
|
let rest_password = function(obj) {
|
||||||
|
console.log()
|
||||||
|
let data = {};
|
||||||
|
data[PRIMARY_KEY] = obj.data[PRIMARY_KEY];
|
||||||
|
let new_password = 'YD' + obj.data['account'] + '123';
|
||||||
|
layer.confirm("确定充值密码?重置后新密码为【"+ new_password +"】", {
|
||||||
|
icon: 3,
|
||||||
|
title: "提示"
|
||||||
|
}, function(index) {
|
||||||
|
layer.close(index);
|
||||||
|
let loading = layer.load();
|
||||||
|
$.ajax({
|
||||||
|
url: '/app/admin/teacher/resetPassword',
|
||||||
|
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 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>
|
@ -351,14 +351,15 @@
|
|||||||
|
|
||||||
// 表格新增数据
|
// 表格新增数据
|
||||||
let exportSchedule = function () {
|
let exportSchedule = function () {
|
||||||
layer.open({
|
let index = layer.open({
|
||||||
type: 2,
|
type: 2,
|
||||||
title: "汇总导出",
|
title: "汇总导出",
|
||||||
shade: 0.1,
|
shade: 0.1,
|
||||||
maxmin: true,
|
maxmin: true,
|
||||||
area: [common.isModile() ? "100%" : "500px", common.isModile() ? "100%" : "450px"],
|
area: [common.isModile() ? "100%" : "750px", common.isModile() ? "100%" : "650px"],
|
||||||
content: INSERT_URL
|
content: '/app/admin/teacher-schedule-time/exportScheduleIndex'
|
||||||
});
|
});
|
||||||
|
layer.full(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表格编辑数据
|
// 表格编辑数据
|
||||||
|
Loading…
x
Reference in New Issue
Block a user