Esempio n. 1
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;
 }
Esempio n. 2
0
                <div class="modal-body">
                    <?php 
for ($i = 0; $i < $iSearchColNum; $i++) {
    ?>
                        <div class="row row-<?php 
    echo $i;
    ?>
" style="margin: 5px 0;">
                            <div class="col-md-1 col-left">
                                <?php 
    echo \kartik\widgets\Select2::widget(['name' => 'left-' . $i, 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'data' => \common\populac\models\Preferences::getByClassmark('tLeft'), 'value' => '', 'options' => ['prompt' => '', 'title' => '如需要选择左括号,请选择..'], 'pluginOptions' => ['allowClear' => true, 'minimumResultsForSearch' => 'Infinity']]);
    ?>
                            </div>
                            <div class="col-md-3 col-field">
                                <?php 
    echo \kartik\widgets\Select2::widget(['name' => 'field-' . $i, 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'data' => \common\populac\models\ColTable::getColumnInfoByTablename('personal'), 'value' => $i == 0 ? 'personal.unit' : ($i == 1 ? 'personal.logout' : ($i == 2 ? 'personal.name1' : '')), 'options' => ['prompt' => '过滤条件', 'class' => 'field-select', 'data-classname' => 'select-value-' . $i], 'pluginOptions' => ['allowClear' => true]]);
    ?>
                            </div>
                            <div class="col-md-2 col-choose">
                                <?php 
    echo \kartik\widgets\Select2::widget(['name' => 'choose-' . $i, 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'data' => \common\populac\models\Preferences::getByClassmark('tChoose'), 'value' => 'like', 'options' => ['multiple' => false, 'class' => 'choose-select-' . $i], 'pluginOptions' => ['minimumResultsForSearch' => 'Infinity']]);
    ?>
                            </div>
                            <div class="col-md-4 col-value">
                                <select disabled class="value-select select-value-<?php 
    echo $i;
    ?>
" name="value-<?php 
    echo $i;
    ?>
" multiple="multiple" style="width: 100%;">
Esempio n. 3
0
 public function actionGetFieldConfig()
 {
     //传过来的数据格式为 pbc_tnam.pbc_cnam
     $params = Yii::$app->request->post('params', '');
     $config = [];
     if ($params) {
         $paramArr = explode('.', $params);
         if (count($paramArr) == 2) {
             $pbc_tnam = $paramArr[0];
             $pbc_cnam = $paramArr[1];
             $classmark = ColTable::getClassmark($pbc_tnam, $pbc_cnam);
             $data = $classmark ? Preferences::getByClassmark($classmark) : [];
             if ($pbc_cnam == 'unit') {
                 $data = Unit::getUnitcodeToUnitnameList();
             }
         }
     }
     if (count($data)) {
         foreach ($data as $key => $value) {
             $tmp['id'] = $key;
             $tmp['text'] = $value;
             $config[] = $tmp;
         }
     }
     return count($config) ? Json::encode($config) : '';
 }
Esempio n. 4
0
         */
        if (!$model->new_value) {
            return '';
        }
        $new = explode(',', str_replace(['[', ']', '"'], ['', '', ''], $model->new_value));
        $field = explode(',', str_replace(['[', ']', '"'], ['', '', ''], $model->field));
        $rawModel = new $model->model();
        $table = $rawModel->tableName();
        $display = [];
        foreach ($new as $i => $line) {
            if (in_array($field[$i], ['created_at', 'updated_at', 'created_by', 'updated_by'])) {
                continue;
            }
            $classmark = '';
            $value = '';
            $classmark = \common\populac\models\ColTable::getClassmark($table, $field[$i]);
            $value = \common\populac\models\Preferences::get($classmark, $line);
            $line = $value ? $value : $line;
            $line = '<span class="bg-info text-success">' . $line . '</span>';
            $display[] = $line;
        }
        return '<h4>' . implode('<br>', $display) . '</h4>';
    }, 'contentOptions' => ['width' => '20%'], 'format' => 'raw'];
}
if (empty($columns) || in_array('diff', $columns)) {
    $_columns[] = ['label' => Yii::t('audit', 'Diff'), 'value' => function ($model) {
        /** @var AuditTrail $model */
        return $model->getDiffHtml();
    }, 'format' => 'raw'];
}
if (empty($columns) || in_array('created', $columns)) {