<repo_name>a562432988/zxmoa<file_sep>/README.md
# zxmoa
第一个适配oa项目
<file_sep>/zxmoa/Daylay.swift
//
//  Daylay.swift
//  zxmoa
//
//  Created by mingxing on 16/3/7.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

class Daylay: UIViewController{
    
    /**客户走访*/
    @IBOutlet weak var btn2: UIButton!
    
    /**工作周报*/
    @IBOutlet weak var btn4: UIButton!
    
    /**请假上报*/
    @IBOutlet weak var btn1: UIButton!
    
    /**代办查看*/
    @IBOutlet weak var btn3: UIButton!
    var data = ""
    var ttle = ""
    var RUN_ID = ""
    var flag = 0
    
    override func viewDidLoad() {
        super.viewDidLoad()

//        btn1.frame = CGRectMake(0,0,30,30)
//        btn1.center = CGPointMake(view.frame.size.width/2, 280)
//        btn1.titleLabel?.font = UIFont.boldSystemFontOfSize(17) //文字大小
        btn1.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal) //文字颜色
        btn1.set(image: UIImage(named: "gongao.png"), title: "请假上报", titlePosition: .Bottom,
            additionalSpacing: 10.0, state: .Normal)

        btn4.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal) //文字颜色
        btn4.set(image: UIImage(named: "liucheng.png"), title: "工作周报", titlePosition: .Bottom,
            additionalSpacing: 10.0, state: .Normal)
        
        btn2.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal) //文字颜色
        btn2.set(image: UIImage(named: "kehu.png"), title: "客户走访", titlePosition: .Bottom,
            additionalSpacing: 10.0, state: .Normal)
        
        btn3.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal) //文字颜色
        btn3.set(image: UIImage(named: "wendang.png"), title: "代办查询", titlePosition: .Bottom,
            additionalSpacing: 10.0, state: .Normal)

    }
    
    
    /** 周报上报*/
    @IBAction func btn4(sender: UIButton) {
        data = "workflow/new/do.php?f=create&FLOW_ID=3004&FLOW_TYPE=1&FUNC_ID=2"
        ttle = "工作周报上报"
        flag = 1
        btn4.userInteractionEnabled = false
        self.ursll()
//         self.trunaround()
    }
    
    @IBAction func btn3(sender: UIButton) {
        let alert: UIAlertView = UIAlertView(title: "", message: "功能开发中", delegate: nil, cancelButtonTitle: "OK")
        alert.show()
    }
    /** 请假上报*/
    @IBAction func btn1(sender: UIButton) {
        data = "workflow/new/do.php?FLOW_ID=2001&f=create&FLOW_TYPE=1&FUNC_ID=2"
        ttle = "请假申请"
        flag = 2
        btn1.userInteractionEnabled = false
        ursll()
    }
    
    /** 客户走访*/
    @IBAction func btn2(sender: UIButton) {
        data = "workflow/new/do.php?FLOW_ID=3002&f=create&FLOW_TYPE=1&FUNC_ID=2"
        ttle = "客户走访信息上报"
        flag = 3
        btn2.userInteractionEnabled = false
//        trunaround()
        ursll()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func ursll(){
        var url1 = "http://www.zxmoa.com:83/general/"
        let header = ["Cookie":"PHPSESSID=\(cookpsw)"]
        url1 = url1 + data
        showNoticeWait()
        Alamofire.request(.GET,url1,headers: header ).response { request, response, data, error in
            let res = String(response?.URL!)
            let charset=NSCharacterSet(charactersInString:"&=")
            let resArray=res.componentsSeparatedByCharactersInSet(charset)
            self.RUN_ID = resArray[1]
            
//            print(self.RUN_ID,1)
            self.clearAllNotice()
            self.trunaround()
        }
    }
    
    func trunaround(){
        let vc = FormController()
        vc.RUN_ID1 = RUN_ID
        vc.flag = flag
        vc.titlename = ttle
        vc.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(vc, animated: true)
        btn4.userInteractionEnabled = true
        btn2.userInteractionEnabled = true
        btn1.userInteractionEnabled = true
    }

}
<file_sep>/zxmoa/webView.swift
//
//  webView.swift
//  zxmoa
//
//  Created by mingxing on 16/3/22.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

class webView: UIViewController,UIWebViewDelegate {
    var webbit:UIWebView?
    var data:String?
    var titles:String?
//    http://www.zxmoa.com:83/general/notify/show/read_notify.php?NOTIFY_ID=20
    var url = "http://www.zxmoa.com:83/general/"
    var header = ["Cookie":"PHPSESSID=\(cookpsw)"]
    override func viewDidLoad() {
        super.viewDidLoad()
        webbit = UIWebView(frame: self.view.frame )
        webbit!.backgroundColor = UIColor(red: 0xf0/255, green: 0xf0/255,
            blue: 0xf0/255, alpha: 1)
        self.webbit?.delegate = self
        self.navigationItem.title = titles!
        self.view.addSubview(webbit!)
        
        //设置是否缩放到适合屏幕大小
        self.webbit?.scalesPageToFit = true
        ursll()
        // Do any additional setup after loading the view.
    }

