diff --git a/.env.development b/.env.development index 1a5d46b..4e87e58 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ # 后台服务地址 -VITE_HTTP_PROXY_TARGET=http://192.168.2.124:10086 +VITE_HTTP_PROXY_TARGET=http://localhost:10086 VITE_WS_PROXY_TARGET=ws://localhost:10086 diff --git a/src/common/router/index.ts b/src/common/router/index.ts index 09998c5..53e088b 100644 --- a/src/common/router/index.ts +++ b/src/common/router/index.ts @@ -110,6 +110,8 @@ export function reloadRouter() { routNames.push('user') routNames.push('role') routNames.push('dict') + routNames.push('db-table') + routNames.push('tpl') if (Colls.isEmpty(routNames)) { return false diff --git a/src/common/utils/http-util.ts b/src/common/utils/http-util.ts index ee71793..bf4c3f1 100644 --- a/src/common/utils/http-util.ts +++ b/src/common/utils/http-util.ts @@ -140,13 +140,14 @@ export function get(url: string, params?: any, disposeErr: boolean = tr * * @param url 请求地址 * @param body Body 参数 + * @param params 参数 * @param disposeErr 是否处理错误响应,默认-->true */ -export function post(url: string, body?: any, disposeErr: boolean = true) { +export function post(url: string, body?: any, params?: any, disposeErr: boolean = true) { if (closeUrls.includes(url)) { return Promise.reject({code: 0, success: true, msg: '', message: '', data: null} as R) } - return httpUtil.post>(url, body, {responseType: 'json'}) + return httpUtil.post>(url, body, {responseType: 'json', params}) .then(({data}) => data) .catch(res => { if (disposeErr) errHandler(res) @@ -224,8 +225,8 @@ function getFileName(contentDisposition: string) { return decodeURIComponent(fileNameWithoutQuotes) } -export function download(url: string, params?: any, defaultName: string = '下载的文件', disposeErr: boolean = true) { - return httpUtil.get(url, {params, paramsSerializer, responseType: 'arraybuffer'}) +export function download(url: string, data?: any, params?: any, defaultName: string = '下载的文件', disposeErr: boolean = true) { + return httpUtil.post(url, data, {params, paramsSerializer, responseType: 'arraybuffer'}) .then(res => { const data = res.data if (!data || data.byteLength <= 0) { diff --git a/src/dts/components.d.ts b/src/dts/components.d.ts index a822845..23ff205 100644 --- a/src/dts/components.d.ts +++ b/src/dts/components.d.ts @@ -5,7 +5,6 @@ // ------ // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 -import { GlobalComponents } from 'vue' export {} @@ -47,6 +46,7 @@ declare module 'vue' { ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabs: typeof import('element-plus/es')['ElTabs'] + ElTabsPane: typeof import('element-plus/es')['ElTabsPane'] ElTag: typeof import('element-plus/es')['ElTag'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTransfer: typeof import('element-plus/es')['ElTransfer'] @@ -97,6 +97,7 @@ declare global { const ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] const ElTabPane: typeof import('element-plus/es')['ElTabPane'] const ElTabs: typeof import('element-plus/es')['ElTabs'] + const ElTabsPane: typeof import('element-plus/es')['ElTabsPane'] const ElTag: typeof import('element-plus/es')['ElTag'] const ElTooltip: typeof import('element-plus/es')['ElTooltip'] const ElTransfer: typeof import('element-plus/es')['ElTransfer'] @@ -104,4 +105,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/pages/sys/dict/DictForm.vue b/src/pages/sys/dict/DictForm.vue index 00b5557..09225f4 100644 --- a/src/pages/sys/dict/DictForm.vue +++ b/src/pages/sys/dict/DictForm.vue @@ -2,6 +2,7 @@ ('add') -const dictFormData = reactive({}) +const dictFormData = ref({}) + +function dialogCloseHandler() { + dictFormData.value = {} +} function submitHandler() { if (status.value === 'view') return submiting.value = true - if (dictFormData.id != null) { - DictApi.modify(dictFormData) + if (dictFormData.value.id != null) { + DictApi.modify(dictFormData.value) .then(() => { ElMessage.success('修改成功') emits('editSucc') @@ -56,7 +61,7 @@ function submitHandler() { submiting.value = false }) } else { - DictApi.add(dictFormData) + DictApi.add(dictFormData.value) .then(() => { ElMessage.success('添加成功') emits('editSucc') @@ -75,11 +80,11 @@ defineExpose({ status.value = 'modify' DictApi.detail(data.id!) .then(res => { - Object.assign(dictFormData, res.data) + dictFormData.value = res.data }) } else { status.value = 'add' - Object.assign(dictFormData, {}) + dictFormData.value = data } }, }) diff --git a/src/pages/sys/dict/DictItemForm.vue b/src/pages/sys/dict/DictItemForm.vue index dbd95f5..6c20333 100644 --- a/src/pages/sys/dict/DictItemForm.vue +++ b/src/pages/sys/dict/DictItemForm.vue @@ -2,6 +2,7 @@ ('add') -const dictItemFormData = reactive({}) +const dictItemFormData = ref({}) + +function dialogCloseHandler() { + dictItemFormData.value = {} +} function submitHandler() { if (status.value === 'view') return submiting.value = true - if (dictItemFormData.id != null) { - DictItemApi.modify(dictItemFormData) + if (dictItemFormData.value.id != null) { + DictItemApi.modify(dictItemFormData.value) .then(() => { ElMessage.success('修改成功') emits('editSucc') @@ -64,11 +69,11 @@ function submitHandler() { submiting.value = false }) } else { - if (Strings.isBlank(dictItemFormData.dictId) || Strings.isBlank(dictItemFormData.dictKey)) { + if (Strings.isBlank(dictItemFormData.value.dictId) || Strings.isBlank(dictItemFormData.value.dictKey)) { ElMessage.error('未指定字典') return } - DictItemApi.add(dictItemFormData) + DictItemApi.add(dictItemFormData.value) .then(() => { ElMessage.success('添加成功') emits('editSucc') @@ -87,11 +92,11 @@ defineExpose({ status.value = 'modify' DictItemApi.detail(data.id!) .then(res => { - Object.assign(dictItemFormData, res.data) + dictItemFormData.value = res.data }) } else { status.value = 'add' - Object.assign(dictItemFormData, data) + dictItemFormData.value = data } }, }) diff --git a/src/pages/sys/gen/db-table/CodePreview.vue b/src/pages/sys/gen/db-table/CodePreview.vue new file mode 100644 index 0000000..eaedcf2 --- /dev/null +++ b/src/pages/sys/gen/db-table/CodePreview.vue @@ -0,0 +1,204 @@ + + + diff --git a/src/pages/sys/gen/db-table/DbTable.vue b/src/pages/sys/gen/db-table/DbTable.vue new file mode 100644 index 0000000..8087afd --- /dev/null +++ b/src/pages/sys/gen/db-table/DbTable.vue @@ -0,0 +1,144 @@ + + + diff --git a/src/pages/sys/gen/db-table/page.ts b/src/pages/sys/gen/db-table/page.ts new file mode 100644 index 0000000..11d293a --- /dev/null +++ b/src/pages/sys/gen/db-table/page.ts @@ -0,0 +1,3 @@ +export default { + component: () => import('@/pages/sys/gen/db-table/DbTable.vue'), +} as RouterTypes.RouteConfig diff --git a/src/pages/sys/gen/gen-api.ts b/src/pages/sys/gen/gen-api.ts new file mode 100644 index 0000000..4a55d2a --- /dev/null +++ b/src/pages/sys/gen/gen-api.ts @@ -0,0 +1,39 @@ +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 new file mode 100644 index 0000000..4a43693 --- /dev/null +++ b/src/pages/sys/gen/gen.d.ts @@ -0,0 +1,29 @@ +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 new file mode 100644 index 0000000..df3c888 --- /dev/null +++ b/src/pages/sys/gen/tpl/Tpl.vue @@ -0,0 +1,213 @@ + + + diff --git a/src/pages/sys/gen/tpl/TplForm.vue b/src/pages/sys/gen/tpl/TplForm.vue new file mode 100644 index 0000000..b028158 --- /dev/null +++ b/src/pages/sys/gen/tpl/TplForm.vue @@ -0,0 +1,126 @@ + + + diff --git a/src/pages/sys/gen/tpl/page.ts b/src/pages/sys/gen/tpl/page.ts new file mode 100644 index 0000000..7ada030 --- /dev/null +++ b/src/pages/sys/gen/tpl/page.ts @@ -0,0 +1,3 @@ +export default { + component: () => import('@/pages/sys/gen/tpl/Tpl.vue'), +} as RouterTypes.RouteConfig diff --git a/src/pages/sys/gen/tpl/tpl-api.ts b/src/pages/sys/gen/tpl/tpl-api.ts new file mode 100644 index 0000000..fccf7d8 --- /dev/null +++ b/src/pages/sys/gen/tpl/tpl-api.ts @@ -0,0 +1,22 @@ +import { + get, + post, +} from '@/common/utils/http-util.ts' + +export default { + paging(data: TplTypes.SearchTplParam) { + return get>('/tpl/paging', data) + }, + detail(id: string) { + return get('/tpl/detail', {id}) + }, + add(data: TplTypes.AddTplParam) { + return post('/tpl/add', data) + }, + modify(data: TplTypes.ModifyTplParam) { + return post('/tpl/modify', data) + }, + del(ids: string[]) { + return post('/tpl/del', ids) + }, +} diff --git a/src/pages/sys/gen/tpl/tpl.d.ts b/src/pages/sys/gen/tpl/tpl.d.ts new file mode 100644 index 0000000..657b874 --- /dev/null +++ b/src/pages/sys/gen/tpl/tpl.d.ts @@ -0,0 +1,64 @@ +export {} +declare global { + namespace TplTypes { + interface SearchTplParam extends G.PageParam { + // Id + id?: string + // 模板名称 + tplName?: string + // 语言 + lang?: string + // 模板内容 + tpl: { + content?: string + dir?: string + filename?: string + } + } + + interface SearchTplResult { + // Id + id?: string + // 模板名称 + tplName?: string + // 语言 + lang?: string + // 模板内容 + tpl: { + content?: string + dir?: string + filename?: string + } + } + + interface AddTplParam { + // Id + id?: string + // 模板名称 + tplName?: string + // 语言 + lang?: string + // 模板内容 + tpl: { + content?: string + dir?: string + filename?: string + } + } + + interface ModifyTplParam { + // Id + id?: string + // 模板名称 + tplName?: string + // 语言 + lang?: string + // 模板内容 + tpl: { + content?: string + dir?: string + filename?: string + } + } + } +} diff --git a/src/pages/sys/menus/MenuForm.vue b/src/pages/sys/menus/MenuForm.vue index b8d1577..063327e 100644 --- a/src/pages/sys/menus/MenuForm.vue +++ b/src/pages/sys/menus/MenuForm.vue @@ -1,164 +1,186 @@