山西督察-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.

494 lines
15 KiB

  1. import React, { useState, useEffect } from 'react';
  2. import { Table, Modal, Button, message, Pagination, Tooltip, Space } from 'antd';
  3. import { connect } from 'umi';
  4. import moment from 'moment';
  5. import TopSearch from '../TopSearch';
  6. import HCBGBtn from '../HCBGBtn';
  7. import CK from '@/components/Tabs-CK';
  8. import CXPF from '@/components/Tabs-CXPF';
  9. import BL from '@/components/Tabs-BL';
  10. import PFSPBatch from '@/components/PFSP-Batch';
  11. import BJSPBatch from '@/components/BJSP-Batch';
  12. import PFSP from '@/components/Tabs-PFSP';
  13. import SLGZ from '@/components/Tabs-SLGZ';
  14. import BJSP from '@/components/Tabs-BJSP';
  15. import BJSQ from '@/components/Tabs-BJSQ';
  16. import BJGZ from '@/components/Tabs-BJGZ';
  17. import { getDicsName } from '@/utils/utils';
  18. import { AJZT, BLFS, UserLevel } from '@/utils/constants';
  19. import { getHGIcons, ExampleBar, getTimeLine } from '@/components/MyIcons';
  20. const initDateType = 'sevenDays';
  21. const initSearchParams = {
  22. page: 1,
  23. size: 10,
  24. startTime: moment().add(-7, 'days'),
  25. endTime: moment(),
  26. };
  27. const TableList = (props) => {
  28. const { msg, sysToken, refesh, isLocationInBu, type, locationType } = props;
  29. // debugger;
  30. const [searchParams, setSearchParams] = useState(initSearchParams);
  31. const [tableData, setTableData] = useState(null);
  32. const [selectedRowKeys, setSelectedRowKeys] = useState([]);
  33. const [selectedRows, setSelectedRows] = useState([]);
  34. const [nowModal, setNowModal] = useState(null);
  35. const rowSelection = {
  36. selectedRowKeys,
  37. onChange: (keys, rows) => {
  38. setSelectedRows(rows)
  39. setSelectedRowKeys(keys);
  40. },
  41. // getCheckboxProps: (record) => ({
  42. // disabled: record.ajhczbl === 0,
  43. // }),
  44. };
  45. const handleClearCheck = () => {
  46. setSelectedRowKeys([]);
  47. setSelectedRows([]);
  48. };
  49. const getList = (params) => {
  50. handleClearCheck();
  51. const newParams = isLocationInBu && type === 'sheng' ? { ...params, sign: 1 } : params; // 部里发布 并且查询省里的列表加额外参数
  52. // debugger;
  53. const newSysToken = (locationType === UserLevel.Province.value && type === 'sheng')|| (locationType === UserLevel.City.value && type === 'shi') ? '' : sysToken;
  54. props.fetchDoingList({ params: newParams, sysToken:newSysToken }).then((data) => setTableData(data));
  55. };
  56. const hideModal = (flag) => {
  57. setNowModal(null);
  58. if (flag) {
  59. props.setRefresh(Math.random()); // 更新modal里的监测数据,为了刷新右上角消息
  60. getList(searchParams);
  61. }
  62. };
  63. const changeModal = (newComponent, flag) => {
  64. setNowModal(newComponent);
  65. if (flag) {
  66. getList(searchParams);
  67. }
  68. };
  69. const reBJSP = (record) => {
  70. setNowModal(
  71. <BJSP id={record.id} sysToken={sysToken} hideModal={hideModal} />,
  72. );
  73. };
  74. const reBJSQ = (record) => {
  75. setNowModal(
  76. <BJSQ id={record.id} sysToken={sysToken} hideModal={hideModal} />,
  77. );
  78. };
  79. const onclickReBJCheck = (record, modalType) => {
  80. props.fetchReBJCheck({ params: record.id, sysToken }).then((res) => {
  81. if (res.data) {
  82. if (modalType === 'sp') reBJSP(record);
  83. if (modalType === 'sq') reBJSQ(record);
  84. getList(searchParams); // 状态更改 要刷新列表
  85. } else {
  86. message.warning('不!');
  87. }
  88. });
  89. };
  90. // ck --查看--按钮是否显示 0-否 1-是
  91. // slpf -- 受理派发 --按钮是否显示 0-否 1-是
  92. // sldspgz 受理待审批--跟踪--按钮是否显示 0-否 1-是
  93. // sldspsp 受理待审批--审批--按钮是否显示 0-否 1-是
  94. // slbbhcxsq 受理被驳回--重新申请 按钮是否显示 0-否 1-是
  95. // ajhczbl 案件核查中--办理--按钮是否显示 0-否 1-是
  96. // bjdspgz 办结待审批--跟踪--按钮是否显示 0-否 1-是
  97. // bjdspsp 办结待审批--审批--按钮是否显示 0-否 1-是"
  98. // bjbbhcxsq 办结被驳回--重新申请--按钮是否显示 0-否 1-是
  99. // bjbbhcxsp 办结被驳回--重新审批--按钮是否显示 0-否 1-是
  100. const renderBtn = (record) => {
  101. const { id } = record;
  102. const allBtns = [];
  103. // const all = ['ck', 'sldspgz'];
  104. const ck = (
  105. <Button
  106. key='ck'
  107. type="link"
  108. onClick={() => setNowModal(<CK id={id} info={record} sysToken={sysToken} />)}
  109. >
  110. 查看
  111. </Button>
  112. );
  113. const slpf = (
  114. <Button
  115. key='slpf'
  116. type="link"
  117. onClick={() => setNowModal(<CXPF id={id} sysToken={sysToken} hideModal={hideModal} />)}
  118. >
  119. 受理派发
  120. </Button>
  121. );
  122. const sldspgz = (
  123. <Button
  124. key='sldspgz'
  125. type="link"
  126. onClick={() => setNowModal(<SLGZ id={id} sysToken={sysToken} hideModal={hideModal} />)}
  127. >
  128. 跟踪
  129. </Button>
  130. );
  131. const sldspsp = (
  132. <Button
  133. key='sldspsp'
  134. type="link"
  135. onClick={() => setNowModal(<PFSP id={id} sysToken={sysToken} hideModal={hideModal} />)}
  136. >
  137. 审批
  138. </Button>
  139. );
  140. const slbbhcxsq = (
  141. <Button
  142. key='slbbhcxsq'
  143. type="link"
  144. onClick={() => setNowModal(<CXPF id={id} sysToken={sysToken} hideModal={hideModal} />)}
  145. >
  146. 重新申请
  147. </Button>
  148. );
  149. const ajhczbl = (
  150. <Button
  151. key='ajhczbl'
  152. type="link"
  153. onClick={() =>
  154. setNowModal(
  155. <BL id={id} sysToken={sysToken} hideModal={hideModal} changeModal={changeModal} />,
  156. )
  157. }
  158. >
  159. 办理
  160. </Button>
  161. );
  162. const bjdspgz = (
  163. <Button
  164. key='bjdspgz'
  165. type="link"
  166. onClick={() => setNowModal(<BJGZ id={id} sysToken={sysToken} hideModal={hideModal} />)}
  167. >
  168. 跟踪
  169. </Button>
  170. );
  171. const bjdspsp = (
  172. <Button
  173. key='bjdspsp'
  174. type="link"
  175. onClick={() =>
  176. setNowModal(
  177. <BJSP id={id} sysToken={sysToken} hideModal={hideModal} changeModal={changeModal} />,
  178. )
  179. }
  180. >
  181. 审批
  182. </Button>
  183. );
  184. const bjbbhcxsq = (
  185. <Button key='bjbbhcxsq' type="link" onClick={() => onclickReBJCheck(record, 'sq')}>
  186. 重新申请
  187. </Button>
  188. );
  189. const bjbbhcxsp = (
  190. <Button key='bjbbhcxsp' type="link" onClick={() => onclickReBJCheck(record, 'sp')}>
  191. 重新审批
  192. </Button>
  193. );
  194. // debugger;
  195. if (record.ck === 1) allBtns.push(ck);
  196. if (record.slpf === 1) allBtns.push(slpf);
  197. if (record.sldspgz === 1) allBtns.push(sldspgz);
  198. if (record.sldspsp === 1) allBtns.push(sldspsp);
  199. if (record.slbbhcxsq === 1) allBtns.push(slbbhcxsq);
  200. if (record.ajhczbl === 1) allBtns.push(ajhczbl);
  201. if (record.bjdspgz === 1) allBtns.push(bjdspgz);
  202. if (record.bjdspsp === 1) allBtns.push(bjdspsp);
  203. if (record.bjbbhcxsq === 1) allBtns.push(bjbbhcxsq);
  204. if (record.bjbbhcxsp === 1) allBtns.push(bjbbhcxsp);
  205. // all.forEach(item => {
  206. // if (record[item] === 1) {
  207. // console.log('ppsp',[item.toUpperCase()])
  208. // allBtns.push([item.toUpperCase()])
  209. // };
  210. // })
  211. // debugger
  212. return allBtns;
  213. };
  214. const columns = [
  215. {
  216. title: '序号',
  217. dataIndex: 'id',
  218. key: 'id',
  219. render: (text, record, index) => index + 1,
  220. width: '5%',
  221. },
  222. {
  223. title: '预警编号',
  224. dataIndex: 'yjBh',
  225. width: '24%',
  226. render: (text, record) => {
  227. return (<span>{getHGIcons(record?.ccjg)}{text}</span>);
  228. }
  229. },
  230. {
  231. title: '模型名称',
  232. dataIndex: 'mxMc',
  233. width: '8%',
  234. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  235. ellipsis: { showTitle: false },
  236. },
  237. {
  238. title: '问题类型',
  239. dataIndex: 'cjwtLx',
  240. width: '8%',
  241. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  242. ellipsis: { showTitle: false },
  243. },
  244. {
  245. title: '承办督察部门',
  246. dataIndex: 'sadwMc',
  247. width: '9%',
  248. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  249. ellipsis: { showTitle: false },
  250. },
  251. {
  252. title: '办理方式',
  253. dataIndex: 'nbfs',
  254. width: '7%',
  255. render: text => (<Tooltip placement="topLeft" title={getDicsName(BLFS, text)} >{getDicsName(BLFS, text)}</Tooltip>),
  256. ellipsis: { showTitle: false },
  257. },
  258. {
  259. title: '问题简述',
  260. dataIndex: 'wtjs',
  261. width: '7%',
  262. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  263. ellipsis: { showTitle: false },
  264. },
  265. {
  266. title: '当前办理单位',
  267. dataIndex: 'dqbldwMc',
  268. width: '12%',
  269. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  270. ellipsis: { showTitle: false },
  271. },
  272. {
  273. title: '当前办理人',
  274. dataIndex: 'dqblrMc',
  275. width: '9%',
  276. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  277. ellipsis: { showTitle: false },
  278. },
  279. {
  280. title: '预警流向',
  281. dataIndex: 'blfsMc',
  282. width: '7%',
  283. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  284. ellipsis: { showTitle: false },
  285. },
  286. {
  287. title: '最新状态',
  288. dataIndex: 'dqZt',
  289. width: '7%',
  290. // render: (text) => getDicsName(AJZT, text),
  291. render: text => (<Tooltip placement="topLeft" title={getDicsName(AJZT, text)} >{getDicsName(AJZT, text)}</Tooltip>),
  292. ellipsis: { showTitle: false },
  293. },
  294. {
  295. title: '最新更新时间',
  296. dataIndex: 'updateTime',
  297. width: '9%',
  298. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  299. ellipsis: { showTitle: false },
  300. },
  301. {
  302. title: '最迟反馈时间',
  303. dataIndex: 'zcfkSj',
  304. width: '9%',
  305. render: text => (<Tooltip placement="topLeft" title={text} >{text}</Tooltip>),
  306. ellipsis: { showTitle: false },
  307. },
  308. {
  309. title: '时限',
  310. key: 'id',
  311. dataIndex: 'fkyj',
  312. width: '5%',
  313. render: (text) => getTimeLine(text),
  314. // fixed: 'right',
  315. },
  316. {
  317. title: '操作',
  318. dataIndex: 'id',
  319. width: '12%',
  320. render: (text, record) => {
  321. console.log(record, 999)
  322. return renderBtn(record);
  323. },
  324. fixed: 'right',
  325. },
  326. ];
  327. useEffect(() => { // 列表正常请求
  328. if (!msg) {
  329. getList(searchParams);
  330. }
  331. }, [refesh]);
  332. useEffect(() => { // 点击待办跳转过来的,参数由跳转带过来
  333. if (msg) {
  334. setSearchParams(msg);
  335. getList(msg);
  336. }
  337. }, [msg]);
  338. // 点击查询
  339. const onSearch = (params) => {
  340. setSearchParams({ ...searchParams, ...params, page: 1 });
  341. getList({ ...searchParams, ...params, page: 1 });
  342. };
  343. const handleReset = () => {
  344. setSearchParams(initSearchParams);
  345. getList(initSearchParams);
  346. };
  347. const changePage = (page) => {
  348. setSearchParams({ ...searchParams, page });
  349. getList({ ...searchParams, page });
  350. };
  351. const checkBatch = (dqzt, nowType) => {
  352. if (selectedRows.length === 0) {
  353. message.warning('请选择办理案件!');
  354. return false;
  355. }
  356. const Nbfs = selectedRows[0].nbfs;
  357. const Blfs = selectedRows[0].blfs;
  358. let showPFSPRows = [];
  359. if (selectedRows.every((item) => item.dqZt === dqzt || AJZT.BJDSP.value && item.nbfs !== null && item.nbfs === Nbfs && item.nbfs !== null && item.nbfs === Nbfs && item.blfs !== null && item.blfs === Blfs )) {
  360. if (nowType === 'sp') { // 批量审批
  361. selectedRows.map(item => {
  362. if (item.sldspsp || item.bjdspsp) {
  363. showPFSPRows.push(item.id);
  364. }
  365. });
  366. if (showPFSPRows.length === selectedRows.length) {
  367. setNowModal(<PFSPBatch ids={showPFSPRows} batchNbfs={Nbfs} sysToken={sysToken} hideModal={hideModal} />)
  368. } else {
  369. message.warning('选择的案件中有不可审批的案件,无法批量审批!')
  370. }
  371. } else if (nowType === 'bj') { // 批量办结
  372. setNowModal(<BJSPBatch ids={selectedRowKeys} batchNbfs={Nbfs} sysToken={sysToken} hideModal={hideModal} />)
  373. }
  374. } else {
  375. message.warning('请选择对应且相同状态下办理方式统一案件进行批量处理!')
  376. }
  377. }
  378. return (
  379. <div>
  380. {/* <p>{props.a}</p> */}
  381. <TopSearch
  382. onSearch={onSearch}
  383. initDateType={initDateType}
  384. // initParams={{ mxmc: 111 }}
  385. changeParams={msg}
  386. handleReset={handleReset}
  387. />
  388. <div style={{ textAlign: 'right', padding: 10, backgroundColor: '#fff', paddingRight: 20 }}>
  389. <Space>
  390. {/* <Button>批量受理派发</Button> */}
  391. <Button type='primary' onClick={() => checkBatch(AJZT.SLDSP.value, 'sp')}>批量受理审批</Button>
  392. {/* <Button>批量办结审批</Button> */}
  393. <HCBGBtn
  394. sysToken={sysToken}
  395. ids={selectedRowKeys}
  396. selectedRowKeys={selectedRows}
  397. handleClearCheck={handleClearCheck}
  398. />
  399. </Space>
  400. </div>
  401. <Table
  402. columns={columns}
  403. dataSource={tableData?.records}
  404. rowKey="id"
  405. rowSelection={rowSelection}
  406. scroll={{ x: 1820 }}
  407. loading={props.loading}
  408. pagination={false}
  409. // current: tableData?.current,
  410. // pageSize: tableData?.size,
  411. // total: tableData?.total,
  412. // onChange: (page) => changePage(page),
  413. // showSizeChanger: true,
  414. // onShowSizeChange: () => this.onShowSizeChange,
  415. // pageSizeOptions: ['10', '20', '50', '100', '500', '1000'],
  416. />
  417. <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
  418. <ExampleBar />
  419. <Pagination
  420. current={tableData?.current || 0}
  421. pageSize={tableData?.size || 0}
  422. total={tableData?.total || 0}
  423. onChange={page => changePage(page)}
  424. showTotal={(total) => `${total}`}
  425. />
  426. </div>
  427. {nowModal && (
  428. <Modal
  429. visible={nowModal}
  430. footer={null}
  431. onCancel={() => setNowModal(null)}
  432. maskClosable={false}
  433. width={1200}
  434. // style={{ height: 'calc(100vh - 100px)' , top: 50, overflowY: 'auto' }}
  435. >
  436. {nowModal}
  437. </Modal>
  438. )}
  439. </div>
  440. );
  441. };
  442. const mapStateToProps = ({ user, doing, loading }) => ({
  443. user: user.currentUser,
  444. doing,
  445. loading:
  446. loading.effects['doing/fetchDoingList'] || loading.effects['doing/fetchReBJCheck'] || false,
  447. });
  448. const mapDispatchToProps = (dispatch) => ({
  449. // 列表
  450. fetchDoingList({ params, sysToken }) {
  451. const chooseTime = {};
  452. if (params.startTime)
  453. chooseTime.startTime = `${params.startTime.format('YYYY-MM-DD')} 00:00:00`;
  454. if (params.endTime) chooseTime.endTime = `${params.endTime.format('YYYY-MM-DD')} 23:59:59`;
  455. return dispatch({
  456. type: 'doing/fetchDoingList',
  457. payload: { params: { ...params, ...chooseTime }, sysToken },
  458. });
  459. },
  460. fetchReBJCheck(params) {
  461. return dispatch({ type: 'doing/fetchReBJCheck', payload: params });
  462. },
  463. setRefresh(params) {
  464. return dispatch({ type: 'doing/setRefresh', payload: params });
  465. }
  466. });
  467. export default connect(mapStateToProps, mapDispatchToProps)(TableList);