Commit c500361d by zhaochengxiang

保存和提交流程

parent 43772b49
...@@ -460,7 +460,7 @@ const DesignUsersItem = ({ value, onChange }) => { ...@@ -460,7 +460,7 @@ const DesignUsersItem = ({ value, onChange }) => {
) )
} }
const AttachesItem = ({ value, onChange, readOnly }) => { export const AttachesItem = ({ value, onChange, readOnly }) => {
return ( return (
<Row> <Row>
{ {
......
...@@ -3,15 +3,18 @@ import { Space, Button, Descriptions, Form, Input, Tooltip, Typography, Select, ...@@ -3,15 +3,18 @@ import { Space, Button, Descriptions, Form, Input, Tooltip, Typography, Select,
import produce from "immer" import produce from "immer"
import Table from '../../../util/Component/Table' import Table from '../../../util/Component/Table'
import { isSzseEnv, getQueryParam } from "../../../util" import { isSzseEnv, getQueryParam, showMessage } from "../../../util"
import { dispatch } from '../../../model'; import { dispatch } from '../../../model';
import { AttachesItem } from "../Model/Component/start-flow"
const FC = (props) => { const FC = (props) => {
const [loading, setLoading] = React.useState(false) const [loading, setLoading] = React.useState(false)
const [waiting, setWaiting] = React.useState(false)
const [data, setData] = React.useState() const [data, setData] = React.useState()
const [form] = Form.useForm() const [form] = Form.useForm()
const id = getQueryParam('id', props.location?.search) const id = getQueryParam('id', props.location?.search)
const type = getQueryParam('type', props.location?.search)
const listRef = React.useRef() const listRef = React.useRef()
...@@ -45,24 +48,66 @@ const FC = (props) => { ...@@ -45,24 +48,66 @@ const FC = (props) => {
} }
const onSaveClick = () => { const onSaveClick = () => {
try {
const tableData = listRef.current?.tableData
console.log('table data', tableData)
setWaiting(true)
dispatch({
type: 'datamodel.updatePhysicalModelApproval',
payload: {
params: {
physicalModelApprovalId: id,
},
data: tableData
},
callback: (data) => {
setWaiting(false)
showMessage('success', '保存成功')
},
error: () => {
setWaiting(false)
}
})
} catch (e) {
} }
}
const onSubmitClick = async () => { const onSubmitClick = async () => {
try { try {
const rows = await form.validateFields()
await listRef.current?.validate() await listRef.current?.validate()
const tableData = listRef.current?.tableData const tableData = listRef.current?.tableData
console.log('table data', tableData) console.log('table data', tableData)
setWaiting(true)
dispatch({
type: 'datamodel.commitPhysicalModelApproval',
payload: {
params: {
physicalModelApprovalId: id,
...rows,
},
data: tableData
},
callback: (data) => {
setWaiting(false)
showMessage('success', '提交成功')
},
error: () => {
setWaiting(false)
}
})
} catch (e) { } catch (e) {
} }
} }
return ( return (
<Spin spinning={loading}> <Spin spinning={loading||waiting}>
<div className='p-5' style={{ height: '100%' }}> <div className='p-5' style={{ height: '100%' }}>
<div className='flex' style={{ justifyContent: 'space-between' }}> <div className='flex' style={{ justifyContent: 'end' }}>
<Space> <Space>
<Button onClick={onCloseClick}>关闭</Button> <Button onClick={onCloseClick}>关闭</Button>
<Button onClick={onSaveClick}>保存</Button> <Button onClick={onSaveClick}>保存</Button>
...@@ -74,12 +119,12 @@ const FC = (props) => { ...@@ -74,12 +119,12 @@ const FC = (props) => {
<h3>模型评审流程</h3> <h3>模型评审流程</h3>
</div> </div>
<Descriptions bordered size='small' column={2}> <Descriptions bordered size='small' column={2}>
<Descriptions.Item label="流程名称"></Descriptions.Item> <Descriptions.Item label="流程名称">{data?.creator?.userName?`${data?.creator?.userName}发起的物理模型评审流程`:''}</Descriptions.Item>
<Descriptions.Item label="送审人"></Descriptions.Item> <Descriptions.Item label="送审人">{data?.creator?.userName}</Descriptions.Item>
<Descriptions.Item label="当前环节"></Descriptions.Item> <Descriptions.Item label="当前环节">{type==='design'?'设计评审':'规范评审'}</Descriptions.Item>
<Descriptions.Item label="送审时间"></Descriptions.Item> <Descriptions.Item label="送审时间">{data?.createdTs?new Date(data?.createdTs).toLocaleString():''}</Descriptions.Item>
<Descriptions.Item label="送审说明"></Descriptions.Item> <Descriptions.Item label="送审说明">{data?.sendReviewExplain}</Descriptions.Item>
<Descriptions.Item label="附件"></Descriptions.Item> <Descriptions.Item label="附件">{<AttachesItem readOnly value={data?.fileList} />}</Descriptions.Item>
</Descriptions> </Descriptions>
</div> </div>
<div className='my-5'> <div className='my-5'>
...@@ -89,7 +134,7 @@ const FC = (props) => { ...@@ -89,7 +134,7 @@ const FC = (props) => {
> >
<Form.Item <Form.Item
label="流程意见" label="流程意见"
name="suggest" name="approvalComment"
rules={[{ required: true, message: '请填写流程意见!' }]} rules={[{ required: true, message: '请填写流程意见!' }]}
style={{ marginBottom: 0 }} style={{ marginBottom: 0 }}
> >
...@@ -101,7 +146,7 @@ const FC = (props) => { ...@@ -101,7 +146,7 @@ const FC = (props) => {
</Form.Item> </Form.Item>
</Form> </Form>
</div> </div>
<List ref={listRef} /> <List ref={listRef} type={type} data={data} />
</div> </div>
</Spin> </Spin>
) )
...@@ -109,25 +154,19 @@ const FC = (props) => { ...@@ -109,25 +154,19 @@ const FC = (props) => {
export default FC export default FC
const List = React.forwardRef(function ({}, ref) { const List = React.forwardRef(function ({type, data}, ref) {
const [tableData, setTableData] = React.useState() const [tableData, setTableData] = React.useState()
const [form] = Form.useForm() const [form] = Form.useForm()
//zcx mock
React.useEffect(() => { React.useEffect(() => {
setTableData(Array.from({ length: 10 }).map((_, i) => ({ setTableData(data?.modelInfoList)
name: `模型${i}`, }, [data])
cnName: `模型${i}`,
remark: '很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长的',
id: i,
})))
}, [])
React.useImperativeHandle(ref, () => ({ React.useImperativeHandle(ref, () => ({
validate: async () => { validate: async () => {
return await form.validateFields() return await form.validateFields()
}, },
tableData, tableData
}), [tableData, form]) }), [tableData, form])
const cols = [ const cols = [
...@@ -192,7 +231,7 @@ const List = React.forwardRef(function ({}, ref) { ...@@ -192,7 +231,7 @@ const List = React.forwardRef(function ({}, ref) {
}, },
{ {
title: '送审备注', title: '送审备注',
dataIndex: 'reviewRemark', dataIndex: 'sendReviewComment',
render: (text, record) => ( render: (text, record) => (
<Tooltip title={text}> <Tooltip title={text}>
<Typography.Paragraph ellipsis={{ <Typography.Paragraph ellipsis={{
...@@ -202,6 +241,11 @@ const List = React.forwardRef(function ({}, ref) { ...@@ -202,6 +241,11 @@ const List = React.forwardRef(function ({}, ref) {
) )
}, },
{ {
title: '变更类型',
dataIndex: 'addModel',
render: (text, record) => record.addModel ? '新增' : '修改',
},
{
title: <span> title: <span>
<span style={{ <span style={{
marginRight: 4, marginRight: 4,
...@@ -209,11 +253,13 @@ const List = React.forwardRef(function ({}, ref) { ...@@ -209,11 +253,13 @@ const List = React.forwardRef(function ({}, ref) {
}}>*</span> }}>*</span>
评审结论 评审结论
</span>, </span>,
dataIndex: 'result', dataIndex: (type === 'design') ? 'designReviewPass' : 'standardReviewPass',
width: 120, width: 120,
className: 'highlight', className: 'highlight',
render: (_, __, index) => ( render: (text, __, index) => {
<Form.Item name={`result${index}`} form?.setFieldsValue({ [`pass${index}`]: text })
return (
<Form.Item name={`pass${index}`}
rules={[{ required: true, message: '请选择评审结论!' }]} rules={[{ required: true, message: '请选择评审结论!' }]}
style={{ marginBottom: 0 }} style={{ marginBottom: 0 }}
> >
...@@ -226,7 +272,11 @@ const List = React.forwardRef(function ({}, ref) { ...@@ -226,7 +272,11 @@ const List = React.forwardRef(function ({}, ref) {
onChange={(val) => { onChange={(val) => {
setTableData(prev => { setTableData(prev => {
return produce(prev, (draft) => { return produce(prev, (draft) => {
draft[index].result = val if (type === 'design') {
draft[index].designReviewPass = val
} else {
draft[index].standardReviewPass = val
}
}) })
}) })
}} }}
...@@ -236,19 +286,25 @@ const List = React.forwardRef(function ({}, ref) { ...@@ -236,19 +286,25 @@ const List = React.forwardRef(function ({}, ref) {
</Select> </Select>
</Form.Item> </Form.Item>
) )
}
}, },
{ {
title: '评审意见', title: '评审意见',
dataIndex: 'suggest', dataIndex: (type === 'design') ? 'designReviewComment' : 'standardReviewComment',
className: 'highlight', className: 'highlight',
render: (_, __, index) => ( render: (text, __, index) => (
<Input.TextArea rows={1} <Input.TextArea rows={1}
value={text}
autoSize={{ minRows: 1, maxRows: 3 }} autoSize={{ minRows: 1, maxRows: 3 }}
allowClear allowClear
onChange={(e) => { onChange={(e) => {
setTableData(prev => { setTableData(prev => {
return produce(prev, (draft) => { return produce(prev, (draft) => {
draft[index].suggest = e.target.value if (type === 'design') {
draft[index].designReviewComment = e.target.value
} else {
draft[index].standardReviewComment = e.target.value
}
}) })
}) })
}} }}
......
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