|
@@ -0,0 +1,105 @@
|
|
|
+<?php
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | tp5-form-builder[请基于ThinkPHP5使用]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Copyright (c) 2016-2019 http://www.lwwan.com
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Author 似水星辰 [ 2630481389@qq.com ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 星辰工作室 QQ群331378225
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+namespace app\admin\controller;
|
|
|
+
|
|
|
+use think\Controller;
|
|
|
+use app\admin\model\Config as ConfigModel;
|
|
|
+/**
|
|
|
+ * 控制器
|
|
|
+ * @package app\admin\controller
|
|
|
+ */
|
|
|
+class Config extends Controller
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 新增表单项
|
|
|
+ * @author 似水星辰 [ 2630481389@qq.com ]
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ $fields =[
|
|
|
+ [
|
|
|
+ 'type' => 'radio',
|
|
|
+ 'name' => 'group',
|
|
|
+ 'title' => '配置分组',
|
|
|
+ 'extra' => config('config_group'),
|
|
|
+ 'value'=> $group,
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'type' => 'select',
|
|
|
+ 'name' => 'type',
|
|
|
+ 'title' => '配置类型',
|
|
|
+ 'tips' => '',
|
|
|
+ 'extra' => config('form_item_type')
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'name' => 'title',
|
|
|
+ 'title' => '配置标题',
|
|
|
+ 'attr' => 'data-rule="required;" data-msg-required="标题不能为空,可以使用中文或者英文"'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'name' => 'name',
|
|
|
+ 'title' => '配置标识',
|
|
|
+ 'attr' => 'data-rule="required;name;" data-rule-name="[/^[a-zA-Z][a-zA-Z0-9_]*$/, \'请输入正确的配置标识,只能使用英文和下划线,必须以英文字母开头\']" data-msg-required="配置标识不能为空"'
|
|
|
+ ],
|
|
|
+ ['type' => 'textarea', 'name' => 'value', 'title' => '配置值'],
|
|
|
+ ['type' => 'textarea', 'name' => 'extra', 'title' => '配置项', 'tips' => '用于单选、多选、下拉、联动等类型'],
|
|
|
+ ['type' => 'textarea', 'name' => 'tips', 'title' => '配置说明'],
|
|
|
+ ['type' => 'radio', 'name' => 'status', 'title' => '状态', '', 'extra' => ['禁用', '启用'], 'value' => 1]
|
|
|
+ ];
|
|
|
+ $this->assign('page_title','新增管理员');
|
|
|
+ $this->assign('form_items',$fields);
|
|
|
+ return $this->fetch('public/add');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑表单项
|
|
|
+ * @param int $id
|
|
|
+ * @author 似水星辰 [ 2630481389@qq.com ]
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function edit($id = 0)
|
|
|
+ {
|
|
|
+ if ($id === 0) $this->error('参数错误');
|
|
|
+
|
|
|
+ // 获取数据
|
|
|
+ $info = ConfigModel::get($id);
|
|
|
+ $fields =[
|
|
|
+ ['type' => 'hidden', 'name' => 'id', ],
|
|
|
+ ['type' => 'radio', 'name' => 'group', 'title' => '配置分组', 'extra' => config('config_group'), 'value'=> $group, ],
|
|
|
+ ['type' => 'select', 'name' => 'type', 'title' => '配置类型', 'extra' => config('form_item_type')],
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'name' => 'title',
|
|
|
+ 'title' => '配置标题',
|
|
|
+ 'attr' => 'data-rule="required;" data-msg-required="标题不能为空,可以使用中文或者英文"'],
|
|
|
+
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'name' => 'name',
|
|
|
+ 'title' => '配置标识',
|
|
|
+ 'attr' => 'data-rule="required;name;" data-rule-name="[/^[a-zA-Z][a-zA-Z0-9_]*$/, \'请输入正确的配置标识,只能使用英文和下划线,必须以英文字母开头\']" data-msg-required="配置标识不能为空"'
|
|
|
+ ],
|
|
|
+ ['type' => 'textarea', 'name' => 'value', 'title' => '配置值'],
|
|
|
+ ['type' => 'textarea', 'name' => 'extra', 'title' => '配置项', 'tips' => '用于单选、多选、下拉、联动等类型'],
|
|
|
+ ['type' => 'textarea', 'name' => 'tips', 'title' => '配置说明'],
|
|
|
+ ['type' => 'radio', 'name' => 'status', 'title' => '状态', '', 'extra' => ['禁用', '启用'], 'value' => 1]
|
|
|
+ ];
|
|
|
+ $this->assign('page_title','编辑配置');
|
|
|
+ $this->assign('form_items', $this->setData($fields, $info));
|
|
|
+ return $this->fetch('public/edit');
|
|
|
+ }
|
|
|
+}
|