123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- //
- // PhotoDetailViewController.swift
- // MCPlus
- //
- // Created by seo ha on 07/02/2019.
- // Copyright © 2019 KangSH. All rights reserved.
- //
- import UIKit
- class PhotoDetailViewController: UIViewController {
-
- @IBOutlet weak var closeButton: UIImageView!{
- didSet{
- closeButton.addTapGestureRecognizer(action: self.closeAction)
- }
- }
-
- @IBOutlet weak var scrollView: UIScrollView!{
- didSet{
- scrollView.delegate = self
- }
- }
-
- @IBOutlet weak var imageView: UIImageView!
-
- @IBOutlet weak var patientIdLabel :UILabel!{
- didSet{
- patientIdLabel.text = self.photo?.user?.patientId
- }
- }
-
- @IBOutlet weak var patientNmLabel :UILabel!{
- didSet{
- patientNmLabel.text = self.photo?.user?.patientNm
- }
- }
-
- @IBOutlet weak var ageGenderLabel :UILabel!{
- didSet{
- ageGenderLabel.text = "\(self.photo?.user?.age ?? "") / \(self.photo?.user?.gender ?? "")"
- }
- }
-
- @IBOutlet weak var titleLabel: UILabel!{
- didSet{
- titleLabel.text = self.photo?.key
- }
- }
-
- // @IBOutlet weak var exitButton: UIButton!{
- // didSet{
- // exitButton.addTapGestureRecognizer(action: self.closeAction)
- // }
- // }
-
- @IBOutlet weak var uploadButton: UIButton!{
- didSet{
- if self.photo?.isSended == true{
- uploadButton.isHidden = true
- }
- uploadButton.addTapGestureRecognizer(action: self.uploadAction)
- }
- }
-
- @IBOutlet weak var deptNmLabel: UILabel!{
- didSet{
- deptNmLabel.text = self.photo?.user?.deptNm
- }
- }
-
- @IBOutlet weak var treatClsKrLabel: UILabel!{
- didSet{
- treatClsKrLabel.text = self.photo?.user?.treatClsKr
- }
- }
-
- @IBOutlet weak var doctorNmLabel: UILabel!{
- didSet{
- doctorNmLabel.text = self.photo?.user?.doctorNm
- }
- }
-
-
- var image:UIImage?
- var photo:Photo?
- var callBack:(()->Void)?
- }
- extension PhotoDetailViewController:UIScrollViewDelegate{
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- self.navigationController?.isNavigationBarHidden = true
- if let img = self.image{
- self.imageView.image = img
- }
- }
-
- func closeAction(){
- self.navigationController?.popViewController(animated: true)
- self.callBack?()
- }
-
- func viewForZooming(in scrollView: UIScrollView) -> UIView? {
- return scrollView.subviews.first
- }
-
- func uploadAction(){
- guard let photo = self.photo else {
- return
- }
- self.uploadItem(photo)
- }
-
- func uploadItem(_ photo:Photo){
- var param = [String:Any]()
- param["hospitalCd"] = photo.user?.hospitalCD ?? ""
- param["userId"] = photo.user?.userId ?? ""
- param["patientId"] = photo.user?.patientId ?? ""
- param["deptCd"] = photo.user?.deptCd ?? ""
- param["doctorId"] = photo.user?.doctorId ?? ""
- param["searchCls"] = photo.user?.treatCls ?? ""
- param["thumbnail"] = ""
- param["excutionDtTm"] = Date().fromString(format: "yyyy-MM-dd hh:mm:ss")
- param["visitDt"] = photo.user?.visitDt ?? ""
-
- if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
- //원본 이미지 찾기
- let origin = dir.appendingPathComponent("kunkuk/\(photo.file ?? "")")
- if let data = try? Data(contentsOf: origin){
-
- param["image"] = String(data: data, encoding: .utf8)
- }
- }
-
-
- let url = "\(MCarePlusConstants.DOMAIN_NAME)/\(photo.user?.serviceUrl ?? "")"
- APIClient(url)
- .param(reqParam: param)
- .enType(.json)
- .connect { [weak self](result:[String:Any]) in
-
- guard let `result` = result["result"] as? [[String:Any]] else{ return }
- let returnCd = result.first?["returnCd"] as? String
- let returnMsg = result.first?["returnMsg"] as? String
- //성공일시
- if returnCd == "0000" {
- photo.isSended = true
- photo.update()
- self?.showAlert("전송 완료되었습니다.", "", "확인", nil, { action in
- self?.closeAction()
- })
- }else{
- self?.showAlert(returnMsg ?? "전송 실패하였습니다.", "", "확인", nil, { action in
- self?.closeAction()
- })
- }
- }
-
- }
- }
|