    func ursll(){
        url = url+data!
        showNoticeWait()
        Alamofire.request(.GET,url,headers: header ).responseString{ response in
            if let j = response.result.value {
                let html = j
                self.webbit!.loadHTMLString(html,baseURL:nil)
                self.clearAllNotice()
            }
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}
<file_sep>/zxmoa/Login View.swift
//
//  ViewController.swift
//  zxmoa
//
//  Created by mingxing on 16/3/1.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

var cookpsw:String = ""
var Usernn:String  = ""

class LoginView: UIViewController {
    
    @IBOutlet weak var remb: UISwitch!
    @IBOutlet weak var send: UIButton!
    @IBOutlet weak var Username: UITextField!
    @IBOutlet weak var Password: UITextField!
    var timer:NSTimer!
    var saveSuccessful: Bool!
    var saveSuccessful1: Bool!
    var saveSuccessful2: Bool = false
    @IBAction func sendup(sender: AnyObject) {
        /**按钮无法按下，防止多次请求*/
        send.userInteractionEnabled = false
        let usern : String! = Username.text
        let passw : String! = Password.text
        showNoticeWait()
        saveSuccessful = KeychainWrapper.setString(usern, forKey: "usern")
        saveSuccessful1 = KeychainWrapper.setString(passw, forKey: "passw")
        if remb.on {
            saveSuccessful2 = KeychainWrapper.setString("1", forKey: "butten")
        } else {
            saveSuccessful2 = KeychainWrapper.removeObjectForKey("butten")
        }
        Usernn = usern
    //发送http post请求
    Alamofire.request(.POST, "http://zxmoa.com:83/general/login/index.php?c=Login&a=loginCheck",parameters:["username":"\(usern)","password":"\(<PASSWORD>)","userLang":"cn"]).responseData{ response in
            if let j = response.result.value {
            let js = JSON(data:j)
            if js["flag"] == 1
            {
                let cookieStorage = NSHTTPCookieStorage.sharedHTTPCookieStorage()
                let cookieArray = cookieStorage.cookies
                if cookieArray!.count > 0
                {
                    for cookie in cookieArray!
                    {
                        if cookie.name == "PHPSESSID"
                        {
                            cookpsw = cookie.value
//                          print("PHPSESSID : \(cookpsw)")
                        }
                    }
                }
//                self.clearAllNotice()
                /**请求完成重新开启按钮*/
                self.send.userInteractionEnabled = true
//                self.dismissViewControllerAnimated(true,completion: nil)//销毁当前视图
                self.performSegueWithIdentifier("Truerun", sender: self)
//               self.modalTransitionStyle = UIModalTransitionStyle.PartialCurl
            }else{
                let alertController = UIAlertController(title: "提示",message: "用户名密码错误", preferredStyle: .Alert) //设置提示框
                self.presentViewController(alertController, animated: true, completion: nil)//显示提示框
                self.timer = NSTimer.scheduledTimerWithTimeInterval(2,target:self,selector:Selector("timers"),userInfo:alertController,repeats:false)
                        //设置单次执行 repeats是否重复执行 selector 执行的方法
                }
            }
        }
    }
    
    /**定时器*/
    func timers()
    {
        self.presentedViewController?.dismissViewControllerAnimated(false, completion: nil)//关闭提示框
        send.userInteractionEnabled = true
        self.timer.invalidate()//释放定时
    }
    
    override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
        
    }
    
    func stateChanged(switchState: UISwitch) {
        if switchState.on {
            let usern : String! = Username.text
            let passw : String! = Password.text
            saveSuccessful = KeychainWrapper.setString(usern, forKey: "usern")
            saveSuccessful1 = KeychainWrapper.setString(passw, forKey: "passw")
        } else {

        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
//        Password.secureTextEntry = true
        NSThread.sleepForTimeInterval(2.0)
//        send.layer.cornerRadius = 5  //设置button按钮圆角
        let flag:String? = KeychainWrapper.stringForKey("butten")
        if flag != nil{
            remb.setOn(true, animated: true)
        }else{
            remb.setOn(false, animated: true)
        }
        if remb.on {
            Username.text = KeychainWrapper.stringForKey("usern")
            Password.text = KeychainWrapper.stringForKey("passw")
        }else
        {
            
        }
        send.layer.cornerRadius = 5  //设置button按钮圆角
    }
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.Username.resignFirstResponder()//释放username控件的第一焦点
        self.Password.resignFirstResponder()//释放password控件的第一焦点
    }
    
    @IBAction func log(segue: UIStoryboardSegue){
//        print("1")
    }
}

<file_sep>/zxmoa/First View.swift
//
//  First View.swift
//  zxmoa
//
//  Created by mingxing on 16/3/7.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

var USER_ID:String!
var USER_PRIV:String!
var DEPT_NAME:String!
class First_View: PageController{
//    @IBOutlet var backGroudView: UIView!

    var vcTitles = ["新闻", "公告", "资料","补丁"]
//    var vcTitles = ["新闻", "公告"]
    let vcClasses: [UIViewController.Type] = [XinWenController.self, GongGaoController.self,ZiLiaoController.self,BuDingController.self]
//    let vcClasses: [UIViewController.Type] = [XinWenController.self, GongGaoController.self]
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        let item = UIBarButtonItem(title: "返回", style: .Plain, target: self, action: nil)
        self.navigationItem.backBarButtonItem = item
        itemsWidths = [80, 80,80,80]
        dataSource = self
        delegate = self
        preloadPolicy = PreloadPolicy.Neighbour
        titles = vcTitles
        viewControllerClasses = vcClasses
        pageAnimatable = true
        menuViewStyle = MenuViewStyle.Line
        bounces = true
        menuHeight = 40
        titleSizeNormal = 16
        titleSizeSelected = 17
        menuBGColor = .clearColor()
        automaticallyAdjustsScrollViewInsets = false // 阻止 tableView 上面的空白
        //        showOnNavigationBar = true
        //        pageController.selectedIndex = 1
        //        pageController.progressColor = .blackColor()
        //        pageController.viewFrame = CGRect(x: 50, y: 100, width: 320, height: 500)
        //        pageController.itemsWidths = [100, 50]
        //        pageController.itemsMargins = [50, 10, 100]
        //        pageController.titleSizeNormal = 12
        //        pageController.titleSizeSelected = 14
        //        pageController.titleColorNormal = UIColor.brownColor()
//                pageController.titleColorSelected = UIColor.blackColor()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        ursll()
    }
    func ursll(){
        let urll = "http://www.zxmoa.com:83/general/info/user/do.php"
        let header = ["Cookie":"PHPSESSID=\(cookpsw)"]
        let param = ["op":"getSearchList","username":"\(Usernn)","b_month":"0","sex":"ALL","currentPage":"0","itemsPerPage":"10"]
        Alamofire.request(.POST,urll,parameters: param,headers:header).responseData{ response in
            if let j = response.result.value{
                let js = JSON(data: j)
                USER_ID = js["list"][0]["USER_ID"].string
                USER_PRIV = js["list"][0]["USER_PRIV"].string
                DEPT_NAME = js["list"][0]["DEPT_NAME"].string
                print("\(USER_ID),\(USER_PRIV),\(DEPT_NAME)")
            }
        }
    }

    
    // 内存警告!
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // MARK: - PageController DataSource
    func numberOfControllersInPageController(pageController: PageController) -> Int {
        return vcTitles.count
    }
    
    func pageController(pageController: PageController, titleAtIndex index: Int) -> String {
        return vcTitles[index]
    }

    // 代理里的方法
    // 结束就会触发
//    override func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
//        let i:Int = Int(self.contentScrollView.contentOffset.x / screenW)
//        selTitleBtn(buttons[i])
//        setUpOneChildViewController(i)
//    }
    
    /* 滑动就会触发
    func scrollViewDidScroll(scrollView: UIScrollView) {
        
    }
    */

}
<file_sep>/zxmoa/TableView.swift
//
//  TableView.swift
//  zxmoa
//
//  Created by mingxing on 16/3/8.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

