Commit c500361d by zhaochengxiang

保存和提交流程

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