CommonRightMenuKS.swift 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. //
  2. // CommonRightMenuKS.swift
  3. // xingchuangke
  4. //
  5. // Created by Apple on 2021/3/4.
  6. // Copyright © 2021 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class CommonRightMenuKS: UIView {
  10. @IBOutlet weak var scrollView: UIScrollView!
  11. @IBOutlet weak var busAllBtn: UIButton!
  12. @IBOutlet weak var busJJBtn: UIButton!
  13. @IBOutlet weak var busSHBtn: UIButton!
  14. @IBOutlet weak var dealAllBtn: UIButton!
  15. @IBOutlet weak var dealSKBtn: UIButton!
  16. @IBOutlet weak var dealHKBtn: UIButton!
  17. @IBOutlet weak var dealWXBtn: UIButton!
  18. @IBOutlet weak var dealALBtn: UIButton!
  19. @IBOutlet weak var dealSFBtn: UIButton!
  20. @IBOutlet weak var cardAllBtn: UIButton!
  21. @IBOutlet weak var cardJJBtn: UIButton!
  22. @IBOutlet weak var cardDJBtn: UIButton!
  23. @IBOutlet weak var wayAllBtn: UIButton!
  24. @IBOutlet weak var wayBtn: UIButton!
  25. @IBOutlet weak var wayBtn1: UIButton!
  26. @IBOutlet weak var deviceAllBtn: UIButton!
  27. @IBOutlet weak var deviceMPBtn: UIButton!
  28. @IBOutlet weak var deviceCTBtn: UIButton!
  29. @IBOutlet weak var deviceDPBtn: UIButton!
  30. @IBOutlet weak var btnConfrim: UIButton!
  31. @IBOutlet weak var btnReset: UIButton!
  32. @IBOutlet weak var btnEnd: UIButton!
  33. @IBOutlet weak var btnStart: UIButton!
  34. var queryEntity: QueryEntityKS!
  35. var oBackFunc: CommonBackQueryKS!
  36. var btnTypes = [UIButton]()
  37. var arrTempType = NSMutableArray()
  38. func initView(arrType: NSMutableArray, backFunc:@escaping CommonBackQueryKS) {
  39. oBackFunc = backFunc
  40. self.setSizeWidth(width: ScreenWidth)
  41. btnEnd.setCornerRadius(size: 3)
  42. btnStart.setCornerRadius(size: 3)
  43. scrollView.contentSize.height = btnConfrim.bottom() + 40
  44. busAllBtn.isSelected = true
  45. dealAllBtn.isSelected = true
  46. cardAllBtn.isSelected = true
  47. wayAllBtn.isSelected = true
  48. deviceAllBtn.isSelected = true
  49. busAllBtn.setTitleColor(.red, for: .selected)
  50. dealAllBtn.setTitleColor(.red, for: .selected)
  51. cardAllBtn.setTitleColor(.red, for: .selected)
  52. wayAllBtn.setTitleColor(.red, for: .selected)
  53. deviceAllBtn.setTitleColor(.red, for: .selected)
  54. arrTempType.removeAllObjects()
  55. arrTempType.addObjects(from: arrType as! [Any])
  56. // scrollViewType.removeAll();
  57. var left: CGFloat = 14
  58. btnTypes.removeAll()
  59. for i in 0 ..< arrType.count {
  60. let btn = UIButton(frame: CGRect(x: left, y: 0, width: 100, height: 36))
  61. btn.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
  62. btn.setTitle((arrType[i] as! NSDictionary).getString(key: "name"), for: .normal)
  63. btn.setTitleColor(CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), for: .normal)
  64. btn.setTitleColor(UIColor.white, for: .selected)
  65. btn.sizeToFitWidth()
  66. btn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
  67. btn.tag = i
  68. btn.addTarget(self, action: #selector(btnTypeClick), for: .touchUpInside)
  69. btn.setSizeWidth(width: btn.width() + 40)
  70. // scrollViewType.addSubview(btn)
  71. left = btn.right() + 15
  72. btnTypes.append(btn)
  73. btn.setCornerRadius(size: 3)
  74. }
  75. // scrollViewType.contentSize.width = left;
  76. queryEntity = QueryEntityKS()
  77. queryEntity.startTime = "选择开始日期"
  78. queryEntity.endTime = "选择截止日期"
  79. }
  80. @objc func btnTypeClick(btn: UIButton) {
  81. for btnTemp in btnTypes {
  82. if btnTemp.tag == btn.tag {
  83. queryEntity.typeID = (arrTempType[btn.tag] as! NSDictionary).getString(key: "id")
  84. btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x2A92F7, alpha: 1.0)
  85. btnTemp.isSelected = true
  86. } else {
  87. btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
  88. btnTemp.isSelected = false
  89. }
  90. }
  91. }
  92. @IBAction func btnMenuClick(_ sender: AnyObject) {
  93. switch (sender as! UIButton).tag {
  94. case 1001: // 开始时间
  95. let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
  96. var defaultDate: Date!
  97. if queryEntity.startTime == "选择开始日期" || queryEntity.startTime.length() != 10 {
  98. defaultDate = CommonDate.addMonth(date: Date(), month: 0)
  99. } else {
  100. defaultDate = CommonDate.getDateForString(dateStr: queryEntity.startTime, dateFormat: "yyyy-MM-dd")
  101. }
  102. viewDatePicer.datePicker.maximumDate = Date()
  103. viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
  104. self!.queryEntity.startTime = str
  105. self!.refreshView()
  106. }
  107. break
  108. case 1002: // 结束时间
  109. let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
  110. var defaultDate: Date!
  111. if queryEntity.endTime == "选择截止日期" || queryEntity.endTime.length() != 10 {
  112. defaultDate = Date()
  113. } else {
  114. defaultDate = CommonDate.getDateForString(dateStr: queryEntity.endTime, dateFormat: "yyyy-MM-dd")
  115. }
  116. viewDatePicer.datePicker.maximumDate = Date()
  117. viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
  118. self!.queryEntity.endTime = str
  119. self!.refreshView()
  120. }
  121. refreshView()
  122. break
  123. case 1011: // 全部
  124. queryEntity.busType = ""
  125. refreshView()
  126. break
  127. case 1012: // 个人版
  128. queryEntity.busType = "0"
  129. refreshView()
  130. case 1013: // 商户版
  131. queryEntity.busType = "1"
  132. refreshView()
  133. break
  134. case 1021: // 全部
  135. queryEntity.depositTrade = ""
  136. refreshView()
  137. break
  138. case 1022: // 刷卡
  139. queryEntity.depositTrade = "01"
  140. refreshView()
  141. break
  142. case 1023: // 挥卡
  143. queryEntity.depositTrade = "02"
  144. refreshView()
  145. break
  146. case 1024: // 微信
  147. queryEntity.depositTrade = "03"
  148. refreshView()
  149. break
  150. case 1025: // 支付宝
  151. queryEntity.depositTrade = "04"
  152. refreshView()
  153. break
  154. case 1026: // 闪付
  155. queryEntity.depositTrade = "05"
  156. refreshView()
  157. break
  158. case 1041: // 全部
  159. queryEntity.cardType = ""
  160. refreshView()
  161. break
  162. case 1042: // 借记卡
  163. queryEntity.cardType = "01"
  164. refreshView()
  165. break
  166. case 1043: // 贷记卡
  167. queryEntity.cardType = "02"
  168. refreshView()
  169. break
  170. case 1003: // s+0
  171. queryEntity.settleWay = "01"
  172. refreshView()
  173. break
  174. case 1004: // t+1
  175. queryEntity.settleWay = "02"
  176. refreshView()
  177. break
  178. case 1005: // 全部
  179. queryEntity.settleWay = ""
  180. refreshView()
  181. break
  182. case 1050: // 全部
  183. queryEntity.deviceType = ""
  184. refreshView()
  185. break
  186. case 1051: // MPOS
  187. queryEntity.deviceType = "MPOS"
  188. refreshView()
  189. break
  190. case 1052: // 传统POS
  191. queryEntity.deviceType = "传统POS"
  192. refreshView()
  193. break
  194. case 1053: // 电签POS
  195. queryEntity.deviceType = "电签POS"
  196. refreshView()
  197. break
  198. case 1007: // 重置
  199. queryEntity.startTime = "选择开始日期"
  200. queryEntity.endTime = "选择截止日期"
  201. queryEntity.cardType = ""
  202. queryEntity.settleWay = ""
  203. queryEntity.typeID = ""
  204. queryEntity.depositTrade = ""
  205. queryEntity.busType = ""
  206. queryEntity.deviceType = ""
  207. refreshView()
  208. break
  209. case 1008: // 确定
  210. hidMenu()
  211. if oBackFunc != nil {
  212. oBackFunc(queryEntity)
  213. }
  214. break
  215. case 1009: // 隐藏
  216. hidMenu()
  217. break
  218. default:
  219. break
  220. }
  221. }
  222. func refreshView() {
  223. for btnTemp in btnTypes {
  224. if queryEntity.typeID != (arrTempType[btnTemp.tag] as! NSDictionary).getString(key: "id") {
  225. btnTemp.isSelected = false
  226. btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
  227. }
  228. }
  229. if queryEntity.busType == "" {
  230. busAllBtn.isSelected = true
  231. busJJBtn.isSelected = false
  232. busSHBtn.isSelected = false
  233. busAllBtn.setTitleColor(.red, for: .selected)
  234. busJJBtn.setTitleColor(.black, for: .normal)
  235. busSHBtn.setTitleColor(.black, for: .normal)
  236. } else if queryEntity.busType == "0" {
  237. busAllBtn.isSelected = false
  238. busJJBtn.isSelected = true
  239. busSHBtn.isSelected = false
  240. busAllBtn.setTitleColor(.black, for: .normal)
  241. busJJBtn.setTitleColor(.red, for: .selected)
  242. busSHBtn.setTitleColor(.black, for: .normal)
  243. } else {
  244. busAllBtn.isSelected = false
  245. busJJBtn.isSelected = false
  246. busSHBtn.isSelected = true
  247. busAllBtn.setTitleColor(.black, for: .normal)
  248. busJJBtn.setTitleColor(.black, for: .normal)
  249. busSHBtn.setTitleColor(.red, for: .selected)
  250. }
  251. if queryEntity.depositTrade == "" {
  252. dealAllBtn.isSelected = true
  253. dealSKBtn.isSelected = false
  254. dealHKBtn.isSelected = false
  255. dealWXBtn.isSelected = false
  256. dealALBtn.isSelected = false
  257. dealSFBtn.isSelected = false
  258. dealAllBtn.setTitleColor(.red, for: .selected)
  259. dealSKBtn.setTitleColor(.black, for: .normal)
  260. dealHKBtn.setTitleColor(.black, for: .normal)
  261. dealWXBtn.setTitleColor(.black, for: .normal)
  262. dealALBtn.setTitleColor(.black, for: .normal)
  263. dealSFBtn.setTitleColor(.black, for: .normal)
  264. } else if queryEntity.depositTrade == "01" {
  265. dealAllBtn.isSelected = false
  266. dealSKBtn.isSelected = true
  267. dealHKBtn.isSelected = false
  268. dealWXBtn.isSelected = false
  269. dealALBtn.isSelected = false
  270. dealSFBtn.isSelected = false
  271. dealAllBtn.setTitleColor(.black, for: .normal)
  272. dealSKBtn.setTitleColor(.red, for: .selected)
  273. dealHKBtn.setTitleColor(.black, for: .normal)
  274. dealWXBtn.setTitleColor(.black, for: .normal)
  275. dealALBtn.setTitleColor(.black, for: .normal)
  276. dealSFBtn.setTitleColor(.black, for: .normal)
  277. }else if queryEntity.depositTrade == "02" {
  278. dealAllBtn.isSelected = false
  279. dealSKBtn.isSelected = false
  280. dealHKBtn.isSelected = true
  281. dealWXBtn.isSelected = false
  282. dealALBtn.isSelected = false
  283. dealSFBtn.isSelected = false
  284. dealAllBtn.setTitleColor(.black, for: .normal)
  285. dealSKBtn.setTitleColor(.black, for: .normal)
  286. dealHKBtn.setTitleColor(.red, for: .selected)
  287. dealWXBtn.setTitleColor(.black, for: .normal)
  288. dealALBtn.setTitleColor(.black, for: .normal)
  289. dealSFBtn.setTitleColor(.black, for: .normal)
  290. }else if queryEntity.depositTrade == "03" {
  291. dealAllBtn.isSelected = false
  292. dealSKBtn.isSelected = false
  293. dealHKBtn.isSelected = false
  294. dealWXBtn.isSelected = true
  295. dealALBtn.isSelected = false
  296. dealSFBtn.isSelected = false
  297. dealAllBtn.setTitleColor(.black, for: .normal)
  298. dealSKBtn.setTitleColor(.black, for: .normal)
  299. dealHKBtn.setTitleColor(.black, for: .normal)
  300. dealWXBtn.setTitleColor(.red, for: .selected)
  301. dealALBtn.setTitleColor(.black, for: .normal)
  302. dealSFBtn.setTitleColor(.black, for: .normal)
  303. }else if queryEntity.depositTrade == "04" {
  304. dealAllBtn.isSelected = false
  305. dealSKBtn.isSelected = false
  306. dealHKBtn.isSelected = false
  307. dealWXBtn.isSelected = false
  308. dealALBtn.isSelected = true
  309. dealSFBtn.isSelected = false
  310. dealAllBtn.setTitleColor(.black, for: .normal)
  311. dealSKBtn.setTitleColor(.black, for: .normal)
  312. dealHKBtn.setTitleColor(.black, for: .normal)
  313. dealWXBtn.setTitleColor(.black, for: .normal)
  314. dealALBtn.setTitleColor(.red, for: .selected)
  315. dealSFBtn.setTitleColor(.black, for: .normal)
  316. }else {
  317. dealAllBtn.isSelected = true
  318. dealSKBtn.isSelected = false
  319. dealHKBtn.isSelected = false
  320. dealWXBtn.isSelected = false
  321. dealALBtn.isSelected = false
  322. dealSFBtn.isSelected = true
  323. dealAllBtn.setTitleColor(.black, for: .normal)
  324. dealSKBtn.setTitleColor(.black, for: .normal)
  325. dealHKBtn.setTitleColor(.black, for: .normal)
  326. dealWXBtn.setTitleColor(.black, for: .normal)
  327. dealALBtn.setTitleColor(.black, for: .normal)
  328. dealSFBtn.setTitleColor(.red, for: .selected)
  329. }
  330. if queryEntity.cardType == "" {
  331. cardAllBtn.isSelected = true
  332. cardJJBtn.isSelected = false
  333. cardDJBtn.isSelected = false
  334. cardAllBtn.setTitleColor(.red, for: .selected)
  335. cardJJBtn.setTitleColor(.black, for: .normal)
  336. cardDJBtn.setTitleColor(.black, for: .normal)
  337. } else if queryEntity.cardType == "01" {
  338. cardAllBtn.isSelected = false
  339. cardJJBtn.isSelected = true
  340. cardDJBtn.isSelected = false
  341. cardAllBtn.setTitleColor(.black, for: .normal)
  342. cardJJBtn.setTitleColor(.red, for: .selected)
  343. cardDJBtn.setTitleColor(.black, for: .normal)
  344. }else if queryEntity.cardType == "02" {
  345. cardAllBtn.isSelected = false
  346. cardJJBtn.isSelected = false
  347. cardDJBtn.isSelected = true
  348. cardAllBtn.setTitleColor(.black, for: .normal)
  349. cardJJBtn.setTitleColor(.black, for: .normal)
  350. cardDJBtn.setTitleColor(.red, for: .selected)
  351. }
  352. if queryEntity.settleWay == "" {
  353. wayAllBtn.isSelected = true
  354. wayBtn.isSelected = false
  355. wayBtn1.isSelected = false
  356. wayAllBtn.setTitleColor(.red, for: .selected)
  357. wayBtn.setTitleColor(.black, for: .normal)
  358. wayBtn1.setTitleColor(.black, for: .normal)
  359. } else if queryEntity.settleWay == "01" {
  360. wayAllBtn.isSelected = false
  361. wayBtn.isSelected = true
  362. wayBtn1.isSelected = false
  363. wayAllBtn.setTitleColor(.black, for: .normal)
  364. wayBtn.setTitleColor(.red, for: .selected)
  365. wayBtn1.setTitleColor(.black, for: .normal)
  366. }else {
  367. wayAllBtn.isSelected = false
  368. wayBtn.isSelected = false
  369. wayBtn1.isSelected = true
  370. wayAllBtn.setTitleColor(.black, for: .normal)
  371. wayBtn.setTitleColor(.black, for: .normal)
  372. wayBtn1.setTitleColor(.red, for: .selected)
  373. }
  374. if queryEntity.deviceType == "" {
  375. deviceAllBtn.isSelected = true
  376. deviceMPBtn.isSelected = false
  377. deviceCTBtn.isSelected = false
  378. deviceDPBtn.isSelected = false
  379. deviceAllBtn.setTitleColor(.red, for: .selected)
  380. deviceMPBtn.setTitleColor(.black, for: .normal)
  381. deviceCTBtn.setTitleColor(.black, for: .normal)
  382. deviceDPBtn.setTitleColor(.black, for: .normal)
  383. } else if queryEntity.deviceType == "MPOS" {
  384. deviceAllBtn.isSelected = false
  385. deviceMPBtn.isSelected = true
  386. deviceCTBtn.isSelected = false
  387. deviceDPBtn.isSelected = false
  388. deviceAllBtn.setTitleColor(.black, for: .normal)
  389. deviceMPBtn.setTitleColor(.red, for: .selected)
  390. deviceCTBtn.setTitleColor(.black, for: .normal)
  391. deviceDPBtn.setTitleColor(.black, for: .normal)
  392. }else if queryEntity.deviceType == "传统POS" {
  393. deviceAllBtn.isSelected = false
  394. deviceMPBtn.isSelected = false
  395. deviceCTBtn.isSelected = true
  396. deviceDPBtn.isSelected = false
  397. deviceAllBtn.setTitleColor(.black, for: .normal)
  398. deviceMPBtn.setTitleColor(.black, for: .normal)
  399. deviceCTBtn.setTitleColor(.red, for: .selected)
  400. deviceDPBtn.setTitleColor(.black, for: .normal)
  401. }else if queryEntity.deviceType == "电签POS" {
  402. deviceAllBtn.isSelected = false
  403. deviceMPBtn.isSelected = false
  404. deviceCTBtn.isSelected = false
  405. deviceDPBtn.isSelected = true
  406. deviceAllBtn.setTitleColor(.black, for: .normal)
  407. deviceMPBtn.setTitleColor(.black, for: .normal)
  408. deviceCTBtn.setTitleColor(.black, for: .normal)
  409. deviceDPBtn.setTitleColor(.red, for: .selected)
  410. }
  411. btnStart.setTitle(queryEntity.startTime, for: .normal)
  412. btnEnd.setTitle(queryEntity.endTime, for: .normal)
  413. }
  414. func showMenu(paretnView: UIView) {
  415. scrollView.marginLeft(left: ScreenWidth)
  416. paretnView.addSubview(self)
  417. self.setFillForSuperView()
  418. UIView.animate(withDuration: 0.5, animations: {
  419. self.scrollView.marginLeft(left: ScreenWidth - self.scrollView.width())
  420. }) { (_) in
  421. }
  422. }
  423. func hidMenu() {
  424. UIView.animate(withDuration: 0.5, animations: {
  425. self.scrollView.marginLeft(left: ScreenWidth)
  426. }) { (_) in
  427. self.removeFromSuperview()
  428. }
  429. }
  430. }
  431. class QueryEntityKS: NSObject {
  432. ///品牌ID
  433. var typeID = ""
  434. var startTime = ""
  435. var endTime = ""
  436. ///结算方式:T0 T1
  437. var settleWay = ""
  438. ///交易卡类型:借记卡
  439. var cardType = ""
  440. ///商户类型
  441. var busType = ""
  442. ///交易类型
  443. var depositTrade = ""
  444. ///设备类型
  445. var deviceType = ""
  446. }
  447. typealias CommonBackQueryKS=(_ entity: QueryEntityKS) -> Void