class TableView: UIViewController, UITableViewDataSource,UITableViewDelegate {
    @IBOutlet var tableView: UITableView!
    var name:[String]=[],names:[String]=[],namep:[String]=[]
    var sex:[String]=[],sexs:[String]=[],sexp:[String]=[]
    var phone:[String]=[],phones:[String]=[],phonep:[String]=[]
    var zhiW:[String]=[],zhiWs:[String]=[],zhiWp:[String]=[]
    var BuMen:[String]=[],BuMens:[String]=[],BuMenp:[String]=[]
    var a=0,b=0,c=0,d=0,e=0
    @IBOutlet weak var cover: UILabel!
    func urlrp(){
        Alamofire.request(.POST, "http://www.zxmoa.com:83/general/address/pubcenter/addpublic_do.php",parameters:["op":"getAddressList","ADDRESS_TYPE":"1","GROUP_ID": "30","f":"view","sortField":"A13","sortType":"ASC","currentPage":"0","itemsPerPage":"20"],headers:["Cookie":"PHPSESSID=\(cookpsw)"]).responseData { response in
            if let j = response.result.value {//ID30 zongjingl
                let js = JSON(data:j)
                self.name.append(js["list"][0]["A1"].string!)
                self.names.append(js["list"][0]["A25"].string!)
                self.namep.append(js["list"][0]["A5"].string!)
            }
//            dispatch_async(dispatch_get_main_queue(), {
                self.tableView?.reloadData()
                self.a=1
                if self.a==1 && self.b==1 && self.c==1 && self.d==1 && self.e==1{
                    self.cover.hidden=true
                    self.clearAllNotice()
                }
//                return
//            })
        }
        
        Alamofire.request(.POST, "http://www.zxmoa.com:83/general/address/pubcenter/addpublic_do.php",parameters:["op":"getAddressList","ADDRESS_TYPE":"1","GROUP_ID": "32","f":"view","sortField":"A13","sortType":"ASC","currentPage":"0","itemsPerPage":"20"],headers:["Cookie":"PHPSESSID=\(cookpsw)"]).responseData { response in
            if let j = response.result.value {
                let js = JSON(data:j)
                self.sex.append(js["list"][0]["A1"].string!)
                self.sex.append(js["list"][1]["A1"].string!)
                self.sexs.append(js["list"][0]["A25"].string!)
                self.sexs.append(js["list"][1]["A25"].string!)
                self.sexp.append(js["list"][0]["A5"].string!)
                self.sexp.append(js["list"][1]["A5"].string!)
            }
//            dispatch_async(dispatch_get_main_queue(), {
                self.tableView?.reloadData()
                self.b=1
                if self.a==1 && self.b==1 && self.c==1 && self.d==1 && self.e==1{
                    self.cover.hidden=true
                    self.clearAllNotice()
                }
//                return
//            })
            //                    print(4)
        }
        Alamofire.request(.POST, "http://www.zxmoa.com:83/general/address/pubcenter/addpublic_do.php",parameters:["op":"getAddressList","ADDRESS_TYPE":"1","GROUP_ID": "34","f":"view","sortField":"A13","sortType":"ASC","currentPage":"0","itemsPerPage":"20"],headers:["Cookie":"PHPSESSID=\(cookpsw)"]).responseData { response in
            if let j = response.result.value {//ID34 财务
                let js = JSON(data:j)
                self.phone.append(js["list"][0]["A1"].string!)
                self.phones.append(js["list"][0]["A25"].string!)
                self.phonep.append(js["list"][0]["A5"].string!)
            }
//            dispatch_async(dispatch_get_main_queue(), {
                self.tableView?.reloadData()
                self.c=1
                if self.a==1 && self.b==1 && self.c==1 && self.d==1 && self.e==1{
                    self.cover.hidden=true
                    self.clearAllNotice()
                }
//                return
//            })
            //                    print(5)
        }
        Alamofire.request(.POST, "http://www.zxmoa.com:83/general/address/pubcenter/addpublic_do.php",parameters:["op":"getAddressList","ADDRESS_TYPE":"1","GROUP_ID": "31","f":"view","sortField":"A13","sortType":"ASC","currentPage":"0","itemsPerPage":"20"],headers:["Cookie":"PHPSESSID=\(cookpsw)"]).responseData { response in
            if let j = response.result.value {//ID31 4G
                let js = JSON(data:j)
                let a:Int = js["list"].count
                for var i=0;i<a;i++
                {
                    self.zhiW.insert(js["list"][i]["A1"].string!, atIndex: i)
                    self.zhiWs.insert(js["list"][i]["A25"].string!, atIndex: i)
                    self.zhiWp.insert(js["list"][i]["A5"].string!, atIndex: i)
                }
            }
//            dispatch_async(dispatch_get_main_queue(), {
                self.tableView?.reloadData()
                self.d=1
                if self.a==1 && self.b==1 && self.c==1 && self.d==1 && self.e==1{
                    self.cover.hidden=true
                    self.clearAllNotice()
                }
//                return
//            })
        }
        Alamofire.request(.POST, "http://www.zxmoa.com:83/general/address/pubcenter/addpublic_do.php",parameters:["op":"getAddressList","ADDRESS_TYPE":"1","GROUP_ID": "33","f":"view","sortField":"A13","sortType":"ASC","currentPage":"0","itemsPerPage":"20"],headers:["Cookie":"PHPSESSID=\(cookpsw)"]).responseData { response in
            if let j = response.result.value {//ID33 工程
                let js = JSON(data:j)
                self.BuMen.insert(js["list"][0]["A1"].string!, atIndex: 0)
                self.BuMen.insert(js["list"][1]["A1"].string!, atIndex: 1)
                self.BuMen.insert(js["list"][2]["A1"].string!, atIndex: 2)
                self.BuMens.insert(js["list"][0]["A25"].string!, atIndex: 0)
                self.BuMens.insert(js["list"][1]["A25"].string!, atIndex: 1)
                self.BuMens.insert(js["list"][2]["A25"].string!, atIndex: 2)
                self.BuMenp.insert(js["list"][0]["A5"].string!, atIndex: 0)
                self.BuMenp.insert(js["list"][1]["A5"].string!, atIndex: 1)
                self.BuMenp.insert(js["list"][2]["A5"].string!, atIndex: 2)
            }
//            dispatch_async(dispatch_get_main_queue(), {
                self.tableView?.reloadData()
                self.e=1
                if self.a==1 && self.b==1 && self.c==1 && self.d==1 && self.e==1{
                    self.cover.hidden=true
                    self.clearAllNotice()
                }

//                return
//            })
        }

    }

