Merge branch 'develop' of gitee.com:karson/fastadmin into develop

pull/406/head
Karson 2022-05-27 15:30:18 +08:00
commit 378aad4409
12 changed files with 1280 additions and 1288 deletions

View File

@ -9,12 +9,16 @@ use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xls; use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Csv; use PhpOffice\PhpSpreadsheet\Reader\Csv;
use think\Db; use think\Db;
use think\db\exception\BindParamException;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\exception\PDOException; use think\exception\PDOException;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\response\Json;
trait Backend trait Backend
{ {
/** /**
* 排除前台提交过来的字段 * 排除前台提交过来的字段
* @param $params * @param $params
@ -24,115 +28,114 @@ trait Backend
{ {
if (is_array($this->excludeFields)) { if (is_array($this->excludeFields)) {
foreach ($this->excludeFields as $field) { foreach ($this->excludeFields as $field) {
if (key_exists($field, $params)) { if (array_key_exists($field, $params)) {
unset($params[$field]); unset($params[$field]);
} }
} }
} else { } else if (array_key_exists($this->excludeFields, $params)) {
if (key_exists($this->excludeFields, $params)) { unset($params[$this->excludeFields]);
unset($params[$this->excludeFields]);
}
} }
return $params; return $params;
} }
/** /**
* 查看 * 查看
*
* @return string|Json
* @throws \think\Exception
* @throws DbException
*/ */
public function index() public function index()
{ {
//设置过滤方法 //设置过滤方法
$this->request->filter(['strip_tags', 'trim']); $this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) { if (false === $this->request->isAjax()) {
//如果发送的来源是Selectpage则转发到Selectpage return $this->view->fetch();
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
} }
return $this->view->fetch(); //如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
} }
/** /**
* 回收站 * 回收站
*
* @return string|Json
* @throws \think\Exception
*/ */
public function recyclebin() public function recyclebin()
{ {
//设置过滤方法 //设置过滤方法
$this->request->filter(['strip_tags', 'trim']); $this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) { if (false === $this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); return $this->view->fetch();
$list = $this->model
->onlyTrashed()
->where($where)
->order($sort, $order)
->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
} }
return $this->view->fetch(); [$where, $sort, $order, $offset, $limit] = $this->buildparams();
$list = $this->model
->onlyTrashed()
->where($where)
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
} }
/** /**
* 添加 * 添加
*
* @return string
* @throws \think\Exception
*/ */
public function add() public function add()
{ {
if ($this->request->isPost()) { if (false === $this->request->isPost()) {
$params = $this->request->post("row/a"); return $this->view->fetch();
if ($params) { }
$params = $this->preExcludeFields($params); $params = $this->request->post('row/a');
if (empty($params)) {
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were inserted'));
}
}
$this->error(__('Parameter %s can not be empty', '')); $this->error(__('Parameter %s can not be empty', ''));
} }
return $this->view->fetch(); $params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
} }
/** /**
* 编辑 * 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/ */
public function edit($ids = null) public function edit($ids = null)
{ {
@ -141,137 +144,132 @@ trait Backend
$this->error(__('No Results were found')); $this->error(__('No Results were found'));
} }
$adminIds = $this->getDataLimitAdminIds(); $adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) { if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) { $this->error(__('You have no permission'));
$this->error(__('You have no permission'));
}
} }
if ($this->request->isPost()) { if (false === $this->request->isPost()) {
$params = $this->request->post("row/a"); $this->view->assign('row', $row);
if ($params) { return $this->view->fetch();
$params = $this->preExcludeFields($params); }
$result = false; $params = $this->request->post('row/a');
Db::startTrans(); if (empty($params)) {
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', '')); $this->error(__('Parameter %s can not be empty', ''));
} }
$this->view->assign("row", $row); $params = $this->preExcludeFields($params);
return $this->view->fetch(); $result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
} }
/** /**
* 删除 * 删除
*
* @param $ids
* @return void
* @throws DbException
* @throws DataNotFoundException
* @throws ModelNotFoundException
*/ */
public function del($ids = "") public function del($ids = null)
{ {
if (!$this->request->isPost()) { if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
if ($ids) { if (empty($ids)) {
$pk = $this->model->getPk(); $this->error(__('Parameter %s can not be empty', 'ids'));
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
$this->model->where($this->dataLimitField, 'in', $adminIds);
}
$list = $this->model->where($pk, 'in', $ids)->select();
$count = 0;
Db::startTrans();
try {
foreach ($list as $k => $v) {
$count += $v->delete();
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
} else {
$this->error(__('No rows were deleted'));
}
} }
$this->error(__('Parameter %s can not be empty', 'ids'));
}
/**
* 真实删除
*/
public function destroy($ids = "")
{
if (!$this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
$ids = $ids ? $ids : $this->request->post("ids");
$pk = $this->model->getPk(); $pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds(); $adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) { if (is_array($adminIds)) {
$this->model->where($this->dataLimitField, 'in', $adminIds); $this->model->where($this->dataLimitField, 'in', $adminIds);
} }
if ($ids) { $list = $this->model->where($pk, 'in', $ids)->select();
$this->model->where($pk, 'in', $ids);
}
$count = 0; $count = 0;
Db::startTrans(); Db::startTrans();
try { try {
$list = $this->model->onlyTrashed()->select(); foreach ($list as $item) {
foreach ($list as $k => $v) { $count += $item->delete();
$count += $v->delete(true);
} }
Db::commit(); Db::commit();
} catch (PDOException $e) { } catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback(); Db::rollback();
$this->error($e->getMessage()); $this->error($e->getMessage());
} }
if ($count) { if ($count) {
$this->success(); $this->success();
} else {
$this->error(__('No rows were deleted'));
} }
$this->error(__('Parameter %s can not be empty', 'ids')); $this->error(__('No rows were deleted'));
}
/**
* 真实删除
*
* @param $ids
* @return void
*/
public function destroy($ids = null)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
$ids = $ids ?: $this->request->post('ids');
if (empty($ids)) {
$this->error(__('Parameter %s can not be empty', 'ids'));
}
$pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
$this->model->where($this->dataLimitField, 'in', $adminIds);
}
$this->model->where($pk, 'in', $ids);
$count = 0;
Db::startTrans();
try {
$list = $this->model->onlyTrashed()->select();
foreach ($list as $item) {
$count += $item->delete(true);
}
Db::commit();
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
}
$this->error(__('No rows were deleted'));
} }
/** /**
* 还原 * 还原
*
* @param $ids
* @return void
*/ */
public function restore($ids = "") public function restore($ids = null)
{ {
if (!$this->request->isPost()) { if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__('Invalid parameters'));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post('ids');
$pk = $this->model->getPk(); $pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds(); $adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) { if (is_array($adminIds)) {
@ -284,14 +282,11 @@ trait Backend
Db::startTrans(); Db::startTrans();
try { try {
$list = $this->model->onlyTrashed()->select(); $list = $this->model->onlyTrashed()->select();
foreach ($list as $index => $item) { foreach ($list as $item) {
$count += $item->restore(); $count += $item->restore();
} }
Db::commit(); Db::commit();
} catch (PDOException $e) { } catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback(); Db::rollback();
$this->error($e->getMessage()); $this->error($e->getMessage());
} }
@ -303,52 +298,56 @@ trait Backend
/** /**
* 批量更新 * 批量更新
*
* @param $ids
* @return void
*/ */
public function multi($ids = "") public function multi($ids = null)
{ {
if (!$this->request->isPost()) { if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__('Invalid parameters'));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post('ids');
if ($ids) { if (empty($ids)) {
if ($this->request->has('params')) { $this->error(__('Parameter %s can not be empty', 'ids'));
parse_str($this->request->post("params"), $values); }
$values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields)));
if ($values) { if (false === $this->request->has('params')) {
$adminIds = $this->getDataLimitAdminIds(); $this->error(__('No rows were updated'));
if (is_array($adminIds)) { }
$this->model->where($this->dataLimitField, 'in', $adminIds); parse_str($this->request->post('params'), $values);
} $values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields)));
$count = 0; if (empty($values)) {
Db::startTrans(); $this->error(__('You have no permission'));
try { }
$list = $this->model->where($this->model->getPk(), 'in', $ids)->select(); $adminIds = $this->getDataLimitAdminIds();
foreach ($list as $index => $item) { if (is_array($adminIds)) {
$count += $item->allowField(true)->isUpdate(true)->save($values); $this->model->where($this->dataLimitField, 'in', $adminIds);
} }
Db::commit(); $count = 0;
} catch (PDOException $e) { Db::startTrans();
Db::rollback(); try {
$this->error($e->getMessage()); $list = $this->model->where($this->model->getPk(), 'in', $ids)->select();
} catch (Exception $e) { foreach ($list as $item) {
Db::rollback(); $count += $item->allowField(true)->isUpdate(true)->save($values);
$this->error($e->getMessage());
}
if ($count) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
} else {
$this->error(__('You have no permission'));
}
} }
Db::commit();
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
} }
$this->error(__('Parameter %s can not be empty', 'ids')); if ($count) {
$this->success();
}
$this->error(__('No rows were updated'));
} }
/** /**
* 导入 * 导入
*
* @return void
* @throws PDOException
* @throws BindParamException
*/ */
protected function import() protected function import()
{ {
@ -368,12 +367,12 @@ trait Backend
if ($ext === 'csv') { if ($ext === 'csv') {
$file = fopen($filePath, 'r'); $file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv'); $filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$fp = fopen($filePath, "w"); $fp = fopen($filePath, 'w');
$n = 0; $n = 0;
while ($line = fgets($file)) { while ($line = fgets($file)) {
$line = rtrim($line, "\n\r\0"); $line = rtrim($line, "\n\r\0");
$encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']); $encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']);
if ($encoding != 'utf-8') { if ($encoding !== 'utf-8') {
$line = mb_convert_encoding($line, 'utf-8', $encoding); $line = mb_convert_encoding($line, 'utf-8', $encoding);
} }
if ($n == 0 || preg_match('/^".*"$/', $line)) { if ($n == 0 || preg_match('/^".*"$/', $line)) {

View File

@ -7,7 +7,7 @@ return [
'Sign up successful' => '注册成功', 'Sign up successful' => '注册成功',
'Username can not be empty' => '用户名不能为空', 'Username can not be empty' => '用户名不能为空',
'Username must be 3 to 30 characters' => '用户名必须3-30个字符', 'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
'Username must be 6 to 30 characters' => '用户名必须3-30个字符', 'Username must be 6 to 30 characters' => '用户名必须6-30个字符',
'Password can not be empty' => '密码不能为空', 'Password can not be empty' => '密码不能为空',
'Password must be 6 to 30 characters' => '密码必须6-30个字符', 'Password must be 6 to 30 characters' => '密码必须6-30个字符',
'Mobile is incorrect' => '手机格式不正确', 'Mobile is incorrect' => '手机格式不正确',

View File

@ -1,11 +1,11 @@
<!--@formatter:off--> <!--@formatter:off-->
{if "[type]" == 'email'} {if "[type]" == 'email'}
<input type="text" name="captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});integer[+];remote({:url('api/validate/check_ems_correct')}, event=[event], email:#email)" /> <input type="text" name="captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});digits;remote({:url('api/validate/check_ems_correct')}, event=[event], email:#email)" />
<span class="input-group-btn" style="padding:0;border:none;"> <span class="input-group-btn" style="padding:0;border:none;">
<a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/ems/send')}" data-type="email" data-event="[event]">发送验证码</a> <a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/ems/send')}" data-type="email" data-event="[event]">发送验证码</a>
</span> </span>
{elseif "[type]" == 'mobile'/} {elseif "[type]" == 'mobile'/}
<input type="text" name="captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});integer[+];remote({:url('api/validate/check_sms_correct')}, event=[event], mobile:#mobile)" /> <input type="text" name="captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});digits;remote({:url('api/validate/check_sms_correct')}, event=[event], mobile:#mobile)" />
<span class="input-group-btn" style="padding:0;border:none;"> <span class="input-group-btn" style="padding:0;border:none;">
<a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/sms/send')}" data-type="mobile" data-event="[event]">发送验证码</a> <a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/sms/send')}" data-type="mobile" data-event="[event]">发送验证码</a>
</span> </span>

View File

@ -69,7 +69,7 @@
<label for="captcha" class="control-label col-xs-12 col-sm-3">{:__('Captcha')}:</label> <label for="captcha" class="control-label col-xs-12 col-sm-3">{:__('Captcha')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<div class="input-group"> <div class="input-group">
<input type="text" name="captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});integer[+];remote({:url('api/validate/check_ems_correct')}, event=resetpwd, email:#email)"/> <input type="text" name="captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});digits;remote({:url('api/validate/check_ems_correct')}, event=resetpwd, email:#email)"/>
<span class="input-group-btn" style="padding:0;border:none;"> <span class="input-group-btn" style="padding:0;border:none;">
<a href="javascript:;" class="btn btn-primary btn-captcha" data-url="{:url('api/ems/send')}" data-type="email" data-event="resetpwd">{:__('Send verification code')}</a> <a href="javascript:;" class="btn btn-primary btn-captcha" data-url="{:url('api/ems/send')}" data-type="email" data-event="resetpwd">{:__('Send verification code')}</a>
</span> </span>

View File

@ -121,7 +121,7 @@
<label class="control-label col-xs-12 col-sm-3">{:__('Captcha')}:</label> <label class="control-label col-xs-12 col-sm-3">{:__('Captcha')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<div class="input-group"> <div class="input-group">
<input type="text" name="captcha" id="email-captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});integer[+];remote({:url('api/validate/check_ems_correct')}, event=changeemail, email:#email)" /> <input type="text" name="captcha" id="email-captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});digits;remote({:url('api/validate/check_ems_correct')}, event=changeemail, email:#email)" />
<span class="input-group-btn" style="padding:0;border:none;"> <span class="input-group-btn" style="padding:0;border:none;">
<a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/ems/send')}" data-type="email" data-event="changeemail">获取验证码</a> <a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/ems/send')}" data-type="email" data-event="changeemail">获取验证码</a>
</span> </span>
@ -155,7 +155,7 @@
<label for="mobile-captcha" class="control-label col-xs-12 col-sm-3">{:__('Captcha')}:</label> <label for="mobile-captcha" class="control-label col-xs-12 col-sm-3">{:__('Captcha')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<div class="input-group"> <div class="input-group">
<input type="text" name="captcha" id="mobile-captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});integer[+];remote({:url('api/validate/check_sms_correct')}, event=changemobile, mobile:#mobile)" /> <input type="text" name="captcha" id="mobile-captcha" class="form-control" data-rule="required;length({$Think.config.captcha.length});digits;remote({:url('api/validate/check_sms_correct')}, event=changemobile, mobile:#mobile)" />
<span class="input-group-btn" style="padding:0;border:none;"> <span class="input-group-btn" style="padding:0;border:none;">
<a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/sms/send')}" data-type="mobile" data-event="changemobile">获取验证码</a> <a href="javascript:;" class="btn btn-info btn-captcha" data-url="{:url('api/sms/send')}" data-type="mobile" data-event="changemobile">获取验证码</a>
</span> </span>

View File

@ -38,7 +38,7 @@
"repositories": [ "repositories": [
{ {
"type": "git", "type": "git",
"url": "https://gitee.com/karson/framework" "url": "https://gitee.com/fastadminnet/framework.git"
} }
] ]
} }

View File

@ -8,45 +8,45 @@ use ArrayAccess;
* 表单元素生成 * 表单元素生成
* @class Form * @class Form
* @package fast * @package fast
* @method string token() static 生成Token * @method static string token() 生成Token
* @method string label(string $name, string $value = null, array $options = []) static label标签 * @method static string label(string $name, string $value = null, array $options = []) label标签
* @method string input($type, $name, string $value = null, array $options = []) static 按类型生成文本框 * @method static string input($type, $name, string $value = null, array $options = []) 按类型生成文本框
* @method string text(string $name, string $value = null, array $options = []) static 普通文本框 * @method static string text(string $name, string $value = null, array $options = []) 普通文本框
* @method string password(string $name, array $options = []) static 密码文本框 * @method static string password(string $name, array $options = []) 密码文本框
* @method string hidden(string $name, string $value = null, array $options = []) static 隐藏文本框 * @method static string hidden(string $name, string $value = null, array $options = []) 隐藏文本框
* @method string email(string $name, string $value = null, array $options = []) static Email文本框 * @method static string email(string $name, string $value = null, array $options = []) Email文本框
* @method string url(string $name, string $value = null, array $options = []) static URL文本框 * @method static string url(string $name, string $value = null, array $options = []) URL文本框
* @method string file(string $name, array $options = []) static 文件上传组件 * @method static string file(string $name, array $options = []) 文件上传组件
* @method string textarea(string $name, string $value = null, array $options = []) static 多行文本框 * @method static string textarea(string $name, string $value = null, array $options = []) 多行文本框
* @method string editor(string $name, string $value = null, array $options = []) static 富文本编辑器 * @method static string editor(string $name, string $value = null, array $options = []) 富文本编辑器
* @method string select(string $name, array $list = [], string $selected = null, array $options = []) static 下拉列表组件 * @method static string select(string $name, array $list = [], string $selected = null, array $options = []) 下拉列表组件
* @method string selects(string $name, array $list = [], string $selected = null, array $options = []) static 下拉列表组件(多选) * @method static string selects(string $name, array $list = [], string $selected = null, array $options = []) 下拉列表组件(多选)
* @method string selectpicker(string $name, array $list = [], string $selected = null, array $options = []) static 下拉列表组件(友好) * @method static string selectpicker(string $name, array $list = [], string $selected = null, array $options = []) 下拉列表组件(友好)
* @method string selectpickers(string $name, array $list = [], string $selected = null, array $options = []) static 下拉列表组件(友好)(多选) * @method static string selectpickers(string $name, array $list = [], string $selected = null, array $options = []) 下拉列表组件(友好)(多选)
* @method string selectpage(string $name, string $value, string $url, string $field = null, string $primaryKey = null, array $options = []) static 动态下拉列表组件 * @method static string selectpage(string $name, string $value, string $url, string $field = null, string $primaryKey = null, array $options = []) 动态下拉列表组件
* @method string selectpages(string $name, string $value, string $url, string $field = null, string $primaryKey = null, array $options = []) static 动态下拉列表组件(多选) * @method static string selectpages(string $name, string $value, string $url, string $field = null, string $primaryKey = null, array $options = []) 动态下拉列表组件(多选)
* @method string citypicker(string $name, string $value, array $options = []) static 城市选择组件 * @method static string citypicker(string $name, string $value, array $options = []) 城市选择组件
* @method string switcher(string $name, string $value, array $options = []) static 切换组件 * @method static string switcher(string $name, string $value, array $options = []) 切换组件
* @method string datepicker(string $name, string $value, array $options = []) static 日期选择组件 * @method static string datepicker(string $name, string $value, array $options = []) 日期选择组件
* @method string timepicker(string $name, string $value, array $options = []) static 时间选择组件 * @method static string timepicker(string $name, string $value, array $options = []) 时间选择组件
* @method string datetimepicker(string $name, string $value, array $options = []) static 日期时间选择组件 * @method static string datetimepicker(string $name, string $value, array $options = []) 日期时间选择组件
* @method string daterange(string $name, string $value, array $options = []) static 日期区间组件 * @method static string daterange(string $name, string $value, array $options = []) 日期区间组件
* @method string timerange(string $name, string $value, array $options = []) static 时间区间组件 * @method static string timerange(string $name, string $value, array $options = []) 时间区间组件
* @method string datetimerange(string $name, string $value, array $options = []) static 日期时间区间组件 * @method static string datetimerange(string $name, string $value, array $options = []) 日期时间区间组件
* @method string fieldlist(string $name, string $value, string $title = null, string $template = null, array $options = []) static 字段列表组件 * @method static string fieldlist(string $name, string $value, string $title = null, string $template = null, array $options = []) 字段列表组件
* @method string cxselect(string $url, array $names = [], array $values = [], array $options = []) static 联动组件 * @method static string cxselect(string $url, array $names = [], array $values = [], array $options = []) 联动组件
* @method string selectRange(string $name, string $begin, string $end, string $selected = null, array $options = []) static 选择数字区间 * @method static string selectRange(string $name, string $begin, string $end, string $selected = null, array $options = []) 选择数字区间
* @method string selectYear(string $name, string $begin, string $end, string $selected = null, array $options = []) static 选择年 * @method static string selectYear(string $name, string $begin, string $end, string $selected = null, array $options = []) 选择年
* @method string selectMonth(string $name, string $selected = null, array $options = [], string $format = '%m') static 选择月 * @method static string selectMonth(string $name, string $selected = null, array $options = [], string $format = '%m') 选择月
* @method string checkbox(string $name, string $value = '1', string $checked = null, array $options = []) static 单个复选框 * @method static string checkbox(string $name, string $value = '1', string $checked = null, array $options = []) 单个复选框
* @method string checkboxs(string $name, array $list = [], string $checked = null, array $options = []) static 一组复选框 * @method static string checkboxs(string $name, array $list = [], string $checked = null, array $options = []) 一组复选框
* @method string radio(string $name, string $value = null, string $checked = null, array $options = [])) static 单个单选框 * @method static string radio(string $name, string $value = null, string $checked = null, array $options = [])) 单个单选框
* @method string radios(string $name, array $list = [], string $checked = null, array $options = [])) static 一组单选框 * @method static string radios(string $name, array $list = [], string $checked = null, array $options = [])) 一组单选框
* @method string image(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) static 上传图片组件 * @method static string image(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传图片组件
* @method string images(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) static 上传图片组件(多图) * @method static string images(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传图片组件(多图)
* @method string upload(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) static 上传文件组件 * @method static string upload(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传文件组件
* @method string uploads(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) static 上传文件组件(多文件) * @method static string uploads(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传文件组件(多文件)
* @method string button(string $value = null, array $options = []) static 表单button * @method static string button(string $value = null, array $options = []) 表单button
*/ */
class Form class Form
{ {

View File

@ -68,13 +68,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
}); });
}); });
//当表格分页变更时
table.on('page-change.bs.table', function (e, page, pagesize) {
if (!isNaN(pagesize)) {
localStorage.setItem("pagesize-addon", pagesize);
}
});
Template.helper("Moment", Moment); Template.helper("Moment", Moment);
Template.helper("addons", Config['addons']); Template.helper("addons", Config['addons']);
@ -90,6 +83,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
// 初始化表格 // 初始化表格
table.bootstrapTable({ table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url, url: $.fn.bootstrapTable.defaults.extend.index_url,
pageSize: 50,
queryParams: function (params) { queryParams: function (params) {
var userinfo = Controller.api.userinfo.get(); var userinfo = Controller.api.userinfo.get();
$.extend(params, { $.extend(params, {
@ -181,7 +175,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
commonSearch: true, commonSearch: true,
searchFormVisible: true, searchFormVisible: true,
searchFormTemplate: 'searchformtpl', searchFormTemplate: 'searchformtpl',
pageSize: localStorage.getItem('pagesize-addon') || 50,
}); });
// 为表格绑定事件 // 为表格绑定事件

View File

@ -11759,7 +11759,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
}, },
ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列 ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
}, },
pageSize: localStorage.getItem("pagesize") || 10, pageSize: localStorage.getItem('page-size') || 10,
pageList: [10, 15, 20, 25, 50, 'All'], pageList: [10, 15, 20, 25, 50, 'All'],
pagination: true, pagination: true,
clickToSelect: true, //是否启用点击选中 clickToSelect: true, //是否启用点击选中
@ -11923,12 +11923,6 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
table.on('refresh.bs.table', function (e, settings, data) { table.on('refresh.bs.table', function (e, settings, data) {
$(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin"); $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
}); });
//当表格分页变更时
table.on('page-change.bs.table', function (e, page, pagesize) {
if (!isNaN(pagesize)) {
localStorage.setItem("pagesize", pagesize);
}
});
//当执行搜索时 //当执行搜索时
table.on('search.bs.table common-search.bs.table', function (e, settings, data) { table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
table.trigger("uncheckbox"); table.trigger("uncheckbox");
@ -12273,6 +12267,12 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
Table.list[id] = table; Table.list[id] = table;
return table; return table;
}, },
// 设置全局分页的单页显示数
pageSize: function (pageSize) {
if (!isNaN(pageSize)) {
localStorage.setItem('page-size', pageSize);
}
},
// 批量操作请求 // 批量操作请求
multi: function (action, ids, table, element) { multi: function (action, ids, table, element) {
var options = table.bootstrapTable('getOptions'); var options = table.bootstrapTable('getOptions');

View File

@ -11607,7 +11607,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
}, },
ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列 ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
}, },
pageSize: localStorage.getItem("pagesize") || 10, pageSize: localStorage.getItem('page-size') || 10,
pageList: [10, 15, 20, 25, 50, 'All'], pageList: [10, 15, 20, 25, 50, 'All'],
pagination: true, pagination: true,
clickToSelect: true, //是否启用点击选中 clickToSelect: true, //是否启用点击选中
@ -11771,12 +11771,6 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
table.on('refresh.bs.table', function (e, settings, data) { table.on('refresh.bs.table', function (e, settings, data) {
$(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin"); $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
}); });
//当表格分页变更时
table.on('page-change.bs.table', function (e, page, pagesize) {
if (!isNaN(pagesize)) {
localStorage.setItem("pagesize", pagesize);
}
});
//当执行搜索时 //当执行搜索时
table.on('search.bs.table common-search.bs.table', function (e, settings, data) { table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
table.trigger("uncheckbox"); table.trigger("uncheckbox");
@ -12121,6 +12115,12 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
Table.list[id] = table; Table.list[id] = table;
return table; return table;
}, },
// 设置全局分页的单页显示数
pageSize: function (pageSize) {
if (!isNaN(pageSize)) {
localStorage.setItem('page-size', pageSize);
}
},
// 批量操作请求 // 批量操作请求
multi: function (action, ids, table, element) { multi: function (action, ids, table, element) {
var options = table.bootstrapTable('getOptions'); var options = table.bootstrapTable('getOptions');

View File

@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
}, },
ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列 ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
}, },
pageSize: localStorage.getItem("pagesize") || 10, pageSize: localStorage.getItem('page-size') || 10,
pageList: [10, 15, 20, 25, 50, 'All'], pageList: [10, 15, 20, 25, 50, 'All'],
pagination: true, pagination: true,
clickToSelect: true, //是否启用点击选中 clickToSelect: true, //是否启用点击选中
@ -190,12 +190,6 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
table.on('refresh.bs.table', function (e, settings, data) { table.on('refresh.bs.table', function (e, settings, data) {
$(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin"); $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
}); });
//当表格分页变更时
table.on('page-change.bs.table', function (e, page, pagesize) {
if (!isNaN(pagesize)) {
localStorage.setItem("pagesize", pagesize);
}
});
//当执行搜索时 //当执行搜索时
table.on('search.bs.table common-search.bs.table', function (e, settings, data) { table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
table.trigger("uncheckbox"); table.trigger("uncheckbox");
@ -540,6 +534,12 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
Table.list[id] = table; Table.list[id] = table;
return table; return table;
}, },
// 设置全局分页的单页显示数
pageSize: function (pageSize) {
if (!isNaN(pageSize)) {
localStorage.setItem('page-size', pageSize);
}
},
// 批量操作请求 // 批量操作请求
multi: function (action, ids, table, element) { multi: function (action, ids, table, element) {
var options = table.bootstrapTable('getOptions'); var options = table.bootstrapTable('getOptions');

2
think
View File

@ -14,4 +14,4 @@
define('APP_PATH', __DIR__ . '/application/'); define('APP_PATH', __DIR__ . '/application/');
// 加载框架引导文件 // 加载框架引导文件
require './thinkphp/console.php'; require __DIR__ . '/thinkphp/console.php';