Przeglądaj źródła

完成店铺登陆权限设置。

Pen Li 9 lat temu
rodzic
commit
bad3e1597f

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


+ 27 - 1
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -25,6 +25,7 @@
 #import "SortItemViewController.h"
 #import "SortButton.h"
 #import "NotificationNameCenter.h"
+#import "Singleton.h"
 
 #define ALERT_FREE 1024
 #define ALERT_DEL 1025
@@ -36,6 +37,8 @@
 @property (nonatomic,strong) SortItemViewController *sortItemController;
 @property (nonatomic,assign) int sortIndex;
 @property (nonatomic,strong) SortButton *sortButton;
+@property (strong, nonatomic) IBOutlet UIButton *placeOrderButton;
+@property (strong, nonatomic) IBOutlet UIButton *cancelOrderButton;
 
 @end
 
@@ -454,6 +457,21 @@
     
     [super viewWillAppear:animated];
     
+    // Shop 权限检查
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        if (![Singleton sharedInstance].permissions_edit_order) {
+            
+            CGRect frame0 = self.cancelOrderButton.frame;
+            CGRect frame1 = self.placeOrderButton.frame;
+            
+            CGFloat x = CGRectGetMaxX(frame1) - frame0.size.width;
+            frame0.origin.x = x;
+            self.cancelOrderButton.frame = frame0;
+            [self.placeOrderButton removeFromSuperview];
+        }
+    }
+    
 //    [self reload_data]; // 视图没及时刷新
     
     //    UIApplication * app = [UIApplication sharedApplication];
@@ -644,6 +662,9 @@
     self.toolpanel.layer.shadowOpacity = 0.5;
     self.toolpanel.layer.shadowRadius = 2.0;
     
+    
+    
+    
     //  CGRect frame =self.orderInfoTableView.tableHeaderView.frame;
     //    self.orderInfoTableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.orderInfoTableView.bounds.size.width, 0.0001)];
     //    self.orderInfoTableView.tableHeaderView.backgroundColor = [UIColor redColor];
@@ -685,7 +706,12 @@
 
 -(void)placeOrder
 {
-    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        if (![Singleton sharedInstance].permissions_edit_order) {
+            return;
+        }
+    }
     
 //    NSMutableArray* checked = [[NSMutableArray alloc] init];
     

+ 41 - 58
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -23,10 +23,51 @@
 {
     [super viewWillAppear:animated];
     
+    // 检查权限
+    NSMutableArray * items = [[NSMutableArray alloc]init];
+    
+    
+    UIBarButtonItem *savebtn = nil;
+    
+    savebtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                               style:UIBarButtonItemStylePlain
+                                              target:self
+                                              action:@selector(onSaveClick:)];
+    
     
+    self.btnSubmitOrder = nil;
+    self.btnSubmitOrder =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                          style:UIBarButtonItemStylePlain
+                                                         target:self
+                                                         action:@selector(onCommitOrderClick:)];
+    
+    
+    UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
+    fixedItem.width = 20.0f;
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
     
