新增文件收集管理功能 前端实现
This commit is contained in:
parent
40ca947f7e
commit
ff57203f15
63
views/admin/collection_manage.php
Normal file
63
views/admin/collection_manage.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use app\models\CollectionTasks;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use yii\grid\ActionColumn;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\CollectionSearch $searchModel */
|
||||||
|
/** @var yii\data\ActiveDataProvider $dataProvider */
|
||||||
|
|
||||||
|
$this->title = '文件收集管理';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="collection-tasks-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'filterModel' => $searchModel,
|
||||||
|
'columns' => [
|
||||||
|
[
|
||||||
|
'attribute' => 'id',
|
||||||
|
'headerOptions' => ['style' => 'width:6%;'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'user_id',
|
||||||
|
'label' => '收集者',
|
||||||
|
'value' => function ($model) {
|
||||||
|
return $model->user->username . ' (ID:' . $model->user_id . ')';
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'folder_path',
|
||||||
|
'created_at',
|
||||||
|
'secret',
|
||||||
|
[
|
||||||
|
'attribute' => 'status',
|
||||||
|
'label' => '收集状态',
|
||||||
|
'value' => function ($model) {
|
||||||
|
return $model->status == 1 ? '有效' : '失效';
|
||||||
|
},
|
||||||
|
'filter' => [1 => '有效', 0 => '失效'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'class' => ActionColumn::class,
|
||||||
|
'template' => '{view} {delete}',
|
||||||
|
'urlCreator' => function ($action, CollectionTasks $model, $key, $index, $column) {
|
||||||
|
if ($action === 'view') {
|
||||||
|
// 返回查看按钮的链接
|
||||||
|
return Url::toRoute(['collection-manage-view', 'id' => $model->id]);
|
||||||
|
} else {
|
||||||
|
// 如果 status 为 0,禁用删除按钮
|
||||||
|
return $model->status != 0 ? Url::toRoute(['collection-manage-delete', 'id' => $model->id]) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
73
views/admin/collection_manage_view.php
Normal file
73
views/admin/collection_manage_view.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use yii\web\JqueryAsset;
|
||||||
|
use yii\web\View;
|
||||||
|
use yii\web\YiiAsset;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
use app\models\CollectionUploadedSearch;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\CollectionTasks $model */
|
||||||
|
|
||||||
|
$this->title = '文件收集ID ' . $model->id;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => '文件收集管理', 'url' => ['collection-manage']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
YiiAsset::register($this);
|
||||||
|
|
||||||
|
$searchModel = new CollectionUploadedSearch();
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
$dataProvider->query->andWhere(['task_id' => $model->id]);
|
||||||
|
?>
|
||||||
|
<div class="collection-tasks-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?php if ($model->status != 0): ?>
|
||||||
|
<?= Html::a('复制收集链接', null, ['class' => 'btn btn-primary', 'id' => 'copy-link-button']) ?>
|
||||||
|
<?= Html::a('访问收集链接', ['collection/access', 'id' => $model->id, 'secret' => $model->secret], ['class' => 'btn btn-primary', 'target' => '_blank']) ?>
|
||||||
|
<?= Html::a('取消收集', ['collection-manage-delete', 'id' => $model->id], [
|
||||||
|
'class' => 'btn btn-danger',
|
||||||
|
'data' => [
|
||||||
|
'confirm' => '你确定要取消这个收集任务吗?已收集的文件不会被删除',
|
||||||
|
'method' => 'post',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?= Html::a('复制收集链接', null, ['class' => 'btn btn-primary disabled', 'id' => 'copy-link-button', 'aria-disabled' => 'true']) ?>
|
||||||
|
<?= Html::a('访问收集链接', null, ['class' => 'btn btn-primary disabled', 'target' => '_blank', 'aria-disabled' => 'true']) ?>
|
||||||
|
<?= Html::a('取消收集', null, [
|
||||||
|
'class' => 'btn btn-danger disabled',
|
||||||
|
'aria-disabled' => 'true'
|
||||||
|
]) ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= DetailView::widget([
|
||||||
|
'model' => $model,
|
||||||
|
'attributes' => [
|
||||||
|
'id',
|
||||||
|
'folder_path',
|
||||||
|
'created_at',
|
||||||
|
'secret',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
<h2>文件收集情况:</h2>
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
'id',
|
||||||
|
'uploader_ip',
|
||||||
|
'uploaded_at',
|
||||||
|
'subfolder_name'
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
$this->registerJsFile('@web/js/collection_view.js', ['depends' => [JqueryAsset::class], 'position' => View::POS_END]);
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user