作者 开飞机的舒克

项目管理字段渲染

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