use yii\helpers\Html; use yii\widgets\Pjax; use kartik\date\DatePicker; use common\models\User; $this->title = '用户列表'; ?> <div class="row"> <div class="col-lg-12"> <?php Pjax::begin(); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-bordered table-center'], 'summaryOptions' => ['tag' => 'p', 'class' => 'text-right text-info'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'headerOptions' => ['class' => 'col-md-1']], ['attribute' => 'mobile', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'nickname', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'gender', 'filter' => User::getGenderList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'headerOptions' => ['class' => 'col-md-1'], 'value' => function ($model, $key, $index, $column) { return $model->genderMsg; }], ['attribute' => 'email', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'status', 'format' => 'raw', 'filter' => User::getStatusList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'headerOptions' => ['class' => 'col-md-1'], 'value' => function ($model, $key, $index, $column) { return Html::dropDownList('status', $model->status, User::getStatusList(), ['data-id' => $model->id]); }], ['attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d H:i'], 'filter' => DatePicker::widget(['model' => $searchModel, 'type' => DatePicker::TYPE_COMPONENT_APPEND, 'attribute' => 'date', 'options' => ['class' => 'input-sm'], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]), 'headerOptions' => ['class' => 'col-md-2']], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'headerOptions' => ['class' => 'col-md-1'], 'template' => '{view}']]]); ?> <?php Pjax::end(); ?> </div> </div> <?php $url = Url::to(['/user/status']); $js = <<<JS var handle = function () { var id = \$(this).attr('data-id'); var status = \$(this).val(); \$.ajax({ url: '{$url}?id=' + id ,
use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model common\models\User */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="user-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'role')->widget(Select2::classname(), ['data' => User::getRoleList(), 'options' => ['placeholder' => '选择一个权限', 'hideSearch' => true]]); ?> <?php echo $form->field($model, 'status')->widget(Select2::classname(), ['data' => User::getStatusList(), 'options' => ['placeholder' => '选择一个状态', 'hideSearch' => true]]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
</div> <div class="box-body"> <?php echo $form->field($model, 'username')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'email')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'group_id')->dropDownList(Group::getList()); ?> <?php echo $form->field($model, 'status')->dropDownList(User::getStatusList()); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> </div> </div> </div> <div class="col-md-8"> </div> </div> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
<?php use common\models\Group; use yii\helpers\Html; use yii\grid\GridView; use common\models\User; use backend\components\SetColumn; /* @var $this yii\web\View */ /* @var $searchModel backend\models\UserSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', 'Users'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="box"> <div class="box-body table-responsive"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'headerOptions' => ['width' => '50']], 'username', 'email:email', ['class' => SetColumn::className(), 'attribute' => 'group_id', 'filter' => Group::getList(), 'name' => 'group.name'], ['class' => SetColumn::className(), 'attribute' => 'status', 'filter' => User::getStatusList(), 'name' => 'statusName', 'cssClasses' => [User::STATUS_DELETED => 'default', User::STATUS_ACTIVE => 'success']], ['attribute' => 'created_at', 'format' => ['date', 'dd.MM.Y']], ['class' => 'yii\\grid\\ActionColumn', 'headerOptions' => ['width' => '50'], 'template' => '{update} {delete}']]]); ?> </div> <div class="box-footer"> <?php echo Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']); ?> </div> </div>
?> <!----> <!-- --><?php //= $form->field($model, 'password_hash') ?> <!----> <!-- --><?php //= $form->field($model, 'password_reset_token') ?> <?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'status_id')->dropDownList(User::getStatusList(), ['prompt' => 'Please choose one']); ?> <?php // echo $form->field($model, 'created_at') ?> <?php // echo $form->field($model, 'updated_at') ?> <?php echo $form->field($model, 'role_id')->dropDownList(User::getRoleList(), ['prompt' => 'Please choose one']); ?> <?php