Commit 48cb840a authored by lujunye's avatar lujunye

7

parent eb76ff60
......@@ -39,8 +39,8 @@ class queryAgentGoods_data_model: Mappable {
var ceiling_price:String?//最高价格范围
var is_show : Int?//是否上下架:0否 1是
var dbt_price:String?
var commission_val:String?
required init?( map: Map) {
}
......@@ -59,6 +59,8 @@ class queryAgentGoods_data_model: Mappable {
ceiling_price <- map["ceiling_price"]
is_show <- map["is_show"]
commission_val <- map["commission_val"]
dbt_price <- map["dbt_price"]
}
}
//MARK: - 新增代理商下拉框查询
......
......@@ -12,6 +12,15 @@ protocol New_Fx_Cell_Delegate {
func New_Fx_Cell_btnSelect(idx:Int,cell:New_Fx_Cell)
}
class New_Fx_Cell: UITableViewCell {
var is_show = 0 {
didSet{
if is_show == 0 {
btn2.setTitle("商品上架", for: .normal)
}else{
btn2.setTitle("商品下架", for: .normal)
}
}
}
@IBAction func btn_select_action(_ sender: UIButton) {
delegate?.New_Fx_Cell_btnSelect(idx: self.tag, cell: self)
}
......@@ -20,7 +29,17 @@ class New_Fx_Cell: UITableViewCell {
print(sender.tag,self.tag)
delegate?.New_Fx_Cell_btnClick(idx: sender.tag, cell: self)
}
var is_dbt = 0 {
didSet{
if is_dbt == 0 {
btn1.isHidden = true
btn2.isHidden = true
}else{
btn1.isHidden = false
btn2.isHidden = false
}
}
}
@IBOutlet weak var btn1: UIButton!
@IBOutlet weak var btn2: UIButton!
@IBOutlet weak var btn3: UIButton!
......
......@@ -9,24 +9,15 @@
import UIKit
class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDataSource, UISearchBarDelegate, SearchBarViewDelegate,GYS_FX_ProductCellDelegate ,SelectContentViewDelegate,HeaderSelectViewDelegate,DistributorSettingAlertViewDelegate{
class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDataSource, UISearchBarDelegate, SearchBarViewDelegate,SelectContentViewDelegate,HeaderSelectViewDelegate, New_Fx_Cell_Delegate, FXSZ_View_Delegate{
var titleStr = ""
@IBOutlet weak var all_select_btn: UIButton!
@IBAction func select_mode_Action(_ sender: UIButton) {
if selectItem.count == 0 {
return
}
let vc = DistributorSettingAlertView(frame: self.view.bounds)
vc.delegate = self
var dbt_goods_type = 100
func FXSZ_View_submitAction(tag: Int, price: String, commission: String,view:FXSZ_View) {
HUD.flash(.progress, delay: 1.2)
if titleStr.contains("代理") == true {
if selectItem.count > 1 {
vc.is_all_select_mode = is_Edit
}
self.view.addSubview(vc)
return
}
func DistributorSettingAlertViewSubmitAction(tag: Int, operation_type: Int, dbt_price: String, commission_type: Int, commission_per: String, commission_val: String,view:DistributorSettingAlertView) {
HUD.flash(.progress, delay: 1.2)
if is_Edit {
var sku_id = ""
for i in 0 ..< selectItem.count {
......@@ -39,12 +30,12 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
}
let dic = ["user_token":UserToken as Any,
"operation_type":operation_type as Any,
"operation_type":1 as Any,
"sku_id":sku_id as Any,
"dbt_price":dbt_price as Any,
"dbt_price":price as Any,
"commission_type":1 as Any,
"commission_per":commission_per as Any,
"commission_val":commission_val as Any]
"commission_per":0 as Any,
"commission_val":commission as Any]
supSetCommodity(dic) { (data) in
HUD.flash(.label("设置成功~"), delay: 1.2)
view.removeFromSuperview()
......@@ -60,12 +51,12 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
let model = datas[tag]
let dic = ["user_token":UserToken as Any,
"operation_type":operation_type as Any,
"operation_type":1 as Any,
"sku_id":model.sku_id as Any,
"dbt_price":dbt_price as Any,
"commission_type":commission_type as Any,
"commission_per":commission_per as Any,
"commission_val":commission_val as Any]
"dbt_price":price as Any,
"commission_type":1 as Any,
"commission_per":0 as Any,
"commission_val":commission as Any]
supSetCommodity(dic) { (data) in
HUD.flash(.label("设置成功~"), delay: 1.2)
view.removeFromSuperview()
......@@ -74,15 +65,79 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
} failture: { (err) in}
}
func GYS_FX_ProductCellTableViewCellBtnAction(idx: Int) {
let vc = DistributorSettingAlertView(frame: self.view.bounds)
vc.tag = idx
vc.data = datas[idx]
func New_Fx_Cell_btnSelect(idx: Int, cell: New_Fx_Cell) {
let model = datas[idx]
if selectItem.contains(model.sku_id!){
let index = selectItem.firstIndex(of: model.sku_id!)
selectItem.remove(at: index!)
}else{
selectItem.append(model.sku_id!)
}
all_select_btn.isSelected = false
all_select_btn.setTitle(" 全选(已选 " + StringByInt(number: selectItem.count) + " 件商品)", for: .normal)
home_list_tbv.reloadData()
}
func New_Fx_Cell_btnClick(idx: Int, cell: New_Fx_Cell) {
if titleStr.contains("代理") == true {
switch idx {
case 0:
break
case 1:
break
default:
let view = XY_FX_Setting_View(frame: self.view.bounds)
self.view.addSubview(view)
break
}
}else{
switch idx {
case 0:
break
case 1:
break
default:
let data = datas[cell.tag]
let view = FXSZ_View(frame: self.view.bounds)
view.delegate = self
view.FX_Price_Tf.text = data.dbt_price
view.commission_tf.text = data.commission_val
self.view.addSubview(view)
break
}
}
}
@IBOutlet weak var all_select_btn: UIButton!
@IBAction func select_mode_Action(_ sender: UIButton) {
if selectItem.count == 0 {
return
}
let vc = FXSZ_View(frame: self.view.bounds)
vc.delegate = self
if selectItem.count > 1 {
vc.is_all_select_mode = is_Edit
}
self.view.addSubview(vc)
}
// func new_GYS_FX_ProductCellTableViewCellBtnAction(idx: Int) {
// let vc = DistributorSettingAlertView(frame: self.view.bounds)
// vc.tag = idx
// vc.data = datas[idx]
// vc.delegate = self
// self.view.addSubview(vc)
// }
var datas:Array<supGoodsListResDataModel> = []
var dbt_datas:Array<queryAgentGoods_data_model> = []
var selectIndexArr = [0,0]
var showSelectvIndex = 0
......@@ -95,7 +150,12 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
selectIndexArr[showSelectvIndex] = sender
var arr:[String] = []
if showSelectvIndex == 0 {
let arr1 = ["全部商品", "不参与分销商品", "参与分销商品", "提成比例商品", "绝对额比例商品"]
var arr1:Array<String> = []
if titleStr.contains("代理") == true {
arr1 = ["全部商品", "分销商品", "现货商品", "提成比例分销商品", "固定提成分销商品"]
}else{
arr1 = ["全部商品", "不参与分销商品", "参与分销商品", "提成比例商品", "绝对额比例商品"]
}
arr.append(arr1[sender])
}else if showSelectvIndex == 1{
let arr2 = ["上架", "下架"]
......@@ -122,7 +182,11 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
make.top.equalTo(top_btn_bg_view.snp_bottom)
}
showSelectV = showSelectView
if titleStr.contains("代理") == true {
showSelectView.dataArr = ["全部商品", "分销商品", "现货商品", "提成比例分销商品", "固定提成分销商品"]
}else{
showSelectView.dataArr = ["全部商品", "不参与分销商品", "参与分销商品", "提成比例商品", "绝对额比例商品"]
}
showSelectView.selectIndx = selectIndexArr[0]
}
break
......@@ -280,7 +344,9 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
SetTopFrame(view: search_view, height: 44)
navbar.title = titleStr
self.view.addSubview(navbar)
if titleStr.contains("代理") == false {
navbar.rightTitle = "编辑商品"
}
let searchBr = SearchBarView.init()
searchV = searchBr
......@@ -298,7 +364,7 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
initHeaderSelectView()
home_list_tbv.register(UINib(nibName: "GYS_FX_ProductCellTableViewCell", bundle: nil), forCellReuseIdentifier: "GYS_FX_ProductCellTableViewCell")
home_list_tbv.register(UINib(nibName: "New_Fx_Cell", bundle: nil), forCellReuseIdentifier: "New_Fx_Cell")
home_list_tbv.separatorStyle = .none
// Do any additional setup after loading the view.
//下拉刷新相关设置
......@@ -312,93 +378,100 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
//MARK: - tableview_delegate
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if titleStr.contains("代理") == true {
return dbt_datas.count
}
return datas.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let model = datas[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "GYS_FX_ProductCellTableViewCell") as! GYS_FX_ProductCellTableViewCell
cell.submitBtn.setTitle("设置", for: .normal)
cell.submitBtn.setTitleColor(UIColor(named: "按钮背景颜色"), for: .normal)
let cell = tableView.dequeueReusableCell(withIdentifier: "New_Fx_Cell") as! New_Fx_Cell
cell.tag = indexPath.row
cell.delegate = self
if is_Edit{
cell.leftValue.constant = 45
cell.submit_Btn_W.constant = 10
cell.submitBtn.isHidden = true
cell.left_btn.isUserInteractionEnabled = true
cell.select_Img.isHidden = false
cell.select_Img.image = UIImage(named: "daixuan")
cell.leftBtn.isUserInteractionEnabled = true
cell.select_img.isHidden = false
cell.select_img.image = UIImage(named: "daixuan")
}else{
cell.leftValue.constant = 0
cell.leftBtn.isUserInteractionEnabled = false
cell.select_img.isHidden = true
}
if titleStr.contains("代理") == true {
let model = dbt_datas[indexPath.row]
selectItem.forEach { (idx) in
if idx == model.sku_id{
cell.select_Img.image = UIImage(named: "yuxuan")
cell.select_img.image = UIImage(named: "yuxuan")
}
}
}else{
cell.leftValue.constant = 0
cell.submit_Btn_W.constant = 50
cell.submitBtn.isHidden = false
cell.left_btn.isUserInteractionEnabled = false
cell.select_Img.isHidden = true
if model.goods_thumb != nil {
cell.icon.sd_setImage(with:URL(string:SERVERCE_ImageHost + model.goods_thumb!), placeholderImage: nil,options:.allowInvalidSSLCertificates)
}
if model.is_show != nil {
cell.is_show = model.is_show!
}
cell.old_price_line.isHidden = false
cell.new_price_Lbl.isHidden = false
if model.dbt_price == nil {
cell.old_price_line.isHidden = true
cell.new_price_Lbl.text = ""
if model.price_type == nil {
cell.is_dbt = 0
cell.price.isHidden = true
}else{
cell.is_dbt = 1
if model.dbt_price == nil && model.commission_val == nil && model.supply_price == nil && model.floor_price == nil && model.ceiling_price == nil {
cell.price.isHidden = true
}else{
cell.new_price_Lbl.text = "¥" + model.dbt_price!
cell.price.isHidden = false
if model.price_type == 0 {
cell.price.text = "分销价: ¥\(model.dbt_price!) (固定提成: \(model.commission_val!))"
}else{
cell.price.text = "供货价: ¥\(model.supply_price!) (加价范围: \(model.floor_price!)-\(model.ceiling_price!)"
}
}
}
cell.old_price_Lbl.text = "¥" + model.price!
if model.commission_type == 1{
cell.FX_Percent_Lbl.isHidden = false
cell.FX_Percent_Lbl.text = "分销(" + StringByInt(number: model.commission_per!) + "%)"
}else if model.commission_type == 2{
cell.FX_Percent_Lbl.isHidden = false
cell.FX_Percent_Lbl.text = "分销(" + model.commission_val! + "元)"
cell.spec.text = "单价: ¥" + model.price!
cell.name.text = model.goods_name
if model.inventory != nil {
cell.spec.text! += " " + "库存: \(model.inventory!)"
}else{
cell.FX_Percent_Lbl.isHidden = true
cell.spec.text! += " " + "库存: -"
}
}else{
let model = datas[indexPath.row]
selectItem.forEach { (idx) in
if idx == model.sku_id{
cell.select_img.image = UIImage(named: "yuxuan")
}
cell.title_Lbl.text = model.goods_name
cell.sell_total_Lbl.text = "销量:-"
if model.dbt_sale != nil {
cell.sell_total_Lbl.text = "销量:" + StringByInt(number: model.dbt_sale!)
}
cell.store_lbl.text = "库存:-"
if model.dbt_price == nil && model.commission_val == nil {
cell.price.isHidden = true
}else{
cell.price.isHidden = false
cell.price.text = "分销价: ¥\(model.dbt_price!) (固定提成: \(model.commission_val!))"
}
cell.is_dbt = model.is_dbt!
// cell.is_show = model.
cell.spec.text = "单价: ¥" + model.price!
cell.name.text = model.goods_name
if model.inventory != nil {
cell.store_lbl.text = "库存:" + StringByInt(number: model.inventory!)
cell.spec.text! += " " + "库存: \(model.inventory!)"
}else{
cell.spec.text! += " " + "库存: -"
}
if model.goods_thumb != nil {
cell.item_Icon_Img.sd_setImage(with:URL(string:SERVERCE_ImageHost + model.goods_thumb!))
cell.icon.sd_setImage(with:URL(string:SERVERCE_ImageHost + model.goods_thumb!), placeholderImage: nil,options:.allowInvalidSSLCertificates)
}
cell.color_lbl.isHidden = cell.FX_Percent_Lbl.isHidden
cell.color_lbl.text = cell.FX_Percent_Lbl.text
return cell
}
var selectItem:Array<Int> = []
func GYS_FX_ProductCellTableViewCellSelect(idx: Int) {
let model = datas[idx]
if selectItem.contains(model.sku_id!){
let index = selectItem.firstIndex(of: model.sku_id!)
selectItem.remove(at: index!)
}else{
selectItem.append(model.sku_id!)
}
all_select_btn.isSelected = false
all_select_btn.setTitle(" 全选(已选 " + StringByInt(number: selectItem.count) + " 件商品)", for: .normal)
home_list_tbv.reloadData()
return cell
}
var selectItem:Array<Int> = []
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 125
return 145
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......@@ -412,16 +485,57 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
//MARK:--加载数据
@objc func loadData(){
print("加载数据")
page = 1
isUpData = true
goods_type = selectIndexArr.first! + 1
if selectIndexArr.last == 1 {
is_show = 0
}else{
is_show = 1
}
if titleStr.contains("代理"){
dbt_goods_type = selectIndexArr.first!
if dbt_goods_type == 0 {
dbt_goods_type = 100
}
let dict = ["user_token":UserToken as Any,"keyword":keyword as Any,"page":page as Any,"dbt_goods_type":dbt_goods_type as Any,"is_show":is_show as Any]
queryAgentGoods(dict){ (data) in
let model = data as! queryAgentGoods_model
self.dbt_datas.removeAll()
self.count_lbl.text = "-"
if model.data!.count > 0 || model.data?.count != nil{
self.count_lbl.text = StringByInt(number: model.data!.count)
}
model.data?.forEach({ (item) in
self.dbt_datas.append(item)
})
self.home_list_tbv.reloadData()
self.home_list_tbv?.mj_header?.endRefreshing()
self.page = 2
if self.selectItem.count > 0 {
self.selectItem.removeAll()
self.all_select_btn.isSelected = false
self.all_select_btn.setTitle(" 全选(已选 " + StringByInt(number: self.selectItem.count) + " 件商品)", for: .normal)
}
if model.data?.count == 0 {
self.home_list_tbv?.mj_footer?.endRefreshingWithNoMoreData()
self.all_select_btn.isUserInteractionEnabled = false
}else{
self.home_list_tbv?.mj_footer?.endRefreshing()
self.all_select_btn.isUserInteractionEnabled = true
}
} failture: { (err) in
self.home_list_tbv?.mj_header?.endRefreshing()
}
return
}
goods_type = selectIndexArr.first! + 1
let dic = ["user_token":UserToken as Any,"keyword":keyword as Any,"page":page as Any,"goods_type":goods_type as Any,"is_show":is_show as Any]
supGoodsList(dic) { (data) in
......@@ -455,9 +569,41 @@ class FX_Product_GuanLiVC: BaseViewController,UITableViewDelegate,UITableViewDat
self.home_list_tbv?.mj_header?.endRefreshing()
}
}
//MARK:--加载更多数据
@objc func loadMoreData(){
print("加载更多数据")
if titleStr.contains("代理"){
let dict = ["user_token":UserToken as Any,"keyword":keyword as Any,"page":page as Any,"dbt_goods_type":dbt_goods_type as Any,"is_show":is_show as Any]
queryAgentGoods(dict){ (data) in
let model = data as! queryAgentGoods_model
if model.data?.count == 0 {
self.home_list_tbv?.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.page += 1
model.data?.forEach({ (item) in
self.dbt_datas.append(item)
})
if self.all_select_btn.isSelected {
self.selectItem.removeAll()
self.dbt_datas.forEach { (model) in
self.selectItem.append(model.sku_id!)
}
self.all_select_btn.setTitle(" 全选(已选 " + StringByInt(number: self.selectItem.count) + " 件商品)", for: .selected)
}
self.home_list_tbv.reloadData()
self.home_list_tbv?.mj_footer?.endRefreshing()
}
} failture: { (err) in
self.home_list_tbv?.mj_header?.endRefreshing()
}
return
}
let dic = ["user_token":UserToken as Any,"keyword":keyword as Any,"page":page as Any,"goods_type":goods_type as Any,"is_show":is_show as Any]
supGoodsList(dic, success: { (data) in
......
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