提交 840dcb09 authored 作者: 姚鑫国's avatar 姚鑫国

4472 评奖评优模块功能优化

上级 ede21a8e
...@@ -5,387 +5,388 @@ ...@@ -5,387 +5,388 @@
* *
* */ * */
import { message, Modal } from 'antd'; import {message, Modal} from 'antd';
import React, { useEffect, useState } from 'react'; import React, {useEffect, useState} from 'react';
import * as service from '../publicApiService'; import * as service from '../publicApiService';
import * as destructionFunc from '../destruction'; import * as destructionFunc from '../destruction';
import { Link } from 'dva/router'; import {Link} from 'dva/router';
import { getApplyPage } from '../publicApiService'; import {getApplyPage} from '../publicApiService';
import { getToken } from '@/utils/authority'; import {getToken} from '@/utils/authority';
import JustApply from './JustApply'; import JustApply from './JustApply';
import PageHeaderWrapper from '@/components/PageHeaderWrapper'; import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import List from './List'; import List from './List';
import pageSetting from './pageSetting'; import pageSetting from './pageSetting';
import ButtonDiy from '@/baseComponent/ButtonDiy'; import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '@/baseComponent/Shell'; import Shell from '@/baseComponent/Shell';
import { deepCopy, getIsBei_Dian } from '@/webPublic/zyd_public/utils/utils'; import {deepCopy, getIsBei_Dian} from '@/webPublic/zyd_public/utils/utils';
import ApplyForZyd from '@/webPublic/one_stop_public/ForZydApply/index'; import ApplyForZyd from '@/webPublic/one_stop_public/ForZydApply/index';
import rebackButton from '@/webPublic/FormInsertDiy/AffairPage/ApplyPage/ReBackButton'; import rebackButton from '@/webPublic/FormInsertDiy/AffairPage/ApplyPage/ReBackButton';
export default function index(props) { export default function index(props) {
const { state = {} } = props.location; const {state = {}} = props.location;
const [show, setShow] = useState(false); const [show, setShow] = useState(false);
useEffect( useEffect(
() => { () => {
setShow(false); setShow(false);
setTimeout(() => { setTimeout(() => {
setShow(true); setShow(true);
}, 100); }, 100);
}, },
[props.location.pathname], [props.location.pathname],
); );
if (!show) { if (!show) {
return null; return null;
} }
if (state.justApply) { if (state.justApply) {
return <JustApply {...props} />; return <JustApply {...props} />;
} else { } else {
return <AffairPage {...props} />; return <AffairPage {...props} />;
} }
} }
class AffairPage extends React.Component { class AffairPage extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
let pathname = this.props.location.pathname; let pathname = this.props.location.pathname;
const { workId } = this.props; const {workId} = this.props;
this.state = { this.state = {
showIframe: false, showIframe: false,
columns: [], columns: [],
pathname, pathname,
workId: workId || '', workId: workId || '',
searchCondition: [], searchCondition: [],
dataBaseId: '', dataBaseId: '',
addFields: [], // 新增时填写的字段。 addFields: [], // 新增时填写的字段。
renderIframe: false, renderIframe: false,
allConfigSetInfo: null, allConfigSetInfo: null,
serviceInfo: null, serviceInfo: null,
}; };
} }
getServiceDetail = (serviceId) => { getServiceDetail = (serviceId) => {
service.getServiceDetail(serviceId).then((res) => { service.getServiceDetail(serviceId).then((res) => {
this.setState({ this.setState({
serviceInfo: res, serviceInfo: res,
}); });
}); });
}; };
getFormDetail = (workId) => { getFormDetail = (workId) => {
service.getFormDetail(workId).then((response) => { service.getFormDetail(workId).then((response) => {
if (typeof response.unifiedServicePatternModel === 'undefined') { if (typeof response.unifiedServicePatternModel === 'undefined') {
return false; return false;
} }
if(response.serviceId){ if (response.serviceId) {
this.getServiceDetail(response.serviceId); this.getServiceDetail(response.serviceId);
} }
destructionFunc.destructionGetDetail(response).then((x) => { destructionFunc.destructionGetDetail(response).then((x) => {
const { addFields, tableInfo, allConfigSetInfo } = x; const {addFields, tableInfo, allConfigSetInfo} = x;
this.setState( this.setState(
{ {
addFields, addFields,
tableInfo, tableInfo,
allConfigSetInfo, allConfigSetInfo,
}, },
() => { () => {
this.giveDetailColumns(); this.giveDetailColumns();
}, },
); );
}); });
}); });
}; };
giveDetailColumns = () => { giveDetailColumns = () => {
const { columns, workId, dataBaseId, addFields } = this.state; const {columns, workId, dataBaseId, addFields} = this.state;
const process_status = columns.find((x) => { const process_status = columns.find((x) => {
return x.name === 'process_status'; return x.name === 'process_status';
}); });
if (process_status && process_status.dataIndex) { if (process_status && process_status.dataIndex) {
process_status.render = (text, record) => { process_status.render = (text, record) => {
return record.statusName || record[process_status.dataIndex]; return record.statusName || record[process_status.dataIndex];
}; };
} }
let findCz = columns.find((g) => g.dataIndex === 'operation'); let findCz = columns.find((g) => g.dataIndex === 'operation');
if (!findCz) { if (!findCz) {
columns.push({ columns.push({
dataIndex: 'operation', dataIndex: 'operation',
title: '操作', title: '操作',
fixed: columns.length > 12 ? 'right' : false, fixed: columns.length > 12 ? 'right' : false,
render: (text, record) => { render: (text, record) => {
return ( return (
<Link <Link
to={{ to={{
pathname: './Detail', pathname: './Detail',
state: { state: {
workId, workId,
dataBaseId, dataBaseId,
record, record,
addFields, addFields,
}, },
}}> }}>
{record.statusName === "重新提交" ? "去提交" : "详情" } {["reject", "re_apply", "un_audit"].includes(record?.hisTaskListData?.formStatusId) ? "去提交" : "详情"}
</Link> </Link>
); );
}, },
}); });
} }
this.setState({ this.setState({
columns, columns,
}); });
}; };
handleButtonSet = () => { handleButtonSet = () => {
const { canApply, otherButtons = [] } = this.props; const {canApply, otherButtons = []} = this.props;
const { allConfigSetInfo, serviceInfo } = this.state; const {allConfigSetInfo, serviceInfo} = this.state;
if (!allConfigSetInfo) { if (!allConfigSetInfo) {
return []; return [];
} }
const isCloseStart = allConfigSetInfo?.isCloseStart; const isCloseStart = allConfigSetInfo?.isCloseStart;
if (canApply === false || isCloseStart) { if (canApply === false || isCloseStart) {
return [...otherButtons]; return [...otherButtons];
} }
return [ return [
{ {
type: 'add', type: 'add',
name: '申请', name: '申请',
component: 'Normal', component: 'Normal',
handleClick: () => { handleClick: () => {
this.setState( this.setState(
{ {
showIframe: true, showIframe: true,
renderIframe: true, renderIframe: true,
}, },
() => {}, () => {
); },
}, );
}, },
...rebackButton(serviceInfo), },
...otherButtons, ...rebackButton(serviceInfo),
]; ...otherButtons,
}; ];
};
handleSearchSet = () => { handleSearchSet = () => {
const { columns, searchCondition } = this.state; const {columns, searchCondition} = this.state;
const { onResponse } = this.props; const {onResponse} = this.props;
const pageSearch = { const pageSearch = {
search: { search: {
field: {}, field: {},
getPageService: getApplyPage, getPageService: getApplyPage,
responseCallBack: (response) => { responseCallBack: (response) => {
if (onResponse) { if (onResponse) {
onResponse(response); onResponse(response);
} }
return response; return response;
}, },
condition: searchCondition, condition: searchCondition,
nameSpan: { nameSpan: {
big: 8, big: 8,
small: 9, small: 9,
}, },
fileSpan: { fileSpan: {
big: 4, big: 4,
small: 4, small: 4,
}, },
}, },
tableRowKey: 'id', tableRowKey: 'id',
columns, columns,
}; };
return pageSearch; return pageSearch;
}; };
getColumns = () => { getColumns = () => {
const { workId } = this.state; const {workId} = this.state;
service.getColumns(workId).then((response) => { service.getColumns(workId).then((response) => {
if (response && Array.isArray(response)) { if (response && Array.isArray(response)) {
response = response.filter((x) => { response = response.filter((x) => {
return x.title !== '流程进度'; return x.title !== '流程进度';
}); });
} }
if (response) { if (response) {
this.setState( this.setState(
{ {
columns: response, columns: response,
}, },
() => { () => {
this.getFormDetail(workId); this.getFormDetail(workId);
}, },
); );
} }
}); });
}; };
initData = () => { initData = () => {
if (!getToken()) { if (!getToken()) {
message.error('您的数据未同步,请联系管理员!'); message.error('您的数据未同步,请联系管理员!');
return false; return false;
} }
const { pathname } = this.state; const {pathname} = this.state;
const { dataBaseId, workId, iframeHeight } = this.props; const {dataBaseId, workId, iframeHeight} = this.props;
if (dataBaseId || workId) { if (dataBaseId || workId) {
this.setState( this.setState(
{ {
workId, workId,
dataBaseId, dataBaseId,
}, },
() => { () => {
this.getColumns(); this.getColumns();
}, },
); );
} else { } else {
service.getId(pathname).then((x) => { service.getId(pathname).then((x) => {
this.setState( this.setState(
{ {
workId: x.workId, workId: x.workId,
dataBaseId: x.dataBaseId, dataBaseId: x.dataBaseId,
}, },
() => { () => {
this.getColumns(); this.getColumns();
}, },
); );
}); });
} }
window.addEventListener( window.addEventListener(
'message', 'message',
(event) => { (event) => {
if (event.data === 'returnList') { if (event.data === 'returnList') {
this.returnList(true); this.returnList(true);
} }
if (event && event.data && event.data.indexOf && event.data.indexOf('iframeHeight') > -1) { if (event && event.data && event.data.indexOf && event.data.indexOf('iframeHeight') > -1) {
let height = Number(event.data.split('-')[1]); let height = Number(event.data.split('-')[1]);
const iframe = document.getElementById('applyIframeId'); const iframe = document.getElementById('applyIframeId');
if (iframe) { if (iframe) {
iframe.height = height + (iframeHeight || 50); iframe.height = height + (iframeHeight || 50);
} }
} }
}, },
false, false,
); );
return true; return true;
}; };
componentDidMount() { componentDidMount() {
this.initData(); this.initData();
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps.workId !== this.props.workId) { if (prevProps.workId !== this.props.workId) {
this.initData(); this.initData();
} }
} }
returnList = (needSearchList = false) => { returnList = (needSearchList = false) => {
const { workId } = this.state; const {workId} = this.state;
this.setState( this.setState(
{ {
renderIframe: false, renderIframe: false,
}, },
() => { () => {
if (needSearchList) { if (needSearchList) {
this.ListComponent.getPage(); this.ListComponent.getPage();
setTimeout(() => { setTimeout(() => {
this.getFormDetail(workId); this.getFormDetail(workId);
}, 2000); }, 2000);
} }
this.setState({ this.setState({
showIframe: false, showIframe: false,
}); });
}, },
); );
}; };
render() { render() {
const { iframeUrlDiy } = this.props; const {iframeUrlDiy} = this.props;
const { const {
workId, workId,
dataBaseId, dataBaseId,
addFields, addFields,
showIframe, showIframe,
renderIframe, renderIframe,
allConfigSetInfo, allConfigSetInfo,
} = this.state; } = this.state;
if (!workId || !allConfigSetInfo) { if (!workId || !allConfigSetInfo) {
return null; return null;
} }
let buttons = this.handleButtonSet({}); let buttons = this.handleButtonSet({});
let listConfig = pageSetting.listConfig; let listConfig = pageSetting.listConfig;
if (!buttons.length) { if (!buttons.length) {
listConfig = deepCopy(listConfig); listConfig = deepCopy(listConfig);
listConfig.buttonArea = false; listConfig.buttonArea = false;
} }
return ( return (
<PageHeaderWrapper title=""> <PageHeaderWrapper title="">
<div <div
style={{ style={{
display: showIframe ? 'none' : 'block', display: showIframe ? 'none' : 'block',
}}> }}>
<List <List
listConfig={listConfig} listConfig={listConfig}
pageButton={buttons} pageButton={buttons}
pageSearch={this.handleSearchSet({})} pageSearch={this.handleSearchSet({})}
addFields={addFields} addFields={addFields}
ref={(ListComponent) => (this.ListComponent = ListComponent)} ref={(ListComponent) => (this.ListComponent = ListComponent)}
workId={workId} workId={workId}
dataBaseId={dataBaseId} dataBaseId={dataBaseId}
/> />
</div> </div>
<div <div
style={{ style={{
visibility: showIframe ? 'visible' : 'hidden', visibility: showIframe ? 'visible' : 'hidden',
height: showIframe ? 'auto' : '0px', height: showIframe ? 'auto' : '0px',
width: '100%', width: '100%',
backgroundColor: '#fff', backgroundColor: '#fff',
paddingLeft: '24px', paddingLeft: '24px',
}}> }}>
<Shell> <Shell>
<div <div
style={{ style={{
height: '54px', height: '54px',
padding: '12px 0 12px 12px', padding: '12px 0 12px 12px',
display: showIframe ? 'block' : 'none', display: showIframe ? 'block' : 'none',
}}> }}>
<ButtonDiy <ButtonDiy
name="返回" name="返回"
className="defaultBlue" className="defaultBlue"
handleClick={this.returnList} handleClick={this.returnList}
icon="arrow-left" icon="arrow-left"
/> />
</div> </div>
</Shell> </Shell>
{renderIframe ? ( {renderIframe ? (
iframeUrlDiy ? ( iframeUrlDiy ? (
<iframe <iframe
src={iframeUrlDiy} src={iframeUrlDiy}
frameBorder={0} frameBorder={0}
id="applyIframeId" id="applyIframeId"
name="applyIframe" name="applyIframe"
marginWidth="0" marginWidth="0"
marginHeight="0" marginHeight="0"
allowTransparency="yes" allowTransparency="yes"
seamless seamless
scrolling={'auto'} scrolling={'auto'}
style={{ style={{
width: '100%', width: '100%',
minHeight: '800px', minHeight: '800px',
overflowY: 'hidden', overflowY: 'hidden',
backgroundColor: '#fff', backgroundColor: '#fff',
}} }}
/> />
) : ( ) : (
<ApplyForZyd {...this.props} <ApplyForZyd {...this.props}
returnList={this.returnList} returnList={this.returnList}
id={workId === '1549319936277479424' ? '1590627747913269248' : workId} /> id={workId === '1549319936277479424' ? '1590627747913269248' : workId}/>
/* 姚鑫国说的 北电科违纪要用另外一个id发起 2022年11月10日 */ /* 姚鑫国说的 北电科违纪要用另外一个id发起 2022年11月10日 */
) )
) : null} ) : null}
</div> </div>
</PageHeaderWrapper> </PageHeaderWrapper>
); );
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论