'use strict'; import React from 'react'; import { connect } from 'react-redux'; import { Modal, Spin, Notification, Row, Space, Button } from '@douyinfe/semi-ui'; import { RouteTable } from '../../utils/webapi'; import { EmisRequest, EmisApiTable } from '$utils'; import { useState } from 'react'; import { useEffect } from 'react'; import { IconClose } from '@douyinfe/semi-icons'; // import { delDraft } from '../../sections/myform/actions/myform'; import './index.less' const { confirm } = Modal; const WorkFlowModal = (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); const [draftId, setDraftId] = useState(); const iframeRef = React.createRef(); const handelCancel = () => { if (draftId) { setCustomVisible(false); } else { onCancel && onCancel(); setLoading(false); } } const showConfirm = () => { if (draftId) { setCustomVisible(true); } else { confirm({ title: '确定关闭此表单吗?', onOk () { handelCancel() }, onCancel () { }, }); } } const handelApprovalCenter = (activeKey) => { if (webOa) { window.open(webOa + "/approval/center?activeKey=" + activeKey); } } const handelOk = () => { const { onCancel } = props; onCancel && onCancel(); setLoading(false); setCustomVisible(false); setDraftId(null); } const handelDeny = () => { EmisRequest.delete(EmisApiTable.delDraftUrl.replace('{draftId}', draftId)).then(res => { Notification.success({ title: '删除草稿成功' }); onCancel && onCancel(); setLoading(false); setCustomVisible(false); setDraftId(null); }) } const cancel = () => { setCustomVisible(false); } useEffect(() => { window.receiveMessageFromIndex = function (event) { if (event && event.data && typeof (event.data) == 'string') { let data = JSON.parse(event.data); const { type, isSaveDraft, setIntervalSave, draftId, msg } = data; if (msg) { console.log(msg); Notification.success({ title: msg }) } setDraftId(draftId); if (type == 'saveSuccess' && successCallBack) { if (ifShowMessage) { if (isSaveDraft) { if (setIntervalSave) { Notification.success({ title: '60秒,表单暂存草稿成功' }); } else { Notification.success(保存草稿成功,可在 handelApprovalCenter("save")}>【审批中心/保存待发】查看详情, 10); } } else { Notification.success({ title: '提交成功,可在【工单列表/我发起的】查看详情' }); successCallBack(); } //防止提示多次 setIfShowMessage(false); } // successCallBack(); 阻止页面关闭 setLoading(false); } } } //监听message事件 window.addEventListener('message', receiveMessageFromIndex, false); }, []) console.log(webEmis, processId); return (