Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
note-library
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
57dfabaa
authored
May 13, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
6c28bc50
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
61 deletions
app/Http/Controllers/WebController.php
app/Services/LabelService.php
public/js/web/record.js
resources/views/web/prints.blade.php
app/Http/Controllers/WebController.php
View file @
57dfabaa
<?php
namespace
App\Http\Controllers
;
use
App\Exceptions\IcException
;
use
App\Model\TmplRelationsModel
;
use
Illuminate\Http\Request
;
use
App\Http\Requests
;
...
...
@@ -93,70 +93,44 @@ class WebController extends Controller
public
function
showPage
(
$request
,
$info
){
$info
[
'title'
]
=
'预览'
;
$id
=
$request
->
input
(
"tmpl_relation_id"
,
0
);
// dump($id);
$tmpRelation
=
TmplRelationsModel
::
where
(
"id"
,
intval
(
$id
))
->
first
();
$tmpRelation
->
template
=
$tmpRelation
->
template
;
$tmpRelation
->
tmpRelation
=
$tmpRelation
->
template
->
template_extend
;
$tmpRelation
->
saleOrder
=
$tmpRelation
->
saleOrder
;
$info
[
'templateInfo'
]
=
$tmpRelation
;
$info
[
"ichunt2020"
][
"sale_order_sn"
]
=
$tmpRelation
->
saleOrder
->
sale_order_sn
;
$info
[
"ichunt2020"
][
"goods_type"
]
=
$tmpRelation
->
saleOrder
->
goods_type
;
$info
[
"ichunt2020"
][
"goods_brand"
]
=
$tmpRelation
->
saleOrder
->
goods_brand
;
$info
[
"ichunt2020"
][
"goods_number"
]
=
$tmpRelation
->
saleOrder
->
goods_number
;
$info
[
"ichunt2020"
][
"sku_code"
]
=
$tmpRelation
->
saleOrder
->
customer_code
;
$info
[
"ichunt2020"
][
"customer_code"
]
=
$tmpRelation
->
saleOrder
->
customer_code
;
$info
[
"ichunt2020"
][
"customer_com"
]
=
$tmpRelation
->
saleOrder
->
customer_com
;
try
{
$matches
=
[];
$a
=
preg_match_all
(
'/<<<(.*?)>>>/i'
,
$tmpRelation
->
tmpRelation
->
html
,
$matches
);
foreach
(
$matches
[
1
]
as
$k
=>
$field
){
$arr
[
$k
]
=
isset
(
$info
[
"ichunt2020"
][
$field
])
?
$info
[
"ichunt2020"
][
$field
]
:
''
;
}
if
(
!
empty
(
$matches
)){
$html
=
str_replace
(
$matches
[
0
],
$arr
,
$tmpRelation
->
tmpRelation
->
html
);
}
else
{
$html
=
$tmpRelation
->
tmpRelation
->
html
;
}
$dom
=
HtmlDomParser
::
str_get_html
(
$html
);
$textareas
=
$dom
->
find
(
'textarea'
);
foreach
(
$textareas
as
$k
=>
$textarea
){
$textarea
->
innertext
=
$textarea
->
datatypes
;
}
$yiweimaits
=
$dom
->
find
(
"div[name='yiweimait']"
);
foreach
(
$yiweimaits
as
$k
=>
$yiweimait
){
$a
=
$yiweimait
->
style
;
$b
=
'data:image/png;base64,'
.
DNS1D
::
getBarcodePNG
(
$yiweimait
->
datatypes
,
"C128"
);
$c
=
preg_replace
(
'/background: url\((.*?)\) 0% 0% \/ 100% 100%/'
,
" background: url(
{
$b
}
) 0% 0% / 100% 100% "
,
$a
);
$yiweimait
->
style
=
$c
;
}
$html
=
(
new
\App\Services\LabelService
)
->
getLabelHtml
(
5
);
$info
[
"html"
]
=
$html
;
return
view
(
'web'
,
$info
);
}
$erweimas
=
$dom
->
find
(
"div[name='erweimait']"
);
foreach
(
$erweimas
as
$k
=>
$erweima
){
$a
=
$erweima
->
style
;
$b
=
'data:image/png;base64,'
.
DNS2D
::
getBarcodePNG
(
$erweima
->
datatypes
,
"QRCODE"
);
$c
=
preg_replace
(
'/background: url\((.*?)\) 0% 0% \/ 100% 100%/'
,
" background: url(
{
$b
}
) 0% 0% / 100% 100% "
,
$a
);
$erweima
->
style
=
$c
;
public
function
prints
(
$request
,
$info
){
$tmpl_relationids
=
$request
->
input
(
"tmpl_relationids"
,
''
);
$tmpl_relationid_arr
=
explode
(
","
,
$tmpl_relationids
);
if
(
empty
(
$tmpl_relationids
)){
die
(
"没有要打印的数据"
);
}
if
(
!
empty
(
$tmpl_relationid_arr
)){
$tmpl_relationid_arr
=
array_unique
(
$tmpl_relationid_arr
);
$tmpl_relationid_arr
=
array_map
(
"intval"
,
$tmpl_relationid_arr
);
$tmpl_relationid_arr
=
array_filter
(
$tmpl_relationid_arr
,
function
(
$val
){
if
(
$val
>
0
)
{
return
true
;
}
else
{
return
false
;
}
});
}
// dump($tmpl_relationid_arr);
$info
[
'title'
]
=
'打印'
;
$templateRelation
=
TmplRelationsModel
::
where
(
"create_userid"
,
$request
->
user
->
userId
)
->
whereIn
(
"id"
,
$tmpl_relationid_arr
)
->
get
();
$html
=
[];
foreach
(
$templateRelation
as
$item
){
$createHtml
=
(
new
\App\Services\LabelService
)
->
getLabelHtml
(
$item
->
id
);
if
(
$createHtml
){
array_push
(
$html
,
$createHtml
);
}
}
catch
(
\Exception
$e
){
dump
(
$e
->
getMessage
());
}
// \View::make('admin.messages', $info["ichunt2020"]);
// dump($html);exit;
$info
[
"html"
]
=
$dom
;
return
view
(
'web'
,
$info
);
$info
[
"html"
]
=
$html
;
return
view
(
'web.prints'
,
$info
);
}
...
...
app/Services/LabelService.php
0 → 100644
View file @
57dfabaa
<?php
namespace
App\Services
;
use
App\Http\Requests
;
use
DB
;
use
Sunra\PhpSimple\HtmlDomParser
;
use
Log
;
use
App\Http\Controllers\Controller
;
use
App\Model\TemplateListModel
;
use
App\Model\NodesModel
;
use
App\Model\TmplRelationsModel
;
class
LabelService
{
public
function
getLabelHtml
(
$id
){
// dump($id);
$tmpRelation
=
TmplRelationsModel
::
where
(
"id"
,
intval
(
$id
))
->
first
();
$tmpRelation
->
template
=
$tmpRelation
->
template
;
$tmpRelation
->
tmpRelation
=
$tmpRelation
->
template
->
template_extend
;
$tmpRelation
->
saleOrder
=
$tmpRelation
->
saleOrder
;
$info
[
'templateInfo'
]
=
$tmpRelation
;
$info
[
"ichunt2020"
][
"sale_order_sn"
]
=
$tmpRelation
->
saleOrder
->
sale_order_sn
;
$info
[
"ichunt2020"
][
"goods_type"
]
=
$tmpRelation
->
saleOrder
->
goods_type
;
$info
[
"ichunt2020"
][
"goods_brand"
]
=
$tmpRelation
->
saleOrder
->
goods_brand
;
$info
[
"ichunt2020"
][
"goods_number"
]
=
$tmpRelation
->
saleOrder
->
goods_number
;
$info
[
"ichunt2020"
][
"sku_code"
]
=
$tmpRelation
->
saleOrder
->
sku_code
;
$info
[
"ichunt2020"
][
"customer_code"
]
=
$tmpRelation
->
saleOrder
->
customer_code
;
$info
[
"ichunt2020"
][
"customer_com"
]
=
$tmpRelation
->
saleOrder
->
customer_com
;
try
{
$matches
=
[];
$a
=
preg_match_all
(
'/<<<(.*?)>>>/i'
,
$tmpRelation
->
tmpRelation
->
html
,
$matches
);
foreach
(
$matches
[
1
]
as
$k
=>
$field
){
$arr
[
$k
]
=
isset
(
$info
[
"ichunt2020"
][
$field
])
?
$info
[
"ichunt2020"
][
$field
]
:
''
;
}
if
(
!
empty
(
$matches
)){
$html
=
str_replace
(
$matches
[
0
],
$arr
,
$tmpRelation
->
tmpRelation
->
html
);
}
else
{
$html
=
$tmpRelation
->
tmpRelation
->
html
;
}
$dom
=
HtmlDomParser
::
str_get_html
(
$html
);
$textareas
=
$dom
->
find
(
'textarea'
);
foreach
(
$textareas
as
$k
=>
$textarea
){
// dump($textarea->datatypes);
if
(
$textarea
->
datatypes
){
$textarea
->
innertext
=
$textarea
->
datatypes
;
}
if
(
$textarea
->
datatypes
!==
false
&&
$textarea
->
datatypes
==
""
){
$textarea
->
innertext
=
""
;
$textarea
->
placeholder
=
""
;
}
}
$yiweimaits
=
$dom
->
find
(
"div[name='yiweimait']"
);
foreach
(
$yiweimaits
as
$k
=>
$yiweimait
){
$a
=
$yiweimait
->
style
;
$b
=
'data:image/png;base64,'
.
DNS1D
::
getBarcodePNG
(
$yiweimait
->
datatypes
,
"C128"
);
$c
=
preg_replace
(
'/background: url\((.*?)\) 0% 0% \/ 100% 100%/'
,
" background: url(
{
$b
}
) 0% 0% / 100% 100% "
,
$a
);
$yiweimait
->
style
=
$c
;
}
$erweimas
=
$dom
->
find
(
"div[name='erweimait']"
);
foreach
(
$erweimas
as
$k
=>
$erweima
){
$a
=
$erweima
->
style
;
$b
=
'data:image/png;base64,'
.
DNS2D
::
getBarcodePNG
(
$erweima
->
datatypes
,
"QRCODE"
);
$c
=
preg_replace
(
'/background: url\((.*?)\) 0% 0% \/ 100% 100%/'
,
" background: url(
{
$b
}
) 0% 0% / 100% 100% "
,
$a
);
$erweima
->
style
=
$c
;
}
return
$dom
;
}
catch
(
\Exception
$e
){
Log
::
info
(
sprintf
(
"解析便签模板失败:%s"
,
$e
->
getMessage
()));
return
false
;
}
}
}
\ No newline at end of file
public/js/web/record.js
View file @
57dfabaa
...
...
@@ -121,7 +121,15 @@ layui.use(['form', 'table', 'laydate'], function(){
layer
.
msg
(
"至少得选中一个打印标签"
,
{
time
:
2000
});
// 阻止重复提交
return
;
}
//layer.alert(JSON.stringify(data));
var
tmp
=
[];
console
.
log
(
data
);
for
(
var
k
=
0
;
k
<
data
.
length
;
k
++
){
tmp
.
push
(
data
[
k
].
id
)
}
var
href
=
"/web/prints?tmpl_relationids="
+
tmp
.
join
(
","
)
window
.
open
(
href
)
break
;
case
'getCheckLength'
:
var
data
=
checkStatus
.
data
;
...
...
resources/views/web/prints.blade.php
0 → 100644
View file @
57dfabaa
<div
class=
"dybox"
>
@foreach($html as $item)
{!! $item !!}
@endforeach
</div>
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