Browse Source

开始开发DatePicker

wechat_public_accounts
blobt 5 years ago
parent
commit
32c894d441
  1. 3
      composer.json
  2. 109
      composer.lock
  3. 2
      console/controllers/InitController.php
  4. 34
      kcadmin/controllers/CategoryController.php
  5. 9
      kcadmin/views/category/_form.php
  6. 8
      kcadmin/views/category/_search.php
  7. 7
      kcadmin/views/category/create.php
  8. 21
      kcadmin/views/category/index.php
  9. 13
      kcadmin/views/category/update.php

3
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": {

109
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

2
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}",

34
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,8 +32,7 @@ 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);
@ -50,8 +48,7 @@ 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),
]);
@ -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()) {
@ -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()) {
@ -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.');
}
}

9
kcadmin/views/category/_form.php

@ -8,10 +8,12 @@ use yii\widgets\ActiveForm;
/* @var $form yii\widgets\ActiveForm */
?>
<div class="category-form">
<?php $form = ActiveForm::begin(); ?>
<div class="box-body">
<?= $form->field($model, 'cat_name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'icon')->textInput(['maxlength' => true]) ?>
@ -26,10 +28,11 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'updated_at')->textInput() ?>
<div class="form-group">
</div>
<div class="box-footer">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

8
kcadmin/views/category/_search.php

@ -18,7 +18,7 @@ $form = ActiveForm::begin([
]);
?>
<div class="col-sm-10">
<div class="col-sm-12">
<div class="dataTables_filter">
<?=
$form->field($model, 'cat_name', [
@ -44,11 +44,11 @@ $form = ActiveForm::begin([
]
])->widget(DateRangePicker::className());
?>
</div>
</div>
<div class="col-sm-2" style="padding: 0;">
<div class="form-group">
<?= Html::submitButton('<i class="fa fa-filter"></i>', ['class' => 'btn btn-default']) ?>
<?= Html::resetButton('<i class="fa fa-eraser"></i>', ['class' => 'btn btn-default']) ?>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>

7
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;
?>
<div class="category-create">
<h1><?= Html::encode($this->title) ?></h1>
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title"><?= Html::encode($this->title) ?></h3>
</div>
<?= $this->render('_form', [
'model' => $model,

21
kcadmin/views/category/index.php

@ -16,9 +16,24 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="col-xs-12">
<?php
echo GridView::widget([
'filter' => $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',
],
],
]);
?>
</div>
</div>

13
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';
?>
<div class="category-update">
<h1><?= Html::encode($this->title) ?></h1>
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title"><?= Html::encode($this->title) ?></h3>
</div>
<?= $this->render('_form', [
<?=
$this->render('_form', [
'model' => $model,
]) ?>
])
?>
</div>
Loading…
Cancel
Save