Эх сурвалжийг харах

自动分配左右,优化查找方式,界面调整

theo 3 жил өмнө
parent
commit
5e3fe9a163

+ 10 - 7
common/models/UserNetwork.php

@@ -171,17 +171,20 @@ class UserNetwork extends \common\components\ActiveRecord
      *
      */
 
-    public static function getBottomPlace($userId, $side){
-        $userNetInfo = static::find()->select(['LOCATION_TAG', 'TOP_DEEP'])->where('USER_ID=:USER_ID', ['USER_ID'=>$userId])->asArray()->one();
-        $userLocationTag = $userNetInfo['LOCATION_TAG'];
-        $sonUserTag = $userLocationTag . ($side=='left' ? '1' : '2');
-        $sonUser = static::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG',['LOCATION_TAG'=>$sonUserTag])->asArray()->one();
-
+    public static function getBottomPlace($userId, $userTag='', $side){
+        if(!$userTag||$userTag==''){
+            $userNetInfo = static::find()->select(['LOCATION_TAG', 'TOP_DEEP'])->where('USER_ID=:USER_ID', ['USER_ID'=>$userId])->asArray()->one();
+            $userLocationTag = $userNetInfo['LOCATION_TAG'];
+            $sonUserTag = $userLocationTag . ($side=='left' ? '1' : '2');
+        }else{
+            $sonUserTag = $userTag . ($side=='left' ? '1' : '2');
+        }
+        $sonUser = static::find()->select('USER_ID, LOCATION_TAG')->where('LOCATION_TAG=:LOCATION_TAG',['LOCATION_TAG'=>$sonUserTag])->asArray()->one();
         if(!$sonUser){// 如果没有查到,说明该位置空白,返回上级用户的信息
             $placeParentTag = substr($sonUserTag, 0, strlen($sonUserTag) - 1);
             return $placeParentTag;
         }else{
-            return self::getBottomPlace($sonUser['USER_ID'], 'left');
+            return self::getBottomPlace($sonUser['USER_ID'], $sonUser['LOCATION_TAG'], 'left');
         }
     }
 

+ 1 - 1
frontendApi/modules/v1/controllers/UserController.php

@@ -464,7 +464,7 @@ class UserController extends BaseController {
         $side = \Yii::$app->request->get('side');
         $userId = Info::getUserIdByUserName($userName);
 //        print_r($userId);
-        $bottomPlace = UserNetwork::getBottomPlace($userId, $side);
+        $bottomPlace = UserNetwork::getBottomPlace($userId,'', $side);
         $bottomUser = UserNetwork::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG', ['LOCATION_TAG' => $bottomPlace])->asArray()->one();
         $bottomUser = User::findOneAsArray('ID=:ID', [':ID' => $bottomUser['USER_ID']], 'USER_NAME');
 //        print_r($bottomUser);

+ 10 - 10
frontendEle/src/views/user/dec.vue

@@ -130,11 +130,9 @@
           </el-input>
         </el-form-item>
 
-        <el-form-item label="Auto Place"><!--自动安置区位-->
-          <el-radio-group v-model="form.autoPlace" @change="setAutoPlace">
-            <el-radio-button label="left">Left</el-radio-button>
-            <el-radio-button label="right">Right</el-radio-button>
-          </el-radio-group>
+        <el-form-item label=""><!--自动安置区位-->
+          <el-button type="primary" @click="setAutoPlace('left')" :plain="form.autoPlace==='left'?true:false">Auto Location: L</el-button>
+          <el-button type="primary" @click="setAutoPlace('right')" :plain="form.autoPlace==='right'?true:false">Auto Location: R</el-button>
         </el-form-item>
 
         <el-form-item label="Placement code"><!--接点人编号-->
@@ -145,11 +143,11 @@
 
         <el-form-item label="Placement tree"><!--安置区位-->
           <el-radio-group v-model="form.location">
-            <el-radio-button :label="1">Left</el-radio-button><!--左区-->
-            <el-radio-button :label="2">Right</el-radio-button><!--中区-->
-            <!--  <el-radio-button :label="3">Right</el-radio-button> --><!--右区-->
+            <el-radio-button :label="1" >Left</el-radio-button><!--左区-->
+            <el-radio-button :label="2" >Right</el-radio-button><!--右区-->
           </el-radio-group>
         </el-form-item>
+
         <div class="hr-tip"><span>Personal Information<!--个人信息--></span></div>
         <el-form-item>
           <template slot="label">
@@ -389,7 +387,8 @@ export default {
         lgaName: '',
         way: 'express',
         payType: '',
-        autoPlace: ''
+        autoPlace: '',
+        location: ''
       },
       conRealName: '-',
       recRealName: '-',
@@ -533,7 +532,8 @@ export default {
           // console.log(response)
           this.form.conUserName = response.USER_NAME
           this.handleChkConUser()
-          // this.form.location = 1
+          this.form.location = 1
+          this.form.autoPlace = val
           this.loading = false
         }).catch(response => {
           // this.recRealName = '-'