Blame view

App/addPerson/VCAddPerson.swift 2.71 KB
1341bf603   Trịnh Văn Quân   version 1.1
1
  import UIKit
fbd62afcf   Trịnh Văn Quân   version 1.2.2
2
3
  import GeneralUtils
  import Alamofire
1341bf603   Trịnh Văn Quân   version 1.1
4
5
6
7
8
  
  class VCAddPerson: UIViewController {
      @IBOutlet weak var edtTitle: UITextField!
      @IBOutlet weak var topMargin: NSLayoutConstraint!
      @IBOutlet weak var vTopLogo: VTopLogo!
fbd62afcf   Trịnh Văn Quân   version 1.2.2
9
      weak var tableView: UITableViewLoadDataFromUIThread?
1341bf603   Trịnh Văn Quân   version 1.1
10

fbd62afcf   Trịnh Văn Quân   version 1.2.2
11
      static func openController(_ viewController: UIViewController, tableView: UITableViewLoadDataFromUIThread) {
1341bf603   Trịnh Văn Quân   version 1.1
12
13
          let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
          let vcOpen = storyboard.instantiateViewController(withIdentifier: "VCAddPerson") as! VCAddPerson
fbd62afcf   Trịnh Văn Quân   version 1.2.2
14
          vcOpen.tableView = tableView;
1341bf603   Trịnh Văn Quân   version 1.1
15
16
17
18
19
          viewController.present(vcOpen, animated: true, completion: nil)
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
fbd62afcf   Trịnh Văn Quân   version 1.2.2
20
          vTopLogo.leftBtnClick = { self.dismiss(animated: true) }
1341bf603   Trịnh Văn Quân   version 1.1
21
      }
fbd62afcf   Trịnh Văn Quân   version 1.2.2
22

1341bf603   Trịnh Văn Quân   version 1.1
23
24
25
26
27
      @IBAction func btnLeftClick(_ sender: Any) {
          dismiss(animated: true)
      }
  
      @IBAction func btnRightClick(_ sender: Any) {
fbd62afcf   Trịnh Văn Quân   version 1.2.2
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
          if let id = edtTitle.text, id.length > 0{
              let parameters: Parameters = [
                      "id_create": getIDWork(),
                      "id": id,
              ]
  
              NetWorkUtils.excutePostTypeRawJSONEncoding(parameters: parameters, url: Constants.PathManager.ROOT_SERVER + "api/worker/add_id",
                      isShowProgress: true, vc: self, responseStringParam: { response in
                  guard let value = response.value else {
                      CommonUtils.showToastLong(text: LocalizedString("Has_Error_occurred"))
                      return
                  }
                  let json = JSON.parse(value)
                  if let isSuccess = json["iSuccess"].bool, isSuccess{
                      CommonUtils.showToastLong(text: LocalizedString("successful"))
                      self.edtTitle.text = nil
                      let person = Person();
                      person.id = id;
                      self.tableView?.itemsData.append(person)
                      self.tableView?.reloadDataTableView()
                      return
                  } else {
                      if let message = json["message"].string {
                          CommonUtils.showToastLong(text: message);
                      } else {
                          CommonUtils.showToastLong(text: LocalizedString("Has_Error_occurred"))
                      }
                  }
              })
          } else {
              CommonUtils.showToastLong(text: LocalizedString("khong_de_trong"))
          }
1341bf603   Trịnh Văn Quân   version 1.1
60
61
62
63
64
65
66
67
68
69
      }
  
      @IBAction func edtActionTrigerClick(_ sender: Any) {
          edtTitle.endEditing(true)
      }
  
  
      override func viewDidDisappear(_ animated: Bool) {
          super.viewDidDisappear(animated)
      }
fbd62afcf   Trịnh Văn Quân   version 1.2.2
70
      override var prefersStatusBarHidden: Bool {
1341bf603   Trịnh Văn Quân   version 1.1
71
72
73
          return true
      }
  }