<table id="sample-table-1" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th class="center">
<label>
<input type="checkbox" class="ace" />
<span class="lbl"></span>
</label>
</th>
<th>商品编号</th>
<th>商品名称</th>
<th>商品图片</th>
<th>所属分类</th>
<th>水果重量</th>
<th>水果库存</th>
<th>已销售量</th>
<th>产地</th>
<th>销售价</th>
<th>会员价</th>
<th>是否上架</th>
<th>是否参与活动</th>
<th>操作</th>
</tr>
</thead>
<tbody class="body">
{foreach name='data' item='v'}
<tr>
<td class="center">
<label>
<input type="checkbox" class ='box' name="box" alt="{$v.f_id}"/>
<span class="lbl"></span>
</label>
</td>
<td>{$v.f_id}</td>
<td>{$v.f_name}</td>
<td><img src="<?php echo $v['f_img'];?>" alt="" width="50"></td>
<td>{$v.t_name}</td>
<td>{$v.f_weight}</td>
<td>{$v.f_surplus}</td>
<td>{$v.f_sale}</td>
<td>{$v.f_place}</td>
<td>{$v.m_price}</td>
<td>{$v.v_price}</td>
<td>
{if condition="$v.is_show == 1"}
上架
{else /}
下架
{/if}
</td>
<td>
{if condition="$v.is_hot== 1"}
参与活动
{else /}
不参与活动
{/if}
</td>
<td>
<a href="{:url('index/Goods/modify')}?fid={$v.f_id}">编辑</a>
<button class="del" alt="{$v.f_id}">删除</button>
</td>
</tr>
{/foreach}
</tbody>
</table>
<center>
<table >
<div><div class="pages">{$page}</div>
<input type="button" class="quan" value="全选">
<input type="button" class="fan" value="反选">
<input type="button" class="pishan" value="批删">
<input type="text" class="pa" value="{$num}"></div>
</table>
</center>
</div><!-- /.table-responsive -->
</div><!-- /span -->
</div><!-- /row -->
//单条修改渲染
public function modify(){
$fid=$_GET['fid'];
$res=db('sg_fruits')
->join('sg_type','sg_fruits.t_id = sg_type.t_id')
->where("f_id =$fid")
->find();
// $res=Db::table('sg_fruits')->where("f_id =$fid")->find();
//分类
$re= db('sg_type')->select();
$this->view->engine->layout(true);
$this->assign('data',$res);
$this->assign('re',$re);
return view('modify');
}
//接值修改
public function upto(){
$data=$_POST;
$f_id=$data['f_id'];
$file = request()->file('img');
if($file){
// 移动到框架应用根目录/public/uploads/ 目录下
$info = $file->move(ROOT_PATH . 'public/uploads');
// var_dump($info) ;die;
if($info){
// 成功上传后 获取上传信息
$a=$info->getSaveName();
$imgp= str_replace("\\","/",$a);
$imgpath='uploads/'.$imgp;
$data['f_img']= $imgpath;
$resd=Db::table('sg_fruits')->where("f_id=$f_id")->update($data);
if($resd){
$this->redirect("goods/lists");
}
}
}else{
//根据商品id修改
$res=Db::table('sg_fruits')->where("f_id=$f_id")->update($data);
if($res){
$this->redirect("goods/lists");
}
}
}