Browse Source

feat: 测试与云的交互

wechat_public_accounts
root 5 years ago
parent
commit
1dc563ea70
  1. 1
      .gitignore
  2. 1
      api/.gitignore
  3. 4
      api/config/.gitignore
  4. 1
      api/config/bootstrap.php
  5. 57
      api/config/main.php
  6. 15
      api/config/params.php
  7. 78
      api/controllers/UserController.php
  8. 2
      api/web/assets/.gitignore
  9. 18
      api/web/index-test.php
  10. 17
      api/web/index.php
  11. 2
      api/web/robots.txt
  12. 5
      backend/config/main.php
  13. 2
      backend/controllers/GoodsController.php
  14. 77
      backend/controllers/SiteController.php
  15. 6
      backend/views/layouts/main.php
  16. 20
      backend/views/layouts/sidebar.php
  17. 4
      backend/web/css/site.css
  18. 1
      backend/web/index.php
  19. 1
      common/config/bootstrap.php
  20. 2
      common/config/main.php
  21. 17
      common/config/params.php
  22. 35
      common/models/User.php
  23. 1
      composer.json
  24. 91
      composer.lock
  25. 41
      console/migrations/m191122_011654_add_column_admin_id_in_table_user.php
  26. 2
      vendor/iron/assets/grid/css/grid.css
  27. 24
      vendor/iron/grid/GridView.php

1
.gitignore

@ -37,4 +37,5 @@ phpunit.phar
vendor.zip
/vagrant
/backend/web/uploads
/api/web/uploads
dump.rdb

1
api/.gitignore

@ -0,0 +1 @@
runtime

4
api/config/.gitignore

@ -0,0 +1,4 @@
codeception-local.php
main-local.php
params-local.php
test-local.php

1
api/config/bootstrap.php

@ -0,0 +1 @@
<?php

57
api/config/main.php

@ -0,0 +1,57 @@
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
);
return [
'id' => 'api',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'api\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'request' => [
'parsers' => [
'application/json' => 'yii\web\JsonParser',
],
'csrfParam' => '_csrf-api',
],
'session' => [
// this is the name of the session cookie used for login on the app
'name' => 'api',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
['class' => 'yii\rest\UrlRule',
'controller' => 'user',
'extraPatterns' => [
'GET menu' => 'menu',
'GET create' => 'create'
]
],
],
],
],
'params' => $params,
];

15
api/config/params.php

@ -0,0 +1,15 @@
<?php
return [
'permissions'=>[
"网站基本权限" => [
'首页(销售数据)' => '/site/index',
'用户注销' => '/site/logout',
'用户登录' => '/site/login',
],
"商品模块" => [
'商品列表' => '/goods/index',
'商品新增' => '/goods/create',
'商品修改' => '/goods/update',
],
]
];

78
api/controllers/UserController.php

