前端改进

*未完成
This commit is contained in:
Chenx221 2024-03-25 16:48:34 +08:00
parent c56f9d68a4
commit 93a978fb76
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
3 changed files with 38 additions and 16 deletions

View File

@ -102,8 +102,8 @@ class AdminController extends Controller
Yii::$app->response->format = Response::FORMAT_JSON; Yii::$app->response->format = Response::FORMAT_JSON;
$oldValue = $model->name; $oldValue = $model->name;
// TODO: Implement the logic to update the value of the model
if ($model->load($_POST)) { if ($model->load($_POST)) {
// read or convert your posted information // read or convert your posted information
$value = $model->name; $value = $model->name;

View File

@ -16,8 +16,6 @@ $this->title = '用户ID: ' . $model->id;
$this->params['breadcrumbs'][] = ['label' => '用户管理', 'url' => ['user']]; $this->params['breadcrumbs'][] = ['label' => '用户管理', 'url' => ['user']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
$alreadyDisabled = $model->status == 0; $alreadyDisabled = $model->status == 0;
$isCurrentUser = Yii::$app->user->id == $model->id ? 'disabled' : '';
$str = $alreadyDisabled ? '启用' : '禁用';
$IPLocation = new IPLocation(); $IPLocation = new IPLocation();
YiiAsset::register($this); YiiAsset::register($this);
FontAwesomeAsset::register($this); FontAwesomeAsset::register($this);
@ -26,18 +24,28 @@ FontAwesomeAsset::register($this);
<h1>用户详情</h1> <h1>用户详情</h1>
<!-- <p>-->
<!-- --><?php //= Html::a($str . '用户', ['user-delete', 'id' => $model->id], [
// 'class' => 'btn btn-danger ' . $isCurrentUser,
// 'data' => [
// 'confirm' => '你确定要' . $str . '这个用户吗?',
// 'method' => 'post',
// ],
// 'title' => '点击' . $str . '用户',
// ]) ?>
<!-- </p>-->
<p> <p>
<!-- --><?php //= Html::a('修改信息', ['user-update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> <?= Html::a('禁用二步验证', ['user-totpoff', 'id' => $model->id], [
<?= Html::a($str . '用户', ['user-delete', 'id' => $model->id], [ 'class' => 'btn btn-danger'.($model->is_otp_enabled == 0 ? ' disabled' : ''),
'class' => 'btn btn-danger ' . $isCurrentUser,
'data' => [ 'data' => [
'confirm' => '你确定要' . $str . '这个用户吗?', 'confirm' => '你确定要取消这个用户的多因素登录吗?',
'method' => 'post', 'method' => 'post',
], ],
'title' => '点击' . $str . '用户', 'title' => '点击取消用户的多因素登录',
]) ?> ]) ?>
</p> </p>
<?= DetailView::widget([ <?= DetailView::widget([
'model' => $model, 'model' => $model,
'attributes' => [ 'attributes' => [
@ -58,17 +66,19 @@ FontAwesomeAsset::register($this);
return $model->getGravatar(email: $model->email, s: 100, img: true); return $model->getGravatar(email: $model->email, s: 100, img: true);
}], }],
['attribute' => 'status', 'label' => '账户状态', 'format' => 'raw', 'value' => function ($model) { ['attribute' => 'status', 'label' => '账户状态', 'format' => 'raw', 'value' => function ($model) {
// return $model->status == 0 ? '禁用' : '启用'; if(Yii::$app->user->id == $model->id){
//TODO 未完成 return $model->status == 0 ? '禁用' : '启用';
}
return Editable::widget([ return Editable::widget([
'name' => 'status', 'name' => 'status',
'value' => $model->status == 0 ? '禁用' : '启用',
'asPopover' => true, 'asPopover' => true,
'header' => '账户状态', 'header' => '账户状态',
'format' => Editable::FORMAT_BUTTON, 'format' => Editable::FORMAT_BUTTON,
'inputType' => Editable::INPUT_DROPDOWN_LIST, 'inputType' => Editable::INPUT_DROPDOWN_LIST,
'data' => [1,2,3], // any list of values 'data' => [0 => '禁用',
1 => '启用',],
'options' => ['class' => 'form-control'], 'options' => ['class' => 'form-control'],
'editableValueOptions' => ['class' => 'text-danger']
]); ]);
}], }],
['attribute' => 'created_at', 'label' => '创建时间', 'value' => function ($model) { ['attribute' => 'created_at', 'label' => '创建时间', 'value' => function ($model) {
@ -86,7 +96,19 @@ FontAwesomeAsset::register($this);
return $model->last_login_ip; return $model->last_login_ip;
} }
}], }],
['attribute' => 'bio', 'label' => '用户简介'], ['attribute' => 'bio', 'label' => '用户简介','format'=>'raw','value'=>function ($model) {
return Editable::widget([
'name'=>'bio',
'asPopover' => true,
'displayValue' => '查看',
'inputType' => Editable::INPUT_TEXTAREA,
'value' => $model->bio,
'header' => '用户简介',
'submitOnEnter' => false,
'size'=>'lg',
'options' => ['class'=>'form-control', 'rows'=>5]
]);
}],
['attribute' => 'role', 'label' => '用户身份', 'value' => function ($model) { ['attribute' => 'role', 'label' => '用户身份', 'value' => function ($model) {
return $model->role == 'user' ? '用户' : '管理员'; return $model->role == 'user' ? '用户' : '管理员';
}], }],

View File

@ -1,4 +1,4 @@
/*解决Editable显示modal时nav乱跳问题*/ /*解决Editable显示modal时nav乱跳问题*/
#w3 { #header nav {
/*padding-right: 0 !important;*/ padding-right: 0 !important;
} }