mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-31 09:12:10 +08:00
feat(代码生成): 支持anyline 动态获取表元数据
- 1. 支持代码生成模板 从 github获取 - 2. 重构代码生成的默认值从配置类获取
This commit is contained in:
parent
a90f2be1e3
commit
fecc5d8bcb
@ -15,6 +15,21 @@ export function list() {
|
||||
});
|
||||
}
|
||||
|
||||
export function online() {
|
||||
return request({
|
||||
url: '/gen/template/online',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
export function checkVersion() {
|
||||
return request({
|
||||
url: '/gen/template/checkVersion',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function addObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/gen/template',
|
||||
|
@ -21,6 +21,13 @@ export const validateNull = (val: any) => {
|
||||
};
|
||||
|
||||
export const rule = {
|
||||
overLength(rule: any, value: any, callback: any) {
|
||||
if (value?.length > 255) {
|
||||
callback(new Error('输入内容过长,请重新输入'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 校验 请输入中文、英文、数字包括下划线
|
||||
* 名称校验
|
||||
|
@ -26,6 +26,7 @@ export default {
|
||||
},
|
||||
dictItem: {
|
||||
index: '#',
|
||||
name: 'dict item',
|
||||
importsysDictItemTip: 'import SysDictItem',
|
||||
id: 'id',
|
||||
dictId: 'dictId',
|
||||
|
@ -29,6 +29,7 @@ export default {
|
||||
},
|
||||
dictItem: {
|
||||
index: '#',
|
||||
name: '字典项',
|
||||
importsysDictItemTip: '导入字典项',
|
||||
id: '编号',
|
||||
dictId: ' dictId',
|
||||
|
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible" :close-on-click-modal="false" draggable>
|
||||
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible"
|
||||
:close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12" class="mb20">
|
||||
@ -27,7 +28,9 @@
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('datasourceconf.confType')" prop="confType">
|
||||
<el-radio-group v-model="form.confType">
|
||||
<el-radio :label="Number(item.value)" v-for="(item, index) in ds_config_type" border :key="index">{{ item.label }} </el-radio>
|
||||
<el-radio :label="Number(item.value)" v-for="(item, index) in ds_config_type" border :key="index">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -72,6 +75,7 @@ import { useMessage } from '/@/hooks/message';
|
||||
import {getObj, addObj, putObj} from '/@/api/gen/datasource';
|
||||
import {useI18n} from 'vue-i18n';
|
||||
import {useDict} from '/@/hooks/dict';
|
||||
import {rule} from "/@/utils/validate";
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh']);
|
||||
@ -94,7 +98,7 @@ const form = reactive({
|
||||
password: ('' as string) || undefined,
|
||||
createTime: '',
|
||||
updateTime: '',
|
||||
dsType: '',
|
||||
dsType: 'mysql',
|
||||
confType: 0,
|
||||
dsName: '',
|
||||
instance: '',
|
||||
@ -123,15 +127,20 @@ const dataRules = ref({
|
||||
{required: true, message: '别名不能为空', trigger: 'blur'},
|
||||
{validator: validateDsName, trigger: 'blur'},
|
||||
],
|
||||
url: [{ required: true, message: 'jdbcurl不能为空', trigger: 'blur' }],
|
||||
username: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
|
||||
url: [{required: true, message: 'jdbcurl不能为空', trigger: 'blur'}, {
|
||||
min: 10,
|
||||
max: 500,
|
||||
message: 'URL长度必须介于 10 和 500 字符之间',
|
||||
trigger: 'blur'
|
||||
},],
|
||||
username: [{ validator: rule.overLength, trigger: 'blur' },{required: true, message: '用户名不能为空', trigger: 'blur'}],
|
||||
password: [{ validator: rule.overLength, trigger: 'blur' },{required: true, message: '密码不能为空', trigger: 'blur'}],
|
||||
dsType: [{required: true, message: '数据库类型不能为空', trigger: 'blur'}],
|
||||
confType: [{required: true, message: '配置类型不能为空', trigger: 'blur'}],
|
||||
dsName: [{ required: true, message: '数据库名称不能为空', trigger: 'blur' }],
|
||||
instance: [{ required: true, message: '实例不能为空', trigger: 'blur' }],
|
||||
dsName: [{ validator: rule.overLength, trigger: 'blur' },{required: true, message: '数据库名称不能为空', trigger: 'blur'}],
|
||||
instance: [{ validator: rule.overLength, trigger: 'blur' },{required: true, message: '实例不能为空', trigger: 'blur'}],
|
||||
port: [{required: true, message: '端口不能为空', trigger: 'blur'}],
|
||||
host: [{ required: true, message: '主机不能为空', trigger: 'blur' }],
|
||||
host: [{ validator: rule.overLength, trigger: 'blur' },{required: true, message: '主机不能为空', trigger: 'blur'}],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
@ -155,7 +164,8 @@ const openDialog = async (id: string) => {
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
const valid = await dataFormRef.value.validate().catch(() => {
|
||||
});
|
||||
if (!valid) return false;
|
||||
|
||||
form.password = form.password?.includes('******') ? undefined : form.password;
|
||||
|
@ -4,13 +4,13 @@
|
||||
<el-row class="ml10" v-show="showSearch">
|
||||
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
|
||||
<el-form-item :label="$t('datasourceconf.dsName')" prop="dsName">
|
||||
<el-input :placeholder="$t('datasourceconf.inputdsNameTip')" formDialogRef style="max-width: 180px" v-model="state.queryForm.dsName" />
|
||||
<el-input :placeholder="$t('datasourceconf.inputdsNameTip')" v-model="state.queryForm.dsName" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList" icon="search" type="primary">
|
||||
{{ $t('common.queryBtn') }}
|
||||
</el-button>
|
||||
<el-button @click="resetQuery" formDialogRef icon="Refresh">{{ $t('common.resetBtn') }} </el-button>
|
||||
<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }} </el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
71
src/views/gen/design/form.vue
Normal file
71
src/views/gen/design/form.vue
Normal file
@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<el-drawer title="设计历史" v-model="visible" draggable>
|
||||
<el-table :data="state.dataList" v-loading="state.loading" style="width: 100%" @sort-change="sortChangeHandle">
|
||||
<el-table-column type="index" label="序号" width="60" />
|
||||
<el-table-column prop="createTime" label="设计时间" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="refresh" text type="primary" @click="handleRollback(scope.row.id)">回滚</el-button>
|
||||
<el-button icon="delete" text type="primary" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemFormHistoryDialog">
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { delFormObj, fetchFormList } from '/@/api/gen/table';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
const emit = defineEmits(['refresh']);
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
// 搜索变量
|
||||
const visible = ref(false);
|
||||
// table hook
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchFormList,
|
||||
createdIsNeed: false,
|
||||
descs: ['create_time'],
|
||||
});
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle } = useTable(state);
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (id: string) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delFormObj(id);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 回滚
|
||||
const handleRollback = (id: string) => {
|
||||
emit('refresh', id);
|
||||
};
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
const { tableName, dsName } = route.query;
|
||||
visible.value = true;
|
||||
state.queryForm.dsName = dsName;
|
||||
state.queryForm.tableName = tableName;
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
132
src/views/gen/design/index.vue
Normal file
132
src/views/gen/design/index.vue
Normal file
@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<v-form-designer ref="vfDesignerRef" :banned-widgets="bannedWidgets" :designer-config="designerConfig">
|
||||
<template #customToolButtons>
|
||||
<el-button link type="primary" @click="saveJsonConfig">保存</el-button>
|
||||
<el-button link type="primary" @click="exportSfcConfig">导出</el-button>
|
||||
<el-button link type="primary" @click="formDialogRef.openDialog()">历史</el-button>
|
||||
</template>
|
||||
</v-form-designer>
|
||||
</div>
|
||||
<form-dialog ref="formDialogRef" @refresh="handleRefresh" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { fetchFormById, useFormConfSaveApi, useGeneratorVFormApi, useGeneratorVFormSfcApi } from '/@/api/gen/table';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { handleBlobFile } from '/@/utils/other';
|
||||
import mittBus from '/@/utils/mitt';
|
||||
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const vfDesignerRef = ref();
|
||||
const formDialogRef = ref();
|
||||
const bannedWidgets = reactive(['tab', 'card', 'table', 'cascader']);
|
||||
|
||||
const designerConfig = reactive({
|
||||
//是否显示语言切换菜单
|
||||
languageMenu: false,
|
||||
|
||||
//是否显示GitHub、文档等外部链接
|
||||
externalLink: false,
|
||||
|
||||
//是否显示表单模板
|
||||
formTemplates: false,
|
||||
|
||||
//是否禁止修改唯一名称
|
||||
widgetNameReadonly: false,
|
||||
|
||||
//是否显示组件事件属性折叠面板
|
||||
eventCollapse: false,
|
||||
|
||||
//是否显示清空设计器按钮
|
||||
clearDesignerButton: true,
|
||||
|
||||
//是否显示预览表单按钮
|
||||
previewFormButton: false,
|
||||
|
||||
//是否显示导入JSON按钮
|
||||
importJsonButton: false,
|
||||
|
||||
//是否显示导出JSON器按钮
|
||||
exportJsonButton: false,
|
||||
|
||||
//是否显示导出代码按钮
|
||||
exportCodeButton: true,
|
||||
|
||||
//是否显示生成SFC按钮
|
||||
generateSFCButton: false,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
importJsonConfig();
|
||||
});
|
||||
|
||||
|
||||
// 根据当前表,获取json配置信息
|
||||
const importJsonConfig = () => {
|
||||
const { tableName, dsName } = route.query;
|
||||
|
||||
if (tableName && dsName) {
|
||||
useGeneratorVFormApi(dsName, tableName).then((res) => {
|
||||
vfDesignerRef.value.loadJson(res);
|
||||
});
|
||||
} else {
|
||||
useMessageBox()
|
||||
.confirm('表单初始化失败,请重新选择表点击设计打开')
|
||||
.then(() => {
|
||||
// 关闭当前tab
|
||||
mittBus.emit('onCurrentContextmenuClick', Object.assign({}, { contextMenuClickId: 1, ...route }));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleRefresh = (id: string) => {
|
||||
fetchFormById(id).then((res) => {
|
||||
vfDesignerRef.value.loadJson(JSON.parse(res.data.formInfo));
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
});
|
||||
};
|
||||
|
||||
const saveJsonConfig = () => {
|
||||
const { tableName, dsName } = route.query;
|
||||
|
||||
if (tableName && dsName) {
|
||||
// 先保存表单
|
||||
const formJson = vfDesignerRef.value.getFormJson();
|
||||
useFormConfSaveApi({
|
||||
dsName,
|
||||
tableName,
|
||||
formInfo: JSON.stringify(formJson),
|
||||
}).then(() => {
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const exportSfcConfig = async () => {
|
||||
try {
|
||||
const { tableName, dsName } = route.query;
|
||||
if (!tableName || !dsName) throw new Error('表名或数据源名称不能为空');
|
||||
const formJson = vfDesignerRef.value.getFormJson();
|
||||
const { data } = await useFormConfSaveApi({
|
||||
dsName,
|
||||
tableName,
|
||||
formInfo: JSON.stringify(formJson),
|
||||
});
|
||||
const sfcRes = await useGeneratorVFormSfcApi(data.id);
|
||||
handleBlobFile(sfcRes, 'form.vue');
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.message);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible" width="600"
|
||||
:close-on-click-modal="false" draggable>
|
||||
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible" width="600" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||
<el-form-item :label="t('fieldtype.columnType')" prop="columnType">
|
||||
<el-input v-model="form.columnType" :placeholder="t('fieldtype.inputcolumnTypeTip')" />
|
||||
@ -77,8 +76,7 @@ const openDialog = (id: string) => {
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {
|
||||
});
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
|
@ -47,10 +47,9 @@ const dsName = ref();
|
||||
const editTableRef = ref();
|
||||
const generatorType = ref();
|
||||
|
||||
// tab 跳转
|
||||
const go = async (activeNum: number) => {
|
||||
if (active.value === activeNum) return;
|
||||
active.value = activeNum;
|
||||
|
||||
try {
|
||||
if (activeNum === 0) {
|
||||
await editTableRef.value.submitHandle();
|
||||
} else if (activeNum === 1) {
|
||||
@ -58,8 +57,14 @@ const go = async (activeNum: number) => {
|
||||
tableId.value = dataform.id;
|
||||
generatorType.value = dataform.generatorType;
|
||||
}
|
||||
if (active.value === activeNum) return;
|
||||
active.value = activeNum;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
// 预览
|
||||
const preview = async () => {
|
||||
await editTableRef.value.submitHandle();
|
||||
previewDialogRef.value.openDialog(tableId.value);
|
||||
|
@ -5,12 +5,12 @@
|
||||
<el-input v-model="form.groupName" :placeholder="t('group.inputGroupNameTip')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('group.templateType')" prop="templateId">
|
||||
<el-select v-model="form.templateId" :placeholder="$t('group.selectType')" class="w100" clearable multiple>
|
||||
<el-select v-model="form.templateId" :placeholder="$t('group.selectType')" clearable multiple>
|
||||
<el-option v-for="item in templateData" :key="item.id" :label="item.templateName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('group.groupDesc')" prop="groupDesc">
|
||||
<el-input type="textarea" maxlength="150" rows="3" v-model="form.groupDesc" :placeholder="t('group.inputGroupDescTip')"/>
|
||||
<el-input type="textarea" maxlength="100" :rows="5" v-model="form.groupDesc" :placeholder="t('group.inputGroupDescTip')" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@ -74,8 +74,7 @@ const openDialog = (id: string) => {
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {
|
||||
});
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
|
151
src/views/gen/table/add-dict.vue
Normal file
151
src/views/gen/table/add-dict.vue
Normal file
@ -0,0 +1,151 @@
|
||||
<template>
|
||||
<el-dialog title="新增字典" v-model="visible" width="600">
|
||||
<el-form :model="dataForm" :rules="dataRules" label-width="100px" ref="dicDialogFormRef" v-loading="loading">
|
||||
<el-form-item :label="$t('sysdict.systemFlag')" prop="systemFlag">
|
||||
<el-radio-group v-model="dataForm.systemFlag">
|
||||
<el-radio border :key="index" :label="item.value" v-for="(item, index) in dict_type">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('sysdict.dictType')" prop="dictType">
|
||||
<el-input :placeholder="$t('sysdict.inputDictTypeTip')" :disabled="dataForm.id !== ''" clearable
|
||||
v-model="dataForm.dictType"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('sysdict.description')" prop="description">
|
||||
<el-input :placeholder="$t('sysdict.inputDescriptionTip')" clearable v-model="dataForm.description"></el-input>
|
||||
</el-form-item>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item :label="t('dictItem.name')" prop="columns">
|
||||
<el-table :data="dataForm.columns" border style="width: 100%" max-height="500">
|
||||
<el-table-column type="index" :label="t('createTable.index')" width="50">
|
||||
<template #header>
|
||||
<el-button icon="Plus" size="small" type="primary" circle @click="onAddItem"></el-button>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-button icon="Minus" size="small" type="danger" circle
|
||||
@click="handleDelete(scope.$index, scope.row)"></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="label" :label="$t('dictItem.label')" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.label" :placeholder="t('dictItem.inputLabelTip')"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="value" :label="$t('dictItem.itemValue')" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.value" :placeholder="t('dictItem.inputItemValueTip')"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
|
||||
<el-button @click="onSubmit" type="primary" :disabled="loading">{{ $t('common.confirmButtonText') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="systemDicDialog" setup>
|
||||
import {useI18n} from 'vue-i18n';
|
||||
import {addItemObj, addObj, getObj, validateDictType} from '/@/api/admin/dict';
|
||||
import {useDict} from '/@/hooks/dict';
|
||||
import {useMessage} from '/@/hooks/message';
|
||||
import {rule} from '/@/utils/validate';
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh']);
|
||||
const {dict_type} = useDict('dict_type');
|
||||
const {t} = useI18n();
|
||||
// 定义变量内容
|
||||
const dicDialogFormRef = ref();
|
||||
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
const selectRow = ref({});
|
||||
const dataForm = reactive({
|
||||
id: '',
|
||||
dictType: '',
|
||||
description: '',
|
||||
systemFlag: '0',
|
||||
remarks: '',
|
||||
columns: [] as any
|
||||
});
|
||||
|
||||
const dataRules = reactive({
|
||||
dictType: [
|
||||
{validator: rule.overLength, trigger: 'blur'},
|
||||
{required: true, message: '类型不能为空', trigger: 'blur'},
|
||||
{validator: rule.validatorNameCn, trigger: 'blur'},
|
||||
{
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
validateDictType(rule, value, callback, dataForm.id !== '');
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
systemFlag: [{required: true, message: '字典类型不能为空', trigger: 'blur'}],
|
||||
description: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '描述不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
columns: [{required: true, message: '字典项不能为空', trigger: 'blur'}],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
visible.value = true;
|
||||
dataForm.id = '';
|
||||
nextTick(() => {
|
||||
dicDialogFormRef.value?.resetFields();
|
||||
});
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dicDialogFormRef.value.validate().catch(() => {
|
||||
});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
// 添加字典
|
||||
const {data} = await addObj(dataForm);
|
||||
// addItemObj
|
||||
|
||||
dataForm.columns.forEach(async (item: any) => {
|
||||
item.dictId = data.id;
|
||||
item.dictType = dataForm.dictType;
|
||||
await addItemObj(item);
|
||||
});
|
||||
useMessage().success(t('common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh', dataForm.dictType);
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
let index = 1;
|
||||
const onAddItem = () => {
|
||||
dataForm.columns.push({sortOrder: `${index++}`});
|
||||
}
|
||||
|
||||
const handleDelete = (index: number, row: any) => {
|
||||
dataForm.columns.splice(index, 1)
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
@ -2,10 +2,11 @@
|
||||
<el-tabs v-model="activeName">
|
||||
<!-- 属性设置面板 -->
|
||||
<el-tab-pane label="属性设置" name="field">
|
||||
<sc-form-table ref="fieldTable" v-model="fieldList" :hideAdd="true" :hideDelete="true" drag-sort placeholder="暂无数据">
|
||||
<sc-form-table ref="fieldTable" v-model="fieldList" :hideAdd="true" :hideDelete="true" drag-sort
|
||||
placeholder="暂无数据">
|
||||
<el-table-column label="主键" prop="primaryPk" width="80" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox v-model="row.primaryPk" true-label="1" false-label="0" disabled></el-checkbox>
|
||||
<el-checkbox v-model="row.primaryPk" true-value="1" false-value="0" disabled></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="字段名" prop="fieldName" show-overflow-tooltip></el-table-column>
|
||||
@ -34,9 +35,13 @@
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="字典类型" prop="fieldDict" show-overflow-tooltip>
|
||||
<el-table-column label="字典名称" prop="fieldDict" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.fieldDict" placeholder="请选择类型" filterable clearable :disabled="row.primaryPk === '1'">
|
||||
<el-select v-model="row.fieldDict" placeholder="请选择类型" filterable clearable
|
||||
:disabled="row.primaryPk === '1'">
|
||||
<template #prefix>
|
||||
<el-button icon="Plus" type="primary" link @click.stop="handleAddDict(row)"></el-button>
|
||||
</template>
|
||||
<el-option v-for="item in fieldDictList" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</template>
|
||||
@ -50,17 +55,20 @@
|
||||
<el-table-column label="说明" prop="fieldComment" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column label="列表显示" prop="gridItem" width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox v-model="row.gridItem" true-label="1" false-label="0" :disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
<el-checkbox v-model="row.gridItem" true-value="1" false-value="0"
|
||||
:disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否排序" prop="gridSort" width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox v-model="row.gridSort" true-label="1" false-label="0" :disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
<el-checkbox v-model="row.gridSort" true-value="1" false-value="0"
|
||||
:disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="查询显示" prop="gridSort" width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox v-model="row.queryItem" true-label="1" false-label="0" :disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
<el-checkbox v-model="row.queryItem" true-value="1" false-value="0"
|
||||
:disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="查询表单类型" prop="queryFormType" show-overflow-tooltip>
|
||||
@ -92,12 +100,14 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="是否显示" prop="formItem" width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox v-model="row.formItem" true-label="1" false-label="0" :disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
<el-checkbox v-model="row.formItem" true-value="1" false-value="0"
|
||||
:disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="表单必填" prop="formRequired" width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox v-model="row.formRequired" true-label="1" false-label="0" :disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
<el-checkbox v-model="row.formRequired" true-value="1" false-value="0"
|
||||
:disabled="row.primaryPk === '1'"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="表单效验" prop="formValidator" show-overflow-tooltip>
|
||||
@ -110,6 +120,9 @@
|
||||
</sc-form-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 新增字典 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="handleDictRefresh"/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@ -118,6 +131,7 @@ import { list } from '/@/api/gen/fieldtype';
|
||||
import Sortable from 'sortablejs';
|
||||
|
||||
const scFormTable = defineAsyncComponent(() => import('/@/components/FormTable/index.vue'));
|
||||
const FormDialog = defineAsyncComponent(() => import('./add-dict.vue'));
|
||||
|
||||
const activeName = ref();
|
||||
const tableId = ref('');
|
||||
@ -135,8 +149,10 @@ const visible = ref(false);
|
||||
|
||||
const sortable = ref() as any;
|
||||
|
||||
const formDialogRef = ref();
|
||||
const typeList = ref([]) as any;
|
||||
const fieldDictList = ref([]) as any;
|
||||
const selectRow = ref();
|
||||
const dsName = ref();
|
||||
const tableName = ref();
|
||||
|
||||
@ -186,6 +202,7 @@ const queryTypeList = reactive([
|
||||
]);
|
||||
|
||||
const formValidatorList = reactive([
|
||||
{label: '去重', value: 'duplicate'},
|
||||
{label: '数字', value: 'number'},
|
||||
{label: '字母', value: 'letter'},
|
||||
{label: '字母和数字', value: 'letterAndNumber'},
|
||||
@ -222,11 +239,33 @@ const propToType = reactive({
|
||||
varchar: 'text',
|
||||
});
|
||||
|
||||
/**
|
||||
* 属性修改触发事件
|
||||
* @param row
|
||||
*/
|
||||
const handleChangeRow = (row: any) => {
|
||||
row.queryFormType = propToType[row.attrType];
|
||||
row.formType = propToType[row.attrType];
|
||||
};
|
||||
|
||||
/**
|
||||
* 添加字典
|
||||
* @param row
|
||||
*/
|
||||
const handleAddDict = (row: object) => {
|
||||
selectRow.value = row;
|
||||
formDialogRef.value.openDialog();
|
||||
};
|
||||
|
||||
/**
|
||||
* 刷新字典
|
||||
* @param dictType
|
||||
*/
|
||||
const handleDictRefresh = async (dictType: string) => {
|
||||
await getDictList();
|
||||
selectRow.value.fieldDict = dictType;
|
||||
};
|
||||
|
||||
const openDialog = (dName: string, tName: string) => {
|
||||
visible.value = true;
|
||||
tableName.value = tName;
|
||||
|
@ -7,7 +7,11 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="说明" prop="tableComment">
|
||||
<el-form-item prop="tableComment">
|
||||
<template #label>
|
||||
<span>注释</span>
|
||||
<tip content="注释"/>
|
||||
</template>
|
||||
<el-input placeholder="说明" v-model="dataForm.tableComment"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -31,14 +35,22 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="模块名" prop="moduleName">
|
||||
<el-form-item prop="moduleName">
|
||||
<template #label>
|
||||
<span>模块名</span>
|
||||
<tip content="所属微服务模块名称,对应微服务路由前缀 (单体固定 admin)"/>
|
||||
</template>
|
||||
<el-input placeholder="模块名" v-model="dataForm.moduleName"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="功能名" prop="functionName">
|
||||
<el-form-item prop="functionName">
|
||||
<template #label>
|
||||
<span>功能名</span>
|
||||
<tip content="对应生成的Controller @RequestMapping 请求路径"/>
|
||||
</template>
|
||||
<el-input placeholder="功能名" v-model="dataForm.functionName"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -55,24 +67,32 @@
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="表单布局" prop="formLayout">
|
||||
<el-radio-group v-model="dataForm.formLayout">
|
||||
<el-radio border :label="1">一列</el-radio>
|
||||
<el-radio border :label="2">两列</el-radio>
|
||||
<el-radio border :value="1">一列</el-radio>
|
||||
<el-radio border :value="2">两列</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="生成方式" prop="generatorType">
|
||||
<el-radio-group v-model="dataForm.generatorType">
|
||||
<el-radio border label="1">自定义路径</el-radio>
|
||||
<el-radio border label="0">ZIP 压缩包</el-radio>
|
||||
<el-radio border value="1">自定义路径</el-radio>
|
||||
<el-radio border value="0">ZIP 压缩包</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="后端生成路径" prop="backendPath" v-if="dataForm.generatorType === '1'">
|
||||
<el-form-item prop="backendPath" v-if="dataForm.generatorType === '1'">
|
||||
<template #label>
|
||||
<span>后端生成路径</span>
|
||||
<tip content="后端模块biz所在文件全路径比如:D:\data\pigx\pigx-upms\pigx-upms-biz"/>
|
||||
</template>
|
||||
<el-input placeholder="后端生成路径" v-model="dataForm.backendPath"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="前端生成路径" prop="frontendPath" v-if="dataForm.generatorType === '1'">
|
||||
<el-form-item prop="frontendPath" v-if="dataForm.generatorType === '1'">
|
||||
<template #label>
|
||||
<span>前端生成路径</span>
|
||||
<tip content="前端所在文件全路径比如:D:\data\pigx-ui"/>
|
||||
</template>
|
||||
<el-input placeholder="前端生成路径" v-model="dataForm.frontendPath"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -83,7 +103,10 @@
|
||||
<script lang="ts" setup>
|
||||
import {putObj, useTableApi} from '/@/api/gen/table';
|
||||
import {list as groupList} from '/@/api/gen/group';
|
||||
import {checkVersion, online} from '/@/api/gen/template';
|
||||
import {Local} from '/@/utils/storage';
|
||||
import {rule} from "/@/utils/validate";
|
||||
import {useMessage, useMessageBox} from "/@/hooks/message";
|
||||
|
||||
const props = defineProps({
|
||||
tableName: {
|
||||
@ -127,7 +150,7 @@ const getTable = (dsName: string, tableName: string) => {
|
||||
.then((res) => {
|
||||
Object.assign(dataForm, res.data);
|
||||
let list = res.data.groupList;
|
||||
dataForm.style = list[0].id;
|
||||
dataForm.style = list[0]?.id;
|
||||
|
||||
// 如果是保存路径的形式,有限使用本地配置项
|
||||
const frontendPath = Local.get('frontendPath');
|
||||
@ -144,24 +167,66 @@ const getTable = (dsName: string, tableName: string) => {
|
||||
};
|
||||
|
||||
const dataRules = ref({
|
||||
tableName: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
tableComment: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
className: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
packageName: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
author: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
moduleName: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
functionName: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
generatorType: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
formLayout: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
backendPath: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
frontendPath: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
tableName: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
tableComment: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
className: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
packageName: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
author: [{validator: rule.overLength, trigger: 'blur'}, {required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
moduleName: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
functionName: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
generatorType: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
formLayout: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
backendPath: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
frontendPath: [{validator: rule.overLength, trigger: 'blur'}, {
|
||||
required: true,
|
||||
message: '必填项不能为空',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
style: [{required: true, message: '必填项不能为空', trigger: 'blur'}],
|
||||
});
|
||||
|
||||
// 保存
|
||||
const submitHandle = async () => {
|
||||
try {
|
||||
await dataFormRef.value.validate();
|
||||
const valid = await dataFormRef.value.validate(); // 表单校验
|
||||
if (!valid) return false;
|
||||
|
||||
loading.value = true;
|
||||
await putObj(Object.assign(dataForm, childForm.value));
|
||||
visible.value = false;
|
||||
@ -171,7 +236,7 @@ const submitHandle = async () => {
|
||||
return Promise.reject();
|
||||
} finally {
|
||||
//保存路径至Local 中方便下次使用
|
||||
if (dataForm.generatorType === '1') {
|
||||
if (dataForm.generatorType === "1") {
|
||||
Local.set('frontendPath', dataForm.frontendPath);
|
||||
Local.set('backendPath', dataForm.backendPath);
|
||||
}
|
||||
@ -180,11 +245,40 @@ const submitHandle = async () => {
|
||||
};
|
||||
|
||||
const genGroupList = () => {
|
||||
groupList().then((res) => {
|
||||
groupDataList.value = res.data;
|
||||
});
|
||||
groupList().then(({data}) => {
|
||||
if (data && data.length > 0 ){
|
||||
groupDataList.value = data;
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* 检查模板版本
|
||||
*/
|
||||
const checkTemplateVersion = async () => {
|
||||
checkVersion().then(({data}) => {
|
||||
if (!data) {
|
||||
useMessageBox().confirm('模板发现新版本,是否更新?').then(() => {
|
||||
// 更新模板
|
||||
online().then(() => {
|
||||
useMessage().success('更新成功');
|
||||
genGroupList()
|
||||
});
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
watch(
|
||||
() => childForm,
|
||||
() => {
|
||||
const {childTableName} = childForm.value || {};
|
||||
tableNameStr.value = childTableName ? `${props.tableName} + ${childTableName}` : props.tableName;
|
||||
},
|
||||
{deep: true, immediate: true}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
// 重置表单数据
|
||||
if (dataFormRef.value) {
|
||||
@ -196,6 +290,7 @@ onMounted(() => {
|
||||
|
||||
getTable(dataForm.dsName, dataForm.tableName);
|
||||
genGroupList();
|
||||
checkTemplateVersion()
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
|
@ -4,13 +4,13 @@
|
||||
<el-row class="ml10" v-show="showSearch">
|
||||
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
|
||||
<el-form-item label="数据源" prop="name">
|
||||
<el-select @change="getDataList" placeholder="请选择数据源" style="width: 100%" v-model="state.queryForm.dsName">
|
||||
<el-select @change="getDataList" placeholder="请选择数据源" v-model="state.queryForm.dsName">
|
||||
<el-option label="默认数据源" value="master"></el-option>
|
||||
<el-option :key="ds.id" :label="ds.name" :value="ds.name" v-for="ds in datasourceList"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('table.tableName')" prop="tableName">
|
||||
<el-input :placeholder="$t('table.inputtableNameTip')" style="max-width: 180px" v-model="state.queryForm.tableName" />
|
||||
<el-input :placeholder="$t('table.inputtableNameTip')" v-model="state.queryForm.tableName"/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList" icon="search" type="primary">
|
||||
@ -41,15 +41,18 @@
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
>
|
||||
<el-table-column :label="t('table.index')" type="index" width="60"/>
|
||||
<el-table-column :label="t('table.tableName')" prop="tableName" show-overflow-tooltip />
|
||||
<el-table-column :label="t('table.tableDesc')" prop="tableComment" show-overflow-tooltip />
|
||||
<el-table-column :label="t('table.tableName')" prop="name" show-overflow-tooltip/>
|
||||
<el-table-column :label="t('table.tableDesc')" prop="comment" show-overflow-tooltip/>
|
||||
<el-table-column :label="t('table.createTime')" prop="createTime" show-overflow-tooltip/>
|
||||
<el-table-column :label="$t('common.action')" width="200">
|
||||
<el-table-column :label="$t('common.action')" width="250">
|
||||
<template #default="scope">
|
||||
<el-button icon="Refresh" @click="syncTable(scope.row)" text type="primary">
|
||||
{{ $t('gen.syncBtn') }}
|
||||
</el-button>
|
||||
<el-button icon="FolderOpened" @click="openGen(scope.row)" text type="primary">{{ $t('gen.genBtn') }} </el-button>
|
||||
<el-button icon="FolderOpened" @click="openGen(scope.row)" text type="primary">{{
|
||||
$t('gen.genBtn')
|
||||
}}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -100,7 +103,7 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
const openGen = (row) => {
|
||||
useTableApi(state.queryForm.dsName, row.tableName)
|
||||
useTableApi(state.queryForm.dsName, row.name)
|
||||
.then((res) => {
|
||||
if (validateNull(res.data.fieldList)) {
|
||||
syncTable(row);
|
||||
@ -110,7 +113,7 @@ const openGen = (row) => {
|
||||
router.push({
|
||||
path: '/gen/gener/index',
|
||||
query: {
|
||||
tableName: row.tableName,
|
||||
tableName: row.name,
|
||||
dsName: state.queryForm.dsName,
|
||||
},
|
||||
});
|
||||
@ -118,8 +121,8 @@ const openGen = (row) => {
|
||||
};
|
||||
|
||||
// 同步表数据
|
||||
const syncTable = (row) => {
|
||||
useSyncTableApi(state.queryForm.dsName, row.tableName).then(() => {
|
||||
const syncTable = (row: { name: string }) => {
|
||||
useSyncTableApi(state.queryForm.dsName, row.name).then(() => {
|
||||
useMessage().success(t('common.optSuccessText'));
|
||||
});
|
||||
};
|
||||
|
@ -35,6 +35,7 @@
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { addObj, getObj, putObj } from '/@/api/gen/template';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {rule} from "/@/utils/validate";
|
||||
|
||||
const CodeEditor = defineAsyncComponent(() => import('/@/components/CodeEditor/index.vue'));
|
||||
const emit = defineEmits(['refresh']);
|
||||
@ -59,9 +60,9 @@ const form = reactive({
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
templateName: [{ required: true, message: '模板名称不能为空', trigger: 'blur' }],
|
||||
generatorPath: [{ required: true, message: '模板路径不能为空', trigger: 'blur' }],
|
||||
templateDesc: [{ required: true, message: '模板描述不能为空', trigger: 'blur' }],
|
||||
templateName: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板名称不能为空', trigger: 'blur' }],
|
||||
generatorPath: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板路径不能为空', trigger: 'blur' }],
|
||||
templateDesc: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板描述不能为空', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
|
@ -4,7 +4,8 @@
|
||||
<el-row class="ml10" v-show="showSearch">
|
||||
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
|
||||
<el-form-item :label="$t('template.templateName')" prop="templateName">
|
||||
<el-input :placeholder="t('template.inputTemplateNameTip')" style="max-width: 180px" v-model="state.queryForm.templateName" />
|
||||
<el-input :placeholder="t('template.inputTemplateNameTip')" style="max-width: 180px"
|
||||
v-model="state.queryForm.templateName"/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList" formDialogRef icon="search" type="primary">
|
||||
@ -16,7 +17,8 @@
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button @click="formDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary" v-auth="'codegen_template_add'">
|
||||
<el-button @click="formDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary"
|
||||
v-auth="'codegen_template_add'">
|
||||
{{ $t('common.addBtn') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
@ -30,6 +32,10 @@
|
||||
>
|
||||
{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
<el-button @click="onlineUpdate" class="ml10" icon="download" plain :disabled="updateDisabled"
|
||||
v-auth="'codegen_template_add'">
|
||||
更新
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
:export="'codegen_template_export'"
|
||||
@exportExcel="exportExcel"
|
||||
@ -57,10 +63,12 @@
|
||||
<el-table-column :label="t('template.createTime')" prop="createTime" show-overflow-tooltip/>
|
||||
<el-table-column :label="$t('common.action')" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" @click="formDialogRef.openDialog(scope.row.id)" text type="primary" v-auth="'codegen_template_edit'"
|
||||
<el-button icon="edit-pen" @click="formDialogRef.openDialog(scope.row.id)" text type="primary"
|
||||
v-auth="'codegen_template_edit'"
|
||||
>{{ $t('common.editBtn') }}
|
||||
</el-button>
|
||||
<el-button icon="delete" @click="handleDelete([scope.row.id])" text type="primary" v-auth="'codegen_template_del'"
|
||||
<el-button icon="delete" @click="handleDelete([scope.row.id])" text type="primary"
|
||||
v-auth="'codegen_template_del'"
|
||||
>{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
</template>
|
||||
@ -76,7 +84,7 @@
|
||||
|
||||
<script lang="ts" name="systemGenTemplate" setup>
|
||||
import {BasicTableProps, useTable} from '/@/hooks/table';
|
||||
import { delObjs, fetchList } from '/@/api/gen/template';
|
||||
import {delObjs, fetchList, online} from '/@/api/gen/template';
|
||||
import {useMessage, useMessageBox} from '/@/hooks/message';
|
||||
import {useI18n} from 'vue-i18n';
|
||||
|
||||
@ -87,6 +95,7 @@ const { t } = useI18n();
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref();
|
||||
const updateDisabled = ref(false);
|
||||
// 搜索变量
|
||||
const queryRef = ref();
|
||||
const showSearch = ref(true);
|
||||
@ -139,4 +148,17 @@ const handleDelete = async (ids: string[]) => {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
const onlineUpdate = async () => {
|
||||
try {
|
||||
updateDisabled.value = true;
|
||||
const {data} = await online();
|
||||
getDataList();
|
||||
useMessage().success(data);
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
updateDisabled.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user