作者 开飞机的舒克

后台优化

{"files":[],"license":"regular","licenseto":"10789","licensekey":"zOyxKJsHuBg8Dq0T K2PTlnRQJF6Ewtd6XhP14A==","domains":["campus.cn"],"licensecodes":[],"validations":["c51a74160ee0aa6a19729b33d4a9fcdc"]}
\ No newline at end of file
... ...
<?php
namespace addons\captcha;
use app\common\library\Menu;
use think\Addons;
/**
* 动态验证码插件
*/
class Captcha extends Addons
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
return true;
}
/**
* 插件启用方法
* @return bool
*/
public function enable()
{
return true;
}
/**
* 插件禁用方法
* @return bool
*/
public function disable()
{
return true;
}
/**
* 实现钩子方法
* @return mixed
*/
public function appInit($param)
{
\think\Route::get('captcha/[:id]', "\\think\\addons\\Route@execute?addon=captcha&controller=index&action=build");
}
}
... ...
<?php
return [
[
'name' => 'random',
'title' => '验证码字库',
'type' => 'string',
'content' => [],
'value' => '012345678',
'rule' => '',
'msg' => '',
'tip' => '默认使用英文加数字的组合,你在此可以自定义验证码字库',
'ok' => '',
'extend' => '',
],
[
'name' => 'is_gif',
'title' => '是否动图',
'type' => 'radio',
'content' => [
1 => '是',
0 => '否',
],
'value' => '1',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'gif_fps',
'title' => '动图帧数',
'type' => 'number',
'content' => [],
'value' => '10',
'rule' => 'required',
'msg' => '',
'tip' => 'GIF动图的帧数,默认为10帧',
'ok' => '',
'extend' => '',
],
];
... ...
<?php
namespace addons\captcha\controller;
use addons\captcha\library\Captcha;
use think\addons\Controller;
use think\Session;
class Index extends Controller
{
public function index()
{
$this->error("当前插件暂无前台页面");
}
public function build()
{
$id = $this->request->param('id', '');
$config = get_addon_config('captcha');
/* 实例化 */
$captcha = new Captcha();
// 验证码宽度
$captcha->width = config('captcha.imageW');
// 验证码高度
$captcha->height = config('captcha.imageH');
// 验证码个数
$captcha->nums = config('captcha.length');
// 随机字符串
if (isset($config['random']) && $config['random']) {
$captcha->random = $config['random'];
}
// 随机数大小
$captcha->font_size = config('captcha.fontSize');
// 字体路径
//$ver->font_path = __DIR__.'/Font/zhankukuhei.ttf';
// 是否为动态验证码
$captcha->is_gif = isset($config['is_gif']) ? $config['is_gif'] : true;
// 动图帧数
$captcha->gif_fps = $config['gif_fps'] ? $config['gif_fps'] : 10;
/* 生成验证码 */
$code = $captcha->getCode();
$originCaptcha = new \think\captcha\Captcha();
// 保存验证码
$key = $this->authcode($originCaptcha->seKey, $originCaptcha->seKey);
$secode = [];
$secode['verify_code'] = $this->authcode(mb_strtoupper($code), $originCaptcha->seKey); // 把校验码保存到session
$secode['verify_time'] = time(); // 验证码创建时间
Session::set($key . $id, $secode, '');
/* 生成验证码图片 */
$captcha->doImg($code);
}
/* 加密验证码 */
private function authcode($str, $seKey)
{
$key = substr(md5($seKey), 5, 8);
$str = substr(md5($str), 8, 10);
return md5($key . $str);
}
}
... ...
name = captcha
title = 动态验证码
intro = 将默认的验证码切换为动态验证码
author = Karson
website = https://www.fastadmin.net
version = 1.0.0
state = 1
url = /addons/captcha
license = regular
licenseto = 10789
... ...
<?php
namespace addons\captcha\library;
use addons\captcha\library\gif\GIFEncoder;
/*
* 验证码类库
* @Author: lovefc
* @Email:fcphp@qq.com
* @Date: 2019-09-27 14:35:05
* @Last Modified by: lovefc
* @Last Modified time: 2019-09-28 15:28:20
*/
class Captcha
{
// 验证码宽度
public $width = 200;
// 验证码高度
public $height = 60;
// 验证码个数
public $nums = 4;
// 随机字符串
public $random = '2345689zxcvbnmasdfhjkqwertyup';
// 随机数大小
public $font_size = 36;
// 字体路径
public $font_path = __DIR__.'/font/zhankukuhei.ttf';
// 是否为动态验证码
public $is_gif = true;
// 动图帧数
public $gif_fps = 10;
/**
* 获取验证码
*
* @return void
*/
public function getCode()
{
return $this->code = strtolower($this->setVerNumber());
}
/**
* 生成验证码
*
* @param integer $w 宽度
* @param integer $h 高度
* @param integer $nums 数量
* @param string $random 随机字符串
* @return void
*/
public function doImg($code = '')
{
if (!$code) {
return false;
}
$code = strtoupper($code);
$imagedata = [];
if ($this->is_gif) {
for ($i = 0; $i < $this->gif_fps; $i++) {
$imagedata[] = $this->creBackGIF($code);
++$i;
}
} else {
$imagedata[] = $this->creBackGIF($code);
}
$gif = new GIFEncoder($imagedata);
header('Content-type:image/gif');
echo $gif->GetAnimation();
exit;
}
/**
* 创建动态背景
*
* @return void
*/
private function creBackGIF($code)
{
ob_start();
$im = $this->createImageSource();
$this->setBackGroundColor($im);
$this->setCode($im, $code);
$this->setRandomCode($im);
imagegif($im);
imagedestroy($im);
$imagedata = ob_get_contents();
ob_clean();
return $imagedata;
}
/**
* 创建个画布
*
* @return void
*/
private function createImageSource()
{
return imagecreate($this->width, $this->height);
}
/**
* 设置背景颜色
*
* @param [type] $im
* @return void
*/
private function setBackGroundColor($im)
{
$bgcolor = imagecolorallocate($im, rand(200, 255), rand(200, 255), rand(200, 255));
imagefill($im, 0, 0, $bgcolor);
}
/**
* 加入随机数
*
* @param [type] $im
* @return string
*/
private function setRandomCode($im)
{
$count_h = $this->height;
$cou = floor($count_h * 1);
for ($i = 0; $i < $cou; $i++) {
$x = rand(0, $this->width);
$y = rand(0, $this->height);
$jiaodu = rand(0, 360); //设置角度
$fonturl = $this->font_path; //使用的字体
// 检测中文
if (preg_match("/[\x7f-\xff]/", $this->random)) {
$fontsize = $this->font_size / 4;
$dscode = $this->getChar(1);
} else {
$size = $this->font_size / 3.5;
$fontsize = rand($size, $size + 3);
$originalcode = 'zxcvbnmasdfghjklqwertyuiop1234567890'; //随机字符串
$countdistrub = mb_strlen($originalcode);
$dscode = $originalcode[rand(0, $countdistrub - 1)];
}
$color = imagecolorallocate($im, rand(40, 140), rand(40, 140), rand(40, 140));
imagettftext($im, $fontsize, $jiaodu, $x, $y, $color, $fonturl, $dscode);
}
}
/**
* 随机中文字符串
*
* @param [type] $num 返回数量
* @return string
*/
private function getChar($num)
{
$b = '';
for ($i = 0; $i < $num; $i++) {
// 使用chr()函数拼接双字节汉字,前一个chr()为高位字节,后一个为低位字节
$a = chr(mt_rand(0xB0, 0xD0)) . chr(mt_rand(0xA1, 0xF0));
// 转码
$b .= iconv('GB2312', 'UTF-8', $a);
}
return $b;
}
/**
* 画布上生成验证码
*
* @param [type] $im
* @param [type] $string
* @return void
*/
private function setCode($im, $string)
{
$width = $this->width;
$height = $this->height;
$len = 1;
$start = 0;
$strlen = $count = mb_strlen($string, 'utf-8');
while ($strlen) {
$array[] = mb_substr($string, $start, $len, "utf8");
$string = mb_substr($string, $len, $strlen, "utf8");
$strlen = mb_strlen($string);
}
$y = floor($height / 2) + floor($height / 4);
$fontsize = rand($this->font_size - 2, $this->font_size);
$fonturl = $this->font_path;
$counts = $count;
for ($i = 0; $i < $counts; $i++) {
$char = $array[$i];
$x = floor($width / $counts) * $i + ($width / 15);
$jiaodu = rand(-30, 30);
$color = imagecolorallocate($im, rand(0, 50), rand(50, 100), rand(100, 140));
imagettftext($im, $fontsize, $jiaodu, $x, $y, $color, $fonturl, $char);
}
}
/**
* 生成随机码,(支持中文)
*
* @return void
*/
private function setVerNumber()
{
$len = 1;
$start = 0;
$string = $this->random;
$strlen = $num = mb_strlen($string, 'utf-8');
while ($strlen) {
$array[] = mb_substr($string, $start, $len, "utf-8");
$string = mb_substr($string, $len, $strlen, "utf-8");
$strlen = mb_strlen($string, 'utf-8');
}
$originalcode = $array;
$_dscode = "";
$counts = $this->nums;
for ($j = 0; $j < $counts; $j++) {
$rand = rand(0, $num - 1);
$dscode = $originalcode[$rand];
$_dscode .= $dscode;
}
return $_dscode;
}
}
... ...
<?php
namespace addons\captcha\library\gif;
/*
* GIF 合成类库
* @Author: Anonymous
* @Date: 2019-09-28 13:35:44
* @Last Modified by: lovefc
* @Last Modified time: 2019-09-28 13:37:09
*/
class GIFEncoder
{
public $GIF = "GIF89a";
public $VER = "GIFEncoder V2.06";
public $BUF = array();
public $LOP = 0;
public $DIS = 2;
public $COL = -1;
public $IMG = -1;
public $ERR = array(
'ERR00' => "Does not supported public function for only one image!",
'ERR01' => "Source is not a GIF image!",
'ERR02' => "Unintelligible flag ",
'ERR03' => "Could not make animation from animated GIF source",
);
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')
{
if (!is_array($GIF_src) && !is_array($GIF_tim)) {
printf("%s: %s", $this->VER, $this->ERR['ERR00']);
exit(0);
}
$this->LOP = ($GIF_lop > -1) ? $GIF_lop : 0;
$this->DIS = ($GIF_dis > -1) ? (($GIF_dis < 3) ? $GIF_dis : 3) : 2;
$this->COL = ($GIF_red > -1 && $GIF_grn > -1 && $GIF_blu > -1) ? ($GIF_red | ($GIF_grn << 8) | ($GIF_blu << 16)) : -1;
for ($i = 0, $src_count = count($GIF_src); $i < $src_count; $i++) {
if (strToLower($GIF_mod) == "url") {
$this->BUF[] = fread(fopen($GIF_src[$i], "rb"), filesize($GIF_src[$i]));
} elseif (strToLower($GIF_mod) == "bin") {
$this->BUF[] = $GIF_src[$i];
} else {
printf("%s: %s(%s)!", $this->VER, $this->ERR['ERR02'], $GIF_mod);
exit(0);
}
if (substr($this->BUF[$i], 0, 6) != "GIF87a" && substr($this->BUF[$i], 0, 6) != "GIF89a") {
printf("%s: %d %s", $this->VER, $i, $this->ERR['ERR01']);
exit(0);
}
for ($j = (13 + 3 * (2 << (ord($this->BUF[$i]{
10}) & 0x07))), $k = TRUE; $k; $j++) {
switch ($this->BUF[$i]{
$j}) {
case "!":
if ((substr($this->BUF[$i], ($j + 3), 8)) == "NETSCAPE") {
printf("%s: %s(%s source)!", $this->VER, $this->ERR['ERR03'], ($i + 1));
exit(0);
}
break;
case ";":
$k = FALSE;
break;
}
}
}
GIFEncoder::GIFAddHeader();
for ($i = 0, $count_buf = count($this->BUF); $i < $count_buf; $i++) {
GIFEncoder::GIFAddFrames($i, $GIF_dly[$i]);
}
GIFEncoder::GIFAddFooter();
}
public function GIFAddHeader()
{
$cmap = 0;
if (ord($this->BUF[0]{
10}) & 0x80) {
$cmap = 3 * (2 << (ord($this->BUF[0]{
10}) & 0x07));
$this->GIF .= substr($this->BUF[0], 6, 7);
$this->GIF .= substr($this->BUF[0], 13, $cmap);
$this->GIF .= "!\377\13NETSCAPE2.0\3\1" . GIFEncoder::GIFWord($this->LOP) . "\0";
}
}
public function GIFAddFrames($i, $d)
{
$Locals_str = 13 + 3 * (2 << (ord($this->BUF[$i]{
10}) & 0x07));
$Locals_end = strlen($this->BUF[$i]) - $Locals_str - 1;
$Locals_tmp = substr($this->BUF[$i], $Locals_str, $Locals_end);
$Global_len = 2 << (ord($this->BUF[0]{
10}) & 0x07);
$Locals_len = 2 << (ord($this->BUF[$i]{
10}) & 0x07);
$Global_rgb = substr($this->BUF[0], 13, 3 * (2 << (ord($this->BUF[0]{
10}) & 0x07)));
$Locals_rgb = substr($this->BUF[$i], 13, 3 * (2 << (ord($this->BUF[$i]{
10}) & 0x07)));
$Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 0) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0";
if ($this->COL > -1 && ord($this->BUF[$i]{
10}) & 0x80) {
for ($j = 0; $j < (2 << (ord($this->BUF[$i]{
10}) & 0x07)); $j++) {
if (ord($Locals_rgb{
3 * $j + 0}) == ($this->COL >> 0) & 0xFF && ord($Locals_rgb{
3 * $j + 1}) == ($this->COL >> 8) & 0xFF && ord($Locals_rgb{
3 * $j + 2}) == ($this->COL >> 16) & 0xFF) {
$Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 1) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0";
break;
}
}
}
switch ($Locals_tmp{
0}) {
case "!":
$Locals_img = substr($Locals_tmp, 8, 10);
$Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
break;
case ",":
$Locals_img = substr($Locals_tmp, 0, 10);
$Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
break;
}
if (ord($this->BUF[$i]{
10}) & 0x80 && $this->IMG > -1) {
if ($Global_len == $Locals_len) {
if (GIFEncoder::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
$this->GIF .= ($Locals_ext . $Locals_img . $Locals_tmp);
} else {
$byte = ord($Locals_img{
9});
$byte |= 0x80;
$byte &= 0xF8;
$byte |= (ord($this->BUF[0]{
10}) & 0x07);
$Locals_img{
9} = chr($byte);
$this->GIF .= ($Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp);
}
} else {
$byte = ord($Locals_img{
9});
$byte |= 0x80;
$byte &= 0xF8;
$byte |= (ord($this->BUF[$i]{
10}) & 0x07);
$Locals_img{
9} = chr($byte);
$this->GIF .= ($Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp);
}
} else {
$this->GIF .= ($Locals_ext . $Locals_img . $Locals_tmp);
}
$this->IMG = 1;
}
public function GIFAddFooter()
{
$this->GIF .= ";";
}
public function GIFBlockCompare($GlobalBlock, $LocalBlock, $Len)
{
for ($i = 0; $i < $Len; $i++) {
if ($GlobalBlock{
3 * $i + 0} != $LocalBlock{
3 * $i + 0} || $GlobalBlock{
3 * $i + 1} != $LocalBlock{
3 * $i + 1} || $GlobalBlock{
3 * $i + 2} != $LocalBlock{
3 * $i + 2}) {
return (0);
}
}
return (1);
}
public function GIFWord($int)
{
return (chr($int & 0xFF) . chr(($int >> 8) & 0xFF));
}
public function GetAnimation()
{
return ($this->GIF);
}
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 项目管理
*
* @icon fa fa-circle-o
*/
class Item extends Backend
{
/**
* Item模型对象
* @var \app\admin\model\Item
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Item;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['user','ronda','radar','campus'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('user')->visible(['username','teach_phone']);
$row->getRelation('ronda')->visible(['title']);
$row->getRelation('radar')->visible(['title']);
$row->getRelation('campus')->visible(['title']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 项目详情表
*
* @icon fa fa-circle-o
*/
class ItemDetails extends Backend
{
/**
* ItemDetails模型对象
* @var \app\admin\model\ItemDetails
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\ItemDetails;
$this->view->assign("isSiftList", $this->model->getIsSiftList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['team','item'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('team')->visible(['title']);
$row->getRelation('item')->visible(['title']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 学生积分记录管理
*
* @icon fa fa-circle-o
*/
class StudyScoreLog extends Backend
{
/**
* StudyScoreLog模型对象
* @var \app\admin\model\StudyScoreLog
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\StudyScoreLog;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
return [
'Item_id' => '项目id',
'Images' => '图片',
'Is_sift' => '是否为精选',
'Is_sift 0' => '否',
'Is_sift 1' => '是',
'Team_id' => '所属战队',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Team.title' => '战队昵称',
'Item.title' => '名称'
];
... ...
<?php
return [
'Id' => '积分',
'Campus_id' => '校区id',
'Item_id' => '项目id',
'Study_id' => '学生id',
'Team_id' => '战队id',
'Score' => '积分',
'Memo' => '备注',
'Createtime' => '创建时间',
'Updatetime' => '更新时间'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class Item extends Model
{
// 表名
protected $name = 'item';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
public function user()
{
return $this->belongsTo('User', 'id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function ronda()
{
return $this->belongsTo('Ronda', 'ronda_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function radar()
{
return $this->belongsTo('Radar', 'radar_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function campus()
{
return $this->belongsTo('Campus', 'campus_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class ItemDetails extends Model
{
// 表名
protected $name = 'item_details';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'is_sift_text'
];
public function getIsSiftList()
{
return ['0' => __('Is_sift 0'), '1' => __('Is_sift 1')];
}
public function getIsSiftTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['is_sift']) ? $data['is_sift'] : '');
$list = $this->getIsSiftList();
return isset($list[$value]) ? $list[$value] : '';
}
public function team()
{
return $this->belongsTo('Team', 'id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function item()
{
return $this->belongsTo('Item', 'item_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class StudyScoreLog extends Model
{
// 表名
protected $name = 'study_score_log';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
<?php
namespace app\admin\model\item\ronda;
use think\Model;
class Rel extends Model
{
// 表名
protected $name = 'item_ronda_rel';
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class IteamDetails extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class ItemDetails extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class ItemRondaRel extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class StudyScoreLog extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-title" class="form-control" name="row[title]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Ronda_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-details" class="form-control editor" rows="5" name="row[details]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Radar_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" class="form-control" step="0.01" name="row[score]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-title" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Ronda_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-details" class="form-control editor" rows="5" name="row[details]" cols="50">{$row.details|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Radar_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" class="form-control" step="0.01" name="row[score]" type="number" value="{$row.score|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('item/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<div class="dropdown btn-group {:$auth->check('item/multi')?'':'hide'}">
<ul class="dropdown-menu text-left" role="menu">
<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>
<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>
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('item/edit')}"
data-operate-del="{:$auth->check('item/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-images" class="form-control" size="50" name="row[images]" type="text">
<div class="input-group-addon no-border no-padding">
<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>
<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>
</div>
<span class="msg-box n-right" for="c-images"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-images"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_sift')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-is_sift" class="form-control selectpicker" name="row[is_sift]">
{foreach name="isSiftList" item="vo"}
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}">
<div class="input-group-addon no-border no-padding">
<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>
<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>
</div>
<span class="msg-box n-right" for="c-images"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-images"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_sift')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-is_sift" class="form-control selectpicker" name="row[is_sift]">
{foreach name="isSiftList" item="vo"}
<option value="{$key}" {in name="key" value="$row.is_sift"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<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>
<div class="dropdown btn-group {:$auth->check('item_details/multi')?'':'hide'}">
<ul class="dropdown-menu text-left" role="menu">
<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>
<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>
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('item_details/edit')}"
data-operate-del="{:$auth->check('item_details/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Study_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-study_id" data-rule="required" data-source="study/index" class="form-control selectpage" name="row[study_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" class="form-control" step="0.01" name="row[score]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Memo')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-memo" class="form-control" name="row[memo]" type="text">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Item_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Study_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" class="form-control" step="0.01" name="row[score]" type="number" value="{$row.score|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Memo')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-memo" class="form-control" name="row[memo]" type="text" value="{$row.memo|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<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>
<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>
<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>
<div class="dropdown btn-group {:$auth->check('study_score_log/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<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>
<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>
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('study_score_log/edit')}"
data-operate-del="{:$auth->check('study_score_log/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'item/index' + location.search,
add_url: 'item/add',
edit_url: 'item/edit',
del_url: 'item/del',
multi_url: 'item/multi',
import_url: 'item/import',
table: 'item',
}
});
var table = $("#table");
//顶部搜索栏
table.on('post-common-search.bs.table', function (event, table) {
var form = $("form", table.$commonsearch);
//类型名称
$("input[name='campus.title']", form).addClass("selectpage").data("source", "campus/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
//$("input[name='activity.title']", form).addClass("selectpage").data("source", "activity/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
$("input[name='title']", form).addClass("selectpage").data("source", "item/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
Form.events.cxselect(form);
Form.events.selectpage(form);
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
showToggle: false,//浏览模式功能关闭
showColumns: false,//显示隐藏列功能关闭
//commonSearch: false, //关闭通用搜索按钮
showExport: false,//导出功能关闭
clickToSelect: false, //是否启用点击选中
dblClickToEdit: false, //是否启用双击编辑
columns: [
[
{checkbox: true},
{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: 'title', title: __('Title'), operate: 'LIKE'},
// {field: 'radar_id', title: __('Radar_id')},
// {field: 'user_id', title: __('User_id')},
{field: 'score', title: __('可获积分'), operate:false},
{field: 'user.username', title: __('管理老师'), operate: false},
{field: 'user.teach_phone', title: __('User.teach_phone'), operate: false},
{field: 'radar.title', title: __('Radar.title'), operate: false},
{field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'buttons',
width: "120px",
title: __('按钮组'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'detail',
text: __('弹出窗口打开'),
title: __('弹出窗口打开'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'study_score_log/add',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
},
}
],
formatter: Table.api.formatter.buttons
},
//{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'item_details/index' + location.search,
add_url: 'item_details/add',
edit_url: 'item_details/edit',
del_url: 'item_details/del',
multi_url: 'item_details/multi',
import_url: 'item_details/import',
table: 'item_details',
}
});
var table = $("#table");
//顶部搜索栏
table.on('post-common-search.bs.table', function (event, table) {
var form = $("form", table.$commonsearch);
//类型名称
$("input[name='item.title']", form).addClass("selectpage").data("source", "item/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
$("input[name='team.title']", form).addClass("selectpage").data("source", "team/index").data("primaryKey", "id").data("field", "title").data("orderBy", "id desc");
Form.events.cxselect(form);
Form.events.selectpage(form);
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
showToggle: false,//浏览模式功能关闭
showColumns: false,//显示隐藏列功能关闭
//commonSearch: false, //关闭通用搜索按钮
showExport: false,//导出功能关闭
clickToSelect: false, //是否启用点击选中
dblClickToEdit: false, //是否启用双击编辑
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'), operate: false},
//{field: 'item_id', title: __('Item_id')},
{field: 'item.title', title: __('项目名称'), operate: 'LIKE'},
{field: 'team.title', title: __('所属战队'), operate: 'LIKE'},
{field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'is_sift', title: __('Is_sift'), operate: false, searchList: {"0":__('Is_sift 0'),"1":__('Is_sift 1')},formatter:Table.api.formatter.toggle},
//{field: 'team_id', title: __('Team_id')},
{field: 'createtime', title: __('Createtime'), operate: false,addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
//{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'study_score_log/index' + location.search,
add_url: 'study_score_log/add',
edit_url: 'study_score_log/edit',
del_url: 'study_score_log/del',
multi_url: 'study_score_log/multi',
import_url: 'study_score_log/import',
table: 'study_score_log',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'campus_id', title: __('Campus_id')},
{field: 'item_id', title: __('Item_id')},
{field: 'study_id', title: __('Study_id')},
{field: 'team_id', title: __('Team_id')},
{field: 'score', title: __('Score'), operate:'BETWEEN'},
{field: 'memo', title: __('Memo'), operate: 'LIKE'},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
... ...