作者 王智

daima

... ... @@ -5,13 +5,13 @@ namespace app\admin\controller;
use app\common\controller\Backend;
/**
*
*
*
* @icon fa fa-circle-o
*/
class Renwu extends Backend
{
/**
* Renwu模型对象
* @var \app\admin\model\Renwu
... ... @@ -26,48 +26,58 @@ class Renwu extends Backend
$this->view->assign("xiTypeList", $this->model->getXiTypeList());
$this->view->assign("zhaoTypeList", $this->model->getZhaoTypeList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
$pid = input('pid');
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
if (empty($pid)) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
}
$map = [];
if ($pid == 1) {
$map['type'] = ['eq', 3];
}
if ($pid == 2) {
$map['type'] = ['eq', 2];
}
$total = $this->model
->with(['user','vip'])
->where($where)
->order($sort, $order)
->count();
->with(['user', 'vip'])
->where($where)
->order($sort, $order)
->where($map)
->count();
$list = $this->model
->with(['user','vip'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
->with(['user', 'vip'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->where($map)
->select();
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname','mobile','address','address_con','car_num','color','car_type','vip']);
$row->getRelation('vip')->visible(['title']);
$row->getRelation('user')->visible(['nickname', 'mobile', 'address', 'address_con', 'car_num', 'color', 'car_type', 'vip']);
$row->getRelation('vip')->visible(['title']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
... ...
... ... @@ -3,28 +3,32 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text" value="{$row.order_sn|htmlentities}">
<input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text"
value="{$row.order_sn|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="" data-source="user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
<input id="c-user_id" data-rule="" data-source="user/index" data-field="nickname"
class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Vip_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-vip_id" data-rule="" data-source="vip/index" data-field="title" class="form-control selectpage" name="row[vip_id]" type="text" value="{$row.vip_id|htmlentities}">
<input id="c-vip_id" data-rule="" data-source="vip/index" data-field="title" class="form-control selectpage"
name="row[vip_id]" type="text" value="{$row.vip_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
<option value="{$key}" {in name="key" value="$row.type" }selected{
/in}>{$vo}</option>
{/foreach}
</select>
... ... @@ -33,16 +37,19 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Xi_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-xi_id" data-rule="" data-source="user/index" data-field="nickname" class="form-control selectpage" name="row[xi_id]" type="text" value="{$row.xi_id|htmlentities}">
<input id="c-xi_id" data-rule="" data-source="user/index" data-field="nickname"
class="form-control selectpage" name="row[xi_id]" type="text" value="{$row.xi_id|htmlentities}"
onchange="set_next_input(this);">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Xi_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-xi_type" class="form-control selectpicker" name="row[xi_type]">
<select id="c-xi_type" class="form-control selectpicker" name="row[xi_type]">
{foreach name="xiTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.xi_type"}selected{/in}>{$vo}</option>
<option value="{$key}" {in name="key" value="$row.xi_type" }selected{
/in}>{$vo}</option>
{/foreach}
</select>
... ... @@ -52,10 +59,16 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Xi_images')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-xi_images" class="form-control" size="50" name="row[xi_images]" type="text" value="{$row.xi_images|htmlentities}">
<input id="c-xi_images" class="form-control" size="50" name="row[xi_images]" type="text"
value="{$row.xi_images|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-xi_images" class="btn btn-danger plupload" data-input-id="c-xi_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-xi_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-xi_images" class="btn btn-primary fachoose" data-input-id="c-xi_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
<span><button type="button" id="plupload-xi_images" class="btn btn-danger plupload"
data-input-id="c-xi_images"
data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp"
data-multiple="true" data-preview-id="p-xi_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-xi_images" class="btn btn-primary fachoose"
data-input-id="c-xi_images" data-mimetype="image/*" data-multiple="true"><i
class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-xi_images"></span>
</div>
... ... @@ -65,16 +78,19 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Zhao_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-zhao_id" data-rule="" data-source="user/index" data-field="nickname" class="form-control selectpage" name="row[zhao_id]" type="text" value="{$row.zhao_id|htmlentities}">
<input id="c-zhao_id" data-rule="" data-source="user/index" data-field="nickname"
class="form-control selectpage" name="row[zhao_id]" type="text" value="{$row.zhao_id|htmlentities}"
onchange="set_next_input2(this);">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Zhao_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-zhao_type" class="form-control selectpicker" name="row[zhao_type]">
<select id="c-zhao_type" class="form-control selectpicker" name="row[zhao_type]">
{foreach name="zhaoTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.zhao_type"}selected{/in}>{$vo}</option>
<option value="{$key}" {in name="key" value="$row.zhao_type" }selected{
/in}>{$vo}</option>
{/foreach}
</select>
... ... @@ -84,10 +100,16 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Zhao_images')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-zhao_images" class="form-control" size="50" name="row[zhao_images]" type="text" value="{$row.zhao_images|htmlentities}">
<input id="c-zhao_images" class="form-control" size="50" name="row[zhao_images]" type="text"
value="{$row.zhao_images|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-zhao_images" class="btn btn-danger plupload" data-input-id="c-zhao_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-zhao_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-zhao_images" class="btn btn-primary fachoose" data-input-id="c-zhao_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
<span><button type="button" id="plupload-zhao_images" class="btn btn-danger plupload"
data-input-id="c-zhao_images"
data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp"
data-multiple="true" data-preview-id="p-zhao_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-zhao_images" class="btn btn-primary fachoose"
data-input-id="c-zhao_images" data-mimetype="image/*" data-multiple="true"><i
class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-zhao_images"></span>
</div>
... ... @@ -97,7 +119,8 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Car_address')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-car_address" class="form-control" name="row[car_address]" type="text" value="{$row.car_address|htmlentities}">
<input id="c-car_address" class="form-control" name="row[car_address]" type="text"
value="{$row.car_address|htmlentities}">
</div>
</div>
<div class="form-group">
... ... @@ -115,13 +138,17 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Startime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-startime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[startime]" type="text" value="{:$row.startime?datetime($row.startime):''}">
<input id="c-startime" data-rule="required" class="form-control datetimepicker"
data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[startime]" type="text"
value="{:$row.startime?datetime($row.startime):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Endtime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-endtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[endtime]" type="text" value="{:$row.endtime?datetime($row.endtime):''}">
<input id="c-endtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss"
data-use-current="true" name="row[endtime]" type="text"
value="{:$row.endtime?datetime($row.endtime):''}">
</div>
</div>
<div class="form-group layer-footer">
... ... @@ -132,3 +159,18 @@
</div>
</div>
</form>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
function set_next_input(obj) {
//改变下面这个框的数据源
$("#c-xi_id_text").data("selectPageObject").option.data = 'Renwu/index?pid=1';
}
function set_next_input2(obj) {
//改变下面这个框的数据源
$("#c-zhao_id_id_text").data("selectPageObject").option.data = 'Renwu/index?pid=2';
}
</script>
... ...