<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                繼續以文章分類為例,我們在/application/cms/controller/admin/目錄下創建Cate.php文件,注意這里我們就會用到很重要的一個特性:動態頁面,我們不需要去寫.vue,只要在這里編寫PHP代碼即可自動解析生頁面,內容如下: ![](https://img.kancloud.cn/4a/9c/4a9c74b21cee0d9ea83d6495f4e8bffb_1100x745.png) ``` <?php /** * +---------------------------------------------------------------------- * | UniAdmin?[?漸進式模塊化通用后臺?] * +---------------------------------------------------------------------- * | Copyright (c) 2018-2020 http://uniadmin.jiangruyi.com All rights reserved. * +---------------------------------------------------------------------- * | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) * +---------------------------------------------------------------------- * | Author: jry <ijry@qq.com> * +---------------------------------------------------------------------- */ namespace app\cms\controller\admin; use think\Db; use think\Validate; use think\facade\Request; use app\core\controller\common\Admin; use app\core\util\Tree; /** * 文章分類 * * @author jry <ijry@qq.com> */ class Cate extends Admin { private $example_cate; protected function initialize() { parent::initialize(); $this->cms_cate = new \app\cms\model\Cate(); } /** * 分類列表 * * @return \think\Response * @author jry <ijry@qq.com> */ public function lists() { //分類列表 $data_list = $this->example_cate->select()->toArray(); $tree = new Tree(); $data_list = $tree->list2tree($data_list); //構造動態頁面數據 $ibuilder_list = new \app\core\util\xybuilder\XyBuilderList(); $list_data = $ibuilder_list->init() ->addTopButton('add', '添加分類', ['api' => '/v1/admin/example/cate/add']) ->addRightButton('edit', '修改', ['api' => '/v1/admin//example/cate/edit', 'title' => '修改分類信息']) ->addRightButton('delete', '刪除', [ 'api' => '/v1/admin//example/cate/delete', 'title' => '確認要刪除該分類嗎?', 'modal_type' => 'confirm', 'width' => '600', 'okText' => '確認刪除', 'cancelText' => '取消操作', 'content' => '<p>刪除后前臺將無法訪問</p>', ]) ->addColumn('id' , 'ID', ['width' => '50px']) ->addColumn('nickname', '昵稱', ['width' => '120px']) ->addColumn('username', '用戶名', ['width' => '120px']) ->addColumn('mobile', '手機號', ['width' => '120px']) ->addColumn('email', '郵箱', ['width' => '120px']) ->addColumn('sortnum', '排序', ['width' => '50px']) ->addColumn('rightButtonList', '操作', [ 'minWidth' => '50px', 'type' => 'template', 'template' => 'right_button_list' ]) ->getData(); //返回數據 return json([ 'code' => 200, 'msg' => '成功', 'data' => [ 'dataList' => $data_list, 'listData' => $list_data ] ]); } /** * 添加 * * @return \think\Response * @author jry <ijry@qq.com> */ public function add() { if (request()->isPost()) { //數據驗證 $validate = Validate::make([ 'title' => 'require' ], [ 'title.require' => '分類標題必須' ]); $data = input('post.'); if (!$validate->check($data)) { return json(['code' => 200, 'msg' => $validate->getError(), 'data' => []]); } //數據構造 $data_db = $data; if (count($data_db) <= 0 ) { return json(['code' => 0, 'msg' => '無數據提交', 'data' => []]); } $data_db['status'] = 1; $data_db['create_time'] = time(); //存儲數據 $ret = $this->example_cate->save($data_db); if ($ret) { return json(['code' => 200, 'msg' => '添加成功', 'data' => []]); } else { return json(['code' => 0, 'msg' => '添加失敗:' . $this->core_user->getError(), 'data' => []]); } } else { //構造動態頁面數據 $ibuilder_form = new \app\core\util\xybuilder\XybuilderForm(); $form_data = $ibuilder_form->init() ->setFormMethod('post') ->addFormItem('title', '標題', 'text', '', [ 'placeholder' => '請輸入標題', 'tip' => '分類標題' ]) ->addFormRule('title', [ ['required' => true, 'message' => '請填寫標題', 'trigger' => 'change'], ]) ->setFormValues() ->getData(); //返回數據 return json([ 'code' => 200, 'msg' => '成功', 'data' => [ 'formData' => $form_data ] ]); } } /** * 修改 * * @return \think\Response * @author jry <ijry@qq.com> */ public function edit($id) { if (request()->isPut()) { //數據驗證 $validate = Validate::make([ 'title' => 'require' ], [ 'title.require' => '標題必須' ]); $data = input('post.'); if (!$validate->check($data)) { return json(['code' => 200, 'msg' => $validate->getError(), 'data' => []]); } //數據構造 $data_db = $data; if (count($data_db) <= 0 ) { return json(['code' => 0, 'msg' => '無數據提交', 'data' => []]); } //存儲數據 $ret = $this->example_cate->update($data_db, ['id' => $id]); if ($ret) { return json(['code' => 200, 'msg' => '修改信息成功', 'data' => []]); } else { return json(['code' => 0, 'msg' => '修改信息失敗:' . $this->core_user->getError(), 'data' => []]); } } else { //用戶信息 $info = $this->core_user ->where('id', $id) ->find(); //構造動態頁面數據 $ibuilder_form = new \app\core\util\xybuilder\XyBuilderForm(); $form_data = $ibuilder_form->init() ->setFormMethod('put') ->addFormItem('title', '標題', 'text', $info['title'], [ 'placeholder' => '請輸入標題', 'tip' => '分類標題' ]) ->addFormRule('title', [ ['required' => true, 'message' => '請填寫標題', 'trigger' => 'change'], ]) ->setFormValues() ->getData(); //返回數據 return json([ 'code' => 200, 'msg' => '成功', 'data' => [ 'formData' => $form_data ] ]); } } /** * 刪除 * * @return \think\Response * @author jry <ijry@qq.com> */ public function delete($id) { //刪除 $ret = $this->example_cate ->where(['id' => $id]) ->find() ->delete(); if ($ret) { return json(['code' => 200, 'msg' => '刪除成功', 'data' => []]); } else { return json(['code' => 0, 'msg' => '刪除錯誤:' . $this->core_user->getError(), 'data' => []]); } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看