Commit 38c92318 authored by Sandy's avatar Sandy

佣金排序bug fix

parent ed13299c
......@@ -9,7 +9,9 @@
#import <UIKit/UIKit.h>
@interface CommodityManagementTopView : UIView
@property (nonatomic, strong) NSMutableArray *arrDatas;
@property (nonatomic, assign) BOOL isLeft;//判断排序判断选中了左边还是右边
@property (nonatomic, assign) NSInteger row;//判断排序判断选中了哪一行 传到下一个页面
@property (weak, nonatomic) IBOutlet UIButton *buttonAddCommodity;
@property (weak, nonatomic) IBOutlet UIButton *buttonManageCommodity;
@end
......@@ -21,37 +21,13 @@
- (void)awakeFromNib {
self.buttonAdd.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.buttonManagement.imageView.contentMode = UIViewContentModeScaleAspectFit;
}
- (IBAction)managementAct:(id)sender {
ManagementViewController *manageVC = [[ManagementViewController alloc] init];
[self hideSortView];
manageVC.isShowNavigationBar = YES;
manageVC.arrCellData = [self.arrDatas mutableCopy];
manageVC.isLeft = self.isLeft;
manageVC.row = self.row;
[[self viewController] PushViewController:manageVC animated:YES];
CLog(@"m");
}
- (IBAction)addAct:(id)sender {
[self hideSortView];
AddCommodityViewController *addVC = [[AddCommodityViewController alloc] init];
addVC.hidesBottomBarWhenPushed = YES;
addVC.isShowNavigationBar = YES;
[[self viewController].navigationController pushViewController:addVC animated:YES];
CLog(@"a");
}
- (void)hideSortView {
CommodityManagementViewController *commodityVC = (CommodityManagementViewController *)[self viewController];
[commodityVC.sorView hide];
self.buttonAddCommodity.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.buttonManageCommodity.imageView.contentMode = UIViewContentModeScaleAspectFit;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
......
......@@ -17,19 +17,13 @@
<state key="normal" title="添加商品" image="commodityManage_add">
<color key="titleColor" red="0.066666666669999999" green="0.066666666669999999" blue="0.066666666669999999" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="addAct:" destination="-1" eventType="touchUpInside" id="aJF-tW-db7"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uY6-mf-dlQ">
<rect key="frame" x="160" y="10" width="160" height="110"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<state key="normal" title="商品管理" image="commodityManage_Manager">
<state key="normal" title="批量管理" image="commodityManage_Manager">
<color key="titleColor" red="0.066666666669999999" green="0.066666666669999999" blue="0.066666666669999999" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="managementAct:" destination="iN0-l3-epB" eventType="touchUpInside" id="PVf-zg-LlH"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
......@@ -46,8 +40,8 @@
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="buttonAdd" destination="y9I-zx-duH" id="l6u-3V-Nwc"/>
<outlet property="buttonManagement" destination="uY6-mf-dlQ" id="Msy-US-Iyp"/>
<outlet property="buttonAddCommodity" destination="y9I-zx-duH" id="2j0-Vu-t3o"/>
<outlet property="buttonManageCommodity" destination="uY6-mf-dlQ" id="s4Q-Bm-ivS"/>
</connections>
<point key="canvasLocation" x="300" y="-26"/>
</view>
......
......@@ -28,7 +28,7 @@
self.labelTitle.text = model.name;
self.labelPrice.text = [NSString stringWithFormat:@"¥%.0f",model.price];
self.labelBrokerageRate.text = [NSString stringWithFormat:@"%.2f",model.commission];
self.labelSaleNumber.text = [NSString stringWithFormat:@"销量:%.0f",model.salesVolume];
}
......
......@@ -16,6 +16,9 @@
#import "Conditions.h"
#import "CommodityDetailViewController.h"
#import "JavenSortView.h"
#import "AddCommodityViewController.h"
#define kCellID @"commodityCell"
#define kPageSize @999
#define kCellId @"CommodityTableViewCell.h"
......@@ -34,6 +37,9 @@
@property (nonatomic, strong) UIView *titleView;
@property (nonatomic, strong) UIView *searchTitleView;
@property (nonatomic, assign) BOOL isLeft;//判断排序判断选中了左边还是右边
@property (nonatomic, assign) NSInteger row;//判断排序判断选中了哪一行
......@@ -51,7 +57,9 @@
[self setUpNavigationbar];
[self setUpViews];
[self setUpSearchBar];
[self setUpData];
[self.topView.buttonAddCommodity addTarget:self action:@selector(addCommodityAction) forControlEvents:UIControlEventTouchUpInside];
[self.topView.buttonManageCommodity addTarget:self action:@selector(manageManentAction) forControlEvents:UIControlEventTouchUpInside];
}
- (void)viewWillAppear:(BOOL)animated {
......@@ -77,10 +85,8 @@
- (void)cancelSearchAction {
self.searchText = @"";
self.condition = @"shop online only";
self.searchBar.width = 0;
self.searchBar.centerX = (kWidth - 100) / 2;
self.navigationItem.titleView = self.titleView;
self.navigationItem.rightBarButtonItem = self.rightItem;
}
......@@ -89,7 +95,6 @@
- (void)setUpNavigationbar {
self.navigationItem.title = @"商品管理";
self.titleView = self.navigationItem.titleView;
self.rightItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"searchIcon"] style:UIBarButtonItemStyleDone target:self action:@selector(searchAct)];
self.rightItem.tintColor = kTextColorDarkGray;
self.navigationItem.rightBarButtonItem = self.rightItem;
......@@ -102,8 +107,8 @@
//设置现在默认选中的排序方式
[self.sorView defaultSelectISLeft:YES row:0];
self.topView.isLeft = YES;
self.topView.row = 0;
// self.topView.isLeft = YES;
// self.topView.row = 0;
WS(weakSelf)
self.sorView.leftTableSelect = ^(NSInteger row){
......@@ -124,8 +129,8 @@
- (void)leftSelectCodtition:(NSInteger)row {
self.topView.isLeft = YES;
self.topView.row = row;
self.isLeft = YES;
self.row = row;
switch (row) {
case 0:
......@@ -155,8 +160,8 @@
}
- (void)rightSelectCondition:(NSInteger)row {
self.topView.isLeft = NO;
self.topView.row = row;
self.isLeft = NO;
self.row = row;
switch (row) {
......@@ -174,7 +179,7 @@
break;
case 2:
{
self.field = @"brokerageRate";
self.field = @"commission";
self.direction = @"desc";
}
break;
......@@ -255,6 +260,33 @@
self.navigationItem.rightBarButtonItem = cancelSearch;
}
//添加商品
- (void)addCommodityAction {
[self.sorView hide];
AddCommodityViewController *addVC = [[AddCommodityViewController alloc] init];
addVC.hidesBottomBarWhenPushed = YES;
addVC.isShowNavigationBar = YES;
[self.navigationController pushViewController:addVC animated:YES];
CLog(@"a");
}
//商品管理
- (void)manageManentAction {
ManagementViewController *manageVC = [[ManagementViewController alloc] init];
[self.sorView hide];
manageVC.isShowNavigationBar = YES;
manageVC.arrCellData = [self.arrItemDatas mutableCopy];
manageVC.isLeft = self.isLeft;
manageVC.row = self.row;
[self.navigationController pushViewController:manageVC animated:YES];
CLog(@"m");
}
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController.navigationBar endEditing:YES];
......@@ -284,7 +316,7 @@
{
CommodityDetailViewController *detailVC = [[CommodityDetailViewController alloc] init];
detailVC.model = self.arrItemDatas[indexPath.row];
CommodityTableViewCell *cell = (CommodityTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
detailVC.image = cell.imgView.image;
[self.navigationController pushViewController:detailVC animated:YES];
......@@ -320,7 +352,8 @@
if (!_topView) {
_topView = [CommodityManagementTopView viewWithNibName:@"CommodityManagementTopView"];
_topView.frame = CGRectMake(0, 0, kWidth, 64 + 64);
_topView.arrDatas = self.arrItemDatas;
// _topView.arrDatas = self.arrItemDatas;
}
return _topView;
}
......
......@@ -15,5 +15,7 @@
@property (nonatomic, assign) BOOL isLeft;//判断排序判断选中了左边还是右边
@property (nonatomic, assign) NSInteger row;//判断排序判断选中了哪一行
@property (nonatomic, copy) NSString *condition;
@property (nonatomic, copy) NSString *field; //排序的字段
@property (nonatomic, copy) NSString *direction; //排序的顺序 升序或降序
@end
......@@ -20,8 +20,7 @@
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) CommodityMutipleSelectBottomView *bottomView;
@property (nonatomic, assign) NSInteger page;
@property (nonatomic, copy) NSString *field; //排序的字段
@property (nonatomic, copy) NSString *direction; //排序的顺序 升序或降序
@property (nonatomic, strong) NSMutableArray *deleteArr;
@property (nonatomic, strong) NSMutableDictionary *dicSelectIds;
@end
......@@ -119,7 +118,7 @@
break;
case 2:
{
self.field = @"brokerageRate";
self.field = @"commission";
self.direction = @"desc";
}
break;
......@@ -141,7 +140,7 @@
//改变排序条件之后重新请求数据
- (void)resetReloadData {
[self.sorView defaultSelectISLeft:YES row:0];
//[self.sorView defaultSelectISLeft:YES row:0];
[self.arrCellData removeAllObjects];
[self setUpData];
......@@ -183,30 +182,28 @@
#pragma mark =========== action ===========
- (void)selectAll:(UIButton *)btn {//tag 等于1表示全选
if (btn.tag == 0) {
[self.bottomView selectAll];
- (void)selectAll:(UIButton *)btn {
if (self.dicSelectIds.allKeys.count == self.arrCellData.count) { //全选
[self.bottomView deselectAll];
for (int i = 0; i < self.arrCellData.count; i ++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
CommotityListModel *model = self.arrCellData[indexPath.row];
[self.dicSelectIds setValue:@"" forKey: model.uuid];
[self.dicSelectIds removeObjectForKey:model.uuid];
}
btn.tag = 1;
}else{
[self.bottomView deselectAll];
[self.bottomView selectAll];
for (int i = 0; i < self.arrCellData.count; i ++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];
CommotityListModel *model = self.arrCellData[indexPath.row];
[self.dicSelectIds removeObjectForKey:model.uuid];
[self.dicSelectIds setValue:@"" forKey: model.uuid];
}
btn.tag = 0;
}
}
......@@ -242,6 +239,8 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CommotityListModel *model = self.arrCellData[indexPath.row];
[self.dicSelectIds setValue:@"" forKey: model.uuid];
[self checkIsAllSelect];
CLog(@"%@",self.dicSelectIds.allKeys);
}
......@@ -249,6 +248,7 @@
CommotityListModel *model = self.arrCellData[indexPath.row];
[self.dicSelectIds removeObjectForKey:model.uuid];
CLog(@"%@",self.dicSelectIds.allKeys);
[self checkIsAllSelect];
}
......@@ -281,41 +281,65 @@
}
NSArray *arrGoodsUuid = self.dicSelectIds.allKeys;
NSDictionary *params = @{@"operCtx" : @{@"time" : [[NSDate date] timeStampNumber],
@"domain" : [UserInfo shareInstance].domain,
@"operator" : @{@"id" : [UserInfo shareInstance].uuid,
@"fullName" : [UserInfo shareInstance].name}},
@"shopUuid" : [UserInfo shareInstance].shop.uuid,
@"listGoodsUuid" : arrGoodsUuid};
WS(weakSelf)
[[HTTPCilent shareCilent] POST:questUrl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
if (arrGoodsUuid.count == 0) {
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:weakSelf.view];
[self.view addSubview:hud];
[MBProgressHUD Javen_showError:@"请至少选择一件商品" onView:self.view delay:0.6 complete:nil];
if ([responseObject[@"code"] isEqualToNumber:@0]) {
UIImage *image = [[UIImage imageNamed:@"Checkmark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.tintColor = kSysWhite;
hud.customView = imageView;
hud.mode = MBProgressHUDModeCustomView;
hud.labelText = @"操作成功!";
[weakSelf.dicSelectIds removeAllObjects];
[weakSelf resetReloadData];
}else{
hud.mode = MBProgressHUDModeText;
hud.labelText = @"未知错误!";
}
[hud show:YES];
[hud hide:YES afterDelay:0.7];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
}];
}else{
NSDictionary *params = @{@"operCtx" : @{@"time" : [[NSDate date] timeStampNumber],
@"domain" : [UserInfo shareInstance].domain,
@"operator" : @{@"id" : [UserInfo shareInstance].uuid,
@"fullName" : [UserInfo shareInstance].name}},
@"shopUuid" : [UserInfo shareInstance].shop.uuid,
@"listGoodsUuid" : arrGoodsUuid};
WS(weakSelf)
[[HTTPCilent shareCilent] POST:questUrl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
[weakSelf unparseData:responseObject];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
}];
}
}
//解析数据
- (void)unparseData:(NSDictionary *)responseObject {
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:hud];
if ([responseObject[@"code"] isEqualToNumber:@0]) {
UIImage *image = [[UIImage imageNamed:@"Checkmark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.tintColor = kSysWhite;
hud.customView = imageView;
hud.mode = MBProgressHUDModeCustomView;
hud.labelText = @"操作成功!";
[self.dicSelectIds removeAllObjects];
[self resetReloadData];
}else{
hud.mode = MBProgressHUDModeText;
hud.labelText = @"未知错误!";
}
[hud show:YES];
[hud hide:YES afterDelay:0.7];
}
//检查是否全部选中了
- (void)checkIsAllSelect {
CLog(@"%lu %lu", (unsigned long)self.dicSelectIds.allKeys.count, (unsigned long)self.arrCellData.count);
if (self.dicSelectIds.allKeys.count == self.arrCellData.count) {
[self.bottomView selectAll];
}else{
[self.bottomView deselectAll];
}
}
- (void)popAction {
[super popAction];
[self.sorView hide];
......
......@@ -131,7 +131,7 @@
{
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view];
[view addSubview:hud];
hud.labelText = @"修改中";
hud.labelText = message;
[hud show:YES];
return hud;
}
......
......@@ -172,6 +172,7 @@
space = @"left";
[self leftAction:nil];
[self setLeftBtnTitle:self.arrTitles[indexPath.row]];
CLog(@"%@", self.arrTitles[indexPath.row]);
[self.leftBtn setTitleColor:kCustomGreenColor forState:UIControlStateNormal];
[self.rightBtn setTitleColor:kTextColorBlack forState:UIControlStateNormal];
self.leftTableSelect(indexPath.row);
......
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