From ac49a92e0836bce790bddc2178526eb786d70f7e Mon Sep 17 00:00:00 2001 From: lzq <2495532633@qq.com> Date: Sun, 7 Dec 2025 14:26:51 +0800 Subject: [PATCH] 1 --- src/common/utils/formUtil.ts | 3 +- src/dts/components.d.ts | 3 +- src/dts/g.d.ts | 8 +- src/pages/login/Login.vue | 4 +- src/pages/sys/gen/db-table/CodePreview.vue | 212 +++++++++++++-------- src/pages/sys/gen/db-table/DbTable.vue | 62 ++++-- src/pages/sys/gen/db-table/db-table-api.ts | 8 + src/pages/sys/gen/db-table/db-table.d.ts | 18 ++ src/pages/sys/gen/gen-api.ts | 39 ---- src/pages/sys/gen/gen.d.ts | 29 --- src/pages/sys/gen/tpl/Tpl.vue | 3 +- src/pages/sys/gen/tpl/TplForm.vue | 3 + src/pages/sys/gen/tpl/tpl-api.ts | 30 +++ src/pages/sys/gen/tpl/tpl.d.ts | 7 + src/pages/sys/menus/MenuForm.vue | 8 +- src/pages/sys/menus/Menus.vue | 11 +- src/pages/sys/task/TaskForm.vue | 1 - 17 files changed, 268 insertions(+), 181 deletions(-) create mode 100644 src/pages/sys/gen/db-table/db-table-api.ts create mode 100644 src/pages/sys/gen/db-table/db-table.d.ts delete mode 100644 src/pages/sys/gen/gen-api.ts delete mode 100644 src/pages/sys/gen/gen.d.ts diff --git a/src/common/utils/formUtil.ts b/src/common/utils/formUtil.ts index 28c09e6..6b37759 100644 --- a/src/common/utils/formUtil.ts +++ b/src/common/utils/formUtil.ts @@ -2,10 +2,9 @@ import { ElMessage, type FormInstance, } from 'element-plus' -import type { R } from '@/common/utils/http-util.ts' export default { - submit(form: Ref, then: () => Promise>) { + submit(form: ShallowRef, then: () => Promise) { return form.value!.validate() .then( then, diff --git a/src/dts/components.d.ts b/src/dts/components.d.ts index 23ff205..60da430 100644 --- a/src/dts/components.d.ts +++ b/src/dts/components.d.ts @@ -5,6 +5,7 @@ // ------ // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +import { GlobalComponents } from 'vue' export {} @@ -105,4 +106,4 @@ declare global { const ElUpload: typeof import('element-plus/es')['ElUpload'] const RouterLink: typeof import('vue-router')['RouterLink'] const RouterView: typeof import('vue-router')['RouterView'] -} +} \ No newline at end of file diff --git a/src/dts/g.d.ts b/src/dts/g.d.ts index b349a06..c12438b 100644 --- a/src/dts/g.d.ts +++ b/src/dts/g.d.ts @@ -26,10 +26,10 @@ declare global { } interface Pagination { - total: number - pages: number - current: number - size: number + total?: number + pages?: number + current?: number + size?: number } } } diff --git a/src/pages/login/Login.vue b/src/pages/login/Login.vue index 5988b24..0f7c278 100644 --- a/src/pages/login/Login.vue +++ b/src/pages/login/Login.vue @@ -12,7 +12,7 @@ import Strings from '@/common/utils/strings.ts' import FormUtil from '@/common/utils/formUtil.ts' import { loadUserInfo } from '@/common/app' -const loginFormIns = ref() +const loginFormIns = useTemplateRef('loginForm') const loginForm = reactive({ account: '', @@ -76,7 +76,7 @@ function loginSubmitHandler() { {{ appName }}
+ :content="currentTable.tableComment" + placement="top"> - + + @change="changeTplHandler"> @@ -34,48 +34,43 @@ value="java"/> - - - - - - + + placeholder="表前缀"/> - + + placeholder="基础包名称"/> - + + placeholder="模块名称"/> - + + + + + + + placeholder="子目录名称"/> - - -
-              {{ codeInfo[tab.tplName!]?.content }}
-            
+ + +
+ 文件名:{{ codeInfo[tab.tplName!]?.path }} +
+
@@ -87,43 +82,37 @@ diff --git a/src/pages/sys/gen/db-table/DbTable.vue b/src/pages/sys/gen/db-table/DbTable.vue index 8087afd..18a5a4d 100644 --- a/src/pages/sys/gen/db-table/DbTable.vue +++ b/src/pages/sys/gen/db-table/DbTable.vue @@ -20,8 +20,9 @@ empty-text="暂无数据" header-row-class-name="table-header" row-key="id"> - - + + + + @@ -37,21 +44,35 @@ import Page from '@/components/page/Page.vue' import { elIcons } from '@/common/element/element.ts' import CodePreview from '@/pages/sys/gen/db-table/CodePreview.vue' -import GenApi from '@/pages/sys/gen/gen-api.ts' +import DbTableApi from '@/pages/sys/gen/db-table/db-table-api.ts' -const tableData = ref([]) -const searchForm = reactive<{ - tableName?: string -}>({}) +const tableData = ref([]) +const searchForm = reactive({ + current: 1, + size: 20, +}) const searching = ref(false) const showSearchForm = ref(true) const codePreviewIns = useTemplateRef>('codePreview') -function showDialog(data?: GenTypes.TableInfo) { +const pagination = reactive({ + total: 0, + pages: 0, + current: 1, + size: 20, +}) + +function pageChangeHandler(currentPage: number, pageSize: number) { + searchForm.current = currentPage + searchForm.size = pageSize + paging() +} + +function showDialog(data?: DbTableTypes.TableInfo) { codePreviewIns.value?.open(data) } -function previewHandler({row}: { row: GenTypes.TableInfo }) { +function previewHandler({row}: { row: DbTableTypes.TableInfo }) { showDialog(row) } @@ -63,10 +84,15 @@ function reset() { function paging() { searching.value = true - GenApi.listTable(searchForm.tableName) + DbTableApi.tablePaing(searchForm) .then(res => { - tableData.value = res.data ?? [] - + tableData.value = res.data.records ?? [] + Object.assign(pagination, { + total: res.data?.total ?? 0, + pages: res.data?.pages ?? 0, + current: res.data?.current ?? 1, + size: res.data?.size ?? 20, + }) }) .finally(() => { searching.value = false @@ -130,15 +156,9 @@ onMounted(() => { margin 0 0 20px 0 } -.avatar { - width: 100%; - height: 100%; - display: flex; - justify-content: center; - align-items: center; - :deep(.el-icon) { - font-size 25px - } +.pagination { + justify-content: end; + margin: 8px; } diff --git a/src/pages/sys/gen/db-table/db-table-api.ts b/src/pages/sys/gen/db-table/db-table-api.ts new file mode 100644 index 0000000..88573e7 --- /dev/null +++ b/src/pages/sys/gen/db-table/db-table-api.ts @@ -0,0 +1,8 @@ +import { get } from '@/common/utils/http-util.ts' + +export default { + tablePaing(data?: DbTableTypes.SearchTplParam) { + return get>('/tpl/table/paging', data) + }, + +} diff --git a/src/pages/sys/gen/db-table/db-table.d.ts b/src/pages/sys/gen/db-table/db-table.d.ts new file mode 100644 index 0000000..0733bb2 --- /dev/null +++ b/src/pages/sys/gen/db-table/db-table.d.ts @@ -0,0 +1,18 @@ +export {} +declare global { + namespace DbTableTypes { + interface SearchTplParam extends G.PageParam { + tableName?: string + tableSchema?: string + } + + + interface TableInfo { + tableSchema?: string + tableName?: string + tableComment?: string + } + + } + +} diff --git a/src/pages/sys/gen/gen-api.ts b/src/pages/sys/gen/gen-api.ts deleted file mode 100644 index 4a55d2a..0000000 --- a/src/pages/sys/gen/gen-api.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { - download, - get, - post, -} from '@/common/utils/http-util.ts' - -export default { - listTable(tableName?: string) { - return get('/tpl/list_table', {tableName}) - }, - list() { - return get('/tpl/list') - }, - preview(tplNames: string[], tableName: string, data: Record) { - return post('/tpl/preview', data, {tplNames, tableName}) - }, - download(tplNames: string[], tableName: string, data: Record) { - return download('/tpl/download', data, {tplNames, tableName}) - .then(res => { - // 创建新的URL并指向File对象或者Blob对象的地址 - const blobURL = window.URL.createObjectURL(res.data.data) - // 创建a标签,用于跳转至下载链接 - const tempLink = document.createElement('a') - tempLink.style.display = 'none' - tempLink.href = blobURL - tempLink.setAttribute('download', decodeURI(res.data.filename)) - // 兼容:某些浏览器不支持HTML5的download属性 - if (typeof tempLink.download === 'undefined') { - tempLink.setAttribute('target', '_blank') - } - // 挂载a标签 - document.body.appendChild(tempLink) - tempLink.click() - document.body.removeChild(tempLink) - // 释放blob URL地址 - window.URL.revokeObjectURL(blobURL) - }) - }, -} diff --git a/src/pages/sys/gen/gen.d.ts b/src/pages/sys/gen/gen.d.ts deleted file mode 100644 index 4a43693..0000000 --- a/src/pages/sys/gen/gen.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -export {} -declare global { - namespace GenTypes { - interface TableInfo { - name?: string - comment?: string - } - - interface TplInfo { - id?: string - tplName?: string - lang?: string - tpl: { - content?: string - dir?: string - filename?: string - } - modelData: Record - } - - interface CodeInfo { - [key: string]: { - content: string - path: string - } - } - } - -} diff --git a/src/pages/sys/gen/tpl/Tpl.vue b/src/pages/sys/gen/tpl/Tpl.vue index df3c888..a9fb5c3 100644 --- a/src/pages/sys/gen/tpl/Tpl.vue +++ b/src/pages/sys/gen/tpl/Tpl.vue @@ -91,6 +91,8 @@ const tableData = ref([]) const searchForm = reactive({ current: 1, size: 20, + orders: 'lang,tpl_name', + tpl: {}, }) const searching = ref(false) const deling = ref(false) @@ -98,7 +100,6 @@ const showSearchForm = ref(true) const tplFormIns = useTemplateRef>('tplForm') const pagination = reactive({ total: 0, - pages: 0, current: 1, size: 1, }) diff --git a/src/pages/sys/gen/tpl/TplForm.vue b/src/pages/sys/gen/tpl/TplForm.vue index b028158..c678394 100644 --- a/src/pages/sys/gen/tpl/TplForm.vue +++ b/src/pages/sys/gen/tpl/TplForm.vue @@ -30,6 +30,7 @@ ('/tpl/list_all', {lang}) + }, + + preview(lang: string, tableName: string, data: Record) { + return post('/tpl/preview', data, {lang, tableName}) + }, + download(lang: string, tableName: string, data: Record) { + return download('/tpl/download', data, {lang, tableName}) + .then(res => { + // 创建新的URL并指向File对象或者Blob对象的地址 + const blobURL = window.URL.createObjectURL(res.data.data) + // 创建a标签,用于跳转至下载链接 + const tempLink = document.createElement('a') + tempLink.style.display = 'none' + tempLink.href = blobURL + tempLink.setAttribute('download', decodeURI(res.data.filename)) + // 兼容:某些浏览器不支持HTML5的download属性 + if (typeof tempLink.download === 'undefined') { + tempLink.setAttribute('target', '_blank') + } + // 挂载a标签 + document.body.appendChild(tempLink) + tempLink.click() + document.body.removeChild(tempLink) + // 释放blob URL地址 + window.URL.revokeObjectURL(blobURL) + }) + }, } diff --git a/src/pages/sys/gen/tpl/tpl.d.ts b/src/pages/sys/gen/tpl/tpl.d.ts index 657b874..0aa266e 100644 --- a/src/pages/sys/gen/tpl/tpl.d.ts +++ b/src/pages/sys/gen/tpl/tpl.d.ts @@ -60,5 +60,12 @@ declare global { filename?: string } } + + interface CodeInfo { + [key: string]: { + content: string + path: string + } + } } } diff --git a/src/pages/sys/menus/MenuForm.vue b/src/pages/sys/menus/MenuForm.vue index 063327e..0833c55 100644 --- a/src/pages/sys/menus/MenuForm.vue +++ b/src/pages/sys/menus/MenuForm.vue @@ -78,6 +78,8 @@ import { } from '@/components/a-icon/iconfont.ts' import AIcon from '@/components/a-icon/AIcon.tsx' +const emits = defineEmits([ 'editSucc' ]) + const pagination = reactive({ total: icons.glyphs.length, pages: Math.ceil(icons.glyphs.length / 5), @@ -91,7 +93,6 @@ function dialogCloseHandler() { } } - function pageChangeHandler(currentPage: number, pageSize: number) { pagination.current = currentPage pagination.size = pageSize @@ -113,7 +114,6 @@ const iconTableDataSource = ref( ) function currentChangeHandler(val?: IconGlyphs) { - console.log(val) if (val == null) return menuForm.value.icon = val.font_class menuForm.value.iconName = val.name @@ -143,6 +143,8 @@ function submitHandler() { MenuApi.modify(menuForm.value) .then(() => { ElMessage.success('修改成功') + showDialog.value = false + emits(('editSucc')) }) .finally(() => { submiting.value = false @@ -151,6 +153,8 @@ function submitHandler() { MenuApi.add(menuForm.value) .then(() => { ElMessage.success('添加成功') + showDialog.value = false + emits(('editSucc')) }) .finally(() => { submiting.value = false diff --git a/src/pages/sys/menus/Menus.vue b/src/pages/sys/menus/Menus.vue index 6499efe..fe50bd5 100644 --- a/src/pages/sys/menus/Menus.vue +++ b/src/pages/sys/menus/Menus.vue @@ -27,14 +27,14 @@ lazy row-key="id"> - + - + @@ -120,10 +120,15 @@ function reset() { listAll() } +function editSuccHandler() { + listAll() +} + function listAll() { searching.value = true MenuApi.listAll({...searchForm, pid: '0'}) .then(res => { + tableData.value = [] tableData.value = res.data?.map(it => { it.hasChildren = true return it diff --git a/src/pages/sys/task/TaskForm.vue b/src/pages/sys/task/TaskForm.vue index 8fe45e6..acdb4d9 100644 --- a/src/pages/sys/task/TaskForm.vue +++ b/src/pages/sys/task/TaskForm.vue @@ -102,7 +102,6 @@ function submitHandler() { defineExpose({ open(data: TaskTypes.SearchTaskResult = {}) { showDialog.value = true - console.log(!Strings.isBlank(data.id), 'dataa') if (!Strings.isBlank(data.id)) { status.value = 'modify' TaskApi.detail(data.id!).then((res) => {