    override func viewDidLoad() {
        super.viewDidLoad()
            urlrp()
//        self.navigationItem.leftBarButtonItem = self.editButtonItem()//添加编辑按钮
//        let addButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Add, target: self, action: "listcelldata:")//增加按钮实现方法
//        self.navigationItem.rightBarButtonItem = addButton//添加增加按钮
//        tableView=UITableView(frame:self.view.frame,style:UITableViewStyle.Grouped)
        showNoticeWait()
        tableView.delegate = self
        tableView.dataSource = self
//        self.view.addSubview(tableView)
        
     // Uncomment the following line to preserve selection between presentations
     // self.clearsSelectionOnViewWillAppear = false

     // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
     // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 25
    }//title高度
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 5
    }//设置分区数量
    func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String?{
        switch (section) {
        case 0:
          return "总经理"
        case 1:
            return "办公室"
        case 2:
            return "财务室"
        case 3:
            return "4G事业部"
        case 4:
            return "工程部"
        default: return  ""
        }
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        if (0 == section) {
            return name.count
        } else if (1 == section) {
            return sex.count
        } else if (2 == section) {
            return phone.count
        }
        else if (3 == section) {
            return zhiW.count
        }
        else if (4 == section) {
            return BuMen.count
        }
        return 0

    }//每组有多少

    
   func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//    print(1)
    var cell = tableView.dequeueReusableCellWithIdentifier("cellid")
    if cell == nil{
        cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cellid")//设置cell样式
        cell!.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator//右侧加小剪头
        }
    if (0 == indexPath.section) {
        cell?.textLabel?.text = name[indexPath.row]
        cell?.detailTextLabel?.text = "职务：\(names[indexPath.row])  | 电话：\(namep[indexPath.row])"
    }
        
    else if(1 == indexPath.section) {
    cell?.textLabel?.text = sex[indexPath.row]
        cell?.detailTextLabel?.text = "职务：\(sexs[indexPath.row])  | 电话：\(sexp[indexPath.row])"
    }
    
    else if (2 == indexPath.section) {
        cell?.textLabel?.text = phone[indexPath.row]
        cell?.detailTextLabel?.text = "职务：\(phones[indexPath.row])  | 电话：\(phonep[indexPath.row])"
    }
    else if (3 == indexPath.section) {
       cell?.textLabel?.text = zhiW[indexPath.row]
        cell?.detailTextLabel?.text = "职务：\(zhiWs[indexPath.row])  | 电话：\(zhiWp[indexPath.row])"
    }

    else if (4 == indexPath.section) {
        cell?.textLabel?.text = BuMen[indexPath.row]
        cell?.detailTextLabel?.text = "职务：\(BuMens[indexPath.row])  | 电话：\(BuMenp[indexPath.row])"

    }
    return cell!
    }//绘制cell
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let ccc:NSIndexPath = indexPath
        var qb:[String]=["1","2","3","1"]
        if (0 == ccc.section) {
            qb[0]=name[ccc.row]
            qb[1]=names[ccc.row]
            qb[2]="总经理"
            qb[3]=namep[ccc.row]
        } else if (1 == ccc.section) {
            qb[0]=sex[ccc.row]
            qb[1]=sexs[ccc.row]
            qb[2]="办公室"
            qb[3]=sexp[ccc.row]
        } else if (2 == ccc.section) {
            qb[0]=phone[ccc.row]
            qb[1]=phones[ccc.row]
            qb[2]="财务室"
            qb[3]=phonep[ccc.row]
        }
        else if (3 == ccc.section) {
            qb[0]=zhiW[ccc.row]
            qb[1]=zhiWs[ccc.row]
            qb[2]="4G事业部"
            qb[3]=zhiWp[ccc.row]
        }
        else if (4 == ccc.section) {
            qb[0]=BuMen[ccc.row]
            qb[1]=BuMens[ccc.row]
            qb[2]="工程部"
            qb[3]=BuMenp[ccc.row]
        }

        self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
        //点击cell后cell不保持选中状态
        
        
        let alertController = UIAlertController(title: "个人详情",
            message: "姓名：\(qb[0])     \n\n部门: \(qb[2])     \n\n职务：\(qb[1])     \n\n电话： \(qb[3])     \n\n", preferredStyle: .Alert)

        
        
        
        
        /**底部警告窗口设置*/
        let phe = UIAlertController(title: "呼出电话", message: "是否呼叫 \(qb[0])", preferredStyle: .ActionSheet)
        /**/
        let ok = UIAlertAction(title: "确定", style: .Default, handler: {action in let url1 = NSURL(string: "tel://\(qb[3])")
            UIApplication.sharedApplication().openURL(url1!)})
        /**警告窗口设置*/
        let cancelAction = UIAlertAction(title: "取消", style: .Destructive, handler: nil)
        
        phe.addAction(ok)
        phe.addAction(cancelAction)
        
        
        
        let cacel = UIAlertAction(title: "呼出", style:.Destructive,handler:{ action in self.presentViewController(phe, animated: true, completion: nil)} )
        let okAction = UIAlertAction(title: "取消", style: .Cancel,
            handler: nil)//定义详情取消按钮
        
        
        alertController.addAction(okAction)
        alertController.addAction(cacel)
        
        self.presentViewController(alertController, animated: true, completion: nil)
    }
    
    override func viewDidDisappear(animated: Bool) {
        self.clearAllNotice()
    }

}
<file_sep>/zxmoa/FormController.swift
//
//  FormController.swift
//  zxmoa
//
//  Created by mingxing on 16/3/30.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

