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

增加文件

  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +use app\common\controller\Backend;
  6 +
  7 +/**
  8 + * 指派人员回收废品管理
  9 + *
  10 + * @icon fa fa-circle-o
  11 + */
  12 +class Assign extends Backend
  13 +{
  14 +
  15 + /**
  16 + * Assign模型对象
  17 + * @var \app\admin\model\Assign
  18 + */
  19 + protected $model = null;
  20 +
  21 + public function _initialize()
  22 + {
  23 + parent::_initialize();
  24 + $this->model = new \app\admin\model\Assign;
  25 +
  26 + }
  27 +
  28 + /**
  29 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  30 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  31 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  32 + */
  33 +
  34 +
  35 + /**
  36 + * 查看
  37 + */
  38 + public function index($ids = '')
  39 + {
  40 + //当前是否为关联查询
  41 + $this->relationSearch = true;
  42 + //设置过滤方法
  43 + $this->request->filter(['strip_tags']);
  44 + if ($this->request->isAjax())
  45 + {
  46 + //如果发送的来源是Selectpage,则转发到Selectpage
  47 + if ($this->request->request('keyField'))
  48 + {
  49 + return $this->selectpage();
  50 + }
  51 + list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  52 + $total = $this->model
  53 + ->with(['sell'])
  54 + ->where($where)
  55 + ->where('u_id',$ids)
  56 + ->order($sort, $order)
  57 + ->count();
  58 +
  59 + $list = $this->model
  60 + ->with(['sell'])
  61 + ->where($where)
  62 + ->where('u_id',$ids)
  63 + ->order($sort, $order)
  64 + ->limit($offset, $limit)
  65 + ->select();
  66 +
  67 + foreach ($list as $row) {
  68 +
  69 + $row->getRelation('sell')->visible(['fullname','address','pre_date','pre_time','images','description']);
  70 + }
  71 + $list = collection($list)->toArray();
  72 + $result = array("total" => $total, "rows" => $list);
  73 +
  74 + return json($result);
  75 + }
  76 + $this->assignconfig("u_id",$ids);
  77 + return $this->view->fetch();
  78 + }
  79 +}
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => 'ID',
  5 + 'Createtime' => '指派时间',
  6 + 'Sell.fullname' => '真实姓名',
  7 + 'Sell.address' => '地址',
  8 + 'Sell.pre_date' => '预约日期',
  9 + 'Sell.pre_time' => '预约时间',
  10 + 'Sell.images' => '废品图片',
  11 + 'Sell.description' => '废品描述',
  12 + 'Sell.mobile' => '手机号'
  13 +];
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +class Assign extends Model
  8 +{
  9 + // 表名
  10 + protected $name = 'assign';
  11 +
  12 + // 自动写入时间戳字段
  13 + protected $autoWriteTimestamp = 'int';
  14 +
  15 + // 定义时间戳字段名
  16 + protected $createTime = 'createtime';
  17 + protected $updateTime = 'updatetime';
  18 +
  19 + // 追加属性
  20 + protected $append = [
  21 + 'deletetime_text'
  22 + ];
  23 +
  24 +
  25 +
  26 +
  27 +
  28 +
  29 + public function getDeletetimeTextAttr($value, $data)
  30 + {
  31 + $value = $value ? $value : (isset($data['deletetime']) ? $data['deletetime'] : '');
  32 + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  33 + }
  34 +
  35 + protected function setDeletetimeAttr($value)
  36 + {
  37 + return $value && !is_numeric($value) ? strtotime($value) : $value;
  38 + }
  39 +
  40 +
  41 + public function sell()
  42 + {
  43 + return $this->belongsTo('Sell', 's_id', 'id', [], 'LEFT')->setEagerlyType(0);
  44 + }
  45 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate;
  4 +
  5 +use think\Validate;
  6 +
  7 +class Assign extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('assign/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 + <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('assign/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
  12 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('assign/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  13 + <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>
  14 +
  15 + <div class="dropdown btn-group {:$auth->check('assign/multi')?'':'hide'}">
  16 + <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
  17 + <ul class="dropdown-menu text-left" role="menu">
  18 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  19 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
  20 + </ul>
  21 + </div>
  22 + </div>
  23 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  24 + data-operate-edit="{:$auth->check('assign/edit')}"
  25 + data-operate-del="{:$auth->check('assign/del')}"
  26 + width="100%">
  27 + </table>
  28 + </div>
  29 + </div>
  30 +
  31 + </div>
  32 + </div>
  33 +</div>
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'assign/index',
  9 + // add_url: 'assign/add',
  10 + // edit_url: 'assign/edit',
  11 + // del_url: 'assign/del',
  12 + // multi_url: 'assign/multi',
  13 + table: 'assign',
  14 + },
  15 + queryParams: function (params) { //自定义搜索条件
  16 + params.ids = Config.u_id;//将搜索过滤器和操作方法 都转为JSON字符串
  17 + return params;
  18 + }
  19 + });
  20 +
  21 + var table = $("#table");
  22 +
  23 + // 初始化表格
  24 + table.bootstrapTable({
  25 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  26 + pk: 'id',
  27 + sortName: 'id',
  28 + columns: [
  29 + [
  30 + {checkbox: true},
  31 + {field: 'id', title: __('Id')},
  32 + {field: 'sell.fullname', title: __('Sell.fullname')},
  33 + // {field: 'sell.mobile', title: __('Sell.mobile')},
  34 + {field: 'sell.address', title: __('Sell.address')},
  35 + {field: 'sell.pre_date', title: __('Sell.pre_date'), operate:'RANGE', addclass:'datetimerange'},
  36 + {field: 'sell.pre_time', title: __('Sell.pre_time')},
  37 + {field: 'sell.images', title: __('Sell.images'), formatter: Table.api.formatter.images},
  38 + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  39 + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  40 + ]
  41 + ]
  42 + });
  43 +
  44 + // 为表格绑定事件
  45 + Table.api.bindevent(table);
  46 + },
  47 + add: function () {
  48 + Controller.api.bindevent();
  49 + },
  50 + edit: function () {
  51 + Controller.api.bindevent();
  52 + },
  53 + api: {
  54 + bindevent: function () {
  55 + Form.api.bindevent($("form[role=form]"));
  56 + }
  57 + }
  58 + };
  59 + return Controller;
  60 +});