Commit 7ff6db9ac7c35f8ca15f85974b9c3414c32f15e4

Authored by xingyu4j
1 parent b1a2dfb0

refactor: codegen

yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue
  1 +<template>
  2 + <ContentDetailWrap title="代码生成" @back="push('/infra/codegen')">
  3 + <el-tabs v-model="activeName">
  4 + <el-tab-pane label="基本信息" name="basicInfo">
  5 + <BasicInfoForm ref="basicInfoRef" :basicInfo="tableCurrentRow" />
  6 + </el-tab-pane>
  7 + <el-tab-pane label="字段信息" name="cloum">
  8 + <CloumInfoForm ref="cloumInfoRef" :info="cloumCurrentRow" />
  9 + </el-tab-pane>
  10 + <el-tab-pane label="生成信息" name="genInfo">
  11 + <GenInfoForm ref="genInfoRef" :genInfo="tableCurrentRow" />
  12 + </el-tab-pane>
  13 + </el-tabs>
  14 + <template #right>
  15 + <XButton type="primary" :title="t('action.save')" :loading="loading" @click="submitForm()" />
  16 + </template>
  17 + </ContentDetailWrap>
  18 +</template>
1 19 <script setup lang="ts">
2 20 import { ref, unref, onMounted } from 'vue'
  21 +import { useRouter, useRoute } from 'vue-router'
  22 +import { ElTabs, ElTabPane } from 'element-plus'
  23 +import { useI18n } from '@/hooks/web/useI18n'
  24 +import { useMessage } from '@/hooks/web/useMessage'
3 25 import { ContentDetailWrap } from '@/components/ContentDetailWrap'
4 26 import { BasicInfoForm, CloumInfoForm, GenInfoForm } from './components'
5   -import { ElTabs, ElTabPane, ElMessage } from 'element-plus'
6 27 import { getCodegenTableApi, updateCodegenTableApi } from '@/api/infra/codegen'
7   -import { useRouter, useRoute } from 'vue-router'
8   -import { useI18n } from '@/hooks/web/useI18n'
9 28 import { CodegenTableVO, CodegenColumnVO, CodegenUpdateReqVO } from '@/api/infra/codegen/types'
10   -const { t } = useI18n()
  29 +
  30 +const { t } = useI18n() // 国际化
  31 +const message = useMessage() // 消息弹窗