class FormController: FormViewController{
    var titlename:String = ""
    var data:String?
    var RUN_ID1:String?
    var date1:[String:AnyObject]=[:]
    var senders0:[[String]] = []
    var senders1:[[String]] = []
    var flag = 0
    /**创建表单结构体*/
    struct Static {
        static let title = "RUN_NAME"
        static let InstancyType = "InstancyType"
        static let DATA_1 = "DATA_1"
        static let DATA_2 = "DATA_2"
        static let DATA_3 = "DATA_3"
        static let DATA_4 = "DATA_4"
        static let DATA_5 = "DATA_5"
        static let DATA_6 = "DATA_6"
        static let DATA_7 = "DATA_7"
        static let DATA_8 = "DATA_8"
        static let DATA_9 = "DATA_9"
        static let DATA_10 = "DATA_10"
        static let DATA_11 = "DATA_11"
        static let DATA_12 = "DATA_12"
        static let DATA_13 = "DATA_13"
    }
    /**初始化加载表单*/
//    required init(coder aDecoder: NSCoder) {
//        super.init(coder: aDecoder)
//        self.loadForm()
//    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.title = titlename
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "提交    ", style: .Plain, target: self, action: "submit:")
        loadForm()
        view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "handleTap:"))
    }
    
    /**按钮事件*/
    func submit(_: UIBarButtonItem!) {
        let message1 = self.form.formValues()
        self.view.endEditing(true)
        date1 = message1
        let cont = makeform()

        if cont == 1{
        
            let res = UIAlertController(title: "Form output", message: date1.description, preferredStyle: .Alert)

            let queren = UIAlertController(title: "确认提交", message: "是否提交\(titlename)", preferredStyle: .ActionSheet)
        
            let querenok = UIAlertAction(title: "提交", style: .Default, handler: {action in
                self.urll()
                self.urllss()
            })
        
        let querencancel = UIAlertAction(title: "取消", style: .Destructive, handler: nil)
        queren.addAction(querenok)
        queren.addAction(querencancel)
        
        let ok = UIAlertAction(title: "提交", style: .Default, handler: {action in self.presentViewController(queren, animated: true, completion: nil)})
        let cancelAction = UIAlertAction(title: "取消", style: .Destructive, handler: nil)
        res.addAction(ok)
        res.addAction(cancelAction)

        self.presentViewController(res, animated: true, completion: nil)
        }
    }
    
    func makeform()->Int{
        var qm = 1
        date1["RUN_ID"]    = RUN_ID1
        date1["doc_id"]    = ""
        date1["OP_FLAG"]   = "1"
        date1["f"]         = "autosave"
        date1["FLOW_PRCS"] = "1"
        date1["PRCS_ID"]   = "1"
        
        if flag == 1{
            date1["FIELD_COUNTER"] = "4"
            date1["ITEM_ID_MAX"]   = "4"
            date1["FLOW_ID"]       = "3004"
            
            let d7:String?         = date1["DATA_7"] as? String
            let d8:String?         = date1["DATA_8"] as? String
            if d7 == "" || d8 == ""{
                qm = 0
                let alert: UIAlertView = UIAlertView(title: "警告", message: "本周工作内容 或者 下周工作计划没有填写", delegate: nil, cancelButtonTitle: "OK")
                alert.show()
            }
        }else if flag == 2{
            date1["FIELD_COUNTER"]  = "13"
            date1["ITEM_ID_MAX"]    = "13"
            date1["FLOW_ID"]        = "2001"
            let d7:String?          = date1["DATA_5"] as? String
            let d8:String?          = date1["DATA_7"] as? String
            if d7 == "" || d8 == ""{
                qm = 0
                let alert: UIAlertView = UIAlertView(title: "警告", message: "请假开始时间 或者 请假结束时间没有填写", delegate: nil, cancelButtonTitle: "OK")
                alert.show()
            }else{
                let timeFo   = NSDateFormatter()
                timeFo.dateFormat = "yyy-MM-dd HH:mm"
                let q5:NSDate = timeFo.dateFromString(d7!)!
                let q6:NSDate = timeFo.dateFromString(d8!)!
                let second = q6.timeIntervalSinceDate(q5)
                if second <= 0{
                    let alert: UIAlertView = UIAlertView(title: "警告", message: "请假开始时间晚于或等于请假结束时间\n请重新填写", delegate: nil, cancelButtonTitle: "OK")
                    alert.show()
                    qm = 0
                }else{
                    let second2 = String(format: "%.2f", second/60.0/60.0/24.0)
                    date1["DATA_10"] = second2
                    timeFo.dateFormat = "yyy-MM-dd"
                    date1["DATA_5"] = timeFo.stringFromDate(q5)
                    date1["DATA_7"] = timeFo.stringFromDate(q6)
                    timeFo.dateFormat = "HH:mm"
                    date1["DATA_6"] = timeFo.stringFromDate(q5)
                    date1["DATA_8"] = timeFo.stringFromDate(q6)
                }
            }

        }else if flag == 3{
            date1["FIELD_COUNTER"]  = "9"
            date1["ITEM_ID_MAX"]    = "9"
            date1["FLOW_ID"]        = "3002"
            let d6:String? = date1["DATA_3"] as? String
            let str3=d6!.substringToIndex(d6!.startIndex.advancedBy(10))
            print(str3)
            date1["DATA_3"] = str3
        }
        return qm
    }
    
    func trunaround(se:[Int],se1:[Int]){
        let vc = submitform()
        vc.RUN_ID = RUN_ID1
        vc.senders = senders0
        vc.senders1 = senders1
        vc.se = se
        vc.se1 = se1
        vc.ten = flag
        vc.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
    func urll(){
        showNoticeWait()
        let url = "http://www.zxmoa.com:83/general/workflow/new/do.php"
        let header = ["Cookie":"PHPSESSID=\(cookpsw)"]
        Alamofire.request(.POST,url,headers: header,parameters: date1).responseString{ response in
            print(response.result.value)
            print("---------")
        }
    }
    
    func urllss(){
        /**工作周报上报选择代办人*/
        let header = ["Cookie":"PHPSESSID=\(cookpsw)"]
        var seede:[String] = ["0","0","0"]
        if flag == 1{
            seede[0] = "1"
            seede[1] = "0"
            seede[2] = "3004"
        }else if flag == 2{
            seede[0] = "2"
            seede[1] = "0"
            seede[2] = "2001"
        }else if flag == 3{
            seede[0] = "0"
            seede[1] = "0"
            seede[2] = "3002"
            
        }
        var pamter:[String:String] = ["op":"getUserByDept","param[RUN_ID]":"\(RUN_ID1)","param[FLOW_ID]":"\(seede[2])","param[PRCS_ID]":"1","param[FLOW_PRCS]":"1","param[showLeaveOffice]":"false","param[getDataType]":"user_select_single_inflow_new","param[flow_type]":"1","param[PRCS_TO_CHOOSE]":"\(seede[0])"]
        let url = "http://www.zxmoa.com:83/newplugins/js/jquery-select-dialog/user/do.php"
        pamter["param[PRCS_TO_CHOOSE]"] = seede[0]
        var se:[Int] = [] , se1:[Int] = []
        Alamofire.request(.GET,url,parameters: pamter,headers: header).responseData{response in
            if let js = response.result.value{
                let jss = JSON(data: js)
                let a = jss["DATA"].count
//                print(a)
                self.senders1 = [[String]](count: a,repeatedValue: [String](count: 2, repeatedValue: " "))
                se1 = [Int](count: a, repeatedValue: 1)
                for var i = 0 ; i<a ; i++ {
                    self.senders1[i][1] = jss["DATA"][i]["USER_ID"].string!
                    se1[i] = i
                    self.senders1[i][0] = jss["DATA"][i]["USER_NAME"].string!
                }
            pamter["param[PRCS_TO_CHOOSE]"] = seede[1]
            Alamofire.request(.GET,url,parameters: pamter,headers: header).responseData{response in
                    if let js = response.result.value{
                        let jss = JSON(data: js)
                        let a = jss["DATA"].count
//                        print(a)
                        self.senders0 = [[String]](count: a,repeatedValue: [String](count: 2,repeatedValue: " "))
                        se = [Int](count: a, repeatedValue: 1)
                        for var i = 0 ; i<a ; i++ {
                            self.senders0[i][1] = jss["DATA"][i]["USER_ID"].string!
                            se[i] = i
                            self.senders0[i][0] = jss["DATA"][i]["USER_NAME"].string!
                        }
//                        print(self.senders0)
                        self.clearAllNotice()
                        self.trunaround(se,se1: se1)
//                        print(self.senders1)
                    }
                }
            }
        }
    }


    /**创建表单*/
    private func loadForm() {
        /**获取系统当前时间*/
        let date = NSDate()
        let timeFormatter = NSDateFormatter()
        timeFormatter.dateFormat = "yyy-MM-dd HH:mm:ss"
        var strNowTime = timeFormatter.stringFromDate(date) as String
        let title1 = titlename + "(\(strNowTime):\(Usernn))"
        let form = FormDescriptor(title: "\(titlename)")
        
        let section1 = FormSectionDescriptor(headerTitle: "流程标题", footerTitle: nil)
        /**流程标题*/
        var row = FormRowDescriptor(tag: Static.title , rowType: .Text, title: "")
        row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Left.rawValue]
        row.value = title1
        section1.addRow(row)
        
        /**紧急选项*/
        row = FormRowDescriptor(tag: Static.InstancyType, rowType: .SegmentedControl, title: "")
        row.configuration[FormRowDescriptor.Configuration.Options] = ["0", "1", "2"]
        row.configuration[FormRowDescriptor.Configuration.TitleFormatterClosure] = { value in switch( value ) {
                case "0": return " 正常 "
                case "1": return " 重要 "
                case "2": return " 紧急 "
                default: return nil
                }
            } as TitleFormatterClosure
        row.value = "0"
        row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["segmentedControl.tintColor" : UIColor.redColor()]
        section1.addRow(row)
        
        let section2 = FormSectionDescriptor(headerTitle: "\(titlename)", footerTitle: nil)
        let section3 = FormSectionDescriptor(headerTitle: nil, footerTitle: nil)
        
        /**根据标志制作不同的表单*/
        if flag == 1{
        row = FormRowDescriptor(tag: Static.DATA_3, rowType: .Label , title: "上报人")
        row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["valueLabel.text" : "\(Usernn)"]
        row.value = "\(Usernn)"
        section2.addRow(row)
        
        timeFormatter.dateFormat = "yyy-MM-dd"
        strNowTime = timeFormatter.stringFromDate(date) as String
        
        row = FormRowDescriptor(tag: Static.DATA_4, rowType: .Label , title: "日期")
        row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["valueLabel.text" : "\(strNowTime)"]
        row.value = "\(strNowTime)"
        section2.addRow(row)
        
        
        row = FormRowDescriptor(tag: Static.DATA_7, rowType: .MultilineText, title: "本周\n工作\n内容")
        section3.addRow(row)
        
        row = FormRowDescriptor(tag: Static.DATA_8, rowType: .MultilineText, title: "下周\n工作\n计划")
        section3.addRow(row)
            
        }else if flag == 2{
            row = FormRowDescriptor(tag: Static.DATA_1, rowType: .Label, title: "登记人ID")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["valueLabel.text" : "\(USER_ID)"]
            row.value = "\(USER_ID)"
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_2, rowType: .Label, title: "登记时间")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["valueLabel.text" : "\(strNowTime)"]
            row.value = strNowTime
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_3, rowType: .Label, title: "登记人部门")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["valueLabel.text" : "\(DEPT_NAME)"]
            row.value = DEPT_NAME
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_4, rowType: .Label, title: "登记人角色")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["valueLabel.text" : "\(USER_PRIV)"]
            row.value = USER_PRIV
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_5, rowType: .DateAndTime, title: "请假开始时间")
            section3.addRow(row)
            row = FormRowDescriptor(tag: Static.DATA_7, rowType: .DateAndTime, title: "请假结束时间")
            section3.addRow(row)
            row = FormRowDescriptor(tag: Static.DATA_9, rowType: .Picker, title: "请假类型")
            row.configuration[FormRowDescriptor.Configuration.Options] = ["年假", "病假", "婚假","产假"]
            row.configuration[FormRowDescriptor.Configuration.TitleFormatterClosure] = { value in
                switch( value ) {
                case "年假":
                    return "年假"
                case "病假":
                    return "病假"
                case "婚假":
                    return "婚假"
                default:
                    return "产假"
                }
                } as TitleFormatterClosure

            section3.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_10, rowType: .Label, title: "请假天数")
            section3.addRow(row)
            row = FormRowDescriptor(tag: Static.DATA_11, rowType: .Label, title: "登记人姓名")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["valueLabel.text" : "\(Usernn)"]
            row.value = Usernn
            section3.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_12, rowType: .Label, title: "审批人签字")
            section3.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_13, rowType: .MultilineText, title: "请假原因")
            section3.addRow(row)
            
        }else if flag == 3{
            row = FormRowDescriptor(tag: Static.DATA_3, rowType: .Date, title: "走访日期")
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_2, rowType: .Text , title: "客户名称")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Right.rawValue]
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_10, rowType: .Text , title: "所属行业")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Right.rawValue]
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_9, rowType: .Text , title: "用户规模")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Right.rawValue]
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_5, rowType: .Text , title: "联系人")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Right.rawValue]
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_1, rowType: .Text , title: "职务")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Right.rawValue]
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_7, rowType: .Text , title: "联系方式")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Right.rawValue]
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_8, rowType: .Text , title: "邮箱")
            row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.textAlignment" : NSTextAlignment.Right.rawValue]
            section2.addRow(row)
            
            row = FormRowDescriptor(tag: Static.DATA_6, rowType: .MultilineText , title: "走访\n情况")
            section3.addRow(row)
        }
        
        form.sections = [section1,section2,section3]
        self.tableView!.contentInset.bottom = -30
        self.form = form
    }
    
    func handleTap(sender: UITapGestureRecognizer) {
        if sender.state == .Ended {
            self.view.endEditing(true)
        }
        sender.cancelsTouchesInView = false
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
<file_sep>/zxmoa/UIbuttonenum.swift
//
//  UIbuttonenum.swift
//  zxmoa
//
//  Created by mingxing on 16/3/28.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit

//extension UIView {
//    
//    func addOnClickListener(target: AnyObject, action: Selector) {
//        let gr = UITapGestureRecognizer(target: target, action: action)
//        gr.numberOfTapsRequired = 1
//        userInteractionEnabled = true
//        addGestureRecognizer(gr)
//    }
//    
//}

extension UIButton {
    
    @objc func set(image anImage: UIImage?, title: String,
        titlePosition: UIViewContentMode, additionalSpacing: CGFloat, state: UIControlState){
            self.imageView?.contentMode = .Center
            self.setImage(anImage, forState: state)
            
            positionLabelRespectToImage(title, position: titlePosition, spacing: additionalSpacing)
            
            self.titleLabel?.contentMode = .Center
            self.setTitle(title, forState: state)
    }
    
    private func positionLabelRespectToImage(title: String, position: UIViewContentMode,
        spacing: CGFloat) {
            let imageSize = self.imageRectForContentRect(self.frame)
            let titleFont = self.titleLabel?.font!
            let titleSize = title.sizeWithAttributes([NSFontAttributeName: titleFont!])
            
            var titleInsets: UIEdgeInsets
            var imageInsets: UIEdgeInsets
            
            switch (position){
            case .Top:
                titleInsets = UIEdgeInsets(top: -(imageSize.height + titleSize.height + spacing),
                    left: -(imageSize.width), bottom: 0, right: 0)
                imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -titleSize.width)
            case .Bottom:
                titleInsets = UIEdgeInsets(top: (imageSize.height + titleSize.height + spacing),
                    left: -(imageSize.width), bottom: 0, right: 0)
                imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -titleSize.width)
            case .Left:
                titleInsets = UIEdgeInsets(top: 0, left: -(imageSize.width * 2), bottom: 0, right: 0)
                imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0,
                    right: -(titleSize.width * 2 + spacing))
            case .Right:
                titleInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -spacing)
                imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
            default:
                titleInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
                imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
            }
            
            self.titleEdgeInsets = titleInsets
            self.imageEdgeInsets = imageInsets
    }
}<file_sep>/zxmoa/ZiLiaoController.swift
//
//  ZiLiaoController.swift
//  zxmoa
//
//  Created by mingxing on 16/3/16.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON
import MJRefresh

