作者 景龙
1 个管道 的构建 通过 耗费 1 秒

增加文件

<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 指派人员回收废品管理
*
* @icon fa fa-circle-o
*/
class Assign extends Backend
{
/**
* Assign模型对象
* @var \app\admin\model\Assign
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Assign;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index($ids = '')
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['sell'])
->where($where)
->where('u_id',$ids)
->order($sort, $order)
->count();
$list = $this->model
->with(['sell'])
->where($where)
->where('u_id',$ids)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->getRelation('sell')->visible(['fullname','address','pre_date','pre_time','images','description']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
$this->assignconfig("u_id",$ids);
return $this->view->fetch();
}
}
... ...
<?php
return [
'Id' => 'ID',
'Createtime' => '指派时间',
'Sell.fullname' => '真实姓名',
'Sell.address' => '地址',
'Sell.pre_date' => '预约日期',
'Sell.pre_time' => '预约时间',
'Sell.images' => '废品图片',
'Sell.description' => '废品描述',
'Sell.mobile' => '手机号'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class Assign extends Model
{
// 表名
protected $name = 'assign';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = [
'deletetime_text'
];
public function getDeletetimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['deletetime']) ? $data['deletetime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setDeletetimeAttr($value)
{
return $value && !is_numeric($value) ? strtotime($value) : $value;
}
public function sell()
{
return $this->belongsTo('Sell', 's_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class Assign extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<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('assign/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('assign/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('assign/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('assign/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<div class="dropdown btn-group {:$auth->check('assign/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('assign/edit')}"
data-operate-del="{:$auth->check('assign/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: 'assign/index',
// add_url: 'assign/add',
// edit_url: 'assign/edit',
// del_url: 'assign/del',
// multi_url: 'assign/multi',
table: 'assign',
},
queryParams: function (params) { //自定义搜索条件
params.ids = Config.u_id;//将搜索过滤器和操作方法 都转为JSON字符串
return params;
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'sell.fullname', title: __('Sell.fullname')},
// {field: 'sell.mobile', title: __('Sell.mobile')},
{field: 'sell.address', title: __('Sell.address')},
{field: 'sell.pre_date', title: __('Sell.pre_date'), operate:'RANGE', addclass:'datetimerange'},
{field: 'sell.pre_time', title: __('Sell.pre_time')},
{field: 'sell.images', title: __('Sell.images'), formatter: Table.api.formatter.images},
{field: 'createtime', title: __('Createtime'), 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}
]
]
});
// 为表格绑定事件
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
... ...