+    //  if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+    {
+        [items addObject:savebtn];
+        
+        [items addObject:fixedItem];
+    }
+    
+    if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        if ([Singleton sharedInstance].permissions_submit_order) {
+            [items addObject:self.btnSubmitOrder];
+        }
+    } else {
+        [items addObject:self.btnSubmitOrder];
+    }
+    
+    
+    //        [items addObject:item2];
+    self.navigationItem.rightBarButtonItems=items;
+    
+    
+    
     if(appDelegate.can_submit_order)
     {
         
@@ -71,64 +112,6 @@
     
     self.navigationItem.leftBarButtonItem = closeButton;
     
-    
-    
-    
-    NSMutableArray * items = [[NSMutableArray alloc]init];
-    
-    
-    UIBarButtonItem *savebtn = nil;//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSaveClick:)];
-    
-    savebtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
-                                               style:UIBarButtonItemStylePlain
-                                              target:self
-                                              action:@selector(onSaveClick:)];
-    
-    
-    self.btnSubmitOrder = nil;
-    self.btnSubmitOrder =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
-                                                          style:UIBarButtonItemStylePlain
-                                                         target:self
-                                                         action:@selector(onCommitOrderClick:)];
-    
-  //  self.btnSubmitOrder.tintColor= UIColorFromRGB(0x996633);
-    
-    
-    //savebtn setBackgroundImage:(nullable UIImage *) forState:<#(UIControlState)#> style:<#(UIBarButtonItemStyle)#> barMetrics:<#(UIBarMetrics)#>
-    //[savebtn setImage:[UIImage imageNamed:@"save"] ];
-    
-    
-    /*
-     UIBarMetricsDefault,
-     UIBarMetricsCompact,
-     UIBarMetricsDefaultPrompt = 101, // Applicable only in bars with the prompt property, such as UINavigationBar and UISearchBar
-     UIBarMetricsCompactPrompt
-     
-     */
-    // [savebtn setBackgroundImage:[UIImage imageNamed:@"save"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
-    //        UIBarButtonItem *item1 = [[UIBarButtonItem alloc] init];
-    //        item1.title = @"item1";
-    ////        item1.image = [UIImage imageNamed:@"rect_setting"];
-    //        UIBarButtonItem *item2 = [[UIBarButtonItem alloc] init];
-    ////        item2.image = [UIImage imageNamed:@"rect_about"];
-    //        item2.title = @"item2";
-    
-    
-    UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
-    fixedItem.width = 20.0f;
-    
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-  //  if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
-    {
-        [items addObject:savebtn];
-        
-        [items addObject:fixedItem];
-    }
-    [items addObject:self.btnSubmitOrder];
-    //        [items addObject:item2];
-    self.navigationItem.rightBarButtonItems=items;
-    
     //    self.navigationItem.backBarButtonItem = backButton;
     
     

+ 20 - 5
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -18,6 +18,7 @@
 #import "DefaultTableHeaderView.h"
 #import "SelectUploadOrderViewController.h"
 #import "NotificationNameCenter.h"
+#import "Singleton.h"
 
 @interface OrderListViewController ()
 
@@ -118,11 +119,6 @@
     [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
     [self.table_order addSubview:ref];
     
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    if(appDelegate.user_type != USER_ROLE_CUSTOMER) {
-        [self.mergeListButton removeFromSuperview];
-        self.mergeListButton = nil;
-    }
     
 //    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
 //    NSString *documents = [paths objectAtIndex:0];
@@ -266,6 +262,21 @@
     //    }
     [[self navigationController] setNavigationBarHidden:!self.showNavibar animated:NO];
     
+    // 检查权限
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    if(appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        
+        if (![Singleton sharedInstance].permissions_merge_order) {
+            // 没有合并订单的权限
+            [self.mergeListButton removeFromSuperview];
+            self.mergeListButton = nil;
+        }
+        
+    } else {
+        
+        [self.mergeListButton removeFromSuperview];
+        self.mergeListButton = nil;
+    }
     
 }
 - (IBAction)onNewOrderClicked:(id)sender {
@@ -1363,6 +1374,10 @@
         }];
         add2MergeListAction.backgroundColor = UIColorFromRGB(0x336699);
         
+        if (![Singleton sharedInstance].permissions_merge_order) {
+            // 没有合并订单的权限
+            return @[];
+        }
         return @[add2MergeListAction];
     }
     

+ 9 - 0
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -3591,6 +3591,15 @@ repeat:
         //-
         [Singleton sharedInstance].npd_shop_price_type = [[objheader valueForKey:@"price_type"] integerValue];
         
+        // 权限
+        [Singleton sharedInstance].permissions_price_setting = [[objheader valueForKey:@"can_set_price_formula"] boolValue];
+        [Singleton sharedInstance].permissions_edit_order = [[objheader valueForKey:@"can_place_order"] boolValue];
+
+        [Singleton sharedInstance].permissions_submit_order = [[objheader valueForKey:@"can_submit_order"] boolValue];
+
+        [Singleton sharedInstance].permissions_merge_order = [[objheader valueForKey:@"can_merge_order"] boolValue];
+
+        
         //        DebugLog(@"sessionid=%@ ",appDelegate.sessionid);
         //        if ([[objheader valueForKey:@"update"] boolValue]==false)
         //        {

