Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
b3ebefaf
Commit
b3ebefaf
authored
Jun 05, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 文件清单添加上传功能
parent
4d6d956b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
250 additions
and
41 deletions
+250
-41
YHFileListViewController.swift
...ice(服务中心)/FileList(文件清单)/C/YHFileListViewController.swift
+20
-11
YHFileListModel.swift
...igentService(服务中心)/FileList(文件清单)/M/YHFileListModel.swift
+1
-11
YHFileListContentView.swift
...ervice(服务中心)/FileList(文件清单)/V/YHFileListContentView.swift
+9
-3
YHFileListItemView.swift
...ntService(服务中心)/FileList(文件清单)/V/YHFileListItemView.swift
+16
-5
YHFileListItemsView.swift
...tService(服务中心)/FileList(文件清单)/V/YHFileListItemsView.swift
+186
-0
YHCertificateUploadContentListVC.swift
...rtificates(我的证书)/C/YHCertificateUploadContentListVC.swift
+5
-0
YHMineCertificateEntryViewController.swift
...icates(我的证书)/C/YHMineCertificateEntryViewController.swift
+1
-0
YHCertificateModel.swift
...ice(服务中心)/MyCertificates(我的证书)/M/YHCertificateModel.swift
+1
-1
YHCertificateViewModel.swift
...务中心)/MyCertificates(我的证书)/VM/YHCertificateViewModel.swift
+7
-10
YhConstant.swift
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
+4
-0
No files found.
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/FileList(文件清单)/C/YHFileListViewController.swift
View file @
b3ebefaf
...
...
@@ -12,13 +12,12 @@ import Photos
文件清单
*/
class
YHFileListViewController
:
YHBaseViewController
{
var
orderId
:
Int
?
private
let
certificateReqVM
:
YHCertificateViewModel
=
YHCertificateViewModel
()
private
lazy
var
headView
:
YHFileListHeaerView
=
{
let
view
=
YHFileListHeaerView
()
view
.
backgroundColor
=
.
clear
...
...
@@ -37,6 +36,7 @@ class YHFileListViewController: YHBaseViewController {
view
.
backgroundColor
=
.
white
view
.
layer
.
cornerRadius
=
kCornerRadius12
view
.
clipsToBounds
=
true
view
.
orderId
=
self
.
orderId
??
0
return
view
}()
...
...
@@ -51,15 +51,18 @@ class YHFileListViewController: YHBaseViewController {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
setupUI
()
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
// 【WARNING】加载数据不要在viewWillAppear里请求数据 因为点击itemView上传文件拉起系统VC,dismiss后 所有itemView会被移除,导致itemView中使用的block找不到self(即itemView本身)引起上传功能bug
// pushVC返回需要刷新数据时通过通知或block重新刷新数据
loadData
()
loadData2
()
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
refreshListData
)
,
name
:
YhConstant
.
YhNotification
.
refreshCertificateFileListNotifiction
,
object
:
nil
)
}
deinit
{
NotificationCenter
.
default
.
removeObserver
(
self
)
}
private
lazy
var
footLable
:
UILabel
=
{
let
footLable
=
UILabel
()
...
...
@@ -75,9 +78,15 @@ class YHFileListViewController: YHBaseViewController {
}
extension
YHFileListViewController
{
@objc
func
refreshListData
()
{
loadData
()
loadData2
()
}
func
loadData
()
{
if
let
orderID
=
UserDefaults
.
standard
.
value
(
forKey
:
"orderIdForPreview"
)
{
let
param
=
[
"order_id"
:
orderID
,
"node"
:
"1"
,
"state"
:
"1"
]
if
let
orderID
=
orderId
{
let
param
=
[
"order_id"
:
orderID
,
"node"
:
"1"
,
"state"
:
"1"
]
as
[
String
:
Any
]
certificateReqVM
.
getCertificateFileListData
(
params
:
param
)
{
success
,
error
in
if
success
==
true
{
self
.
myContentView
.
dataModel
=
self
.
certificateReqVM
.
arrFileListData
...
...
@@ -104,8 +113,8 @@ extension YHFileListViewController {
}
func
loadData2
()
{
if
let
orderID
=
UserDefaults
.
standard
.
value
(
forKey
:
"orderIdForPreview"
)
{
let
param
=
[
"order_id"
:
orderID
,
"node"
:
"1"
,
"state"
:
"1"
]
if
let
orderID
=
orderId
{
let
param
=
[
"order_id"
:
orderID
,
"node"
:
"1"
,
"state"
:
"1"
]
as
[
String
:
Any
]
certificateReqVM
.
getCertificateStatisticData
(
params
:
param
)
{
success
,
error
in
if
success
==
true
{
self
.
headView
.
dataModel
=
self
.
certificateReqVM
.
certificateEntryModel
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/FileList(文件清单)/M/YHFileListModel.swift
View file @
b3ebefaf
...
...
@@ -13,7 +13,7 @@ class YHFileListModel: SmartCodable {
var
ApplicantName
:
String
=
""
var
category_id
:
Int
=
-
1
var
checks_tatus
:
Int
=
-
1
var
supplement_list
:
[
YH
FileListSubModel
]
=
[]
var
supplement_list
:
[
YH
SupplementInfo
]
=
[]
var
type
:
Int
=
0
//0-数据来自服务端 1-客户端自己添加的
var
arrTxt
:
[
String
]
=
[]
//type=1时使用的内容
...
...
@@ -21,13 +21,3 @@ class YHFileListModel: SmartCodable {
required
init
()
{
}
}
class
YHFileListSubModel
:
SmartCodable
{
var
name
:
String
=
""
var
type_name
:
String
=
""
var
check_status
:
Int
=
-
1
required
init
()
{
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/FileList(文件清单)/V/YHFileListContentView.swift
View file @
b3ebefaf
...
...
@@ -9,6 +9,9 @@
import
UIKit
class
YHFileListContentView
:
UIView
{
var
orderId
:
Int
=
0
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initView
()
...
...
@@ -20,7 +23,7 @@ class YHFileListContentView: UIView {
var
dataModel
:
[
YHFileListModel
?]?
{
didSet
{
updat
a
UI
()
updat
e
UI
()
}
}
}
...
...
@@ -34,7 +37,7 @@ private extension YHFileListContentView {
}
extension
YHFileListContentView
{
func
updat
a
UI
()
{
func
updat
e
UI
()
{
guard
let
arrData
=
dataModel
,
arrData
.
count
>
0
else
{
return
}
removeSubviews
()
...
...
@@ -72,7 +75,10 @@ extension YHFileListContentView {
for
(
index
,
item
)
in
arrData
.
enumerated
()
{
if
let
iii
=
item
{
var
view
:
UIView
=
YHFileListItemsView
()
if
view
is
YHFileListItemsView
{
let
targetView
=
view
as!
YHFileListItemsView
targetView
.
orderId
=
self
.
orderId
}
if
iii
.
type
==
0
{
(
view
as!
YHFileListItemsView
)
.
dataModel
=
item
}
else
{
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/FileList(文件清单)/V/YHFileListItemView.swift
View file @
b3ebefaf
...
...
@@ -9,6 +9,9 @@
import
UIKit
class
YHFileListItemView
:
UIView
{
var
clickBlock
:((
YHSupplementInfo
?)
->
())?
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initView
()
...
...
@@ -68,7 +71,7 @@ class YHFileListItemView: UIView {
var
dataModel
:
YH
FileListSubModel
?
{
var
dataModel
:
YH
SupplementInfo
?
{
didSet
{
updateUI
()
}
...
...
@@ -83,6 +86,10 @@ class YHFileListItemView: UIView {
private
extension
YHFileListItemView
{
func
initView
()
{
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
didItemViewClicked
)
)
self
.
addGestureRecognizer
(
tap
)
addSubview
(
indexLable
)
indexLable
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
8
)
...
...
@@ -129,20 +136,20 @@ extension YHFileListItemView {
func
updateUI
()
{
guard
let
dataModel
=
dataModel
else
{
return
}
titleLable
.
text
=
dataModel
.
name
subtitleLable
.
text
=
dataModel
.
type
_n
ame
subtitleLable
.
text
=
dataModel
.
type
N
ame
var
text
:
String
=
"--"
var
color
:
UIColor
=
.
failColor
if
dataModel
.
check
_s
tatus
==
2
{
if
dataModel
.
check
S
tatus
==
2
{
text
=
"需重传"
color
=
.
failColor
}
else
if
dataModel
.
check
_s
tatus
==
3
{
}
else
if
dataModel
.
check
S
tatus
==
3
{
text
=
"待提交"
color
=
.
brandMainColor
}
else
{
text
=
"需过滤"
+
String
(
dataModel
.
check
_s
tatus
)
text
=
"需过滤"
+
String
(
dataModel
.
check
S
tatus
)
color
=
UIColor
.
purple
}
...
...
@@ -157,4 +164,8 @@ extension YHFileListItemView {
let
index
=
String
(
myIndex
+
1
)
indexLable
.
text
=
index
.
defaultStringIfEmpty
(
detaultValue
:
"-"
)
}
@objc
func
didItemViewClicked
()
{
clickBlock
?(
self
.
dataModel
)
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/FileList(文件清单)/V/YHFileListItemsView.swift
View file @
b3ebefaf
...
...
@@ -9,6 +9,10 @@
import
UIKit
class
YHFileListItemsView
:
UIView
{
var
orderId
:
Int
=
0
var
viewModel
:
YHCertificateViewModel
=
YHCertificateViewModel
()
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
}
...
...
@@ -133,8 +137,14 @@ private extension YHFileListItemsView {
let
view
=
YHFileListItemView
()
view
.
myIndex
=
index
view
.
dataModel
=
item
view
.
clickBlock
=
{
[
weak
self
]
model
in
guard
let
self
=
self
else
{
return
}
self
.
handleClickDataModel
(
model
)
}
holdView
.
addSubview
(
view
)
if
index
==
dataModel
.
supplement_list
.
count
-
1
{
view
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
lastView
.
snp
.
bottom
)
...
...
@@ -156,3 +166,179 @@ private extension YHFileListItemsView {
holdView
.
layer
.
borderColor
=
UIColor
(
hex
:
0xDEE5F1
,
alpha
:
1.0
)
.
cgColor
}
}
private
extension
YHFileListItemsView
{
func
handleClickDataModel
(
_
targetModel
:
YHSupplementInfo
?)
{
guard
let
model
=
targetModel
else
{
return
}
if
model
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
// 待上传
showUploadSheetView
(
model
)
return
}
// 非待上传的进入详情
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
vc
.
categoryId
=
self
.
dataModel
?
.
category_id
??
0
vc
.
supplementId
=
model
.
id
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
}
func
showUploadSheetView
(
_
supplementInfo
:
YHSupplementInfo
)
{
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
()
sheetView
.
maxSelectCount
=
9
sheetView
.
uploadFilesBlock
=
{
[
weak
self
]
fileUrl
in
guard
let
self
=
self
else
{
return
}
print
(
fileUrl
)
uploadFile
(
fileUrl
,
supplementInfo
:
supplementInfo
)
{
// 待上传的进入详情
DispatchQueue
.
main
.
async
{
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
vc
.
categoryId
=
self
.
dataModel
?
.
category_id
??
0
vc
.
supplementId
=
supplementInfo
.
id
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
}
}
}
sheetView
.
uploadImageBlock
=
{
[
weak
self
]
targetImgArr
in
guard
let
self
=
self
else
{
return
}
let
ossGroup
=
DispatchGroup
()
var
ossArr
:[
YHContentUrl
]
=
[]
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
// 先将所有图片组上传到OSS
for
item
in
targetImgArr
{
if
let
image
=
item
.
data
{
ossGroup
.
enter
()
uploadImage
(
image
,
imageName
:
item
.
name
,
supplementInfo
:
supplementInfo
)
{
success
,
urlModel
in
if
success
,
let
model
=
urlModel
{
ossArr
.
append
(
model
)
}
ossGroup
.
leave
()
}
}
}
// 再将OSS上传信息组上传到服务器
ossGroup
.
notify
(
queue
:
.
main
)
{
if
ossArr
.
count
<=
0
{
YHHUD
.
hide
()
YHHUD
.
flash
(
message
:
"上传失败"
)
return
}
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:
ossArr
,
operation
:
"add"
,
rename
:
""
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
if
success
{
if
ossArr
.
count
==
targetImgArr
.
count
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
YHHUD
.
flash
(
message
:
"
\(
ossArr
.
count
)
张照片上传成功
\n\(
targetImgArr
.
count
-
ossArr
.
count
)
张照片上传失败"
)
}
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
vc
.
categoryId
=
self
.
dataModel
?
.
category_id
??
0
vc
.
supplementId
=
supplementInfo
.
id
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
}
else
{
YHHUD
.
flash
(
message
:
"上传失败"
)
}
}
}
}
sheetView
.
show
()
}
func
uploadImage
(
_
img
:
UIImage
,
imageName
:
String
,
supplementInfo
:
YHSupplementInfo
,
callBack
:((
Bool
,
YHContentUrl
?)
->
())?)
{
// 先OSS上传得到URL
self
.
viewModel
.
uploadImage
(
img
)
{
url
,
error
in
if
let
url
=
url
,
!
url
.
isEmpty
{
var
suffix
=
"jpg"
let
suffixName
=
url
.
pathExtension
.
lowercased
()
if
!
suffixName
.
isEmpty
{
suffix
=
suffixName
}
// 再调用业务接口
let
model
=
YHContentUrl
()
model
.
name
=
imageName
model
.
url
=
url
model
.
suffix
=
suffix
callBack
?(
true
,
model
)
}
else
{
callBack
?(
false
,
nil
)
}
}
}
func
uploadFile
(
_
fileUrl
:
URL
,
supplementInfo
:
YHSupplementInfo
,
successBlock
:(()
->
())?)
{
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
// 将文件数据上传到服务器
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
print
(
"
\(
size
)
"
)
// 先OSS上传得到URL
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{
[
weak
self
]
successUrl
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
// 再调用业务接口
if
let
successUrl
=
successUrl
,
!
successUrl
.
isEmpty
{
let
fileName
=
successUrl
.
lastPathComponent
let
suffixName
=
successUrl
.
pathExtension
.
lowercased
()
let
model
=
YHContentUrl
()
model
.
name
=
fileName
model
.
url
=
successUrl
model
.
suffix
=
suffixName
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:[
model
],
operation
:
"add"
,
rename
:
""
)
{
success
,
error
in
YHHUD
.
hide
()
// self.requestList(status:self.status)
if
success
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
var
msg
=
"上传失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
if
success
{
successBlock
?()
}
}
return
}
var
msg
=
"上传图片失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
}
else
{
YHHUD
.
flash
(
message
:
"识别文件失败"
)
}
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/C/YHCertificateUploadContentListVC.swift
View file @
b3ebefaf
...
...
@@ -129,6 +129,11 @@ class YHCertificateUploadContentListVC: YHBaseViewController {
}
}
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
refreshCertificateFileListNotifiction
,
object
:
nil
)
}
deinit
{
removeNotify
()
}
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/C/YHMineCertificateEntryViewController.swift
View file @
b3ebefaf
...
...
@@ -131,6 +131,7 @@ extension YHMineCertificateEntryViewController {
}
else
{
//生成清单
let
vc
=
YHFileListViewController
()
vc
.
orderId
=
self
.
orderId
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/M/YHCertificateModel.swift
View file @
b3ebefaf
...
...
@@ -61,7 +61,7 @@ class YHSupplementInfo: SmartCodable {
var
id
:
Int
=
0
var
name
:
String
=
""
var
typeName
:
String
=
""
var
checkStatus
:
Int
=
0
var
checkStatus
:
Int
=
-
1
var
templateCateName
:
String
=
""
var
templateCateShortName
:
String
=
""
var
templateCateShortColor
:
String
=
""
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/VM/YHCertificateViewModel.swift
View file @
b3ebefaf
...
...
@@ -26,7 +26,7 @@ enum YHCertificateUploadStatus : Int {
case
review
=
0
// 已完成
case
finish
=
1
//
审核中
//
已驳回
case
rejected
=
2
// 待上传
case
preUpload
=
3
...
...
@@ -63,7 +63,7 @@ class YHCertificateViewModel: YHBaseViewModel {
for
(
_
,
item
)
in
resultModel
.
enumerated
()
{
let
arr
=
item
?
.
supplement_list
.
filter
{
(
item
)
->
Bool
in
return
item
.
check
_status
==
2
||
item
.
check_s
tatus
==
3
return
item
.
check
Status
==
2
||
item
.
checkS
tatus
==
3
}
item
?
.
supplement_list
=
arr
??
[]
}
...
...
@@ -190,22 +190,20 @@ class YHCertificateViewModel: YHBaseViewModel {
}
// 上传/重命名/删除 证件
func
updateCertificates
(
params
:[
String
:
Any
],
callBack
:
@escaping
((
Bool
,
YHErrorModel
?)
->
())
)
{
func
updateCertificates
(
params
:[
String
:
Any
],
callBack
:
((
Bool
,
YHErrorModel
?)
->
())?
)
{
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Certificate
.
certificateUploadApi
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
json
,
code
in
if
json
.
code
==
200
{
callBack
(
true
,
nil
)
callBack
?
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBack
(
false
,
error
)
callBack
?
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBack
(
false
,
err
)
callBack
?
(
false
,
err
)
}
}
...
...
@@ -230,8 +228,7 @@ class YHCertificateViewModel: YHBaseViewModel {
]
self
.
updateCertificates
(
params
:
params
)
{
[
weak
self
]
success
,
error
in
guard
self
!=
nil
else
{
return
}
success
,
error
in
callBack
?(
success
,
error
)
}
}
...
...
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
View file @
b3ebefaf
...
...
@@ -214,5 +214,9 @@ extension YhConstant {
//强制更新通知
public
static
let
didForceUpgradeNotifiction
=
Notification
.
Name
(
rawValue
:
"com.yinhe.version.forceUpgrade"
)
// 刷新证件文件列表通知
public
static
let
refreshCertificateFileListNotifiction
=
Notification
.
Name
(
rawValue
:
"com.yinhe.certificate.updateFileList"
)
}
}
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