@ -0,0 +1,78 @@
<?php
namespace api\controllers;
/*
* The MIT License
*
* Copyright 2019 Blobt.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
use common\models\ars\Config;
use common\models\User;
use yii\base\NotSupportedException;
use yii\filters\auth\HttpBearerAuth;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\rest\ActiveController;
use Yii;
class UserController extends ActiveController
{
public $modelClass = 'common\models\User';
public function actions()
{
$actions = parent::actions();
unset($actions['index']);
unset($actions['create']);
}
public function actionIndex()
{
$key = $param = base64_encode(1 + date('Y')
+ date('m') - date('d') - date('h'));
$data = [];
Yii::$app->userLogic->createUser($data, $key);
$response = Yii::$app->getResponse();
$response->setStatusCode(201);
return ['status' => true];
}
public function actionCreate()
{
$key = Yii::$app->request->post('key');
$data = \Yii::$app->request->post('data');
Yii::$app->userLogic->createUser($data, $key);
$response = Yii::$app->getResponse();
$response->setStatusCode(201);
return ['status' => true];
}
public function actionMenu()
{
$key = Yii::$app->request->get('key');
if (Yii::$app->userLogic->login($key)){
return Yii::$app->userLogic->getUserMenu();
}
}
}

2
api/web/assets/.gitignore

@ -0,0 +1,2 @@
*
!.gitignore

18
api/web/index-test.php

@ -0,0 +1,18 @@
<?php
// NOTE: Make sure this file is not accessible when deployed to production
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = require __DIR__ . '/../config/test-local.php';
(new yii\web\Application($config))->run();

17
api/web/index.php

@ -0,0 +1,17 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php'
);
(new yii\web\Application($config))->run();

2
api/web/robots.txt

@ -0,0 +1,2 @@
User-agent: *
Disallow: /

5
backend/config/main.php

@ -1,7 +1,7 @@
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
);
return [
@ -42,5 +42,8 @@ return [
],
],
],
'as access' => [
'class' => 'iron\components\AccessControl',
],
'params' => $params,
];

2
backend/controllers/GoodsController.php

@ -2,6 +2,8 @@
namespace backend\controllers;
use common\models\Category;
use common\models\User;
use Yii;
use common\models\ars\Goods;
use common\models\searchs\GoodsSearch;

77
backend/controllers/SiteController.php

@ -3,55 +3,34 @@
namespace backend\controllers;
use Yii;
use yii\base\NotSupportedException;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use common\models\CategorySearch;
use yii\web\Cookie;
use yii\web\ForbiddenHttpException;
use yii\web\NotAcceptableHttpException;
use yii\web\NotFoundHttpException;
/**
* Site controller
*/
class SiteController extends Controller {
class SiteController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error', 'test'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
// 'logout' => ['post'],
],
],
];
}
/**
* {@inheritdoc}
*/
public function actions() {
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'upload'=>[
'class'=>'iron\actions\UploadAction',
'upload' => [
'class' => 'iron\actions\UploadAction',
]
];
}
@ -61,32 +40,22 @@ class SiteController extends Controller {
*
* @return string
*/
public function actionIndex() {
public function actionIndex()
{
return $this->render('index');
}
/**
* Login action.
*
* @return string
*/
public function actionLogin() {
$this->layout = 'base';
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$key = Yii::$app->request->get('key');
if (Yii::$app->userLogic->login($key)) {
return $this->goBack();
} else {
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
throw new ForbiddenHttpException('身份验证失败,请重新进去');
}
}
@ -95,17 +64,19 @@ class SiteController extends Controller {
*
* @return string
*/
public function actionLogout() {
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
public function actionTest() {
public function actionTest()
{
$searchModel = new CategorySearch();
return $this->render('test', [
'name' => 'blobt',
'model' => $searchModel
'name' => 'blobt',
'model' => $searchModel
]);
}

6
backend/views/layouts/main.php

@ -22,11 +22,8 @@ AppAsset::register($this);
<body class="hold-transition skin-blue-light sidebar-mini">
<?php $this->beginBody() ?>
<div class="wrapper">
<?= $this->render('header') ?>
<?= $this->render('sidebar') ?>
<div class="content-wrapper">
<div class="content">
<section class="content-header">
<?= $this->render('breadcrumb') ?>
</section>
@ -35,7 +32,6 @@ AppAsset::register($this);
</section>
</div>
<?= $this->render('footer') ?>
</div>
<?php $this->endBody() ?>
</body>

20
backend/views/layouts/sidebar.php

@ -12,27 +12,7 @@ use iron\widgets\Menu;
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<?php
echo Menu::widget([
'items' => [
// ['label' => 'MAIN NAVIGATION', 'is_header' => true],
['label' => '商城管理', 'url' => '#', 'icon' => 'far fa-store', 'items' => [
['label' => '运营数据', 'url' => ['site/index', 'tag' => 'new']],
['label' => '基础配置', 'url' => ['config/index', 'tag' => 'new']],
]
],
['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [
['label' => '商品分类', 'url' => ['category/index', 'tag' => 'new']],
['label' => '商品列表', 'url' => ['goods/index']],
['label' => '属性管理', 'url' => ['attribute/index']],
]
],
['label' => '订单管理', 'url' => '#', 'icon' => 'far fa-list-alt', 'items' => [
['label' => '订单列表', 'url' => ['order/index', 'tag' => 'new']],
]
],
]
]);
?>
</section>
<!-- /.sidebar -->

4
backend/web/css/site.css

@ -49,4 +49,8 @@
.icheck-label-group label{
margin-right: 20px;
}
body::-webkit-scrollbar{
width: 1px;
height: 1px;
}

1
backend/web/index.php

@ -1,5 +1,4 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

1
common/config/bootstrap.php

@ -2,3 +2,4 @@
Yii::setAlias('@common', dirname(__DIR__));
Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('@api', dirname(dirname(__DIR__)) . '/api');

2
common/config/main.php

@ -12,11 +12,13 @@ return [
'timeZone' => 'Asia/Shanghai',
'language' => 'zh-CN',
'components' => [
'userLogic' => ['class' => 'iron\logic\UserManager'],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
'db'=>'db_user'
],
'formatter' => [
'dateFormat' => 'php:Y-m-d',

17
common/config/params.php

@ -5,4 +5,21 @@ return [
'senderEmail' => 'noreply@example.com',
'senderName' => 'Example.com mailer',
'user.passwordResetTokenExpire' => 3600,
'menus'=>[
'商城管理' => [
'icon' => 'fa-store',
'items' => [
['运营数据', '/site',],
['基础配置', '/config'],
],
],
'商品管理' => [
'icon' => 'fa-archive',
'items' => [
['商品分类', '/category'],
['商品列表', '/goods'],
['属性管理', '/attribute'],
],
]
]
];

35
common/models/User.php

@ -1,4 +1,5 @@
<?php
namespace common\models;
use Yii;
@ -25,7 +26,6 @@ use yii\web\IdentityInterface;
class User extends ActiveRecord implements IdentityInterface
{
const STATUS_DELETED = 0;
const STATUS_INACTIVE = 9;
const STATUS_ACTIVE = 10;
@ -43,21 +43,43 @@ class User extends ActiveRecord implements IdentityInterface
public function behaviors()
{
return [
TimestampBehavior::className(),
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function () {
return time();
},
],
];
}
public static function getDb()
{
return Yii::$app->get('db_user');
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
['status', 'default', 'value' => self::STATUS_INACTIVE],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_INACTIVE, self::STATUS_DELETED]],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]],
];
}
public function beforeSave($insert)
{
if ($insert) {
$this->email = $this->username . '@example.com';
$this->generateAuthKey();
$this->setPassword(Yii::$app->security->generateRandomString());
}
return parent::beforeSave($insert);
}
/**
* {@inheritdoc}
*/
@ -109,7 +131,8 @@ class User extends ActiveRecord implements IdentityInterface
* @param string $token verify email token
* @return static|null
*/
public static function findByVerificationToken($token) {
public static function findByVerificationToken($token)
{
return static::findOne([
'verification_token' => $token,
'status' => self::STATUS_INACTIVE
@ -128,7 +151,7 @@ class User extends ActiveRecord implements IdentityInterface
return false;
}
$timestamp = (int) substr($token, strrpos($token, '_') + 1);
$timestamp = (int)substr($token, strrpos($token, '_') + 1);
$expire = Yii::$app->params['user.passwordResetTokenExpire'];
return $timestamp + $expire >= time();
}

1
composer.json

@ -15,6 +15,7 @@
"yiisoft/yii2": "~2.0.14",
"yiisoft/yii2-bootstrap4": "~2.0.6",
"yiisoft/yii2-redis": "^2.0.0",
"yiisoft/yii2-httpclient": "^2.0@dev",
"moonlandsoft/yii2-phpexcel": "*"
},
"repositories": {

91
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": "2c9d2c75498023f08e9c4155af6cb5d4",
"content-hash": "a8ab9c3bc93983dbad9ba1fed4c2bb6d",
"packages": [
{
"name": "bower-asset/inputmask",
@ -71,7 +71,7 @@
"version": "3.4.1",
"source": {
"type": "git",
"url": "git@github.com:jquery/jquery-dist.git",
"url": "https://github.com/jquery/jquery-dist.git",
"reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d"
},
"dist": {
@ -499,12 +499,12 @@
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "6a2e0cef4390c62e9847eaa09b1a2b48297d5651"
"reference": "f734783d826bd84c3d54fcf7b71c37ab9bac4b04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/6a2e0cef4390c62e9847eaa09b1a2b48297d5651",
"reference": "6a2e0cef4390c62e9847eaa09b1a2b48297d5651",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/f734783d826bd84c3d54fcf7b71c37ab9bac4b04",
"reference": "f734783d826bd84c3d54fcf7b71c37ab9bac4b04",
"shasum": ""
},
"require": {
@ -584,7 +584,7 @@
"xls",
"xlsx"
],
"time": "2019-11-17T20:53:09+00:00"
"time": "2019-11-18T11:33:05+00:00"
},
{
"name": "psr/simple-cache",
@ -640,12 +640,12 @@
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-framework.git",
"reference": "e5aa7e91f3c310cd47aaeb0eee05d69b2e8c7ed0"
"reference": "7f114c9a772107265a174379e2adf23f51af7458"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/e5aa7e91f3c310cd47aaeb0eee05d69b2e8c7ed0",
"reference": "e5aa7e91f3c310cd47aaeb0eee05d69b2e8c7ed0",
"url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/7f114c9a772107265a174379e2adf23f51af7458",
"reference": "7f114c9a772107265a174379e2adf23f51af7458",
"shasum": ""
},
"require": {
@ -732,7 +732,7 @@
"framework",
"yii2"
],
"time": "2019-11-12T18:18:10+00:00"
"time": "2019-11-19T21:22:42+00:00"
},
{
"name": "yiisoft/yii2-bootstrap4",
@ -858,6 +858,56 @@
],
"time": "2019-07-16T13:22:50+00:00"
},
{
"name": "yiisoft/yii2-httpclient",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-httpclient.git",
"reference": "05ecc99868352cf840173bfd8fe67bfd84b5f295"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-httpclient/zipball/05ecc99868352cf840173bfd8fe67bfd84b5f295",
"reference": "05ecc99868352cf840173bfd8fe67bfd84b5f295",
"shasum": ""
},
"require": {
"yiisoft/yii2": "~2.0.13"
},
"require-dev": {
"phpunit/phpunit": "4.8.27|~5.7.21|^6.2"
},
"type": "yii2-extension",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"yii\\httpclient\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Paul Klimov",
"email": "klimov.paul@gmail.com"
}
],
"description": "HTTP client extension for the Yii framework",
"keywords": [
"curl",
"http",
"httpclient",
"yii2"
],
"time": "2019-10-08T09:48:57+00:00"
},
{
"name": "yiisoft/yii2-redis",
"version": "dev-master",
@ -1083,16 +1133,16 @@
},
{
"name": "yiisoft/yii2-debug",
"version": "2.1.11",
"version": "2.1.12",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-debug.git",
"reference": "72e7c6c454028366f14ccef5a93d6c18fc9dcd63"
"reference": "bf9234ba1369116d12ebe266d98006416a5ae304"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-debug/zipball/72e7c6c454028366f14ccef5a93d6c18fc9dcd63",
"reference": "72e7c6c454028366f14ccef5a93d6c18fc9dcd63",
"url": "https://api.github.com/repos/yiisoft/yii2-debug/zipball/bf9234ba1369116d12ebe266d98006416a5ae304",
"reference": "bf9234ba1369116d12ebe266d98006416a5ae304",
"shasum": ""
},
"require": {
@ -1137,20 +1187,20 @@
"debugger",
"yii2"
],
"time": "2019-11-05T13:56:49+00:00"
"time": "2019-11-19T20:09:08+00:00"
},
{
"name": "yiisoft/yii2-gii",
"version": "2.1.2",
"version": "2.1.3",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-gii.git",
"reference": "cf3e81953a9e9796eed4021f3065bc5c18ee3356"
"reference": "0dcc7d3c66de045f1b560ad4928dc67a6611f6d1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/cf3e81953a9e9796eed4021f3065bc5c18ee3356",
"reference": "cf3e81953a9e9796eed4021f3065bc5c18ee3356",
"url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/0dcc7d3c66de045f1b560ad4928dc67a6611f6d1",
"reference": "0dcc7d3c66de045f1b560ad4928dc67a6611f6d1",
"shasum": ""
},
"require": {
@ -1188,12 +1238,13 @@
"gii",
"yii2"
],
"time": "2019-10-08T10:28:42+00:00"
"time": "2019-11-19T20:19:33+00:00"
}
],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
"yiisoft/yii2-httpclient": 20,
"yiisoft/yii2-debug": 20,
"kint-php/kint": 20,
"yiisoft/yii2-gii": 20