+ 9 - 7
RedAnt ERP Mobile/iSales-NPD/Base.lproj/Main.storyboard

@@ -2689,6 +2689,7 @@
                         <outlet property="btn_addwish" destination="Lpc-ux-UXx" id="ASy-V3-nj3"/>
                         <outlet property="btn_delete" destination="SsF-JY-rqj" id="qm9-XF-CQc"/>
                         <outlet property="btn_edit_select" destination="Qyh-x9-Q29" id="SW6-IF-mo5"/>
+                        <outlet property="cancelOrderButton" destination="HXI-1Z-Yo5" id="yfI-KK-bHm"/>
                         <outlet property="cartItemView" destination="APc-j8-ZhR" id="aua-Qg-MgJ"/>
                         <outlet property="itemListTable" destination="r3H-Zh-AQ4" id="RxD-ZP-Gbh"/>
                         <outlet property="labelTotal" destination="Rak-uF-hDd" id="zd4-Ey-hCG"/>
@@ -2700,6 +2701,7 @@
                         <outlet property="label_qty" destination="a8v-V0-Le7" id="o1W-1L-2Mc"/>
                         <outlet property="label_weight" destination="5XQ-b9-pCs" id="T2j-4T-MeJ"/>
                         <outlet property="mum" destination="636-3h-qpT" id="oVo-Z4-hgK"/>
+                        <outlet property="placeOrderButton" destination="jew-M1-our" id="sFD-dz-VUB"/>
                         <outlet property="toolbar" destination="GnW-hP-0qy" id="etW-tE-Wxa"/>
                         <outlet property="toolpanel" destination="NPc-ws-YtX" id="2pQ-ZI-TEp"/>
                     </connections>
@@ -2971,7 +2973,7 @@
                                     <barButtonItem style="plain" systemItem="flexibleSpace" id="XgM-Ds-OBI"/>
                                     <barButtonItem style="plain" id="dZA-gs-cR2">
                                         <searchBar key="customView" contentMode="redraw" searchBarStyle="minimal" placeholder="Sale order number, sales rep, create by, contact" id="afv-fP-PRn">
-                                            <rect key="frame" x="186" y="0.0" width="364" height="44"/>
+                                            <rect key="frame" x="198" y="0.0" width="364" height="44"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
                                             <textInputTraits key="textInputTraits"/>
                                             <connections>
@@ -2982,7 +2984,7 @@
                                     <barButtonItem style="plain" systemItem="flexibleSpace" id="L0d-T1-Fz0"/>
                                     <barButtonItem style="plain" id="RsL-7F-uf5">
                                         <button key="customView" opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="bAb-Lk-i0b">
-                                            <rect key="frame" x="566" y="7" width="90" height="30"/>
+                                            <rect key="frame" x="590" y="7" width="90" height="30"/>
                                             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                             <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                             <state key="normal" title="Merge List">
@@ -2996,7 +2998,7 @@
                                             </connections>
                                         </button>
                                     </barButtonItem>
-                                    <barButtonItem width="42" style="plain" systemItem="fixedSpace" id="CAM-9N-Eb2"/>
+                                    <barButtonItem style="plain" systemItem="flexibleSpace" id="kuR-14-mMo"/>
                                     <barButtonItem image="neworder" id="wye-VI-b4W">
                                         <color key="tintColor" red="0.59999999999999998" green="0.40000000000000002" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                         <connections>
@@ -3015,7 +3017,7 @@
                                         <rect key="frame" x="0.0" y="22" width="768" height="66"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="H8t-DU-AtW" id="q6R-9a-SsD">
