diff --git a/common/models/Category.php b/common/models/Category.php index 3dcc1e2..e54bd84 100644 --- a/common/models/Category.php +++ b/common/models/Category.php @@ -2,6 +2,7 @@ namespace common\models; +use iron\wegets\Upload; use Yii; use yii\behaviors\TimestampBehavior; @@ -17,7 +18,8 @@ use yii\behaviors\TimestampBehavior; * @property int $created_at * @property int $updated_at */ -class Category extends \yii\db\ActiveRecord { +class Category extends \yii\db\ActiveRecord +{ const ICON_TYPE_BOOSTARAP = 1; const ICON_TYPE_AWESOME = 2; @@ -30,16 +32,18 @@ class Category extends \yii\db\ActiveRecord { /** * {@inheritdoc} */ - public static function tableName() { + public static function tableName() + { return 'category'; } /** * {@inheritdoc} */ - public function rules() { + public function rules() + { return [ - [['icon_type','cat_name','created_at'], 'required'], + [['icon_type', 'cat_name', 'created_at'], 'required'], [['icon_type', 'sort_order', 'created_at', 'updated_at'], 'integer'], [['description'], 'string'], [['cat_name', 'icon'], 'string', 'max' => 64], @@ -49,7 +53,8 @@ class Category extends \yii\db\ActiveRecord { /** * {@inheritdoc} */ - public function attributeLabels() { + public function attributeLabels() + { return [ 'id' => 'ID', 'cat_name' => '类名', @@ -62,7 +67,56 @@ class Category extends \yii\db\ActiveRecord { ]; } - public function behaviors() { + /** + * @return array + * 列格式 + */ + public static function columns() + { + return [ + [ + 'class' => 'blobt\grid\CheckboxColumn', + 'width' => '2%', + 'align' => 'center' + ], + [ + 'attribute' => 'id', + 'width' => '10%', + 'align' => 'center' + ], + [ + 'attribute' => 'created_at', + 'width' => '10%', + 'format' => 'date' + ], + [ + 'attribute' => 'cat_name', + 'width' => '10%', + ], + [ + 'attribute' => 'icon', + 'width' => '10%', + ], + [ + 'attribute' => 'icon_type', + 'width' => '10%', + 'showConstText' => true + ], + [ + 'attribute' => 'description', + 'enableSorting' => false, + 'format' => 'ntext', + 'width' => '20%', + ], + [ + 'class' => 'iron\grid\ActionColumn', + 'align' => 'center', + ], + ]; + } + + public function behaviors() + { return [ TimestampBehavior::className() ]; diff --git a/common/models/CategorySearch.php b/common/models/CategorySearch.php index e9f8725..e49e616 100644 --- a/common/models/CategorySearch.php +++ b/common/models/CategorySearch.php @@ -2,25 +2,30 @@ namespace common\models; +use common\models\Category; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\models\Category; use yii\helpers\ArrayHelper; /** * CategorySearch represents the model behind the search form of `\common\models\Category`. */ -class CategorySearch extends Category { - public $imagefile; - - public function attributes() { +class CategorySearch extends Category +{ + /** + * @return array + * 增加创建时间查询字段 + */ + public function attributes() + { return ArrayHelper::merge(['created_at_range'], parent::attributes()); } /** * {@inheritdoc} */ - public function rules() { + public function rules() + { return [ [['id', 'icon_type', 'sort_order', 'created_at', 'updated_at'], 'integer'], [['cat_name', 'icon', 'description', 'created_at_range'], 'safe'], @@ -30,11 +35,29 @@ class CategorySearch extends Category { /** * {@inheritdoc} */ - public function scenarios() { + public function scenarios() + { // bypass scenarios() implementation in the parent class return Model::scenarios(); } + /** + * @param $params + * @return ActiveDataProvider + * 不分页的所有数据 + */ + public function allData($params) + { + $query = Category::find(); + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'pagination' => false, + 'sort' => false + ]); + $this->load($params); + return $this->filter($query, $dataProvider); + } + /** * Creates data provider instance with search query applied * @@ -42,7 +65,8 @@ class CategorySearch extends Category { * * @return ActiveDataProvider */ - public function search($params) { + public function search($params) + { $query = Category::find(); // add conditions that should always apply here @@ -58,8 +82,18 @@ class CategorySearch extends Category { ] ], ]); - $this->load($params); + return $this->filter($query, $dataProvider); + } + + /** + * @param $query + * @param $dataProvider + * @return ActiveDataProvider + * 条件筛选 + */ + private function filter($query, $dataProvider) + { if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails @@ -67,7 +101,7 @@ class CategorySearch extends Category { return $dataProvider; } - // grid filtering conditions +// grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, 'icon_type' => $this->icon_type, @@ -77,8 +111,8 @@ class CategorySearch extends Category { ]); $query->andFilterWhere(['like', 'cat_name', $this->cat_name]) - ->andFilterWhere(['like', 'icon', $this->icon]) - ->andFilterWhere(['like', 'description', $this->description]); + ->andFilterWhere(['like', 'icon', $this->icon]) + ->andFilterWhere(['like', 'description', $this->description]); if ($this->created_at_range) { $arr = explode(' ~ ', $this->created_at_range); diff --git a/composer.json b/composer.json index 3719903..0c1c701 100755 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "require": { "php": ">=7.1.0", "yiisoft/yii2": "~2.0.14", - "yiisoft/yii2-bootstrap": "^2.0@dev", + "yiisoft/yii2-bootstrap4": "~2.0.6", "moonlandsoft/yii2-phpexcel": "*" }, "repositories": { diff --git a/composer.lock b/composer.lock index c59a1f7..4717707 100644 --- a/composer.lock +++ b/composer.lock @@ -4,58 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f3ddaead9bc7b0924e8f9ccf68c842ff", + "content-hash": "0b877f5de588db414192c9663665b6d1", "packages": [ - { - "name": "bower-asset/bootstrap", - "version": "v3.4.1", - "source": { - "type": "git", - "url": "https://github.com/twbs/bootstrap.git", - "reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twbs/bootstrap/zipball/68b0d231a13201eb14acd3dc84e51543d16e5f7e", - "reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e", - "shasum": "" - }, - "require": { - "bower-asset/jquery": ">=1.9.1,<4.0" - }, - "type": "bower-asset-library", - "extra": { - "bower-asset-main": [ - "less/bootstrap.less", - "dist/js/bootstrap.js" - ], - "bower-asset-ignore": [ - "/.*", - "_config.yml", - "CNAME", - "composer.json", - "CONTRIBUTING.md", - "docs", - "js/tests", - "test-infra" - ] - }, - "license": [ - "MIT" - ], - "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", - "keywords": [ - "css", - "framework", - "front-end", - "js", - "less", - "mobile-first", - "responsive", - "web" - ], - "time": "2019-02-13T15:55:38+00:00" - }, { "name": "bower-asset/inputmask", "version": "3.3.11", @@ -121,7 +71,7 @@ "version": "3.4.1", "source": { "type": "git", - "url": "https://github.com/jquery/jquery-dist.git", + "url": "git@github.com:jquery/jquery-dist.git", "reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d" }, "dist": { @@ -277,23 +227,23 @@ }, { "name": "ezyang/htmlpurifier", - "version": "v4.10.0", + "version": "v4.12.0", "source": { "type": "git", "url": "https://github.com/ezyang/htmlpurifier.git", - "reference": "d85d39da4576a6934b72480be6978fb10c860021" + "reference": "a617e55bc62a87eec73bd456d146d134ad716f03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/d85d39da4576a6934b72480be6978fb10c860021", - "reference": "d85d39da4576a6934b72480be6978fb10c860021", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/a617e55bc62a87eec73bd456d146d134ad716f03", + "reference": "a617e55bc62a87eec73bd456d146d134ad716f03", "shasum": "" }, "require": { "php": ">=5.2" }, "require-dev": { - "simpletest/simpletest": "^1.1" + "simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd" }, "type": "library", "autoload": { @@ -306,7 +256,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL" + "LGPL-2.1-or-later" ], "authors": [ { @@ -320,7 +270,369 @@ "keywords": [ "html" ], - "time": "2018-02-23T01:58:20+00:00" + "time": "2019-10-28T03:44:26+00:00" + }, + { + "name": "markbaker/complex", + "version": "1.4.7", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000", + "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000", + "shasum": "" + }, + "require": { + "php": "^5.6.0|^7.0.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", + "phpcompatibility/php-compatibility": "^8.0", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "2.*", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^4.8.35|^5.4.0", + "sebastian/phpcpd": "2.*", + "squizlabs/php_codesniffer": "^3.3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + }, + "files": [ + "classes/src/functions/abs.php", + "classes/src/functions/acos.php", + "classes/src/functions/acosh.php", + "classes/src/functions/acot.php", + "classes/src/functions/acoth.php", + "classes/src/functions/acsc.php", + "classes/src/functions/acsch.php", + "classes/src/functions/argument.php", + "classes/src/functions/asec.php", + "classes/src/functions/asech.php", + "classes/src/functions/asin.php", + "classes/src/functions/asinh.php", + "classes/src/functions/atan.php", + "classes/src/functions/atanh.php", + "classes/src/functions/conjugate.php", + "classes/src/functions/cos.php", + "classes/src/functions/cosh.php", + "classes/src/functions/cot.php", + "classes/src/functions/coth.php", + "classes/src/functions/csc.php", + "classes/src/functions/csch.php", + "classes/src/functions/exp.php", + "classes/src/functions/inverse.php", + "classes/src/functions/ln.php", + "classes/src/functions/log2.php", + "classes/src/functions/log10.php", + "classes/src/functions/negative.php", + "classes/src/functions/pow.php", + "classes/src/functions/rho.php", + "classes/src/functions/sec.php", + "classes/src/functions/sech.php", + "classes/src/functions/sin.php", + "classes/src/functions/sinh.php", + "classes/src/functions/sqrt.php", + "classes/src/functions/tan.php", + "classes/src/functions/tanh.php", + "classes/src/functions/theta.php", + "classes/src/operations/add.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "time": "2018-10-13T23:28:42+00:00" + }, + { + "name": "markbaker/matrix", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "5348c5a67e3b75cd209d70103f916a93b1f1ed21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/5348c5a67e3b75cd209d70103f916a93b1f1ed21", + "reference": "5348c5a67e3b75cd209d70103f916a93b1f1ed21", + "shasum": "" + }, + "require": { + "php": "^5.6.0|^7.0.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "dev-master", + "phploc/phploc": "^4", + "phpmd/phpmd": "dev-master", + "phpunit/phpunit": "^5.7", + "sebastian/phpcpd": "^3.0", + "squizlabs/php_codesniffer": "^3.0@dev" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + }, + "files": [ + "classes/src/functions/adjoint.php", + "classes/src/functions/antidiagonal.php", + "classes/src/functions/cofactors.php", + "classes/src/functions/determinant.php", + "classes/src/functions/diagonal.php", + "classes/src/functions/identity.php", + "classes/src/functions/inverse.php", + "classes/src/functions/minors.php", + "classes/src/functions/trace.php", + "classes/src/functions/transpose.php", + "classes/src/operations/add.php", + "classes/src/operations/directsum.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "time": "2019-10-06T11:29:25+00:00" + }, + { + "name": "moonlandsoft/yii2-phpexcel", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/moonlandsoft/yii2-phpexcel.git", + "reference": "ccf28ff8ce2c665a7769dd6516098b4a35c8c309" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/moonlandsoft/yii2-phpexcel/zipball/ccf28ff8ce2c665a7769dd6516098b4a35c8c309", + "reference": "ccf28ff8ce2c665a7769dd6516098b4a35c8c309", + "shasum": "" + }, + "require": { + "phpoffice/phpspreadsheet": "*", + "yiisoft/yii2": "*" + }, + "type": "yii2-extension", + "autoload": { + "psr-4": { + "moonland\\phpexcel\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Moh Khoirul Anam", + "email": "moh.khoirul.anaam@gmail.com" + } + ], + "description": "Exporting PHP to Excel or Importing Excel to PHP", + "keywords": [ + "excel", + "export", + "extension", + "import", + "xls", + "yii2" + ], + "time": "2019-01-31T14:14:03+00:00" + }, + { + "name": "npm-asset/bootstrap", + "version": "4.3.1", + "dist": { + "type": "tar", + "url": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.3.1.tgz" + }, + "type": "npm-asset", + "license": [ + "MIT" + ] + }, + { + "name": "phpoffice/phpspreadsheet", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "75dfcb5a364a33ecc1f7e57e636dda86c617aa78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/75dfcb5a364a33ecc1f7e57e636dda86c617aa78", + "reference": "75dfcb5a364a33ecc1f7e57e636dda86c617aa78", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "markbaker/complex": "^1.4", + "markbaker/matrix": "^1.2", + "php": "^7.1", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "dompdf/dompdf": "^0.8.3", + "friendsofphp/php-cs-fixer": "^2.16", + "jpgraph/jpgraph": "^4.0", + "mpdf/mpdf": "^8.0", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.5", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "^6.3" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "time": "2019-11-10T21:59:09+00:00" + }, + { + "name": "psr/simple-cache", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "time": "2017-10-23T01:57:42+00:00" }, { "name": "yiisoft/yii2", @@ -328,12 +640,12 @@ "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-framework.git", - "reference": "f61cfa2ab22ddf82377f5c3428066689123b50e5" + "reference": "e5aa7e91f3c310cd47aaeb0eee05d69b2e8c7ed0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/f61cfa2ab22ddf82377f5c3428066689123b50e5", - "reference": "f61cfa2ab22ddf82377f5c3428066689123b50e5", + "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/e5aa7e91f3c310cd47aaeb0eee05d69b2e8c7ed0", + "reference": "e5aa7e91f3c310cd47aaeb0eee05d69b2e8c7ed0", "shasum": "" }, "require": { @@ -420,38 +732,39 @@ "framework", "yii2" ], - "time": "2019-07-10T18:16:39+00:00" + "time": "2019-11-12T18:18:10+00:00" }, { - "name": "yiisoft/yii2-bootstrap", - "version": "dev-master", + "name": "yiisoft/yii2-bootstrap4", + "version": "2.0.8", "source": { "type": "git", - "url": "https://github.com/yiisoft/yii2-bootstrap.git", - "reference": "40a00e20b66057cd32d0c8bbc9377dc0223e541a" + "url": "https://github.com/yiisoft/yii2-bootstrap4.git", + "reference": "c67ae3f3624c35d977841f6b18d0d752ebed6420" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-bootstrap/zipball/40a00e20b66057cd32d0c8bbc9377dc0223e541a", - "reference": "40a00e20b66057cd32d0c8bbc9377dc0223e541a", + "url": "https://api.github.com/repos/yiisoft/yii2-bootstrap4/zipball/c67ae3f3624c35d977841f6b18d0d752ebed6420", + "reference": "c67ae3f3624c35d977841f6b18d0d752ebed6420", "shasum": "" }, "require": { - "bower-asset/bootstrap": "3.4.* | 3.3.* | 3.2.* | 3.1.*", - "yiisoft/yii2": "~2.0.6" + "npm-asset/bootstrap": "^4.3", + "yiisoft/yii2": "~2.0" }, "require-dev": { - "phpunit/phpunit": "<7" + "phpunit/phpunit": "<7", + "yiisoft/yii2-coding-standards": "~2.0" }, "type": "yii2-extension", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { - "yii\\bootstrap\\": "src" + "yii\\bootstrap4\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -460,8 +773,9 @@ ], "authors": [ { - "name": "Paul Klimov", - "email": "klimov.paul@gmail.com" + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com", + "homepage": "http://www.yiiframework.com/" }, { "name": "Alexander Makarov", @@ -473,17 +787,21 @@ "email": "amigo.cobos@gmail.com" }, { - "name": "Qiang Xue", - "email": "qiang.xue@gmail.com", - "homepage": "http://www.yiiframework.com/" + "name": "Paul Klimov", + "email": "klimov.paul@gmail.com" + }, + { + "name": "Simon Karlen", + "email": "simi.albi@outlook.com" } ], "description": "The Twitter Bootstrap extension for the Yii framework", "keywords": [ "bootstrap", + "bootstrap4", "yii2" ], - "time": "2019-05-23T16:20:29+00:00" + "time": "2019-10-08T11:01:37+00:00" }, { "name": "yiisoft/yii2-composer", @@ -491,12 +809,12 @@ "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-composer.git", - "reference": "fa0856bb95beb49d30f408639224b0e0ed26b4f3" + "reference": "602673880e00bc2cc6d874b0714382775b372ac2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/fa0856bb95beb49d30f408639224b0e0ed26b4f3", - "reference": "fa0856bb95beb49d30f408639224b0e0ed26b4f3", + "url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/602673880e00bc2cc6d874b0714382775b372ac2", + "reference": "602673880e00bc2cc6d874b0714382775b372ac2", "shasum": "" }, "require": { @@ -538,7 +856,7 @@ "extension installer", "yii2" ], - "time": "2019-05-28T08:14:44+00:00" + "time": "2019-07-16T13:22:50+00:00" } ], "packages-dev": [ @@ -548,12 +866,12 @@ "source": { "type": "git", "url": "https://github.com/kint-php/kint.git", - "reference": "339b24fc0439d61644ddcc5d5f52cf5fdfbe3fa3" + "reference": "5cc6ac40c3b8aed404ee65a6b98a7c7ef6e6ffbb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kint-php/kint/zipball/339b24fc0439d61644ddcc5d5f52cf5fdfbe3fa3", - "reference": "339b24fc0439d61644ddcc5d5f52cf5fdfbe3fa3", + "url": "https://api.github.com/repos/kint-php/kint/zipball/5cc6ac40c3b8aed404ee65a6b98a7c7ef6e6ffbb", + "reference": "5cc6ac40c3b8aed404ee65a6b98a7c7ef6e6ffbb", "shasum": "" }, "require": { @@ -590,14 +908,14 @@ "MIT" ], "authors": [ - { - "name": "Rokas Šleinius", - "homepage": "https://github.com/raveren" - }, { "name": "Jonathan Vollebregt", "homepage": "https://github.com/jnvsor" }, + { + "name": "Rokas Šleinius", + "homepage": "https://github.com/raveren" + }, { "name": "Contributors", "homepage": "https://github.com/kint-php/kint/graphs/contributors" @@ -610,7 +928,68 @@ "kint", "php" ], - "time": "2019-07-11T17:29:14+00:00" + "time": "2019-10-14T18:57:03+00:00" + }, + { + "name": "opis/closure", + "version": "3.4.1", + "source": { + "type": "git", + "url": "https://github.com/opis/closure.git", + "reference": "e79f851749c3caa836d7ccc01ede5828feb762c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opis/closure/zipball/e79f851749c3caa836d7ccc01ede5828feb762c7", + "reference": "e79f851749c3caa836d7ccc01ede5828feb762c7", + "shasum": "" + }, + "require": { + "php": "^5.4 || ^7.0" + }, + "require-dev": { + "jeremeamia/superclosure": "^2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Opis\\Closure\\": "src/" + }, + "files": [ + "functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marius Sarca", + "email": "marius.sarca@gmail.com" + }, + { + "name": "Sorin Sarca", + "email": "sarca_sorin@hotmail.com" + } + ], + "description": "A library that can be used to serialize closures (anonymous functions) and arbitrary objects.", + "homepage": "https://opis.io/closure", + "keywords": [ + "anonymous functions", + "closure", + "function", + "serializable", + "serialization", + "serialize" + ], + "time": "2019-10-19T18:38:51+00:00" }, { "name": "phpspec/php-diff", @@ -652,20 +1031,21 @@ }, { "name": "yiisoft/yii2-debug", - "version": "2.1.5", + "version": "2.1.11", "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-debug.git", - "reference": "a6bbf55093e154e2eeb2c778af8717989495270e" + "reference": "72e7c6c454028366f14ccef5a93d6c18fc9dcd63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-debug/zipball/a6bbf55093e154e2eeb2c778af8717989495270e", - "reference": "a6bbf55093e154e2eeb2c778af8717989495270e", + "url": "https://api.github.com/repos/yiisoft/yii2-debug/zipball/72e7c6c454028366f14ccef5a93d6c18fc9dcd63", + "reference": "72e7c6c454028366f14ccef5a93d6c18fc9dcd63", "shasum": "" }, "require": { "ext-mbstring": "*", + "opis/closure": "^3.3", "php": ">=5.4", "yiisoft/yii2": "~2.0.13" }, @@ -705,20 +1085,20 @@ "debugger", "yii2" ], - "time": "2019-06-04T14:21:49+00:00" + "time": "2019-11-05T13:56:49+00:00" }, { "name": "yiisoft/yii2-gii", - "version": "2.1.0", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-gii.git", - "reference": "d1c18f0dcbd72ab285acd320c56b1aa2554e06fa" + "reference": "cf3e81953a9e9796eed4021f3065bc5c18ee3356" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/d1c18f0dcbd72ab285acd320c56b1aa2554e06fa", - "reference": "d1c18f0dcbd72ab285acd320c56b1aa2554e06fa", + "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/cf3e81953a9e9796eed4021f3065bc5c18ee3356", + "reference": "cf3e81953a9e9796eed4021f3065bc5c18ee3356", "shasum": "" }, "require": { @@ -756,13 +1136,12 @@ "gii", "yii2" ], - "time": "2019-03-17T19:23:15+00:00" + "time": "2019-10-08T10:28:42+00:00" } ], "aliases": [], "minimum-stability": "dev", "stability-flags": { - "yiisoft/yii2-bootstrap": 20, "yiisoft/yii2-debug": 20, "kint-php/kint": 20, "yiisoft/yii2-gii": 20 diff --git a/environments/skeleton/kcadmin/config/main-local.php b/environments/skeleton/kcadmin/config/main-local.php index ddff7d3..1e46ae6 100644 --- a/environments/skeleton/kcadmin/config/main-local.php +++ b/environments/skeleton/kcadmin/config/main-local.php @@ -22,18 +22,17 @@ if (!YII_ENV_TEST) { 'allowedIPs' => ['127.0.0.1'], 'generators' => [ 'crud' => [ - 'class' => 'blobt\generators\crud\Generator', + 'class' => 'iron\generators\crud\Generator', 'templates' => [ - 'blobtCrud' => '@blobt/generators/crud/default', - 'linyaoCrud' => '@linyao/generators/crud/default', - ] + 'basicModel' => '@iron/generators/crud/default', + ], ], 'model' => [ - 'class' => 'linyao\generators\model\Generator', + 'class' => 'iron\generators\model\Generator', 'templates' => [ - 'linyaoModel' => '@linyao/generators/model/default', - ] - ] + 'basicModel' => '@iron/generators/model/default', + ], + ], ], ]; } diff --git a/kcadmin/assets/AppAsset.php b/kcadmin/assets/AppAsset.php index 64d62bb..d4f192e 100644 --- a/kcadmin/assets/AppAsset.php +++ b/kcadmin/assets/AppAsset.php @@ -19,8 +19,8 @@ class AppAsset extends AssetBundle ]; public $depends = [ 'yii\web\YiiAsset', - 'yii\bootstrap\BootstrapAsset', - 'yii\bootstrap\BootstrapPluginAsset', - 'blobt\web\AdminlteAsset', + 'yii\bootstrap4\BootstrapAsset', + 'yii\bootstrap4\BootstrapPluginAsset', + 'iron\web\AdminlteAsset', ]; } diff --git a/kcadmin/controllers/CategoryController.php b/kcadmin/controllers/CategoryController.php index c6cf654..1ae4c9a 100644 --- a/kcadmin/controllers/CategoryController.php +++ b/kcadmin/controllers/CategoryController.php @@ -2,22 +2,28 @@ namespace kcadmin\controllers; +use common\models\Cat; use Yii; use common\models\Category; use common\models\CategorySearch; +use yii\helpers\Html; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; +use yii\web\Response; /** * CategoryController implements the CRUD actions for Category model. */ -class CategoryController extends Controller { +class CategoryController extends Controller +{ public $enableCsrfValidation = false; + /** * {@inheritdoc} */ - public function behaviors() { + public function behaviors() + { return [ 'verbs' => [ 'class' => VerbFilter::className(), @@ -28,36 +34,87 @@ class CategoryController extends Controller { ]; } - public function actions() { + public function actions() + { return [ - 'test'=>[ - 'class'=>'iron\actions\UploadAction', + 'upload' => [ + 'class' => 'iron\actions\UploadAction', + 'path' => 'xls/' ] ]; } + + public function actionSaveDatabase() + { + Yii::$app->response->format = Response::FORMAT_JSON; + //TODO save data in database + return ['status'=>true]; + } + + public function actionPreviews() + { + Yii::$app->response->format = Response::FORMAT_JSON; + return [['name' => '111', 'path' => '/uploads/15736315233032.jpg', 'size' => 1024]]; + } + + /** + * @author iron + * 文件导出 + */ + public function actionExport() + { + $searchModel = new CategorySearch(); + $params = Yii::$app->request->queryParams; + if ($params['page-type'] == 'all') { + $dataProvider = $searchModel->allData($params); + } else { + $dataProvider = $searchModel->search($params); + } + \iron\widgets\Excel::export([ + 'models' => $dataProvider->getModels(), + 'format' => 'Xlsx', + 'asAttachment' => true, + 'fileName' => "category" . "-" . date('Y-m-d H/i/s', time()), + 'columns' => Category::columns() + ]); + } + + public function actionTest() + { + return $this->renderPartial('test'); + } + /** * 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, + 'columns' => Category::columns() ]); } + public function actionImageDel() + { + Yii::$app->response->format = Response::FORMAT_JSON; + return ['status' => true]; + } + /** * Displays a single Category model. * @param integer $id * @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), ]); } @@ -66,7 +123,8 @@ 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()) { @@ -74,7 +132,7 @@ class CategoryController extends Controller { } return $this->render('create', [ - 'model' => $model, + 'model' => $model, ]); } @@ -85,7 +143,8 @@ 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()) { @@ -93,7 +152,7 @@ class CategoryController extends Controller { } return $this->render('update', [ - 'model' => $model, + 'model' => $model, ]); } @@ -104,16 +163,18 @@ 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() { + public function actionDeletes() + { //获取前端post的记录id $ids = Yii::$app->request->post('ids'); } @@ -125,7 +186,8 @@ 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; } diff --git a/kcadmin/views/category/_form.php b/kcadmin/views/category/_form.php index ae85251..e783af7 100644 --- a/kcadmin/views/category/_form.php +++ b/kcadmin/views/category/_form.php @@ -21,18 +21,22 @@ use blobt\widgets\Icheck; field($model, 'icon_type')->widget(Select2::className(), ["items" => $model::$iconType, "promptText" => false]) ?> - field($model, 'icon_type')->widget(Icheck::className(), ["items" => $model::$iconType,'type' => "radio"]) ?> + field($model, 'icon_type')->widget(Icheck::className(), ["items" => $model::$iconType, 'type' => "radio"]) ?> field($model, 'description')->textarea(['rows' => 6]) ?> - field($model, 'sort_order')->textInput() ?> + field($model, 'sort_order')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'imageDel', + 'dragdropWidth'=> 800 + ]) ?> field($model, 'created_at')->widget(DatetimePicker::className()) ?> + diff --git a/kcadmin/views/category/_search.php b/kcadmin/views/category/_search.php index 03e5587..96eb2a9 100644 --- a/kcadmin/views/category/_search.php +++ b/kcadmin/views/category/_search.php @@ -12,14 +12,14 @@ use blobt\widgets\DateRangePicker; ['index'], - 'method' => 'get', - 'validateOnType' => true, - ]); + 'action' => ['index'], + 'method' => 'get', + 'validateOnType' => true, +]); ?> -
-
+
+
field($model, 'cat_name', [ "template" => "{input}{error}", @@ -32,7 +32,8 @@ $form = ActiveForm::begin([ ] ]) ?> - +
+
field($model, "created_at_range", [ "template" => "{input}{error}", @@ -44,10 +45,10 @@ $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/index.php b/kcadmin/views/category/index.php index bab362a..7fe8ef4 100644 --- a/kcadmin/views/category/index.php +++ b/kcadmin/views/category/index.php @@ -1,7 +1,7 @@ title = 'Categories'; $this->params['breadcrumbs'][] = $this->title; + ?>
-
+
$dataProvider, 'filter' => $this->render("_search", ['model' => $searchModel]), @@ -27,46 +28,7 @@ $this->params['breadcrumbs'][] = $this->title; "url" => "/category/others" ], ], - 'columns' => [ - [ - 'class' => 'blobt\grid\CheckboxColumn', - 'width' => '2%', - 'align' => 'center' - ], - [ - 'attribute' => 'id', - 'width' => '5%', - 'align' => 'center' - ], - [ - 'attribute' => 'created_at', - 'width' => '7%', - 'format' => 'date' - ], - [ - 'attribute' => 'cat_name', - 'width' => '13%', - ], - [ - 'attribute' => 'icon', - 'width' => '5%', - ], - [ - 'attribute' => 'icon_type', - 'width' => '7%', - 'showConstText' => true - ], - [ - 'attribute' => 'description', - 'enableSorting' => false, - 'format' => 'ntext', - 'width' => '50%', - ], - [ - 'class' => 'blobt\grid\ActionColumn', - 'align' => 'center', - ], - ], + 'columns' => $columns ]); ?>
diff --git a/kcadmin/views/category/test.php b/kcadmin/views/category/test.php new file mode 100644 index 0000000..a2ec90b --- /dev/null +++ b/kcadmin/views/category/test.php @@ -0,0 +1,98 @@ + + +
+ + + +
+ +
+
+
Upload +
+ +
+
+ Drag & Drop Files
+
+
+
+ + diff --git a/kcadmin/views/layouts/breadcrumb.php b/kcadmin/views/layouts/breadcrumb.php index a159020..57806ab 100644 --- a/kcadmin/views/layouts/breadcrumb.php +++ b/kcadmin/views/layouts/breadcrumb.php @@ -1,13 +1,25 @@ -title)): ?> -

title ?>params['subtitle'])): ?>params['subtitle'] ?>

- - 'ol', - 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], -]); -?> \ No newline at end of file +
+
+
+ title)): ?> +

title ?>params['subtitle'])): ?> + params['subtitle'] ?>

+ +
+
+ 'ol', + 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], + 'itemTemplate' => "\n", + 'activeItemTemplate' => "
  • {link}
  • \n", + 'options' => ['class' => 'breadcrumb float-sm-right'] + ]); + ?> +
    +
    \ No newline at end of file diff --git a/kcadmin/views/layouts/header.php b/kcadmin/views/layouts/header.php index 2bbba81..0fd795d 100644 --- a/kcadmin/views/layouts/header.php +++ b/kcadmin/views/layouts/header.php @@ -1,71 +1,49 @@ -
    - - - -
    - + \ No newline at end of file diff --git a/kcadmin/views/layouts/main.php b/kcadmin/views/layouts/main.php index 421217b..2384cae 100644 --- a/kcadmin/views/layouts/main.php +++ b/kcadmin/views/layouts/main.php @@ -4,8 +4,6 @@ use kcadmin\assets\AppAsset; use yii\helpers\Html; -use yii\bootstrap\Nav; -use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; AppAsset::register($this); diff --git a/kcadmin/views/layouts/sidebar.php b/kcadmin/views/layouts/sidebar.php index a164ca5..befdd05 100644 --- a/kcadmin/views/layouts/sidebar.php +++ b/kcadmin/views/layouts/sidebar.php @@ -1,8 +1,13 @@ -