Commit 54b89283 by zhaochengxiang

评论

parent 59980834
...@@ -450,4 +450,24 @@ export function* getRuleAlertTypes() { ...@@ -450,4 +450,24 @@ export function* getRuleAlertTypes() {
export function* getRuleStatus() { export function* getRuleStatus() {
return yield call(datamodelerService.getRuleStatus) return yield call(datamodelerService.getRuleStatus)
}
export function* addComment(payload) {
return yield call(datamodelerService.addComment, payload)
}
export function* deleteComment(payload) {
return yield call(datamodelerService.deleteComment, payload)
}
export function* getComments(payload) {
return yield call(datamodelerService.getComments, payload)
}
export function* uploadCommentFile(payload) {
return yield call(datamodelerService.uploadCommentFile, payload)
}
export function* deleteCommentFile(payload) {
return yield call(datamodelerService.deleteCommentFile, payload)
} }
\ No newline at end of file
...@@ -402,4 +402,24 @@ export function getRuleAlertTypes() { ...@@ -402,4 +402,24 @@ export function getRuleAlertTypes() {
export function getRuleStatus() { export function getRuleStatus() {
return GetJSON("/shandatamodeler/easyDataModelerRule/getRuleStatus") return GetJSON("/shandatamodeler/easyDataModelerRule/getRuleStatus")
}
export function addComment(payload) {
return PostJSON("/datamodelercomment/comment/add", payload)
}
export function deleteComment(payload) {
return Delete("/datamodelercomment/comment/del", payload)
}
export function getComments(payload) {
return GetJSON("/datamodelercomment/comment/list", payload)
}
export function uploadCommentFile(payload) {
return PostFile("/datamodelercomment/file/upload", payload)
}
export function deleteCommentFile(payload) {
return Delete("/datamodelercomment/file/del", payload)
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import { ImportActionTable } from './ImportActionTable'; ...@@ -7,6 +7,7 @@ import { ImportActionTable } from './ImportActionTable';
import ImportActionIndex from './ImportActionIndex'; import ImportActionIndex from './ImportActionIndex';
import ImportActionManage from './ImportActionManage'; import ImportActionManage from './ImportActionManage';
import ImportActionRelation from './ImportActionRelation'; import ImportActionRelation from './ImportActionRelation';
import ImportActionComment from './ImportActionComment';
import { getInternalCurrentAnchor, getQueryParam } from '../../../../util'; import { getInternalCurrentAnchor, getQueryParam } from '../../../../util';
import { Action } from '../../../../util/constant'; import { Action } from '../../../../util/constant';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
...@@ -136,6 +137,7 @@ const ImportAction = React.forwardRef((props, ref) => { ...@@ -136,6 +137,7 @@ const ImportAction = React.forwardRef((props, ref) => {
'model-import-action-index', 'model-import-action-index',
'model-import-action-manage', 'model-import-action-manage',
'model-import-action-relation', 'model-import-action-relation',
'model-import-action-comment',
], ],
20, 20,
5, 5,
...@@ -594,6 +596,7 @@ const ImportAction = React.forwardRef((props, ref) => { ...@@ -594,6 +596,7 @@ const ImportAction = React.forwardRef((props, ref) => {
<Tabs.TabPane tab='数据表索引' key="model-import-action-index" /> <Tabs.TabPane tab='数据表索引' key="model-import-action-index" />
<Tabs.TabPane tab='管理信息' key="model-import-action-manage" /> <Tabs.TabPane tab='管理信息' key="model-import-action-manage" />
<Tabs.TabPane tab='关联对象' key="model-import-action-relation" /> <Tabs.TabPane tab='关联对象' key="model-import-action-relation" />
<Tabs.TabPane tab='模型评论' key="model-import-action-comment" />
</Tabs> </Tabs>
<div ref={setContainer} style={{ height: action==='edit-inherite-modal'?'60vh':'calc(100vh - 44px - 64px - 66px)', overflow: 'auto', padding: '20px 20px 0' }}> <div ref={setContainer} style={{ height: action==='edit-inherite-modal'?'60vh':'calc(100vh - 44px - 64px - 66px)', overflow: 'auto', padding: '20px 20px 0' }}>
<ImportActionHeader <ImportActionHeader
...@@ -639,6 +642,9 @@ const ImportAction = React.forwardRef((props, ref) => { ...@@ -639,6 +642,9 @@ const ImportAction = React.forwardRef((props, ref) => {
<ImportActionRelation <ImportActionRelation
modelerData={modelerData} action={action} modelerData={modelerData} action={action}
/> />
<ImportActionComment
modelerData={modelerData}
/>
</div> </div>
</div> </div>
} }
......
import React from "react"
import { Button, Space, Input, Divider, Upload, Row, Col, Tooltip } from "antd"
import { DownOutlined, UpOutlined, PlusOutlined } from '@ant-design/icons'
import { showMessage } from "../../../../util"
import { dispatch } from '../../../../model';
const FC = (props) => {
const { modelerData } = props
const [isCollapse, setCollapse] = React.useState(true)
const [uploading, setUploading] = React.useState(false)
const [fileList, setFileList] = React.useState()
const [comment, setComment] = React.useState()
const [comments, setComments] = React.useState()
React.useEffect(() => {
if (modelerData?.id) {
getComments()
}
}, [modelerData])
const getComments = () => {
dispatch({
type: 'datamodel.getComments',
payload: {
modelId: modelerData?.id
},
callback: data => {
setComments(data)
}
})
}
const onAddCommentClick = () => {
if (uploading) {
showMessage('warn', '文件上传中,请稍后')
return
}
dispatch({
type: 'datamodel.addComment',
payload: {
data: {
fileList,
modelId: modelerData?.id,
comment
}
},
callback: data => {
showMessage('success', '发表评论成功')
setFileList([])
setComment()
}
})
}
const uploadProps = {
beforeUpload: file => {
const isLt5M = file.size / 1024 / 1024 < 5
if (!isLt5M) {
showMessage('error', '上传文件必须小于5M')
return false
}
setUploading(true)
dispatch({
type: 'datamodel.uploadCommentFile',
payload: {
fileList: [file]
},
callback: data => {
setUploading(false)
if (data) {
setFileList(prevFileList => {
return [...prevFileList??[], data]
})
}
},
error: () => {
setUploading(false)
}
})
return false
},
fileList: []
}
return (
<div>
<div className='model-import-action-comment mb-3'>
<Space>
<h3 style={{ marginBottom: 0 }}>评论</h3>
{
isCollapse ? <Button type='primary' size='small' onClick={() => {
setCollapse(!isCollapse)
}}>展开<DownOutlined /></Button> : <Button type='primary' size='small' onClick={() => {
setCollapse(!isCollapse)
}}>收起<UpOutlined /></Button>
}
</Space>
</div>
{
!isCollapse && <React.Fragment>
<div style={{ border: '1px solid #d9d9d9', borderRadius: 4 }}>
<Input.TextArea bordered={false} rows={4} placeholder='请输入您的评论' onChange={(e) => { setComment(e.target.value) }} />
<Divider style={{ margin: 0 }}/>
<div className='flex' style={{ padding: '11px', justifyContent: 'space-between' }}>
<Space align='start'>
<Upload {...uploadProps }>
<Button size='small' icon={<PlusOutlined />} />
</Upload>
<AttachesItem value={fileList} onChange={(val) => { setFileList(val) }} />
</Space>
<Tooltip title={comment?'':'请先输入您的评论'}>
<Button disabled={!comment} size='small' type='primary' onClick={onAddCommentClick}>发表评论</Button>
</Tooltip>
</div>
</div>
</React.Fragment>
}
</div>
)
}
export default FC
const AttachesItem = ({ value, onChange, readOnly }) => {
return (
<React.Fragment>
{
value?.map((item, index) => {
return (
<div key={index} style={{ marginTop: (index!==0)?5:0 }}>
<Space>
<a onClick={() => {
window.open(`/api/datamodelercomment/file/download?id=${item.id}`)
}}>{item.fileName}
</a>
{
!readOnly && <Button
size='small'
type='danger'
onClick={() => {
dispatch({
type: 'datamodel.deleteCommentFile',
payload: {
id: item?.id
},
callback: () => {
const newValue = [...value]
newValue.splice(index, 1)
onChange?.(newValue)
}
})
}}
>删除</Button>
}
</Space>
</div>
)
})
}
</React.Fragment>
)
}
\ 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