VCRootCreateNew.swift
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import UIKit
import Foundation
import GeneralUtils
import Alamofire
class VCRootCreateNew: VCContainerFullScreen {
var tenCty: String?, tenCtruong: String?
var mucChups: [ShootItem]?
var signboard: Int = 1
static func openController(_ viewController: UIViewController) {
let vcOpen = VCRootCreateNew()
viewController.present(vcOpen, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
changeCurrentController(VCNhapTenCty.getInstance())
}
func createNewToServer() {
var ShootingItem = [Any]()
if let mucChups = mucChups {
for item in mucChups {
if let name = item.name {
ShootingItem.append(["name": name, "willShoot": (item.willShoot == 1)])
}
}
}
let parameters: Parameters = [
"idWorker": getIDWork(),
"signboard": signboard == 1,
"companyName": tenCty ?? "",
"constructionName": tenCtruong ?? "",
"ShootingItem": ShootingItem
]
NetWorkUtils.excutePostTypeRawJSONEncoding(parameters: parameters, url: Constants.PathManager.ROOT_SERVER + "api/regulations/store",
isShowProgress: true, vc: self, responseStringParam: { response in
if response.result.isSuccess {
CommonUtils.showToastLong(text: LocalizedString("successful"))
self.dismiss(animated: true)
} else {
DialogUtils.builderDialog(showCloseButton: true, showTitle: false).showError("", subTitle: LocalizedString("Has_Error_occurred"))
}
})
}
}