作者 sgj

Merge remote-tracking branch 'origin/master'

正在显示 72 个修改的文件 包含 1488 行增加147 行删除
... ... @@ -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中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 故障挂失类型
*
* @icon fa fa-circle-o
*/
class Guzhang extends Backend
{
/**
* Guzhang模型对象
* @var \app\admin\model\Guzhang
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Guzhang;
}
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());
... ...
... ... @@ -54,7 +54,7 @@ class Order extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['stor','user','batterycode'])
->with(['stor','user'])
->where($where)
->order($sort, $order)
->paginate($limit);
... ... @@ -63,7 +63,6 @@ class Order extends Backend
$row->getRelation('stor')->visible(['name']);
$row->getRelation('user')->visible(['nickname','avatar']);
$row->getRelation('batterycode')->visible(['title']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
... ...
<?php
return [
'Id' => 'ID',
'Title' => '电池类型名称',
'Batterycode' => '电池编码',
'Createtime' => '创建时间',
'Updatetime' => '更改时间',
'Avatar' => '设备头图',
'Manufactor' => '厂家'
'Id' => 'ID',
'Battery_type_id' => '电池类型',
'Batterycode' => '电池编码',
'Avatar' => '设备头图',
'Mac' => 'Mac地址',
'Manufactor' => '厂家',
'Createtime' => '出场时间',
'Batterytype.type' => '产品型号'
];
... ...
<?php
return [
'Id' => 'ID',
'Type' => '产品型号'
];
... ...
<?php
return [
'Id' => 'ID',
'Title' => '故障挂失类型'
];
... ...
<?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', 'battery_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 = [
];
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class Guzhang extends Model
{
// 表名
protected $name = 'guzhang';
// 自动写入时间戳字段
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);
}
}
... ...
... ... @@ -95,8 +95,8 @@ class Order extends Model
}
public function batterycode()
{
return $this->belongsTo('BatteryCode', 'battery_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
// public function batterycode()
// {
// return $this->belongsTo('BatteryCode', 'battery_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' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class Guzhang 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">{:__('Battery_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-battery_type_id" data-rule="required" data-source="battery_type/index" data-field="type" class="form-control selectpage" name="row[battery_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">{:__('Battery_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-battery_type_id" data-rule="required" data-source="battery_type/index" data-field="type" class="form-control selectpage" name="row[battery_type_id]" type="text" value="{$row.battery_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">{:__('Title')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-title" data-rule="required" class="form-control" name="row[title]" 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">{:__('Title')}:</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}">
</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('guzhang/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('guzhang/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('guzhang/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('guzhang/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('guzhang/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('guzhang/edit')}"
data-operate-del="{:$auth->check('guzhang/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" data-field="type" 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" data-field="type" 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>
... ...
... ... @@ -77,12 +77,6 @@
<ul class="row list-inline faupload-preview" id="p-stor_image"></ul>
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Battery')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-Battery" data-rule="required" class="form-control" name="row[Battery]" type="text" value="{$row.Battery|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">
... ...
<?php
namespace app\api\controller;
use think\Db;
use app\common\controller\Api;
use function fast\e;
/**
* 新增接口
*/
class Add extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = '*';
/**
* @ApiTitle (新增电池)
* @ApiSummary (新增电池)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/AddBattery)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="battery_code", type="string", required=true, description="电池编号")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function AddBattery()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$params = $this->request->param();
$data = [
'battery_code' => $params['battery_code'],
'battery_type_id' => Db::name('battery_code')->where('BatteryCode', $params['battery_code'])->value('battery_type_id'),
'stor_id' => $StorID,
'battery' => 0,
'status' => 1
];
Db::name('cp')->insert($data);
$this->success('成功', 1);
}
/**
* @ApiTitle (故障挂失-根据用户名查询电池型号电池编号)
* @ApiSummary (故障挂失-根据用户名查询电池型号电池编号)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/UserSelectBattery)
* @ApiParams (name="name", type="string", required=true, description="用户名")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"battery_type_id": 4, //电池类型ID
"battery_type": "型号4", //电池类型名称
"BatteryCode": "asdhjghjghjhg" //电池序列号
}
})
*/
public function UserSelectBattery()
{
$Parmas = $this->request->param();
$Map['h.name'] = ['LIKE', '%' . $Parmas['name'] . '%'];
$Info = Db::name('hdxxsj')
->alias('h')
->where($Map)
->join('battery_code b', 'b.BatteryCode=h.BatteryCode')
->join('battery_type t', 't.id=b.battery_type_id')
->field('b.battery_type_id,t.type as battery_type,h.BatteryCode')
->find();
$this->success('成功', $Info);
}
/**
* @ApiTitle (故障挂失类型)
* @ApiSummary (故障挂失类型)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/GuzhangType)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": [
{
"id": 1,
"title": "丢失"
},
{
"id": 2,
"title": "故障"
},
{
"id": 3,
"title": "人为损坏"
}
]
})
*/
public function GuzhangType()
{
$Info = [];
$Info = Db::name('guzhang')->select();
$this->success('成功', $Info);
}
/**
* @ApiTitle (故障挂失提交)
* @ApiSummary (故障挂失提交)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/GuzhangTables)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="guzhang_id", type="string", required=true, description="故障挂失类型ID")
* @ApiParams (name="yydt_yhm", type="string", required=true, description="用户名")
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
* @ApiParams (name="BatteryCode", type="string", required=true, description="电池序列号")
* @ApiParams (name="yydt_zrfd", type="string", required=true, description="责任分担")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function GuzhangTables()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$Parmas = $this->request->param();
$data = [
'stor_id' => $StorID,
'guzhang_id' => $Parmas['guzhang_id'],
'yydt_yhm' => $Parmas['yydt_yhm'],
'mobile' => $Parmas['mobile'],
'BatteryCode' => $Parmas['BatteryCode'],
'yydt_zrfd' => $Parmas['yydt_zrfd'],
'createtime' => time()
];
$Res = Db::name('gzgs')->insert($data);
if ($Res) $this->success('提交成功', 1);
else $this->error('提交失败', 0);
}
/**
* @ApiTitle (营业状态开关)
* @ApiSummary (营业状态开关)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/Tooger)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="status", type="string", required=true, description="0=关闭,1=打开")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function Tooger()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$Status = input('status');
Db::name('stor')->where('id', $StorID)->update(['status' => $Status, 'updatetime' => time()]);
$this->success('成功', 1);
}
/**
* @ApiTitle (电池管理)
* @ApiSummary (电池管理)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/BatteryList)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"BatteryCenter": [ //充电中
{
"battery_type_id": 4, //电池型号ID
"num": 1, //数量
"BatteryTitle": "型号4" //电池型号名曾
},
{
"battery_type_id": 2,
"num": 1,
"BatteryTitle": "型号2"
}
],
"Clock": [ //锁定
{
"battery_type_id": 3,
"num": 1,
"BatteryTitle": "型号3"
},
{
"battery_type_id": 1,
"num": 1,
"BatteryTitle": "型号1"
}
],
"BatteryOk": [ //可换电
{
"battery_type_id": 3,
"num": 1,
"BatteryTitle": "型号3"
}
],
"About": [ //全部
{
"battery_type_id": 4,
"num": 1,
"BatteryTitle": "型号4"
},
{
"battery_type_id": 3,
"num": 2,
"BatteryTitle": "型号3"
},
{
"battery_type_id": 2,
"num": 1,
"BatteryTitle": "型号2"
},
{
"battery_type_id": 1,
"num": 1,
"BatteryTitle": "型号1"
}
],
"Count": 1 //本月换电次数
}
})
*/
public function BatteryList()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
//月
$start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
$end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
$map['hd_time'] = ['between', [$start_time, $end_time]];
$data['BatteryCenter'] = [];
$data['Clock'] = [];
$data['BatteryOk'] = [];
$data['About'] = [];
$data['Count'] = count(Db::name('hdxxsj')->where($map)->where('stor_id', $StorID)->select());
/*充电中*/
$data['BatteryCenter'] = Db::name('cp')->where('stor_id', $StorID)->where('status', 1)->field('battery_type_id')->select();
/*锁定*/
$data['Clock'] = Db::name('cp')->where('stor_id', $StorID)->where('status', 2)->field('battery_type_id')->select();
/*可换电*/
$data['BatteryOk'] = Db::name('cp')->where('stor_id', $StorID)->where('status', 0)->field('battery_type_id')->select();
/*全部*/
$data['About'] = Db::name('cp')->where('stor_id', $StorID)->field('battery_type_id')->select();
if (!empty($data['BatteryCenter'])) {
$data['BatteryCenter'] = array_values($this->second_array_unique_bykey($data['BatteryCenter'], 'battery_type_id'));
foreach ($data['BatteryCenter'] as $k => $v) {
$data['BatteryCenter'][$k]['num'] = count(Db::name('cp')->where('stor_id', $StorID)->where('status', 1)->where('battery_type_id', $v['battery_type_id'])->field('battery_type_id')->select());
$data['BatteryCenter'][$k]['BatteryTitle'] = Db::name('battery_type')->where('id', $v['battery_type_id'])->value('type');
}
}
if (!empty($data['Clock'])) {
$data['Clock'] = array_values($this->second_array_unique_bykey($data['Clock'], 'battery_type_id'));
foreach ($data['Clock'] as $k => $v) {
$data['Clock'][$k]['num'] = count(Db::name('cp')->where('stor_id', $StorID)->where('status', 2)->where('battery_type_id', $v['battery_type_id'])->field('battery_type_id')->select());
$data['Clock'][$k]['BatteryTitle'] = Db::name('battery_type')->where('id', $v['battery_type_id'])->value('type');
}
}
if (!empty($data['BatteryOk'])) {
$data['BatteryOk'] = array_values($this->second_array_unique_bykey($data['BatteryOk'], 'battery_type_id'));
foreach ($data['BatteryOk'] as $k => $v) {
$data['BatteryOk'][$k]['num'] = count(Db::name('cp')->where('stor_id', $StorID)->where('status', 0)->where('battery_type_id', $v['battery_type_id'])->field('battery_type_id')->select());
$data['BatteryOk'][$k]['BatteryTitle'] = Db::name('battery_type')->where('id', $v['battery_type_id'])->value('type');
}
}
if (!empty($data['About'])) {
$data['About'] = array_values($this->second_array_unique_bykey($data['About'], 'battery_type_id'));
foreach ($data['About'] as $k => $v) {
$data['About'][$k]['num'] = count(Db::name('cp')->where('stor_id', $StorID)->where('battery_type_id', $v['battery_type_id'])->field('battery_type_id')->select());
$data['About'][$k]['BatteryTitle'] = Db::name('battery_type')->where('id', $v['battery_type_id'])->value('type');
}
}
$this->success('成功', $data);
}
/**
* @ApiTitle (电池管理-充电中)
* @ApiSummary (电池管理-充电中)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/BatteryCenter)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="battery_type_id", type="string", required=true, description="电池型号ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": [
{
"id": 1, //ID
"battery_code": "asdhjghjghjhg", //电池序列号了
"Mac": "sdfsdfdsfsdf", //MAC地址
"battery": "0" //当前电量
},
{
"id": 4,
"battery_code": "asdhjghjghjhg",
"Mac": "sdfsdfdsfsdf",
"battery": "19"
}
]
})
*/
public function BatteryCenter()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$BatteryCenter = [];
$BatteryCenter = Db::name('cp')
->alias('c')
->where('c.stor_id', $StorID)
->where('c.status', 1)
->join('battery_code b', 'b.BatteryCode=c.battery_code')
->field('c.id,c.battery_code,b.Mac,c.battery')
->select();
$this->success('成功', $BatteryCenter);
}
/**
* @ApiTitle (电池管理-锁定)
* @ApiSummary (电池管理-锁定)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/BatteryClock)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="battery_type_id", type="string", required=true, description="电池型号ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": [
{
"id": 3, //ID
"nickname": "百荣科技 产品经理", //用户
"type": "型号3" //电池型号
},
{
"id": 5,
"nickname": "百荣科技 产品经理",
"type": "型号1"
}
]
})
*/
public function BatteryClock()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$BatteryCenter = [];
$BatteryCenter = Db::name('cp')
->alias('c')
->where('c.stor_id', $StorID)
->where('c.status', 2)
->join('battery_type b', 'b.id=c.battery_type_id')
->join('user u', 'u.id=c.user_id')
->field('c.id,u.nickname,b.type')
->select();
$this->success('成功', $BatteryCenter);
}
/**
* @ApiTitle (电池管理-全部)
* @ApiSummary (电池管理-全部)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/BatteryAbout)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": [
{
"id": 1, //ID
"type": "型号4", //电池型号名称
"battery_code": "asdhjghjghjhg", //电池序列号
"status": 1 //电池当前状态:0=可使用,1=充电中,2=锁定,3=可充电,4=下架 限制锁定状态不可下架
},
{
"id": 2,
"type": "型号3",
"battery_code": "asdhjghjghjhg",
"status": 0
},
{
"id": 3,
"type": "型号3",
"battery_code": "asdhjghjghjhg",
"status": 2
},
{
"id": 4,
"type": "型号2",
"battery_code": "asdhjghjghjhg",
"status": 1
},
{
"id": 5,
"type": "型号1",
"battery_code": "asdhjghjghjhg",
"status": 2
}
]
})
*/
public function BatteryAbout()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$BatteryAbout = [];
$BatteryAbout = Db::name('cp')
->alias('c')
->where('c.stor_id', $StorID)
->join('battery_type b', 'b.id=c.battery_type_id')
->field('c.id,b.type,c.battery_code,c.status')
->select();
$this->success('成功', $BatteryAbout);
}
/**
* @ApiTitle (电池管理-可换电)
* @ApiSummary (电池管理-可换电)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/BatteryOk)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": [
{
"id": 1, //ID
"type": "型号4", //电池型号名称
"battery_code": "asdhjghjghjhg", //电池序列号
"status": 1 //电池当前状态:0=可使用,1=充电中,2=锁定,3=可充电,4=下架 限制锁定状态不可下架
}
]
})
*/
public function BatteryOk()
{
$UserId = $this->IsToken($this->request->header());
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$BatteryAbout = [];
$BatteryAbout = Db::name('cp')
->alias('c')
->where('c.stor_id', $StorID)
->where('c.status', 0)
->join('battery_type b', 'b.id=c.battery_type_id')
->field('c.id,b.type,c.battery_code,c.status')
->select();
$this->success('成功', $BatteryAbout);
}
/**
* @ApiTitle (紧急使用)
* @ApiSummary (紧急使用)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/JInji)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="string", required=true, description="数据行ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
})
*/
public function JInji()
{
$UserId = $this->IsToken($this->request->header());
$Id = input('id');
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$Res = Db::name('cp')->where('stod_id', $StorID)->where('id', $Id)->update(['status' => 0]);
if ($Res) $this->success('成功', 1);
else $this->error('失败', 0);
}
/**
* @ApiTitle (下架电池)
* @ApiSummary (下架电池)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/Xiajia)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="string", required=true, description="数据行ID")
* @ApiParams (name="status", type="string", required=true, description="操作 0=上架,4=下架")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
})
*/
public function Xiajia()
{
$UserId = $this->IsToken($this->request->header());
$Parmas = $this->request->param();
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$Res = Db::name('cp')->where('stod_id', $StorID)->where('id', $Parmas['id'])->update(['status' => $Parmas['status']]);
if ($Res) $this->success('成功', 1);
else $this->error('失败', 0);
}
/**
* @ApiTitle (选择电池页面)
* @ApiSummary (选择电池页面)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/OtherBatteryList)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="string", required=true, description="数据行ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": [
{
"battery_id": 2, //ID 发放电池请求使用
"battery_code": "asdhjghjghjhg" //电池序列号
},
{
"battery_id": 5,
"battery_code": "asdhjghjghjhg"
}
]
})
*/
public function OtherBatteryList()
{
$UserId = $this->IsToken($this->request->header());
$Parmas = $this->request->param();
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
//'battery_type_id'
$BatteryType_Id = Db::name('cp')->where('id', $Parmas['id'])->find();
$Map1['status'] = ['EQ', 0];
$Map2['id'] = ['EQ', $Parmas['id']];
$Info = Db::name('cp')->where('stor_id', $StorID)->where($Map1)->where('battery_type_id', $BatteryType_Id['battery_type_id'])->field('id as battery_id,battery_code')->select();
$Info2 = Db::name('cp')->where('stor_id', $StorID)->where($Map2)->where('battery_type_id', $BatteryType_Id['battery_type_id'])->field('id as battery_id,battery_code')->select();
$this->success('成功', array_values(array_merge($Info, $Info2)));
}
/**
* @ApiTitle (发放电池)
* @ApiSummary (发放电池)
* @ApiMethod (POST)
* @ApiRoute (/api/Add/OutBattery)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="string", required=true, description="数据行ID")
* @ApiParams (name="battery_id", type="string", required=true, description="选择的电池ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
})
*/
public function OutBattery()
{
$UserId = $this->IsToken($this->request->header());
$Parmas = $this->request->param();
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
$this->error('您不是门店拥有者');
}
$Con = Db::name('cp')->where('id', $Parmas['id'])->find();
Db::name('cp')->where('id', $Parmas['id'])->update(['status' => 0, 'user_id' => '']);
Db::name('cp')->where('id', $Parmas['battery_id'])->delete();
$data = [
'user_id' => $Con['user_id'],
'stor_id' => $StorID,
'name' => Db::name('user')->where('id', $Con['user_id'])->value('nickname'),
'hd_time' => time(),
'BatteryCode' => $Con['battery_code']
];
Db::name('hdxxsj')->insert($data);
$this->success('发放成功', 1);
}
}
\ No newline at end of file
... ...
... ... @@ -13,6 +13,7 @@ use think\Hook;
use EasyWeChat\Foundation\Application;
use think\Db;
use app\common\model\Attachment;
use think\Log;
use think\process\exception\Timeout;
/**
... ... @@ -371,7 +372,7 @@ class Common extends Api
public function AgreementConfigMoney()
{
$params = $this->request->param();
$MoneyConfigArr = Db::name('money_config')->where('battery_id', $params['battery_id'])->find();
$MoneyConfigArr = Db::name('money_config')->where('battery_type_id', $params['battery_id'])->find();
$data = [
'UpMoney' => $MoneyConfigArr['UpMoney'],
'MonthMoney' => $MoneyConfigArr['MonthMoney'] * 3
... ... @@ -480,6 +481,10 @@ class Common extends Api
*/
public function TuikuanOperation()
{
Log::init([
'path' => LOG_PATH . 'tuikuanLog' . date('Y-m-d H:i:s', time()),
'type' => 'file'
]);
$UserId = $this->IsToken($this->request->header());
$params = $this->request->param();
$IsSeller = Db::name('agreement')
... ... @@ -502,8 +507,14 @@ class Common extends Api
$res = Db::name('tuikuan')->where('OrderSn', $OrderInfo['OrderSn'])->where('seller_id', $IsSeller)->update(['status' => $params['type']]);
if ($params['type'] == 1) {
$OrderSn = Db::name('agreement')->where('id', $params['id'])->find();
$PayOrderInfo = Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('type', 1)->find();
$TuiMoney = $OrderSn['UpMoney'] + $OrderSn['Money'];
// $PayOrderInfo = Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('type', 1)->find();
$PayOrderInfo = Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('type', 1)->select();
// $TuiMoney = $OrderSn['UpMoney'] + $OrderSn['Money'];
$TuiMoney = round(($OrderSn['UpMoney'] * $params['bili'] + $OrderSn['Money']), 2);
log::write('押金' . $params['UpMoney']);
log::write('剩余租金' . $params['Money']);
log::write('比例' . $params['bili']);
log::write('应退金额' . $TuiMoney);
//配置
$config = [
'app_id' => 'wx6a9080f20326f817',
... ... @@ -516,18 +527,34 @@ class Common extends Api
];
$app = new Application($config);
$payment = $app->payment;
try {
$result = $payment->refundByTransactionId($PayOrderInfo['WeChatOrder'], $PayOrderInfo['PayOrder'], $PayOrderInfo['money'] * 100, $TuiMoney * 100); // 总金额 100, 退款 80,操作员:商户号
// try {
// $result = $payment->refundByTransactionId($PayOrderInfo['WeChatOrder'], $PayOrderInfo['PayOrder'], $PayOrderInfo['money'] * 100, $TuiMoney * 100); // 总金额 100, 退款 80,操作员:商户号
// //更改订单状态为已退款
// Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('PayOrder', $PayOrderInfo['PayOrder'])->update(['type' => 0]);
foreach ($PayOrderInfo as $k => $v) {
log::write('循环次数' . $k . '剩余应退金额' . $TuiMoney);
$result = $payment->refundByTransactionId($v['WeChatOrder'], $v['PayOrder'], $v['money'] * 100, (($TuiMoney > $v['money']) ? $v['money'] : $TuiMoney) * 100); // 总金额 100, 退款 80,操作员:商户号
//更改订单状态为已退款
Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('PayOrder', $PayOrderInfo['PayOrder'])->update(['type' => 0]);
} catch (Exception $e) {
$e->getMessage();
}
if (!$result) {
$this->error('退款失败', 0);
die;
Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('PayOrder', $v['PayOrder'])->update(['type' => 0]);
if (!$result) {
$this->error('退款失败', 0);
die;
}
$TuiMoney = ($TuiMoney > $v['money']) ? ($TuiMoney - $v['money']) : 0;
log::write('循环次数' . $k . '退款后剩余应退金额' . $TuiMoney);
if ($TuiMoney == 0) {
break;
}
}
}
//
// } catch (Exception $e) {
// $e->getMessage();
// }
// }
}
$this->res($res);
}
... ... @@ -548,7 +575,8 @@ class Common extends Api
'msg':'返回成功',
)
*/
public function DeleteOrder()
public
function DeleteOrder()
{
$UserId = $this->IsToken($this->request->header());
$OrderSn = input('OrderSn');
... ... @@ -583,7 +611,8 @@ class Common extends Api
'msg':'返回成功',
)
*/
public function UpMoneyOperation()
public
function UpMoneyOperation()
{
$UserId = $this->IsToken($this->request->header());
$params = $this->request->param();
... ... @@ -642,7 +671,8 @@ class Common extends Api
'msg':'返回成功',
)
*/
public function OrderOperation()
public
function OrderOperation()
{
$UserId = $this->IsToken($this->request->header());
$params = $this->request->param();
... ... @@ -668,7 +698,8 @@ class Common extends Api
//定时任务
public function MonthMoney()
public
function MonthMoney()
{
$Arr = Db::name('agreement')->select();
if (!empty($Arr)) {
... ... @@ -713,18 +744,19 @@ class Common extends Api
}
)
*/
public function BatteryCon()
public
function BatteryCon()
{
$Code = input('battery_code');
if (empty($Code) || $Code == '' || $Code == "" || $Code == null) {
$this->error('请先链接蓝牙', 0);
die;
}
$map['BatteryCode'] = ['LIKE', '%' . $Code . '%'];
$map['BatteryCode'] = ['EQ', $Code];
//用户电池分类ID
$Id = Db::name('battery_code')->where($map)->find();
if (empty($Id)) {
$this->error('系统没有找到该电池分类', 0);
$this->error('系统没有找到该电池', 0);
die;
}
$data = [
... ... @@ -736,7 +768,8 @@ class Common extends Api
}
//定时任务
public function delNoPay()
public
function delNoPay()
{
Db::name('agreement')->where('pay', 0)->delete();
}
... ...
<?php
namespace app\api\controller;
use think\Db;
use app\common\controller\Api;
/**
* 数据存储
*/
class Data extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* @ApiTitle (产品移动轨迹记录)
* @ApiSummary (产品移动轨迹记录)
* @ApiMethod (POST)
* @ApiRoute (/api/Data/BatteryWhere)
* @ApiParams (name="cp_xulehao", type="string", required=true, description="产品序列号")
* @ApiParams (name="lng", type="string", required=true, description="经度")
* @ApiParams (name="lat", type="string", required=true, description="纬度")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function BatteryWhere()
{
$Params = $this->request->param();
Db::name('gis')->insert(['cp_xulehao' => $Params['cp_xulehao'], 'lng' => $Params['lng'], 'lat' => $Params['lat'], 'createtime' => time()]);
$this->success('成功', 1);
}
/**
* @ApiTitle (动态数据记录)
* @ApiSummary (动态数据记录)
* @ApiMethod (POST)
* @ApiRoute (/api/Data/DynamicData)
* @ApiParams (name="cp_xulehao", type="string", required=true, description="产品序列号")
* @ApiParams (name="yydt_jb", type="string", required=true, description="警报信息")
* @ApiParams (name="yydt_dqdl", type="string", required=true, description="当前电量")
* @ApiParams (name="yydt_gfbhcs", type="string", required=true, description="过放保护次数")
* @ApiParams (name="yydt_gfbcsj", type="string", required=true, description="过放保护时间")
* @ApiParams (name="yydt_ljxhcs", type="string", required=true, description="累计循环次数")
* @ApiParams (name="yydt_dqrl", type="string", required=true, description="当前容量")
* @ApiParams (name="yydt_zfdl", type="string", required=true, description="总放电量")
* @ApiParams (name="yydt_zcdl", type="string", required=true, description="总充电量")
* @ApiParams (name="yydt_pjdy", type="string", required=true, description="平均电压")
* @ApiParams (name="yydt_zgdtdy", type="string", required=true, description="最高单体电压")
* @ApiParams (name="yydt_zddtdy", type="string", required=true, description="最低单体电压")
* @ApiParams (name="yydt_dqzgwd", type="string", required=true, description="当前最高温度")
* @ApiParams (name="yydt_dqzdwd", type="string", required=true, description="当前最低温度")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function DynamicData()
{
$Params = $this->request->param();
$data = [
'cp_xulehao' => $Params['cp_xulehao'],
'yydt_jb' => $Params['yydt_jb'],
'yydt_dqdl' => $Params['yydt_dqdl'],
'yydt_gfbhcs' => $Params['yydt_gfbhcs'],
'yydt_gfbcsj' => $Params['yydt_gfbcsj'],
'yydt_ljxhcs' => $Params['yydt_ljxhcs'],
'yydt_dqrl' => $Params['yydt_dqrl'],
'yydt_zfdl' => $Params['yydt_zfdl'],
'yydt_zcdl' => $Params['yydt_zcdl'],
'yydt_pjdy' => $Params['yydt_pjdy'],
'yydt_zgdtdy' => $Params['yydt_zgdtdy'],
'yydt_zddtdy' => $Params['yydt_zddtdy'],
'yydt_dqzgwd' => $Params['yydt_dqzgwd'],
'yydt_dqzdwd' => $Params['yydt_dqzdwd'],
'createtime' => time()
];
Db::name('yydtsjb')->insert($data);
$this->success('成功', 1);
}
}
\ No newline at end of file
... ...
... ... @@ -67,8 +67,8 @@ class Index extends Api
/**
* 首页接口
* @ApiTitle (新增/更改门店)
* @ApiSummary (新增/更改门店)
* @ApiTitle (新增/更改门店(改))
* @ApiSummary (新增/更改门店(改))
* @ApiMethod (POST)
* @ApiRoute (/api/Index/InsertUpdateStor)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
... ... @@ -83,7 +83,6 @@ class Index extends Api
* @ApiParams (name="address_con", type="string", required=true, description="详细地址")
* @ApiParams (name="mobile", type="string", required=true, description="联系电话")
* @ApiParams (name="hours", type="string", required=true, description="营业时间")
* @ApiParams (name="Battery", type="string", required=true, description="电池分类Json数组type_id.num)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
... ... @@ -107,11 +106,10 @@ class Index extends Api
'address_con' => $params['address_con'],
'mobile' => $params['mobile'],
'hours' => $params['hours'],
'Battery' => htmlspecialchars_decode($params['Battery']),
];
if(!empty($params['lng'])){
$data['lng'] = $params['lng'];
$data['lat'] = $params['lat'];
if (!empty($params['lng'])) {
$data['lng'] = $params['lng'];
$data['lat'] = $params['lat'];
}
$Res = Db::name('stor')->insert($data);
... ... @@ -125,8 +123,8 @@ class Index extends Api
'lat' => $params['lat'],
'address_con' => $params['address_con'],
'mobile' => $params['mobile'],
'hours' => $params['hours'],
'Battery' => htmlspecialchars_decode($params['Battery'])])->value('id');
'hours' => $params['hours']
])->value('id');
$this->NameCarQrCode('storID' . $StorID, $params['url'] . '?stor_id=' . $StorID);
Db::name('stor')->where('user_id', $UserId)->where('id', $StorID)->update(['stor_image' => '/images/storID' . $StorID . '.png']);
} else {
... ... @@ -140,7 +138,6 @@ class Index extends Api
'address_con' => $params['address_con'],
'mobile' => $params['mobile'],
'hours' => $params['hours'],
'Battery' => htmlspecialchars_decode($params['Battery']),
];
$Res = Db::name('stor')->where('id', $params['id'])->update($data);
}
... ... @@ -150,8 +147,8 @@ class Index extends Api
/**
* 首页接口
* @ApiTitle (门店更改回显)
* @ApiSummary (门店更改回显)
* @ApiTitle (门店更改回显(改))
* @ApiSummary (门店更改回显(改))
* @ApiMethod (POST)
* @ApiRoute (/api/Index/UpdateStorBack)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
... ... @@ -171,16 +168,6 @@ class Index extends Api
"mobile": "13292442918", //联系方式
"hours": "1213", 营业时间
"stor_image": "", 店铺吗
"Battery": [ //电池分类
{
"type_id": "1",
"num": "10"
},
{
"type_id": "2",
"num": "10"
}
]
}
})
*/
... ... @@ -192,10 +179,6 @@ class Index extends Api
if (empty($Arr)) {
$this->error('参数错误', 0);
}
$BatteryArr = json_decode($Arr['Battery'], true);
foreach ($BatteryArr as $k => $v) {
$BatteryArr[$k]['title'] = Db::name('battery_code')->where('id', $v['type_id'])->value('title');
}
$data = [
'avatar' => cdnurl($Arr['avatar']),
'name' => $Arr['name'],
... ... @@ -206,7 +189,6 @@ class Index extends Api
'mobile' => $Arr['mobile'],
'hours' => $Arr['hours'],
'stor_image' => $this->request->domain() . $Arr['stor_image'],
'Battery' => $BatteryArr,
];
$this->success('成功', $data);
}
... ... @@ -625,17 +607,16 @@ class Index extends Api
*/
public function MapStor()
{
$Arr = Db::name('stor')->select();
$Arr = Db::name('stor')->where('status', 1)->select();
$Code = input('battery_code');
$battery_code = explode('-', $Code);
if (empty($Code) || $Code == '' || $Code == "" || $Code == null) {
$this->error('请先链接蓝牙', 0);
die;
}
$map['BatteryCode'] = ['LIKE', '%' . $battery_code[0] . '%'];
$map['BatteryCode'] = ['EQ', $Code];
//用户电池分类ID
$Id = Db::name('battery_code')->where($map)->value('id');
if (empty($Id)) {
$BatteryTypeId = Db::name('battery_code')->where($map)->value('battery_type_id');
if (empty($BatteryTypeId)) {
$this->error('系统没有找到该电池分类', 0);
die;
}
... ... @@ -643,20 +624,13 @@ class Index extends Api
$List = [];
} else {
foreach ($Arr as $k => $v) {
$i = 0;
$List[$k]['id'] = $v['id'];
$List[$k]['name'] = $v['name'];
$List[$k]['lng'] = $v['lng'];
$List[$k]['lat'] = $v['lat'];
$JsonArr = json_decode($v['Battery'], true);
foreach ($JsonArr as $k1 => $v1) {
if ($v1['type_id'] == $Id) {
$List[$k]['num'] = $v1['num'];
$i++;
}
}
if ($i == 0) {
$List[$k]['num'] = 0;
$Battery = Db::name('cp')->where('battery_type_id', $BatteryTypeId)->where('status', 0)->where('stor_id', $v['id'])->select();
if (!empty($Battery)) {
$List[$k]['id'] = $v['id'];
$List[$k]['name'] = $v['name'];
$List[$k]['lng'] = $v['lng'];
$List[$k]['lat'] = $v['lat'];
$List[$k]['num'] = count($Battery);
}
}
}
... ... @@ -687,11 +661,10 @@ class Index extends Api
{
$UserId = $this->IsToken($this->request->header());
$params = $this->request->param();
$battery_code = explode('-', $params['battery_code']);
$map['BatteryCode'] = ['LIKE', '%' . $battery_code[0] . '%'];
$map['BatteryCode'] = ['EQ', $params['battery_code']];
//用户电池分类ID
$Id = Db::name('battery_code')->where($map)->value('id');
if (empty($Id)) {
$BatteryTypeId = Db::name('battery_code')->where($map)->value('battery_type_id');
if (empty($BatteryTypeId)) {
$this->error('系统没有找到该电池分类', 0);
die;
}
... ... @@ -711,7 +684,7 @@ class Index extends Api
'OrderSn' => $OrderSn,
'stor_id' => $params['id'],
'user_id' => $UserId,
'battery_id' => $Id,
'battery_type_id' => $BatteryTypeId,
'battery_code' => $params['battery_code'],
'manufactor' => $params['manufactor'],
'Voltage' => $params['Voltage'],
... ... @@ -721,6 +694,19 @@ class Index extends Api
'updatetime' => time()
];
$res = Db::name('order')->insert($data);
/*去换电 锁定电池*/
$cp_id = Db::name('cp')->where('stor_id', $params['id'])->where('battery_type_id', $BatteryTypeId)->where('status', 0)->value('id');
if (empty($cp_id)) {
$this->error('信息异常', 0);
}
/*增加锁定产品数量*/
$ztsd = Db::name('ztsd')->where('battery_type_id', $BatteryTypeId)->where('stor_id', $params['id'])->find();
if (empty($ztsd)) {
Db::name('ztsd')->insert(['cp_sl' => 1, 'stor_id' => $params['id'], 'battery_type_id' => $BatteryTypeId]);
} else {
Db::name('ztsd')->where('id', $ztsd['id'])->update(['cp_sl' => $ztsd['cp_sl'] + 1]);
}
Db::name('cp')->where('id', $cp_id)->update(['status' => 2, 'user_id' => $UserId]);
$this->res($res);
}
... ... @@ -892,8 +878,8 @@ class Index extends Api
$List[$k]['status'] = $v['status'];
$List[$k]['refind_status'] = $v['refind_status'];
$List[$k]['CompanyName'] = $v['CompanyName'];
$List[$k]['create_time'] = date('Y-m-d H:i',$v['createtime']);
$List[$k]['EXP_time'] = date('Y-m-d H:i',$v['EXP_time']);
$List[$k]['create_time'] = date('Y-m-d H:i', $v['createtime']);
$List[$k]['EXP_time'] = date('Y-m-d H:i', $v['EXP_time']);
}
$data = [
'Count' => count($Count),
... ... @@ -956,6 +942,10 @@ class Index extends Api
'createtime' => time()
];
$Res = Db::name('battery')->insert($data);
/*更改电量状态*/
if ($Params['battery'] == 100) $Status = 0;
else $Status = 1;
Db::name('cp')->where('battery_code', $Params['code'])->update(['status' => $Status, 'battery' => $Params['battery']]);
$this->Res($Res);
}
}
... ...
... ... @@ -20,7 +20,6 @@ class User extends Api
/**
* 用户接口
* @ApiTitle (用户登陆)
* @ApiSummary (用户登陆)
* @ApiMethod (POST)
... ... @@ -34,7 +33,8 @@ class User extends Api
'code':'1',
'msg':'返回成功',
'data':{
'token' => token,
'token' : token,
'BindMobile':0=未绑定,1=已绑定
})
*/
public function UserLogin()
... ... @@ -85,14 +85,14 @@ class User extends Api
$return = [
'token' => $rult['token'],
'avatar' => $param['avatar'],
'nickname' => $param['nickname']
'nickname' => $param['nickname'],
'BindMobile' => $rult['mobile'] == "" ? 0 : 1
];
$this->success('成功', $return);
}
/**
* 用户接口
* @ApiTitle (Code换token)
* @ApiSummary (Code换token)
* @ApiMethod (POST)
... ... @@ -145,4 +145,29 @@ class User extends Api
$this->success('成功', $token);
}
}
/**
* @ApiTitle (绑定手机号)
* @ApiSummary (绑定手机号)
* @ApiMethod (POST)
* @ApiRoute (/api/User/BindMobile)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="mobile", type="integer", required=true, description="手机号")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function BindMobile()
{
$UserId = $this->IsToken($this->request->header());
$Mobile = input('mobile');
$Res = Db::name('user')->where('id', $UserId)->update(['mobile' => $Mobile, 'updatetime' => time()]);
if ($Res) $this->success('绑定成功', 1);
else $this->error('绑定失败', 0);
}
}
... ...
... ... @@ -326,7 +326,9 @@ class Api
$this->request->token();
}
//检查Token
/**
* 检查token
*/
protected function IsToken($token)
{
if (empty($token['token'])) {
... ... @@ -339,7 +341,10 @@ class Api
return $is_token['id'];
}
//接收全部参数
/**
* 接受全部参数
* @ApiInternal
* */
public function MyParams()
{
$params = $this->request->param();
... ... @@ -348,7 +353,10 @@ class Api
return $params;
}
//Res
/**
* 验证申请是否唯一
* @ApiInternal
* */
public function Res($res)
{
if ($res) {
... ... @@ -358,7 +366,10 @@ class Api
}
}
//验证申请是否唯一
/**
* 验证申请是否唯一
* @ApiInternal
* */
public function OnlySeller($UserId)
{
$SellerArr = Db::name('seller')->where('user_id', $UserId)->find();
... ... @@ -367,7 +378,9 @@ class Api
}
}
//订单号生成
/**
* @ApiInternal
* */
public function order_sn()
{
@date_default_timezone_set("PRC");
... ... @@ -384,16 +397,20 @@ class Api
}
//生成支付单号
/**
* @ApiInternal
* */
public function PayOrder()
{
//生成订单号
$yCode = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K','L','M','N');
$yCode = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N');
$PayOrder = $yCode[intval(date('Y')) - 2011] . strtoupper(dechex(date('m'))) . date('d') . substr(time(), -5) . substr(microtime(), 2, 5) . sprintf('%02d', rand(0, 99));
return $PayOrder;
}
/**
* @ApiInternal
* */
public function Tuikuan($OrderSn)
{
$PayOrderInfo = Db::name('pay_order')->where('OrderSn', $OrderSn)->where('type', 1)->find();
... ... @@ -425,6 +442,7 @@ class Api
/**
* @ApiInternal
* 生成名片二维码
*/
function NameCarQrCode($ImageName, $url = '')
... ... @@ -440,4 +458,22 @@ class Api
$qr1 = new \QRcode();
$qr1::png($value, $fileName, $errorCorrectionLevel, $matrixPointSize, 2);
}
/**
* @ApiInternal
*/
function second_array_unique_bykey($arr, $key)
{
$tmp_arr = array();
foreach ($arr as $k => $v) {
if (in_array($v[$key], $tmp_arr)) //搜索$v[$key]是否在$tmp_arr数组中存在,若存在返回true
{
unset($arr[$k]); //销毁一个变量 如果$tmp_arr中已存在相同的值就删除该值
} else {
$tmp_arr[$k] = $v[$key]; //将不同的值放在该数组中保存
}
}
//ksort($arr); //ksort函数对数组进行排序(保留原键值key) sort为不保留key值
return $arr;
}
}
... ...
不能预览此文件类型
此 diff 太大无法显示。
... ... @@ -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: 'battery_type_id', title: __('Battery_type_id')},
{field: 'batterytype.type', title: __('Batterytype.type'), operate: 'LIKE'},
{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: '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
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'guzhang/index' + location.search,
add_url: 'guzhang/add',
edit_url: 'guzhang/edit',
del_url: 'guzhang/del',
multi_url: 'guzhang/multi',
import_url: 'guzhang/import',
table: 'guzhang',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title'), 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,8 +26,8 @@ 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: 'batterytype.type', title: __('Batterytype.type'), operate: 'LIKE'},
{field: 'UpMoney', title: __('Upmoney'), operate:'BETWEEN'},
{field: 'MonthMoney', title: __('Monthmoney'), operate:'BETWEEN'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
... ...
... ... @@ -29,7 +29,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'OrderSn', title: __('Ordersn'), operate: 'LIKE'},
// {field: 'stor_id', title: __('Stor_id')},
// {field: 'user_id', title: __('User_id')},
// {field: 'battery_id', title: __('Battery_id')},
{field: 'stor.name', title: __('Stor.name'), operate: 'LIKE'},
{field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
{field: 'user.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
... ...