浏览代码

修复字典新增和编辑表单

zhontai 2 年之前
父节点
当前提交
cf2512f580

+ 1 - 1
src/views/admin/dictionary/components/dictionary-form.vue

@@ -69,7 +69,7 @@ const open = async (row: any = {}) => {
       state.form = res.data as DictionaryAddInput & DictionaryUpdateInput
     }
   } else {
-    state.form = {} as DictionaryAddInput & DictionaryUpdateInput
+    state.form = { dictionaryTypeId: row.dictionaryTypeId } as DictionaryAddInput & DictionaryUpdateInput
   }
   state.showDialog = true
 }

+ 2 - 2
src/views/admin/dictionary/dictionary-type.vue

@@ -106,12 +106,12 @@ const onQuery = async () => {
 }
 
 const onAdd = () => {
-  state.dictionaryTypeFormTitle = '新增租户'
+  state.dictionaryTypeFormTitle = '新增字典分类'
   dictionaryTypeFormRef.value.open()
 }
 
 const onEdit = (row: DictionaryTypeListOutput) => {
-  state.dictionaryTypeFormTitle = '编辑租户'
+  state.dictionaryTypeFormTitle = '编辑字典分类'
   dictionaryTypeFormRef.value.open(row)
 }
 

+ 8 - 4
src/views/admin/dictionary/dictionary.vue

@@ -71,11 +71,15 @@ const state = reactive({
     pageSize: 20,
   } as PageInputDictionaryGetPageDto,
   dictionaryListData: [] as Array<DictionaryListOutput>,
+  dictionaryTypeName: '',
 })
 
 onMounted(() => {
   eventBus.on('refreshDict', (data: DictionaryTypeListOutput) => {
-    state.filterModel.dictionaryTypeId = data.id as number
+    if ((data?.id as number) > 0) {
+      state.filterModel.dictionaryTypeId = data.id as number
+      state.dictionaryTypeName = data.name as string
+    }
     onQuery()
   })
 })
@@ -94,12 +98,12 @@ const onQuery = async () => {
 }
 
 const onAdd = () => {
-  state.dictionaryFormTitle = '新增租户'
-  dictionaryFormRef.value.open()
+  state.dictionaryFormTitle = `新增【${state.dictionaryTypeName}】字典`
+  dictionaryFormRef.value.open({ dictionaryTypeId: state.filterModel.dictionaryTypeId })
 }
 
 const onEdit = (row: DictionaryListOutput) => {
-  state.dictionaryFormTitle = '编辑租户'
+  state.dictionaryFormTitle = `编辑【${state.dictionaryTypeName}】字典`
   dictionaryFormRef.value.open(row)
 }