作者 xieweiping
1 个管道 的构建 通过 耗费 7 秒

课表取消功能

... ... @@ -162,7 +162,19 @@ class CourseStore extends Backend
public function publish(){
if ($this->request->isPost()) {
$params = $this->request->post();
$this->model->save(['status'=>'confirmed'],['id'=>$params['id']]);
$courseStore = $this->model->where(['id'=>$params['id']])->find();
if(empty($courseStore)){
$this->error(__('没有课程安排', ''));
}
$courseStore = $courseStore->toArray();
if($courseStore['status'] == 'new'){
$this->model->save(['status'=>'confirmed'],['id'=>$params['id']]);
}
if($courseStore['status'] == 'confirmed'){
$this->model->save(['status'=>'cancel'],['id'=>$params['id']]);
}
$return = $this->model->where(['id'=>$params['id']])->find();
$this->success('ok', null,$return);
... ...
... ... @@ -14,6 +14,7 @@ return [
'Status' => '状态',
'confirmed' => '已发布',
'new' => '未发布',
'cancel' => '已取消',
'Publish' => '发布',
'Detail' => '报名情况',
];
... ...
... ... @@ -11,8 +11,8 @@ use WeChat\Exceptions\LocalCacheException;
use WeMini\Newtmpl;
/**
* 课程接口
*/
* 课程接口
*/
class Course extends Api
{
protected $noNeedLogin = ['*'];
... ... @@ -219,26 +219,30 @@ class Course extends Api
$m = cdnurl($m,true);
}
$course['banner'] = $banner;
//查询门店课程
$courseStore = new \app\admin\model\CourseStore();
$where['course_id'] = $id;
$where['status'] = 'confirmed';
$where['is_end'] = false;
$where['end'] = ['>',date('Y-m-d H:i:s')];
if(!empty($store_id)){
$where['store_id'] = $store_id;
}
$courseStore = $courseStore->where($where)->order('date','asc')->select();
$store_id = [];
$store = [];
if(!empty($store_id)){
foreach($courseStore as $k){
$store_id[$k['store_id']] = $k['store_id'];
$store1 = new \app\admin\model\Store();
$store1 = $store1->where(['id'=>$store_id])->find();
$store1 = $store1->where(['id'=>$k['store_id']])->find();
$store1 = $store1->toArray();
$store1['start'] = 2000000000;
$store1['end'] = 1;
$store1['course'] = [];
$store[$store_id] = $store1;
}
foreach ($courseStore as $k){
$k['enable'] = true;
if(!empty($user_id)){
... ... @@ -275,15 +279,15 @@ class Course extends Api
$course['store'] = array_values($store);
/* foreach ($course['store'] as &$k){
$courseStore = new \app\admin\model\CourseStore();
$where['course_id'] = $id;
$where['store_id'] = $k['id'];
$where['status'] = 'confirmed';
$where['is_end'] = false;
$where['end'] = ['>',date('Y-m-d H:i:s')];
$k['course'] = $courseStore->with('store')->where($where)->order('date','desc')->select();
}*/
/* foreach ($course['store'] as &$k){
$courseStore = new \app\admin\model\CourseStore();
$where['course_id'] = $id;
$where['store_id'] = $k['id'];
$where['status'] = 'confirmed';
$where['is_end'] = false;
$where['end'] = ['>',date('Y-m-d H:i:s')];
$k['course'] = $courseStore->with('store')->where($where)->order('date','desc')->select();
}*/
//查询评价
$star = new \app\admin\model\CourseSignStart();
... ...
... ... @@ -45,6 +45,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
if (value === 'new') {
color = 'green';
}
if (value === 'cancel') {
color = 'black';
}
return '<span style="color:' + color + '">' + __(value) + '</span>';
}},
{
... ... @@ -64,12 +67,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
],
events: Table.api.events.operate, formatter: function (value, row, index) {
var that = $.extend({}, this);
that.buttons[0].extend = 'data-publish-id="' + row.id + '"';
that.buttons[0].extend = 'data-publish-id="' + row.id + '" data-publish-status="' + row.status + '"';
that.buttons[1].url = 'course_sign/index?ids=' + row.id;
var table = $(that.table).clone(true);
if (row.status === 'confirmed') {
$(table).data("operate-edit", null);
$(table).data("operate-del", null);
that.buttons[0].text = '取消';
}
if (row.status === 'cancel') {
$(table).data("operate-edit", null);
$(table).data("operate-del", null);
$(table).data("operate-publish", null);
}
if (row.status === 'new') {
... ... @@ -89,33 +97,60 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
//发布
$(document).on("click",".btn-publish",function (e) {
var id = $(this).data('publish-id');
var status = $(this).data('publish-status');
e.stopPropagation();
e.preventDefault(); //事件冒泡阻止
var that = this;
var table = $(that).closest('table');
var options = table.bootstrapTable('getOptions');
Layer.open({title: '发布', content: '是否发布此课程', btn: '确定',yes:function (row) {
$.ajax({
type : "POST",
url : "course_store/publish",
data : {
id : id
},
dataType: "json",
success : function (data) {
// console.log(data);
if (data.code === 1) {
Layer.msg('发布成功')
Layer.closeAll()
$('.btn-refresh').trigger('click')
} else {
Layer.msg('发布失败')
Layer.closeAll()
}
if(status === 'confirmed'){
Layer.open({title: '取消', content: '是否取消此课程', btn: '确定',yes:function (row) {
$.ajax({
type : "POST",
url : "course_store/publish",
data : {
id : id
},
dataType: "json",
success : function (data) {
// console.log(data);
if (data.code === 1) {
Layer.msg('取消成功');
Layer.closeAll();
$('.btn-refresh').trigger('click')
} else {
Layer.msg('取消失败');
Layer.closeAll()
}
}
})
}})
}
})
}})
}
if(status === 'new'){
Layer.open({title: '发布', content: '是否发布此课程', btn: '确定',yes:function (row) {
$.ajax({
type : "POST",
url : "course_store/publish",
data : {
id : id
},
dataType: "json",
success : function (data) {
// console.log(data);
if (data.code === 1) {
Layer.msg('发布成功');
Layer.closeAll();
$('.btn-refresh').trigger('click')
} else {
Layer.msg('发布失败');
Layer.closeAll()
}
}
})
}})
}
});
},
add: function () {
... ...