Vplatform.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace app\admin\controller\platform;
  3. use app\common\controller\Backend;
  4. use app\common\model\Videolist;
  5. use app\common\model\Platform;
  6. class Vplatform extends Backend
  7. {
  8. protected $model = null;
  9. public function _initialize()
  10. {
  11. parent::_initialize();
  12. $this->model = new \app\common\model\VideoPlatform;
  13. // 获取短剧和平台数据(用于下拉框)
  14. // $videolist = Videolist::column('id,name');
  15. // $platforms = Platform::column('id,name');
  16. // $this->assign('videolist', $videolist);
  17. // $this->assign('platforms', $platforms);
  18. }
  19. // 列表页
  20. // application/admin/controller/platform/Vplatform.php
  21. public function index()
  22. {
  23. $this->request->filter(['strip_tags']);
  24. if ($this->request->isAjax()) {
  25. //如果发送的来源是Selectpage,则转发到Selectpage
  26. if ($this->request->request('keyField')) {
  27. return $this->selectpage();
  28. }
  29. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  30. $total = $this->model
  31. ->where($where)
  32. ->order($sort, $order)
  33. ->count();
  34. $list = $this->model
  35. ->where($where)
  36. ->order($sort, $order)
  37. ->limit($offset, $limit)
  38. ->select();
  39. $result = array("total" => $total, "rows" => $list);
  40. return json($result);
  41. }
  42. return $this->view->fetch();
  43. }
  44. /**
  45. * 编辑
  46. */
  47. public function edit($ids = NULL)
  48. {
  49. $row = $this->model->get($ids);
  50. if (!$row)
  51. $this->error(__('No Results were found'));
  52. return parent::edit($ids);
  53. }
  54. public function add()
  55. {
  56. return parent::add();
  57. }
  58. // public function dragsort()
  59. // {
  60. // if ($this->request->isPost()) {
  61. // $ids = $this->request->post('ids');
  62. // // 根据 $ids 更新排序逻辑(示例代码)
  63. // foreach ($ids as $index => $id) {
  64. // $this->model::where('id', $id)->update(['sort' => $index + 1]);
  65. // }
  66. // $this->success();
  67. // }
  68. // $this->error(__('参数错误'));
  69. // }
  70. // // 添加
  71. // public function add()
  72. // {
  73. // if ($this->request->isPost()) {
  74. // $params = $this->request->post("row/a");
  75. // if ($params) {
  76. // $result = $this->model->save($params);
  77. // if ($result) $this->success();
  78. // $this->error(__('操作失败'));
  79. // }
  80. // $this->error(__('参数错误'));
  81. // }
  82. // return $this->view->fetch();
  83. // }
  84. //
  85. // // 编辑
  86. // public function edit($ids = null)
  87. // {
  88. // $row = $this->model->get($ids);
  89. // if (!$row) $this->error(__('记录不存在'));
  90. // if ($this->request->isPost()) {
  91. // $params = $this->request->post("row/a");
  92. // if ($params) {
  93. // $result = $row->save($params);
  94. // if ($result) $this->success();
  95. // $this->error(__('操作失败'));
  96. // }
  97. // $this->error(__('参数错误'));
  98. // }
  99. // $this->assign('row', $row);
  100. // return $this->view->fetch();
  101. // }
  102. }