Commit d6450157 authored by lujunye's avatar lujunye

17

parent 3328ec68
......@@ -23,6 +23,15 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
}
}
}
var is_dz = false {
didSet {
if is_dz{
title_lbl.text = "新增店铺"
}
}
}
let UserToken = UserDefaults.standard.value(forKey: "user_token")
func GLAlertTbAddViewCellBtnAction(target: String,tag:Int) {
......@@ -39,6 +48,11 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
list_tableview.reloadData()
}
var dz_centers:Array<getDbtList_Data_model> = [] {
didSet{
bottom_tableview.reloadData()
}
}
var dls_centers:Array<getAllAge_data_model> = [] {
didSet{
......@@ -49,13 +63,11 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
var centers:Array<getAllShopDataModel> = []{
didSet{
print(centers.count,gys_centers.count)
bottom_tableview.reloadData()
}
}
var gys_centers:Array<getSupShopDataModel> = []{
didSet{
print(centers.count,gys_centers.count)
bottom_tableview.reloadData()
}
}
......@@ -72,6 +84,9 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
if title_lbl.text?.contains("代理商") == true {
return dls_centers.count
}
if is_dz {
return dz_centers.count
}
return centers.count
}
}
......@@ -98,7 +113,27 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
}
return cell
}else{
if is_dz {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSelectCell")! as! TitleAndSelectCell
cell.is_center_select = true
cell.delegate = self
let model = dz_centers[indexPath.row]
cell.titleLbl.text = model.shop_name
let str = datas[idx] as! String
if str.count > 0{
if cell.titleLbl.text == str {
cell.selectBtn.isSelected = true
}else{
cell.selectBtn.isSelected = false
}
}
return cell
}
if title_lbl.text == "新增供应商" || title_lbl.text == "新增代理商"{
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSelectCell")! as! TitleAndSelectCell
cell.is_center_select = true
......@@ -109,8 +144,8 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
let model = dls_centers[indexPath.row]
cell.titleLbl.text = model.shop_name
}else{
let model = gys_centers[indexPath.row]
cell.titleLbl.text = model.shop_name
let model = gys_centers[indexPath.row]
cell.titleLbl.text = model.shop_name
}
let str = datas[idx] as! String
if str.count > 0{
......@@ -162,6 +197,10 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
let cell = item as! TitleAndSelectCell
cell.selectBtn.isSelected = false
}
if is_dz {
let model = dz_centers[indexPath.row]
datas.insert(model.shop_name!, at: idx)
}
if title_lbl.text == "新增供应商" {
let model = gys_centers[indexPath.row]
datas.insert(model.shop_name!, at: idx)
......@@ -169,8 +208,10 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
let model = dls_centers[indexPath.row]
datas.insert(model.shop_name!, at: idx)
}else{
let model = centers[indexPath.row]
datas.insert(model.shop_name!, at: idx)
if is_dz == false {
let model = centers[indexPath.row]
datas.insert(model.shop_name!, at: idx)
}
}
datas.remove(at: idx+1)
list_tableview.reloadData()
......@@ -197,6 +238,37 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
d.append(str)
}
}
if is_dz {
print(dz_centers.count)
for i in 0 ..< d.count{
let str = d[i]
dz_centers.forEach { (item) in
if item.shop_name == str {
if i < d.count-1 {
shop_id += StringByInt(number: item.shop_id!) + ","
}else{
shop_id += StringByInt(number: item.shop_id!)
}
}
}
}
if shop_id.count == 0 {
HUD.flash(.label("商店不能为空"), delay: 1.2)
return
}
HUD.flash(.progress)
addDbtShops(["user_token":UserToken as Any,"dbt_id":shop_id as Any]) { (data) in
self.removeFromSuperview()
HUD.hide()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "haveAdd"), object: "dbtShopAdd")
} failture: { (err) in
}
return
}
if title_lbl.text == "新增供应商" {
for i in 0 ..< d.count{
let str = d[i]
......@@ -218,7 +290,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
dbtAddContract(["user_token":UserToken as Any,"shop_id":shop_id as Any]) { (data) in
self.removeFromSuperview()
HUD.hide()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "haveAdd"), object: "fxsAdd")
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "haveAdd"), object: "dbtAdd")
} failture: { (err) in
}
return
......
......@@ -8,9 +8,24 @@
import UIKit
class XY_DZ_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,XY_DZ_GL_VC_Cell_Delegate {
class XY_DZ_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,XY_DZ_GL_VC_Cell_Delegate, GeliAlertViewDelegate {
func sureGeliAlertViewAction(sender: UIButton) {
let model = dataArr[sender.tag]
delDbtContract(["user_token":UserToken as Any,"dbt_id":model.dbt_id as Any]) { (data) in
self.list_view.mj_header?.beginRefreshing()
} failture: { (err) in
}
}
func XY_DZ_GL_VC_Cell_Del(cell: XY_DZ_GL_VC_Cell) {
print("del \(cell.tag)")
let alertView = GeliAlertView(frame: self.view.window!.bounds)
alertView.delegate = self;
alertView.tishiLbl.text = ""
alertView.titileLbl.text = "是否删除店长?"
alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal)
alertView.rightBtn.tag = cell.tag
self.view.window?.addSubview(alertView)
}
var titleStr = ""
......@@ -23,18 +38,41 @@ class XY_DZ_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelegat
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
return dataArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "XY_DZ_GL_VC_Cell") as! XY_DZ_GL_VC_Cell
cell.delegate = self
let model = dataArr[indexPath.row]
cell.tag = indexPath.row
cell.icon.sd_setImage(with:URL(string:SERVERCE_ImageHost + model.shop_img_thumb!), placeholderImage: nil,options:.allowInvalidSSLCertificates)
cell.name.text = model.shop_name
cell.adr.text = model.address
cell.time.text = model.create_time
cell.status.text = model.status
return cell
}
var dz_arr:Array<getDbtList_Data_model> = []
func rightBtnClick() {
print("新增店铺")
getDbtList(["user_token":UserToken as Any]) {[self] (data) in
let model = data as! getDbtList_model
dz_arr.removeAll()
model.data?.forEach({ (item) in
self.dz_arr.append(item)
})
HUD.hide()
let alertView = GLAlertTbAddView(frame: self.view.bounds)
alertView.is_dz = true
alertView.bottom_tableview.isHidden = true
alertView.dz_centers = dz_arr
self.view.addSubview(alertView)
} failture: { (err) in
}
}
@IBOutlet weak var list_view: UITableView!
......@@ -68,14 +106,42 @@ class XY_DZ_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelegat
list_view.mj_header = self.headerMJ
list_view.mj_header?.beginRefreshing()
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
list_view.mj_footer = self.footerMJ
NotificationCenter.default.addObserver(self, selector: #selector(getNoti(noti:)), name: NSNotification.Name(rawValue: "haveAdd"), object: nil)
}
deinit {
/// 移除通知
NotificationCenter.default.removeObserver(self)
}
@objc func getNoti(noti:Notification){
list_view.mj_header?.beginRefreshing()
}
var dataArr:Array<agentDetDbtList_Data_model> = []
@objc func loadData(){
agentDetDbtList(["user_token":UserToken as Any,"keyword":keyword as Any]) {[self] (data) in
let model = data as! agentDetDbtList_model
dataArr.removeAll()
model.data?.forEach({ (item) in
dataArr.append(item)
})
list_view.mj_header?.endRefreshing()
list_view.reloadData()
if model.data?.count == 0 {
list_view.mj_footer?.endRefreshingWithNoMoreData()
}else{
list_view.mj_footer?.endRefreshing()
}
} failture: { [self] (err) in
list_view.mj_header?.endRefreshing()
}
@objc func loadData(){}
}
@objc func loadMoreData(){}
// @objc func loadMoreData(){}
var blackBtnView:UIButton! = nil
......
......@@ -11,6 +11,11 @@ protocol XY_DZ_GL_VC_Cell_Delegate {
func XY_DZ_GL_VC_Cell_Del(cell:XY_DZ_GL_VC_Cell)
}
class XY_DZ_GL_VC_Cell: UITableViewCell {
@IBOutlet weak var icon: UIImageView!
@IBOutlet weak var name: UILabel!
@IBOutlet weak var adr: UILabel!
@IBOutlet weak var time: UILabel!
@IBOutlet weak var status: UILabel!
var delegate:XY_DZ_GL_VC_Cell_Delegate?
@IBAction func del_action(_ sender: Any) {
delegate?.XY_DZ_GL_VC_Cell_Del(cell: self)
......
......@@ -133,6 +133,13 @@
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<color key="backgroundColor" name="app底色"/>
<connections>
<outlet property="adr" destination="kJG-2i-Qv0" id="0ha-5q-lAA"/>
<outlet property="icon" destination="R3Z-qs-eTs" id="fLJ-Nl-a2H"/>
<outlet property="name" destination="j04-yw-sk5" id="Lhs-lY-Oov"/>
<outlet property="status" destination="Qoh-4q-FFw" id="UxE-u0-hho"/>
<outlet property="time" destination="nUE-tC-5wq" id="4xw-SJ-iuR"/>
</connections>
<point key="canvasLocation" x="-197" y="100"/>
</tableViewCell>
</objects>
......
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