Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
data-collect
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
汪伟伟
data-collect
Commits
ac3b1101
Commit
ac3b1101
authored
Jan 24, 2024
by
汪伟伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
富文本图片base64 转成 url
parent
9c757215
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
46 deletions
+75
-46
app/Admin/Controllers/AlreadyDoneTaskController.php
app/Admin/Controllers/AlreadyDoneTaskController.php
+11
-4
app/Admin/Controllers/NoDoneTaskController.php
app/Admin/Controllers/NoDoneTaskController.php
+15
-6
app/Admin/Controllers/TaskController.php
app/Admin/Controllers/TaskController.php
+46
-33
app/Admin/Controllers/TasksApproveController.php
app/Admin/Controllers/TasksApproveController.php
+1
-1
resources/views/admin/check.blade.php
resources/views/admin/check.blade.php
+2
-2
No files found.
app/Admin/Controllers/AlreadyDoneTaskController.php
View file @
ac3b1101
...
...
@@ -13,6 +13,7 @@ use Dcat\Admin\Layout\Content;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Dcat\Admin\Widgets\Tooltip
;
use
Illuminate\Support\Facades\Storage
;
class
AlreadyDoneTaskController
extends
AdminController
{
...
...
@@ -211,11 +212,17 @@ class AlreadyDoneTaskController extends AdminController
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
preg_match_all
(
$pattern
,
$form
->
input
(
'collects.net_img'
),
$matches
);
$images
=
implode
(
','
,
$matches
[
1
])
;
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
if
(
!
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
))
{
//不是链接
$images
=
null
;
break
;
if
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
)
{
//是链接
$images
.=
$v
.
','
;
}
else
{
// 去除Base64字符串开头的"data:"及其后面的逗号
$base64Data
=
substr
(
$v
,
strpos
(
$v
,
','
)
+
1
);
$path
=
'/tinymce/images/'
.
time
()
.
uniqid
()
.
'.png'
;
Storage
::
disk
(
'admin'
)
->
put
(
$path
,
base64_decode
(
$base64Data
));
$url
=
Storage
::
disk
(
'admin'
)
->
url
(
$path
);
$images
.=
$url
.
','
;
}
}
TasksCollect
::
query
()
->
where
(
'receive_id'
,
$this
->
id
)
->
update
([
'images'
=>
$images
]);
//更新
...
...
app/Admin/Controllers/NoDoneTaskController.php
View file @
ac3b1101
...
...
@@ -14,6 +14,7 @@ use Dcat\Admin\Layout\Content;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Storage
;
class
NoDoneTaskController
extends
AdminController
{
...
...
@@ -155,13 +156,14 @@ class NoDoneTaskController extends AdminController
$no
=
\App\Models\TasksReceive
::
query
()
->
where
(
'id'
,
'!='
,
$id
)
->
where
(
'user_id'
,(
Admin
::
user
())
->
id
)
->
where
(
'status'
,
0
)
->
orderBy
(
'created_at'
)
->
first
();
if
(
$no
){
$url
=
'/noDone/'
.
$no
->
id
.
'/edit'
;
}
else
{
$url
=
'/
already
'
;
$url
=
'/
noDone
'
;
}
...
...
@@ -225,11 +227,17 @@ class NoDoneTaskController extends AdminController
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
preg_match_all
(
$pattern
,
$form
->
input
(
'collects.net_img'
),
$matches
);
$images
=
implode
(
','
,
$matches
[
1
])
;
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
if
(
!
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
))
{
//不是链接
$images
=
null
;
break
;
if
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
)
{
//是链接
$images
.=
$v
.
','
;
}
else
{
// 去除Base64字符串开头的"data:"及其后面的逗号
$base64Data
=
substr
(
$v
,
strpos
(
$v
,
','
)
+
1
);
$path
=
'/tinymce/images/'
.
time
()
.
uniqid
()
.
'.png'
;
Storage
::
disk
(
'admin'
)
->
put
(
$path
,
base64_decode
(
$base64Data
));
$url
=
Storage
::
disk
(
'admin'
)
->
url
(
$path
);
$images
.=
$url
.
','
;
}
}
TasksCollect
::
query
()
->
where
(
'receive_id'
,
$this
->
id
)
->
update
([
'images'
=>
$images
]);
//更新
...
...
@@ -250,13 +258,14 @@ class NoDoneTaskController extends AdminController
$no
=
\App\Models\TasksReceive
::
query
()
->
where
(
'id'
,
'!='
,
$this
->
id
)
->
where
(
'user_id'
,(
Admin
::
user
())
->
id
)
->
where
(
'status'
,
0
)
->
orderBy
(
'created_at'
,
'desc'
)
->
first
();
if
(
$no
){
$url
=
'/noDone/'
.
$no
->
id
.
'/edit'
;
}
else
{
$url
=
'/
already
'
;
$url
=
'/
noDone
'
;
}
// var_dump($url);
return
$form
->
response
()
->
success
(
'保存成功'
)
->
redirect
(
$url
);
...
...
app/Admin/Controllers/TaskController.php
View file @
ac3b1101
...
...
@@ -14,6 +14,7 @@ use Dcat\Admin\Layout\Content;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Storage
;
class
TaskController
extends
AdminController
...
...
@@ -37,14 +38,14 @@ class TaskController extends AdminController
{
$user
=
Admin
::
user
();
$exists
=
TasksReceive
::
query
()
->
where
(
'user_id'
,
$user
->
id
)
->
pluck
(
'task_id'
)
->
toArray
();
$exists
=
TasksReceive
::
query
()
->
where
(
'user_id'
,
$user
->
id
)
->
pluck
(
'task_id'
)
->
toArray
();
// $model = \App\Models\Task::query()->whereNotIn('id',$exists)
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
use
(
$user
,
$exists
)
{
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
use
(
$user
,
$exists
)
{
$grid
->
addTableClass
([
'table-text-center'
]);
//设置表格文字居中
// $grid->title('dasd');
$grid
->
model
()
->
whereNotIn
(
'id'
,
$exists
);
$grid
->
model
()
->
whereNotIn
(
'id'
,
$exists
);
// dd(Admin::user()->is_admin);
// dd(trans('admin.view'));//查看
...
...
@@ -56,14 +57,14 @@ class TaskController extends AdminController
// $grid->column('id')->sortable();
$grid
->
column
(
'name'
);
$grid
->
column
(
'level'
);
$grid
->
column
(
'city_id'
)
->
display
(
function
(
$v
){
$grid
->
column
(
'city_id'
)
->
display
(
function
(
$v
)
{
return
CityAreaService
::
getAreaName
(
$v
);
});
$grid
->
column
(
'year'
);
$grid
->
column
(
'refer'
)
->
display
(
function
(
$val
)
{
if
(
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
{
//是链接
return
"<a href=
{
$val
}
target='_blank' style='color: #00b44e'>点击查看</a>"
;
}
else
{
}
else
{
return
$val
;
}
});
...
...
@@ -113,10 +114,10 @@ class TaskController extends AdminController
$show
->
field
(
'year'
);
$show
->
field
(
'refer'
);
$res
=
\App\Models\Task
::
query
()
->
find
(
$id
);
if
(
$res
->
images
){
$show
->
field
(
'images'
,
'参考指南'
)
->
image
();
}
else
{
$show
->
field
(
'guide'
,
'参考指南'
)
->
unescape
();
//不 转义html内容
if
(
$res
->
images
)
{
$show
->
field
(
'images'
,
'参考指南'
)
->
image
();
}
else
{
$show
->
field
(
'guide'
,
'参考指南'
)
->
unescape
();
//不 转义html内容
}
// $show->field('status');
...
...
@@ -134,10 +135,10 @@ class TaskController extends AdminController
*/
protected
function
grid
()
{
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
{
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
{
$grid
->
addTableClass
([
'table-text-center'
]);
//设置表格文字居中
$grid
->
model
()
->
orderBy
(
'created_at'
,
'desc'
);
$grid
->
model
()
->
orderBy
(
'created_at'
,
'desc'
);
// dd(trans('admin.view'));//查看
// 在 display 回调中使用
...
...
@@ -149,14 +150,14 @@ class TaskController extends AdminController
$grid
->
column
(
'name'
);
$grid
->
column
(
'level'
);
// $grid->column('city_id')->distpicker();
$grid
->
column
(
'city_id'
)
->
display
(
function
(
$v
){
$grid
->
column
(
'city_id'
)
->
display
(
function
(
$v
)
{
return
CityAreaService
::
getAreaName
(
$v
);
});
$grid
->
column
(
'year'
);
$grid
->
column
(
'refer'
)
->
display
(
function
(
$val
)
{
if
(
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
{
//是链接
return
"<a href=
{
$val
}
target='_blank' style='color: #00b44e'>点击查看</a>"
;
}
else
{
}
else
{
return
$val
;
}
});
...
...
@@ -198,10 +199,10 @@ class TaskController extends AdminController
$show
->
field
(
'refer'
);
$show
->
field
(
'price'
);
$res
=
\App\Models\Task
::
query
()
->
find
(
$id
);
if
(
$res
->
images
){
$show
->
field
(
'images'
,
'参考指南'
)
->
image
();
}
else
{
$show
->
field
(
'guide'
,
'参考指南'
)
->
unescape
();
//不 转义html内容
if
(
$res
->
images
)
{
$show
->
field
(
'images'
,
'参考指南'
)
->
image
();
}
else
{
$show
->
field
(
'guide'
,
'参考指南'
)
->
unescape
();
//不 转义html内容
}
// $show->field('status');
...
...
@@ -218,7 +219,7 @@ class TaskController extends AdminController
$data
=
json_decode
(
file_get_contents
(
base_path
(
'app/china_all_area.json'
)),
true
);
$city
=
[];
foreach
(
$data
[
'100000'
]
as
$key
=>
$value
)
{
foreach
(
$data
[
'100000'
]
as
$key
=>
$value
)
{
if
(
isset
(
$data
[
$key
]))
{
foreach
(
$data
[
$key
]
as
$k
=>
$val
)
{
$city
[]
=
[
...
...
@@ -248,7 +249,7 @@ class TaskController extends AdminController
$form
->
select
(
'level'
)
->
options
([
1
=>
1
,
2
=>
2
,
3
=>
3
,
4
=>
4
,
5
=>
5
])
->
required
();
// $form->select('province_id', '省')->options($arr)->loads('city_id', '/getCity');
$form
->
multipleSelect
(
'city_id'
,
'选择地区'
)
->
options
(
'/getCity'
)
->
required
()
->
saving
(
function
(
$v
){
$form
->
multipleSelect
(
'city_id'
,
'选择地区'
)
->
options
(
'/getCity'
)
->
required
()
->
saving
(
function
(
$v
)
{
return
$v
[
0
];
});
...
...
@@ -266,7 +267,7 @@ class TaskController extends AdminController
})
->
value
(
2024
)
->
required
();
$form
->
decimal
(
'price'
,
'单价'
);
$form
->
text
(
'refer'
,
'参考信源'
)
->
required
();
$form
->
editor
(
'guide'
,
'收集指南'
)
->
options
([
'pasteImage'
=>
false
])
->
required
();
$form
->
editor
(
'guide'
,
'收集指南'
)
->
options
([
'pasteImage'
=>
false
])
->
required
();
$form
->
hidden
(
'images'
);
// $form->text('status');
...
...
@@ -281,13 +282,19 @@ class TaskController extends AdminController
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
preg_match_all
(
$pattern
,
$form
->
input
(
'guide'
),
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
if
(
!
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
))
{
//不是链接
$form
->
images
=
null
;
return
;
if
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
)
{
//是链接
$images
.=
$v
.
','
;
}
else
{
// 去除Base64字符串开头的"data:"及其后面的逗号
$base64Data
=
substr
(
$v
,
strpos
(
$v
,
','
)
+
1
);
$path
=
'/tinymce/images/'
.
time
()
.
uniqid
()
.
'.png'
;
Storage
::
disk
(
'admin'
)
->
put
(
$path
,
base64_decode
(
$base64Data
));
$url
=
Storage
::
disk
(
'admin'
)
->
url
(
$path
);
$images
.=
$url
.
','
;
}
}
$images
=
implode
(
','
,
$matches
[
1
]);
$form
->
images
=
$images
;
//...
...
...
@@ -336,11 +343,17 @@ class TaskController extends AdminController
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
preg_match_all
(
$pattern
,
$param
[
'guide'
],
$matches
);
$images
=
implode
(
','
,
$matches
[
1
])
;
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
if
(
!
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
))
{
//是链接
$images
=
null
;
break
;
if
(
filter_var
(
$v
,
FILTER_VALIDATE_URL
)
!==
false
)
{
//是链接
$images
.=
$v
.
','
;
}
else
{
// 去除Base64字符串开头的"data:"及其后面的逗号
$base64Data
=
substr
(
$v
,
strpos
(
$v
,
','
)
+
1
);
$path
=
'/tinymce/images/'
.
time
()
.
uniqid
()
.
'.png'
;
Storage
::
disk
(
'admin'
)
->
put
(
$path
,
base64_decode
(
$base64Data
));
$url
=
Storage
::
disk
(
'admin'
)
->
url
(
$path
);
$images
.=
$url
.
','
;
}
}
...
...
@@ -357,7 +370,7 @@ class TaskController extends AdminController
'year'
=>
[
$y
],
'refer'
=>
$param
[
'refer'
],
'guide'
=>
$param
[
'guide'
],
'price'
=>
$param
[
'price'
]
??
0
,
'price'
=>
$param
[
'price'
]
??
0
,
'images'
=>
$images
,
];
$query
->
create
(
$insertData
);
...
...
@@ -372,11 +385,11 @@ class TaskController extends AdminController
public
function
destroy
(
$id
)
{
$idArr
=
explode
(
','
,
$id
);
foreach
(
$idArr
as
$idv
){
if
(
TasksReceive
::
query
()
->
where
(
'task_id'
,
$idv
)
->
exists
())
{
$idArr
=
explode
(
','
,
$id
);
foreach
(
$idArr
as
$idv
)
{
if
(
TasksReceive
::
query
()
->
where
(
'task_id'
,
$idv
)
->
exists
())
{
$task
=
\App\Models\Task
::
query
()
->
find
(
$idv
);
return
$this
->
form
()
->
response
()
->
error
(
'已经有用户领取了任务,不允许删除,任务名称:'
.
$task
->
name
.
' '
.
CityAreaService
::
getAreaName
(
$task
->
city_id
)
.
' '
.
$task
->
year
);
return
$this
->
form
()
->
response
()
->
error
(
'已经有用户领取了任务,不允许删除,任务名称:'
.
$task
->
name
.
' '
.
CityAreaService
::
getAreaName
(
$task
->
city_id
)
.
' '
.
$task
->
year
);
}
}
...
...
app/Admin/Controllers/TasksApproveController.php
View file @
ac3b1101
...
...
@@ -28,7 +28,7 @@ class TasksApproveController extends AdminController
public
function
checkData
(
Request
$request
)
{
$page
=
$request
->
input
(
'page'
,
1
);
$pageSize
=
$request
->
input
(
'per_page'
,
5
);
$pageSize
=
$request
->
input
(
'per_page'
,
10
);
// var_dump($request->input());
$data
=
Task
::
query
()
->
whereHas
(
'receives'
,
function
(
$query
)
{
...
...
resources/views/admin/check.blade.php
View file @
ac3b1101
...
...
@@ -232,9 +232,9 @@
<
span
class
=
"caret"
></
span
>
</
a
>
<
ul
class
=
"dropdown-menu"
><
li
class
=
"dropdown-item"
><
a
href
=/
approves
?
page_size
=
5
>
5
</
a
></
li
><
li
href
=/
approves
?
page_size
=
10
>
10
</
a
></
li
><
li
class
=
"dropdown-item"
><
a
href
=/
approves
?
per_page
=
1
0
>
10
</
a
></
li
><
li
href
=/
approves
?
per_page
=
1
5
>
15
</
a
></
li
><
li
class
=
"dropdown-item"
><
a
href
=/
approves
?
per_page
=
20
>
20
</
a
></
li
><
li
class
=
"dropdown-item"
><
a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment