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