Commit e630ae77 by zhaochengxiang

模型送审

parent 764d3f53
......@@ -622,4 +622,24 @@ export function* deleteBranch(payload) {
export function* getCooperationUsers() {
return yield call(datamodelerService.getCooperationUsers)
}
export function* addPhysicalModelApproval(payload) {
return yield call(datamodelerService.addPhysicalModelApproval, payload)
}
export function* updatePhysicalModelApproval(payload) {
return yield call(datamodelerService.updatePhysicalModelApproval, payload)
}
export function* commitPhysicalModelApproval(payload) {
return yield call(datamodelerService.commitPhysicalModelApproval, payload)
}
export function* approvalUploadFile(payload) {
return yield call(datamodelerService.approvalUploadFile, payload)
}
export function* approvalDeleteFile(payload) {
return yield call(datamodelerService.approvalDeleteFile, payload)
}
\ No newline at end of file
......@@ -569,4 +569,25 @@ export function deleteBranch(payload) {
export function getCooperationUsers() {
return GetJSON("/datamodeler/easyDataModelerCooperation/users")
}
/*approval*/
export function addPhysicalModelApproval(payload) {
return PostJSON("/datamodeler/easyDataModelerApproval/addPhysicalModelApproval", payload)
}
export function updatePhysicalModelApproval(payload) {
return PostJSON("/datamodeler/easyDataModelerApproval/updatePhysicalModelApproval", payload)
}
export function commitPhysicalModelApproval(payload) {
return PostJSON("/datamodeler/easyDataModelerApproval/commitPhysicalModelApproval", payload)
}
export function approvalUploadFile(payload) {
return PostFile("/datamodeler/file/upload", payload)
}
export function approvalDeleteFile(payload) {
return Delete("/datamodeler/file/del", payload)
}
\ No newline at end of file
import React from 'react'
import { Modal, Button, Spin, Form, Input, Select, Space, Radio, Row, Col, Upload, Typography, Tooltip } from 'antd'
import { UploadOutlined } from '@ant-design/icons'
import { useDebounceEffect } from 'ahooks'
import { isSzseEnv, showMessage } from '../../../../util'
import Table from '../../../../util/Component/Table'
import produce from 'immer'
import { Action, CatalogId, Editable, Holder, ModelerId, PermitCheckOut, ReadOnly, StateId } from '../../../../util/constant'
import { dispatch } from '../../../../model'
const FC = (props) => {
const { visible, items, onCancel } = props
......@@ -24,8 +26,29 @@ const FC = (props) => {
const basicRows = await basicRef.current?.validate()
const tableData = listRef.current?.tableData
if (basicRef.current?.uploading) {
showMessage('warn', '文件上传中,请稍后')
return
}
console.log('basic rows', basicRows)
console.log('table data', tableData)
setWaiting(true)
dispatch({
type: 'datamodel.addPhysicalModelApproval',
payload: {
data: {
...basicRows,
modelInfoList: tableData,
},
},
callback: (data) => {
close(data)
},
error: () => {
setWaiting(false)
}
})
} catch (e) {
}
......@@ -64,9 +87,7 @@ const FC = (props) => {
export default FC
const Basic = React.forwardRef(function ({}, ref) {
const [loadingDesignReviewers, setLoadingDesignReviewers] = React.useState(false)
const [designReviewers, setDesignReviewers] = React.useState()
const [fileList, setFileList] = React.useState()
const [uploading, setUploading] = React.useState(false)
const [form] = Form.useForm()
......@@ -74,57 +95,49 @@ const Basic = React.forwardRef(function ({}, ref) {
validate: async () => {
const rows = await form.validateFields()
rows.requiresStandardApproval = rows.standard?.requiresStandardApproval
rows.standardApprovalUserList = rows.standard?.standardApprovalUserList
return rows
},
}), [form])
React.useEffect(() => {
getDesignReviewers()
}, [])
uploading,
}), [form, uploading])
const marginBottom = React.useMemo(() => {
return 15
}, [])
const getDesignReviewers = () => {
setLoadingDesignReviewers(true)
setTimeout(() => {
setLoadingDesignReviewers(false)
setDesignReviewers(Array.from({ length: 10 }).map((_, i) => ({
name: `user${i}`,
id: i,
})))
}, 3000)
}
const onValuesChange = (changedValues, allValues) => {
}
const uploadProps = {
onRemove: file => {
const index = (fileList??[]).indexOf(file)
if (index !== -1) {
const newFileList = (fileList??[]).slice()
newFileList.splice(index, 1)
setFileList(newFileList)
}
},
beforeUpload: file => {
const isLt5M = file.size / 1024 / 1024 < 5
if (!isLt5M) {
showMessage('error', '上传文件必须小于5M')
setFileList([])
return false
}
setFileList(prev => {
return [...prev??[], file]
setUploading(true)
dispatch({
type: 'datamodel.approvalUploadFile',
payload: {
fileList: [file],
},
callback: (data) => {
setUploading(false)
const prev = form?.getFieldValue('fileList')
const newFileList = [...prev??[], data]
form?.setFieldsValue({ fileList: newFileList })
},
error: () => {
setUploading(false)
}
})
return false
},
fileList: fileList || [],
fileList: [],
}
return (
......@@ -137,7 +150,7 @@ const Basic = React.forwardRef(function ({}, ref) {
>
<Form.Item
label='送审说明'
name="approvalName"
name="sendReviewExplain"
style={{ marginBottom }}
rules={[{ required: true, message: '请填写送审说明!' }]}
>
......@@ -146,33 +159,26 @@ const Basic = React.forwardRef(function ({}, ref) {
<Form.Item
label='设计评审人员'
name="designReviewerers"
name="designApprovalUserList"
style={{ marginBottom }}
rules={[{ required: true, message: '请选择设计评审人员!' }]}
>
<Select
placeholder='请选择设计评审人员'
loading={loadingDesignReviewers}
allowClear
mode='multiple'
>
{designReviewers?.map(item => <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>)}
</Select>
<DesignUsersItem />
</Form.Item>
<Form.Item
label='规范评审'
name='ruleReview'
name='standard'
wrapperCol={{ span: 12 }}
style={{ marginBottom }}
rules={[{
required: true,
validator: (_, value) => {
if (value?.ruleReviewSelected === null || value?.ruleReviewSelected === undefined) {
if (value?.requiresStandardApproval === null || value?.requiresStandardApproval === undefined) {
return Promise.reject(new Error('请选择是否规范评审!'))
}
if (value?.ruleReviewSelected && (value?.ruleReviewers??[]).length === 0) {
if (value?.requiresStandardApproval && (value?.standardApprovalUserList??[]).length === 0) {
return Promise.reject(new Error('请选择规范评审人员!'))
}
......@@ -191,28 +197,57 @@ const Basic = React.forwardRef(function ({}, ref) {
<Button icon={<UploadOutlined />}>点击上传</Button>
</Upload>
</Form.Item>
<Form.Item
label='已上传附件'
name='fileList'
>
<AttachesItem />
</Form.Item>
</Form>
)
})
const RuleReviewItem = ({ value = {}, onChange }) => {
const [ruleReviewSelected, setRuleReviewSelected] = React.useState()
const [loadingRuleReviewers, setLoadingRuleReviewers] = React.useState(false)
const [ruleReviewers, setRuleReviewers] = React.useState()
const [loading, setLoading] = React.useState(false)
const [users, setUsers] = React.useState()
const [searchValue, setSearchValue] = React.useState()
const [options, setOptions] = React.useState()
useDebounceEffect(() => {
setOptions(
(users??[])
.filter(item => !searchValue || (item.name??'').indexOf(searchValue)!==-1)
.map(item => ({
label: item.name,
value: item.id,
}))
)
}, [searchValue, users], { wait: 300 })
React.useEffect(() => {
getRuleReviewers()
getUsers()
}, [])
const getRuleReviewers = () => {
setLoadingRuleReviewers(true)
setTimeout(() => {
setLoadingRuleReviewers(false)
setRuleReviewers(Array.from({ length: 10 }).map((_, i) => ({
name: `user${i}`,
id: i,
})))
}, 3000)
const getUsers = () => {
setLoading(true)
dispatch({
type: 'datamodel.getCooperationUsers',
callback: data => {
setLoading(false)
//id int转string
const newData = produce(data??[], (draft) => {
draft.forEach(item => {
item.id = `${item.id}`
})
})
setUsers(newData)
},
error: () => {
setLoading(false)
}
})
}
const triggerChange = (changedValue) => {
......@@ -226,25 +261,32 @@ const RuleReviewItem = ({ value = {}, onChange }) => {
<Row align='middle'>
<Radio.Group onChange={(e) => {
setRuleReviewSelected(e.target.value)
triggerChange({ ruleReviewSelected: e.target.value })
triggerChange({ requiresStandardApproval: e.target.value })
}}>
<Radio value={true}></Radio>
<Radio value={false}></Radio>
</Radio.Group>
{
ruleReviewSelected && <Col span={16}>
<Select
placeholder='请选择规范评审人员'
loading={loadingRuleReviewers}
allowClear
mode='multiple'
style={{ width: '100%' }}
<Select showSearch loading={loading} allowClear
placeholder='请选择规范评审人员'
searchValue={searchValue}
onSearch={(val) => {
setSearchValue(val)
}}
onClear={() => {
setSearchValue()
}}
filterOption={false}
options={options}
onChange={(val) => {
triggerChange({ ruleReviewers: val })
triggerChange({
standardApprovalUserList: (users??[])
.filter(item => val===item.id)
.map(item => ({ userId: item.id, userName: item.name }))
})
}}
>
{ruleReviewers?.map(item => <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>)}
</Select>
/>
</Col>
}
</Row>
......@@ -258,7 +300,10 @@ const List = React.forwardRef(function ({ items }, ref) {
tableData: (tableData??[]).map(item => ({
id: item.id,
name: item.name,
cnName: item.cnName,
remark: item.remark,
path: item.path,
sendReviewComment: item.sendReviewComment,
})),
}), [tableData])
......@@ -348,4 +393,113 @@ const List = React.forwardRef(function ({ items }, ref) {
pagination={false}
/>
)
})
\ No newline at end of file
})
const DesignUsersItem = ({ value, onChange }) => {
const [loading, setLoading] = React.useState(false)
const [users, setUsers] = React.useState()
const [searchValue, setSearchValue] = React.useState()
const [options, setOptions] = React.useState()
useDebounceEffect(() => {
setOptions(
(users??[])
.filter(item => !searchValue || (item.name??'').indexOf(searchValue)!==-1)
.map(item => ({
label: item.name,
value: item.id,
}))
)
}, [searchValue, users], { wait: 300 })
React.useEffect(() => {
getUsers()
}, [])
const getUsers = () => {
setLoading(true)
dispatch({
type: 'datamodel.getCooperationUsers',
callback: data => {
setLoading(false)
//id int转string
const newData = produce(data??[], (draft) => {
draft.forEach(item => {
item.id = `${item.id}`
})
})
setUsers(newData)
},
error: () => {
setLoading(false)
}
})
}
return (
<Select loading={loading} mode='multiple' allowClear
placeholder='请选择设计评审人员'
value={value?.map(item => item.userId)}
searchValue={searchValue}
onSearch={(val) => {
setSearchValue(val)
}}
onClear={() => {
setSearchValue()
}}
filterOption={false}
options={options}
onChange={(val) => {
onChange?.(
(users??[])
.filter(item => (val??[]).indexOf(item.id) !== -1)
.map(item => ({ userId: item.id, userName: item.name }))
)
}}
/>
)
}
const AttachesItem = ({ value, onChange, readOnly }) => {
return (
<Row>
{
value?.map((item, index) => {
return (
<Col key={index} span={24} style={{ lineHeight: '32px' }}>
<Row>
<Col span={readOnly?24:12}>
<a onClick={() => {
window.open(`/api/datamodeler/file/download?id=${item.id}`)
}}>{item.fileName}
</a>
</Col>
{
!readOnly && <Col span={4}>
<Button
size='small'
type='danger'
onClick={() => {
dispatch({
type: 'datamodel.approvalDeleteFile',
payload: {
id: item.id
},
callback: (data) => {
const newValue = [...value]
newValue.splice(index, 1)
onChange?.(newValue)
}
})
}}
>删除</Button>
</Col>
}
</Row>
</Col>
)
})
}
</Row>
)
}
\ 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