Commit a669fc26 by zhaochengxiang

评估方案

parent b0f5c229
...@@ -301,8 +301,8 @@ export function* saveEvaluation(payload) { ...@@ -301,8 +301,8 @@ export function* saveEvaluation(payload) {
return yield call(service.saveEvaluation, payload) return yield call(service.saveEvaluation, payload)
} }
export function* runEvaluation(payload) { export function* runEvaluations(payload) {
return yield call(service.runEvaluation, payload) return yield call(service.runEvaluations, payload)
} }
export function* deleteEvaluations(payload) { export function* deleteEvaluations(payload) {
......
...@@ -308,7 +308,7 @@ export function saveEvaluation(payload) { ...@@ -308,7 +308,7 @@ export function saveEvaluation(payload) {
return PostJSON('/dataassetmanager/evaluationApi/saveProject', payload) return PostJSON('/dataassetmanager/evaluationApi/saveProject', payload)
} }
export function runEvaluation(payload) { export function runEvaluations(payload) {
return PostJSON('/dataassetmanager/evaluationApi/run', payload) return PostJSON('/dataassetmanager/evaluationApi/run', payload)
} }
......
...@@ -5,7 +5,7 @@ import produce from "immer" ...@@ -5,7 +5,7 @@ import produce from "immer"
import { dispatch } from '../../../model' import { dispatch } from '../../../model'
const FC = (props) => { const FC = (props) => {
const { visible, onCancel } = props const { visible, item, action, onCancel } = props
const [waiting, setWaiting] = React.useState(false) const [waiting, setWaiting] = React.useState(false)
const [loading, setLoading] = React.useState(false) const [loading, setLoading] = React.useState(false)
const [elements, setElements] = React.useState() const [elements, setElements] = React.useState()
...@@ -43,7 +43,7 @@ const FC = (props) => { ...@@ -43,7 +43,7 @@ const FC = (props) => {
dispatch({ dispatch({
type: 'assetmanage.saveEvaluation', type: 'assetmanage.saveEvaluation',
payload: { payload: {
data: row data: (action==='add')?row:{...item, ...row}
}, },
callback: data => { callback: data => {
close(true) close(true)
...@@ -80,7 +80,7 @@ const FC = (props) => { ...@@ -80,7 +80,7 @@ const FC = (props) => {
onCancel={() => { close() }} onCancel={() => { close() }}
> >
<Spin spinning={loading || waiting}> <Spin spinning={loading || waiting}>
<Basic ref={basicRef} elements={elements} /> <Basic ref={basicRef} item={item} elements={elements} />
</Spin> </Spin>
</Modal> </Modal>
) )
...@@ -88,15 +88,21 @@ const FC = (props) => { ...@@ -88,15 +88,21 @@ const FC = (props) => {
export default FC export default FC
const Basic = React.forwardRef(function ({ elements }, ref) { const Basic = React.forwardRef(function ({ item, elements }, ref) {
const [form] = Form.useForm() const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({ React.useImperativeHandle(ref, () => ({
validate: async () => { validate: async () => {
return await form.validateFields() return await form?.validateFields()
}, },
}), [form]) }), [form])
React.useEffect(() => {
if (item) {
form?.setFieldsValue(item)
}
}, [item])
return ( return (
<Form <Form
form={form} form={form}
......
...@@ -28,7 +28,9 @@ const FC = (props) => { ...@@ -28,7 +28,9 @@ const FC = (props) => {
const $keyword = React.useMemo(() => new Subject(), []) const $keyword = React.useMemo(() => new Subject(), [])
const [keyword, setKeyword] = React.useState() const [keyword, setKeyword] = React.useState()
const [addEvaluateParams, setAddEvaluateParams] = React.useState({ const [addEvaluateParams, setAddEvaluateParams] = React.useState({
visible: false visible: false,
item: undefined,
action: undefined
}) })
const [selectedRows, setSelectedRows] = React.useState([]) const [selectedRows, setSelectedRows] = React.useState([])
...@@ -126,6 +128,20 @@ const FC = (props) => { ...@@ -126,6 +128,20 @@ const FC = (props) => {
ellipsis: true, ellipsis: true,
render: (_, record) => record.createTimestamp ? new Date(record.createTimestamp).toLocaleString() : '' render: (_, record) => record.createTimestamp ? new Date(record.createTimestamp).toLocaleString() : ''
}, },
{
title: '操作',
key: 'action',
width: 120,
render: (_,record) => (
<a onClick={() => {
setAddEvaluateParams({
visible: true,
item: record,
action: 'edit',
})
}}>编辑</a>
)
}
] ]
const getEvaluations = () => { const getEvaluations = () => {
...@@ -163,7 +179,9 @@ const FC = (props) => { ...@@ -163,7 +179,9 @@ const FC = (props) => {
<Space> <Space>
<Button onClick={() => { <Button onClick={() => {
setAddEvaluateParams({ setAddEvaluateParams({
visible: true visible: true,
item: undefined,
action: 'add',
}) })
}}>新增</Button> }}>新增</Button>
<Tooltip title={((selectedRows??[]).length===0)?'请先选择评估方案':''}> <Tooltip title={((selectedRows??[]).length===0)?'请先选择评估方案':''}>
...@@ -184,7 +202,7 @@ const FC = (props) => { ...@@ -184,7 +202,7 @@ const FC = (props) => {
} }
}, },
callback: data => { callback: data => {
showMessage('warn', '运行成功') showMessage('success', '运行成功')
}, },
}) })
} }
...@@ -209,7 +227,7 @@ const FC = (props) => { ...@@ -209,7 +227,7 @@ const FC = (props) => {
} }
}, },
callback: data => { callback: data => {
showMessage('warn', '删除成功') showMessage('success', '删除成功')
getEvaluations() getEvaluations()
}, },
}) })
...@@ -220,7 +238,7 @@ const FC = (props) => { ...@@ -220,7 +238,7 @@ const FC = (props) => {
</Space> </Space>
<Space> <Space>
<Input size="middle" <Input size="middle"
placeholder="任务编号/分配人" placeholder="方案名称"
value={keyword} value={keyword}
bordered={true} allowClear bordered={true} allowClear
onChange={(e) => { onChange={(e) => {
...@@ -271,7 +289,9 @@ const FC = (props) => { ...@@ -271,7 +289,9 @@ const FC = (props) => {
{...addEvaluateParams} {...addEvaluateParams}
onCancel={(refresh) => { onCancel={(refresh) => {
setAddEvaluateParams({ setAddEvaluateParams({
visible: false visible: false,
item: undefined,
action: undefined
}) })
refresh && getEvaluations() refresh && getEvaluations()
......
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