diff --git a/application/admin/controller/school/Message.php b/application/admin/controller/school/Message.php index fb6d67d..6c89041 100644 --- a/application/admin/controller/school/Message.php +++ b/application/admin/controller/school/Message.php @@ -56,7 +56,7 @@ class Message extends Backend list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $as = $this->model->getWithAlisaName(); $list = $this->model - ->with(['admin','user']) + ->with(['admin','user','messageevent']) ->where($where) // ->order($sort, $order) ->order("{$as}.weigh DESC,{$as}.id DESC") @@ -66,6 +66,7 @@ class Message extends Backend $row->getRelation('admin')->visible(['nickname','avatar']); $row->getRelation('user')->visible(['nickname','avatar']); + $row->getRelation('messageevent')->visible(['logo_image']); } $result = array("total" => $list->total(), "rows" => $list->items()); diff --git a/application/admin/controller/school/MessageConfig.php b/application/admin/controller/school/MessageConfig.php new file mode 100644 index 0000000..e4e4ca8 --- /dev/null +++ b/application/admin/controller/school/MessageConfig.php @@ -0,0 +1,40 @@ +model = new \app\admin\model\school\MessageConfig; + $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("wechatWapList", $this->model->getWechatWapList()); + $this->view->assign("messageList", $this->model->getMessageList()); + $this->view->assign("selfmailList", $this->model->getSelfmailList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index 7d3f27a..8566b55 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -216,7 +216,9 @@ class ClassesLib extends Backend $classesLib->no_auth_fields = $this->no_auth_fields; $classesLib->need_auth = $this->need_auth; $classesLib->have_auth = $this->have_auth; - $classesLib->classesCheck($params,$shop_id=null,$row); + + $classesLib->classesCheck($params,null,$row); + $this->need_auth = $classesLib->need_auth; $this->have_auth = $classesLib->have_auth; @@ -349,8 +351,17 @@ class ClassesLib extends Backend $this->model->validateFailException()->validate($validate); } $this->update_check($params,$row=null); + $spec = $params["spec"]; + unset($params["spec"]); $result = $this->model->allowField(true)->save($params); \app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]); + + //添加课程规格 + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $this->model["id"]; + \app\common\model\school\classes\ClassesSpec::create($v); + } + $this->update_classes($this->model["id"]); if($this->have_auth){ @@ -405,6 +416,11 @@ class ClassesLib extends Backend $this->error(__('You have no permission')); } if (false === $this->request->isPost()) { + $spec = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row["id"])->field("id,classes_lib_id,name,start_time,end_time,limit_num,status,weigh")->order('weigh desc,id desc')->select(); + foreach ($spec as $k=>&$v){ + $v["time"] = date("Y/m/d H:i",$v["start_time"])." - ".date("Y/m/d H:i",$v["end_time"]); + } + $row["spec"] = json_encode($spec); $this->view->assign('row', $row); return $this->view->fetch(); } @@ -422,8 +438,29 @@ class ClassesLib extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException()->validate($validate); } + $this->update_check($params,$row); + $spec = $params["spec"] ?? []; + $delete_spec_ids = $params["delete_spec_ids"] ?? []; + unset($params["spec"]); + unset($params["delete_spec_ids"]); $result = $row->allowField(true)->save($params); + //添加课程规格 + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $row["id"]; + //有id更新,否则新增 + if(isset($v["id"]) && $v["id"]){ + \app\common\model\school\classes\ClassesSpec::update((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + }else{ + \app\common\model\school\classes\ClassesSpec::create((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + } + + } + //删除规格 + foreach ($delete_spec_ids as $k=>$delete_spec){ + $delete_spec->delete(); + } + $this->update_classes($row["id"]); if($this->have_auth){ //调用通过事件 diff --git a/application/admin/controller/school/classes/ClassesSpec.php b/application/admin/controller/school/classes/ClassesSpec.php index e64d9a0..755b242 100644 --- a/application/admin/controller/school/classes/ClassesSpec.php +++ b/application/admin/controller/school/classes/ClassesSpec.php @@ -135,14 +135,18 @@ class ClassesSpec extends Backend { //限定人数必须大于0 try { - (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,$shop_id=null,$row); - }catch (\Exception $e){ - $this->error($e->getMessage()); - } - //修改 + $classesLib = new \app\common\model\school\classes\ClassesSpec(); + $classesLib->no_auth_fields = $this->no_auth_fields; + $classesLib->need_auth = $this->need_auth; + $classesLib->have_auth = $this->have_auth; + $classesLib->specCheck($params,$shop_id=null,$row); + $this->need_auth = $classesLib->need_auth; + $this->have_auth = $classesLib->have_auth; + + //修改 if($row){ - $this->updateCheck($row->id,$params,$row); + $classesLib->updateCheck($row->id,$params,$row); }else{ //新增 @@ -150,6 +154,13 @@ class ClassesSpec extends Backend } +// (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,$shop_id=null,$row); + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + + + ; } diff --git a/application/admin/lang/zh-cn/school/message.php b/application/admin/lang/zh-cn/school/message.php index 82dcca1..556b1fd 100644 --- a/application/admin/lang/zh-cn/school/message.php +++ b/application/admin/lang/zh-cn/school/message.php @@ -5,6 +5,7 @@ return [ 'Type 1' => '未读', 'Type 2' => '已读', 'Weigh' => '权重', + 'Logo_image' => '事件消息logo', 'Platform' => '消息平台', 'Platform admin' => '总后台', 'Platform user' => '用户端', diff --git a/application/admin/lang/zh-cn/school/message_config.php b/application/admin/lang/zh-cn/school/message_config.php new file mode 100644 index 0000000..2a0460b --- /dev/null +++ b/application/admin/lang/zh-cn/school/message_config.php @@ -0,0 +1,30 @@ + '事件名', + 'Event' => '事件标识', + 'Logo_image' => '事件消息logo', + 'Status' => '事件类型', + 'Status 1' => '系统推送', + 'Set status to 1' => '设为系统推送', + 'Status 2' => '其他', + 'Set status to 2' => '设为其他', + 'Wechat_wap' => '微信公众号消息', + 'Wechat_wap 1' => '开启', + 'Wechat_wap 2' => '关闭', + 'Message' => '短信消息', + 'Message 1' => '开启', + 'Message 2' => '关闭', + 'Selfmail' => '站内行消息', + 'Selfmail 1' => '开启', + 'Selfmail 2' => '关闭', + 'Message_id' => '短信模板id', + 'Wechat_wap_id' => '公众号模板消息id', + 'Selfmail_title' => '站内信标题', + 'Selfmail_template_text' => '站内信模板', + 'Configjson' => '可用的模板字段变量', + 'Weigh' => '权重', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Deletetime' => '删除时间' +]; diff --git a/application/admin/model/school/Message.php b/application/admin/model/school/Message.php index 32d46c1..59af4dc 100644 --- a/application/admin/model/school/Message.php +++ b/application/admin/model/school/Message.php @@ -144,4 +144,11 @@ class Message extends BaseModel { return $this->belongsTo('app\admin\model\User', 'to_id', 'id', [], 'LEFT')->setEagerlyType(0); } + + + public function messageevent() + { + return $this->belongsTo(MessageConfig::class, 'event', 'event', [], 'LEFT')->setEagerlyType(0); + } + } diff --git a/application/admin/model/school/MessageConfig.php b/application/admin/model/school/MessageConfig.php new file mode 100644 index 0000000..b38002b --- /dev/null +++ b/application/admin/model/school/MessageConfig.php @@ -0,0 +1,101 @@ +getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + } + }); + } + + + public function getStatusList() + { + return ['1' => __('Status 1'), '2' => __('Status 2')]; + } + + public function getWechatWapList() + { + return ['1' => __('Wechat_wap 1'), '2' => __('Wechat_wap 2')]; + } + + public function getMessageList() + { + return ['1' => __('Message 1'), '2' => __('Message 2')]; + } + + public function getSelfmailList() + { + return ['1' => __('Selfmail 1'), '2' => __('Selfmail 2')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getWechatWapTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['wechat_wap']) ? $data['wechat_wap'] : ''); + $list = $this->getWechatWapList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getMessageTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['message']) ? $data['message'] : ''); + $list = $this->getMessageList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSelfmailTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['selfmail']) ? $data['selfmail'] : ''); + $list = $this->getSelfmailList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + + +} diff --git a/application/admin/validate/school/MessageConfig.php b/application/admin/validate/school/MessageConfig.php new file mode 100644 index 0000000..18d5fb9 --- /dev/null +++ b/application/admin/validate/school/MessageConfig.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/school/classes/classes_lib/addnew.html b/application/admin/view/school/classes/classes_lib/addnew.html index d82d644..6c66719 100644 --- a/application/admin/view/school/classes/classes_lib/addnew.html +++ b/application/admin/view/school/classes/classes_lib/addnew.html @@ -169,9 +169,9 @@ + + + + + + + + +
@@ -376,7 +430,7 @@
- +
diff --git a/application/admin/view/school/classes/classes_lib/index.html b/application/admin/view/school/classes/classes_lib/index.html index 13df2e4..ffe3c10 100644 --- a/application/admin/view/school/classes/classes_lib/index.html +++ b/application/admin/view/school/classes/classes_lib/index.html @@ -20,10 +20,10 @@ - {:__('Add')} + - {:__('新版添加')}(开发中) + {:__('Add')} {:__('Edit')} {:__('Delete')} diff --git a/application/admin/view/school/message/add.html b/application/admin/view/school/message/add.html index 8a7d075..2b09868 100644 --- a/application/admin/view/school/message/add.html +++ b/application/admin/view/school/message/add.html @@ -84,6 +84,14 @@
+ +
+ +
+ +
+
+
@@ -91,6 +99,9 @@
+ + +
diff --git a/application/admin/view/school/message/edit.html b/application/admin/view/school/message/edit.html index b23c312..fbae4f6 100644 --- a/application/admin/view/school/message/edit.html +++ b/application/admin/view/school/message/edit.html @@ -84,6 +84,14 @@
+ +
+ +
+ +
+
+
diff --git a/application/admin/view/school/message_config/add.html b/application/admin/view/school/message_config/add.html new file mode 100644 index 0000000..cb6a21a --- /dev/null +++ b/application/admin/view/school/message_config/add.html @@ -0,0 +1,129 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+ +
+
    +
    +
    +
    + +
    + +
    + {foreach name="statusList" item="vo"} + + {/foreach} +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + {:__('Key')} + {:__('Value')} +
    +
    {:__('Append')}
    + +
    + + +
    +
    +
    + +
    + +
    +
    + +
    diff --git a/application/admin/view/school/message_config/edit.html b/application/admin/view/school/message_config/edit.html new file mode 100644 index 0000000..4b257ed --- /dev/null +++ b/application/admin/view/school/message_config/edit.html @@ -0,0 +1,129 @@ +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    + + +
    + +
    +
      +
      +
      +
      + +
      + +
      + {foreach name="statusList" item="vo"} + + {/foreach} +
      + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      + {:__('Key')} + {:__('Value')} +
      +
      {:__('Append')}
      + +
      + + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/school/message_config/index.html b/application/admin/view/school/message_config/index.html new file mode 100644 index 0000000..3454263 --- /dev/null +++ b/application/admin/view/school/message_config/index.html @@ -0,0 +1,46 @@ +
      + +
      + {:build_heading(null,FALSE)} + +
      + + +
      +
      +
      +
      +
      + + {:__('Add')} + {:__('Edit')} + {:__('Delete')} + + + + + {:__('Recycle bin')} +
      + +
      +
      +
      + +
      +
      +
      diff --git a/application/admin/view/school/message_config/recyclebin.html b/application/admin/view/school/message_config/recyclebin.html new file mode 100644 index 0000000..56e2c25 --- /dev/null +++ b/application/admin/view/school/message_config/recyclebin.html @@ -0,0 +1,25 @@ +
      + {:build_heading()} + +
      +
      +
      + +
      + +
      +
      +
      diff --git a/application/api/controller/school/Message.php b/application/api/controller/school/Message.php index 57afa73..7330bb5 100644 --- a/application/api/controller/school/Message.php +++ b/application/api/controller/school/Message.php @@ -69,7 +69,8 @@ class Message extends Base * @ApiParams(name = "limit", type = "string",required=true,description = "条数") * @ApiParams(name = "status", type = "string",required=false,description = "消息总类型:system=系统消息,classes=课程消息,order=订单消息") * @ApiParams(name = "mini_type", type = "string",required=false,description = "小消息类型:order_notice=课程订单通知,classes_auth=课程报名审核,classes_apply=课程上新审核,shop_apply=机构审核,classes_order_notice=课时预约,user_auth=机构授权用户信息,aftercare=售后服务,other=其他") - *@ApiParams(name = "type", type = "string",required=false,description = "已读状态:1=未读,2=已读") + * @ApiParams(name = "type", type = "string",required=false,description = "已读状态:1=未读,2=已读") + * @ApiParams(name = "time", type = "string",required=false,description = "复合时间查询:today今天,week本周,month本月,year本年,yesterday昨天,last year上一年,last week上周,last month上個月,lately7最近7天 , lately30最近30天,按开始时间区间查传值格式:Y/m/d H:M:S-Y/m/d H:M:S") * * @ApiReturn({ * @@ -86,11 +87,12 @@ class Message extends Base $status = $this->request->get('status/s', ''); //搜索关键字 $mini_type = $this->request->get('mini_type/s', ''); //搜索关键字 $type = $this->request->get('type/s', ''); //搜索关键字 + $time = $this->request->get('time/s', ''); //时间 // $type = $this->request->get('type/s', ''); //筛选学员和教练单 $to_id = $user_id; try{ //当前申请状态 - $res = $this->model::messageList($page, $limit,$to_id,$keywords,$status,$mini_type,$type); + $res = $this->model::messageList($page, $limit,$to_id,$keywords,$status,$mini_type,$type,$time); // if($user_id =='670153'){ // file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); // } diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index c8f5094..b0e0cad 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -118,6 +118,7 @@ class Backend extends Controller protected $have_auth = false; + protected $need_auth = false; protected $no_auth_fields = []; protected function no_auth_fields_check($params,$row){ diff --git a/application/common/controller/ManystoreBase.php b/application/common/controller/ManystoreBase.php index fa0fe0a..79e5eb2 100644 --- a/application/common/controller/ManystoreBase.php +++ b/application/common/controller/ManystoreBase.php @@ -123,6 +123,7 @@ class ManystoreBase extends Controller protected $have_auth = false; + protected $need_auth = false; protected $no_auth_fields = []; protected function no_auth_fields_check($params,$row){ diff --git a/application/common/listener/classes/ClassesHook.php b/application/common/listener/classes/ClassesHook.php index c571635..86450cd 100644 --- a/application/common/listener/classes/ClassesHook.php +++ b/application/common/listener/classes/ClassesHook.php @@ -27,6 +27,7 @@ class ClassesHook "event"=>"classes_auth_need_after", "classes_lib_id"=>$classes["id"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -54,6 +55,7 @@ class ClassesHook "event"=>"classes_auth_success_after", "classes_lib_id"=>$classes["id"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); } @@ -79,6 +81,7 @@ class ClassesHook "event"=>"classes_auth_success_after", "classes_lib_id"=>$classes["id"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); diff --git a/application/common/listener/classeshourorder/OrderHook.php b/application/common/listener/classeshourorder/OrderHook.php index c6a0f0d..455c6de 100644 --- a/application/common/listener/classeshourorder/OrderHook.php +++ b/application/common/listener/classeshourorder/OrderHook.php @@ -40,6 +40,7 @@ class OrderHook "order_id"=>$order["id"], "order_no"=>$order["order_no"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); } @@ -70,6 +71,7 @@ class OrderHook "order_id"=>$order["id"], "order_no"=>$order["order_no"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -104,6 +106,7 @@ class OrderHook "order_id"=>$order["id"], "order_no"=>$order["order_no"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); } @@ -135,6 +138,7 @@ class OrderHook "order_no"=>$order["order_no"], "reason"=>$order['reason'] ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -166,6 +170,7 @@ class OrderHook "order_id"=>$order["id"], "order_no"=>$order["order_no"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -199,6 +204,7 @@ class OrderHook "order_id"=>$order["id"], "order_no"=>$order["order_no"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); diff --git a/application/common/listener/classesorder/OrderHook.php b/application/common/listener/classesorder/OrderHook.php index ca68ebb..f524e09 100644 --- a/application/common/listener/classesorder/OrderHook.php +++ b/application/common/listener/classesorder/OrderHook.php @@ -34,6 +34,7 @@ class OrderHook "order_id"=>$order["id"], "order_no"=>$order["order_no"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -64,6 +65,7 @@ class OrderHook "order_no"=>$order["order_no"], "classes_lib_id"=>$order["classes_lib_id"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -94,6 +96,7 @@ class OrderHook "order_id"=>$order["id"], "order_no"=>$order["order_no"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); } @@ -122,6 +125,7 @@ class OrderHook "order_no"=>$order["order_no"], "classes_lib_id"=>$order["classes_lib_id"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); } diff --git a/application/common/listener/manystore/ShopHook.php b/application/common/listener/manystore/ShopHook.php index 47b4a7c..82edf23 100644 --- a/application/common/listener/manystore/ShopHook.php +++ b/application/common/listener/manystore/ShopHook.php @@ -67,6 +67,7 @@ class ShopHook "shop_id"=>$shop["id"], "desc"=>$shop["desc"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -102,6 +103,7 @@ class ShopHook "shop_id"=>$shop["id"], "desc"=>$shop["desc"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); @@ -131,6 +133,7 @@ class ShopHook "shop_id"=>$shop["id"], "desc"=>$shop["desc"], ]; + Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); diff --git a/application/common/model/BaseModel.php b/application/common/model/BaseModel.php index b029151..4735c09 100644 --- a/application/common/model/BaseModel.php +++ b/application/common/model/BaseModel.php @@ -77,7 +77,8 @@ class BaseModel extends Model public function no_auth_fields_check($params,$row){ - + $this->getTableFields(); + $params = $this->checkAssemblyParameters($params); foreach ($params as $k=>$v){ //说明数值有变动 @@ -87,7 +88,7 @@ class BaseModel extends Model if($row[$k]!=$params[$k]){ //当修改参数不在允许修改的字段中 if(!in_array($k,$this->no_auth_fields)){ - +// var_dump($row[$k],$params[$k]); $this->have_auth = true;break; } diff --git a/application/common/model/school/Message.php b/application/common/model/school/Message.php index 2899263..c127b38 100644 --- a/application/common/model/school/Message.php +++ b/application/common/model/school/Message.php @@ -131,6 +131,16 @@ class Message extends BaseModel return $this->belongsTo('app\admin\model\User', 'to_id', 'id', [], 'LEFT')->setEagerlyType(0); } + + public function messageevent() + { + return $this->belongsTo(MessageConfig::class, 'event', 'event', [], 'LEFT')->setEagerlyType(0); + } + + + + public static $event_name = ""; + /** 发送站内信 * @param $title 站内信标题 * @param $desc 内容 @@ -156,6 +166,7 @@ class Message extends BaseModel 'to_type' => $to_type, 'status' => $status, 'mini_type' => $mini_type, + "event" =>self::$event_name ?? "", ]; $message = new self(); $message->save($data); @@ -196,6 +207,8 @@ class Message extends BaseModel $data->save(); } + // + $data->messageevent; // //加载订单详情 // $data->detail->teacher; // //订单用户 @@ -247,7 +260,7 @@ class Message extends BaseModel if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']); if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}id|{$alisa}title|{$alisa}desc", '=', $whereData['keywords']); if (isset($whereData['time'])&&$whereData['time']){ - $model = $model->time($whereData['time']); + $model = $model->time(['createtime',$whereData['time']]); } if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}to_id", '=', $whereData['user_id']); @@ -268,7 +281,6 @@ class Message extends BaseModel $query->where("{$alisa}to_id", $whereData['to_id']) ->whereOr("{$alisa}to_id", '=', 0); }); - } @@ -305,9 +317,10 @@ class Message extends BaseModel - public static function messageList($page, $limit,$to_id,$keywords,$status,$mini_type,$type){ + public static function messageList($page, $limit,$to_id,$keywords,$status,$mini_type,$type,$time=null){ $with_field = [ 'user'=>['nickname','mobile','avatar','realname'], + 'messageevent'=>['event','logo_image'], 'base'=>['*'], // 'shop'=>['*'], // 'detail'=>['*'], @@ -316,7 +329,7 @@ class Message extends BaseModel $alisa = (new self)->getWithAlisaName(); $sort = "{$alisa}.weigh desc,{$alisa}.id desc"; // $sort = "field({$alisa}.type,'1','2') asc,{$alisa}.weigh desc,{$alisa}.id desc"; - $serch_where = ["to_id"=>$to_id,'platform'=>"user",'status'=>$status,'keywords'=>$keywords,"mini_type"=>$mini_type,"type"=>$type]; + $serch_where = ["to_id"=>$to_id,'platform'=>"user",'status'=>$status,'keywords'=>$keywords,"mini_type"=>$mini_type,"type"=>$type,"time"=>$time]; // if($type)$serch_where['type'] = $type; return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); } diff --git a/application/common/model/school/MessageConfig.php b/application/common/model/school/MessageConfig.php new file mode 100644 index 0000000..98dffce --- /dev/null +++ b/application/common/model/school/MessageConfig.php @@ -0,0 +1,107 @@ +getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + } + }); + } + + + public function getStatusList() + { + return ['1' => __('Status 1'), '2' => __('Status 2')]; + } + + public function getWechatWapList() + { + return ['1' => __('Wechat_wap 1'), '2' => __('Wechat_wap 2')]; + } + + public function getMessageList() + { + return ['1' => __('Message 1'), '2' => __('Message 2')]; + } + + public function getSelfmailList() + { + return ['1' => __('Selfmail 1'), '2' => __('Selfmail 2')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getWechatWapTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['wechat_wap']) ? $data['wechat_wap'] : ''); + $list = $this->getWechatWapList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getMessageTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['message']) ? $data['message'] : ''); + $list = $this->getMessageList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSelfmailTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['selfmail']) ? $data['selfmail'] : ''); + $list = $this->getSelfmailList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getLogoImageAttr($value, $data) + { + if (!empty($value)) return cdnurl($value, true); + } + + + + +} diff --git a/application/common/model/school/classes/ClassesLib.php b/application/common/model/school/classes/ClassesLib.php index 4452ea5..016aadb 100644 --- a/application/common/model/school/classes/ClassesLib.php +++ b/application/common/model/school/classes/ClassesLib.php @@ -872,6 +872,7 @@ $user_unpaid_order = $user_paid_order =null; if(!$this->no_auth_fields_check($params,$row)){ return true; } + } // 课程存在未完成订单则不允许操作 @@ -891,7 +892,7 @@ $user_unpaid_order = $user_paid_order =null; { $params["auth_status"] = $params["auth_status"] ?? '0'; $params["status"] = $params["status"] ?? '3'; - + if(!$shop_id)$shop_id = $params["shop_id"] ?? 0; $manystore = Manystore::where("shop_id",$shop_id)->find(); @@ -1008,23 +1009,77 @@ $user_unpaid_order = $user_paid_order =null; } + + //如果存在课程规格,验证每个课时规格的合法性 + if(isset($params["spec"])){ + //如果存在"的HTML转义字符,先反转义再解析json + $params["spec"] = html_entity_decode($params["spec"]); + $spec = json_decode($params["spec"],true); + if(empty($spec))throw new \Exception("请至少添加一个课时规格"); + + foreach ($spec as $k=>&$v){ + $v["classes_lib_id"] = $row->id; + (new ClassesSpec)->specCheck($v,$shop_id,empty($v["id"])? null : ClassesSpec::get($v["id"])); + + } + $params["spec"] = $spec; + } + }else{ //新增 //名称title不能重复 - $check_title = $this->model->where('title',$params["title"])->find(); + $check_title = self::where('title',$params["title"])->find(); if($check_title){ throw new \Exception("课程名称已存在或被其他机构占用,请更改!"); } + + + //如果存在课程规格,验证每个课时规格的合法性 + if(isset($params["spec"])){ + + $spec = json_decode($params["spec"],true); + if(empty($spec))throw new \Exception("请至少添加一个课时规格"); + + foreach ($spec as $k=>&$v){ + $v["classes_lib_id"] = 0; + (new ClassesSpec)->specCheck($v,$shop_id,null); + } + $params["spec"] = $spec; + } + } + $params["delete_spec_ids"] = []; + //按前端顺序分配显示权重 + if(isset($params["spec"]) && $params["spec"]){ + //数组倒过来 + $params["spec"] = array_reverse($params["spec"]); + $insert_spec = []; + foreach ($params["spec"] as $k=>&$v){ + $v["weigh"] = $k; + if(!empty($v["id"]))$insert_spec[] = $v["id"]; + } + if($insert_spec && $row){ + $params["delete_spec_ids"] = ClassesSpec::where("classes_lib_id",$row->id)->where("id","not in",$insert_spec)->column("id"); + } + } + + //存在需要删除的规格则判断规格是否能删除 + if($params["delete_spec_ids"] && $row){ + $check_spec = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row->id)->where("id","in",$params["delete_spec_ids"])->select(); + foreach ($check_spec as $k=>$vv){ + (new \app\common\model\school\classes\ClassesSpec)->updateCheck($vv->id); + } + $params["delete_spec_ids"] = $check_spec; + } + //如果是上架,判断是否拥有课时规格,没有则无法上架 - if($params["status"]=="1" && empty($params["spec"])){ + if(empty($params["spec"])){ if(!$row)throw new \Exception("新添加的课程请先至少添加一个课时规格后再上架!"); //判断是否拥有课时规格,没有则无法上架 $check_spec = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row->id)->count(); if(!$check_spec)throw new \Exception("新添加的课程请先至少添加一个课时规格后再上架!"); - } } diff --git a/application/common/model/school/classes/ClassesSpec.php b/application/common/model/school/classes/ClassesSpec.php index 7099501..6763d32 100644 --- a/application/common/model/school/classes/ClassesSpec.php +++ b/application/common/model/school/classes/ClassesSpec.php @@ -31,11 +31,11 @@ class ClassesSpec extends BaseModel 'status_text' ]; - + public $no_auth_fields = ['name','limit_num','status','weigh']; protected static function init() { self::afterInsert(function ($row) { - if (!$row['weigh']) { + if (empty($row['weigh'])) { $pk = $row->getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); } @@ -87,9 +87,9 @@ class ClassesSpec extends BaseModel } - protected function specupdateCheck($id,$params=[],$row=null){ + public function updateCheck($id,$params=[],$row=null){ if($params && $row){ - +// var_dump($this->no_auth_fields_check($params,$row)); if(!$this->no_auth_fields_check($params,$row)){ return true; } @@ -117,7 +117,7 @@ class ClassesSpec extends BaseModel if(empty($time))throw new \Exception("请选择开始和结束时间"); $split_line = " - "; $time_arr = explode($split_line,$time); - $params["start_time"] = $time_arr[0]; + $params["start_time"] = $time_arr[0] ; $params["end_time"] = $time_arr[1]; unset($params["time"]); @@ -138,14 +138,21 @@ class ClassesSpec extends BaseModel //结束时间不能是已经过去的时间 $now_time = time(); if($end_time<=$now_time){ - throw new \Exception("结束时间不能是已经过去的时间"); +// throw new \Exception("结束时间不能是已经过去的时间"); } + $params["start_time"] = $start_time; + $params["end_time"] = $end_time; + $orderTimeTableName = (new ClassesSpec)->getWithAlisaName(); //修改 if($row){ - $this->specupdateCheck($row->id,$params,$row); + //修复旧数据时间戳 + $row["start_time"]= strtotime(date("Y-m-d H:i",$row["start_time"])); + $row["end_time"]= strtotime(date("Y-m-d H:i",$row["end_time"])); + + $this->updateCheck($row->id,$params,$row); //规格名字不能一样(同课程下) $spec_name = $params["name"]; diff --git a/application/manystore/controller/school/classes/ClassesLib.php b/application/manystore/controller/school/classes/ClassesLib.php index 0b24f3c..aecaa8f 100644 --- a/application/manystore/controller/school/classes/ClassesLib.php +++ b/application/manystore/controller/school/classes/ClassesLib.php @@ -297,8 +297,16 @@ class ClassesLib extends ManystoreBase $this->model->validateFailException(true)->validate($validate); } $this->update_check($params,$row=null); + $spec = $params["spec"]; + unset($params["spec"]); $result = $this->model->allowField(true)->save($params); \app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]); + //添加课程规格 + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $this->model["id"]; + \app\common\model\school\classes\ClassesSpec::create($v); + } + $this->update_classes($this->model["id"]); if($this->have_auth){ //调用通过事件 @@ -422,9 +430,30 @@ class ClassesLib extends ManystoreBase $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException(true)->validate($validate); } + $this->update_check($params,$row); + $spec = $params["spec"] ?? [];//$params["delete_spec_ids"] + $delete_spec_ids = $params["delete_spec_ids"] ?? []; + unset($params["spec"]); + unset($params["delete_spec_ids"]); + $result = $row->allowField(true)->save($params); + + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $row["id"]; + //有id更新,否则新增 + if(isset($v["id"]) && $v["id"]){ + \app\common\model\school\classes\ClassesSpec::update((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + }else{ + \app\common\model\school\classes\ClassesSpec::create((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + } + } + //删除规格 + foreach ($delete_spec_ids as $k=>$delete_spec){ + $delete_spec->delete(); + } + $this->update_classes($row["id"]); if($this->have_auth){ @@ -454,6 +483,12 @@ class ClassesLib extends ManystoreBase } $this->error(__('Parameter %s can not be empty', '')); } + + $spec = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row["id"])->field("id,classes_lib_id,name,start_time,end_time,limit_num,status,weigh")->order('weigh desc,id desc')->select(); + foreach ($spec as $k=>&$v){ + $v["time"] = date("Y/m/d H:i",$v["start_time"])." - ".date("Y/m/d H:i",$v["end_time"]); + } + $row["spec"] = json_encode($spec, JSON_UNESCAPED_UNICODE);//不转义任何字符串 $this->view->assign("row", $row); return $this->view->fetch(); } diff --git a/application/manystore/controller/school/classes/ClassesSpec.php b/application/manystore/controller/school/classes/ClassesSpec.php index 66b9402..4795e0a 100644 --- a/application/manystore/controller/school/classes/ClassesSpec.php +++ b/application/manystore/controller/school/classes/ClassesSpec.php @@ -135,16 +135,28 @@ class ClassesSpec extends ManystoreBase try { - (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,SHOP_ID,$row); + + $classesLib = new \app\common\model\school\classes\ClassesSpec(); + $classesLib->no_auth_fields = $this->no_auth_fields; + $classesLib->need_auth = $this->need_auth; + $classesLib->have_auth = $this->have_auth; + $classesLib->specCheck($params,SHOP_ID,$row); + $this->need_auth = $classesLib->need_auth; + $this->have_auth = $classesLib->have_auth; + + //修改 + if($row){ + $classesLib->updateCheck($row->id,$params,$row); + }else{ + + } + +// (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,SHOP_ID,$row); }catch (\Exception $e){ $this->error($e->getMessage()); } - //修改 - if($row){ - $this->updateCheck($row->id,$params,$row); - }else{ - } + } diff --git a/application/manystore/view/school/classes/classes_lib/addnew.html b/application/manystore/view/school/classes/classes_lib/addnew.html index 37c9603..341befd 100644 --- a/application/manystore/view/school/classes/classes_lib/addnew.html +++ b/application/manystore/view/school/classes/classes_lib/addnew.html @@ -146,9 +146,9 @@ +
      +
      + + + + + +
      @@ -365,7 +417,7 @@
      - + diff --git a/application/manystore/view/school/classes/classes_lib/index.html b/application/manystore/view/school/classes/classes_lib/index.html index b4defc2..dbf4769 100644 --- a/application/manystore/view/school/classes/classes_lib/index.html +++ b/application/manystore/view/school/classes/classes_lib/index.html @@ -27,10 +27,10 @@
      - {:__('Add')} + - {:__('新版添加')}(开发中) + {:__('Add')} {:__('Edit')} {:__('Delete')} diff --git a/public/assets/js/backend/school/classes/classes_lib.js b/public/assets/js/backend/school/classes/classes_lib.js index 5a89925..6d07f0a 100644 --- a/public/assets/js/backend/school/classes/classes_lib.js +++ b/public/assets/js/backend/school/classes/classes_lib.js @@ -30,20 +30,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'operate', title: __('Operate'), table: table , buttons: [ - { - name: 'classes_spec', - text: __('设置课程规格'), - title: __('设置课程规格'), - classname: 'btn btn-xs btn-danger btn-magic btn-dialog', - icon: 'fa fa-list', - url: classes_spec_url, - callback: function (data) { - - }, - // visible: function (row) { - // return row.status == '2'||row.status == '3'; - // } - }, + // { + // name: 'classes_spec', + // text: __('设置课程规格'), + // title: __('设置课程规格'), + // classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + // icon: 'fa fa-list', + // url: classes_spec_url, + // callback: function (data) { + // + // }, + // // visible: function (row) { + // // return row.status == '2'||row.status == '3'; + // // } + // }, { name: 'virtual_user', text: __('设置虚拟参与者'), @@ -329,6 +329,38 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin Controller.api.bindevent(); }, edit: function () { + + //因为日期选择框不会触发change事件,导致无法刷新textarea,所以加上判断 + $(document).on("dp.change", "#edit-form .datetimerange", function () { + $(this).parent().prev().find("input").trigger("change"); + }); + + $(document).on("dp.change", "#edit-form .datetimepicker", function () { + $(this).parent().prev().find("input").trigger("change"); + }); + + $(document).on("fa.event.appendfieldlist", "#edit-form .btn-append", function (e, obj) { + // Form.api.bindevent($("form[role=form]")); + // // //绑定动态下拉组件 + Form.events.selectpage(obj); + // // //绑定日期组件 + Form.events.daterangepicker(obj); + Form.events.datetimepicker(obj); + Form.events.selectpicker(obj); + // Form.events.switcher(obj); + + // // Form.events.datetimerange(obj); + // Form.api.bindevent(this); + // //绑定上传组件 + // Form.events.faupload(obj); + + // //上传成功回调事件,变更按钮的背景 + // $(".upload-image", obj).data("upload-success", function (data) { + // $(this).css("background-image", "url('" + Fast.api.cdnurl(data.url) + "')"); + // }) + }); + + Controller.api.bindevent(); }, api: { diff --git a/public/assets/js/backend/school/message.js b/public/assets/js/backend/school/message.js index 56e2f5c..8d7e97a 100644 --- a/public/assets/js/backend/school/message.js +++ b/public/assets/js/backend/school/message.js @@ -31,19 +31,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'id', title: __('Id')}, {field: 'weigh', title: __('Weigh'), operate: false,sortable: true}, + {field: 'messageevent.logo_image', title: __('Logo_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal}, + {field: 'status', title: __('Status'), searchList: {"system":__('Status system'),"classes":__('Status classes'),"order":__('Status order')}, formatter: Table.api.formatter.status}, + {field: 'mini_type', title: __('Mini_type'), searchList: {"order_notice":__('Mini_type order_notice'),"classes_auth":__('Mini_type classes_auth'),"classes_apply":__('Mini_type classes_apply'),"shop_apply":__('Mini_type shop_apply'),"classes_order_notice":__('Mini_type classes_order_notice'),"user_auth":__('Mini_type user_auth'),"aftercare":__('Mini_type aftercare'),"other":__('Mini_type other')}, formatter: Table.api.formatter.normal}, + {field: 'event', title: __('Event'),visible:false, operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + + {field: 'platform', title: __('Platform'), searchList: {"admin":__('Platform admin'),"user":__('Platform user'),"shop":__('Platform shop')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label}, {field: 'oper_type', title: __('Oper_type'), searchList: {"admin":__('Oper_type admin'),"user":__('Oper_type user'),"system":__('Oper_type system'),"shop":__('Oper_type shop')}, formatter: Table.api.formatter.normal}, {field: 'oper_id', title: __('Oper_id')}, {field: 'to_type', title: __('To_type'), searchList: {"admin":__('To_type admin'),"user":__('To_type user'),"system":__('To_type system'),"shop":__('To_type shop')}, formatter: Table.api.formatter.normal}, {field: 'to_id', title: __('To_id')}, - {field: 'status', title: __('Status'), searchList: {"system":__('Status system'),"classes":__('Status classes'),"order":__('Status order')}, formatter: Table.api.formatter.status}, - {field: 'mini_type', title: __('Mini_type'), searchList: {"order_notice":__('Mini_type order_notice'),"classes_auth":__('Mini_type classes_auth'),"classes_apply":__('Mini_type classes_apply'),"shop_apply":__('Mini_type shop_apply'),"classes_order_notice":__('Mini_type classes_order_notice'),"user_auth":__('Mini_type user_auth'),"aftercare":__('Mini_type aftercare'),"other":__('Mini_type other')}, formatter: Table.api.formatter.normal}, - {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - // {field: 'params', title: __('Params'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + // {field: 'params', title: __('Params'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'admin.nickname', title: __('Admin.nickname'), operate: 'LIKE'}, {field: 'admin.avatar', title: __('Admin.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image}, diff --git a/public/assets/js/backend/school/message_config.js b/public/assets/js/backend/school/message_config.js new file mode 100644 index 0000000..3a5cf56 --- /dev/null +++ b/public/assets/js/backend/school/message_config.js @@ -0,0 +1,126 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'school/message_config/index' + location.search, + add_url: 'school/message_config/add', + edit_url: 'school/message_config/edit', + del_url: 'school/message_config/del', + multi_url: 'school/message_config/multi', + import_url: 'school/message_config/import', + table: 'school_message_config', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'weigh', + fixedColumns: true, + fixedRightNumber: 1, + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'event', title: __('Event'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'logo_image', title: __('Logo_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, + {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status}, + {field: 'wechat_wap', title: __('Wechat_wap'), searchList: {"1":__('Wechat_wap 1'),"2":__('Wechat_wap 2')}, formatter: Table.api.formatter.normal}, + {field: 'message', title: __('Message'), searchList: {"1":__('Message 1'),"2":__('Message 2')}, formatter: Table.api.formatter.normal}, + {field: 'selfmail', title: __('Selfmail'), searchList: {"1":__('Selfmail 1'),"2":__('Selfmail 2')}, formatter: Table.api.formatter.normal}, + {field: 'message_id', title: __('Message_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'wechat_wap_id', title: __('Wechat_wap_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'selfmail_title', title: __('Selfmail_title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'weigh', title: __('Weigh'), operate: false}, + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + recyclebin: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + 'dragsort_url': '' + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: 'school/message_config/recyclebin' + location.search, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'name', title: __('Name'), align: 'left'}, + { + field: 'deletetime', + title: __('Deletetime'), + operate: 'RANGE', + addclass: 'datetimerange', + formatter: Table.api.formatter.datetime + }, + { + field: 'operate', + width: '140px', + title: __('Operate'), + table: table, + events: Table.api.events.operate, + buttons: [ + { + name: 'Restore', + text: __('Restore'), + classname: 'btn btn-xs btn-info btn-ajax btn-restoreit', + icon: 'fa fa-rotate-left', + url: 'school/message_config/restore', + refresh: true + }, + { + name: 'Destroy', + text: __('Destroy'), + classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit', + icon: 'fa fa-times', + url: 'school/message_config/destroy', + refresh: true + } + ], + formatter: Table.api.formatter.operate + } + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); diff --git a/public/assets/js/manystore/school/classes/classes_lib.js b/public/assets/js/manystore/school/classes/classes_lib.js index 46a513e..8b058a8 100644 --- a/public/assets/js/manystore/school/classes/classes_lib.js +++ b/public/assets/js/manystore/school/classes/classes_lib.js @@ -29,34 +29,34 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'operate', title: __('Operate'), table: table , buttons: [ - { - name: 'classes_spec', - text: __('设置课程规格'), - title: __('设置课程规格'), - classname: 'btn btn-xs btn-danger btn-magic btn-dialog', - icon: 'fa fa-list', - url: classes_spec_url, - callback: function (data) { - - }, - // visible: function (row) { - // return row.status == '2'||row.status == '3'; - // } - }, - { - name: 'virtual_user', - text: __('设置虚拟参与者'), - title: __('设置虚拟参与者'), - classname: 'btn btn-xs btn-primary btn-dialog', - icon: 'fa fa-list', - url: virtual_user_url, - callback: function (data) { - - }, - // visible: function (row) { - // return row.status == '2'||row.status == '3'; - // } - }, + // { + // name: 'classes_spec', + // text: __('设置课程规格'), + // title: __('设置课程规格'), + // classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + // icon: 'fa fa-list', + // url: classes_spec_url, + // callback: function (data) { + // + // }, + // // visible: function (row) { + // // return row.status == '2'||row.status == '3'; + // // } + // }, + // { + // name: 'virtual_user', + // text: __('设置虚拟参与者'), + // title: __('设置虚拟参与者'), + // classname: 'btn btn-xs btn-primary btn-dialog', + // icon: 'fa fa-list', + // url: virtual_user_url, + // callback: function (data) { + // + // }, + // // visible: function (row) { + // // return row.status == '2'||row.status == '3'; + // // } + // }, { name: 'teacher', text: __('主讲老师信息'), @@ -332,6 +332,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin generrate.setOfflineType($("input:radio[name='row[address_type]']").val()); }, edit: function () { + + //因为日期选择框不会触发change事件,导致无法刷新textarea,所以加上判断 + $(document).on("dp.change", "#edit-form .datetimerange", function () { + $(this).parent().prev().find("input").trigger("change"); + }); + + $(document).on("dp.change", "#edit-form .datetimepicker", function () { + $(this).parent().prev().find("input").trigger("change"); + }); + + $(document).on("fa.event.appendfieldlist", "#edit-form .btn-append", function (e, obj) { + // Form.api.bindevent($("form[role=form]")); + // // //绑定动态下拉组件 + Form.events.selectpage(obj); + // // //绑定日期组件 + Form.events.daterangepicker(obj); + Form.events.datetimepicker(obj); + // // Form.events.datetimerange(obj); + // Form.api.bindevent(this); + // //绑定上传组件 + // Form.events.faupload(obj); + + // //上传成功回调事件,变更按钮的背景 + // $(".upload-image", obj).data("upload-success", function (data) { + // $(this).css("background-image", "url('" + Fast.api.cdnurl(data.url) + "')"); + // }) + }); + + Controller.api.bindevent(); }, api: {