class ZiLiaoController: UIViewController,UITableViewDataSource,UITableViewDelegate {
    var ZiLiao:[[String]]=[]
    var tableView:UITableView?
    var cover:UILabel?
    var isNew:[[Bool]] = []
    var a=0,b = 0,c = 0,flag = 0
    var urll = "http://www.zxmoa.com:83/general/file_folder/file_new/filelist_do.php"
    var parameters:[String : String] = ["FILE_SORT":"1","SORT_ID":"36","currentPage":"0","itemsPerPage":"10"]
    var header = ["Cookie":"PHPSESSID=\(cookpsw)"]
    // 顶部刷新
    let aheader = MJRefreshNormalHeader()
    // 底部刷新
    let footer = MJRefreshAutoNormalFooter()
    
    override func loadView() {
        super.loadView()//通过xib加载时图
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
//        self.ZiLiao = [[String]](count: 0, repeatedValue: [String](count: 3, repeatedValue: ""))
        ursll("0")//发送请求
        creativeCell()//创建cell
        tableView!.reloadData()
        
        
        // 下拉刷新
        aheader.setRefreshingTarget(self, refreshingAction: Selector("headerRefresh"))
        // 现在的版本要用mj_header
        tableView!.mj_header = aheader
        // 上拉刷新
        footer.setRefreshingTarget(self, refreshingAction: Selector("footerRefresh"))
        tableView!.mj_footer = footer
    }
    // 底部刷新
    var index = 0
    func footerRefresh(){
        if index < b - 1{
            index += 1
            ursll("\(index)")
            self.tableView!.mj_footer.endRefreshing()
        }
        else {
            footer.endRefreshingWithNoMoreData()//全部刷新完毕
        }
    }
    func headerRefresh(){
        uryanz("0")
        if flag == 1{
            headerursll("0")
            // 结束刷新
            self.tableView!.mj_header.endRefreshing()
        }
        else{
            self.tableView!.mj_header.endRefreshing()
        }
    }
    
