Commit 713389c3 by zhaochengxiang

任务可见列设置

parent c6c16cc5
...@@ -530,4 +530,12 @@ export function* getChildBySystem(payload) { ...@@ -530,4 +530,12 @@ export function* getChildBySystem(payload) {
export function* getChildByParentId(payload) { export function* getChildByParentId(payload) {
return yield call(metadataService.getChildByParentId, payload) return yield call(metadataService.getChildByParentId, payload)
}
export function* getSettingCols(payload) {
return yield call(datamodelerService.getSettingCols, payload)
}
export function* setSettingCols(payload) {
return yield call(datamodelerService.setSettingCols, payload)
} }
\ No newline at end of file
...@@ -475,4 +475,12 @@ export function getStrategyItemPropertyTypes() { ...@@ -475,4 +475,12 @@ export function getStrategyItemPropertyTypes() {
export function getCompareJobCronCycleTypes() { export function getCompareJobCronCycleTypes() {
return GetJSON("/datamodeler/easyDataModelModelCompareJob/getCronCycleTypes") return GetJSON("/datamodeler/easyDataModelModelCompareJob/getCronCycleTypes")
}
export function getSettingCols(payload) {
return GetJSON("/dataquality/setting/get", payload)
}
export function setSettingCols(payload) {
return PostJSON("/dataquality/setting/set", payload)
} }
\ No newline at end of file
import React, { useEffect } from 'react'
import { Modal, Button, Spin, Switch, Checkbox, Row, Col } from 'antd'
import { dispatch } from '../../../model'
const FC = (props) => {
const { visible, type, cols, onCancel } = props
const [loading, setLoading] = React.useState(false)
const [waiting, setWaiting] = React.useState(false)
const [checkedKeys, setCheckedKeys] = React.useState([])
useEffect(() => {
if (visible && type) {
getColConfig()
}
}, [visible])
const getColConfig = () => {
setLoading(true)
dispatch({
type: 'datamodel.getSettingCols',
payload: {
type
},
callback: data => {
setLoading(false)
setCheckedKeys(data?.settings)
},
error: () => {
setLoading(false)
}
})
}
const onCheckAllChange = (checked) => {
let newCheckedKeys = []
if (checked) {
newCheckedKeys = (cols??[]).map(item => item.title)
} else {
newCheckedKeys = (cols??[]).filter(item => item.required).map(item => item.title)
}
setCheckedKeys(newCheckedKeys);
}
const onCheckChange = (checkedValues) => {
setCheckedKeys(checkedValues)
}
const close = (refresh = false) => {
setWaiting(false)
onCancel?.(refresh)
}
const save = () => {
setWaiting(true)
dispatch({
type: 'datamodel.setSettingCols',
payload: {
params: {
type,
},
data: checkedKeys
},
callback: data => {
close(true)
},
error: () => {
setWaiting(false)
}
})
}
const footer = React.useMemo(() => {
return [
<Button key={'cancel'}
onClick={() => close()}
>取消</Button>,
<Button key={'save'} type='primary'
disabled={waiting}
onClick={() => save()}
>保存</Button>
]
}, [close, save, waiting])
return (
<Modal
title='可见列设置'
width={600}
bodyStyle={{ overflowX: 'auto', maxHeight: '80vh' }}
visible={visible}
footer={footer}
onCancel={() => { close() }}
>
<Spin spinning={loading||waiting}>
<div className='flex' style={{ justifyContent: 'flex-end' }}>
<Switch
checkedChildren='全不选'
unCheckedChildren='全选'
onChange={onCheckAllChange}
/>
</div>
<Checkbox.Group
className='mt-3'
value={checkedKeys}
style={{ width: '100%' }}
onChange={onCheckChange}>
<Row>
{
(cols??[]).map((col, index) => {
return (
<Col key={index} md={6}>
<Checkbox value={col.title} disabled={col.required}>{col.title}</Checkbox>
</Col>
)
})
}
</Row>
</Checkbox.Group>
</Spin>
</Modal>
)
}
export default FC
\ No newline at end of file
...@@ -6,9 +6,12 @@ import Table from '../../../util/Component/Table' ...@@ -6,9 +6,12 @@ import Table from '../../../util/Component/Table'
import { dispatch } from '../../../model' import { dispatch } from '../../../model'
import { generateUUID, paginate, showMessage } from '../../../util' import { generateUUID, paginate, showMessage } from '../../../util'
import UpdateTask from './update-task' import UpdateTask from './update-task'
import ColConfig from './col-config'
import '../AssetTask/index.less' import '../AssetTask/index.less'
const ColType = 'data-model-compare'
const FC = (props) => { const FC = (props) => {
const [args, setArgs] = React.useState({ const [args, setArgs] = React.useState({
state: undefined, state: undefined,
...@@ -26,10 +29,15 @@ const FC = (props) => { ...@@ -26,10 +29,15 @@ const FC = (props) => {
item: undefined, item: undefined,
type: undefined type: undefined
}) })
const [colConfigParams, setColConfigParams] = React.useState({
visible: false,
})
const [visibleColNames, setVisibleColNames] = React.useState()
const [modal, contextHolder] = Modal.useModal() const [modal, contextHolder] = Modal.useModal()
React.useEffect(() => { React.useEffect(() => {
getColConfig()
getStates() getStates()
getTasks() getTasks()
}, []) }, [])
...@@ -164,6 +172,27 @@ const FC = (props) => { ...@@ -164,6 +172,27 @@ const FC = (props) => {
}, },
] ]
const columns = React.useMemo(() => {
return [...cols].filter(item => (visibleColNames??[]).length===0 || (visibleColNames??[]).includes(item.title))
}, [cols, visibleColNames ])
const getColConfig = () => {
setLoading(true)
dispatch({
type: 'datamodel.getSettingCols',
payload: {
type: ColType
},
callback: data => {
setLoading(false)
setVisibleColNames(data?.settings)
},
error: () => {
setLoading(false)
}
})
}
const getStates = () => { const getStates = () => {
setLoadingStates(true) setLoadingStates(true)
dispatch({ dispatch({
...@@ -223,7 +252,9 @@ const FC = (props) => { ...@@ -223,7 +252,9 @@ const FC = (props) => {
} }
const onVisbleColConfigClick = () => { const onVisbleColConfigClick = () => {
setColConfigParams({
visible: true,
})
} }
const onRightMenuItemClick = (key, record) => { const onRightMenuItemClick = (key, record) => {
...@@ -312,7 +343,7 @@ const FC = (props) => { ...@@ -312,7 +343,7 @@ const FC = (props) => {
extraColWidth={32} extraColWidth={32}
loading={loading} loading={loading}
maxHeight='calc(100vh - 285px - 46px)' maxHeight='calc(100vh - 285px - 46px)'
columns={cols??[]} columns={columns??[]}
dataSource={tableData??[]} dataSource={tableData??[]}
rowSelection={{ rowSelection={{
selectedRowKeys: (selectedRows??[]).map(item => item.id), selectedRowKeys: (selectedRows??[]).map(item => item.id),
...@@ -344,6 +375,18 @@ const FC = (props) => { ...@@ -344,6 +375,18 @@ const FC = (props) => {
refresh && getTasks() refresh && getTasks()
}} }}
/> />
<ColConfig
{...colConfigParams}
type={ColType}
cols={cols}
onCancel={(refresh) => {
setColConfigParams({
visible: false,
})
refresh && getColConfig()
}}
/>
{contextHolder} {contextHolder}
</div> </div>
) )
......
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