From 32c894d4412a88176b4eef85fd0842b996809132 Mon Sep 17 00:00:00 2001 From: blobt <380255922@qq.com> Date: Mon, 19 Aug 2019 20:42:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=BC=80=E5=8F=91DatePicker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +- composer.lock | 109 +-------------------- console/controllers/InitController.php | 2 +- kcadmin/controllers/CategoryController.php | 44 +++++---- kcadmin/views/category/_form.php | 17 ++-- kcadmin/views/category/_search.php | 10 +- kcadmin/views/category/create.php | 7 +- kcadmin/views/category/index.php | 21 +++- kcadmin/views/category/update.php | 13 ++- 9 files changed, 71 insertions(+), 155 deletions(-) diff --git a/composer.json b/composer.json index d3ffece..768fceb 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,7 @@ "require": { "php": ">=7.1.0", "yiisoft/yii2": "~2.0.14", - "yiisoft/yii2-bootstrap": "^2.0@dev", - "kartik-v/yii2-date-range": "^1.7@dev" + "yiisoft/yii2-bootstrap": "^2.0@dev" }, "repositories": { "asset_packagist": { diff --git a/composer.lock b/composer.lock index 3c2e96a..c59a1f7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ddd66f4b0e8258bef7d2931651335239", + "content-hash": "f3ddaead9bc7b0924e8f9ccf68c842ff", "packages": [ { "name": "bower-asset/bootstrap", @@ -322,112 +322,6 @@ ], "time": "2018-02-23T01:58:20+00:00" }, - { - "name": "kartik-v/yii2-date-range", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/kartik-v/yii2-date-range.git", - "reference": "c8ed362fb201d17a1b84d4de3a4c7b0be8e0d7c1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-date-range/zipball/c8ed362fb201d17a1b84d4de3a4c7b0be8e0d7c1", - "reference": "c8ed362fb201d17a1b84d4de3a4c7b0be8e0d7c1", - "shasum": "" - }, - "require": { - "kartik-v/yii2-krajee-base": ">=2.0.0" - }, - "type": "yii2-extension", - "extra": { - "branch-alias": { - "dev-master": "1.7.x-dev" - } - }, - "autoload": { - "psr-4": { - "kartik\\daterange\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kartik Visweswaran", - "email": "kartikv2@gmail.com", - "homepage": "http://www.krajee.com/" - } - ], - "description": "An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.", - "homepage": "https://github.com/kartik-v/yii2-date-range", - "keywords": [ - "bootstrap", - "bootstrap 3", - "date", - "date-range", - "extension", - "range", - "time", - "widget", - "yii2" - ], - "time": "2019-05-17T12:35:38+00:00" - }, - { - "name": "kartik-v/yii2-krajee-base", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/kartik-v/yii2-krajee-base.git", - "reference": "8aa48bb2e7613db45b3c34f7a9346d7f43b1f4ec" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-krajee-base/zipball/8aa48bb2e7613db45b3c34f7a9346d7f43b1f4ec", - "reference": "8aa48bb2e7613db45b3c34f7a9346d7f43b1f4ec", - "shasum": "" - }, - "suggest": { - "yiisoft/yii2-bootstrap": "for Krajee extensions to work with Bootstrap 3.x version", - "yiisoft/yii2-bootstrap4": "for Krajee extensions to work with Bootstrap 4.x version" - }, - "type": "yii2-extension", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "kartik\\base\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kartik Visweswaran", - "email": "kartikv2@gmail.com", - "homepage": "http://www.krajee.com/" - } - ], - "description": "Base library and foundation components for all Yii2 Krajee extensions.", - "homepage": "https://github.com/kartik-v/yii2-krajee-base", - "keywords": [ - "base", - "extension", - "foundation", - "krajee", - "widget", - "yii2" - ], - "time": "2019-05-25T07:25:02+00:00" - }, { "name": "yiisoft/yii2", "version": "dev-master", @@ -869,7 +763,6 @@ "minimum-stability": "dev", "stability-flags": { "yiisoft/yii2-bootstrap": 20, - "kartik-v/yii2-date-range": 20, "yiisoft/yii2-debug": 20, "kint-php/kint": 20, "yiisoft/yii2-gii": 20 diff --git a/console/controllers/InitController.php b/console/controllers/InitController.php index 67579be..d0ee181 100644 --- a/console/controllers/InitController.php +++ b/console/controllers/InitController.php @@ -20,7 +20,7 @@ class InitController extends Controller { public function actionIndex() { echo "index\n"; Category::deleteAll(); - for ($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 1000000; $i++) { $model = new Category(); $model->attributes = [ "cat_name" => "这是一个测试分类{$i}", diff --git a/kcadmin/controllers/CategoryController.php b/kcadmin/controllers/CategoryController.php index 0bbc472..f3c995c 100644 --- a/kcadmin/controllers/CategoryController.php +++ b/kcadmin/controllers/CategoryController.php @@ -12,13 +12,12 @@ use yii\filters\VerbFilter; /** * CategoryController implements the CRUD actions for Category model. */ -class CategoryController extends Controller -{ +class CategoryController extends Controller { + /** * {@inheritdoc} */ - public function behaviors() - { + public function behaviors() { return [ 'verbs' => [ 'class' => VerbFilter::className(), @@ -33,14 +32,13 @@ class CategoryController extends Controller * Lists all Category models. * @return mixed */ - public function actionIndex() - { + public function actionIndex() { $searchModel = new CategorySearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, ]); } @@ -50,10 +48,9 @@ class CategoryController extends Controller * @return mixed * @throws NotFoundHttpException if the model cannot be found */ - public function actionView($id) - { + public function actionView($id) { return $this->render('view', [ - 'model' => $this->findModel($id), + 'model' => $this->findModel($id), ]); } @@ -62,8 +59,7 @@ class CategoryController extends Controller * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ - public function actionCreate() - { + public function actionCreate() { $model = new Category(); if ($model->load(Yii::$app->request->post()) && $model->save()) { @@ -71,7 +67,7 @@ class CategoryController extends Controller } return $this->render('create', [ - 'model' => $model, + 'model' => $model, ]); } @@ -82,8 +78,7 @@ class CategoryController extends Controller * @return mixed * @throws NotFoundHttpException if the model cannot be found */ - public function actionUpdate($id) - { + public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { @@ -91,7 +86,7 @@ class CategoryController extends Controller } return $this->render('update', [ - 'model' => $model, + 'model' => $model, ]); } @@ -102,13 +97,20 @@ class CategoryController extends Controller * @return mixed * @throws NotFoundHttpException if the model cannot be found */ - public function actionDelete($id) - { + public function actionDelete($id) { $this->findModel($id)->delete(); return $this->redirect(['index']); } + /** + * + */ + public function actionDeletes() { + //获取前端post的记录id + $ids = Yii::$app->request->post('ids'); + } + /** * Finds the Category model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. @@ -116,12 +118,12 @@ class CategoryController extends Controller * @return Category the loaded model * @throws NotFoundHttpException if the model cannot be found */ - protected function findModel($id) - { + protected function findModel($id) { if (($model = Category::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException('The requested page does not exist.'); } + } diff --git a/kcadmin/views/category/_form.php b/kcadmin/views/category/_form.php index a26664e..da00c27 100644 --- a/kcadmin/views/category/_form.php +++ b/kcadmin/views/category/_form.php @@ -8,9 +8,11 @@ use yii\widgets\ActiveForm; /* @var $form yii\widgets\ActiveForm */ ?> -
- + + +
+ field($model, 'cat_name')->textInput(['maxlength' => true]) ?> @@ -26,10 +28,11 @@ use yii\widgets\ActiveForm; field($model, 'updated_at')->textInput() ?> -
- 'btn btn-success']) ?> -
+
+ + + - -
diff --git a/kcadmin/views/category/_search.php b/kcadmin/views/category/_search.php index fe487cb..03e5587 100644 --- a/kcadmin/views/category/_search.php +++ b/kcadmin/views/category/_search.php @@ -18,7 +18,7 @@ $form = ActiveForm::begin([ ]); ?> -
+
field($model, 'cat_name', [ @@ -44,11 +44,11 @@ $form = ActiveForm::begin([ ] ])->widget(DateRangePicker::className()); ?> +
+ ', ['class' => 'btn btn-default']) ?> + ', ['class' => 'btn btn-default']) ?> +
-
- ', ['class' => 'btn btn-default']) ?> - ', ['class' => 'btn btn-default']) ?> -
diff --git a/kcadmin/views/category/create.php b/kcadmin/views/category/create.php index 48abbb7..ccfed85 100644 --- a/kcadmin/views/category/create.php +++ b/kcadmin/views/category/create.php @@ -9,9 +9,10 @@ $this->title = 'Create Category'; $this->params['breadcrumbs'][] = ['label' => 'Categories', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> -
- -

title) ?>

+
+
+

title) ?>

+
render('_form', [ 'model' => $model, diff --git a/kcadmin/views/category/index.php b/kcadmin/views/category/index.php index b24015f..74efc5d 100644 --- a/kcadmin/views/category/index.php +++ b/kcadmin/views/category/index.php @@ -16,9 +16,24 @@ $this->params['breadcrumbs'][] = $this->title;
$this->render("_search", ['model' => $searchModel]), 'dataProvider' => $dataProvider, + 'filter' => $this->render("_search", ['model' => $searchModel]), + 'batch' => [ + [ + "label" => "删除", + "url" => "/category/deletes" + ], + [ + "label" => "其它操作", + "url" => "/category/others" + ], + ], 'columns' => [ + [ + 'class' => 'blobt\grid\CheckboxColumn', + 'width' => '2%', + 'align' => 'center' + ], [ 'attribute' => 'id', 'width' => '5%', @@ -44,15 +59,15 @@ $this->params['breadcrumbs'][] = $this->title; ], [ 'attribute' => 'description', + 'enableSorting' => false, 'format' => 'ntext', 'width' => '50%', ], [ - 'class' => 'yii\grid\ActionColumn', + 'class' => 'blobt\grid\ActionColumn', ], ], ]); - ?>
\ No newline at end of file diff --git a/kcadmin/views/category/update.php b/kcadmin/views/category/update.php index 09a7500..e4bd260 100644 --- a/kcadmin/views/category/update.php +++ b/kcadmin/views/category/update.php @@ -10,12 +10,15 @@ $this->params['breadcrumbs'][] = ['label' => 'Categories', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Update'; ?> -
+
+
+

title) ?>

+
-

title) ?>

- - render('_form', [ + render('_form', [ 'model' => $model, - ]) ?> + ]) + ?>