自定义表单功能优化修复
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
use think\facade\Db;
|
||||
use app\model\Form as FormM;
|
||||
use app\model\FormAttr;
|
||||
|
||||
@@ -17,6 +18,15 @@ use app\model\FormAttr;
|
||||
*/
|
||||
class Form extends Base {
|
||||
|
||||
public $modelInfo = [];
|
||||
public $model = null;
|
||||
|
||||
public function initialize() {
|
||||
parent::initialize();
|
||||
$this->modelInfo = FormM::where('id', $this->request->param('form_id'))->find();
|
||||
$this->model = Db::name('Form'.ucfirst($this->modelInfo['name']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 表单列表
|
||||
*/
|
||||
@@ -78,10 +88,15 @@ class Form extends Base {
|
||||
* @title 删除表单
|
||||
*/
|
||||
public function del() {
|
||||
$id = $this->getArrayParam('id');
|
||||
$result = false;
|
||||
if (false !== $result) {
|
||||
return $this->success('删除成功!');
|
||||
$id = $this->request->param('id', 0);
|
||||
|
||||
if (!$id) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
|
||||
$result = FormM::find($id)->delete();
|
||||
if ($result) {
|
||||
return $this->success('删除模型成功!');
|
||||
} else {
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
@@ -95,18 +110,17 @@ class Form extends Base {
|
||||
* @return html 页面
|
||||
*/
|
||||
public function lists($form_id = '') {
|
||||
$form = $this->model->where('id', $form_id)->find();
|
||||
$form = $this->modelInfo;
|
||||
|
||||
$list = M($form['name'], 'form')->order('id desc')->paginate(25);
|
||||
$list = $this->model->order('id desc')->paginate(25);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'meta_title' => $this->modelInfo['title'] . '列表',
|
||||
'form_id' => $form_id,
|
||||
'list' => $list,
|
||||
'page' => $list->render()
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('数据列表');
|
||||
return $this->fetch('list_'.$form['name']);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user