更新
This commit is contained in:
@@ -8,8 +8,32 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller;
|
||||
|
||||
use \app\model\Form;
|
||||
|
||||
|
||||
class Front extends Base {
|
||||
public function index() {
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function form(){
|
||||
if($this->request->isAjax()){
|
||||
|
||||
}else{
|
||||
$id = $this->request->param('id');
|
||||
$name = $this->request->param('name');
|
||||
|
||||
$map = [];
|
||||
|
||||
$map[] = ['id', '=', $id];
|
||||
|
||||
$info = Form::where($map)->find();
|
||||
|
||||
|
||||
$this->data = [
|
||||
'info' => $info
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
app/controller/Upload.php
Normal file
24
app/controller/Upload.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller;
|
||||
|
||||
use think\facade\Session;
|
||||
|
||||
class Upload extends Base {
|
||||
|
||||
public $data = ['data' => [], 'code' => 0, 'msg' => ''];
|
||||
|
||||
protected function initialize() {
|
||||
}
|
||||
|
||||
public function ueditor(){
|
||||
$data = new \com\Ueditor(Session::get('userInfo.uid'));
|
||||
echo $data->output();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class Channel extends Admin {
|
||||
*/
|
||||
public function editable($name = null, $value = null, $pk = null) {
|
||||
if ($name && ($value != null || $value != '') && $pk) {
|
||||
model('Channel')->where(array('id' => $pk))->setField($name, $value);
|
||||
ChannelM::where(array('id' => $pk))->update([$name => $value]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,9 @@ class Channel extends Admin {
|
||||
*/
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$id = $Channel->save($data);
|
||||
$id = ChannelM::save($data);
|
||||
if ($id) {
|
||||
return $this->success('新增成功', url('index'));
|
||||
//记录行为
|
||||
@@ -70,21 +69,23 @@ class Channel extends Admin {
|
||||
return $this->error('新增失败');
|
||||
}
|
||||
} else {
|
||||
$this->error($Channel->getError());
|
||||
$this->error('新增失败');
|
||||
}
|
||||
} else {
|
||||
$pid = input('pid', 0);
|
||||
//获取父导航
|
||||
if (!empty($pid)) {
|
||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||
$parent = ChannelM::where(array('id' => $pid))->field('title')->find();
|
||||
$this->assign('parent', $parent);
|
||||
}
|
||||
|
||||
$pnav = db('Channel')->where(array('pid' => '0'))->select();
|
||||
$this->assign('pnav', $pnav);
|
||||
$this->assign('pid', $pid);
|
||||
$this->assign('info', null);
|
||||
$this->setMeta('新增导航');
|
||||
$pnav = ChannelM::where(array('pid' => '0'))->select();
|
||||
|
||||
$this->data = [
|
||||
'pnav' => $pnav,
|
||||
'pid' => $pid,
|
||||
'info' => ['pid' => $pid]
|
||||
];
|
||||
return $this->fetch('edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Form as FormM;
|
||||
use app\model\FormAttr;
|
||||
|
||||
/**
|
||||
* @title 自定义表单
|
||||
@@ -37,44 +38,40 @@ class Form extends Admin {
|
||||
/**
|
||||
* @title 添加表单
|
||||
*/
|
||||
public function add(\think\Request $request) {
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Form')->save($request->post());
|
||||
$result = FormM::create($this->request->post());
|
||||
if (false !== $result) {
|
||||
return $this->success('添加成功!', url('admin/form/index'));
|
||||
return $this->success('添加成功!', url('/admin/form/index'));
|
||||
} else {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'keyList' => $this->model->addField,
|
||||
$this->data = array(
|
||||
'keyList' => (new FormM())->addField,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('添加表单');
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑表单
|
||||
*/
|
||||
public function edit(\think\Request $request) {
|
||||
public function edit() {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Form')->save($request->post(), array('id' => $request->post('id')));
|
||||
$result = FormM::update($this->request->post(), array('id' => $this->request->param('id')));
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功!', url('admin/form/index'));
|
||||
return $this->success('修改成功!', url('/admin/form/index'));
|
||||
} else {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
} else {
|
||||
$info = $this->model->where('id', $request->param('id'))->find();
|
||||
$data = array(
|
||||
$info = FormM::where('id', $this->request->param('id'))->find();
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $this->model->editField,
|
||||
'keyList' => (new FormM())->editField,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('编辑表单');
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,17 +152,18 @@ class Form extends Admin {
|
||||
* @title 表单字段
|
||||
*/
|
||||
public function attr($form_id = '') {
|
||||
$map = array();
|
||||
$map = [];
|
||||
$order = "id desc";
|
||||
$list = $this->Fattr->where($map)->order($order)->paginate(25);
|
||||
|
||||
$data = array(
|
||||
$map[] = ['form_id', '=', $form_id];
|
||||
|
||||
$list = FormAttr::where($map)->order($order)->paginate(25);
|
||||
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'form_id' => $form_id,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->setMeta('表单字段');
|
||||
$this->assign($data);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -179,23 +177,18 @@ class Form extends Admin {
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = $this->Fattr->save($data);
|
||||
$result = FormAttr::create($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('添加成功!', url('admin/form/attr?form_id='.$form_id));
|
||||
}else{
|
||||
return $this->error($this->Fattr->getError());
|
||||
}
|
||||
}else{
|
||||
$info = array(
|
||||
'form_id' => $form_id
|
||||
$this->data = array(
|
||||
'info' => ['form_id' => $form_id],
|
||||
'keyList' => $this->getField()
|
||||
);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $this->field
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('添加字段');
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,18 +240,19 @@ class Form extends Admin {
|
||||
}
|
||||
|
||||
protected function getField(){
|
||||
$config = \think\facade\Cache::get('system_config_data');
|
||||
return array(
|
||||
array('name' => 'id', 'title' => 'id', 'help' => '', 'type' => 'hidden'),
|
||||
array('name' => 'form_id', 'title' => 'model_id', 'help' => '', 'type' => 'hidden'),
|
||||
array('name' => 'name', 'title' => '字段名', 'help' => '英文字母开头,长度不超过30', 'type' => 'text'),
|
||||
array('name' => 'title', 'title' => '字段标题', 'help' => '请输入字段标题,用于表单显示', 'type' => 'text'),
|
||||
array('name' => 'type', 'title' => '字段类型', 'help' => '用于表单中的展示方式', 'type' => 'select', 'option' => $this->attr, 'help' => ''),
|
||||
array('name' => 'type', 'title' => '字段类型', 'help' => '用于表单中的展示方式', 'type' => 'select', 'option' => $config['config_type_list'], 'help' => ''),
|
||||
array('name' => 'length', 'title' => '字段长度', 'help' => '字段的长度值', 'type' => 'text'),
|
||||
array('name' => 'extra', 'title' => '参数', 'help' => '布尔、枚举、多选字段类型的定义数据', 'type' => 'textarea'),
|
||||
array('name' => 'value', 'title' => '默认值', 'help' => '字段的默认值', 'type' => 'text'),
|
||||
array('name' => 'remark', 'title' => '字段备注', 'help' => '用于表单中的提示', 'type' => 'text'),
|
||||
array('name' => 'is_show', 'title' => '是否显示', 'help' => '是否显示在表单中', 'type' => 'select', 'option' => array('1' => '始终显示', '2' => '新增显示', '3' => '编辑显示', '0' => '不显示'), 'value' => 1),
|
||||
array('name' => 'is_must', 'title' => '是否必填', 'help' => '用于自动验证', 'type' => 'select', 'option' => array('0' => '否', '1' => '是')),
|
||||
array('name' => 'is_show', 'title' => '是否显示', 'help' => '是否显示在表单中', 'type' => 'select', 'option' => [['key'=>'1', 'label' => '始终显示'], ['key' => '2', 'label' => '新增显示'], ['key' => '3', 'label' => '编辑显示'], ['key' => '0', 'label' => '不显示']], 'value' => 1),
|
||||
array('name' => 'is_must', 'title' => '是否必填', 'help' => '用于自动验证', 'type' => 'select', 'option' => array(['key'=>'0', 'label' => '否'], ['key'=>'1', 'label' => '是'])),
|
||||
);
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -72,9 +72,9 @@ class Index extends Admin {
|
||||
$clear = input('post.clear/a', array());
|
||||
foreach ($clear as $key => $value) {
|
||||
if ($value == 'cache') {
|
||||
\think\Cache::clear(); // 清空缓存数据
|
||||
\think\facade\Cache::clear(); // 清空缓存数据
|
||||
} elseif ($value == 'log') {
|
||||
\think\Log::clear();
|
||||
\think\facade\Log::clear();
|
||||
}
|
||||
}
|
||||
return $this->success("更新成功!", url('/admin/index/index'));
|
||||
|
||||
@@ -67,12 +67,10 @@ class User extends Admin {
|
||||
} else {
|
||||
$info = $this->getUserinfo();
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $model->editfield,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑用户");
|
||||
return $this->fetch('public/edit');
|
||||
}
|
||||
}
|
||||
@@ -216,7 +214,6 @@ class User extends Admin {
|
||||
return $this->error($user->getError());
|
||||
}
|
||||
} else {
|
||||
$this->setMeta('修改密码');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user