| xqd
@@ -196,23 +196,24 @@ class Plan extends AuthController
|
|
|
if ($id) {
|
|
|
$plan = PlanSteps::get($id);
|
|
|
if (!$plan) return JsonService::fail('学习计划不存在!');
|
|
|
- if ($op == 'getlist') {
|
|
|
- //获取当前步骤的课程信息
|
|
|
- $where = ['stepsid' => $id, ];
|
|
|
- $list = PlanSteps::where($where)->select();
|
|
|
- $count = count($list);
|
|
|
- $return = [
|
|
|
- 'data' => $list,
|
|
|
- 'count' => $count,
|
|
|
- ];
|
|
|
- return JsonService::successlayui($return);
|
|
|
+ //获取当前步骤的课程信息
|
|
|
+ $where = ['stepsid' => $id, ];
|
|
|
+ $join = [
|
|
|
+ ['special s', 's.id = it.cid and s.is_del = 0 and s.status = 1']
|
|
|
+ ];
|
|
|
+ $coulist = [];
|
|
|
+ $list = PlanItems::alias('it')->field('s.*')->join($join)->where($where)->select();
|
|
|
+ foreach($list as $v){
|
|
|
+ $coulist[$v['id']] = $v;
|
|
|
}
|
|
|
} else {
|
|
|
$plan = [];
|
|
|
+ $coulist = [];
|
|
|
}
|
|
|
$this->assign('id', $id);
|
|
|
$this->assign('pid', $pid);
|
|
|
$this->assign('plan', json_encode($plan));
|
|
|
+ $this->assign('coulist', json_encode($coulist));
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
| xqd
@@ -222,14 +223,44 @@ class Plan extends AuthController
|
|
|
['pid', 0],
|
|
|
['introduction', ''],
|
|
|
['sort', 0],
|
|
|
+ ['courseids', []],
|
|
|
]);
|
|
|
$data['is_del'] = 0;
|
|
|
+
|
|
|
+
|
|
|
if ($id) {
|
|
|
PlanSteps::edit($data, $id);
|
|
|
+ PlanItems::where(['stepsid' => $id])->delete();
|
|
|
+ if ($data['courseids']){
|
|
|
+ $items = [];
|
|
|
+ foreach ($data['courseids'] as $one) {
|
|
|
+ $items[] = [
|
|
|
+ 'stepsid' => $id,
|
|
|
+ 'pid' => $data['pid'],
|
|
|
+ 'cid' => $one,
|
|
|
+ 'add_time' => time(),
|
|
|
+ 'type' => 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ PlanItems::setAll($items);
|
|
|
+ }
|
|
|
return JsonService::successful('修改成功');
|
|
|
} else {
|
|
|
$data['add_time'] = time();
|
|
|
$res = PlanSteps::set($data);
|
|
|
+ if ($data['courseids']){
|
|
|
+ $items = [];
|
|
|
+ foreach ($data['courseids'] as $one) {
|
|
|
+ $items[] = [
|
|
|
+ 'stepsid' => $res->id,
|
|
|
+ 'pid' => $data['pid'],
|
|
|
+ 'cid' => $one,
|
|
|
+ 'add_time' => time(),
|
|
|
+ 'type' => 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ PlanItems::setAll($items);
|
|
|
+ }
|
|
|
if ($res)
|
|
|
return JsonService::successful('添加成功');
|
|
|
else
|