Commit f072bf03 authored by 刘俊宏's avatar 刘俊宏

新增商品分类,多级分组UI

parent 66621a1d
...@@ -333,6 +333,9 @@ ...@@ -333,6 +333,9 @@
F969BF1F244EE67900C79953 /* GoodsManageListVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = F969BF1D244EE67900C79953 /* GoodsManageListVC.xib */; }; F969BF1F244EE67900C79953 /* GoodsManageListVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = F969BF1D244EE67900C79953 /* GoodsManageListVC.xib */; };
F9956B1C2463D941001A617D /* WorkSelectTimeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9956B1B2463D941001A617D /* WorkSelectTimeView.xib */; }; F9956B1C2463D941001A617D /* WorkSelectTimeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9956B1B2463D941001A617D /* WorkSelectTimeView.xib */; };
F9956B1E2463D94E001A617D /* WorkSelectTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9956B1D2463D94E001A617D /* WorkSelectTimeView.swift */; }; F9956B1E2463D94E001A617D /* WorkSelectTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9956B1D2463D94E001A617D /* WorkSelectTimeView.swift */; };
F9956B22246408A6001A617D /* GoodsClassViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9956B20246408A6001A617D /* GoodsClassViewController.swift */; };
F9956B23246408A6001A617D /* GoodsClassViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9956B21246408A6001A617D /* GoodsClassViewController.xib */; };
F9956B2524640D34001A617D /* GoodsClassModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9956B2424640D34001A617D /* GoodsClassModel.swift */; };
F9DDBE922457BFEC00A32CB2 /* HUDEXT.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9DDBE912457BFEC00A32CB2 /* HUDEXT.swift */; }; F9DDBE922457BFEC00A32CB2 /* HUDEXT.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9DDBE912457BFEC00A32CB2 /* HUDEXT.swift */; };
F9DDBE962457D3EC00A32CB2 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9DDBE942457D3EC00A32CB2 /* WebViewController.swift */; }; F9DDBE962457D3EC00A32CB2 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9DDBE942457D3EC00A32CB2 /* WebViewController.swift */; };
F9DDBE972457D3EC00A32CB2 /* WebViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9DDBE952457D3EC00A32CB2 /* WebViewController.xib */; }; F9DDBE972457D3EC00A32CB2 /* WebViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9DDBE952457D3EC00A32CB2 /* WebViewController.xib */; };
...@@ -716,6 +719,9 @@ ...@@ -716,6 +719,9 @@
F969BF1D244EE67900C79953 /* GoodsManageListVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GoodsManageListVC.xib; sourceTree = "<group>"; }; F969BF1D244EE67900C79953 /* GoodsManageListVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GoodsManageListVC.xib; sourceTree = "<group>"; };
F9956B1B2463D941001A617D /* WorkSelectTimeView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WorkSelectTimeView.xib; sourceTree = "<group>"; }; F9956B1B2463D941001A617D /* WorkSelectTimeView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WorkSelectTimeView.xib; sourceTree = "<group>"; };
F9956B1D2463D94E001A617D /* WorkSelectTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkSelectTimeView.swift; sourceTree = "<group>"; }; F9956B1D2463D94E001A617D /* WorkSelectTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkSelectTimeView.swift; sourceTree = "<group>"; };
F9956B20246408A6001A617D /* GoodsClassViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoodsClassViewController.swift; sourceTree = "<group>"; };
F9956B21246408A6001A617D /* GoodsClassViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GoodsClassViewController.xib; sourceTree = "<group>"; };
F9956B2424640D34001A617D /* GoodsClassModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoodsClassModel.swift; sourceTree = "<group>"; };
F9DDBE912457BFEC00A32CB2 /* HUDEXT.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUDEXT.swift; sourceTree = "<group>"; }; F9DDBE912457BFEC00A32CB2 /* HUDEXT.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUDEXT.swift; sourceTree = "<group>"; };
F9DDBE942457D3EC00A32CB2 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; }; F9DDBE942457D3EC00A32CB2 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
F9DDBE952457D3EC00A32CB2 /* WebViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WebViewController.xib; sourceTree = "<group>"; }; F9DDBE952457D3EC00A32CB2 /* WebViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WebViewController.xib; sourceTree = "<group>"; };
...@@ -1175,6 +1181,7 @@ ...@@ -1175,6 +1181,7 @@
E09B03AD2445B0BA00211A51 /* ViewController */ = { E09B03AD2445B0BA00211A51 /* ViewController */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F9956B1F24640865001A617D /* 商品分类 */,
E0A409C5246400BA00CFF109 /* 分类Cell */, E0A409C5246400BA00CFF109 /* 分类Cell */,
E0A409C02463F2F400CFF109 /* 收支统计 */, E0A409C02463F2F400CFF109 /* 收支统计 */,
F94A315024626D4000FEC38E /* 工作中心 */, F94A315024626D4000FEC38E /* 工作中心 */,
...@@ -1768,6 +1775,16 @@ ...@@ -1768,6 +1775,16 @@
path = "商品管理"; path = "商品管理";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
F9956B1F24640865001A617D /* 商品分类 */ = {
isa = PBXGroup;
children = (
F9956B20246408A6001A617D /* GoodsClassViewController.swift */,
F9956B21246408A6001A617D /* GoodsClassViewController.xib */,
F9956B2424640D34001A617D /* GoodsClassModel.swift */,
);
path = "商品分类";
sourceTree = "<group>";
};
F9DDBE932457D3CB00A32CB2 /* Web */ = { F9DDBE932457D3CB00A32CB2 /* Web */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1944,6 +1961,7 @@ ...@@ -1944,6 +1961,7 @@
E088CC942447124D000DAA8A /* BindViewController.xib in Resources */, E088CC942447124D000DAA8A /* BindViewController.xib in Resources */,
E03549A9245820C2008BD021 /* PiCiXuanZeCell.xib in Resources */, E03549A9245820C2008BD021 /* PiCiXuanZeCell.xib in Resources */,
E0F97B092451620B001BD600 /* ProductDetailViewController.xib in Resources */, E0F97B092451620B001BD600 /* ProductDetailViewController.xib in Resources */,
F9956B23246408A6001A617D /* GoodsClassViewController.xib in Resources */,
E06524FA24581A7900CA22E2 /* ChuKuCell.xib in Resources */, E06524FA24581A7900CA22E2 /* ChuKuCell.xib in Resources */,
E0B9462C2456AABE00FBEC9A /* YuShouWeiKuanFaHuoCell.xib in Resources */, E0B9462C2456AABE00FBEC9A /* YuShouWeiKuanFaHuoCell.xib in Resources */,
E0A2E81F24552F0A00D6DB34 /* TilteAndTextViewCell.xib in Resources */, E0A2E81F24552F0A00D6DB34 /* TilteAndTextViewCell.xib in Resources */,
...@@ -2166,6 +2184,7 @@ ...@@ -2166,6 +2184,7 @@
E07B1E5E24591AA50055BA3C /* KeHuXQViewController.swift in Sources */, E07B1E5E24591AA50055BA3C /* KeHuXQViewController.swift in Sources */,
F9DDBE962457D3EC00A32CB2 /* WebViewController.swift in Sources */, F9DDBE962457D3EC00A32CB2 /* WebViewController.swift in Sources */,
E06524F924581A7900CA22E2 /* ChuKuCell.swift in Sources */, E06524F924581A7900CA22E2 /* ChuKuCell.swift in Sources */,
F9956B2524640D34001A617D /* GoodsClassModel.swift in Sources */,
F961D26B24500FF6007FBE70 /* HeaderSelectView.swift in Sources */, F961D26B24500FF6007FBE70 /* HeaderSelectView.swift in Sources */,
E09F4C9D2452BEBB00BE033D /* JiPaiFangShiViewController.swift in Sources */, E09F4C9D2452BEBB00BE033D /* JiPaiFangShiViewController.swift in Sources */,
E0D4166424483058008DCAB4 /* ChangePassViewController.swift in Sources */, E0D4166424483058008DCAB4 /* ChangePassViewController.swift in Sources */,
...@@ -2185,6 +2204,7 @@ ...@@ -2185,6 +2204,7 @@
F950FDAD245163E500C40530 /* GoodsListModel.swift in Sources */, F950FDAD245163E500C40530 /* GoodsListModel.swift in Sources */,
E0D197BD2448431C002B080C /* BabySpeaker.m in Sources */, E0D197BD2448431C002B080C /* BabySpeaker.m in Sources */,
E00D85E1244561FD00F5F816 /* SceneDelegate.swift in Sources */, E00D85E1244561FD00F5F816 /* SceneDelegate.swift in Sources */,
F9956B22246408A6001A617D /* GoodsClassViewController.swift in Sources */,
F950FDDA24518B9500C40530 /* FSCalendarCell.m in Sources */, F950FDDA24518B9500C40530 /* FSCalendarCell.m in Sources */,
F969BF1E244EE67900C79953 /* GoodsManageListVC.swift in Sources */, F969BF1E244EE67900C79953 /* GoodsManageListVC.swift in Sources */,
E0273DD824551B4C00B3FCAE /* SendTimeSelectView.swift in Sources */, E0273DD824551B4C00B3FCAE /* SendTimeSelectView.swift in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<capability name="Named colors" minToolsVersion="9.0"/> <capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
...@@ -24,11 +24,7 @@ ...@@ -24,11 +24,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="3" translatesAutoresizingMaskIntoConstraints="NO" id="fzr-hO-ZT7"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="3" translatesAutoresizingMaskIntoConstraints="NO" id="fzr-hO-ZT7">
<rect key="frame" x="351" y="20" width="9" height="9"/> <rect key="frame" x="355.5" y="20" width="4.5" height="9"/>
<constraints>
<constraint firstAttribute="width" constant="9" id="TBk-nn-jgD"/>
<constraint firstAttribute="height" constant="9" id="f5j-5Q-4wy"/>
</constraints>
</imageView> </imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="j9L-eQ-KnD"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="j9L-eQ-KnD">
<rect key="frame" x="15" y="48" width="360" height="1"/> <rect key="frame" x="15" y="48" width="360" height="1"/>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<capability name="Named colors" minToolsVersion="9.0"/> <capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
...@@ -31,11 +31,7 @@ ...@@ -31,11 +31,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="3" translatesAutoresizingMaskIntoConstraints="NO" id="uwp-3N-xwZ"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="3" translatesAutoresizingMaskIntoConstraints="NO" id="uwp-3N-xwZ">
<rect key="frame" x="351" y="19.5" width="9" height="9"/> <rect key="frame" x="355.5" y="19.5" width="4.5" height="9"/>
<constraints>
<constraint firstAttribute="height" constant="9" id="v9J-st-KXA"/>
<constraint firstAttribute="width" constant="9" id="x7b-nD-ase"/>
</constraints>
</imageView> </imageView>
</subviews> </subviews>
<color key="backgroundColor" name="分类Cell背景色"/> <color key="backgroundColor" name="分类Cell背景色"/>
...@@ -63,7 +59,7 @@ ...@@ -63,7 +59,7 @@
<resources> <resources>
<image name="3" width="4.5" height="9"/> <image name="3" width="4.5" height="9"/>
<namedColor name="分类Cell背景色"> <namedColor name="分类Cell背景色">
<color red="0.90980392156862744" green="0.93725490196078431" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.9100000262260437" green="0.93699997663497925" blue="0.97299998998641968" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor> </namedColor>
<namedColor name="标题字颜色"> <namedColor name="标题字颜色">
<color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<capability name="Named colors" minToolsVersion="9.0"/> <capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
...@@ -24,11 +24,7 @@ ...@@ -24,11 +24,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="daixuan" translatesAutoresizingMaskIntoConstraints="NO" id="4da-tb-aTt"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="daixuan" translatesAutoresizingMaskIntoConstraints="NO" id="4da-tb-aTt">
<rect key="frame" x="340" y="14.5" width="20" height="20"/> <rect key="frame" x="341" y="15" width="19" height="19"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="kHU-M2-7Wc"/>
<constraint firstAttribute="width" constant="20" id="oXa-pd-vlS"/>
</constraints>
</imageView> </imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SfC-2S-YPK"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SfC-2S-YPK">
<rect key="frame" x="15" y="48" width="360" height="1"/> <rect key="frame" x="15" y="48" width="360" height="1"/>
...@@ -63,7 +59,7 @@ ...@@ -63,7 +59,7 @@
<resources> <resources>
<image name="daixuan" width="19" height="19"/> <image name="daixuan" width="19" height="19"/>
<namedColor name="分类Cell背景色"> <namedColor name="分类Cell背景色">
<color red="0.90980392156862744" green="0.93725490196078431" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.9100000262260437" green="0.93699997663497925" blue="0.97299998998641968" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor> </namedColor>
<namedColor name="标题字颜色"> <namedColor name="标题字颜色">
<color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
......
//
// GoodsClassModel.swift
// GeliBusinessPlatform
//
// Created by 刘俊宏 on 2020/5/7.
// Copyright © 2020 junye lu. All rights reserved.
//
import Foundation
import ObjectMapper
class GoodsClassModel: NSObject {
var isExpand : Bool? = false
var isSelect : Bool? = false
var isCanExpand : Bool? = false
var isCanSelect : Bool? = false
var Level_Type : Int?
var name : String?
var modelS : Array<GoodsClassModel>? = []
var modelId : Int?
}
//
// GoodsClassViewController.swift
// GeliBusinessPlatform
//
// Created by 刘俊宏 on 2020/5/7.
// Copyright © 2020 junye lu. All rights reserved.
//
import UIKit
import Dollar
class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITableViewDataSource{
override func viewDidLoad() {
super.viewDidLoad()
navbar.title = "请选择商品分类"
self.view.addSubview(navbar)
for i in 0..<5 {
let model_1 = GoodsClassModel()
model_1.name = "商品=\(i)"
model_1.isExpand = false
model_1.isCanExpand = false
model_1.isCanSelect = false
model_1.isSelect = false
model_1.Level_Type = 0
model_1.modelId = i
if i != 1 {
model_1.isCanExpand = true
for j in 0..<3 {
let model_2 = GoodsClassModel()
model_2.name = "第二商品=\(j)"
model_2.isExpand = false
model_2.isCanExpand = false
model_2.isCanSelect = false
model_2.isSelect = false
model_2.Level_Type = 1
model_2.modelId = j
if j != 2 {
model_2.isCanExpand = true
for k in 0..<2 {
let model_3 = GoodsClassModel()
model_3.name = "第三商品=\(k)"
model_3.isExpand = false
model_3.isCanExpand = false
model_3.isCanSelect = true
model_3.isSelect = false
model_3.Level_Type = 2
model_3.modelId = k
model_2.modelS?.append(model_3)
}
}else{
model_2.isCanSelect = true
}
model_1.modelS?.append(model_2)
}
}else{
model_1.isCanSelect = true
}
var arrs:Array<Any> = []
arrs.append(model_1)
dataArr.append(arrs)
}
setTabv()
}
var tableV :UITableView!
var dataArr:Array<Any> = []
func setTabv() {
tableV = UITableView()
view.addSubview(tableV);
tableV.snp.makeConstraints { (make) in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(navbar.snp_bottom)
}
tableV.backgroundColor = UIColor.init(named: "app底色")
tableV.delegate = self
tableV.dataSource = self
tableV.separatorStyle = .none
tableV?.register(UINib(nibName: "FirstCell", bundle: nil), forCellReuseIdentifier: "FirstCell")
tableV?.register(UINib(nibName: "SecondCell", bundle: nil), forCellReuseIdentifier: "SecondCell")
tableV?.register(UINib(nibName: "ThirdCell", bundle: nil), forCellReuseIdentifier: "ThirdCell")
}
func numberOfSections(in tableView: UITableView) -> Int {
return dataArr.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let arrs = dataArr[section] as! Array<Any>
return arrs.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let arrs = dataArr[indexPath.section] as! Array<Any>
let rowModel = arrs[indexPath.row] as! GoodsClassModel
if rowModel.Level_Type == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: "SecondCell") as! SecondCell
cell.nameLbl.text = rowModel.name
if rowModel.isCanExpand! {
if rowModel.isExpand! {
cell.imgView.image = UIImage.init(named: "2")
cell.nameLbl.textColor = UIColor.init(named: "标题字颜色")
}else{
cell.imgView.image = UIImage.init(named: "3")
cell.nameLbl.textColor = UIColor.init(named: "标题字颜色")
}
}else{
if rowModel.isSelect! {
cell.imgView.image = UIImage.init(named: "yuxuan")
cell.nameLbl.textColor = UIColor.init(named: "蓝色字体颜色")
}else{
cell.imgView.image = UIImage.init(named: "daixuan")
cell.nameLbl.textColor = UIColor.init(named: "标题字颜色")
}
}
return cell
}
if rowModel.Level_Type == 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: "ThirdCell") as! ThirdCell
cell.nameLbl.text = rowModel.name
if rowModel.isSelect! {
cell.imgView.image = UIImage.init(named: "yuxuan")
cell.nameLbl.textColor = UIColor.init(named: "蓝色字体颜色")
}else{
cell.imgView.image = UIImage.init(named: "daixuan")
cell.nameLbl.textColor = UIColor.init(named: "标题字颜色")
}
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "FirstCell") as! FirstCell
if rowModel.isCanExpand! {
if rowModel.isExpand! {
cell.imgView.image = UIImage.init(named: "1")
cell.nameLbl.textColor = UIColor.init(named: "蓝色字体颜色")
}else{
cell.imgView.image = UIImage.init(named: "3")
cell.nameLbl.textColor = UIColor.init(named: "标题字颜色")
}
}else{
if rowModel.isSelect! {
cell.imgView.image = UIImage.init(named: "yuxuan")
cell.nameLbl.textColor = UIColor.init(named: "蓝色字体颜色")
}else{
cell.imgView.image = UIImage.init(named: "daixuan")
cell.nameLbl.textColor = UIColor.init(named: "标题字颜色")
}
}
cell.nameLbl.text = rowModel.name
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(indexPath)
let arrs = dataArr[indexPath.section] as! Array<Any>
let rowModel = arrs[indexPath.row] as! GoodsClassModel
if rowModel.Level_Type != 2 && rowModel.isCanExpand!
{
rowModel.isExpand = !rowModel.isExpand!
reloadSection(section: indexPath.section, model: rowModel, isExpand: rowModel.isExpand!)
}else{
rowModel.isSelect = !rowModel.isSelect!
let reloadSet = IndexSet.init(arrayLiteral: indexPath.section)
tableV.reloadSections(reloadSet, with: .automatic)
}
}
//MARK:--展开或收起(利用数据)
func reloadSection(section:Int,model:GoodsClassModel,isExpand:Bool) {
var arrs = dataArr[section] as! Array<GoodsClassModel>
let index = Dollar.indexOf(arrs, value: model)
if isExpand {
//这一步是防止在二级展开的情况下,关闭一级展开, 则二级展开的状态还是展开,需要手动置回 NO
model.modelS?.forEach({ (md) in
md.isExpand = false
})
arrs.insert(contentsOf: model.modelS!, at: index! + 1)
dataArr.remove(at: section)
dataArr.insert(arrs, at: section)
}else{
let lenght = ((model.Level_Type == 0) ? (arrs.count - 1):model.modelS?.count)!
let startIndex = index! + 1
let lastIndex = startIndex + lenght
for i in (startIndex..<lastIndex).reversed() {
arrs.remove(at: (i))
}
dataArr.remove(at: section)
dataArr.insert(arrs, at: section)
}
let reloadSet = IndexSet.init(arrayLiteral: section)
tableV.reloadSections(reloadSet, with: .automatic)
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50*glscale
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="GoodsClassViewController" customModuleProvider="target">
<connections>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
</view>
</objects>
</document>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment