From 1c5b134ab2f8ced3fc52b2014525c48f76eefb90 Mon Sep 17 00:00:00 2001 From: leiqiaochu Date: Fri, 1 Sep 2023 11:54:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/dictionary.ts | 7 +- .../system/Dictionary/components/Left.vue | 86 ++++++++++++++++--- .../Dictionary/components/save/index.vue | 19 ++-- 3 files changed, 92 insertions(+), 20 deletions(-) diff --git a/src/api/system/dictionary.ts b/src/api/system/dictionary.ts index 4cfd5a06..9fef3ddc 100644 --- a/src/api/system/dictionary.ts +++ b/src/api/system/dictionary.ts @@ -13,4 +13,9 @@ export const verifyId = (id:string) => request.post(`/dictionary/_exists`,{where /** * 保存字典 */ -export const addDictionary = (data:any) => request.post('/dictionary',data) \ No newline at end of file +export const addDictionary = (data:any) => request.patch('/dictionary',data) + +/** + * 删除字典 + */ +export const deleteDictionary =(id:string) => request.delete(`/dictionary/${id}`) \ No newline at end of file diff --git a/src/views/system/Dictionary/components/Left.vue b/src/views/system/Dictionary/components/Left.vue index ab7d77de..94a5be20 100644 --- a/src/views/system/Dictionary/components/Left.vue +++ b/src/views/system/Dictionary/components/Left.vue @@ -10,30 +10,37 @@ 下载 导入 +
- - \ No newline at end of file diff --git a/src/views/system/Dictionary/components/save/index.vue b/src/views/system/Dictionary/components/save/index.vue index f77cf5b0..12b86ac4 100644 --- a/src/views/system/Dictionary/components/save/index.vue +++ b/src/views/system/Dictionary/components/save/index.vue @@ -10,7 +10,7 @@ > - + @@ -33,11 +33,14 @@ import { isInput } from '@/utils/regular'; import type { Rule } from 'ant-design-vue/es/form'; import { verifyId,addDictionary } from '@/api/system/dictionary' import { onlyMessage } from '@/utils/comm'; -import { error } from 'console'; const props = defineProps({ type:{ type:String, default:'add' + }, + data:{ + type:Object, + default:{} } }) const emit = defineEmits(['closeSave','success']) @@ -96,21 +99,27 @@ const rules = { const submitData = () =>{ formRef.value.validate().then(async()=>{ loading.value = true - if(props.type === 'add'){ - const res = await addDictionary(form) + const res = await addDictionary(form) if(res.status === 200){ onlyMessage('保存成功!') emit('success') }else{ onlyMessage('操作失败!','error') } - } loading.value = false }) } const closeModal = ()=>{ emit('closeSave') } +onMounted(()=>{ + if(props.type==='edit' && props.data){ + form.describe = props.data.describe + form.id = props.data.id + form.name = props.data.name + form.status = props.data.status + } +}) \ No newline at end of file