Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GeliBusinessPlatform
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
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ljy
GeliBusinessPlatform
Commits
b5bd873f
Commit
b5bd873f
authored
Apr 30, 2021
by
lujunye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
阿斯顿发送到发333
parent
a87a2bec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
12 deletions
+131
-12
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
...erdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
GeliBusinessPlatform/ViewController/1.1入库&出库/出库/NewCKVc.swift
...BusinessPlatform/ViewController/1.1入库&出库/出库/NewCKVc.swift
+131
-12
No files found.
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
View file @
b5bd873f
No preview for this file type
GeliBusinessPlatform/ViewController/1.1入库&出库/出库/NewCKVc.swift
View file @
b5bd873f
...
@@ -8,8 +8,9 @@
...
@@ -8,8 +8,9 @@
import
UIKit
import
UIKit
import
LGButton
import
LGButton
import
WebKit
class
NewCKVc
:
BaseViewController
,
UITableViewDelegate
,
UITableViewDataSource
,
CKNonGmCellDelegate
,
CKGmCellDelegate
,
PiCiXuanZeViewControllerDelegate
,
GLAlertSelectViewDelegate
,
NewSelectItemVcDelegate
,
GeliAlertTextViewDelegate
,
Print_Gprinter_View_Delegate
{
class
NewCKVc
:
BaseViewController
,
UITableViewDelegate
,
UITableViewDataSource
,
CKNonGmCellDelegate
,
CKGmCellDelegate
,
PiCiXuanZeViewControllerDelegate
,
GLAlertSelectViewDelegate
,
NewSelectItemVcDelegate
,
GeliAlertTextViewDelegate
,
Print_Gprinter_View_Delegate
,
WKNavigationDelegate
{
func
NewSelectItemVcSelect
(
datas
:
Array
<
InputInitInfoGoodsInfoModel
>
,
pici
:
Array
<
Array
<
GetGoodBatchDataModel
>>
,
select
:
Array
<
Int
>
,
str
:
Array
<
String
>
,
typeArr
:
Array
<
Int
>
,
imgArr
:
Array
<
String
>
)
{
func
NewSelectItemVcSelect
(
datas
:
Array
<
InputInitInfoGoodsInfoModel
>
,
pici
:
Array
<
Array
<
GetGoodBatchDataModel
>>
,
select
:
Array
<
Int
>
,
str
:
Array
<
String
>
,
typeArr
:
Array
<
Int
>
,
imgArr
:
Array
<
String
>
)
{
rkSelectArr
.
removeAll
()
rkSelectArr
.
removeAll
()
datas
.
forEach
{
(
item
)
in
datas
.
forEach
{
(
item
)
in
...
@@ -198,20 +199,38 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo
...
@@ -198,20 +199,38 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo
}
}
var
goodsInfoArr
:
Array
<
Any
>
=
[]
var
goodsInfoArr
:
Array
<
Any
>
=
[]
@IBOutlet
weak
var
gm_view
:
UIView
!
@IBOutlet
weak
var
gm_view
:
UIView
!
let
wkWebView
=
WKWebView
()
// 页面加载完成之后调用
func
webView
(
_
webView
:
WKWebView
,
didFinish
navigation
:
WKNavigation
!
){
print
(
"页面加载完成..."
)
webView
.
takeScreenshotOfFullContent
{
(
img
)
in
let
command
=
TscCommand
()
command
.
addSize
(
40
,
30
)
command
.
addGap
(
withM
:
2
,
withN
:
0
)
command
.
addReference
(
0
,
0
)
command
.
addTear
(
"ON"
)
command
.
addQueryPrinterStatus
(
Response
(
rawValue
:
1
)
!
)
command
.
addCls
()
command
.
addBitmapwithX
(
0
,
withY
:
0
,
withMode
:
0
,
withWidth
:
400
,
with
:
img
)
command
.
addPrint
(
1
,
1
)
ConnecterManager
.
sharedInstance
()?
.
write
(
command
.
getCommand
())
}
}
@IBAction
func
ck_action
(
_
sender
:
UIButton
)
{
@IBAction
func
ck_action
(
_
sender
:
UIButton
)
{
let
command
=
TscCommand
()
let
urlStr
=
"https://c.gelifood.com/market/src/views/Order/codeDetail.html?order_id=12767"
command
.
addSize
(
40
,
30
)
let
urlString
=
urlStr
.
addingPercentEncoding
(
withAllowedCharacters
:
.
urlQueryAllowed
)
!
command
.
addGap
(
withM
:
2
,
withN
:
0
)
let
url
=
URL
(
string
:
urlString
)
command
.
addReference
(
0
,
0
)
command
.
addTear
(
"ON"
)
let
request
=
URLRequest
.
init
(
url
:
url
!
,
cachePolicy
:
.
reloadRevalidatingCacheData
,
timeoutInterval
:
10
)
command
.
addQueryPrinterStatus
(
Response
(
rawValue
:
1
)
!
)
wkWebView
.
navigationDelegate
=
self
command
.
addCls
()
wkWebView
.
load
(
request
)
let
image
=
UIImage
(
named
:
"3.png"
)
command
.
addBitmapwithX
(
0
,
withY
:
0
,
withMode
:
0
,
withWidth
:
400
,
with
:
image
)
command
.
addPrint
(
1
,
1
)
ConnecterManager
.
sharedInstance
()?
.
write
(
command
.
getCommand
())
return
return
if
isGm
{
if
isGm
{
...
@@ -643,3 +662,103 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo
...
@@ -643,3 +662,103 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo
glSelectView
=
nil
glSelectView
=
nil
}
}
}
}
/// WebViewPrintPageRenderer: use to print the full content of webview into one image
internal
final
class
WebViewPrintPageRenderer
:
UIPrintPageRenderer
{
private
var
formatter
:
UIPrintFormatter
private
var
contentSize
:
CGSize
/// 生成PrintPageRenderer实例
///
/// - Parameters:
/// - formatter: WebView的viewPrintFormatter
/// - contentSize: WebView的ContentSize
required
init
(
formatter
:
UIPrintFormatter
,
contentSize
:
CGSize
)
{
self
.
formatter
=
formatter
self
.
contentSize
=
contentSize
super
.
init
()
self
.
addPrintFormatter
(
formatter
,
startingAtPageAt
:
0
)
}
override
var
paperRect
:
CGRect
{
return
CGRect
.
init
(
origin
:
.
zero
,
size
:
contentSize
)
}
override
var
printableRect
:
CGRect
{
return
CGRect
.
init
(
origin
:
.
zero
,
size
:
contentSize
)
}
private
func
printContentToPDFPage
()
->
CGPDFPage
?
{
let
data
=
NSMutableData
()
UIGraphicsBeginPDFContextToData
(
data
,
self
.
paperRect
,
nil
)
self
.
prepare
(
forDrawingPages
:
NSMakeRange
(
0
,
1
))
let
bounds
=
UIGraphicsGetPDFContextBounds
()
UIGraphicsBeginPDFPage
()
self
.
drawPage
(
at
:
0
,
in
:
bounds
)
UIGraphicsEndPDFContext
()
let
cfData
=
data
as
CFData
guard
let
provider
=
CGDataProvider
.
init
(
data
:
cfData
)
else
{
return
nil
}
let
pdfDocument
=
CGPDFDocument
.
init
(
provider
)
let
pdfPage
=
pdfDocument
?
.
page
(
at
:
1
)
return
pdfPage
}
private
func
covertPDFPageToImage
(
_
pdfPage
:
CGPDFPage
)
->
UIImage
?
{
let
pageRect
=
pdfPage
.
getBoxRect
(
.
trimBox
)
let
contentSize
=
CGSize
.
init
(
width
:
floor
(
pageRect
.
size
.
width
),
height
:
floor
(
pageRect
.
size
.
height
))
// usually you want UIGraphicsBeginImageContextWithOptions last parameter to be 0.0 as this will us the device's scale
UIGraphicsBeginImageContextWithOptions
(
contentSize
,
true
,
2.0
)
guard
let
context
=
UIGraphicsGetCurrentContext
()
else
{
return
nil
}
context
.
setFillColor
(
UIColor
.
white
.
cgColor
)
context
.
setStrokeColor
(
UIColor
.
white
.
cgColor
)
context
.
fill
(
pageRect
)
context
.
saveGState
()
context
.
translateBy
(
x
:
0
,
y
:
contentSize
.
height
)
context
.
scaleBy
(
x
:
1.0
,
y
:
-
1.0
)
context
.
interpolationQuality
=
.
low
context
.
setRenderingIntent
(
.
defaultIntent
)
context
.
drawPDFPage
(
pdfPage
)
context
.
restoreGState
()
let
image
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
image
}
/// print the full content of webview into one image
///
/// - Important: if the size of content is very large, then the size of image will be also very large
/// - Returns: UIImage?
internal
func
printContentToImage
()
->
UIImage
?
{
guard
let
pdfPage
=
self
.
printContentToPDFPage
()
else
{
return
nil
}
let
image
=
self
.
covertPDFPageToImage
(
pdfPage
)
return
image
}
}
extension
WKWebView
{
public
func
takeScreenshotOfFullContent
(
_
completion
:
@escaping
((
UIImage
?)
->
Void
))
{
self
.
scrollView
.
setContentOffset
(
CGPoint
(
x
:
0
,
y
:
0
),
animated
:
false
)
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
DispatchTime
.
now
()
+
0.3
)
{
let
renderer
=
WebViewPrintPageRenderer
.
init
(
formatter
:
self
.
viewPrintFormatter
(),
contentSize
:
self
.
scrollView
.
contentSize
)
let
image
=
renderer
.
printContentToImage
()
completion
(
image
)
}
}
}
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