update2022

This commit is contained in:
2022-05-08 17:00:49 +08:00
parent 769b276649
commit 0943735bf8
6 changed files with 25 additions and 13 deletions

View File

@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Model;
use PhpOffice\PhpWord\Exception\CopyFileException;
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
use PhpOffice\PhpWord\TemplateProcessor;
use RuntimeException;
class DestroyData extends RowAction
{
@@ -24,7 +25,7 @@ class DestroyData extends RowAction
{
try {
if ($model->archives) {
// return $this->response()->error('数据销毁失败')->refresh();
// return $this->response()->error('数据销毁失败')->refresh();
}
// 先做存档
$archives = [];
@@ -47,10 +48,10 @@ class DestroyData extends RowAction
$download = $this->exportEqual($model);
}
// $model->logs()->delete();
$model->logs()->delete();
return $this->response()->success('数据销毁完成')->refresh()->download($download);
} catch (\RuntimeException $exception) {
} catch (RuntimeException $exception) {
return $this->response()->error('数据销毁失败'.$exception->getMessage())->refresh();
}
}
@@ -69,8 +70,8 @@ class DestroyData extends RowAction
{
$templateProcessor = new TemplateProcessor(storage_path('app/public/DENG_FEN.docx'));
$templateProcessor->setValue('TOTAL1', $vote->logs()->distinct('user_id')->count());
$templateProcessor->setValue('TITLE', $vote->title);
$templateProcessor->setValue('TOTAL', $vote->logs()->distinct('user_id')->count());
$templateProcessor->setValue('TITLE', strip_tags($vote->title));
$i = 0;
$tpl = '';

View File

@@ -23,7 +23,12 @@ class ItemController extends Controller
protected function grid($vote)
{
$grid = new Grid(new Item);
$grid->model()->where('vote_id', $vote->id);
$grid->filter(function (Grid\Filter $v) {
$v->column(1 / 2, function (Grid\Filter $f) {
$f->like('name', '姓名');
});
});
$grid->model()->where('vote_id', $vote->id)->orderBy('sort');
$grid->column('cover')->image('', 80);
$grid->column('id', '#ID#');
$grid->column('name');

View File

@@ -21,8 +21,14 @@ class UserController extends AdminController
$tools->append(new UserImport);
$tools->append(new CleanData);
});
// $grid->disableCreateButton();
// $grid->disableActions();
$grid->filter(function (Grid\Filter $v) {
$v->column(1 / 2, function (Grid\Filter $f) {
$f->like('name', '姓名');
});
$v->column(1 / 2, function (Grid\Filter $f) {
$f->equal('mobile', '手机号');
});
});
$grid->column('归属干事')->display(function () {
return $this->parent->name ?? '';
});
@@ -45,8 +51,8 @@ class UserController extends AdminController
$form->text('name', '姓名');
$form->text('mobile', '手机号');
$form->select('parent_id','归属干事')->options(
User::where('type', 1)->pluck('name', 'id')
$form->select('parent_id', '归属干事')->options(
User::where('type', 1)->pluck('name', 'id')
)->default(0);
$form->select('type')->options([
0 => '投票人',

View File

@@ -53,9 +53,9 @@ class IndexController extends Controller
function agent()
{
if (Api::user()->type == 1) {
$users = User::where('parent_id', Api::id())->select(['id', 'mobile', 'name', 'sign'])->get();
$users = User::where('parent_id', Api::id())->select(['id', 'mobile', 'name', 'sign'])->orderBy('sign')->get();
} else {
$users = User::where('type', 0)->select(['id', 'mobile', 'name', 'sign'])->get();
$users = User::where('type', 0)->select(['id', 'mobile', 'name', 'sign'])->orderBy('sign')->get();
}
$vote = Vote::where('status', 1)->first();

View File

@@ -39,7 +39,7 @@ class Kernel extends HttpKernel
],
'api' => [
'throttle:60,1',
'throttle:600,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];