作者 杨育虎

后台

正在显示 51 个修改的文件 包含 332 行增加49 行删除
... ... @@ -37,4 +37,38 @@ class BatteryCode extends Backend
*/
/**
* 查看
*/
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(['batterytype'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('batterytype')->visible(['type']);
}
$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 BatteryType extends Backend
{
/**
* BatteryType模型对象
* @var \app\admin\model\BatteryType
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\BatteryType;
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
... ... @@ -54,14 +54,14 @@ class MoneyConfig extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['batterycode'])
->with(['batterytype'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('batterycode')->visible(['title']);
$row->getRelation('batterytype')->visible(['type']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
... ...
<?php
return [
'Id' => 'ID',
'Title' => '电池类型名称',
'Batterycode' => '电池编码',
'Createtime' => '创建时间',
'Updatetime' => '更改时间',
'Avatar' => '设备头图',
'Manufactor' => '厂家'
'Id' => 'ID',
'Batter_type_id' => '电池类型',
'Batterycode' => '电池编码',
'Avatar' => '设备头图',
'Mac' => 'Mac地址',
'Manufactor' => '厂家',
'Createtime' => '出场时间',
'Batterytype.type' => '产品型号'
];
... ...
<?php
return [
'Id' => 'ID',
'Type' => '产品型号'
];
... ...
<?php
return [
'Id' => 'ID',
'Battery_id' => '电池类型',
'Upmoney' => '押金',
'Monthmoney' => '月租金',
'Batterycode.title' => '电池类型名称'
'Id' => 'ID',
'Battery_type_id' => '电池类型',
'Upmoney' => '押金',
'Monthmoney' => '月租金',
'Batterytype.type' => '产品型号'
];
... ...
... ... @@ -20,7 +20,7 @@ class BatteryCode extends Model
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
... ... @@ -37,4 +37,8 @@ class BatteryCode extends Model
public function batterytype()
{
return $this->belongsTo('BatteryType', 'batter_type_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class BatteryType extends Model
{
// 表名
protected $name = 'battery_type';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
... ... @@ -37,8 +37,8 @@ class MoneyConfig extends Model
public function batterycode()
public function batterytype()
{
return $this->belongsTo('BatteryCode', 'battery_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('BatteryType', 'battery_type_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class BatteryType 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>
<label class="control-label col-xs-12 col-sm-2">{:__('Batter_type_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text">
<input id="c-batter_type_id" data-rule="required" data-source="batter/type/index" class="form-control selectpage" name="row[batter_type_id]" type="text" value="">
</div>
</div>
<div class="form-group">
... ... @@ -27,6 +27,12 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mac')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-Mac" data-rule="required" class="form-control" name="row[Mac]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Manufactor')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-manufactor" data-rule="required" class="form-control" name="row[manufactor]" type="text">
... ...
<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>
<label class="control-label col-xs-12 col-sm-2">{:__('Batter_type_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
<input id="c-batter_type_id" data-rule="required" data-source="batter/type/index" class="form-control selectpage" name="row[batter_type_id]" type="text" value="{$row.batter_type_id|htmlentities}">
</div>
</div>
<div class="form-group">
... ... @@ -27,6 +27,12 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mac')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-Mac" data-rule="required" class="form-control" name="row[Mac]" type="text" value="{$row.Mac|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Manufactor')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-manufactor" data-rule="required" class="form-control" name="row[manufactor]" type="text" value="{$row.manufactor|htmlentities}">
... ...
... ... @@ -10,16 +10,16 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('battery_code/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('battery_code/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('battery_code/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('battery_code/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('battery_code/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>-->
<!---->
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('battery_code/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('battery_code/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"
... ...
<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">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-type" data-rule="required" class="form-control" name="row[type]" 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-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">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-type" data-rule="required" class="form-control" name="row[type]" type="text" value="{$row.type|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-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('battery_type/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('battery_type/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('battery_type/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('battery_type/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('battery_type/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('battery_type/edit')}"
data-operate-del="{:$auth->check('battery_type/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">{:__('Battery_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Battery_type_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-battery_id" data-rule="required" data-source="battery_code/index" data-field="title" class="form-control selectpage" name="row[battery_id]" type="text" value="">
<input id="c-battery_type_id" data-rule="required" data-source="battery/type/index" class="form-control selectpage" name="row[battery_type_id]" type="text" value="">
</div>
</div>
<div class="form-group">
... ...
<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">{:__('Battery_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Battery_type_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-battery_id" data-rule="required" data-source="battery_code/index" data-field="title" class="form-control selectpage" name="row[battery_id]" type="text" value="{$row.battery_id|htmlentities}">
<input id="c-battery_type_id" data-rule="required" data-source="battery/type/index" class="form-control selectpage" name="row[battery_type_id]" type="text" value="{$row.battery_type_id|htmlentities}">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -10,15 +10,15 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('money_config/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('money_config/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('money_config/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('money_config/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('money_config/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>-->
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('money_config/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('money_config/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>
... ...
... ... @@ -26,12 +26,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'batter_type_id', title: __('Batter_type_id')},
{field: 'BatteryCode', title: __('Batterycode'), operate: 'LIKE'},
{field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'Mac', title: __('Mac'), operate: 'LIKE'},
{field: 'manufactor', title: __('Manufactor'), operate: 'LIKE'},
{field: 'BatteryCode', title: __('Batterycode'), 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: 'batterytype.type', title: __('Batterytype.type'), operate: 'LIKE'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 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: 'battery_type/index' + location.search,
add_url: 'battery_type/add',
edit_url: 'battery_type/edit',
del_url: 'battery_type/del',
multi_url: 'battery_type/multi',
import_url: 'battery_type/import',
table: 'battery_type',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'type', title: __('Type'), operate: 'LIKE'},
{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
... ...
... ... @@ -26,10 +26,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
// {field: 'battery_id', title: __('Battery_id')},
{field: 'batterycode.title', title: __('Batterycode.title'), operate: 'LIKE'},
{field: 'battery_type_id', title: __('Battery_type_id')},
{field: 'UpMoney', title: __('Upmoney'), operate:'BETWEEN'},
{field: 'MonthMoney', title: __('Monthmoney'), operate:'BETWEEN'},
{field: 'batterytype.type', title: __('Batterytype.type'), operate: 'LIKE'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...