up.
This commit is contained in:
parent
23ee3f6d7c
commit
a166d6c368
@ -27,4 +27,56 @@ class ConfigController extends BaseController
|
|||||||
|
|
||||||
return $this->writeSuccess('success', $config->toArray());
|
return $this->writeSuccess('success', $config->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$data = $this->request->post([
|
||||||
|
'title' => '',
|
||||||
|
'value' => '',
|
||||||
|
'tips' => '',
|
||||||
|
'type' => '',
|
||||||
|
'options' => '',
|
||||||
|
'name' => '',
|
||||||
|
'comments' => '',
|
||||||
|
'group'=> ''
|
||||||
|
]);
|
||||||
|
$user = new SysConfig();
|
||||||
|
$user->save($data);
|
||||||
|
|
||||||
|
return $this->writeSuccess('添加成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update()
|
||||||
|
{
|
||||||
|
$data = $this->request->post([
|
||||||
|
'id' => 0,
|
||||||
|
'title' => '',
|
||||||
|
'value' => '',
|
||||||
|
'type' => '',
|
||||||
|
'tips' => '',
|
||||||
|
'options' => '',
|
||||||
|
'name' => '',
|
||||||
|
'comments' => '',
|
||||||
|
'group'=> ''
|
||||||
|
]);
|
||||||
|
$user = SysConfig::findOrFail($data['id']);
|
||||||
|
$user->save($data);
|
||||||
|
|
||||||
|
return $this->writeSuccess('修改成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateStatus()
|
||||||
|
{
|
||||||
|
$id = $this->request->put('id');
|
||||||
|
$status = $this->request->put('status');
|
||||||
|
$user = SysConfig::findOrFail($id);
|
||||||
|
$user->save(['status'=>$status]);
|
||||||
|
return $this->writeSuccess('修改成功');
|
||||||
|
}
|
||||||
|
public function batchDelete()
|
||||||
|
{
|
||||||
|
$data = $this->request->delete();
|
||||||
|
SysConfig::destroy($data);
|
||||||
|
return $this->writeSuccess('删除成功');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -70,10 +70,12 @@ Route::group("adminapi", function () {
|
|||||||
*/
|
*/
|
||||||
Route::get('config$', [ConfigController::class, "list"])->name("system.listConfig");
|
Route::get('config$', [ConfigController::class, "list"])->name("system.listConfig");
|
||||||
Route::get('config/data', [ConfigController::class, "data"])->name("system.getConfigData");
|
Route::get('config/data', [ConfigController::class, "data"])->name("system.getConfigData");
|
||||||
Route::post("config", [UserController::class, "add"])->name("system.addConfig");
|
Route::post("config", [ConfigController::class, "add"])->name("system.addConfig");
|
||||||
Route::put("config$", [UserController::class, "update"])->name("system.updateConfig");
|
Route::put("config$", [ConfigController::class, "update"])->name("system.updateConfig");
|
||||||
Route::delete("config", [UserController::class, "delete"])->name("system.deleteConfig");
|
Route::delete("config/batch", [ConfigController::class, "batchDelete"])->name("system.batchDeleteConfig");
|
||||||
Route::put("config/cache", [UserController::class, "cache"])->name("system.cacheConfig");
|
Route::put("config/cache", [ConfigController::class, "cache"])->name("system.cacheConfig");
|
||||||
|
Route::put("config/status", [ConfigController::class, "updateStatus"])->name("system.updateConfigStatus");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 用户管理
|
* 用户管理
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -55,8 +55,8 @@ export async function updateConfig(data: Config) {
|
|||||||
/**
|
/**
|
||||||
* 修改配置状态
|
* 修改配置状态
|
||||||
*/
|
*/
|
||||||
export async function updateConfigStatus(data: Config) {
|
export async function updateConfigStatus(id: number, status: number) {
|
||||||
const res = await request.put<ApiResult<unknown>>('/system/config/status', data);
|
const res = await request.put<ApiResult<unknown>>('/system/config/status', {id, status});
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
return res.data.message;
|
return res.data.message;
|
||||||
}
|
}
|
||||||
@ -67,8 +67,8 @@ export async function updateConfigStatus(data: Config) {
|
|||||||
/**
|
/**
|
||||||
* 批量删除配置
|
* 批量删除配置
|
||||||
*/
|
*/
|
||||||
export async function removeConfigs(id?: number) {
|
export async function removeConfigs(ids: number[]) {
|
||||||
const res = await request.delete<ApiResult<unknown>>('/system/config/batch');
|
const res = await request.delete<ApiResult<unknown>>('/system/config/batch', {data: ids});
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
return res.data.message;
|
return res.data.message;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
label-width="80px"
|
label-width="80px"
|
||||||
@submit.prevent=""
|
@submit.prevent=""
|
||||||
>
|
>
|
||||||
|
|
||||||
<el-form-item label="配置标题" prop="title">
|
<el-form-item label="配置标题" prop="title">
|
||||||
<el-input
|
<el-input
|
||||||
clearable
|
clearable
|
||||||
@ -30,7 +31,29 @@
|
|||||||
placeholder="请输入配置名称"
|
placeholder="请输入配置名称"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- //由英文字母和下划线组成,如 web_site_title,调用方法:config('web_site_title')-->
|
<!-- //由英文字母和下划线组成,如 web_site_title,调用方法:config('web_site_title')-->
|
||||||
|
<el-form-item label="配置类型" prop="type">
|
||||||
|
<el-select
|
||||||
|
clearable
|
||||||
|
class="ele-fluid"
|
||||||
|
placeholder="请选择配置类型"
|
||||||
|
v-model="form.type"
|
||||||
|
>
|
||||||
|
<el-option value="text" label="单行文本" />
|
||||||
|
<el-option value="textarea" label="多行文本" />
|
||||||
|
<el-option value="password" label="密码" />
|
||||||
|
<el-option value="checkbox" label="复选框" />
|
||||||
|
<el-option value="radio" label="单选按钮" />
|
||||||
|
<el-option value="date" label="日期" />
|
||||||
|
<el-option value="datetime" label="日期+时间" />
|
||||||
|
<el-option value="switch" label="开关" />
|
||||||
|
<el-option value="hidden" label="隐藏" />
|
||||||
|
<el-option value="time" label="时间" />
|
||||||
|
<el-option value="range" label="范围" />
|
||||||
|
<el-option value="number" label="数字" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="配置值">
|
<el-form-item label="配置值">
|
||||||
<el-input
|
<el-input
|
||||||
:rows="4"
|
:rows="4"
|
||||||
@ -47,12 +70,12 @@
|
|||||||
placeholder="请输入配置项"
|
placeholder="请输入配置项"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注">
|
<el-form-item label="配置说明">
|
||||||
<el-input
|
<el-input
|
||||||
:rows="4"
|
:rows="4"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
v-model="form.tips"
|
v-model="form.tips"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入配置说明"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注">
|
<el-form-item label="备注">
|
||||||
@ -84,6 +107,8 @@
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
/** 修改回显的数据 */
|
/** 修改回显的数据 */
|
||||||
data?: Config | null;
|
data?: Config | null;
|
||||||
|
/** 配置所属组 */
|
||||||
|
group?: string | null;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -104,15 +129,20 @@
|
|||||||
|
|
||||||
/** 表单数据 */
|
/** 表单数据 */
|
||||||
const [form, resetFields, assignFields] = useFormData<Config>({
|
const [form, resetFields, assignFields] = useFormData<Config>({
|
||||||
roleId: void 0,
|
id: void 0,
|
||||||
roleName: '',
|
comments: '',
|
||||||
roleCode: '',
|
group: '',
|
||||||
comments: ''
|
title: '',
|
||||||
|
name: '',
|
||||||
|
type: '',
|
||||||
|
tips: '',
|
||||||
|
options: '',
|
||||||
|
value: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 表单验证规则 */
|
/** 表单验证规则 */
|
||||||
const rules = reactive<FormRules>({
|
const rules = reactive<FormRules>({
|
||||||
roleName: [
|
name: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入配置名称',
|
message: '请输入配置名称',
|
||||||
@ -120,10 +150,10 @@
|
|||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
roleCode: [
|
title: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入配置标识',
|
message: '请输入配置标题',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
@ -167,6 +197,7 @@
|
|||||||
resetFields();
|
resetFields();
|
||||||
isUpdate.value = false;
|
isUpdate.value = false;
|
||||||
}
|
}
|
||||||
|
form.group = props.group;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -8,19 +8,19 @@
|
|||||||
>
|
>
|
||||||
<el-row :gutter="8">
|
<el-row :gutter="8">
|
||||||
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
||||||
<el-form-item label="角色名称">
|
<el-form-item label="名称">
|
||||||
<el-input
|
<el-input
|
||||||
clearable
|
clearable
|
||||||
v-model.trim="form.roleName"
|
v-model.trim="form.name"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
||||||
<el-form-item label="角色标识">
|
<el-form-item label="标题">
|
||||||
<el-input
|
<el-input
|
||||||
clearable
|
clearable
|
||||||
v-model.trim="form.roleCode"
|
v-model.trim="form.title"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -38,16 +38,16 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useFormData } from '@/utils/use-form-data';
|
import { useFormData } from '@/utils/use-form-data';
|
||||||
import type { RoleParam } from '@/api/system/role/model';
|
import type { ConfigParam } from '@/api/system/config/model';
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'search', where?: RoleParam): void;
|
(e: 'search', where?: ConfigParam): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
/** 表单数据 */
|
/** 表单数据 */
|
||||||
const [form, resetFields] = useFormData<RoleParam>({
|
const [form, resetFields] = useFormData<ConfigParam>({
|
||||||
roleName: '',
|
name: '',
|
||||||
roleCode: '',
|
title: '',
|
||||||
comments: ''
|
comments: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<ele-page>
|
<ele-page>
|
||||||
<!-- 搜索表单 -->
|
<!-- 搜索表单 -->
|
||||||
<role-search @search="reload"/>
|
<config-search @search="reload"/>
|
||||||
|
|
||||||
<ele-tabs
|
<ele-tabs
|
||||||
type="card"
|
type="card"
|
||||||
@ -14,14 +14,12 @@
|
|||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<ele-pro-table
|
<ele-pro-table
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
row-key="roleId"
|
row-key="id"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:datasource="datasource"
|
:datasource="datasource"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
v-model:selections="selections"
|
v-model:selections="selections"
|
||||||
:highlight-current-row="true"
|
:highlight-current-row="true"
|
||||||
:export-config="{ fileName: '角色数据', datasource: exportSource }"
|
|
||||||
:print-config="{ datasource: exportSource }"
|
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
cache-key="systemRoleTable"
|
cache-key="systemRoleTable"
|
||||||
:load-on-created="false"
|
:load-on-created="false"
|
||||||
@ -35,14 +33,13 @@
|
|||||||
>
|
>
|
||||||
添加
|
添加
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<!-- <el-button-->
|
||||||
type="danger"
|
<!-- type="danger"-->
|
||||||
class="ele-btn-icon"
|
<!-- class="ele-btn-icon"-->
|
||||||
:icon="DeleteOutlined"
|
<!-- :icon="Refresh"-->
|
||||||
@click="remove()"
|
<!-- >-->
|
||||||
>
|
<!-- 同步配置-->
|
||||||
删除
|
<!-- </el-button>-->
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<el-link type="primary" underline="never" @click="openEdit(row)">
|
<el-link type="primary" underline="never" @click="openEdit(row)">
|
||||||
@ -58,14 +55,14 @@
|
|||||||
<template #status="{ row }">
|
<template #status="{ row }">
|
||||||
<el-switch
|
<el-switch
|
||||||
size="small"
|
size="small"
|
||||||
:model-value="row.status === 0"
|
:model-value="row.status === 1"
|
||||||
@change="(checked: boolean) => editStatus(checked, row)"
|
@change="(checked: boolean) => editStatus(checked, row)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</ele-pro-table>
|
</ele-pro-table>
|
||||||
</ele-card>
|
</ele-card>
|
||||||
<!-- 编辑弹窗 -->
|
<!-- 编辑弹窗 -->
|
||||||
<config-edit v-model="showEdit" :data="current" @done="reload"/>
|
<config-edit v-model="showEdit" :data="current" @done="reload" :group="configGroup"/>
|
||||||
</ele-page>
|
</ele-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -78,8 +75,9 @@ import type {
|
|||||||
DatasourceFunction,
|
DatasourceFunction,
|
||||||
Columns
|
Columns
|
||||||
} from 'ele-admin-plus/es/ele-pro-table/types';
|
} from 'ele-admin-plus/es/ele-pro-table/types';
|
||||||
import {PlusOutlined, DeleteOutlined} from '@/components/icons';
|
// import { Refresh } from "@element-plus/icons-vue"
|
||||||
import RoleSearch from './components/role-search.vue';
|
import {PlusOutlined,} from '@/components/icons';
|
||||||
|
import ConfigSearch from './components/config-search.vue';
|
||||||
import ConfigEdit from './components/config-edit.vue';
|
import ConfigEdit from './components/config-edit.vue';
|
||||||
import type {Config, ConfigParam} from '@/api/system/config/model';
|
import type {Config, ConfigParam} from '@/api/system/config/model';
|
||||||
import {listConfig, updateConfigStatus, removeConfigs} from "@/api/system/config";
|
import {listConfig, updateConfigStatus, removeConfigs} from "@/api/system/config";
|
||||||
@ -123,6 +121,11 @@ const columns = ref<Columns>([
|
|||||||
slot: 'status',
|
slot: 'status',
|
||||||
formatter: (row) => (row.status == 0 ? '正常' : '冻结')
|
formatter: (row) => (row.status == 0 ? '正常' : '冻结')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
prop: 'sort',
|
||||||
|
label: '排序',
|
||||||
|
minWidth: 140
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prop: 'comments',
|
prop: 'comments',
|
||||||
label: '备注',
|
label: '备注',
|
||||||
@ -185,7 +188,7 @@ const remove = (row?: Config) => {
|
|||||||
message: '请求中..',
|
message: '请求中..',
|
||||||
plain: true
|
plain: true
|
||||||
});
|
});
|
||||||
removeConfigs(rows.map((d) => d.roleId))
|
removeConfigs(rows.map((d) => d.id))
|
||||||
.then((msg) => {
|
.then((msg) => {
|
||||||
loading.close();
|
loading.close();
|
||||||
EleMessage.success({message: msg, plain: true});
|
EleMessage.success({message: msg, plain: true});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user