作者 何书鹏
1 个管道 的构建 通过 耗费 3 秒

合并分支 'heshupeng' 到 'master'

通知公告和政策动态多附件



查看合并请求 !262
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 行业资讯附件
*
* @icon fa fa-circle-o
*/
class InformationFile extends Backend
{
/**
* InformationFile模型对象
* @var \app\admin\model\InformationFile
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\InformationFile;
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = false;
//设置过滤方法
$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
->where('information_id',$this->request->request('information_id'))
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','file_name','file','createtime','updatetime']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
/**
* 添加
*/
public function add()
{
$information_id = $this->request->request('information_id');
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$params['information_id'] = $information_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', ''));
}
return $this->view->fetch();
}
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 政策动态附件
*
* @icon fa fa-circle-o
*/
class PolicyFile extends Backend
{
/**
* PolicyFile模型对象
* @var \app\admin\model\PolicyFile
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\PolicyFile;
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = false;
//设置过滤方法
$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
->where('policy_id',$this->request->request('policy_id'))
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','file_name','file','createtime','updatetime']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
/**
* 添加
*/
public function add()
{
$policy_id = $this->request->request('policy_id');
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$params['policy_id'] = $policy_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', ''));
}
return $this->view->fetch();
}
}
... ...
<?php
return [
'Id' => 'id',
'Information_id' => '行业资讯id',
'File_name' => '附件名称',
'File' => '附件',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
];
... ...
<?php
return [
'Id' => 'id',
'Policy_id' => '政策动态id',
'File_name' => '附件名称',
'File' => '附件',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class InformationFile extends Model
{
// 表名
protected $name = 'information_file';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class PolicyFile extends Model
{
// 表名
protected $name = 'policy_file';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
... ... @@ -24,7 +24,7 @@
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text">
... ... @@ -43,7 +43,7 @@
</div>
<ul class="row list-inline plupload-preview" id="p-file"></ul>
</div>
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('是否上架')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -24,7 +24,7 @@
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text" value="{$row.file_name}">
... ... @@ -43,7 +43,7 @@
</div>
<ul class="row list-inline plupload-preview" id="p-file"></ul>
</div>
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('是否上架')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
<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">{:__('File_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-file" class="form-control" size="50" name="row[file]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-file" class="btn btn-danger faupload" data-input-id="c-file" data-multiple="false" data-preview-id="p-file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-file" class="btn btn-primary fachoose" data-input-id="c-file" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-file"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-file"></ul>
</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-success 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">{:__('File_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text" value="{$row.file_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-file" class="form-control" size="50" name="row[file]" type="text" value="{$row.file|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-file" class="btn btn-danger faupload" data-input-id="c-file" data-multiple="false" data-preview-id="p-file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-file" class="btn btn-primary fachoose" data-input-id="c-file" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-file"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-file"></ul>
</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-success 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('information_file/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('information_file/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('information_file/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('information_file/edit')}"
data-operate-del="{:$auth->check('information_file/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -24,7 +24,7 @@
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text">
... ... @@ -43,7 +43,7 @@
</div>
<ul class="row list-inline plupload-preview" id="p-file"></ul>
</div>
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('是否上架')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -24,7 +24,7 @@
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text" value="{$row.file_name}">
... ... @@ -43,7 +43,7 @@
</div>
<ul class="row list-inline plupload-preview" id="p-file"></ul>
</div>
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('是否上架')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
<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">{:__('File_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-file" class="form-control" size="50" name="row[file]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-file" class="btn btn-danger faupload" data-input-id="c-file" data-multiple="false" data-preview-id="p-file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-file" class="btn btn-primary fachoose" data-input-id="c-file" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-file"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-file"></ul>
</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-success 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">{:__('File_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text" value="{$row.file_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-file" class="form-control" size="50" name="row[file]" type="text" value="{$row.file|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-file" class="btn btn-danger faupload" data-input-id="c-file" data-multiple="false" data-preview-id="p-file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-file" class="btn btn-primary fachoose" data-input-id="c-file" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-file"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-file"></ul>
</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-success 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('policy_file/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('policy_file/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('policy_file/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('policy_file/edit')}"
data-operate-del="{:$auth->check('policy_file/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -338,19 +338,39 @@ class Lists extends Api
->where('id',$id)
->field('updatetime',true)
->find();
if(!empty($data['file'])){
$base_url = $data['file'];
$qiniu_url = $qiniu.$data['file'];
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
mkdir($path,0777,true);
// if(!empty($data['file'])){
// $base_url = $data['file'];
// $qiniu_url = $qiniu.$data['file'];
// $a = file_get_contents($qiniu_url);
// $path = './uploads/'.explode('/',$base_url)[2].'/';
// if(!file_exists($path)) {
// mkdir($path,0777,true);
// }
// file_put_contents('.'.$base_url,$a);
// $data['file'] = request()->domain().$base_url;
// }else{
// $data['file'] = '';
// }
$file_list = Db::name('information_file')
->where('information_id',$id)
->field('file_name,file')
->select();
foreach ($file_list as &$v){
if(!empty($v['file'])){
$base_url = $v['file'];
$qiniu_url = $qiniu.$v['file'];
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
mkdir($path,0777,true);
}
file_put_contents('.'.$base_url,$a);
$v['file'] = request()->domain().$base_url;
}else{
$v['file'] = '';
}
file_put_contents('.'.$base_url,$a);
$data['file'] = request()->domain().$base_url;
}else{
$data['file'] = '';
}
$data['file_list'] = $file_list;
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
$this->success('success',$data);
}
... ... @@ -390,19 +410,39 @@ class Lists extends Api
->where('id',$id)
->field('updatetime',true)
->find();
if(!empty($data['file'])){
$base_url = $data['file'];
$qiniu_url = $qiniu.$data['file'];
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
mkdir($path,0777,true);
// if(!empty($data['file'])){
// $base_url = $data['file'];
// $qiniu_url = $qiniu.$data['file'];
// $a = file_get_contents($qiniu_url);
// $path = './uploads/'.explode('/',$base_url)[2].'/';
// if(!file_exists($path)) {
// mkdir($path,0777,true);
// }
// file_put_contents('.'.$base_url,$a);
// $data['file'] = request()->domain().$base_url;
// }else{
// $data['file'] = '';
// }
$file_list = Db::name('policy_file')
->where('policy_id',$id)
->field('file_name,file')
->select();
foreach ($file_list as &$v){
if(!empty($v['file'])){
$base_url = $v['file'];
$qiniu_url = $qiniu.$v['file'];
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
mkdir($path,0777,true);
}
file_put_contents('.'.$base_url,$a);
$v['file'] = request()->domain().$base_url;
}else{
$v['file'] = '';
}
file_put_contents('.'.$base_url,$a);
$data['file'] = request()->domain().$base_url;
}else{
$data['file'] = '';
}
$data['file_list'] = $file_list;
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
$this->success('success',$data);
}
... ...
... ... @@ -27,12 +27,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title')},
{field: 'from', title: __('转载于')},
{field: 'file_name', title: __('附件名称')},
{field: 'file', title: __('File'),formatter: Table.api.formatter.url},
// {field: 'file_name', title: __('附件名称')},
// {field: 'file', title: __('File'),formatter: Table.api.formatter.url},
{field: 'is_up', title: __('是否上架'),searchList: {"0":"否","1":'是'},formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
//操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮
{
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'file',
text: __('附件'),
title: __('附件'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'information_file/index?information_id={id}',
}
],
formatter: Table.api.formatter.operate
}
]
]
});
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'information_file/index' + location.search,
add_url: 'information_file/add' + location.search,
edit_url: 'information_file/edit',
del_url: 'information_file/del',
multi_url: 'information_file/multi',
import_url: 'information_file/import',
table: 'information_file',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'file_name', title: __('File_name'), operate: 'LIKE'},
{field: 'file', title: __('File'),formatter: Table.api.formatter.url},
{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;
});
\ No newline at end of file
... ...
... ... @@ -27,12 +27,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title')},
{field: 'from', title: __('From')},
{field: 'file_name', title: __('附件名称')},
{field: 'file', title: __('File'),formatter: Table.api.formatter.url},
// {field: 'file_name', title: __('附件名称')},
// {field: 'file', title: __('File'),formatter: Table.api.formatter.url},
{field: 'is_up', title: __('是否上架'),searchList: {"0":"否","1":'是'},formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
//操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮
{
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'file',
text: __('附件'),
title: __('附件'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'policy_file/index?policy_id={id}',
}
],
formatter: Table.api.formatter.operate
}
]
]
});
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'policy_file/index' + location.search,
add_url: 'policy_file/add' + location.search,
edit_url: 'policy_file/edit',
del_url: 'policy_file/del',
multi_url: 'policy_file/multi',
import_url: 'policy_file/import',
table: 'policy_file',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'file_name', title: __('File_name'), operate: 'LIKE'},
{field: 'file', title: __('File'),formatter: Table.api.formatter.url},
{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;
});
\ No newline at end of file
... ...