Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-collect
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
汪伟伟
data-collect
Commits
e40384a5
Commit
e40384a5
authored
Feb 04, 2024
by
汪伟伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
封装imges
parent
6ba13c1f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
108 deletions
+51
-108
app/Admin/Controllers/AlreadyDoneTaskController.php
+3
-18
app/Admin/Controllers/NoDoneTaskController.php
+4
-18
app/Admin/Controllers/TasController.php
+6
-36
app/Admin/Controllers/TaskController.php
+3
-36
app/Admin/Services/TaskService.php
+35
-0
No files found.
app/Admin/Controllers/AlreadyDoneTaskController.php
View file @
e40384a5
...
@@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
...
@@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
use
App\Admin\Extensions\Tools\BackAction
;
use
App\Admin\Extensions\Tools\BackAction
;
use
App\Admin\Repositories\TasksReceive
;
use
App\Admin\Repositories\TasksReceive
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\TaskService
;
use
App\Models\Task
;
use
App\Models\Task
;
use
App\Models\TasksCollect
;
use
App\Models\TasksCollect
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Admin
;
...
@@ -340,24 +341,8 @@ class AlreadyDoneTaskController extends AdminController
...
@@ -340,24 +341,8 @@ class AlreadyDoneTaskController extends AdminController
// });
// });
//保存后回调
//保存后回调
$form
->
saved
(
function
(
Form
$form
)
{
$form
->
saved
(
function
(
Form
$form
)
{
$start
=
'src="'
;
$images
=
TaskService
::
getImagesFromStr
(
$form
->
input
(
'collects.net_img'
));
$end
=
'" alt'
;
ini_set
(
'pcre.backtrack_limit'
,
'2097152'
);
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
preg_match_all
(
$pattern
,
$form
->
input
(
'collects.net_img'
),
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
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
]);
//更新
TasksCollect
::
query
()
->
where
(
'receive_id'
,
$this
->
id
)
->
update
([
'images'
=>
$images
]);
//更新
\App\Models\TasksReceive
::
query
()
->
where
(
'id'
,
$this
->
id
)
->
update
([
'time'
=>
date
(
'Y-m-d H:i:s'
)]);
//更新完成时间
\App\Models\TasksReceive
::
query
()
->
where
(
'id'
,
$this
->
id
)
->
update
([
'time'
=>
date
(
'Y-m-d H:i:s'
)]);
//更新完成时间
});
});
...
...
app/Admin/Controllers/NoDoneTaskController.php
View file @
e40384a5
...
@@ -6,6 +6,7 @@ use App\Admin\Extensions\Tools\BackAction;
...
@@ -6,6 +6,7 @@ use App\Admin\Extensions\Tools\BackAction;
use
App\Admin\Repositories\Tas
;
use
App\Admin\Repositories\Tas
;
use
App\Admin\Repositories\TasksReceive
;
use
App\Admin\Repositories\TasksReceive
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\TaskService
;
use
App\Models\TasksApprove
;
use
App\Models\TasksApprove
;
use
App\Models\TasksCollect
;
use
App\Models\TasksCollect
;
use
Dcat\Admin\Actions\Action
;
use
Dcat\Admin\Actions\Action
;
...
@@ -366,24 +367,9 @@ class NoDoneTaskController extends AdminController
...
@@ -366,24 +367,9 @@ class NoDoneTaskController extends AdminController
// });
// });
//保存后回调
//保存后回调
$form
->
saved
(
function
(
Form
$form
)
{
$form
->
saved
(
function
(
Form
$form
)
{
$start
=
'src="'
;
$end
=
'" alt'
;
$images
=
TaskService
::
getImagesFromStr
(
$form
->
input
(
'collects.net_img'
));
ini_set
(
'pcre.backtrack_limit'
,
'2097152'
);
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
preg_match_all
(
$pattern
,
$form
->
input
(
'collects.net_img'
),
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
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
]);
//更新
TasksCollect
::
query
()
->
where
(
'receive_id'
,
$this
->
id
)
->
update
([
'images'
=>
$images
]);
//更新
if
(
$this
->
status
==
0
)
{
if
(
$this
->
status
==
0
)
{
...
...
app/Admin/Controllers/TasController.php
View file @
e40384a5
...
@@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
...
@@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
use
App\Admin\Extensions\Tools\ListAction
;
use
App\Admin\Extensions\Tools\ListAction
;
use
App\Admin\Repositories\Tas
;
use
App\Admin\Repositories\Tas
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\TaskService
;
use
App\Models\Task
;
use
App\Models\Task
;
use
App\Models\TasksReceive
;
use
App\Models\TasksReceive
;
use
Dcat\Admin\Actions\Action
;
use
Dcat\Admin\Actions\Action
;
...
@@ -236,24 +237,8 @@ class TasController extends AdminController
...
@@ -236,24 +237,8 @@ class TasController extends AdminController
// // 在表单提交前调用
// // 在表单提交前调用
$form
->
submitted
(
function
(
Form
$form
)
{
$form
->
submitted
(
function
(
Form
$form
)
{
$start
=
'src="'
;
$images
=
TaskService
::
getImagesFromStr
(
$form
->
input
(
'guide'
));
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
ini_set
(
'pcre.backtrack_limit'
,
'2097152'
);
preg_match_all
(
$pattern
,
$form
->
input
(
'guide'
),
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
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
.
','
;
}
}
$form
->
images
=
$images
;
$form
->
images
=
$images
;
//...
//...
...
@@ -302,24 +287,9 @@ class TasController extends AdminController
...
@@ -302,24 +287,9 @@ class TasController extends AdminController
$param
[
'city_id'
]
=
explode
(
','
,
$city_id
);
$param
[
'city_id'
]
=
explode
(
','
,
$city_id
);
$param
[
'year'
]
=
explode
(
','
,
$year
);
$param
[
'year'
]
=
explode
(
','
,
$year
);
$start
=
'src="'
;
$images
=
TaskService
::
getImagesFromStr
(
$param
[
'guide'
]);
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
ini_set
(
'pcre.backtrack_limit'
,
'2097152'
);
preg_match_all
(
$pattern
,
$param
[
'guide'
],
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
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
.
','
;
}
}
$form
=
Form
::
make
();
$form
=
Form
::
make
();
$insertData
=
[];
$insertData
=
[];
foreach
(
$param
[
'city_id'
]
as
$city
)
{
foreach
(
$param
[
'city_id'
]
as
$city
)
{
...
...
app/Admin/Controllers/TaskController.php
View file @
e40384a5
...
@@ -7,6 +7,7 @@ use App\Admin\Extensions\Tools\ListAction;
...
@@ -7,6 +7,7 @@ use App\Admin\Extensions\Tools\ListAction;
use
App\Admin\Extensions\Tools\ReceiveAction
;
use
App\Admin\Extensions\Tools\ReceiveAction
;
use
App\Admin\Repositories\Task
;
use
App\Admin\Repositories\Task
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\CityAreaService
;
use
App\Admin\Services\TaskService
;
use
App\Models\TasksReceive
;
use
App\Models\TasksReceive
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Form
;
...
@@ -331,24 +332,7 @@ class TaskController extends AdminController
...
@@ -331,24 +332,7 @@ class TaskController extends AdminController
// // 在表单提交前调用
// // 在表单提交前调用
$form
->
submitted
(
function
(
Form
$form
)
{
$form
->
submitted
(
function
(
Form
$form
)
{
$start
=
'src="'
;
$images
=
TaskService
::
getImagesFromStr
(
$form
->
input
(
'guide'
));
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
ini_set
(
'pcre.backtrack_limit'
,
'2097152'
);
preg_match_all
(
$pattern
,
$form
->
input
(
'guide'
),
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
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
.
','
;
}
}
$form
->
images
=
$images
;
$form
->
images
=
$images
;
//...
//...
...
@@ -392,25 +376,8 @@ class TaskController extends AdminController
...
@@ -392,25 +376,8 @@ class TaskController extends AdminController
// dd($request->input());
// dd($request->input());
$param
=
$request
->
input
();
$param
=
$request
->
input
();
$images
=
TaskService
::
getImagesFromStr
(
$param
[
'guide'
]);
$start
=
'src="'
;
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
ini_set
(
'pcre.backtrack_limit'
,
'2097152'
);
preg_match_all
(
$pattern
,
$param
[
'guide'
],
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
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
.
','
;
}
}
$form
=
Form
::
make
();
$form
=
Form
::
make
();
foreach
(
$param
[
'city_id'
]
as
$city
)
{
foreach
(
$param
[
'city_id'
]
as
$city
)
{
if
(
$city
)
{
if
(
$city
)
{
...
...
app/Admin/Services/TaskService.php
0 → 100644
View file @
e40384a5
<?php
namespace
App\Admin\Services
;
use
Illuminate\Support\Facades\Storage
;
class
TaskService
{
public
static
function
getImagesFromStr
(
$guide
)
:
string
{
$start
=
'src="'
;
$end
=
'" alt'
;
$pattern
=
'/'
.
preg_quote
(
$start
)
.
'(.*?)'
.
preg_quote
(
$end
)
.
'/'
;
ini_set
(
'pcre.backtrack_limit'
,
'2097152'
);
preg_match_all
(
$pattern
,
$guide
,
$matches
);
$images
=
''
;
foreach
(
$matches
[
1
]
as
$v
)
{
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
.
','
;
}
}
return
$images
;
}
}
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