From a166d6c368146d22e0ea2d0b53f8395c028a25b1 Mon Sep 17 00:00:00 2001 From: u2nyakim Date: Fri, 22 Aug 2025 15:05:03 +0800 Subject: [PATCH] up. --- .../admin/system/ConfigController.php | 52 +++++++++++++++++++ route/api.php | 10 ++-- z_ele/src/api/system/config/index.ts | 8 +-- .../system/config/components/config-edit.vue | 49 +++++++++++++---- .../{role-search.vue => config-search.vue} | 18 +++---- z_ele/src/views/system/config/index.vue | 37 +++++++------ 6 files changed, 131 insertions(+), 43 deletions(-) rename z_ele/src/views/system/config/components/{role-search.vue => config-search.vue} (77%) diff --git a/app/controller/admin/system/ConfigController.php b/app/controller/admin/system/ConfigController.php index 284cd34..8d1fe16 100644 --- a/app/controller/admin/system/ConfigController.php +++ b/app/controller/admin/system/ConfigController.php @@ -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('删除成功'); + } } \ No newline at end of file diff --git a/route/api.php b/route/api.php index 3289828..03c0c79 100644 --- a/route/api.php +++ b/route/api.php @@ -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"); + /* * 用户管理 */ diff --git a/z_ele/src/api/system/config/index.ts b/z_ele/src/api/system/config/index.ts index 2e44b32..c2258b8 100644 --- a/z_ele/src/api/system/config/index.ts +++ b/z_ele/src/api/system/config/index.ts @@ -55,8 +55,8 @@ export async function updateConfig(data: Config) { /** * 修改配置状态 */ -export async function updateConfigStatus(data: Config) { - const res = await request.put>('/system/config/status', data); +export async function updateConfigStatus(id: number, status: number) { + const res = await request.put>('/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>('/system/config/batch'); +export async function removeConfigs(ids: number[]) { + const res = await request.delete>('/system/config/batch', {data: ids}); if (res.data.code === 0) { return res.data.message; } diff --git a/z_ele/src/views/system/config/components/config-edit.vue b/z_ele/src/views/system/config/components/config-edit.vue index 2691f6e..44e26f5 100644 --- a/z_ele/src/views/system/config/components/config-edit.vue +++ b/z_ele/src/views/system/config/components/config-edit.vue @@ -14,6 +14,7 @@ label-width="80px" @submit.prevent="" > + + + + + + + + + + + + + + + + + + - + @@ -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({ - roleId: void 0, - roleName: '', - roleCode: '', - comments: '' + id: void 0, + comments: '', + group: '', + title: '', + name: '', + type: '', + tips: '', + options: '', + value: '', }); /** 表单验证规则 */ const rules = reactive({ - 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; } }); diff --git a/z_ele/src/views/system/config/components/role-search.vue b/z_ele/src/views/system/config/components/config-search.vue similarity index 77% rename from z_ele/src/views/system/config/components/role-search.vue rename to z_ele/src/views/system/config/components/config-search.vue index 5ff3e88..fce9ee5 100644 --- a/z_ele/src/views/system/config/components/role-search.vue +++ b/z_ele/src/views/system/config/components/config-search.vue @@ -8,19 +8,19 @@ > - + - + @@ -38,16 +38,16 @@