山西督察-superintend-distribute-web react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.3 KiB

  1. import React, { useState } from 'react';
  2. import { Tabs } from 'antd';
  3. import { connect, history } from 'umi';
  4. import ProvinceSelect from '@/components/ProvinceSelect';
  5. import { UserLevel, processTab } from '@/utils/constants';
  6. import TableList from './TableList';
  7. // import Department from './Department';
  8. // import Province from './Province';
  9. import { secondTabName } from '@/utils/utils';
  10. const { TabPane } = Tabs
  11. const Doing = (props) => {
  12. const { user, isLocationInBu,locationType } = props;
  13. // console.log(isLocationInBu);
  14. // debugger;
  15. const tabList = processTab(locationType);
  16. const [activeKey, setActiveKey] = useState('department');
  17. const [selectdProvince, setSelectdProvince] = useState('');
  18. const [selectdCity, setSelectdCity] = useState('');
  19. const [showProvinceSelect, setShowProvinceSelect] = useState(isLocationInBu);
  20. const [departmentMsg, setDepartmentMsg] = useState(null);
  21. const [provinceMsg, setProvinceMsg] = useState(null);
  22. const [cityMsg, setCityMsg] = useState(null);
  23. const [ifReload, setIfReload] = useState(null); // 页面是否要重新加载 为从待办跳转过来准备
  24. const changeTab = (key) => {
  25. setActiveKey(key);
  26. setShowProvinceSelect(isLocationInBu);
  27. setDepartmentMsg(null);
  28. setProvinceMsg(null);
  29. setCityMsg(null);
  30. }
  31. if (props.location.params) { // 监控路由参数 点击消息跳转过来的会带params参数
  32. const { type, msg, reload } = props.location.params; // type: 展示tab类型 msg: 消息带过来的查询条件
  33. if (reload === ifReload) { // 防止不断循环
  34. return false
  35. }
  36. setIfReload(reload);
  37. if (type === 'department') { // 跳转到部级下发
  38. setActiveKey(type);
  39. setDepartmentMsg(msg);
  40. } else if (type === 'province') { // 跳转到省级下发
  41. setShowProvinceSelect(false);
  42. setActiveKey(type);
  43. setProvinceMsg(msg);
  44. } else if (type === 'city') { // 跳转到市级下发
  45. setShowProvinceSelect(false);
  46. setActiveKey(type);
  47. setCityMsg(msg);
  48. }
  49. history.push('/doingcases'); // 清空参数 防止误判
  50. }
  51. const onSelectProvince = (key) => {
  52. setSelectdProvince(key);
  53. setActiveKey('province');
  54. setShowProvinceSelect(false);
  55. }
  56. const onSelectCity = (key) => {
  57. setSelectdCity(key);
  58. setActiveKey('city');
  59. setShowProvinceSelect(false);
  60. }
  61. const renderContent = (active) => {
  62. if (active === 'department') {
  63. return <TableList
  64. msg={departmentMsg}
  65. refesh={Math.random()}
  66. isLocationInBu={isLocationInBu}
  67. locationType={locationType}
  68. type='bu'
  69. sysToken={isLocationInBu ? '' : 'bu'}
  70. />
  71. }
  72. // debugger;
  73. if (active === 'province') {
  74. if (showProvinceSelect) {
  75. return (
  76. <ProvinceSelect
  77. onSelectProvince={onSelectProvince}
  78. sysToken={isLocationInBu ? selectdProvince : ''}
  79. />
  80. )
  81. }else{
  82. return (
  83. <TableList
  84. msg={provinceMsg}
  85. refesh={Math.random()}
  86. isLocationInBu={isLocationInBu}
  87. locationType={locationType}
  88. type='sheng'
  89. sysToken={isLocationInBu ? selectdProvince : 'sheng'}
  90. />
  91. )
  92. }
  93. }
  94. // if(locationType === 2 ){
  95. if (active === 'city'){
  96. return <TableList
  97. msg={cityMsg}
  98. refesh={Math.random()}
  99. isLocationInBu={isLocationInBu}
  100. locationType={locationType}
  101. type='shi'
  102. sysToken={'shi'}
  103. />
  104. // }
  105. }
  106. }
  107. return (
  108. <div>
  109. <Tabs activeKey={activeKey} onChange={changeTab}>
  110. {/* <TabPane tab='部级平台' key='department'></TabPane> */}
  111. {/* <TabPane tab={secondTabName(user.departmentOrgLevel)} key='province'>
  112. </TabPane> */}
  113. {/* <TabPane tab='省级平台' key='province'></TabPane> */}
  114. {/* isLocationInBu !==2 */}
  115. {/* <TabPane tab='市级平台' key='city' forceRender={true} hidden={isLocationInBu !== 2}></TabPane> */}
  116. {
  117. tabList.map((item) => {
  118. return (
  119. <TabPane key={item.key}></TabPane>
  120. );
  121. })
  122. }
  123. </Tabs>
  124. {
  125. renderContent(activeKey)
  126. }
  127. </div>
  128. )
  129. }
  130. export default connect(({ user }) => ({
  131. user: user.currentUser,
  132. isLocationInBu: user.isLocationInBu,
  133. locationType: user.locationType
  134. }))(Doing);