Commit c7b11490 by zhaochengxiang

DDL导出参数设置

parent 0c352685
import React from "react" import React from "react"
import { Modal, Button, Row, Col, Space, Select, Input, Form, Tooltip, Typography, Spin } from 'antd' import { Modal, Button, Row, Col, Space, Select, Input, Form, Tooltip, Typography, Spin, Checkbox } from 'antd'
import { SettingFilled } from '@ant-design/icons';
import { dispatch } from '../../../../model' import { dispatch } from '../../../../model'
import { formatVersionDate } from "../../../../util" import { formatVersionDate } from "../../../../util"
import download from "../../../../util/Component/download" import download from "../../../../util/Component/download"
import { config } from "rxjs" import { config } from "rxjs"
const ddlFilterInfo = {
: {
tableDrop: 'DROP',
tableCreate: 'CREATE',
tableAlert: 'ALERT',
tableSchema: '表物理位置',
tableCnName: '表中文名',
tableRemark: '表描述',
},
KEY: {
primaryKey: '主键',
primaryKeyConstraint: '主键约束',
},
字段: {
columnCnName: '中文名',
columnRemark: '字段描述',
},
索引: {
index: '索引',
indexRemark: '注释',
}
}
const notAlertSpecialInfo = [
{ key: 'tableCreate', defaultValue: true },
{ key: 'tableAlert', defaultValue: false },
]
const alertSpecialInfo = [
{ key: 'tableCreate', defaultValue: false },
{ key: 'tableAlert', defaultValue: true },
{ key: 'tableDrop', defaultValue: false },
]
const FC = (props) => { const FC = (props) => {
const { ids, visible, onCancel } = props const { ids, visible, onCancel } = props
const [downloading, setDownloading] = React.useState(false) const [downloading, setDownloading] = React.useState(false)
...@@ -84,23 +119,22 @@ const Basic = React.forwardRef(function ({ ids }, ref) { ...@@ -84,23 +119,22 @@ const Basic = React.forwardRef(function ({ ids }, ref) {
}, [ids]) }, [ids])
React.useEffect(() => { React.useEffect(() => {
let ddlFilter = {}
for (const key in ddlFilterInfo) {
for (const _key in ddlFilterInfo[key]) {
ddlFilter[_key] = true
const index = notAlertSpecialInfo.findIndex(item => item.key === _key)
if (index !== -1) {
ddlFilter[_key] = notAlertSpecialInfo[index].defaultValue
}
}
}
const newConfigs = (data??[]).map(item => ({ const newConfigs = (data??[]).map(item => ({
alertDLL: false, //false全量 true增量 alertDLL: false, //false全量 true增量
...item, ...item,
ddlFilter: { ddlFilter,
columnCnName: true,
columnComment: true,
index: true,
indexName: true,
primaryKey: true,
primaryKeyConstraint: true,
tableAlert: true,
tableCnName: true,
tableComment: true,
tableCreate: true,
tableDrop: true,
tableSchema: true,
},
})) }))
setConfigs(newConfigs) setConfigs(newConfigs)
if ((newConfigs??[]).length > 0) { if ((newConfigs??[]).length > 0) {
...@@ -130,7 +164,7 @@ const Basic = React.forwardRef(function ({ ids }, ref) { ...@@ -130,7 +164,7 @@ const Basic = React.forwardRef(function ({ ids }, ref) {
<Row gutter={15}> <Row gutter={15}>
<Col flex='300px' style={{ height: 'calc(80vh - 30px)', overflow: 'auto' }}> <Col flex='300px' style={{ height: 'calc(80vh - 30px)', overflow: 'auto' }}>
{ data?.map((item, index) => ( { data?.map((item, index) => (
<Row gutter={10} key={index} className={index!==0?'mt-2':''}> <Row gutter={10} key={index} className={index!==0?'mt-2':''} align='middle'>
<Col flex='1' style={{ overflow: 'hidden' }}> <Col flex='1' style={{ overflow: 'hidden' }}>
<Tooltip title={item.modelEnName}> <Tooltip title={item.modelEnName}>
<Typography.Text ellipsis={true}> <Typography.Text ellipsis={true}>
...@@ -149,12 +183,17 @@ const Basic = React.forwardRef(function ({ ids }, ref) { ...@@ -149,12 +183,17 @@ const Basic = React.forwardRef(function ({ ids }, ref) {
</Col> </Col>
<Col flex='80px'>{item.dbType}</Col> <Col flex='80px'>{item.dbType}</Col>
<Col flex='none'> <Col flex='none'>
<Select defaultValue={false} size='small' <Select defaultValue={false}
style={{ width: 80 }} style={{ width: 80 }}
onChange={(val) => { onChange={(val) => {
const index = (configs??[]).findIndex(_item => item.easyDataModelerDataModelId === _item.easyDataModelerDataModelId) const index = (configs??[]).findIndex(_item => item.easyDataModelerDataModelId === _item.easyDataModelerDataModelId)
if (index !== -1) { if (index !== -1) {
const newConfig = { ...configs[index], alertDLL: val } const newConfig = { ...configs[index], alertDLL: val }
const info = val ? alertSpecialInfo : notAlertSpecialInfo
for (const item of info) {
newConfig.ddlFilter[item.key] = item.defaultValue
}
setConfigs((prev) => { setConfigs((prev) => {
const newConfigs = [...prev??[]] const newConfigs = [...prev??[]]
newConfigs.splice(index, 1, newConfig) newConfigs.splice(index, 1, newConfig)
...@@ -198,6 +237,9 @@ const DDLDetail = ({ config, setConfig }) => { ...@@ -198,6 +237,9 @@ const DDLDetail = ({ config, setConfig }) => {
const [incVersions, setIncVersions] = React.useState() const [incVersions, setIncVersions] = React.useState()
const [loadingDDL, setLoadingDDL] = React.useState(false) const [loadingDDL, setLoadingDDL] = React.useState(false)
const [ddl, setDDL] = React.useState() const [ddl, setDDL] = React.useState()
const [ddlFilterParams, setDDLFilterParams] = React.useState({
visible: false,
})
React.useEffect(() => { React.useEffect(() => {
if (config?.easyDataModelerDataModelId) { if (config?.easyDataModelerDataModelId) {
...@@ -302,6 +344,7 @@ const DDLDetail = ({ config, setConfig }) => { ...@@ -302,6 +344,7 @@ const DDLDetail = ({ config, setConfig }) => {
return ( return (
<> <>
<div className='flex' style={{ justifyContent: 'space-between' }}>
<Form layout='inline'> <Form layout='inline'>
<Form.Item label='基线版本'> <Form.Item label='基线版本'>
<Select loading={loadingVersions} value={(versions??[]).length>0?config?.leftVersionId:undefined} style={{ width: 300 }} onChange={onBasicChange} > <Select loading={loadingVersions} value={(versions??[]).length>0?config?.leftVersionId:undefined} style={{ width: 300 }} onChange={onBasicChange} >
...@@ -317,7 +360,7 @@ const DDLDetail = ({ config, setConfig }) => { ...@@ -317,7 +360,7 @@ const DDLDetail = ({ config, setConfig }) => {
</Select> </Select>
</Form.Item> </Form.Item>
{ {
config?.alertDLL && <Form.Item label='增量版本'> config?.alertDLL && <Form.Item label='增量版本' style={{ marginRight: 5 }}>
<Select value={(incVersions??[]).length>0?config?.rightVersionId:undefined} style={{ width: 300 }} disabled={!config?.leftVersionId} onChange={onIncChange}> <Select value={(incVersions??[]).length>0?config?.rightVersionId:undefined} style={{ width: 300 }} disabled={!config?.leftVersionId} onChange={onIncChange}>
{ {
(incVersions||[]).map((item, index) => ( (incVersions||[]).map((item, index) => (
...@@ -328,11 +371,134 @@ const DDLDetail = ({ config, setConfig }) => { ...@@ -328,11 +371,134 @@ const DDLDetail = ({ config, setConfig }) => {
</Form.Item> </Form.Item>
} }
</Form> </Form>
<Button icon={<SettingFilled />} onClick={() => { setDDLFilterParams({ visible: true }) }} />
</div>
<div className='mt-2'> <div className='mt-2'>
<Spin spinning={loadingDDL}> <Spin spinning={loadingDDL}>
<Input.TextArea value={ddl??''} style={{ height: 'calc(80vh - 70px)', resize: 'none' }} /> <Input.TextArea value={ddl??''} style={{ height: 'calc(80vh - 70px)', resize: 'none' }} />
</Spin> </Spin>
</div> </div>
<DDLFilter
{...ddlFilterParams}
config={config}
setConfig={setConfig}
onCancel={() => {
setDDLFilterParams({ visible: false })
}}
/>
</> </>
) )
} }
const DDLFilter = (props) => {
const { visible, onCancel, config, setConfig } = props
const [form] = Form.useForm()
React.useEffect(() => {
if (visible) {
form.setFieldsValue(config?.ddlFilter)
}
}, [config, visible])
const close = () => {
onCancel?.()
}
const save = () => {
setConfig?.({ ...config, ddlFilter: form?.getFieldsValue() })
close()
}
const footer = React.useMemo(() => {
return [
<Button key='cancel'
onClick={() => close()}
>取消</Button>,
<Button key='save' type='primary'
onClick={() => save()}
>确定</Button>
]
}, [close, save])
const onValuesChange = (changedValues, allValues) => {
if (changedValues.hasOwnProperty('primaryKeyConstraint')) {
if (changedValues['primaryKeyConstraint']) {
form?.setFieldsValue({ primaryKey: true })
}
}
if (changedValues.hasOwnProperty('primaryKey')) {
if (!changedValues['primaryKey']) {
form?.setFieldsValue({ primaryKeyConstraint: false })
}
}
if (changedValues.hasOwnProperty('indexRemark')) {
if (changedValues['indexRemark']) {
form?.setFieldsValue({ index: true })
}
}
if (changedValues.hasOwnProperty('index')) {
if (!changedValues['index']) {
form?.setFieldsValue({ indexRemark: false })
}
}
}
return (
<Modal
visible={visible}
footer={footer}
bodyStyle={{ padding: '15px 15px 0px', overflowX: 'auto', maxHeight: '80vh' }}
title=''
width={600}
closable={false}
centered destroyOnClose
onCancel={() => { close() }}
>
<Form
form={form}
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
autoComplete="off"
onValuesChange={onValuesChange}
>
{
Object.keys(ddlFilterInfo).map((key, index) => {
const item = ddlFilterInfo[key]
return (
<Form.Item
key={key}
label={`对于${key}`}
style={{ marginBottom: 15 }}
>
<Row>
{
Object.keys(item).map((_key, index) => {
let disabled = false
const info = (config?.alertDLL) ? alertSpecialInfo : notAlertSpecialInfo
const _index = info.findIndex(item => item.key === _key)
disabled = (_index !== -1)
return (
<Col span={6} key={index}>
<Form.Item name={_key}
style={{ marginBottom: 0 }}
valuePropName="checked"
>
<Checkbox disabled={disabled}>
{item[_key]}
</Checkbox>
</Form.Item>
</Col>
)
})
}
</Row>
</Form.Item>
)
})
}
</Form>
</Modal>
)
}
\ No newline at end of file
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