Commit 3c4ab42e by 汪伟伟

图片点击放大预览

parent c17597a1
......@@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\BackAction;
use App\Admin\Repositories\TasksReceive;
use App\Admin\Services\CityAreaService;
use App\Models\TasksCollect;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
......@@ -130,7 +131,8 @@ class AlreadyDoneTaskController extends AdminController
$show->field('collects.value', '指标值');
$show->field('collects.reality_refer', '实际信源');
$show->field('collects.refer_level', '信源等级');
$show->field('collects.net_img', '网页截图')->unescape();
// $show->field('collects.net_img', '网页截图')->unescape();
$show->field('collects.net_img', '网页截图')->image();
$show->field('collects.remark', '备注信息');
}
......@@ -187,7 +189,7 @@ class AlreadyDoneTaskController extends AdminController
// // 在表单提交前调用
// $form->submitted(function (Form $form) {
// //...
//
// });
// //保存前回调
// $form->saving(function (Form $form) {
......@@ -195,8 +197,14 @@ class AlreadyDoneTaskController extends AdminController
//
// });
//保存后回调
// $form->saved(function (Form $form) {
// });
$form->saved(function (Form $form) {
$start = 'src="';
$end = '" alt';
$pattern = '/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/';
preg_match_all($pattern, $form->input('collects.net_img'), $matches);
$images = implode(',',$matches[1]);
TasksCollect::query()->where('receive_id', $this->id)->update(['net_img' => $images]);//更新
});
$form->disableDeleteButton();
});
......
......@@ -201,7 +201,7 @@ class NoDoneTaskController extends AdminController
// // 在表单提交前调用
// $form->submitted(function (Form $form) {
// //...
//
// });
// //保存前回调
// $form->saving(function (Form $form) {
......@@ -210,6 +210,14 @@ class NoDoneTaskController extends AdminController
// });
//保存后回调
$form->saved(function (Form $form) {
$start = 'src="';
$end = '" alt';
$pattern = '/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/';
preg_match_all($pattern, $form->input('collects.net_img'), $matches);
$images = implode(',',$matches[1]);
TasksCollect::query()->where('receive_id', $this->id)->update(['net_img' => $images]);//更新
if ($this->status == 0) {
// dd($this->id);
\App\Models\TasksReceive::query()->where('id', $this->id)->update(['status' => 1]);//状态更新成已完成
......
......@@ -111,7 +111,12 @@ class TaskController extends AdminController
$show->field('year');
$show->field('refer');
$show->guide()->unescape();//不 转义html内容
$res = \App\Models\Task::query()->find($id);
if ($res->images){
$show->field('images','参考指南')->image();
}else{
$show->field('guide','参考指南')->unescape();//不 转义html内容
}
// $show->field('status');
// $show->field('created_at');
......@@ -126,12 +131,10 @@ class TaskController extends AdminController
*
* @return Grid
*/
protected function grid($tab = 0)
protected function grid()
{
return Grid::make(new Task(), function (Grid $grid) use ($tab) {
if ($tab) {
$grid->model()->where('status', $tab);
}
return Grid::make(new Task(), function (Grid $grid) {
$grid->model()->orderBy('created_at','desc');
// dd(trans('admin.view'));//查看
// 在 display 回调中使用
......@@ -190,7 +193,12 @@ class TaskController extends AdminController
$show->field('year');
$show->field('refer');
$show->guide()->unescape();//不 转义html内容
$res = \App\Models\Task::query()->find($id);
if ($res->images){
$show->field('images','参考指南')->image();
}else{
$show->field('guide','参考指南')->unescape();//不 转义html内容
}
// $show->field('status');
// $show->field('created_at');
......@@ -254,6 +262,7 @@ class TaskController extends AdminController
})->value(2024)->required();
$form->text('refer', '参考信源')->required();
$form->editor('guide', '收集指南')->required();
$form->hidden('images');
// $form->text('status');
// $form->display('created_at');
......@@ -261,17 +270,29 @@ class TaskController extends AdminController
// // 在表单提交前调用
// $form->submitted(function (Form $form) {
// //...
// });
$form->submitted(function (Form $form) {
$start = 'src="';
$end = '" alt';
$pattern = '/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/';
preg_match_all($pattern, $form->input('guide'), $matches);
$images = implode(',',$matches[1]);
$form->images = $images;
//...
});
// //保存前回调
// $form->saving(function (Form $form) {
// dump($form->year);
//
// });
//保存后回调
// $form->saved(function (Form $form) {
// dump($form->name);
// $form->saved(function (Form $form,$id) {
//
// $form->images = 12;
// dd($id,$form->guide);
//
// });
......@@ -300,6 +321,13 @@ class TaskController extends AdminController
// dd($request->input());
$param = $request->input();
$start = 'src="';
$end = '" alt';
$pattern = '/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/';
preg_match_all($pattern, $param['guide'], $matches);
$images = implode(',',$matches[1]);
$query = \App\Models\Task::query();
foreach ($param['city_id'] as $city) {
if ($city) {
......@@ -313,6 +341,7 @@ class TaskController extends AdminController
'year' => [$y],
'refer' => $param['refer'],
'guide' => $param['guide'],
'images' => $images,
];
$query->create($insertData);
}
......
......@@ -33,6 +33,7 @@ class Task extends Model
'price',
'status',
'num',
'images',
'created_at',
'updated_at',
];
......
......@@ -25,6 +25,8 @@ class CreateTasksTable extends Migration
$table->decimal('price')->default('0.00')->comment('单价');
$table->tinyInteger('status')->default('0')->comment('任务状态');
$table->unsignedInteger('num')->default('2')->comment('可以被领取次数');
$table->longText('images')->nullable()->comment('图片地址url 多个逗号隔开');
$table->timestamps();
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment