Browse Source

表单验证状态展示

dev
巴林闲侠 2 years ago
parent
commit
3bee7b70d9
  1. 1
      api/app/lib/controllers/workOrder/index.js
  2. 61
      web/client/src/components/workflow/index.jsx
  3. 124
      web/client/src/sections/workOrder/containers/jobOrder.jsx
  4. 2
      web/client/src/utils/webapi.js

1
api/app/lib/controllers/workOrder/index.js

@ -21,6 +21,7 @@ async function getEnabledWorkflowProcess (ctx) {
WHERE WHERE
workflow_process.deleted = 0 workflow_process.deleted = 0
AND workflow_process.is_enable = 1 AND workflow_process.is_enable = 1
order by workflow_process.update_time desc
`).toPromise() `).toPromise()
ctx.status = 200; ctx.status = 200;

61
web/client/src/components/workflow/index.jsx

@ -2,9 +2,9 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Modal, Spin, Notification, Row } from '@douyinfe/semi-ui'; import { Modal, Spin, Notification, Row, Space, Button } from '@douyinfe/semi-ui';
import { RouteTable } from '../../utils/webapi'; import { RouteTable } from '../../utils/webapi';
import { RouteRequest } from '@peace/utils'; import { EmisRequest, EmisApiTable } from '$utils';
import { useState } from 'react'; import { useState } from 'react';
import { useEffect } from 'react'; import { useEffect } from 'react';
import { IconClose } from '@douyinfe/semi-icons'; import { IconClose } from '@douyinfe/semi-icons';
@ -14,7 +14,7 @@ import './index.less'
const { confirm } = Modal; const { confirm } = Modal;
const WorkFlowModal = (props) => { const WorkFlowModal = (props) => {
const { successCallBack = () => { }, title, visible, clientHeight, postData, processId, user, dispatch, webEmis, webOa } = props; const { successCallBack = () => { }, title, visible, clientHeight, postData, processId, user, dispatch, webEmis, webOa, onCancel } = props;
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [ifShowMessage, setIfShowMessage] = useState(true); const [ifShowMessage, setIfShowMessage] = useState(true);
const [customVisible, setCustomVisible] = useState(false); const [customVisible, setCustomVisible] = useState(false);
@ -25,7 +25,6 @@ const WorkFlowModal = (props) => {
if (draftId) { if (draftId) {
setCustomVisible(false); setCustomVisible(false);
} else { } else {
const { onCancel } = props;
onCancel && onCancel(); onCancel && onCancel();
setLoading(false); setLoading(false);
} }
@ -60,18 +59,13 @@ const WorkFlowModal = (props) => {
} }
const handelDeny = () => { const handelDeny = () => {
// dispatch(delDraft(draftId)).then(res => { EmisRequest.delete(EmisApiTable.delDraftUrl.replace('{draftId}', draftId)).then(res => {
// if (res.success) { Notification.success({ title: '删除草稿成功' });
// Notification.success({title:'稿'}); onCancel && onCancel();
// const { onCancel } = props; setLoading(false);
// onCancel && onCancel(); setCustomVisible(false);
// setLoading(false); setDraftId(null);
// setCustomVisible(false); })
// setDraftId(null);
// } else {
// Notification.error({title:'稿'});
// }
// })
} }
const cancel = () => { const cancel = () => {
@ -84,6 +78,7 @@ const WorkFlowModal = (props) => {
let data = JSON.parse(event.data); let data = JSON.parse(event.data);
const { type, isSaveDraft, setIntervalSave, draftId, msg } = data; const { type, isSaveDraft, setIntervalSave, draftId, msg } = data;
if (msg) { if (msg) {
console.log(msg);
Notification.success({ title: msg }) Notification.success({ title: msg })
} }
setDraftId(draftId); setDraftId(draftId);
@ -109,7 +104,6 @@ const WorkFlowModal = (props) => {
} }
//message //message
window.addEventListener('message', receiveMessageFromIndex, false); window.addEventListener('message', receiveMessageFromIndex, false);
}, []) }, [])
console.log(webEmis, processId); console.log(webEmis, processId);
@ -124,7 +118,7 @@ const WorkFlowModal = (props) => {
hasCancel={false} hasCancel={false}
footer={null} footer={null}
wrapClassName='process_modal_wrap' wrapClassName='process_modal_wrap'
onCancel={showConfirm} // onCancel={showConfirm}
> >
<Row> <Row>
<div className='workflow-body'> <div className='workflow-body'>
@ -158,16 +152,27 @@ const WorkFlowModal = (props) => {
</div> </div>
</div> </div>
{ {
customVisible ? <div className='modalBox'> customVisible ?
<div className='modal'> <Modal
<p className='content'>此表单已保存为草稿是否需要保留</p> title="此表单已保存为草稿,是否需要保留"
<ul className='btn'> visible={customVisible}
<li className='confirm' onClick={() => handelOk()}></li> footer={
<li className='deny' onClick={() => handelDeny()}></li> <Space>
<li className='cancel' onClick={() => cancel()}>取消</li> <Button type="primary" onClick={() => handelOk()}>
</ul>
</div> </Button>
</div> : '' <Button type="primary" onClick={() => handelDeny()}>
</Button>
<Button type="primary" onClick={() => cancel()}>
取消
</Button>
</Space>
}
>
</Modal>
: ''
} }
</Row> </Row>
</Modal > </Modal >

124
web/client/src/sections/workOrder/containers/jobOrder.jsx

@ -3,96 +3,104 @@ import { connect } from 'react-redux';
import moment from 'moment'; import moment from 'moment';
import { WorkflowModal, WorkFlowViewModal } from "$components" import { WorkflowModal, WorkFlowViewModal } from "$components"
import { EmisRequest, EmisApiTable } from "$utils" import { EmisRequest, EmisApiTable } from "$utils"
import { Card, Notification, Space, Button } from '@douyinfe/semi-ui'; import { Card, Notification, Space, Button, Spin } from '@douyinfe/semi-ui';
import { IconArticle } from '@douyinfe/semi-icons'; import { IconArticle } from '@douyinfe/semi-icons';
import '../style.less' import '../style.less'
const { Meta } = Card; const { Meta } = Card;
const JobOrder = (props) => { const JobOrder = (props) => {
const { dispatch, actions, user, workflowProcess } = props const { dispatch, actions, user, workflowProcess, clientHeight } = props
const { workOrder } = actions const { workOrder } = actions
const [workflowModalVisible, setWorkflowModalVisible] = useState(false) const [workflowModalVisible, setWorkflowModalVisible] = useState(false)
const [launchProcessId, setLaunchProcessId] = useState(null) const [launchProcessId, setLaunchProcessId] = useState(null)
const [formStateRequestingIndex, setFormStateRequestingIndex] = useState(false)
useEffect(() => { useEffect(() => {
dispatch(workOrder.getEnabledWorkflowProcess()) dispatch(workOrder.getEnabledWorkflowProcess())
}, []) }, [])
return ( return (
<div className='work-order-container' style={{ <div>
display: 'grid', gridTemplateColumns: `repeat(auto-fit, minmax(340px, 1fr))`, gridAutoRows: `minmax(0, auto)`, gridGap: 12, <div className='work-order-container' style={{
}}> display: 'grid', gridTemplateColumns: `repeat(auto-fit, minmax(340px, 1fr))`, gridAutoRows: `minmax(0, auto)`, gridGap: 12,
{ }}>
workflowProcess.map(p => { {
return ( workflowProcess.map((p, index) => {
<Card return (
key={p.id} <Card
className='work-order-card' key={p.id}
style={{ gridColumn: `span 1`, cursor: 'pointer' }} className='work-order-card'
footerLine={true} style={{ gridColumn: `span 1`, cursor: 'pointer' }}
footerStyle={{ display: 'flex', justifyContent: 'flex-end' }} footerLine={true}
footer={ footerStyle={{ display: 'flex', justifyContent: 'flex-end' }}
`创建时间:${moment(p.createTime || p.updateTime).format('YYYY-MM-DD HH:mm:ss')}` footer={
} `创建时间:${moment(p.createTime || p.updateTime).format('YYYY-MM-DD HH:mm:ss')}`
onClick={() => { }
EmisRequest.get(EmisApiTable.getProcessByName, { onClick={() => {
name: decodeURIComponent(p.name), if (formStateRequestingIndex) return;
resource: p.id setFormStateRequestingIndex(index + 1)
}).then(res => { EmisRequest.get(EmisApiTable.getProcessByName, {
console.log(res); name: decodeURIComponent(p.name),
if (res) { resource: p.id
// if (res.deleted) { }).then(res => {
// Notification.error({ title: '退' }) setFormStateRequestingIndex(false)
// } else if (res.isEdited) { if (res) {
// Notification.error({ title: '退' }) // if (res.deleted) {
// } else if (!res.isEnable) { // Notification.error({ title: '退' })
// Notification.error({ title: '退' }) // } else if (res.isEdited) {
// } else // Notification.error({ title: '退' })
if (res.id) { // } else if (!res.isEnable) {
setLaunchProcessId(res.id) // Notification.error({ title: '退' })
setWorkflowModalVisible(true) // } else
if (res.id) {
setLaunchProcessId(res.id)
setWorkflowModalVisible(true)
}
} else {
Notification.error({ title: `获取指定流程失败` });
} }
} else { })
Notification.error({ title: `获取指定流程失败` }); }}
} >
}) <div>
}} <Meta
> title={
<div> <span>{p.name}<Spin style={{ position: 'relative', top: 6, left: 6 }} spinning={formStateRequestingIndex == index + 1} /></span>
<Meta }
title={p.name} avatar={
// description="" <IconArticle style={{ fontSize: 42 }} />
avatar={ }
<IconArticle style={{ fontSize: 42 }} /> />
} </div>
/> </Card>
</div> )
</Card> })
) }
}) </div>
} <WorkflowModal
{/* <WorkflowModal
visible={workflowModalVisible} visible={workflowModalVisible}
title={''} title={''}
processId={launchProcessId} processId={launchProcessId}
onCancel={() => { setWorkflowModalVisible(false) }} onCancel={() => { setWorkflowModalVisible(false) }}
successCallBack={() => { setWorkflowModalVisible(false) }} successCallBack={() => { setWorkflowModalVisible(false) }}
/> */} />
<WorkFlowViewModal {/* <WorkFlowViewModal
visible={workflowModalVisible} visible={workflowModalVisible}
processId={launchProcessId} processId={launchProcessId}
/> /> */}
</div> </div>
) )
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { auth, global, workflowProcess } = state; const { auth, global, workflowProcess } = state;
console.log(global);
return { return {
user: auth.user, user: auth.user,
actions: global.actions, actions: global.actions,
workflowProcess: workflowProcess.data || [] workflowProcess: workflowProcess.data || [],
clientHeight: global.clientHeight
}; };
} }

2
web/client/src/utils/webapi.js

@ -86,6 +86,8 @@ export const ApiTable = {
export const EmisApiTable = { export const EmisApiTable = {
//通过流程名称查找指定流程 //通过流程名称查找指定流程
getProcessByName: 'workflow/process/name', getProcessByName: 'workflow/process/name',
//删除草稿
delDraftUrl: 'process/drafts/{draftId}',
} }
export const RouteTable = { export const RouteTable = {

Loading…
Cancel
Save