-                                            <frame key="frameInset" width="768" height="66"/>
+                                            <frame key="frameInset" width="768" height="65.5"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="WEB1509140024" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fu3-Bf-ZH2" userLabel="So#">
@@ -3026,14 +3028,14 @@
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="12345678.00" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="N3e-hc-gFF" userLabel="price">
-                                                    <frame key="frameInset" minY="23" width="100" maxX="176" maxY="22"/>
+                                                    <frame key="frameInset" minY="23" width="100" maxX="176" maxY="21.5"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="02/02/2015 10:10:10" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="qf1-u6-uMA" userLabel="date">
-                                                    <frame key="frameInset" minY="11" width="148" maxX="15" maxY="12"/>
+                                                    <frame key="frameInset" minY="11" width="148" maxX="15" maxY="11.5"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -3054,7 +3056,7 @@
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="99999" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="kLZ-2K-sGp">
-                                                    <frame key="frameInset" minY="5" width="100" maxX="176" maxY="40"/>
+                                                    <frame key="frameInset" minY="5" width="100" maxX="176" maxY="39.5"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>

+ 5 - 4
RedAnt ERP Mobile/iSales-NPD/CUL.storyboard

@@ -27,7 +27,7 @@
                                 <nil key="highlightedColor"/>
                             </label>
                             <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vVs-6N-BCX">
-                                <frame key="frameInset" minX="20" minY="145" width="150" height="40"/>
+                                <frame key="frameInset" minX="20" minY="85" width="150" height="40"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                 <inset key="titleEdgeInsets" minX="-70" minY="0.0" maxX="0.0" maxY="0.0"/>
@@ -40,7 +40,7 @@
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mw1-Vv-KOj">
-                                <frame key="frameInset" minX="20" minY="85" width="150" height="40"/>
+                                <frame key="frameInset" minX="20" minY="145" width="150" height="40"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                 <inset key="titleEdgeInsets" minX="-10" minY="0.0" maxX="0.0" maxY="0.0"/>
@@ -82,6 +82,7 @@
                     </view>
                     <connections>
                         <outlet property="priceTypeButton" destination="jtK-Ru-fSW" id="jkm-Cl-oLP"/>
+                        <outlet property="setPriceButton" destination="mw1-Vv-KOj" id="VEC-xB-uaS"/>
                         <outlet property="showButton" destination="vVs-6N-BCX" id="KQJ-gx-IAV"/>
                     </connections>
                 </viewController>
@@ -105,10 +106,10 @@
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <prototypes>
                                     <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="CategoryPriceCell" rowHeight="47" id="rnb-EK-8yY" customClass="CategoryPriceCell">
-                                        <rect key="frame" x="0.0" y="28" width="1024" height="47"/>
+                                        <rect key="frame" x="0.0" y="28" width="375" height="47"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="rnb-EK-8yY" id="WGZ-Bw-E4C">
-                                            <frame key="frameInset" width="1024" height="46.5"/>
+                                            <frame key="frameInset" width="375" height="46"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Dinning" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3fh-vo-1qn">

+ 6 - 0
RedAnt ERP Mobile/iSales-NPD/PriceSettingViewController.m

@@ -18,11 +18,13 @@
 
 
 
+
 @interface PriceSettingViewController ()
 
 @property (strong, nonatomic) IBOutlet UIButton *priceTypeButton;
 
 @property (strong, nonatomic) IBOutlet UIButton *showButton;
+@property (strong, nonatomic) IBOutlet UIButton *setPriceButton;
 
 @end
 
@@ -47,6 +49,10 @@
 
 - (void)configAppearance {
     
+
+    self.setPriceButton.hidden = ![Singleton sharedInstance].permissions_price_setting;
+
+    
     UIApplication * app = [UIApplication sharedApplication];
     AppDelegate *appDelegate = (AppDelegate *)[app delegate];
     

+ 1 - 1
RedAnt ERP Mobile/iSales-NPD/Singleton.h

@@ -12,7 +12,7 @@
 
 @property (nonatomic,assign) NSInteger npd_shop_price_type;///<Shop 设置的价格类型
 
-#pragma mark - 用户权限
+#pragma mark - Shop 用户权限
 
 @property (nonatomic,assign) BOOL permissions_price_setting;///<价格设置权限
 @property (nonatomic,assign) BOOL permissions_edit_order;///<编辑订单权限,Place Order