ActiveMenuComponent.js 3.3 KB
Newer Older
1 2 3 4 5
/**
 * 钟是志
 * 2022年9月15日
 * onestopApp1.0
 * */
6
import React, { useEffect, useState, createContext, useRef } from 'react';
钟是志's avatar
钟是志 committed
7 8 9 10 11
import CheckRecord from '@/webPublic/FormInsertDiy/ExportComponent/CheckRecord'; // 查询类
import Apply from '@/webPublic/FormInsertDiy/AffairPage/ApplyPage'; // 申请
import BatchAudit from '@/webPublic/FormInsertDiy/AffairPage/AuditPage/BatchAudit'; // 批量审批
import Audit from '@/webPublic/FormInsertDiy/AffairPage/AuditPage/index.js'; // 审批
import Detail from '@/webPublic/FormInsertDiy/AffairPage/Detail'; //详情
钟是志's avatar
钟是志 committed
12
import { Modal, message, notification, Popconfirm } from 'antd';
13
import { connect } from 'dva';
14
import router from 'umi/router';
15 16
import { getIsQian_Nan } from '@/webPublic/zyd_public/utils/getSchoolType';
import exportHandledInfo from '@/webPublic/FormInsertDiy/AffairPage/AuditPage/exportHandledInfo';
17 18

export const CreateC = createContext({
19
	routerConfig: {},
20 21
});

22
window.iframeParentComponent = {
23 24 25 26
	Modal,
	message,
	notification,
	Popconfirm,
27 28
};

29 30 31 32 33 34 35 36
function ActiveMenuComponent({ routerConfig, ...otherProps }) {
	const { component = '', appId } = routerConfig;
	const refType = useRef();
	const { location } = otherProps;
	const record = location?.state?.record;
	const [show, setShow] = useState(false);
	useEffect(
		() => {
37 38
			if ((appId || record.id) && refType.current?.component === component) {
				// 当同一个组件渲染时 切换show 保证重新调接口并渲染页面
39 40 41 42 43 44 45 46 47 48 49 50 51 52
				setShow(false);
				setTimeout(() => {
					setShow(true);
				}, 100);
			} else {
				setShow(true);
			}
			refType.current = routerConfig;
		},
		[appId, record],
	);
	if (!show) {
		return null;
	}
53

54
	let Res = <div>暂无此功能</div>;
55

56 57 58 59 60
	switch (component) {
		case 'CheckRecord': // 查询类应用
			Res = <CheckRecord workId={appId} />;
			break;
		case 'Apply': // 申请类
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
			if (appId === '1549319936277479424') {
				// 29573 当前位置: 违纪管理/违纪上报(辅导员),100086 下面这个模块做个超链接 搞到这儿来
				otherProps.otherButtons = [
					{
						type: 'weijiJiangjiLiebiao',
						name: '申诉降级上报',
						component: 'Normal',
						handleClick: () => {
							router.push({
								pathname: '/xg/Violation/downgrade',
							});
						},
					},
				];
			}
			Res = <Apply workId={appId} {...otherProps} />;
77 78
			break;
		case 'Audit': // 审批类
79 80 81
			Res = <Audit workId={appId} {...otherProps} />;
			break;
		case 'BatchAudit': // 批量审批
82
      if(appId === '1492048888356405248' && getIsQian_Nan() || process.env.NODE_ENV === 'development'){
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
        // 禅道30031
        otherProps.tab2Buttons = [
          {
            type: 'export',
            name: '导出',
            component: 'Normal',
            handleClick: (selectRows, formValues, getPage, search, columns) => {
              exportHandledInfo({
                columns,
                appId,
                handled: 'handled',
              });
            },
          },
        ];
      }
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
			Res = <BatchAudit workId={appId} {...otherProps} />;
			break;
		case 'Detail': // 详情
			Res = <Detail {...otherProps} />;
			break;
		default:
			break;
	}
	return (
		<CreateC.Provider
			value={{
				routerConfig,
			}}>
			{Res}
		</CreateC.Provider>
	);
115
}
116 117

export default connect(({}) => {
118
	return {};
119
})(ActiveMenuComponent);