Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MapTable::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'order_num' => $this->order_num, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'tname', $this->tname])->andFilterWhere(['like', 'cnname', $this->cnname])->andFilterWhere(['like', 'memo', $this->memo]);
     //默认排序
     $query->orderBy(['order_num' => SORT_DESC, 'tname' => SORT_ASC]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * (array|\yii\db\ActiveRecord[]) createTree :
  * @param $id 树父级ID
  * @param $user_id 用户ID
  * @return array|\yii\db\ActiveRecord[]
  */
 public function createTree($id, $user_id)
 {
     //empty(var):当var存在,并且是一个非空非零的值时返回 FALSE 否则返回 TRUE
     if (empty($user_id) || empty($id)) {
         return [];
     }
     $data = [];
     if ($id === 'js.map_field') {
         $data = MapTable::find()->select(['id' => 'tname', 'text' => 'cnname'])->where(['status' => MapTable::STATUS_ON])->orderBy(['order_num' => SORT_DESC])->asArray()->all();
         if (!empty($data)) {
             foreach ($data as &$arr) {
                 $arr['children'] = true;
                 $arr['icon'] = 'fa fa-list text-orange';
                 $arr['text'] = "<span class='text-info'>{$arr['text']}</span>";
             }
         }
     } else {
         $data = ColTable::find()->select(['id' => "CONCAT('gdjs.', pbc_tnam , '.', pbc_cnam)", 'text' => 'pbc_labl', 'pbc_cnam'])->where(['pbc_tnam' => $id])->orderBy(['sort_no' => SORT_ASC])->limit(24)->asArray()->all();
         if (!empty($data)) {
             foreach ($data as &$arr) {
                 $user_power = self::getUserPower($user_id, $id, $arr['pbc_cnam']);
                 $user_power_icon = 'fa-key';
                 $user_power_class = 'text-success';
                 switch ($user_power) {
                     case self::USER_POWER_VIEW:
                         $user_power_icon = 'fa-eye';
                         $user_power_class = 'text-primary';
                         break;
                     case self::USER_POWER_VIEW_AFTER_ADD:
                         $user_power_icon = 'fa-eye-slash';
                         $user_power_class = 'text-info';
                         break;
                     case self::USER_POWER_DENY:
                         $user_power_icon = 'fa-lock';
                         $user_power_class = 'text-muted';
                         break;
                 }
                 $arr['children'] = false;
                 $arr['icon'] = "fa {$user_power_icon} {$user_power_class}";
                 $arr['text'] = "<span class='" . $user_power_class . "'>{$arr['text']}</span>";
             }
         }
     }
     return $data;
 }
Пример #3
0
 /**
  * Finds the MapTable model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MapTable the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MapTable::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #4
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\populac\models\MapTable */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="map-table-form">

    <?php 
$form = ActiveForm::begin(['id' => 'map-table-form', 'options' => ['enctype' => 'multipart/form-data', 'class' => 'form-horizontal'], 'enableClientValidation' => true, 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-9\">{input}</div>\n<div class=\"col-lg-offset-3 col-lg-9\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-3 control-label']]]);
?>
    <?php 
if ($model->isNewRecord) {
    echo $form->field($model, 'tname')->widget(\kartik\widgets\Select2::classname(), ['data' => \common\populac\models\MapTable::getLostTables(), 'options' => ['placeholder' => '选择一个表..'], 'pluginOptions' => ['allowClear' => true]]);
} else {
    echo $form->field($model, 'tname')->textInput(['readOnly' => true]);
}
?>

    <?php 
echo $form->field($model, 'cnname')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'memo')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'order_num')->textInput();