11 32 const { push } = useRouter()
12 33 const { query } = useRoute()
13 34 const tableCurrentRow = ref<CodegenTableVO>()
... ... @@ -26,10 +47,6 @@ const activeName = ref(&#39;cloum&#39;)
26 47 const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>()
27 48 const genInfoRef = ref<ComponentRef<typeof GenInfoForm>>()
28 49 const cloumInfoRef = ref(null)
29   -const parentMenuId = ref<number>()
30   -const menu = (id: number) => {
31   - parentMenuId.value = id
32   -}
33 50 const submitForm = async () => {
34 51 const basicInfo = unref(basicInfoRef)
35 52 const genInfo = unref(genInfoRef)
... ... @@ -38,17 +55,12 @@ const submitForm = async () =&gt; {
38 55 if (basicForm && genForm) {
39 56 const basicInfoData = (await basicInfo?.getFormData()) as CodegenTableVO
40 57 const genInfoData = (await genInfo?.getFormData()) as CodegenTableVO
41   - if (parentMenuId.value) {
42   - genInfoData.parentMenuId = parentMenuId.value
43   - } else {
44   - genInfoData.parentMenuId = 0
45   - }
46 58 const genTable: CodegenUpdateReqVO = {
47 59 table: Object.assign({}, basicInfoData, genInfoData),
48 60 columns: cloumCurrentRow.value
49 61 }
50 62 await updateCodegenTableApi(genTable)
51   - ElMessage.success(t('common.updateSuccess'))
  63 + message.success(t('common.updateSuccess'))
52 64 push('/infra/codegen')
53 65 }
54 66 }
... ... @@ -56,21 +68,3 @@ onMounted(() =&gt; {
56 68 getList()
57 69 })
58 70 </script>
59   -<template>
60   - <ContentDetailWrap title="代码生成" @back="push('/infra/codegen')">
61   - <el-tabs v-model="activeName">
62   - <el-tab-pane label="基本信息" name="basicInfo">
63   - <BasicInfoForm ref="basicInfoRef" :basicInfo="tableCurrentRow" />
64   - </el-tab-pane>
65   - <el-tab-pane label="字段信息" name="cloum">
66   - <CloumInfoForm ref="cloumInfoRef" :info="cloumCurrentRow" />
67   - </el-tab-pane>
68   - <el-tab-pane label="生成信息" name="genInfo">
69   - <GenInfoForm ref="genInfoRef" :genInfo="tableCurrentRow" @menu="menu" />
70   - </el-tab-pane>
71   - </el-tabs>
72   - <template #right>
73   - <XButton type="primary" :title="t('action.save')" :loading="loading" @click="submitForm()" />
74   - </template>
75   - </ContentDetailWrap>
76   -</template>
... ...
yudao-ui-admin-vue3/src/views/infra/codegen/codegen.data.ts
1 1 import { reactive } from 'vue'
2 2 import { useI18n } from '@/hooks/web/useI18n'
3 3 import { required } from '@/utils/formRules'
4   -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
  4 +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
5 5 const { t } = useI18n() // 国际化
6 6  
7 7 // 表单校验
... ... @@ -12,54 +12,45 @@ export const rules = reactive({
12 12 })
13 13  
14 14 // CrudSchema
15   -const crudSchemas = reactive<CrudSchema[]>([
16   - {
17   - label: t('common.index'),
18   - field: 'id',
19   - type: 'index',
20   - isForm: false,
21   - isDetail: false
22   - },
23   - {
24   - label: '表名称',
25   - field: 'tableName',
26   - isSearch: true
27   - },
28   - {
29   - label: '表描述',
30   - field: 'tableComment',
31   - isSearch: true
32   - },
33   - {
34   - label: '实体',
35   - field: 'className',
36   - isSearch: true
37   - },
38   - {
39   - label: t('common.createTime'),
40   - field: 'createTime',
41   - isForm: false,
42   - search: {
43   - show: true,
44   - component: 'DatePicker',
45   - componentProps: {
46   - type: 'datetimerange',
47   - valueFormat: 'YYYY-MM-DD HH:mm:ss',
48   - defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]
  15 +const crudSchemas = reactive<VxeCrudSchema>({
  16 + primaryKey: 'id',
  17 + primaryType: 'seq',
  18 + action: true,
  19 + actionWidth: '400px',
  20 + columns: [
  21 + {
  22 + title: '表名称',
  23 + field: 'tableName',
  24 + isSearch: true
  25 + },
  26 + {
  27 + title: '表描述',
  28 + field: 'tableComment',
  29 + isSearch: true
  30 + },
  31 + {
  32 + title: '实体',
  33 + field: 'className',
  34 + isSearch: true
  35 + },
  36 + {
  37 + title: t('common.createTime'),
  38 + field: 'createTime',
  39 + formatter: 'formatDate',
  40 + isForm: false,
  41 + search: {
  42 + show: true,
  43 + itemRender: {
  44 + name: 'XDataTimePicker'
  45 + }
49 46 }
  47 + },
  48 + {
  49 + title: t('common.updateTime'),
  50 + field: 'updateTime',
  51 + formatter: 'formatDate',
  52 + isForm: false
50 53 }
51   - },
52   - {
53   - label: t('common.updateTime'),
54   - field: 'updateTime',
55   - isForm: false
56   - },
57   - {
58   - label: t('table.action'),
59   - field: 'action',
60   - width: '350px',
61   - isForm: false,
62   - isDetail: false
63   - }
64   -])
65   -export const { allSchemas } = useCrudSchemas(crudSchemas)
  54 + ]
  55 +})
  56 +export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
... ...
yudao-ui-admin-vue3/src/views/infra/codegen/components/BasicInfoForm.vue
  1 +<template>
  2 + <Form :rules="rules" @register="register" />
  3 +</template>
1 4 <script setup lang="ts">
2 5 import { PropType, reactive, watch } from 'vue'
3 6 import { required } from '@/utils/formRules'
4   -import { CodegenTableVO } from '@/api/infra/codegen/types'
5   -import { Form } from '@/components/Form'
6 7 import { useForm } from '@/hooks/web/useForm'
  8 +import { Form } from '@/components/Form'
7 9 import { FormSchema } from '@/types/form'
8   -
  10 +import { CodegenTableVO } from '@/api/infra/codegen/types'
9 11 const props = defineProps({
10 12 basicInfo: {
11 13 type: Object as PropType<Nullable<CodegenTableVO>>,
... ... @@ -85,6 +87,3 @@ defineExpose({
85 87 getFormData: methods.getFormData
86 88 })
87 89 </script>
88   -<template>
89   - <Form :rules="rules" @register="register" />
90   -</template>
... ...
yudao-ui-admin-vue3/src/views/infra/codegen/components/CloumInfoForm.vue
1   -<script setup lang="ts">
2   -import { onMounted, PropType, ref } from 'vue'
3   -import { ElInput, ElSelect, ElOption } from 'element-plus'
4   -import { CodegenColumnVO } from '@/api/infra/codegen/types'
5   -import { listSimpleDictTypeApi } from '@/api/system/dict/dict.type'
6   -import { DictTypeVO } from '@/api/system/dict/types'
7   -const props = defineProps({
8   - info: {
9   - type: Array as unknown as PropType<CodegenColumnVO[]>,
10   - default: () => null
11   - }
12   -})
13   -/** 查询字典下拉列表 */
14   -const dictOptions = ref<DictTypeVO[]>()
15   -const getDictOptions = async () => {
16   - const res = await listSimpleDictTypeApi()
17   - dictOptions.value = res
18   -}
19   -onMounted(async () => {
20   - await getDictOptions()
21   -})
22   -defineExpose({
23   - info: props.info
24   -})
25   -</script>
26 1 <template>
27 2 <vxe-table ref="dragTable" :data="info" stripe :column-config="{ resizable: true }">
28 3 <vxe-column title="字段列名" field="columnName" fixed="left" width="80" />
... ... @@ -123,3 +98,29 @@ defineExpose({
123 98 </vxe-column>
124 99 </vxe-table>
125 100 </template>
  101 +<script setup lang="ts">
  102 +import { onMounted, PropType, ref } from 'vue'
  103 +import { ElInput, ElSelect, ElOption } from 'element-plus'
  104 +import { DictTypeVO } from '@/api/system/dict/types'
  105 +import { CodegenColumnVO } from '@/api/infra/codegen/types'
  106 +import { listSimpleDictTypeApi } from '@/api/system/dict/dict.type'
  107 +
  108 +const props = defineProps({
  109 + info: {
  110 + type: Array as unknown as PropType<CodegenColumnVO[]>,
  111 + default: () => null
  112 + }
  113 +})
  114 +/** 查询字典下拉列表 */
  115 +const dictOptions = ref<DictTypeVO[]>()
  116 +const getDictOptions = async () => {
  117 + const res = await listSimpleDictTypeApi()
  118 + dictOptions.value = res
  119 +}
  120 +onMounted(async () => {
  121 + await getDictOptions()
  122 +})
  123 +defineExpose({
  124 + info: props.info
  125 +})
  126 +</script>
... ...
yudao-ui-admin-vue3/src/views/infra/codegen/components/GenInfoForm.vue
  1 +<template>
  2 + <Form :rules="rules" @register="register" />
  3 +</template>
1 4 <script setup lang="ts">
2 5 import { onMounted, PropType, reactive, ref, watch } from 'vue'
3   -import { required } from '@/utils/formRules'
4 6 import { Form } from '@/components/Form'
5   -import { handleTree } from '@/utils/tree'
6   -import { ElTreeSelect } from 'element-plus'
7 7 import { useForm } from '@/hooks/web/useForm'
  8 +import { required } from '@/utils/formRules'
  9 +import { handleTree } from '@/utils/tree'
8 10 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
9 11 import { listSimpleMenusApi } from '@/api/system/menu'
10 12 import { CodegenTableVO } from '@/api/infra/codegen/types'
... ... @@ -32,7 +34,6 @@ const rules = reactive({
32 34 })
33 35 const templateTypeOptions = getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE)
34 36 const sceneOptions = getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE)
35   -const treeRef = ref<InstanceType<typeof ElTreeSelect>>()
36 37 const menuOptions = ref<any>([]) // 树形结构
37 38 const getTree = async () => {
38 39 const res = await listSimpleMenusApi()
... ... @@ -100,8 +101,12 @@ const schema = reactive&lt;FormSchema[]&gt;([
100 101 {
101 102 label: '上级菜单',
102 103 field: 'parentMenuId',
  104 + component: 'TreeSelect',
103 105 componentProps: {
104   - optionsSlot: true
  106 + data: menuOptions,
  107 + props: menuProps,
  108 + checkStrictly: true,
  109 + nodeKey: 'id'
105 110 },
106 111 labelMessage: '分配到指定菜单下,例如 系统管理',
107 112 colProps: {
... ... @@ -112,12 +117,6 @@ const schema = reactive&lt;FormSchema[]&gt;([
112 117 const { register, methods, elFormRef } = useForm({
113 118 schema
114 119 })
115   -const parentMenuId = ref<number>()
116   -//子组件像父组件传值
117   -const emit = defineEmits(['menu'])
118   -const handleNodeClick = () => {
119   - emit('menu', parentMenuId.value)
120   -}
121 120  
122 121 // ========== 初始化 ==========
123 122 onMounted(async () => {
... ... @@ -140,18 +139,3 @@ defineExpose({
140 139 getFormData: methods.getFormData
141 140 })
142 141 </script>
143   -<template>
144   - <Form :rules="rules" @register="register">
145   - <template #parentMenuId>
146   - <el-tree-select
147   - v-model="parentMenuId"
148   - ref="treeRef"
149   - node-key="id"
150   - :props="menuProps"
151   - :data="menuOptions"
152   - check-strictly
153   - @change="handleNodeClick"
154   - />
155   - </template>
156   - </Form>
157   -</template>
... ...
yudao-ui-admin-vue3/src/views/infra/codegen/components/ImportTable.vue
... ... @@ -48,16 +48,16 @@
48 48 </template>
49 49 </XModal>
50 50 </template>
51   -
52 51 <script setup lang="ts">
53 52 import { ref, reactive } from 'vue'
54 53 import { useI18n } from '@/hooks/web/useI18n'
55 54 import { useMessage } from '@/hooks/web/useMessage'
56   -import { getSchemaTableListApi, createCodegenListApi } from '@/api/infra/codegen'
  55 +import { VxeTableInstance } from 'vxe-table'
57 56 import { ElForm, ElFormItem, ElInput, ElSelect, ElOption } from 'element-plus'
58   -import { getDataSourceConfigListApi, DataSourceConfigVO } from '@/api/infra/dataSourceConfig'
59 57 import type { DatabaseTableVO } from '@/api/infra/codegen/types'
60   -import { VxeTableInstance } from 'vxe-table'
  58 +import { getSchemaTableListApi, createCodegenListApi } from '@/api/infra/codegen'
  59 +import { getDataSourceConfigListApi, DataSourceConfigVO } from '@/api/infra/dataSourceConfig'
  60 +
61 61 const { t } = useI18n() // 国际化
62 62 const message = useMessage() // 消息弹窗
63 63 const emit = defineEmits(['ok'])
... ...
yudao-ui-admin-vue3/src/views/infra/codegen/components/Preview.vue
  1 +<template>
  2 + <XModal title="预览" v-model="preview.open">
  3 + <div class="flex">
  4 + <el-card class="w-1/4" :gutter="12" shadow="hover">
  5 + <el-scrollbar height="calc(100vh - 88px - 40px - 50px)">
  6 + <el-tree
  7 + ref="treeRef"
  8 + node-key="id"
  9 + :data="preview.fileTree"
  10 + :expand-on-click-node="false"
  11 + default-expanded-keys="[0]"
  12 + highlight-current
  13 + @node-click="handleNodeClick"
  14 + />
  15 + </el-scrollbar>
  16 + </el-card>
  17 + <el-card class="w-3/4" style="margin-left: 10px" :gutter="12" shadow="hover">
  18 + <el-tabs v-model="preview.activeName">
  19 + <el-tab-pane
  20 + v-for="item in previewCodegen"
  21 + :label="item.filePath.substring(item.filePath.lastIndexOf('/') + 1)"
  22 + :name="item.filePath"
  23 + :key="item.filePath"
  24 + >
  25 + <XTextButton style="float: right" :title="t('common.copy')" @click="copy(item.code)" />
  26 + <pre>{{ item.code }}</pre>
  27 + </el-tab-pane>
  28 + </el-tabs>
  29 + </el-card>
  30 + </div>
  31 + </XModal>
  32 +</template>
1 33 <script setup lang="ts">
2 34 import { reactive, ref, unref } from 'vue'
  35 +import { useClipboard } from '@vueuse/core'
  36 +import { ElCard, ElTree, ElTabs, ElTabPane } from 'element-plus'
  37 +import { useI18n } from '@/hooks/web/useI18n'
  38 +import { useMessage } from '@/hooks/web/useMessage'
3 39 import { handleTree2 } from '@/utils/tree'
4   -import { ElCard, ElTree, ElTabs, ElTabPane, ElMessage } from 'element-plus'
5 40 import { previewCodegenApi } from '@/api/infra/codegen'
6 41 import { CodegenTableVO, CodegenPreviewVO } from '@/api/infra/codegen/types'
7   -import { useI18n } from '@/hooks/web/useI18n'
8   -import { useClipboard } from '@vueuse/core'
9   -const { t } = useI18n()
  42 +
  43 +const { t } = useI18n() // 国际化
  44 +const message = useMessage() // 消息弹窗
10 45 // ======== 显示页面 ========
11 46 const preview = reactive({
12 47 open: false,
... ... @@ -101,11 +136,11 @@ const handleFiles = (datas: CodegenPreviewVO[]) =&gt; {
101 136 const copy = async (text: string) => {
102 137 const { copy, copied, isSupported } = useClipboard({ source: text })
103 138 if (!isSupported) {
104   - ElMessage.error(t('common.copyError'))
  139 + message.error(t('common.copyError'))
105 140 } else {
106 141 await copy()
107 142 if (unref(copied)) {
108   - ElMessage.success(t('common.copySuccess'))
  143 + message.success(t('common.copySuccess'))
109 144 }
110 145 }
111 146 }
... ... @@ -113,38 +148,3 @@ defineExpose({
113 148 show
114 149 })
115 150 </script>
116   -<template>
117   - <XModal title="预览" v-model="preview.open">
118   - <div class="flex">
119   - <el-card class="w-1/4" :gutter="12" shadow="hover">
120   - <el-scrollbar height="calc(100vh - 88px - 40px - 50px)">
121   - <el-tree
122   - ref="treeRef"
123   - node-key="id"
124   - :data="preview.fileTree"
125   - :expand-on-click-node="false"
126   - default-expand-all
127   - highlight-current
128   - @node-click="handleNodeClick"
129   - />
130   - </el-scrollbar>
131   - </el-card>
132   - <el-card class="w-3/4" style="margin-left: 10px" :gutter="12" shadow="hover">
133   - <el-tabs v-model="preview.activeName">
134   - <el-tab-pane
135   - v-for="item in previewCodegen"
136   - :label="item.filePath.substring(item.filePath.lastIndexOf('/') + 1)"
137   - :name="item.filePath"
138   - :key="item.filePath"
139   - >
140   - <el-button link style="float: right" @click="copy(item.code)">
141   - {{ t('common.copy') }}
142   - </el-button>
143   - <pre>{{ item.code }}</pre>
144   - <!-- <pre><code class="language-html" v-html="highlightedCode(item)"></code></pre> -->
145   - </el-tab-pane>
146   - </el-tabs>
147   - </el-card>
148   - </div>
149   - </XModal>
150   -</template>
... ...
yudao-ui-admin-vue3/src/views/infra/codegen/index.vue
  1 +<template>
  2 + <ContentWrap>
  3 + <!-- 列表 -->
  4 + <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  5 + <template #toolbar_buttons>
  6 + <XButton
  7 + type="primary"
  8 + preIcon="ep:zoom-in"
  9 + :title="t('action.import')"
  10 + v-hasPermi="['infra:codegen:create']"
  11 + @click="openImportTable()"
  12 + />
  13 + </template>
  14 + <template #actionbtns_default="{ row }">
  15 + <XTextButton
  16 + preIcon="ep:view"
  17 + :title="t('action.preview')"
  18 + v-hasPermi="['infra:codegen:query']"
  19 + @click="handlePreview(row.id)"
  20 + />
  21 + <XTextButton
  22 + preIcon="ep:edit"
  23 + :title="t('action.edit')"
  24 + v-hasPermi="['infra:codegen:update']"
  25 + @click="handleUpdate(row.id)"
  26 + />
  27 + <XTextButton
  28 + preIcon="ep:delete"
  29 + :title="t('action.del')"
  30 + v-hasPermi="['infra:codegen:delete']"
  31 + @click="handleDelete(row.id)"
  32 + />
  33 + <XTextButton
  34 + preIcon="ep:refresh"
  35 + :title="t('action.sync')"
  36 + v-hasPermi="['infra:codegen:update']"
  37 + @click="handleSynchDb(row.id)"
  38 + />
  39 + <XTextButton
  40 + preIcon="ep:download"
  41 + :title="t('action.generate')"
  42 + v-hasPermi="['infra:codegen:download']"
  43 + @click="handleGenTable(row.id)"
  44 + />
  45 + </template>
  46 + </vxe-grid>
  47 + </ContentWrap>
  48 + <ImportTable ref="importRef" @ok="handleQuery()" />
  49 + <Preview ref="previewRef" />
  50 +</template>
1 51 <script setup lang="ts">
2 52 import { ref } from 'vue'
3   -import dayjs from 'dayjs'
  53 +import { useRouter } from 'vue-router'
  54 +import { VxeGridInstance } from 'vxe-table'
  55 +import { useI18n } from '@/hooks/web/useI18n'
  56 +import { useMessage } from '@/hooks/web/useMessage'
  57 +import { useVxeGrid } from '@/hooks/web/useVxeGrid'
  58 +import download from '@/utils/download'
4 59 import * as CodegenApi from '@/api/infra/codegen'
5   -import { useTable } from '@/hooks/web/useTable'
6 60 import { CodegenTableVO } from '@/api/infra/codegen/types'
7 61 import { allSchemas } from './codegen.data'
8   -import { useI18n } from '@/hooks/web/useI18n'
9 62 import { ImportTable, Preview } from './components'
10   -import download from '@/utils/download'
11   -import { useRouter } from 'vue-router'
12   -import { useMessage } from '@/hooks/web/useMessage'
13   -const message = useMessage()
  63 +
14 64 const { t } = useI18n() // 国际化
  65 +const message = useMessage() // 消息弹窗
15 66 const { push } = useRouter()
16   -// ========== 列表相关 ==========
17   -const { register, tableObject, methods } = useTable<CodegenTableVO>({
  67 +// 列表相关的变量
  68 +const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
  69 +const { gridOptions, getList, deleteData } = useVxeGrid<CodegenTableVO>({
  70 + allSchemas: allSchemas,
18 71 getListApi: CodegenApi.getCodegenTablePageApi,
19   - delListApi: CodegenApi.deleteCodegenTableApi
  72 + deleteApi: CodegenApi.deleteCodegenTableApi
20 73 })
21   -const { getList, setSearchParams, delList } = methods
  74 +
22 75 // 导入操作
23 76 const importRef = ref()
24 77 const openImportTable = () => {
... ... @@ -30,8 +83,8 @@ const handlePreview = (row: CodegenTableVO) =&gt; {
30 83 previewRef.value.show(row)
31 84 }
32 85 // 编辑操作
33   -const handleEditTable = (row: CodegenTableVO) => {
34   - push('/codegen/edit?id=' + row.id)
  86 +const handleUpdate = (rowId: number) => {
  87 + push('/codegen/edit?id=' + rowId)
35 88 }
36 89 // 同步操作
37 90 const handleSynchDb = (row: CodegenTableVO) => {
... ... @@ -49,88 +102,12 @@ const handleGenTable = async (row: CodegenTableVO) =&gt; {
49 102 const res = await CodegenApi.downloadCodegenApi(row.id)
50 103 download.zip(res, 'codegen-' + row.className + '.zip')
51 104 }
  105 +// 删除操作
  106 +const handleDelete = async (rowId: number) => {
  107 + await deleteData(xGrid, rowId)
  108 +}
52 109 // 查询操作
53   -const handleQuery = () => {
54   - getList()
  110 +const handleQuery = async () => {
  111 + await getList(xGrid)
55 112 }
56   -// ========== 初始化 ==========
57   -getList()
58 113 </script>
59   -<template>
60   - <!-- 搜索工作区 -->
61   - <ContentWrap>
62   - <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
63   - </ContentWrap>
64   - <ContentWrap>
65   - <!-- 操作工具栏 -->
66   - <div class="mb-10px">
67   - <el-button type="primary" v-hasPermi="['infra:codegen:create']" @click="openImportTable">
68   - <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.import') }}
69   - </el-button>
70   - </div>
71   - <!-- 列表 -->
72   - <Table
73   - :columns="allSchemas.tableColumns"
74   - :selection="false"
75   - :data="tableObject.tableList"
76   - :loading="tableObject.loading"
77   - :pagination="{
78   - total: tableObject.total
79   - }"
80   - v-model:pageSize="tableObject.pageSize"
81   - v-model:currentPage="tableObject.currentPage"
82   - @register="register"
83   - >
84   - <template #createTime="{ row }">
85   - <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
86   - </template>
87   - <template #updateTime="{ row }">
88   - <span>{{ dayjs(row.updateTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
89   - </template>
90   - <template #action="{ row }">
91   - <el-button
92   - link
93   - type="primary"
94   - v-hasPermi="['infra:codegen:preview']"
95   - @click="handlePreview(row)"
96   - >
97   - <Icon icon="ep:view" class="mr-1px" /> {{ t('action.preview') }}
98   - </el-button>
99   - <el-button
100   - link
101   - type="primary"
102   - v-hasPermi="['infra:codegen:update']"
103   - @click="handleEditTable(row)"
104   - >
105   - <Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }}
106   - </el-button>
107   - <el-button
108   - link
109   - type="primary"
110   - v-hasPermi="['infra:codegen:delete']"
111   - @click="delList(row.id, false)"
112   - >
113   - <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
114   - </el-button>
115   - <el-button
116   - link
117   - type="primary"
118   - v-hasPermi="['infra:codegen:update']"
119   - @click="handleSynchDb(row)"
120   - >
121   - <Icon icon="ep:refresh" class="mr-1px" /> {{ t('action.sync') }}
122   - </el-button>
123   - <el-button
124   - link
125   - type="primary"
126   - v-hasPermi="['infra:codegen:download']"
127   - @click="handleGenTable(row)"
128   - >
129   - <Icon icon="ep:download" class="mr-1px" /> {{ t('action.generate') }}
130   - </el-button>
131   - </template>
132   - </Table>
133   - </ContentWrap>
134   - <ImportTable ref="importRef" @ok="handleQuery" />
135   - <Preview ref="previewRef" />
136   -</template>
... ...