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

View File

@@ -23,7 +23,12 @@ class ItemController extends Controller
protected function grid($vote) protected function grid($vote)
{ {
$grid = new Grid(new Item); $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('cover')->image('', 80);
$grid->column('id', '#ID#'); $grid->column('id', '#ID#');
$grid->column('name'); $grid->column('name');

View File

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

View File

@@ -53,9 +53,9 @@ class IndexController extends Controller
function agent() function agent()
{ {
if (Api::user()->type == 1) { 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 { } 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(); $vote = Vote::where('status', 1)->first();

View File

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

BIN
storage/.DS_Store vendored Normal file

Binary file not shown.