Пример #1
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) : '';
 }
Пример #2
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)) {