作者 开飞机的舒克

后台优化

  1 +{"files":[],"license":"regular","licenseto":"10789","licensekey":"zOyxKJsHuBg8Dq0T K2PTlnRQJF6Ewtd6XhP14A==","domains":["campus.cn"],"licensecodes":[],"validations":["c51a74160ee0aa6a19729b33d4a9fcdc"]}
  1 +<?php
  2 +
  3 +namespace addons\captcha;
  4 +
  5 +use app\common\library\Menu;
  6 +use think\Addons;
  7 +
  8 +/**
  9 + * 动态验证码插件
  10 + */
  11 +class Captcha extends Addons
  12 +{
  13 +
  14 + /**
  15 + * 插件安装方法
  16 + * @return bool
  17 + */
  18 + public function install()
  19 + {
  20 +
  21 + return true;
  22 + }
  23 +
  24 + /**
  25 + * 插件卸载方法
  26 + * @return bool
  27 + */
  28 + public function uninstall()
  29 + {
  30 +
  31 + return true;
  32 + }
  33 +
  34 + /**
  35 + * 插件启用方法
  36 + * @return bool
  37 + */
  38 + public function enable()
  39 + {
  40 +
  41 + return true;
  42 + }
  43 +
  44 + /**
  45 + * 插件禁用方法
  46 + * @return bool
  47 + */
  48 + public function disable()
  49 + {
  50 +
  51 + return true;
  52 + }
  53 +
  54 + /**
  55 + * 实现钩子方法
  56 + * @return mixed
  57 + */
  58 + public function appInit($param)
  59 + {
  60 + \think\Route::get('captcha/[:id]', "\\think\\addons\\Route@execute?addon=captcha&controller=index&action=build");
  61 + }
  62 +
  63 +}
  1 +<?php
  2 +
  3 +return [
  4 + [
  5 + 'name' => 'random',
  6 + 'title' => '验证码字库',
  7 + 'type' => 'string',
  8 + 'content' => [],
  9 + 'value' => '012345678',
  10 + 'rule' => '',
  11 + 'msg' => '',
  12 + 'tip' => '默认使用英文加数字的组合,你在此可以自定义验证码字库',
  13 + 'ok' => '',
  14 + 'extend' => '',
  15 + ],
  16 + [
  17 + 'name' => 'is_gif',
  18 + 'title' => '是否动图',
  19 + 'type' => 'radio',
  20 + 'content' => [
  21 + 1 => '是',
  22 + 0 => '否',
  23 + ],
  24 + 'value' => '1',
  25 + 'rule' => 'required',
  26 + 'msg' => '',
  27 + 'tip' => '',
  28 + 'ok' => '',
  29 + 'extend' => '',
  30 + ],
  31 + [
  32 + 'name' => 'gif_fps',
  33 + 'title' => '动图帧数',
  34 + 'type' => 'number',
  35 + 'content' => [],
  36 + 'value' => '10',
  37 + 'rule' => 'required',
  38 + 'msg' => '',
  39 + 'tip' => 'GIF动图的帧数,默认为10帧',
  40 + 'ok' => '',
  41 + 'extend' => '',
  42 + ],
  43 +];
  1 +<?php
  2 +
  3 +namespace addons\captcha\controller;
  4 +
  5 +use addons\captcha\library\Captcha;
  6 +use think\addons\Controller;
  7 +use think\Session;
  8 +
  9 +class Index extends Controller
  10 +{
  11 +
  12 + public function index()
  13 + {
  14 + $this->error("当前插件暂无前台页面");
  15 + }
  16 +
  17 + public function build()
  18 + {
  19 + $id = $this->request->param('id', '');
  20 + $config = get_addon_config('captcha');
  21 +
  22 + /* 实例化 */
  23 + $captcha = new Captcha();
  24 +
  25 + // 验证码宽度
  26 + $captcha->width = config('captcha.imageW');
  27 + // 验证码高度
  28 + $captcha->height = config('captcha.imageH');
  29 + // 验证码个数
  30 + $captcha->nums = config('captcha.length');
  31 + // 随机字符串
  32 + if (isset($config['random']) && $config['random']) {
  33 + $captcha->random = $config['random'];
  34 + }
  35 + // 随机数大小
  36 + $captcha->font_size = config('captcha.fontSize');
  37 + // 字体路径
  38 + //$ver->font_path = __DIR__.'/Font/zhankukuhei.ttf';
  39 + // 是否为动态验证码
  40 + $captcha->is_gif = isset($config['is_gif']) ? $config['is_gif'] : true;
  41 + // 动图帧数
  42 + $captcha->gif_fps = $config['gif_fps'] ? $config['gif_fps'] : 10;
  43 +
  44 + /* 生成验证码 */
  45 + $code = $captcha->getCode();
  46 +
  47 + $originCaptcha = new \think\captcha\Captcha();
  48 +
  49 + // 保存验证码
  50 + $key = $this->authcode($originCaptcha->seKey, $originCaptcha->seKey);
  51 +
  52 + $secode = [];
  53 + $secode['verify_code'] = $this->authcode(mb_strtoupper($code), $originCaptcha->seKey); // 把校验码保存到session
  54 + $secode['verify_time'] = time(); // 验证码创建时间
  55 +
  56 + Session::set($key . $id, $secode, '');
  57 +
  58 + /* 生成验证码图片 */
  59 + $captcha->doImg($code);
  60 + }
  61 +
  62 + /* 加密验证码 */
  63 + private function authcode($str, $seKey)
  64 + {
  65 + $key = substr(md5($seKey), 5, 8);
  66 + $str = substr(md5($str), 8, 10);
  67 + return md5($key . $str);
  68 + }
  69 +
  70 +}
  1 +name = captcha
  2 +title = 动态验证码
  3 +intro = 将默认的验证码切换为动态验证码
  4 +author = Karson
  5 +website = https://www.fastadmin.net
  6 +version = 1.0.0
  7 +state = 1
  8 +url = /addons/captcha
  9 +license = regular
  10 +licenseto = 10789
  1 +<?php
  2 +
  3 +namespace addons\captcha\library;
  4 +
  5 +use addons\captcha\library\gif\GIFEncoder;
  6 +
  7 +
  8 +/*
  9 + * 验证码类库
  10 + * @Author: lovefc
  11 + * @Email:fcphp@qq.com
  12 + * @Date: 2019-09-27 14:35:05
  13 + * @Last Modified by: lovefc
  14 + * @Last Modified time: 2019-09-28 15:28:20
  15 + */
  16 +
  17 +
  18 +class Captcha
  19 +{
  20 +
  21 + // 验证码宽度
  22 + public $width = 200;
  23 +
  24 + // 验证码高度
  25 + public $height = 60;
  26 +
  27 + // 验证码个数
  28 + public $nums = 4;
  29 +
  30 + // 随机字符串
  31 + public $random = '2345689zxcvbnmasdfhjkqwertyup';
  32 +
  33 + // 随机数大小
  34 + public $font_size = 36;
  35 +
  36 + // 字体路径
  37 + public $font_path = __DIR__.'/font/zhankukuhei.ttf';
  38 +
  39 + // 是否为动态验证码
  40 + public $is_gif = true;
  41 +
  42 + // 动图帧数
  43 + public $gif_fps = 10;
  44 +
  45 + /**
  46 + * 获取验证码
  47 + *
  48 + * @return void
  49 + */
  50 + public function getCode()
  51 + {
  52 + return $this->code = strtolower($this->setVerNumber());
  53 + }
  54 +
  55 + /**
  56 + * 生成验证码
  57 + *
  58 + * @param integer $w 宽度
  59 + * @param integer $h 高度
  60 + * @param integer $nums 数量
  61 + * @param string $random 随机字符串
  62 + * @return void
  63 + */
  64 + public function doImg($code = '')
  65 + {
  66 + if (!$code) {
  67 + return false;
  68 + }
  69 + $code = strtoupper($code);
  70 + $imagedata = [];
  71 + if ($this->is_gif) {
  72 + for ($i = 0; $i < $this->gif_fps; $i++) {
  73 + $imagedata[] = $this->creBackGIF($code);
  74 + ++$i;
  75 + }
  76 + } else {
  77 + $imagedata[] = $this->creBackGIF($code);
  78 + }
  79 + $gif = new GIFEncoder($imagedata);
  80 + header('Content-type:image/gif');
  81 + echo $gif->GetAnimation();
  82 + exit;
  83 + }
  84 +
  85 + /**
  86 + * 创建动态背景
  87 + *
  88 + * @return void
  89 + */
  90 + private function creBackGIF($code)
  91 + {
  92 + ob_start();
  93 + $im = $this->createImageSource();
  94 + $this->setBackGroundColor($im);
  95 + $this->setCode($im, $code);
  96 + $this->setRandomCode($im);
  97 + imagegif($im);
  98 + imagedestroy($im);
  99 + $imagedata = ob_get_contents();
  100 + ob_clean();
  101 + return $imagedata;
  102 + }
  103 +
  104 + /**
  105 + * 创建个画布
  106 + *
  107 + * @return void
  108 + */
  109 + private function createImageSource()
  110 + {
  111 + return imagecreate($this->width, $this->height);
  112 + }
  113 +
  114 + /**
  115 + * 设置背景颜色
  116 + *
  117 + * @param [type] $im
  118 + * @return void
  119 + */
  120 + private function setBackGroundColor($im)
  121 + {
  122 + $bgcolor = imagecolorallocate($im, rand(200, 255), rand(200, 255), rand(200, 255));
  123 + imagefill($im, 0, 0, $bgcolor);
  124 + }
  125 +
  126 + /**
  127 + * 加入随机数
  128 + *
  129 + * @param [type] $im
  130 + * @return string
  131 + */
  132 + private function setRandomCode($im)
  133 + {
  134 + $count_h = $this->height;
  135 + $cou = floor($count_h * 1);
  136 + for ($i = 0; $i < $cou; $i++) {
  137 + $x = rand(0, $this->width);
  138 + $y = rand(0, $this->height);
  139 + $jiaodu = rand(0, 360); //设置角度
  140 + $fonturl = $this->font_path; //使用的字体
  141 + // 检测中文
  142 + if (preg_match("/[\x7f-\xff]/", $this->random)) {
  143 + $fontsize = $this->font_size / 4;
  144 + $dscode = $this->getChar(1);
  145 + } else {
  146 + $size = $this->font_size / 3.5;
  147 + $fontsize = rand($size, $size + 3);
  148 + $originalcode = 'zxcvbnmasdfghjklqwertyuiop1234567890'; //随机字符串
  149 + $countdistrub = mb_strlen($originalcode);
  150 + $dscode = $originalcode[rand(0, $countdistrub - 1)];
  151 + }
  152 + $color = imagecolorallocate($im, rand(40, 140), rand(40, 140), rand(40, 140));
  153 + imagettftext($im, $fontsize, $jiaodu, $x, $y, $color, $fonturl, $dscode);
  154 + }
  155 + }
  156 +
  157 + /**
  158 + * 随机中文字符串
  159 + *
  160 + * @param [type] $num 返回数量
  161 + * @return string
  162 + */
  163 + private function getChar($num)
  164 + {
  165 + $b = '';
  166 + for ($i = 0; $i < $num; $i++) {
  167 + // 使用chr()函数拼接双字节汉字,前一个chr()为高位字节,后一个为低位字节
  168 + $a = chr(mt_rand(0xB0, 0xD0)) . chr(mt_rand(0xA1, 0xF0));
  169 + // 转码
  170 + $b .= iconv('GB2312', 'UTF-8', $a);
  171 + }
  172 + return $b;
  173 + }
  174 +
  175 + /**
  176 + * 画布上生成验证码
  177 + *
  178 + * @param [type] $im
  179 + * @param [type] $string
  180 + * @return void
  181 + */
  182 + private function setCode($im, $string)
  183 + {
  184 + $width = $this->width;
  185 + $height = $this->height;
  186 + $len = 1;
  187 + $start = 0;
  188 + $strlen = $count = mb_strlen($string, 'utf-8');
  189 + while ($strlen) {
  190 + $array[] = mb_substr($string, $start, $len, "utf8");
  191 + $string = mb_substr($string, $len, $strlen, "utf8");
  192 + $strlen = mb_strlen($string);
  193 + }
  194 + $y = floor($height / 2) + floor($height / 4);
  195 + $fontsize = rand($this->font_size - 2, $this->font_size);
  196 + $fonturl = $this->font_path;
  197 + $counts = $count;
  198 + for ($i = 0; $i < $counts; $i++) {
  199 + $char = $array[$i];
  200 + $x = floor($width / $counts) * $i + ($width / 15);
  201 + $jiaodu = rand(-30, 30);
  202 + $color = imagecolorallocate($im, rand(0, 50), rand(50, 100), rand(100, 140));
  203 + imagettftext($im, $fontsize, $jiaodu, $x, $y, $color, $fonturl, $char);
  204 + }
  205 + }
  206 +
  207 + /**
  208 + * 生成随机码,(支持中文)
  209 + *
  210 + * @return void
  211 + */
  212 + private function setVerNumber()
  213 + {
  214 + $len = 1;
  215 + $start = 0;
  216 + $string = $this->random;
  217 + $strlen = $num = mb_strlen($string, 'utf-8');
  218 + while ($strlen) {
  219 + $array[] = mb_substr($string, $start, $len, "utf-8");
  220 + $string = mb_substr($string, $len, $strlen, "utf-8");
  221 + $strlen = mb_strlen($string, 'utf-8');
  222 + }
  223 + $originalcode = $array;
  224 + $_dscode = "";
  225 + $counts = $this->nums;
  226 + for ($j = 0; $j < $counts; $j++) {
  227 + $rand = rand(0, $num - 1);
  228 + $dscode = $originalcode[$rand];
  229 + $_dscode .= $dscode;
  230 + }
  231 + return $_dscode;
  232 + }
  233 +}
  1 +<?php
  2 +
  3 +namespace addons\captcha\library\gif;
  4 +
  5 +/*
  6 + * GIF 合成类库
  7 + * @Author: Anonymous
  8 + * @Date: 2019-09-28 13:35:44
  9 + * @Last Modified by: lovefc
  10 + * @Last Modified time: 2019-09-28 13:37:09
  11 + */
  12 +
  13 +class GIFEncoder
  14 +{
  15 + public $GIF = "GIF89a";
  16 +
  17 + public $VER = "GIFEncoder V2.06";
  18 +
  19 + public $BUF = array();
  20 +
  21 + public $LOP = 0;
  22 +
  23 + public $DIS = 2;
  24 +
  25 + public $COL = -1;
  26 +
  27 + public $IMG = -1;
  28 +
  29 + public $ERR = array(
  30 + 'ERR00' => "Does not supported public function for only one image!",
  31 + 'ERR01' => "Source is not a GIF image!",
  32 + 'ERR02' => "Unintelligible flag ",
  33 + 'ERR03' => "Could not make animation from animated GIF source",
  34 + );
  35 +
  36 + public function __construct($GIF_src, $GIF_dly = 100, $GIF_lop = 0, $GIF_dis = 0, $GIF_red = 0, $GIF_grn = 0, $GIF_blu = 0, $GIF_mod = 'bin')
  37 + {
  38 + if (!is_array($GIF_src) && !is_array($GIF_tim)) {
  39 + printf("%s: %s", $this->VER, $this->ERR['ERR00']);
  40 + exit(0);
  41 + }
  42 + $this->LOP = ($GIF_lop > -1) ? $GIF_lop : 0;
  43 + $this->DIS = ($GIF_dis > -1) ? (($GIF_dis < 3) ? $GIF_dis : 3) : 2;
  44 + $this->COL = ($GIF_red > -1 && $GIF_grn > -1 && $GIF_blu > -1) ? ($GIF_red | ($GIF_grn << 8) | ($GIF_blu << 16)) : -1;
  45 +
  46 + for ($i = 0, $src_count = count($GIF_src); $i < $src_count; $i++) {
  47 + if (strToLower($GIF_mod) == "url") {
  48 + $this->BUF[] = fread(fopen($GIF_src[$i], "rb"), filesize($GIF_src[$i]));
  49 + } elseif (strToLower($GIF_mod) == "bin") {
  50 + $this->BUF[] = $GIF_src[$i];
  51 + } else {
  52 + printf("%s: %s(%s)!", $this->VER, $this->ERR['ERR02'], $GIF_mod);
  53 + exit(0);
  54 + }
  55 + if (substr($this->BUF[$i], 0, 6) != "GIF87a" && substr($this->BUF[$i], 0, 6) != "GIF89a") {
  56 + printf("%s: %d %s", $this->VER, $i, $this->ERR['ERR01']);
  57 + exit(0);
  58 + }
  59 + for ($j = (13 + 3 * (2 << (ord($this->BUF[$i]{
  60 + 10}) & 0x07))), $k = TRUE; $k; $j++) {
  61 + switch ($this->BUF[$i]{
  62 + $j}) {
  63 + case "!":
  64 + if ((substr($this->BUF[$i], ($j + 3), 8)) == "NETSCAPE") {
  65 + printf("%s: %s(%s source)!", $this->VER, $this->ERR['ERR03'], ($i + 1));
  66 + exit(0);
  67 + }
  68 + break;
  69 + case ";":
  70 + $k = FALSE;
  71 + break;
  72 + }
  73 + }
  74 + }
  75 + GIFEncoder::GIFAddHeader();
  76 + for ($i = 0, $count_buf = count($this->BUF); $i < $count_buf; $i++) {
  77 + GIFEncoder::GIFAddFrames($i, $GIF_dly[$i]);
  78 + }
  79 + GIFEncoder::GIFAddFooter();
  80 + }
  81 +
  82 + public function GIFAddHeader()
  83 + {
  84 + $cmap = 0;
  85 + if (ord($this->BUF[0]{
  86 + 10}) & 0x80) {
  87 + $cmap = 3 * (2 << (ord($this->BUF[0]{
  88 + 10}) & 0x07));
  89 + $this->GIF .= substr($this->BUF[0], 6, 7);
  90 + $this->GIF .= substr($this->BUF[0], 13, $cmap);
  91 + $this->GIF .= "!\377\13NETSCAPE2.0\3\1" . GIFEncoder::GIFWord($this->LOP) . "\0";
  92 + }
  93 + }
  94 +
  95 + public function GIFAddFrames($i, $d)
  96 + {
  97 + $Locals_str = 13 + 3 * (2 << (ord($this->BUF[$i]{
  98 + 10}) & 0x07));
  99 + $Locals_end = strlen($this->BUF[$i]) - $Locals_str - 1;
  100 + $Locals_tmp = substr($this->BUF[$i], $Locals_str, $Locals_end);
  101 + $Global_len = 2 << (ord($this->BUF[0]{
  102 + 10}) & 0x07);
  103 + $Locals_len = 2 << (ord($this->BUF[$i]{
  104 + 10}) & 0x07);
  105 + $Global_rgb = substr($this->BUF[0], 13, 3 * (2 << (ord($this->BUF[0]{
  106 + 10}) & 0x07)));
  107 + $Locals_rgb = substr($this->BUF[$i], 13, 3 * (2 << (ord($this->BUF[$i]{
  108 + 10}) & 0x07)));
  109 + $Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 0) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0";
  110 + if ($this->COL > -1 && ord($this->BUF[$i]{
  111 + 10}) & 0x80) {
  112 + for ($j = 0; $j < (2 << (ord($this->BUF[$i]{
  113 + 10}) & 0x07)); $j++) {
  114 + if (ord($Locals_rgb{
  115 + 3 * $j + 0}) == ($this->COL >> 0) & 0xFF && ord($Locals_rgb{
  116 + 3 * $j + 1}) == ($this->COL >> 8) & 0xFF && ord($Locals_rgb{
  117 + 3 * $j + 2}) == ($this->COL >> 16) & 0xFF) {
  118 + $Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 1) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0";
  119 + break;
  120 + }
  121 + }
  122 + }
  123 + switch ($Locals_tmp{
  124 + 0}) {
  125 + case "!":
  126 + $Locals_img = substr($Locals_tmp, 8, 10);
  127 + $Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
  128 + break;
  129 + case ",":
  130 + $Locals_img = substr($Locals_tmp, 0, 10);
  131 + $Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
  132 + break;
  133 + }
  134 + if (ord($this->BUF[$i]{
  135 + 10}) & 0x80 && $this->IMG > -1) {
  136 + if ($Global_len == $Locals_len) {
  137 + if (GIFEncoder::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
  138 + $this->GIF .= ($Locals_ext . $Locals_img . $Locals_tmp);
  139 + } else {
  140 + $byte = ord($Locals_img{
  141 + 9});
  142 + $byte |= 0x80;
  143 + $byte &= 0xF8;
  144 + $byte |= (ord($this->BUF[0]{
  145 + 10}) & 0x07);
  146 + $Locals_img{
  147 + 9} = chr($byte);
  148 + $this->GIF .= ($Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp);
  149 + }
  150 + } else {
  151 + $byte = ord($Locals_img{
  152 + 9});
  153 + $byte |= 0x80;
  154 + $byte &= 0xF8;
  155 + $byte |= (ord($this->BUF[$i]{
  156 + 10}) & 0x07);
  157 + $Locals_img{
  158 + 9} = chr($byte);
  159 + $this->GIF .= ($Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp);
  160 + }
  161 + } else {
  162 + $this->GIF .= ($Locals_ext . $Locals_img . $Locals_tmp);
  163 + }
  164 + $this->IMG = 1;
  165 + }
  166 +
  167 + public function GIFAddFooter()
  168 + {
  169 + $this->GIF .= ";";
  170 + }
  171 +
  172 + public function GIFBlockCompare($GlobalBlock, $LocalBlock, $Len)
  173 + {
  174 + for ($i = 0; $i < $Len; $i++) {
  175 + if ($GlobalBlock{
  176 + 3 * $i + 0} != $LocalBlock{
  177 + 3 * $i + 0} || $GlobalBlock{
  178 + 3 * $i + 1} != $LocalBlock{
  179 + 3 * $i + 1} || $GlobalBlock{
  180 + 3 * $i + 2} != $LocalBlock{
  181 + 3 * $i + 2}) {
  182 + return (0);
  183 + }
  184 + }
  185 + return (1);
  186 + }
  187 +
  188 + public function GIFWord($int)
  189 + {
  190 + return (chr($int & 0xFF) . chr(($int >> 8) & 0xFF));
  191 + }
  192 +
  193 + public function GetAnimation()
  194 + {
  195 + return ($this->GIF);
  196 + }
  197 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +
  7 +/**
  8 + * 项目管理
  9 + *
  10 + * @icon fa fa-circle-o
  11 + */
  12 +class Item extends Backend
  13 +{
  14 +
  15 + /**
  16 + * Item模型对象
  17 + * @var \app\admin\model\Item
  18 + */
  19 + protected $model = null;
  20 +
  21 + public function _initialize()
  22 + {
  23 + parent::_initialize();
  24 + $this->model = new \app\admin\model\Item;
  25 +
  26 + }
  27 +
  28 +
  29 +
  30 + /**
  31 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  32 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  33 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  34 + */
  35 +
  36 +
  37 + /**
  38 + * 查看
  39 + */
  40 + public function index()
  41 + {
  42 + //当前是否为关联查询
  43 + $this->relationSearch = true;
  44 + //设置过滤方法
  45 + $this->request->filter(['strip_tags', 'trim']);
  46 + if ($this->request->isAjax()) {
  47 + //如果发送的来源是Selectpage,则转发到Selectpage
  48 + if ($this->request->request('keyField')) {
  49 + return $this->selectpage();
  50 + }
  51 + list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  52 +
  53 + $list = $this->model
  54 + ->with(['user','ronda','radar','campus'])
  55 + ->where($where)
  56 + ->order($sort, $order)
  57 + ->paginate($limit);
  58 +
  59 + foreach ($list as $row) {
  60 +
  61 + $row->getRelation('user')->visible(['username','teach_phone']);
  62 + $row->getRelation('ronda')->visible(['title']);
  63 + $row->getRelation('radar')->visible(['title']);
  64 + $row->getRelation('campus')->visible(['title']);
  65 + }
  66 +
  67 + $result = array("total" => $list->total(), "rows" => $list->items());
  68 +
  69 + return json($result);
  70 + }
  71 + return $this->view->fetch();
  72 + }
  73 +
  74 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +
  7 +/**
  8 + * 项目详情表
  9 +
  10 + *
  11 + * @icon fa fa-circle-o
  12 + */
  13 +class ItemDetails extends Backend
  14 +{
  15 +
  16 + /**
  17 + * ItemDetails模型对象
  18 + * @var \app\admin\model\ItemDetails
  19 + */
  20 + protected $model = null;
  21 +
  22 + public function _initialize()
  23 + {
  24 + parent::_initialize();
  25 + $this->model = new \app\admin\model\ItemDetails;
  26 + $this->view->assign("isSiftList", $this->model->getIsSiftList());
  27 + }
  28 +
  29 +
  30 +
  31 + /**
  32 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  33 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  34 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  35 + */
  36 +
  37 +
  38 + /**
  39 + * 查看
  40 + */
  41 + public function index()
  42 + {
  43 + //当前是否为关联查询
  44 + $this->relationSearch = true;
  45 + //设置过滤方法
  46 + $this->request->filter(['strip_tags', 'trim']);
  47 + if ($this->request->isAjax()) {
  48 + //如果发送的来源是Selectpage,则转发到Selectpage
  49 + if ($this->request->request('keyField')) {
  50 + return $this->selectpage();
  51 + }
  52 + list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  53 +
  54 + $list = $this->model
  55 + ->with(['team','item'])
  56 + ->where($where)
  57 + ->order($sort, $order)
  58 + ->paginate($limit);
  59 +
  60 + foreach ($list as $row) {
  61 +
  62 + $row->getRelation('team')->visible(['title']);
  63 + $row->getRelation('item')->visible(['title']);
  64 + }
  65 +
  66 + $result = array("total" => $list->total(), "rows" => $list->items());
  67 +
  68 + return json($result);
  69 + }
  70 + return $this->view->fetch();
  71 + }
  72 +
  73 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +
  7 +/**
  8 + * 学生积分记录管理
  9 + *
  10 + * @icon fa fa-circle-o
  11 + */
  12 +class StudyScoreLog extends Backend
  13 +{
  14 +
  15 + /**
  16 + * StudyScoreLog模型对象
  17 + * @var \app\admin\model\StudyScoreLog
  18 + */
  19 + protected $model = null;
  20 +
  21 + public function _initialize()
  22 + {
  23 + parent::_initialize();
  24 + $this->model = new \app\admin\model\StudyScoreLog;
  25 +
  26 + }
  27 +
  28 +
  29 +
  30 + /**
  31 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  32 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  33 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  34 + */
  35 +
  36 +
  37 +}
  1 +<?php
  2 +
  3 +return [
  4 + 'Item_id' => '项目id',
  5 + 'Images' => '图片',
  6 + 'Is_sift' => '是否为精选',
  7 + 'Is_sift 0' => '否',
  8 + 'Is_sift 1' => '是',
  9 + 'Team_id' => '所属战队',
  10 + 'Createtime' => '创建时间',
  11 + 'Updatetime' => '更新时间',
  12 + 'Team.title' => '战队昵称',
  13 + 'Item.title' => '名称'
  14 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => '积分',
  5 + 'Campus_id' => '校区id',
  6 + 'Item_id' => '项目id',
  7 + 'Study_id' => '学生id',
  8 + 'Team_id' => '战队id',
  9 + 'Score' => '积分',
  10 + 'Memo' => '备注',
  11 + 'Createtime' => '创建时间',
  12 + 'Updatetime' => '更新时间'
  13 +];
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +
  8 +class Item extends Model
  9 +{
  10 +
  11 +
  12 +
  13 +
  14 +
  15 + // 表名
  16 + protected $name = 'item';
  17 +
  18 + // 自动写入时间戳字段
  19 + protected $autoWriteTimestamp = 'integer';
  20 +
  21 + // 定义时间戳字段名
  22 + protected $createTime = 'createtime';
  23 + protected $updateTime = 'updatetime';
  24 + protected $deleteTime = false;
  25 +
  26 + // 追加属性
  27 + protected $append = [
  28 +
  29 + ];
  30 +
  31 +
  32 +
  33 +
  34 +
  35 +
  36 +
  37 +
  38 +
  39 +
  40 + public function user()
  41 + {
  42 + return $this->belongsTo('User', 'id', 'id', [], 'LEFT')->setEagerlyType(0);
  43 + }
  44 +
  45 +
  46 + public function ronda()
  47 + {
  48 + return $this->belongsTo('Ronda', 'ronda_id', 'id', [], 'LEFT')->setEagerlyType(0);
  49 + }
  50 +
  51 +
  52 + public function radar()
  53 + {
  54 + return $this->belongsTo('Radar', 'radar_id', 'id', [], 'LEFT')->setEagerlyType(0);
  55 + }
  56 +
  57 +
  58 + public function campus()
  59 + {
  60 + return $this->belongsTo('Campus', 'campus_id', 'id', [], 'LEFT')->setEagerlyType(0);
  61 + }
  62 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +
  8 +class ItemDetails extends Model
  9 +{
  10 +
  11 +
  12 +
  13 +
  14 +
  15 + // 表名
  16 + protected $name = 'item_details';
  17 +
  18 + // 自动写入时间戳字段
  19 + protected $autoWriteTimestamp = 'integer';
  20 +
  21 + // 定义时间戳字段名
  22 + protected $createTime = 'createtime';
  23 + protected $updateTime = 'updatetime';
  24 + protected $deleteTime = false;
  25 +
  26 + // 追加属性
  27 + protected $append = [
  28 + 'is_sift_text'
  29 + ];
  30 +
  31 +
  32 +
  33 + public function getIsSiftList()
  34 + {
  35 + return ['0' => __('Is_sift 0'), '1' => __('Is_sift 1')];
  36 + }
  37 +
  38 +
  39 + public function getIsSiftTextAttr($value, $data)
  40 + {
  41 + $value = $value ? $value : (isset($data['is_sift']) ? $data['is_sift'] : '');
  42 + $list = $this->getIsSiftList();
  43 + return isset($list[$value]) ? $list[$value] : '';
  44 + }
  45 +
  46 +
  47 +
  48 +
  49 + public function team()
  50 + {
  51 + return $this->belongsTo('Team', 'id', 'id', [], 'LEFT')->setEagerlyType(0);
  52 + }
  53 +
  54 +
  55 + public function item()
  56 + {
  57 + return $this->belongsTo('Item', 'item_id', 'id', [], 'LEFT')->setEagerlyType(0);
  58 + }
  59 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +
  8 +class StudyScoreLog extends Model
  9 +{
  10 +
  11 +
  12 +
  13 +
  14 +
  15 + // 表名
  16 + protected $name = 'study_score_log';
  17 +
  18 + // 自动写入时间戳字段
  19 + protected $autoWriteTimestamp = 'integer';
  20 +
  21 + // 定义时间戳字段名
  22 + protected $createTime = 'createtime';
  23 + protected $updateTime = 'updatetime';
  24 + protected $deleteTime = false;
  25 +
  26 + // 追加属性
  27 + protected $append = [
  28 +
  29 + ];
  30 +
  31 +
  32 +
  33 +
  34 +
  35 +
  36 +
  37 +
  38 +
  39 +
  40 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model\item\ronda;
  4 +
  5 +use think\Model;
  6 +
  7 +class Rel extends Model
  8 +{
  9 + // 表名
  10 + protected $name = 'item_ronda_rel';
  11 +
  12 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class IteamDetails extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class ItemDetails extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class ItemRondaRel extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class StudyScoreLog extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-title" class="form-control" name="row[title]" type="text">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Ronda_id')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <input id="c-ronda_id" data-rule="required" data-source="ronda/index" class="form-control selectpage" data-field="title" name="row[ronda_id]" type="text" value="">
  13 + </div>
  14 + </div>
  15 + <div class="form-group">
  16 + <label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <input id="c-campus_id" data-rule="required" data-source="campus/index" class="form-control selectpage" data-field="title" name="row[campus_id]" type="text" value="">
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <textarea id="c-details" class="form-control editor" rows="5" name="row[details]" cols="50"></textarea>
  25 + </div>
  26 + </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Radar_id')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 + <input id="c-radar_id" data-rule="required" data-source="radar/index" class="form-control selectpage" data-field="title" name="row[radar_id]" type="text" value="">
  31 + </div>
  32 + </div>
  33 + <div class="form-group">
  34 + <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
  35 + <div class="col-xs-12 col-sm-8">
  36 + <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
  37 + </div>
  38 + </div>
  39 + <div class="form-group">
  40 + <label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
  41 + <div class="col-xs-12 col-sm-8">
  42 + <input id="c-score" class="form-control" step="0.01" name="row[score]" type="number">
  43 + </div>
  44 + </div>
  45 + <div class="form-group layer-footer">
  46 + <label class="control-label col-xs-12 col-sm-2"></label>
  47 + <div class="col-xs-12 col-sm-8">
  48 + <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  49 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  50 + </div>
  51 + </div>
  52 +</form>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-title" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Ronda_id')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <input id="c-ronda_id" data-rule="required" data-source="ronda/index" class="form-control selectpage" name="row[ronda_id]" data-field="title" type="text" value="{$row.ronda_id|htmlentities}">
  13 + </div>
  14 + </div>
  15 + <div class="form-group">
  16 + <label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <input id="c-campus_id" data-rule="required" data-source="campus/index" class="form-control selectpage" name="row[campus_id]" data-field="title" type="text" value="{$row.campus_id|htmlentities}">
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <textarea id="c-details" class="form-control editor" rows="5" name="row[details]" cols="50">{$row.details|htmlentities}</textarea>
  25 + </div>
  26 + </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Radar_id')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 + <input id="c-radar_id" data-rule="required" data-source="radar/index" class="form-control selectpage" name="row[radar_id]" data-field="title" type="text" value="{$row.radar_id|htmlentities}">
  31 + </div>
  32 + </div>
  33 + <div class="form-group">
  34 + <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
  35 + <div class="col-xs-12 col-sm-8">
  36 + <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
  37 + </div>
  38 + </div>
  39 + <div class="form-group">
  40 + <label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
  41 + <div class="col-xs-12 col-sm-8">
  42 + <input id="c-score" class="form-control" step="0.01" name="row[score]" type="number" value="{$row.score|htmlentities}">
  43 + </div>
  44 + </div>
  45 + <div class="form-group layer-footer">
  46 + <label class="control-label col-xs-12 col-sm-2"></label>
  47 + <div class="col-xs-12 col-sm-8">
  48 + <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  49 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  50 + </div>
  51 + </div>
  52 +</form>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('item/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 +
  12 +
  13 + <div class="dropdown btn-group {:$auth->check('item/multi')?'':'hide'}">
  14 + <ul class="dropdown-menu text-left" role="menu">
  15 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  16 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
  17 + </ul>
  18 + </div>
  19 +
  20 +
  21 + </div>
  22 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  23 + data-operate-edit="{:$auth->check('item/edit')}"
  24 + data-operate-del="{:$auth->check('item/del')}"
  25 + width="100%">
  26 + </table>
  27 + </div>
  28 + </div>
  29 +
  30 + </div>
  31 + </div>
  32 +</div>
  1 +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-item_id" data-rule="required" data-source="item/index" class="form-control selectpage" data-field="title" name="row[item_id]" type="text" value="">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <div class="input-group">
  13 + <input id="c-images" class="form-control" size="50" name="row[images]" type="text">
  14 + <div class="input-group-addon no-border no-padding">
  15 + <span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  16 + <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  17 + </div>
  18 + <span class="msg-box n-right" for="c-images"></span>
  19 + </div>
  20 + <ul class="row list-inline faupload-preview" id="p-images"></ul>
  21 + </div>
  22 + </div>
  23 + <div class="form-group">
  24 + <label class="control-label col-xs-12 col-sm-2">{:__('Is_sift')}:</label>
  25 + <div class="col-xs-12 col-sm-8">
  26 +
  27 + <select id="c-is_sift" class="form-control selectpicker" name="row[is_sift]">
  28 + {foreach name="isSiftList" item="vo"}
  29 + <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
  30 + {/foreach}
  31 + </select>
  32 +
  33 + </div>
  34 + </div>
  35 + <div class="form-group">
  36 + <label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
  37 + <div class="col-xs-12 col-sm-8">
  38 + <input id="c-team_id" data-rule="required" data-source="team/index" class="form-control selectpage" data-field="title" name="row[team_id]" type="text" value="">
  39 + </div>
  40 + </div>
  41 + <div class="form-group layer-footer">
  42 + <label class="control-label col-xs-12 col-sm-2"></label>
  43 + <div class="col-xs-12 col-sm-8">
  44 + <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  45 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  46 + </div>
  47 + </div>
  48 +</form>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-item_id" data-rule="required" data-source="item/index" class="form-control selectpage" data-field="title" name="row[item_id]" type="text" value="{$row.item_id|htmlentities}">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <div class="input-group">
  13 + <input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}">
  14 + <div class="input-group-addon no-border no-padding">
  15 + <span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  16 + <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  17 + </div>
  18 + <span class="msg-box n-right" for="c-images"></span>
  19 + </div>
  20 + <ul class="row list-inline faupload-preview" id="p-images"></ul>
  21 + </div>
  22 + </div>
  23 + <div class="form-group">
  24 + <label class="control-label col-xs-12 col-sm-2">{:__('Is_sift')}:</label>
  25 + <div class="col-xs-12 col-sm-8">
  26 +
  27 + <select id="c-is_sift" class="form-control selectpicker" name="row[is_sift]">
  28 + {foreach name="isSiftList" item="vo"}
  29 + <option value="{$key}" {in name="key" value="$row.is_sift"}selected{/in}>{$vo}</option>
  30 + {/foreach}
  31 + </select>
  32 +
  33 + </div>
  34 + </div>
  35 + <div class="form-group">
  36 + <label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
  37 + <div class="col-xs-12 col-sm-8">
  38 + <input id="c-team_id" data-rule="required" data-source="team/index" class="form-control selectpage" data-field="title" name="row[team_id]" type="text" value="{$row.team_id|htmlentities}">
  39 + </div>
  40 + </div>
  41 + <div class="form-group layer-footer">
  42 + <label class="control-label col-xs-12 col-sm-2"></label>
  43 + <div class="col-xs-12 col-sm-8">
  44 + <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  45 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  46 + </div>
  47 + </div>
  48 +</form>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('item_details/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 +
  12 +
  13 + <div class="dropdown btn-group {:$auth->check('item_details/multi')?'':'hide'}">
  14 + <ul class="dropdown-menu text-left" role="menu">
  15 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  16 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
  17 + </ul>
  18 + </div>
  19 +
  20 +
  21 + </div>
  22 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  23 + data-operate-edit="{:$auth->check('item_details/edit')}"
  24 + data-operate-del="{:$auth->check('item_details/del')}"
  25 + width="100%">
  26 + </table>
  27 + </div>
  28 + </div>
  29 +
  30 + </div>
  31 + </div>
  32 +</div>
  1 +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-campus_id" data-rule="required" data-source="campus/index" data-field="title" class="form-control selectpage" name="row[campus_id]" type="text" value="">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <input id="c-item_id" data-rule="required" data-source="item/index" data-field="title" class="form-control selectpage" name="row[item_id]" type="text" value="">
  13 + </div>
  14 + </div>
  15 + <div class="form-group">
  16 + <label class="control-label col-xs-12 col-sm-2">{:__('Study_id')}:</label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <input id="c-study_id" data-rule="required" data-source="study/index" class="form-control selectpage" name="row[study_id]" type="text" value="">
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <input id="c-team_id" data-rule="required" data-source="team/index" data-field="title" class="form-control selectpage" name="row[team_id]" type="text" value="">
  25 + </div>
  26 + </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 + <input id="c-score" class="form-control" step="0.01" name="row[score]" type="number">
  31 + </div>
  32 + </div>
  33 + <div class="form-group">
  34 + <label class="control-label col-xs-12 col-sm-2">{:__('Memo')}:</label>
  35 + <div class="col-xs-12 col-sm-8">
  36 + <input id="c-memo" class="form-control" name="row[memo]" type="text">
  37 + </div>
  38 + </div>
  39 + <div class="form-group layer-footer">
  40 + <label class="control-label col-xs-12 col-sm-2"></label>
  41 + <div class="col-xs-12 col-sm-8">
  42 + <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  43 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  44 + </div>
  45 + </div>
  46 +</form>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-campus_id" data-rule="required" data-source="campus/index" class="form-control selectpage" name="row[campus_id]" type="text" value="{$row.campus_id|htmlentities}">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <input id="c-item_id" data-rule="required" data-source="item/index" class="form-control selectpage" name="row[item_id]" type="text" value="{$row.item_id|htmlentities}">
  13 + </div>
  14 + </div>
  15 + <div class="form-group">
  16 + <label class="control-label col-xs-12 col-sm-2">{:__('Study_id')}:</label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <input id="c-study_id" data-rule="required" data-source="study/index" class="form-control selectpage" name="row[study_id]" type="text" value="{$row.study_id|htmlentities}">
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <input id="c-team_id" data-rule="required" data-source="team/index" class="form-control selectpage" name="row[team_id]" type="text" value="{$row.team_id|htmlentities}">
  25 + </div>
  26 + </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 + <input id="c-score" class="form-control" step="0.01" name="row[score]" type="number" value="{$row.score|htmlentities}">
  31 + </div>
  32 + </div>
  33 + <div class="form-group">
  34 + <label class="control-label col-xs-12 col-sm-2">{:__('Memo')}:</label>
  35 + <div class="col-xs-12 col-sm-8">
  36 + <input id="c-memo" class="form-control" name="row[memo]" type="text" value="{$row.memo|htmlentities}">
  37 + </div>
  38 + </div>
  39 + <div class="form-group layer-footer">
  40 + <label class="control-label col-xs-12 col-sm-2"></label>
  41 + <div class="col-xs-12 col-sm-8">
  42 + <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  43 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  44 + </div>
  45 + </div>
  46 +</form>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('study_score_log/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 + <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('study_score_log/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
  12 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('study_score_log/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  13 +
  14 +
  15 + <div class="dropdown btn-group {:$auth->check('study_score_log/multi')?'':'hide'}">
  16 + <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
  17 + <ul class="dropdown-menu text-left" role="menu">
  18 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  19 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
  20 + </ul>
  21 + </div>
  22 +
  23 +
  24 + </div>
  25 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  26 + data-operate-edit="{:$auth->check('study_score_log/edit')}"
  27 + data-operate-del="{:$auth->check('study_score_log/del')}"
  28 + width="100%">
  29 + </table>
  30 + </div>
  31 + </div>
  32 +
  33 + </div>
  34 + </div>
  35 +</div>
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'item/index' + location.search,
  9 + add_url: 'item/add',
  10 + edit_url: 'item/edit',
  11 + del_url: 'item/del',
  12 + multi_url: 'item/multi',
  13 + import_url: 'item/import',
  14 + table: 'item',
  15 + }
  16 + });
  17 +
  18 + var table = $("#table");
  19 +
  20 + //顶部搜索栏
  21 + table.on('post-common-search.bs.table', function (event, table) {
  22 + var form = $("form", table.$commonsearch);
  23 + //类型名称
  24 + $("input[name='campus.title']", form).addClass("selectpage").data("source", "campus/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
  25 + //$("input[name='activity.title']", form).addClass("selectpage").data("source", "activity/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
  26 + $("input[name='title']", form).addClass("selectpage").data("source", "item/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
  27 + Form.events.cxselect(form);
  28 + Form.events.selectpage(form);
  29 + });
  30 +
  31 + // 初始化表格
  32 + table.bootstrapTable({
  33 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  34 + pk: 'id',
  35 + sortName: 'id',
  36 + fixedColumns: true,
  37 + fixedRightNumber: 1,
  38 + showToggle: false,//浏览模式功能关闭
  39 + showColumns: false,//显示隐藏列功能关闭
  40 + //commonSearch: false, //关闭通用搜索按钮
  41 + showExport: false,//导出功能关闭
  42 + clickToSelect: false, //是否启用点击选中
  43 + dblClickToEdit: false, //是否启用双击编辑
  44 + columns: [
  45 + [
  46 + {checkbox: true},
  47 + {field: 'id', title: __('Id'), operate: false},
  48 + // {field: 'campus_id', title: __('Campus_id')},
  49 + // {field: 'ronda_id', title: __('Ronda_id')},
  50 + {field: 'campus.title', title: __('所属校区'), operate: 'LIKE'},
  51 + {field: 'ronda.title', title: __('场次'), operate: false},
  52 + {field: 'title', title: __('Title'), operate: 'LIKE'},
  53 + // {field: 'radar_id', title: __('Radar_id')},
  54 + // {field: 'user_id', title: __('User_id')},
  55 + {field: 'score', title: __('可获积分'), operate:false},
  56 + {field: 'user.username', title: __('管理老师'), operate: false},
  57 + {field: 'user.teach_phone', title: __('User.teach_phone'), operate: false},
  58 + {field: 'radar.title', title: __('Radar.title'), operate: false},
  59 + {field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  60 + {
  61 + field: 'buttons',
  62 + width: "120px",
  63 + title: __('按钮组'),
  64 + table: table,
  65 + events: Table.api.events.operate,
  66 + buttons: [
  67 + {
  68 + name: 'detail',
  69 + text: __('弹出窗口打开'),
  70 + title: __('弹出窗口打开'),
  71 + classname: 'btn btn-xs btn-primary btn-dialog',
  72 + icon: 'fa fa-list',
  73 + url: 'study_score_log/add',
  74 + callback: function (data) {
  75 + Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  76 + },
  77 + }
  78 + ],
  79 + formatter: Table.api.formatter.buttons
  80 + },
  81 + //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  82 + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  83 + ]
  84 + ]
  85 + });
  86 +
  87 + // 为表格绑定事件
  88 + Table.api.bindevent(table);
  89 + },
  90 + add: function () {
  91 + Controller.api.bindevent();
  92 + },
  93 + edit: function () {
  94 + Controller.api.bindevent();
  95 + },
  96 + api: {
  97 + bindevent: function () {
  98 + Form.api.bindevent($("form[role=form]"));
  99 + }
  100 + }
  101 + };
  102 + return Controller;
  103 +});
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'item_details/index' + location.search,
  9 + add_url: 'item_details/add',
  10 + edit_url: 'item_details/edit',
  11 + del_url: 'item_details/del',
  12 + multi_url: 'item_details/multi',
  13 + import_url: 'item_details/import',
  14 + table: 'item_details',
  15 + }
  16 + });
  17 +
  18 + var table = $("#table");
  19 +
  20 + //顶部搜索栏
  21 + table.on('post-common-search.bs.table', function (event, table) {
  22 + var form = $("form", table.$commonsearch);
  23 + //类型名称
  24 + $("input[name='item.title']", form).addClass("selectpage").data("source", "item/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
  25 + $("input[name='team.title']", form).addClass("selectpage").data("source", "team/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
  26 + Form.events.cxselect(form);
  27 + Form.events.selectpage(form);
  28 + });
  29 + // 初始化表格
  30 + table.bootstrapTable({
  31 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  32 + pk: 'id',
  33 + sortName: 'id',
  34 + showToggle: false,//浏览模式功能关闭
  35 + showColumns: false,//显示隐藏列功能关闭
  36 + //commonSearch: false, //关闭通用搜索按钮
  37 + showExport: false,//导出功能关闭
  38 + clickToSelect: false, //是否启用点击选中
  39 + dblClickToEdit: false, //是否启用双击编辑
  40 + columns: [
  41 + [
  42 + {checkbox: true},
  43 + {field: 'id', title: __('Id'), operate: false},
  44 + //{field: 'item_id', title: __('Item_id')},
  45 + {field: 'item.title', title: __('项目名称'), operate: 'LIKE'},
  46 + {field: 'team.title', title: __('所属战队'), operate: 'LIKE'},
  47 + {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  48 + {field: 'is_sift', title: __('Is_sift'), operate: false, searchList: {"0":__('Is_sift 0'),"1":__('Is_sift 1')},formatter:Table.api.formatter.toggle},
  49 + //{field: 'team_id', title: __('Team_id')},
  50 + {field: 'createtime', title: __('Createtime'), operate: false,addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  51 + //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  52 + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  53 + ]
  54 + ]
  55 + });
  56 +
  57 + // 为表格绑定事件
  58 + Table.api.bindevent(table);
  59 + },
  60 + add: function () {
  61 + Controller.api.bindevent();
  62 + },
  63 + edit: function () {
  64 + Controller.api.bindevent();
  65 + },
  66 + api: {
  67 + bindevent: function () {
  68 + Form.api.bindevent($("form[role=form]"));
  69 + }
  70 + }
  71 + };
  72 + return Controller;
  73 +});
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'study_score_log/index' + location.search,
  9 + add_url: 'study_score_log/add',
  10 + edit_url: 'study_score_log/edit',
  11 + del_url: 'study_score_log/del',
  12 + multi_url: 'study_score_log/multi',
  13 + import_url: 'study_score_log/import',
  14 + table: 'study_score_log',
  15 + }
  16 + });
  17 +
  18 + var table = $("#table");
  19 +
  20 + // 初始化表格
  21 + table.bootstrapTable({
  22 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  23 + pk: 'id',
  24 + sortName: 'id',
  25 + columns: [
  26 + [
  27 + {checkbox: true},
  28 + {field: 'id', title: __('Id')},
  29 + {field: 'campus_id', title: __('Campus_id')},
  30 + {field: 'item_id', title: __('Item_id')},
  31 + {field: 'study_id', title: __('Study_id')},
  32 + {field: 'team_id', title: __('Team_id')},
  33 + {field: 'score', title: __('Score'), operate:'BETWEEN'},
  34 + {field: 'memo', title: __('Memo'), operate: 'LIKE'},
  35 + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36 + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37 + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  38 + ]
  39 + ]
  40 + });
  41 +
  42 + // 为表格绑定事件
  43 + Table.api.bindevent(table);
  44 + },
  45 + add: function () {
  46 + Controller.api.bindevent();
  47 + },
  48 + edit: function () {
  49 + Controller.api.bindevent();
  50 + },
  51 + api: {
  52 + bindevent: function () {
  53 + Form.api.bindevent($("form[role=form]"));
  54 + }
  55 + }
  56 + };
  57 + return Controller;
  58 +});