41
console/migrations/m191122_011654_add_column_admin_id_in_table_user.php

@ -0,0 +1,41 @@
<?php
use yii\db\Migration;
/**
* Class m191122_011654_create_table_user_admin
*/
class m191122_011654_add_column_admin_id_in_table_user extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user','admin_id',$this->integer(11)->notNull()->defaultValue(0));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('user','admin_id');
return true;
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m191122_011654_create_table_user_admin cannot be reverted.\n";
return false;
}
*/
}

2
vendor/iron/assets/grid/css/grid.css

@ -62,4 +62,4 @@ THE SOFTWARE.
.dataTable td a{
color: #333;
opacity: 0.8;
}
}

24
vendor/iron/grid/GridView.php

@ -219,13 +219,13 @@ class GridView extends BaseListView
<div class="row">
<div class="col-sm-12 col-md-6">
{batch}
<a href="create" class="btn btn-default"><i class="fas fa-plus-square mr-2"></i>添加</a>
<a href="{url}/create" class="btn btn-default"><i class="fas fa-plus-square mr-2"></i>添加</a>
<!-- <a href="#" data-url='export' class="export btn btn-default"><i class="fa fa-file-excel-o"></i>导出</a>-->
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fas fa-file-upload mr-2"></i>导出</button>
<ul class="dropdown-menu" role="menu">
<li> <a class="dropdown-item export-page" href="#" data-url="export">本页</a></li>
<li> <a class="dropdown-item export-all" href="#" data-url="export">全部</a></li>
<li> <a class="dropdown-item export-page" href="#" data-url="{url}/export">本页</a></li>
<li> <a class="dropdown-item export-all" href="#" data-url="{url}/export">全部</a></li>
</ul>
</div>
<!-- <button type="button" id="export" class="btn btn-default"><i class="fa fa-file-excel-o"></i>导出</button>-->
@ -281,14 +281,14 @@ HTML;
throw new InvalidConfigException('The "formatter" property must be either a Format object or a configuration array.');
}
$this->pager = [
'options'=>['class'=>['justify-content-end','pagination']],
'linkOptions'=>['class'=>'page-link'],
'pageCssClass'=>'paginate_button page-item',
'disabledPageCssClass'=>'page-link disabled',
'firstPageLabel'=>'&laquo;',
'prevPageLabel'=>'&lsaquo;',
'nextPageLabel'=>'&rsaquo;',
'lastPageLabel'=>'&raquo;',];
'options' => ['class' => ['justify-content-end', 'pagination']],
'linkOptions' => ['class' => 'page-link'],
'pageCssClass' => 'paginate_button page-item',
'disabledPageCssClass' => 'page-link disabled',
'firstPageLabel' => '&laquo;',
'prevPageLabel' => '&lsaquo;',
'nextPageLabel' => '&rsaquo;',
'lastPageLabel' => '&raquo;',];
$this->initColumns();
}
@ -445,6 +445,8 @@ SCRIPT;
return $this->renderFilter();
case '{batch}':
return $this->renderBatch();
case '{url}':
return Yii::$app->request->url;
default:
return false;
}

Loading…
Cancel
Save