Commit b1470738 authored by chenjiahao's avatar chenjiahao

数仓开发-数据加载-数据出湖&入湖修改

parent e99aaa06
...@@ -316,108 +316,6 @@ export const FieldTypeMappingRuleFormSchema: FormSchema[] = [ ...@@ -316,108 +316,6 @@ export const FieldTypeMappingRuleFormSchema: FormSchema[] = [
}, },
]; ];
export const DataTransformationRuleFormSchema: FormSchema[] = [
{
field: 'ruleName',
label: '规则名称',
component: 'Input',
required: true,
},
{
field: 'selectiveDataTable',
label: '选择数据表',
component: 'Select',
componentProps: {
options: [
{ label: 'table_1', value: 'table_1' },
{ label: 'table_2', value: 'table_2' },
{ label: 'table_3', value: 'table_3' },
{ label: 'table_4', value: 'table_4' },
],
},
required: true,
},
{
field: 'conversionResultWriting',
label: '转换结果写入',
component: 'RadioGroup',
defaultValue: '覆盖已有字段',
componentProps: ({ formModel, formActionType }) => ({
onChange: () => {
const flag = formModel.conversionResultWriting === '覆盖已有字段';
formActionType.updateSchema([{ field: 'selectExistingField', ifShow: flag }]);
formActionType.updateSchema([{ field: 'newFieldName', ifShow: !flag }]);
formActionType.updateSchema([{ field: 'newFieldType', ifShow: !flag }]);
},
options: [
{ label: '覆盖已有字段', value: '覆盖已有字段' },
{ label: '写入新增字段', value: '写入新增字段' },
],
}),
},
{
field: 'selectExistingField',
label: '选择已有字段',
component: 'Select',
componentProps: {
options: [
{ label: 'total_amount', value: 'total_amount' },
{ label: 'payment_id', value: 'payment_id' },
{ label: 'position', value: 'position' },
{ label: 'employee_id', value: 'employee_id' },
],
},
required: true,
ifShow: true,
},
{
field: 'newFieldName',
label: '新增字段名称',
component: 'Input',
required: true,
ifShow: false,
},
{
field: 'newFieldType',
label: '新增字段类型',
component: 'Select',
componentProps: {
options: [
{ label: 'int', value: 'int' },
{ label: 'bigint', value: 'bigint' },
{ label: 'decimal', value: 'decimal' },
{ label: 'varchar', value: 'varchar' },
{ label: 'string', value: 'string' },
{ label: 'timestamp', value: 'timestamp' },
],
},
required: true,
ifShow: false,
},
{
field: 'conversionRule',
label: '转换规则',
component: 'RadioGroup',
defaultValue: '配置规则',
componentProps: ({ formModel, formActionType }) => ({
onChange: () => {
const flag = formModel.conversionRule === '自定义';
formActionType.updateSchema([{ field: 'customRule', ifShow: flag }]);
},
options: [
{ label: '配置规则', value: '配置规则' },
{ label: '自定义', value: '自定义' },
],
}),
},
{
field: 'customRule',
label: '自定义规则',
component: 'InputTextArea',
ifShow: false,
},
];
export const FieldNameMappingRuleFormSchema: FormSchema[] = [ export const FieldNameMappingRuleFormSchema: FormSchema[] = [
{ {
field: 'ruleName', field: 'ruleName',
......
...@@ -6,16 +6,205 @@ ...@@ -6,16 +6,205 @@
@ok="handleSubmit" @ok="handleSubmit"
minHeight="50" minHeight="50"
> >
<BasicForm @register="registerForm" /> <BasicForm @register="registerForm">
<template #functionExpressionTableSlot>
<div style="width: 100%; margin-bottom: 20px">
<a-button style="width: 100%" type="primary">参数解析</a-button>
</div>
<div>
<BasicTable @register="registerDataTransformationRuleTable" />
</div>
</template>
</BasicForm>
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted } from 'vue'; import { onMounted, ref } from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal'; import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicTable, FormSchema, useTable } from '@/components/Table';
import { BasicForm, useForm } from '@/components/Form'; import { BasicForm, useForm } from '@/components/Form';
import { DataTransformationRuleFormSchema } from './dataEntry.data'; import { dataTransformationRuleColumns } from '@/views/dataIntegration/dataLoading/dataEntryLake/offlineLoading.data';
let dataTransformationRuleTableData = ref([]);
let functionExpressionValue = ref('');
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const DataTransformationRuleFormSchema: FormSchema[] = [
{
field: 'ruleName',
label: '规则名称',
component: 'Input',
required: true,
},
{
field: 'selectiveDataTable',
label: '选择数据表',
component: 'Select',
componentProps: {
options: [
{ label: 'table_1', value: 'table_1' },
{ label: 'table_2', value: 'table_2' },
{ label: 'table_3', value: 'table_3' },
{ label: 'table_4', value: 'table_4' },
],
},
required: true,
},
{
field: 'conversionResultWriting',
label: '转换结果写入',
component: 'RadioGroup',
defaultValue: '覆盖已有字段',
componentProps: ({ formModel, formActionType }) => ({
onChange: () => {
const flag = formModel.conversionResultWriting === '覆盖已有字段';
formActionType.updateSchema([{ field: 'selectExistingField', ifShow: flag }]);
formActionType.updateSchema([{ field: 'newFieldName', ifShow: !flag }]);
formActionType.updateSchema([{ field: 'newFieldType', ifShow: !flag }]);
},
options: [
{ label: '覆盖已有字段', value: '覆盖已有字段' },
{ label: '写入新增字段', value: '写入新增字段' },
],
}),
},
{
field: 'selectExistingField',
label: '选择已有字段',
component: 'Select',
componentProps: {
options: [
{ label: 'total_amount', value: 'total_amount' },
{ label: 'payment_id', value: 'payment_id' },
{ label: 'position', value: 'position' },
{ label: 'employee_id', value: 'employee_id' },
],
},
required: true,
ifShow: true,
},
{
field: 'newFieldName',
label: '新增字段名称',
component: 'Input',
required: true,
ifShow: false,
},
{
field: 'newFieldType',
label: '新增字段类型',
component: 'Select',
componentProps: {
options: [
{ label: 'int', value: 'int' },
{ label: 'bigint', value: 'bigint' },
{ label: 'decimal', value: 'decimal' },
{ label: 'varchar', value: 'varchar' },
{ label: 'string', value: 'string' },
{ label: 'timestamp', value: 'timestamp' },
],
},
required: true,
ifShow: false,
},
{
field: 'conversionRule',
label: '转换规则',
component: 'RadioGroup',
defaultValue: '配置规则',
componentProps: ({ formModel, formActionType }) => ({
onChange: () => {
const flag = formModel.conversionRule === '自定义';
formActionType.updateSchema([{ field: 'customRule', ifShow: flag }]);
formActionType.updateSchema([{ field: 'functionExpression', ifShow: !flag }]);
formActionType.updateSchema([{ field: 'functionExpressionTableSlot', ifShow: !flag }]);
},
options: [
{ label: '配置规则', value: '配置规则' },
{ label: '自定义', value: '自定义' },
],
}),
},
{
field: 'customRule',
label: '自定义规则',
component: 'InputTextArea',
ifShow: false,
},
{
field: 'functionExpression',
label: '函数表达式',
component: 'Select',
componentProps: ({ formModel, formActionType }) => ({
onChange: () => {
functionExpressionValue.value = formModel.functionExpression;
const regex = /\$\{(\w+)\}/g;
const matches = [...functionExpressionValue.value.matchAll(regex)];
dataTransformationRuleTableData.value = matches.map((match) => ({
parameterName: match[1],
}));
reload();
// console.log(dataTransformationRuleTableData.value);
},
options: [
{
label: '变更字段名',
value:
'ALTER TABLE ${table_name} CHANGE ${old_column_name} ${new_column_name} ${column_type};',
},
{
label: '变更字段数据类型',
value: 'ALTER TABLE ${table_name} MODIFY ${column_name} ${new_column_type};',
},
{
label: '添加新字段',
value:
'ALTER TABLE ${table_name} ADD COLUMN ${new_column_name} ${column_type} ${default_value};',
},
{
label: '删除字段',
value: 'ALTER TABLE ${table_name} DROP COLUMN ${column_name};',
},
{
label: '重命名表',
value: 'RENAME TABLE ${old_table_name} TO ${new_table_name};',
},
{
label: '创建索引',
value: 'CREATE INDEX ${index_name} ON ${table_name} (${column_name});',
},
{
label: '删除索引',
value: 'DROP INDEX ${index_name} ON ${table_name};',
},
{
label: '添加主键',
value: 'ALTER TABLE ${table_name} ADD PRIMARY KEY (${column_name});',
},
{
label: '移除主键',
value: 'ALTER TABLE ${table_name} DROP PRIMARY KEY;',
},
{
label: '添加外键约束',
value:
'ALTER TABLE ${table_name} ADD CONSTRAINT ${constraint_name} FOREIGN KEY (${column_name}) REFERENCES ${referenced_table_name}(${referenced_column_name});',
},
{
label: '移除外键约束',
value: 'ALTER TABLE ${table_name} DROP FOREIGN KEY ${constraint_name};',
},
],
}),
required: true,
},
{
field: 'functionExpressionTableSlot',
label: '',
slot: 'functionExpressionTableSlot',
},
];
const [registerForm, { validate }] = useForm({ const [registerForm, { validate }] = useForm({
labelWidth: 100, labelWidth: 100,
baseColProps: { span: 24 }, baseColProps: { span: 24 },
...@@ -28,6 +217,27 @@ ...@@ -28,6 +217,27 @@
//初始化弹框 //初始化弹框
const [registerModal, { closeModal, setModalProps }] = useModalInner(async () => {}); const [registerModal, { closeModal, setModalProps }] = useModalInner(async () => {});
const [registerDataTransformationRuleTable, { reload }] = useTable({
api: async () => {
const response = {
pageNu: '1',
pageSize: '5',
pages: '1',
total: dataTransformationRuleTableData.value.length,
code: '',
message: '',
data: dataTransformationRuleTableData.value,
};
return { ...response };
},
scroll: { y: 300 },
rowKey: 'businessId',
columns: dataTransformationRuleColumns,
showTableSetting: false,
showIndexColumn: false,
bordered: false,
});
async function handleSubmit() { async function handleSubmit() {
try { try {
setModalProps({ confirmLoading: true }); setModalProps({ confirmLoading: true });
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
:accept="['.xlsx, .xls']" :accept="['.xlsx, .xls']"
> >
<template #uploadBtnName> <template #uploadBtnName>
{{ 1231231 }} <span>导入文件</span>
</template> </template>
</BasicUpload> </BasicUpload>
</div> </div>
...@@ -2234,34 +2234,15 @@ ...@@ -2234,34 +2234,15 @@
} }
function updateDestinationConfiguration() { function updateDestinationConfiguration() {
updateDestinationConfigurationSchema({ updateDestinationConfigurationSchema([
field: 'CodePreview', { field: 'CodePreview', ifShow: [0].includes(configurationModeFlag.value) },
ifShow: [0].includes(configurationModeFlag.value), { field: 'configurationForm', ifShow: [1].includes(configurationModeFlag.value) },
}); { field: 'switchToTheConfigurationItem', ifShow: [0].includes(configurationModeFlag.value) },
updateDestinationConfigurationSchema({ { field: 'customQuerySQL', ifShow: [0].includes(configurationModeFlag.value) },
field: 'configurationForm', { field: 'editSQL', ifShow: [1].includes(configurationModeFlag.value) },
ifShow: [1].includes(configurationModeFlag.value), { field: 'SQLPreview', ifShow: [1].includes(configurationModeFlag.value) },
}); { field: 'span', ifShow: ![0, 1].includes(configurationModeFlag.value) },
updateDestinationConfigurationSchema({ ]);
field: 'switchToTheConfigurationItem',
ifShow: [0].includes(configurationModeFlag.value),
});
updateDestinationConfigurationSchema({
field: 'customQuerySQL',
ifShow: [0].includes(configurationModeFlag.value),
});
updateDestinationConfigurationSchema({
field: 'editSQL',
ifShow: [1].includes(configurationModeFlag.value),
});
updateDestinationConfigurationSchema({
field: 'SQLPreview',
ifShow: [1].includes(configurationModeFlag.value),
});
updateDestinationConfigurationSchema({
field: 'span',
ifShow: ![0, 1].includes(configurationModeFlag.value),
});
} }
function configurationTableOnClick(record) { function configurationTableOnClick(record) {
......
...@@ -93,7 +93,7 @@ export const partitionKeyColumns: BasicColumn[] = [ ...@@ -93,7 +93,7 @@ export const partitionKeyColumns: BasicColumn[] = [
{ label: 'CHAR', value: 'CHAR' }, { label: 'CHAR', value: 'CHAR' },
{ label: 'BOOLEAN', value: 'BOOLEAN' }, { label: 'BOOLEAN', value: 'BOOLEAN' },
], ],
} },
}, },
]; ];
...@@ -289,6 +289,23 @@ export const compareSearchFormSchema: FormSchema[] = [ ...@@ -289,6 +289,23 @@ export const compareSearchFormSchema: FormSchema[] = [
}, },
]; ];
export const dataTransformationRuleColumns: BasicColumn[] = [
{
title: '参数名',
dataIndex: 'parameterName',
},
{
title: '实际值',
dataIndex: 'parameterValue',
editable: true,
edit: true,
editComponent: 'Input',
editComponentProps: {
placeholder: '请输入',
}
},
];
export const tableListSearchFormSchema: FormSchema[] = [ export const tableListSearchFormSchema: FormSchema[] = [
{ {
field: 'name', field: 'name',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment