Skip to content

Commit

Permalink
feat(generator): 代码生成字段配置支持选择关联字典
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Aug 26, 2024
1 parent fcbc3eb commit 6574181
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/apis/tool/generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type * as Tool from './type'
import type { LabelValueState } from '@/types/global'
import http from '@/utils/http'

const BASE_URL = '/generator'
Expand Down Expand Up @@ -36,3 +37,8 @@ export function generate(tableNames: Array<string>) {
responseType: 'blob'
})
}

/** @desc 查询字典列表 */
export function listFieldConfigDict() {
return http.get<LabelValueState[]>(`${BASE_URL}/dict`)
}
1 change: 1 addition & 0 deletions src/apis/tool/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface FieldConfigResp {
showInQuery: boolean
formType: string
queryType: string
dictCode: string
createTime?: string
}
export interface GenConfigResp {
Expand Down
20 changes: 17 additions & 3 deletions src/views/tool/generator/GenConfigDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:title="title"
:mask-closable="false"
:esc-to-close="false"
:width="width >= 1050 ? 1050 : '100%'"
:width="width >= 1350 ? 1350 : '100%'"
@before-ok="save"
@close="reset"
>
Expand Down Expand Up @@ -106,6 +106,15 @@
/>
<span v-else>无需设置</span>
</template>
<template #dictCode="{ record }">
<a-select
v-model="record.dictCode"
:options="dictList"
placeholder="请选择字典类型"
allow-search
allow-clear
/>
</template>
</GiTable>
</a-tab-pane>
</a-tabs>
Expand All @@ -115,7 +124,8 @@
<script setup lang="ts">
import { type FormInstance, Message } from '@arco-design/web-vue'
import { useWindowSize } from '@vueuse/core'
import { type FieldConfigResp, type GeneratorConfigResp, getGenConfig, listFieldConfig, saveGenConfig } from '@/apis'
import { type FieldConfigResp, type GeneratorConfigResp, getGenConfig, listFieldConfig, listFieldConfigDict, saveGenConfig } from '@/apis'
import type { LabelValueState } from '@/types/global'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useForm } from '@/hooks'
import { useDict } from '@/hooks/app'
Expand All @@ -136,9 +146,11 @@ const columns: TableInstanceColumns[] = [
{ title: '必填', slotName: 'isRequired', width: 60, align: 'center' },
{ title: '查询', slotName: 'showInQuery', width: 60, align: 'center' },
{ title: '表单类型', slotName: 'formType', width: 150 },
{ title: '查询方式', slotName: 'queryType' }
{ title: '查询方式', slotName: 'queryType' },
{ title: '关联字典', slotName: 'dictCode' }
]
const dictList = ref<LabelValueState[]>([])
const dataList = ref<FieldConfigResp[]>([])
const loading = ref(false)
// 查询列表数据
Expand All @@ -147,6 +159,8 @@ const getDataList = async (tableName: string, requireSync: boolean) => {
loading.value = true
const res = await listFieldConfig(tableName, requireSync)
dataList.value = res.data
const { data } = await listFieldConfigDict()
dictList.value = data
} finally {
loading.value = false
}
Expand Down

0 comments on commit 6574181

Please sign in to comment.