Просмотр исходного кода

1.修改NPD Portfolio Sort视图,增加Category项,并且修改Sort使之随数据变化。

Pen Li 9 лет назад
Родитель
Сommit
47e1904a7d

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 10 - 5
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -11825,7 +11825,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     NSString *orderBy = @"";
     NSString *orderBy = @"";
     switch (sort) {
     switch (sort) {
         case 0:{
         case 0:{
-            orderBy = @"modify_time desc";
+            orderBy = @"p.modify_time desc";
         }
         }
             break;
             break;
         case 1:{
         case 1:{
@@ -11833,24 +11833,29 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         }
         }
             break;
             break;
         case 2:{
         case 2:{
-            orderBy = @"name asc";
+            orderBy = @"p.name asc";
         }
         }
             break;
             break;
         case 3:{
         case 3:{
-            orderBy = @"name desc";
+            orderBy = @"p.name desc";
         }
         }
             break;
             break;
         case 4:{
         case 4:{
-            orderBy = @"description asc";
+            orderBy = @"p.description asc";
         }
         }
             break;
             break;
+        case 5: {
+            orderBy = @"m.default_category asc";
+        }
             
             
         default:
         default:
             break;
             break;
     }
     }
     
     
     
     
-    NSString *sql = [NSString stringWithFormat:@"select p.product_id,p.name,p.description,ifnull(p.sheet_price,'null'),p.sheet_discount,ifnull(p.available_qty,'null'),p.percentage,p.item_id,p.fashion_id,i.url,p.line_note,p.percent from offline_portfolio as p left join model_image as i on i.product_id = p.product_id where i.type = 1 and (p.is_delete is null or  p.is_delete = 0) group by  p.product_id order by %@ limit %d offset %d;",orderBy,limit,offset];
+//    NSString *sql = [NSString stringWithFormat:@"select p.product_id,p.name,p.description,ifnull(p.sheet_price,'null'),p.sheet_discount,ifnull(p.available_qty,'null'),p.percentage,p.item_id,p.fashion_id,i.url,p.line_note,p.percent from offline_portfolio as p left join model_image as i on i.product_id = p.product_id where i.type = 1 and (p.is_delete is null or  p.is_delete = 0) group by  p.product_id order by %@ limit %d offset %d;",orderBy,limit,offset];
+
+    NSString *sql = [NSString stringWithFormat:@"select * from (select p.product_id,p.name,p.description,ifnull(p.sheet_price,'null'),p.sheet_discount,ifnull(p.available_qty,'null'),p.percentage,p.item_id,p.fashion_id,i.url,p.line_note,p.percent,p.modify_time from offline_portfolio as p left join model_image as i on i.product_id = p.product_id where i.type = 1 and (p.is_delete is null or  p.is_delete = 0) group by  p.product_id limit %d offset %d) as p left join product as m on p.product_id = m.product_id order by %@;",limit,offset,orderBy];
     
     
     __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     
     

+ 8 - 1
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m

