From 3bee7b70d9482515828b3830c02d6cff12d11199 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 1 Jun 2023 18:04:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/workOrder/index.js | 1 + web/client/src/components/workflow/index.jsx | 61 +++++---- .../workOrder/containers/jobOrder.jsx | 124 ++++++++++-------- web/client/src/utils/webapi.js | 2 + 4 files changed, 102 insertions(+), 86 deletions(-) diff --git a/api/app/lib/controllers/workOrder/index.js b/api/app/lib/controllers/workOrder/index.js index 4479687..4fe4164 100644 --- a/api/app/lib/controllers/workOrder/index.js +++ b/api/app/lib/controllers/workOrder/index.js @@ -21,6 +21,7 @@ async function getEnabledWorkflowProcess (ctx) { WHERE workflow_process.deleted = 0 AND workflow_process.is_enable = 1 + order by workflow_process.update_time desc `).toPromise() ctx.status = 200; diff --git a/web/client/src/components/workflow/index.jsx b/web/client/src/components/workflow/index.jsx index 12ad985..a1e8868 100644 --- a/web/client/src/components/workflow/index.jsx +++ b/web/client/src/components/workflow/index.jsx @@ -2,9 +2,9 @@ import React from 'react'; 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 { RouteRequest } from '@peace/utils'; +import { EmisRequest, EmisApiTable } from '$utils'; import { useState } from 'react'; import { useEffect } from 'react'; import { IconClose } from '@douyinfe/semi-icons'; @@ -14,7 +14,7 @@ import './index.less' const { confirm } = Modal; 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 [ifShowMessage, setIfShowMessage] = useState(true); const [customVisible, setCustomVisible] = useState(false); @@ -25,7 +25,6 @@ const WorkFlowModal = (props) => { if (draftId) { setCustomVisible(false); } else { - const { onCancel } = props; onCancel && onCancel(); setLoading(false); } @@ -60,18 +59,13 @@ const WorkFlowModal = (props) => { } const handelDeny = () => { - // dispatch(delDraft(draftId)).then(res => { - // if (res.success) { - // Notification.success({title:'删除草稿成功'}); - // const { onCancel } = props; - // onCancel && onCancel(); - // setLoading(false); - // setCustomVisible(false); - // setDraftId(null); - // } else { - // Notification.error({title:'删除草稿失败,请联系管理员'}); - // } - // }) + EmisRequest.delete(EmisApiTable.delDraftUrl.replace('{draftId}', draftId)).then(res => { + Notification.success({ title: '删除草稿成功' }); + onCancel && onCancel(); + setLoading(false); + setCustomVisible(false); + setDraftId(null); + }) } const cancel = () => { @@ -84,6 +78,7 @@ const WorkFlowModal = (props) => { let data = JSON.parse(event.data); const { type, isSaveDraft, setIntervalSave, draftId, msg } = data; if (msg) { + console.log(msg); Notification.success({ title: msg }) } setDraftId(draftId); @@ -109,7 +104,6 @@ const WorkFlowModal = (props) => { } //监听message事件 window.addEventListener('message', receiveMessageFromIndex, false); - }, []) console.log(webEmis, processId); @@ -124,7 +118,7 @@ const WorkFlowModal = (props) => { hasCancel={false} footer={null} wrapClassName='process_modal_wrap' - onCancel={showConfirm} + // onCancel={showConfirm} >
@@ -158,16 +152,27 @@ const WorkFlowModal = (props) => {
{ - customVisible ?
-
-

此表单已保存为草稿,是否需要保留

-
    -
  • handelOk()}>是
  • -
  • handelDeny()}>否
  • -
  • cancel()}>取消
  • -
-
-
: '' + customVisible ? + + + + + + + } + > + + : '' }
diff --git a/web/client/src/sections/workOrder/containers/jobOrder.jsx b/web/client/src/sections/workOrder/containers/jobOrder.jsx index e318f37..21dfa5d 100644 --- a/web/client/src/sections/workOrder/containers/jobOrder.jsx +++ b/web/client/src/sections/workOrder/containers/jobOrder.jsx @@ -3,96 +3,104 @@ import { connect } from 'react-redux'; import moment from 'moment'; import { WorkflowModal, WorkFlowViewModal } from "$components" 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 '../style.less' const { Meta } = Card; const JobOrder = (props) => { - const { dispatch, actions, user, workflowProcess } = props + const { dispatch, actions, user, workflowProcess, clientHeight } = props const { workOrder } = actions const [workflowModalVisible, setWorkflowModalVisible] = useState(false) const [launchProcessId, setLaunchProcessId] = useState(null) + const [formStateRequestingIndex, setFormStateRequestingIndex] = useState(false) useEffect(() => { dispatch(workOrder.getEnabledWorkflowProcess()) }, []) return ( -
- { - workflowProcess.map(p => { - return ( - { - EmisRequest.get(EmisApiTable.getProcessByName, { - name: decodeURIComponent(p.name), - resource: p.id - }).then(res => { - console.log(res); - if (res) { - // if (res.deleted) { - // Notification.error({ title: '该表单流程已删除,请尝试退出账号重新登录或联系项企管理员' }) - // } else if (res.isEdited) { - // Notification.error({ title: '该表单流程已修改,请尝试退出账号重新登录或联系项企管理员' }) - // } else if (!res.isEnable) { - // Notification.error({ title: '该表单流程已停用,请尝试退出账号重新登录或联系项企管理员' }) - // } else - if (res.id) { - setLaunchProcessId(res.id) - setWorkflowModalVisible(true) +
+
+ { + workflowProcess.map((p, index) => { + return ( + { + if (formStateRequestingIndex) return; + setFormStateRequestingIndex(index + 1) + EmisRequest.get(EmisApiTable.getProcessByName, { + name: decodeURIComponent(p.name), + resource: p.id + }).then(res => { + setFormStateRequestingIndex(false) + if (res) { + // if (res.deleted) { + // Notification.error({ title: '该表单流程已删除,请尝试退出账号重新登录或联系项企管理员' }) + // } else if (res.isEdited) { + // Notification.error({ title: '该表单流程已修改,请尝试退出账号重新登录或联系项企管理员' }) + // } else if (!res.isEnable) { + // Notification.error({ title: '该表单流程已停用,请尝试退出账号重新登录或联系项企管理员' }) + // } else + if (res.id) { + setLaunchProcessId(res.id) + setWorkflowModalVisible(true) + } + } else { + Notification.error({ title: `获取指定流程失败` }); } - } else { - Notification.error({ title: `获取指定流程失败` }); - } - }) - }} - > -
- - } - /> -
-
- ) - }) - } - {/* +
+ {p.name} + } + avatar={ + + } + /> +
+ + ) + }) + } +
+ { setWorkflowModalVisible(false) }} successCallBack={() => { setWorkflowModalVisible(false) }} - /> */} - + {/* + /> */}
) } function mapStateToProps (state) { const { auth, global, workflowProcess } = state; + console.log(global); return { user: auth.user, actions: global.actions, - workflowProcess: workflowProcess.data || [] + workflowProcess: workflowProcess.data || [], + clientHeight: global.clientHeight }; } diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 2c3261a..b9999ec 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -86,6 +86,8 @@ export const ApiTable = { export const EmisApiTable = { //通过流程名称查找指定流程 getProcessByName: 'workflow/process/name', + //删除草稿 + delDraftUrl: 'process/drafts/{draftId}', } export const RouteTable = {