This commit is contained in:
parent
e3a637f9b7
commit
689aaeaf17
|
|
@ -23,6 +23,8 @@ use App\Request\Role as rRequest;
|
||||||
use App\Request\GenTable as gtRequest;
|
use App\Request\GenTable as gtRequest;
|
||||||
use App\Model\AssetCategory as acModel;
|
use App\Model\AssetCategory as acModel;
|
||||||
use App\Request\AssetCategory as acRequest;
|
use App\Request\AssetCategory as acRequest;
|
||||||
|
use App\Model\SystemConfig as scModel;
|
||||||
|
use App\Request\SystemConfig as scRequest;
|
||||||
use App\Model\Asset as asModel;
|
use App\Model\Asset as asModel;
|
||||||
use App\Utils\AppInfoHelper;
|
use App\Utils\AppInfoHelper;
|
||||||
use App\Utils\CpuHelper;
|
use App\Utils\CpuHelper;
|
||||||
|
|
@ -609,6 +611,7 @@ class System extends Base
|
||||||
// 搜搜字段
|
// 搜搜字段
|
||||||
$query_fields = [];
|
$query_fields = [];
|
||||||
$insert_fields = [];
|
$insert_fields = [];
|
||||||
|
$edit_fields = [];
|
||||||
$list_fields = [];
|
$list_fields = [];
|
||||||
$required_fields = [];
|
$required_fields = [];
|
||||||
$fields = $table['gen_table_columns'];
|
$fields = $table['gen_table_columns'];
|
||||||
|
|
@ -634,8 +637,8 @@ class System extends Base
|
||||||
'request.php' => $this->render->getContents('templates/request.php.twig', compact("controller_name", "insert_fields", "fields", "required_fields", "edit_fields")),
|
'request.php' => $this->render->getContents('templates/request.php.twig', compact("controller_name", "insert_fields", "fields", "required_fields", "edit_fields")),
|
||||||
'controller.php' => $this->render->getContents('templates/controller.php.twig', compact("controller_name", "module_name", "query_fields", "insert_fields", "edit_fields", "table_name", "name1", "name2")),
|
'controller.php' => $this->render->getContents('templates/controller.php.twig', compact("controller_name", "module_name", "query_fields", "insert_fields", "edit_fields", "table_name", "name1", "name2")),
|
||||||
'api.ts' => $this->render->getContents('templates/api.ts.twig', compact('table_name')),
|
'api.ts' => $this->render->getContents('templates/api.ts.twig', compact('table_name')),
|
||||||
'index.vue' => $this->render->getContents('templates/index.vue.twig', compact('table_name', 'list_fields', 'query_fields')),
|
'index.vue' => $this->render->getContents('templates/index.vue.twig', compact('table_name', 'list_fields', 'query_fields', 'name2')),
|
||||||
'save.vue' => $this->render->getContents('templates/save.vue.twig', compact('table_name', 'insert_fields', 'required_fields'))
|
'save.vue' => $this->render->getContents('templates/save.vue.twig', compact('table_name', 'insert_fields', 'required_fields', 'edit_fields'))
|
||||||
];
|
];
|
||||||
return $this->success("模板信息", $data);
|
return $this->success("模板信息", $data);
|
||||||
}
|
}
|
||||||
|
|
@ -760,4 +763,55 @@ class System extends Base
|
||||||
}
|
}
|
||||||
return $this->error("上传失败");
|
return $this->error("上传失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[GetMapping(path: "system_config/list")]
|
||||||
|
#[Auth(auth: "system_config:list")]
|
||||||
|
public function systemConfigList()
|
||||||
|
{
|
||||||
|
$param = Param::only(["config_name", "config_key", "limit" => 10]);
|
||||||
|
return $this->success("列表接口", scModel::list($param));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[GetMapping(path: "system_config/option")]
|
||||||
|
#[Auth(needAuth: false)]
|
||||||
|
public function systemConfigOption()
|
||||||
|
{
|
||||||
|
return $this->success(scModel::options());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[GetMapping(path: "system_config/info")]
|
||||||
|
#[Auth(auth: "system_config:info")]
|
||||||
|
public function systemConfigInfo()
|
||||||
|
{
|
||||||
|
$id = $this->request->input("id");
|
||||||
|
return $this->success(scModel::getById($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[PostMapping(path: "system_config/add")]
|
||||||
|
#[Auth(auth: "system_config:add")]
|
||||||
|
public function systemConfigAdd()
|
||||||
|
{
|
||||||
|
$request = $this->container->get(scRequest::class);
|
||||||
|
$request->scene('add')->validateResolved();
|
||||||
|
$data = Param::only(["config_name", "config_key", "config_value", "remark"]);
|
||||||
|
return $this->toAjax(scModel::add($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[PutMapping(path: "system_config/edit")]
|
||||||
|
#[Auth(auth: "system_config:edit")]
|
||||||
|
public function systemConfigEdit()
|
||||||
|
{
|
||||||
|
$request = $this->container->get(scRequest::class);
|
||||||
|
$request->scene('edit')->validateResolved();
|
||||||
|
$data = Param::only(["config_id", "config_name", "config_key", "config_value", "remark"]);
|
||||||
|
return $this->toAjax(scModel::edit($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DeleteMapping(path: "system_config/del")]
|
||||||
|
#[Auth(auth: "system_config:del")]
|
||||||
|
public function systemConfigDel()
|
||||||
|
{
|
||||||
|
$ids = $this->request->input("ids");
|
||||||
|
return $this->toAjax(scModel::del($ids));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +176,7 @@ class GenTable extends Model
|
||||||
'php_type' => Str::typeMysqlToPhp($column->Type),
|
'php_type' => Str::typeMysqlToPhp($column->Type),
|
||||||
'php_field' => $column->Field,
|
'php_field' => $column->Field,
|
||||||
'is_insert' => Str::isInsert($column->Field, $column->Extra),
|
'is_insert' => Str::isInsert($column->Field, $column->Extra),
|
||||||
'is_edit' => Str::isEdit($column->Field, $column->Extra),
|
'is_edit' => Str::isEdit($column->Field),
|
||||||
'is_list' => Str::isList($column->Field, $column->Extra),
|
'is_list' => Str::isList($column->Field, $column->Extra),
|
||||||
'is_query' => Str::isQuery($column->Field, $column->Extra),
|
'is_query' => Str::isQuery($column->Field, $column->Extra),
|
||||||
'is_required' => 0,
|
'is_required' => 0,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $config_id
|
||||||
|
* @property string $config_name
|
||||||
|
* @property string $config_key
|
||||||
|
* @property string $config_value
|
||||||
|
* @property string $remark
|
||||||
|
* @property string $create_time
|
||||||
|
* @property string $update_time
|
||||||
|
* @property string $deleted_at
|
||||||
|
*/
|
||||||
|
class SystemConfig extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*/
|
||||||
|
protected ?string $table = 'system_config';
|
||||||
|
|
||||||
|
protected string $primaryKey = 'config_id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*/
|
||||||
|
protected array $fillable = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast to native types.
|
||||||
|
*/
|
||||||
|
protected array $casts = ['config_id' => 'integer'];
|
||||||
|
|
||||||
|
public static function list(array $param)
|
||||||
|
{
|
||||||
|
$model = self::query();
|
||||||
|
if (isset($param['config_name']) && $param['config_name'] != '') {
|
||||||
|
$model = $model->where('config_name', "like", "%{$param['config_name']}%");
|
||||||
|
}
|
||||||
|
if (isset($param['config_key']) && $param['config_key'] != '') {
|
||||||
|
$model = $model->where('config_key', "like", "%{$param['config_key']}%");
|
||||||
|
}
|
||||||
|
return $model->orderByDesc("config_id")
|
||||||
|
->select(["config_id", "config_name", "config_key", "config_value", "remark", "create_time", "update_time"])
|
||||||
|
->paginate((int)$param['limit']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function options()
|
||||||
|
{
|
||||||
|
return self::select(["config_id", "config_name"])->get()->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Request;
|
||||||
|
|
||||||
|
use Hyperf\Validation\Request\FormRequest;
|
||||||
|
|
||||||
|
class SystemConfig extends FormRequest
|
||||||
|
{
|
||||||
|
protected array $scenes = [
|
||||||
|
'add' => ["config_name", "config_key"],
|
||||||
|
'edit' => ["config_id", "config_name", "config_key"],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'config_id' => 'required',
|
||||||
|
'config_name' => 'required',
|
||||||
|
'config_key' => 'required',
|
||||||
|
'config_value' => 'required',
|
||||||
|
'remark' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'config_name.required' => '参数名称必传!',
|
||||||
|
'config_key.required' => '参数键名必传!',
|
||||||
|
'config_value.required' => '参数键值必传!',
|
||||||
|
'remark.required' => '备注必传!',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -87,11 +87,8 @@ class Str
|
||||||
return !in_array($field, ["deleted_at", "update_time"]) ? 1 : 0;
|
return !in_array($field, ["deleted_at", "update_time"]) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isEdit($field, $extra): int
|
public static function isEdit($field): int
|
||||||
{
|
{
|
||||||
if ($extra == "auto_increment") {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return !in_array($field, ["deleted_at", "create_time"]) ? 1 : 0;
|
return !in_array($field, ["deleted_at", "create_time"]) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class {{ controller_name }} extends Base
|
||||||
public function {{ name2 }}List()
|
public function {{ name2 }}List()
|
||||||
{
|
{
|
||||||
$param = Param::only([{% for field in query_fields %}"{{ field.column_name }}"{% if not loop.last %}, {% endif %}{% endfor %}, "limit"=>10]);
|
$param = Param::only([{% for field in query_fields %}"{{ field.column_name }}"{% if not loop.last %}, {% endif %}{% endfor %}, "limit"=>10]);
|
||||||
return $this->success({{ name1 }}Model::list($param));
|
return $this->success("列表接口", {{ name1 }}Model::list($param));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[GetMapping(path: "{{ table_name }}/option")]
|
#[GetMapping(path: "{{ table_name }}/option")]
|
||||||
|
|
@ -38,7 +38,7 @@ class {{ controller_name }} extends Base
|
||||||
public function {{ name2 }}Info()
|
public function {{ name2 }}Info()
|
||||||
{
|
{
|
||||||
$id = $this->request->input("id");
|
$id = $this->request->input("id");
|
||||||
return $this->success({{ name1 }}Model::getById());
|
return $this->success({{ name1 }}Model::getById($id));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[PostMapping(path: "{{ table_name }}/add")]
|
#[PostMapping(path: "{{ table_name }}/add")]
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,12 @@
|
||||||
<el-table-column label="操作" fixed="right" align="right" width="170">
|
<el-table-column label="操作" fixed="right" align="right" width="170">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button-group>
|
<el-button-group>
|
||||||
<el-button text type="primary" size="small" @click="table_show(scope.row, scope.$index)">查看
|
<el-button text type="primary" size="small" @click="show(scope.row, scope.$index)">查看
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-auth="'{{ table_name }}:edit'" text type="success" size="small"
|
<el-button v-auth="'{{ table_name }}:edit'" text type="success" size="small"
|
||||||
@click="table_edit(scope.row, scope.$index)">编辑
|
@click="edit(scope.row, scope.$index)">编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index)">
|
<el-popconfirm title="确定删除吗?" @confirm="del(scope.row, scope.$index)">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button v-auth="'{{ table_name }}:del'" text type="danger" size="small">删除</el-button>
|
<el-button v-auth="'{{ table_name }}:del'" text type="danger" size="small">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
import {getCurrentInstance, nextTick, ref} from "vue";
|
import {getCurrentInstance, nextTick, ref} from "vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: ""
|
name: "{{ name2 }}"
|
||||||
})
|
})
|
||||||
|
|
||||||
const {proxy} = getCurrentInstance()
|
const {proxy} = getCurrentInstance()
|
||||||
|
|
@ -121,7 +121,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
//编辑
|
//编辑
|
||||||
async function table_edit(row) {
|
async function edit(row) {
|
||||||
dialogShow.value = true
|
dialogShow.value = true
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
dialogRef.value.open('edit', row)
|
dialogRef.value.open('edit', row)
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
//查看
|
//查看
|
||||||
async function table_show(row) {
|
async function show(row) {
|
||||||
dialogShow.value = true
|
dialogShow.value = true
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
dialogRef.value.open('show', row)
|
dialogRef.value.open('show', row)
|
||||||
|
|
@ -137,7 +137,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除
|
//删除
|
||||||
async function table_del(row) {
|
async function del(row) {
|
||||||
const loading = proxy.$loading();
|
const loading = proxy.$loading();
|
||||||
const res = await api.{{ table_name }}.del({ids: [row.{{ table_name }}_id]});
|
const res = await api.{{ table_name }}.del({ids: [row.{{ table_name }}_id]});
|
||||||
tableRef.value.refresh()
|
tableRef.value.refresh()
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {getCurrentInstance, ref} from 'vue'
|
import {getCurrentInstance, ref} from 'vue'
|
||||||
import api from "@/api/index.js";
|
import api from "@/api/index"
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open
|
open
|
||||||
|
|
@ -68,8 +68,8 @@
|
||||||
let visible = ref(false)
|
let visible = ref(false)
|
||||||
let isSaveing = ref(false)
|
let isSaveing = ref(false)
|
||||||
let form = ref({
|
let form = ref({
|
||||||
{% for field in insert_fields %}
|
{% for field in edit_fields %}
|
||||||
{{ field.php_field }}: null
|
{{ field.php_field }}: null,
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
})
|
})
|
||||||
const rules = ref({
|
const rules = ref({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue