xxxrrrdddd il y a 3 ans
Parent
commit
f784c2006a

+ 11 - 0
application/admin/controller/MobileOrder.php

@@ -89,6 +89,17 @@ class MobileOrder extends Backend
             $this->assign('row',$row);
             return view();
         }else{
+            $data=input('row/a');
+            if(isset($data['city'])){
+                $data['city']=\app\common\model\Area::whereIn('name|shortname',str_replace('/',',',$data['city']))->column('id');
+            }
+            $this->validate($data,[
+                'status'=>'in:'.implode(',',array_keys(\app\common\model\MobileOrder::$status))
+            ]);
+            foreach ($data as $key=>$value){
+                $model[$key]=$value;
+            }
+            $model->save();
             $this->success('');
         }
     }

+ 6 - 0
application/admin/view/mobile_order/edit.html

@@ -29,6 +29,12 @@
             <input id="c-address" class="form-control" name="row[address]" type="text" value="{$row.address|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('状态')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            {:build_select('row[status]',$status,$row['status'])}
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 6 - 2
application/common/model/Area.php

@@ -119,7 +119,11 @@ class Area extends Model
     }
 
     public static function getTreeId($id){
-        $county=self::where('id',$id)->area()->find();
+        if(is_numeric($id)) {
+            $county = self::where('id', $id)->area()->find();
+        }else{
+            $county= self::where('name|shortname',$id)->find();
+        }
         if(!$county){
             throw_user('区县不存在');
         }
@@ -128,7 +132,7 @@ class Area extends Model
         if(!$provinceId){
             throw_user('省不存在');
         }
-        return [$provinceId,$cityId,$id];
+        return [$provinceId,$cityId,$county['id']];
     }
     public static function getNameString($id,$sp=''){
         if(!$id){

+ 6 - 0
application/common/model/MobileOrder.php

@@ -61,6 +61,12 @@ class MobileOrder extends Model
     public function getAddressAttr($a,$b){
         return Area::getNameString($b['city']).$a;
     }
+    public function setCityAttr($a){
+        if(is_array($a)){
+            return implode(',',$a);
+        }
+        return $a;
+    }
 
 
     protected static function init()