    /**判断是否有新的*/
    func uryanz(ur:String){
        parameters.updateValue(ur, forKey: "currentPage")
        Alamofire.request(.POST,urll,parameters:parameters,headers: header ).responseData{ response in
            if let j = response.result.value{
                let js = JSON(data: j)
                let q = Int(js["totalCount"].string!)!
                if(q > self.c){
                    self.flag = q - self.c
                } else {
                    self.flag = 0
                }
            }
            
        }
    }
    
    func headerursll(ur:String){
        var xin:[[String]]=[]
        parameters.updateValue(ur, forKey: "currentPage")
        Alamofire.request(.POST,urll,parameters:parameters,headers: header ).responseData{ response in
            if let j = response.result.value{
                let js = JSON(data: j)
                self.a = js["list"].count;self.b = Int(js["totalCount"].string!)!
                self.c = self.b
                xin = [[String]](count: self.a, repeatedValue: [String](count: 4, repeatedValue: ""))
                //                print(self.Xinwen, 111)
                let qq:[String]=["1","SUBJECT","USER_NAME"]
                for var i=0;i<self.a;i+=1{
                    for var j=0;j<3;j+=1{
                        let q = qq[j]
                        xin[i][j] = js["list"][i][q].string!
                    }
                    if self.ZiLiao.count >= 10{
                        self.ZiLiao.removeLast()
                    }
                    self.ZiLiao.insert(xin[i],atIndex:0)
                }
                self.tableView!.reloadData()
                self.cover!.hidden=true
            }
        }
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func creativeCell(){
        self.tableView = UITableView(frame: self.view.frame, style: UITableViewStyle.Plain)
        self.tableView?.frame = CGRectMake(0, 0, self.view.frame.width, self.view.frame.height - 150)
        cover = UILabel(frame: self.view.frame )
        cover!.backgroundColor = UIColor(red: 0xf0/255, green: 0xf0/255,
            blue: 0xf0/255, alpha: 1)

        //创建控件
        
        self.tableView!.dataSource=self
        self.tableView!.delegate=self
        //实现代理
        
        self.tableView!.backgroundColor = UIColor(red: 0xf0/255, green: 0xf0/255,
            blue: 0xf0/255, alpha: 1)
        
        self.tableView!.registerNib(UINib(nibName:"GroupCellAll", bundle:nil),
            forCellReuseIdentifier:"mycell")
        
        self.tableView!.estimatedRowHeight = 200.0;
//        self.tableView!.rowHeight = UITableViewAutomaticDimension;
        
        //去除单元格分隔线
        self.tableView!.separatorStyle = .None
        
        //去除尾部多余的空行
//        tableView!.tableFooterView = UIView(frame:CGRectZero)
        
        self.view.addSubview(tableView!)
        self.view.addSubview(cover!)
        //显示控件
        
//        self.tableView!.contentInset.bottom = 160
        //由于设置了自动估算高度 导致最后一个cell弹出屏幕外 增加下边缘的高度
        self.tableView!.reloadData()
    }
    
    func ursll(ur:String){
        var xin:[[String]]=[]
        parameters.updateValue(ur, forKey: "currentPage")
//        showNoticeWait()
        Alamofire.request(.POST,urll,parameters:parameters,headers:header).responseData{ response in
            if let j = response.result.value{
                let js = JSON(data: j)
                self.a = js["list"].count;self.b=Int(js["totalCount"].string!)!
                self.c = self.b
                xin = [[String]](count: self.a, repeatedValue: [String](count: 4, repeatedValue: ""))
//                print(self.b)
                let qq:[String]=["1","SUBJECT","USER_NAME"]
                for var i=0;i<self.a;i+=1{
                    for var j=0;j<3;j+=1{
                        let q = qq[j]
                        xin[i][j]=js["list"][i][q].string!
                    }
                }
                if self.b%10 == 0 {
                    self.b = self.b / 10
                }else{
                    self.b = self.b / 10 + 1
                }
                self.ZiLiao += xin
//                dispatch_async(dispatch_get_main_queue(), {
                    self.tableView!.reloadData()
                    self.cover!.hidden=true
//                    self.clearAllNotice()
//                    return
//                })
            }
            
        }
    }
    
    //设置每组有多少数量
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1;
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.ZiLiao.count
    }
    

    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell:GroupCellAll = tableView.dequeueReusableCellWithIdentifier("mycell")
            as! GroupCellAll
        cell.titleView.text = self.ZiLiao[indexPath.row][1]
        cell.GroupEdit.text = self.ZiLiao[indexPath.row][2]

//        cell.GroupTime.text = self.ZiLiao[indexPath.row][3]
        return cell
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        //点击cell后cell不保持选中状态
        
        /*
        let newId = "NOTIFY_ID" + self.ZiLiao[indexPath.row][0]
        let vc = webView()
        vc.data = newId
        //        self.presentViewController(vc, animated: true, completion: nil)
        
        vc.hidesBottomBarWhenPushed = true
        //在push到二级页面后隐藏tab bar
        
        self.navigationController?.pushViewController(vc, animated: true)
        //页面跳转 push方法
        */
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
<file_sep>/zxmoa/submitform.swift
//
//  submitform.swift
//  zxmoa
//
//  Created by mingxing on 16/4/1.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit
import Alamofire
import SwiftyJSON

class submitform: FormViewController {

    var RUN_ID:String?
    var senders:[[String]] = []
    var senders1:[[String]] = []
    var se:[Int]=[]
    var se1:[Int]=[]
    var qb:[[String]] = []
    var date1:[String:AnyObject]?
    var flag = 0
    var ten:Int!
    struct Static {
        static let submit = "opUserListStr"
        static let sub = "userListStr"
    }
    
    func segmentDidchange(segmented:UISegmentedControl){
        
        switch( segmented.selectedSegmentIndex ) {
        case 0:
            self.form.removeSectionAll()
            loadForm(se1,ss: senders1)
            self.tableView.reloadData()
            qb = senders1
            if ten == 1 || ten == 3{
            flag = 1
            }else if ten == 2{
                flag = 2
            }
            break
        case 1:
            self.form.removeSectionAll()
            loadForm(se,ss: senders)
            self.tableView.reloadData()
            qb = senders
            flag = 0
            break
        default : break
        }
  //        print(segmented.titleForSegmentAtIndex(segmented.selectedSegmentIndex))
    }

    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        var items:[String]!
        if ten == 1 || ten == 2{
            items = ["办公室","中层领导"] as [String]
        }else{
            items = ["上报"] as [String]
        }
        let segmented=UISegmentedControl(items:items)
            segmented.center=self.view.center
            segmented.selectedSegmentIndex = 0 //默认选中第一项
            segmented.addTarget(self, action: "segmentDidchange:",
                forControlEvents: UIControlEvents.ValueChanged)  //添加值改变监听
            segmented.tintColor = UIColor.redColor()

        self.view.addSubview(segmented)
    
