作者 开飞机的舒克

项目管理字段渲染

<?php
return [
'Title' => '名称',
'Details' => '详情',
'Ronda_ids' => '场次',
'Campus_ids' => '校区',
'Title' => '项目名称',
'Details' => '项目详情',
'Ronda_ids' => '项目场次',
'Campus_ids' => '项目界次',
'Radar_ids' => '所属维度',
'User_id' => '所属老师',
'Images' => '项目图片',
... ... @@ -15,38 +15,6 @@ return [
'Ronda.title' => '场次名称',
'Radar.title' => '维度名称',
'User.id' => 'ID',
'User.group_id' => '组别ID',
'User.username' => '用户名',
'User.nickname' => '昵称',
'User.password' => '密码',
'User.salt' => '密码盐',
'User.email' => '电子邮箱',
'User.mobile' => '手机号',
'User.avatar' => '头像',
'User.level' => '等级',
'User.gender' => '性别',
'User.birthday' => '生日',
'User.bio' => '格言',
'User.money' => '余额',
'User.score' => '积分',
'User.successions' => '连续登录天数',
'User.maxsuccessions' => '最大连续登录天数',
'User.prevtime' => '上次登录时间',
'User.logintime' => '登录时间',
'User.loginip' => '登录IP',
'User.loginfailure' => '失败次数',
'User.joinip' => '加入IP',
'User.jointime' => '加入时间',
'User.createtime' => '创建时间',
'User.updatetime' => '更新时间',
'User.token' => 'Token',
'User.status' => '状态',
'User.verification' => '验证',
'User.teach_phone' => '老师手机号',
'User.is_teach' => '是否为老师',
'User.is_teach 0' => '否',
'User.is_teach 1' => '是',
'User.bind_study' => '是否绑定学生信息',
'User.bind_study 0' => '否',
'User.bind_study 1' => '是'
'User.nickname' => '老师昵称',
'User.teach_phone'=> '联系方式'
];
... ...
... ... @@ -25,17 +25,40 @@ class Item extends Model
// 追加属性
protected $append = [
'campus_text',
'ronda_text',
'radar_text',
];
public function getCampusTextAttr($value,$data){
$campus = explode(',',$data['campus_ids']);
$title = [];
foreach ($campus as $k){
$title[] = db('campus')->where('id',$k)->value('title');
}
$value = implode(',',$title);
return $value;
}
public function getRondaTextAttr($value,$data){
$ronda = explode(',',$data['ronda_ids']);
$title = [];
foreach ($ronda as $k){
$title[] = db('ronda')->where('id',$k)->value('title');
}
$value = implode(',',$title);
return $value;
}
public function getRadarTextAttr($value,$data){
$radar = explode(',',$data['radar_ids']);
$title = [];
foreach ($radar as $k){
$title[] = db('radar')->where('id',$k)->value('title');
}
$value = implode(',',$title);
return $value;
}
public function campus()
{
... ... @@ -57,6 +80,6 @@ class Item extends Model
public function user()
{
return $this->belongsTo('User', 'user_id', 'nickname', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
... ... @@ -36,15 +36,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id'), operate: false},
// {field: 'campus_id', title: __('Campus_id')},
// {field: 'ronda_id', title: __('Ronda_id')},
{field: 'campus.title', title: __('所属校区'), operate: 'LIKE'},
{field: 'ronda.title', title: __('场次'), operate: false},
{field: 'campus_text', title: __('Campus_ids'), operate: 'LIKE',
formatter : function(value, row, index, field){
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space:nowrap;' title='" + row.campus_text + "'>" + value + "</span>";
},
cellStyle : function(value, row, index, field) {
return {
css: {
"white-space": "nowrap",
"text-overflow": "ellipsis",
"overflow": "hidden",
"max-width": "150px"
}
};
},
},
{field: 'ronda_text', title: __('Ronda_ids'), operate: false,formatter:Table.api.formatter.flag},
{field: 'title', title: __('Title'), operate: 'LIKE'},
// {field: 'radar_id', title: __('Radar_id')},
// {field: 'user_id', title: __('User_id')},
{field: 'score', title: __('可获积分'), operate: false},
{field: 'user.nickname', title: __('管理老师'), operate: false},
{field: 'user.nickname', title: __('User.nickname'), operate: false},
{field: 'user.teach_phone', title: __('User.teach_phone'), operate: false},
{field: 'radar.title', title: __('Radar.title'), operate: false},
{field: 'radar_text', title: __('Radar.title'), operate: false, formatter: Table.api.formatter.label},
{
field: 'createtime',
title: __('Createtime'),
... ...