示例#1
0
 /**
  * (string) actionDetail : 右侧区域信息
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionDetail()
 {
     //$this->layout = 'bank';
     $id = Yii::$app->request->post('id', '%');
     if ($id == '0' || $id == '@') {
         $id = '%';
     }
     $name = Yii::$app->request->post('name', '计生管理系统');
     $unit = new Unit();
     $p_num = Personal::find()->where(['unit' => $id])->count(1);
     if ($unit->isParent($id) && $p_num <= 0) {
         return $this->renderAjax('_detail', ['parent' => $id, 'parentName' => $name, 'unitcode' => Unit::getMaxunitcode($id), 'isParent' => intval($this->findModel($id)->corpflag) < 5 ? "yes" : "no"]);
     } else {
         $preferences = [];
         $preferences['sex'] = Preferences::getByClassmark('psex');
         $preferences['marry'] = Preferences::getByClassmark('pmarry');
         $preferences['flag'] = Preferences::getByClassmark('pflag');
         $preferences['work1'] = Preferences::getByClassmark('pwork1');
         return $this->renderAjax('/personal/_list', ['parent' => $id, 'parentName' => $name, 'code1' => Personal::getMaxCode(), 'preferences' => Json::encode($preferences)]);
     }
 }
示例#2
0
 /**
  * (array|\yii\db\ActiveRecord[]) getChildren :
  * @param $id
  * @param $user_id 用户ID
  * @return array|\yii\db\ActiveRecord[]
  */
 public function getChildren($id, $user_id)
 {
     $query = Unit::find();
     $query->select(['id' => 'unitcode', 'text' => 'unitname']);
     $query->andFilterWhere(['upunitcode' => $id == '0' ? '%' : $id]);
     $data = $query->orderBy(['order_num' => SORT_ASC, 'unitcode' => SORT_ASC])->asArray()->all();
     if (count($data) > 0) {
         foreach ($data as &$arr) {
             $user_power = self::getUserPower($user_id, $arr['id']);
             $user_power_icon = 'fa-lock';
             $user_power_class = 'text-muted';
             switch ($user_power) {
                 case self::USER_POWER_ALLOW:
                     $user_power_icon = 'fa-key';
                     $user_power_class = 'text-success';
                     break;
                 case self::USER_POWER_VIEW_ALL:
                     $user_power_icon = 'fa-eye';
                     $user_power_class = 'text-primary';
                     break;
                 case self::USER_POWER_VIEW_DEPT:
                     $user_power_icon = 'fa-eye-slash';
                     $user_power_class = 'text-info';
                     break;
             }
             $arr['children'] = Unit::isParent($arr['id']);
             $arr['icon'] = $arr['children'] ? "fa fa-folder {$user_power_class}" : "fa {$user_power_icon} {$user_power_class}";
             $arr['text'] = $arr['children'] ? "<span class='" . $user_power_class . "'>{$arr['text']} <i class='fa " . $user_power_icon . "'></i></span>" : "<span class='" . $user_power_class . "'>{$arr['text']}</span>";
             $arr['id'] = $arr['id'] == '%' ? '0' : $arr['id'];
             $arr['url'] = Url::to(['index', 'id' => $arr['id']]);
         }
     }
     return $data;
 }