@@ -1677,7 +1677,14 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     if (!_sortItemController) {
     if (!_sortItemController) {
         _sortItemController = [[SortItemViewController alloc] initWithTableOrigin:CGPointMake(40, 40)];
         _sortItemController = [[SortItemViewController alloc] initWithTableOrigin:CGPointMake(40, 40)];
         _sortItemController.sortIndex = self.sortIndex;
         _sortItemController.sortIndex = self.sortIndex;
-
+        _sortItemController.sortData = @[
+                                         @{@"title":@"Last",@"icon":@"TX_18"},
+                                         @{@"title":@"First",@"icon":@"TS_18"},
+                                         @{@"title":@"Item number a-z",@"icon":@"IX_18"},
+                                         @{@"title":@"Item number z-a",@"icon":@"IS_18"},
+                                         @{@"title":@"Description",@"icon":@"DX_18"},
+                                         @{@"title":@"Category",@"icon":@""}
+                                         ];
         __weak typeof(self) weakSelf = self;
         __weak typeof(self) weakSelf = self;
         _sortItemController.sortBlock = ^(int sort){
         _sortItemController.sortBlock = ^(int sort){
             weakSelf.sortIndex = sort;
             weakSelf.sortIndex = sort;

+ 7 - 1
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -1181,7 +1181,13 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     if (!_sortItemController) {
     if (!_sortItemController) {
         _sortItemController = [[SortItemViewController alloc] initWithTableOrigin:CGPointMake(40, 40)];
         _sortItemController = [[SortItemViewController alloc] initWithTableOrigin:CGPointMake(40, 40)];
         _sortItemController.sortIndex = self.sortIndex;
         _sortItemController.sortIndex = self.sortIndex;
-
+        _sortItemController.sortData = @[
+                                         @{@"title":@"Last",@"icon":@"TX_18"},
+                                         @{@"title":@"First",@"icon":@"TS_18"},
+                                         @{@"title":@"Item number a-z",@"icon":@"IX_18"},
+                                         @{@"title":@"Item number z-a",@"icon":@"IS_18"},
+                                         @{@"title":@"Description",@"icon":@"DX_18"},
+                                         ];
         __weak typeof(self) weakSelf = self;
         __weak typeof(self) weakSelf = self;
         _sortItemController.sortBlock = ^(int sort){
         _sortItemController.sortBlock = ^(int sort){
             weakSelf.sortIndex = sort;
             weakSelf.sortIndex = sort;

+ 2 - 0
RedAnt ERP Mobile/common/sort/SortItemCell.h

@@ -20,4 +20,6 @@
 
 
 @property (nonatomic,assign) NSInteger sortIndex;
 @property (nonatomic,assign) NSInteger sortIndex;
 
 
+@property (nonatomic,strong) NSDictionary *sortItem;
+
 @end
 @end

+ 33 - 26
RedAnt ERP Mobile/common/sort/SortItemCell.m

@@ -89,32 +89,39 @@
 - (void)setSortIndex:(NSInteger)sortIndex {
 - (void)setSortIndex:(NSInteger)sortIndex {
     _sortIndex = sortIndex;
     _sortIndex = sortIndex;
     
     
-    NSString *selectedImageName = @"";
-    switch (sortIndex) {
-        case 0:{
-            selectedImageName = @"TX_18";
-        }
-            break;
-        case 1:{
-            selectedImageName = @"TS_18";
-        }
-            break;
-        case 2:{
-            selectedImageName = @"IX_18";
-        }
-            break;
-        case 3:{
-            selectedImageName = @"IS_18";
-        }
-            break;
-        case 4:{
-            selectedImageName = @"DX_18";
-        }
-            break;
-            
-        default:
-            break;
-    }
+//    NSString *selectedImageName = @"";
+//    switch (sortIndex) {
+//        case 0:{
+//            selectedImageName = @"TX_18";
+//        }
+//            break;
+//        case 1:{
+//            selectedImageName = @"TS_18";
+//        }
+//            break;
+//        case 2:{
+//            selectedImageName = @"IX_18";
+//        }
+//            break;
+//        case 3:{
+//            selectedImageName = @"IS_18";
+//        }
+//            break;
+//        case 4:{
+//            selectedImageName = @"DX_18";
+//        }
+//            break;
+//            
+//        default:
+//            break;
+//    }
+//    [self.selectedView setImage:[UIImage imageNamed:selectedImageName] forState:UIControlStateSelected];
+}
+
+- (void)setSortItem:(NSDictionary *)sortItem {
+    NSString *title = [sortItem objectForKey:@"title"];
+    NSString *selectedImageName = [sortItem objectForKey:@"icon"];
+    self.sortTitle = title;
     [self.selectedView setImage:[UIImage imageNamed:selectedImageName] forState:UIControlStateSelected];
     [self.selectedView setImage:[UIImage imageNamed:selectedImageName] forState:UIControlStateSelected];
 }
 }
 
 

+ 2 - 0
RedAnt ERP Mobile/common/sort/SortItemViewController.h

@@ -16,6 +16,8 @@ typedef void(^sortRequestBlock)(int sort);
 
 
 @property (nonatomic,assign) int sortIndex;
 @property (nonatomic,assign) int sortIndex;
 
 
+@property (nonatomic,strong) NSArray <NSDictionary *> *sortData;
+
 - (instancetype)initWithTableOrigin:(CGPoint)origin;
 - (instancetype)initWithTableOrigin:(CGPoint)origin;
 
 
 @end
 @end

+ 39 - 28
RedAnt ERP Mobile/common/sort/SortItemViewController.m

@@ -32,7 +32,13 @@
 - (void)viewDidLoad {
 - (void)viewDidLoad {
     [super viewDidLoad];
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     // Do any additional setup after loading the view.
-    tableSize = CGSizeMake(180, 200);
+//    tableSize = CGSizeMake(180, 200);
+    
+    tableSize = CGSizeZero;
+    if (self.sortData.count) {
+        tableSize = CGSizeMake(180, 40 * self.sortData.count);
+    }
+    
     self.view.backgroundColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.5];
     self.view.backgroundColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.5];
     
     
     [self.view addSubview:self.tableBackgroundView];
     [self.view addSubview:self.tableBackgroundView];
@@ -75,7 +81,7 @@
 #pragma mark data source
 #pragma mark data source
 
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    return 5;
+    return self.sortData.count;
 }
 }
 
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -85,31 +91,36 @@
     }
     }
 //    cell.selectionStyle = UITableViewCellSelectionStyleNone;
 //    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     
     
-    switch (indexPath.row) {
-        case 0:{
-            cell.sortTitle = @"Last";
-        }
-            break;
-        case 1:{
-            cell.sortTitle = @"First";
-        }
-            break;
-        case 2:{
-            cell.sortTitle = @"Item number a-z";
-        }
-            break;
-        case 3:{
-            cell.sortTitle = @"Item number z-a";
-        }
-            break;
-        case 4:{
-            cell.sortTitle = @"Description";
-        }
-            break;
-            
-        default:
-            break;
-    }
+//    switch (indexPath.row) {
+//        case 0:{
+//            cell.sortTitle = @"Last";
+//        }
+//            break;
+//        case 1:{
+//            cell.sortTitle = @"First";
+//        }
+//            break;
+//        case 2:{
+//            cell.sortTitle = @"Item number a-z";
+//        }
+//            break;
+//        case 3:{
+//            cell.sortTitle = @"Item number z-a";
+//        }
+//            break;
+//        case 4:{
+//            cell.sortTitle = @"Description";
+//        }
+//            break;
+//            
+//        default:
+//            break;
+//    }
+
+    
+    NSDictionary *sortItem = [self.sortData objectAtIndex:indexPath.row];
+    cell.sortItem = sortItem;
+    
     cell.sortIndex = indexPath.row;
     cell.sortIndex = indexPath.row;
     
     
 //    if (self.sortIndex == indexPath.row) {
 //    if (self.sortIndex == indexPath.row) {
@@ -140,7 +151,7 @@
 //        SortItemCell *oldCell = [tableView cellForRowAtIndexPath:oldIndexPath];
 //        SortItemCell *oldCell = [tableView cellForRowAtIndexPath:oldIndexPath];
 //        oldCell.selectedSort = NO;
 //        oldCell.selectedSort = NO;
         
         
-        self.sortIndex = indexPath.row;
+        self.sortIndex = (int)indexPath.row;
         cell.selectedSort = YES;
         cell.selectedSort = YES;
         
         
         if (self.sortBlock) {
         if (self.sortBlock) {