fastadmin列表头部加按钮,点击弹出窗口提交数据保存
index.html
<a href="{:url('pattern/piliangadd')}" class="btn btn-success btn-piliangadd btn-dialog {:$auth->check('pattern/piliangadd')?'':'hide'}" title="批量添加" ><i class="fa fa-plus"></i> 批量添加</a>
pattern.php
public function piliangadd(){
if (false === $this->request->isPost()) {
return $this->view->fetch();
}
$params = $this->request->post('row/a');
Db::startTrans();
try {
if(!empty($params['namea']) && !empty($params['imagea'])){
$dataa = [
'name'=>$params['namea'],
'image'=>$params['imagea'],
'status'=>'1',
'weight'=>0,
'createtime'=>time(),
];
Db::name('pattern')->insert($dataa);
}
if(!empty($params['nameb']) && !empty($params['imageb'])){
$datab = [
'name'=>$params['nameb'],
'image'=>$params['imageb'],
'status'=>'1',
'weight'=>0,
'createtime'=>time(),
];
Db::name('pattern')->insert($datab);
}
if(!empty($params['namec']) && !empty($params['imagec'])){
$datac = [
'name'=>$params['namec'],
'image'=>$params['imagec'],
'status'=>'1',
'weight'=>0,
'createtime'=>time(),
];
Db::name('pattern')->insert($datac);
}
if(!empty($params['named']) && !empty($params['imaged'])){
$datad = [
'name'=>$params['named'],
'image'=>$params['imaged'],
'status'=>'1',
'weight'=>0,
'createtime'=>time(),
];
Db::name('pattern')->insert($datad);
}
Db::commit();
$this->success('操作成功');
} catch (Exception $e) {
Db::
上一篇: 详解 nginx l
下一篇: javascript