        self.navigationItem.title = "流转节点"
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "提交  ", style: .Plain, target: self, action: "submit:")
        loadForm(se1,ss: senders1)
        segmentDidchange(segmented)
        // Do any additional setup after loading the view.
    }

    func submit(_: UIBarButtonItem!) {

        date1 = self.form.formValues()
        let d7:String? = date1!["opUserListStr"] as? String
        let d8:String? = date1!["userListStr"] as? String
        if d7 == ""{
            let alert: UIAlertView = UIAlertView(title: "警告", message: "没有指定主办人", delegate: nil, cancelButtonTitle: "OK")
            alert.show()
        }else{
            
            let opuser = qb[opstringToInt(d7!)][0]
            
            date1!["opUserListStr"] = opuser
            date1!["PRCS_OP_USER"] = qb[opstringToInt(d7!)][1]
            date1!["PRCS_OP_USER_NAME_TMP"] = opuser
            date1!["f"] = "turnnext"
            date1!["flow_node"] = "on"
            date1!["MOBILE_SMS_REMIND"] = "0"
            date1!["EMAIL_REMIND"] = "0"
            date1!["SMS_REMIND"] = "0"
            date1!["muc"] = "0"
            date1!["is_concourse"] = "0"
            date1!["OP_FLAG"] = "1"
            date1!["FLOW_PRCS_UP"] = "1"
            date1!["PRCS_ID"] = "1"
            date1!["RUN_ID"] = RUN_ID
            
            if ten == 1{
                date1!["FLOW_ID"] = "3004"
                date1!.updateValue("\(flag)", forKey: "PRCS_TO_CHOOSE")
                date1!["FLOW_PRCS"] = "\(flag+2)"
                let user = stringToInt(d8!)
                var prcs = ""
                var prcsid = ""
                for var i = 0;i < user.count;i++ {
                    let s = user[i]
                    prcs = prcs + qb[s][0] + ","
                    prcsid = prcsid + qb[s][1] + ","
                }
                date1!["userListStr"] = prcs
                date1!["PRCS_USER"] = prcsid
                date1!["PRCS_USER_NAME_TMP"] = prcs
            }else if ten == 2{
                date1!["FLOW_ID"] = "2001"
                date1!.updateValue("\(flag)", forKey: "PRCS_TO_CHOOSE")
                date1!["FLOW_PRCS"] = "\(flag+2)"
                let user = stringToInt(d8!)
                var prcs = ""
                var prcsid = ""
                for var i = 0;i < user.count;i++ {
                    let s = user[i]
                    prcs = prcs + qb[s][0] + ","
                    prcsid = prcsid + qb[s][1] + ","
                }
                date1!["userListStr"] = prcs
                date1!["PRCS_USER"] = prcsid
                date1!["PRCS_USER_NAME_TMP"] = prcs
            }else{
                date1!["FLOW_ID"] = "3002"
                date1!["PRCS_TO_CHOOSE"] = "0"
                date1!["FLOW_PRCS"] = "2"
                let user = stringToInt(d8!)
                var prcs = ""
                var prcsid = ""
                for var i = 0;i < user.count;i++ {
                    let s = user[i]
                    prcs = prcs + senders[s][0] + ","
                    prcsid = prcsid + senders[s][1] + ","
                }
                date1!["userListStr"] = prcs
                date1!["PRCS_USER"] = prcsid
                date1!["PRCS_USER_NAME_TMP"] = prcs
            }
            print(date1)
            urll()
        }
    }
    
    func urll(){
    //        showNoticeWait()
        let url = "http://www.zxmoa.com:83/general/workflow/new/do.php"
        let header = ["Cookie":"PHPSESSID=\(cookpsw)"]
        Alamofire.request(.POST,url,headers: header,parameters: date1).responseString{ response in
            if let j = response.result.value{
            print(j)
            print("---------")
            let range = j.rangeOfString("流程提交完成")
                if range != nil{
                    self.showNoticeSuc("流程提交完成", time: 1.5, autoClear: true)
                    self.navigationController?.popToRootViewControllerAnimated(true)
                }else{
                self.showNoticeErr("流程提交失败",time: 1.5, autoClear: true)
                self.navigationController?.popToRootViewControllerAnimated(true)
                }
            }
        }
    }

    func stringToInt(res:String)-> [Int]{
        let qcharset=NSCharacterSet(charactersInString:"()")
        let str4 = res.stringByTrimmingCharactersInSet(qcharset)
        
        let charset=NSCharacterSet(charactersInString:",")
        let resArray=str4.componentsSeparatedByCharactersInSet(charset)
        let re = NSCharacterSet(charactersInString:" \n ")
        var trname:[Int]=[]
        for var i = 0;i < resArray.count;i++ {
            let str5 = resArray[i].stringByTrimmingCharactersInSet(re)
            trname.append(Int(str5)!)
        }
        return trname
    }
    
    func opstringToInt(res:String)-> Int{
        let qcharset=NSCharacterSet(charactersInString:"()")
        let str4 = res.stringByTrimmingCharactersInSet(qcharset)
    
        let charset=NSCharacterSet(charactersInString:",")
        let resArray=str4 .componentsSeparatedByCharactersInSet(charset)
        
        let re = NSCharacterSet(charactersInString:"\n ")
        let str5 = resArray[0].stringByTrimmingCharactersInSet(re)
        let trname = Int(str5)
        return trname!
    }

    private func loadForm(s:[Int],ss:[[String]]) {
        let form = FormDescriptor(title: "流转节点")

        let section1 = FormSectionDescriptor(headerTitle: "指定主办人", footerTitle: nil)
        
        var row = FormRowDescriptor(tag: Static.submit, rowType: .MultipleSelector, title: "指定主办人")
        row.configuration[FormRowDescriptor.Configuration.Options] = s
        row.configuration[FormRowDescriptor.Configuration.AllowsMultipleSelection] = false
        row.configuration[FormRowDescriptor.Configuration.TitleFormatterClosure] = { value in return ss[value as! Int][0]
            } as TitleFormatterClosure
        if s.count == 1{
            row.value = 0
        }
        section1.addRow(row)
        
        
        let section2 = FormSectionDescriptor(headerTitle: "所有主办人", footerTitle: nil)
        
        row = FormRowDescriptor(tag: Static.sub, rowType: .MultipleSelector, title: "所有主办人")
        row.configuration[FormRowDescriptor.Configuration.Options] = s
        row.configuration[FormRowDescriptor.Configuration.AllowsMultipleSelection] = true
        row.configuration[FormRowDescriptor.Configuration.TitleFormatterClosure] = { value in return ss[value as! Int][0]
            } as TitleFormatterClosure
        
        if s.count == 1{
            row.value = 0
        }
        section2.addRow(row)

        form.sections = [section1,section2]
        self.form = form
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
<file_sep>/zxmoa/GroupCellAll.swift
//
//  GroupCellAll.swift
//  zxmoa
//
//  Created by mingxing on 16/3/17.
//  Copyright © 2016年 ruanxr. All rights reserved.
//

import UIKit

/**自定义cell的xib视图*/
class GroupCellAll: UITableViewCell {

    @IBOutlet weak var groupView: UIView!
    @IBOutlet weak var titleView: UILabel!
    @IBOutlet weak var GroupEdit: UILabel!
    @IBOutlet weak var GroupTime: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
//        groupView.layer.cornerRadius = 5
        
        /**自动换行*/
        titleView.lineBreakMode = NSLineBreakMode.ByWordWrapping
        /**自动换行*/
        titleView.numberOfLines = 0
        // Initialization code
        
        /**设置cell阴影*/
        self.layer.shadowColor = UIColor.grayColor().CGColor
        self.layer.shadowOffset = CGSizeMake(0, 3)//偏移距离
        self.layer.shadowOpacity = 0.3//不透明度
        self.layer.shadowRadius = 2.0//半径
        self.clipsToBounds = false
        /**设置cell阴影*/
    }

    
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
