import React, { useState, useEffect } from 'react'; import { connect } from 'umi'; import { Button, Table, Popconfirm, message } from 'antd'; import { CzqkList } from '@/utils/constants'; import FormModal from './FormModal'; import styles from './index.less'; const CZBtn = (props) => { const { id, sysToken, fetchAJCZtable, fetchAddAJCZ, fetchDeleteAJCZ, fetchDownloadFile, fetchOrgTreeData, fetchOrgDataByName, CZLX, onlyRead, loading, } = props; const [visible, setVisible] = useState(false); const [tableData, setTableData] = useState([]); // const [CZLX, setCZLX] = useState([]); const handleOpenModal = () => { // fetchDictCZLX(sysToken).then((res) => { // if (res && res.resCode === 0) { // setCZLX(res.data); // setVisible(true); // } // }); setVisible(true); }; const handleCloseModal = () => { setVisible(false); }; const handleGetTable = () => { fetchAJCZtable({ id, sysToken }).then((res) => { setTableData(res); }); }; const handleDelete = (id) => { fetchDeleteAJCZ({ id, sysToken }).then((res) => { if (res && res.resCode === 0) { message.success(res.resMsg); handleGetTable(); } else { message.error(res.resMsg); } }); }; useEffect(() => { handleGetTable(); // fetchCzlx(); }, []); // 下载文件 const handleDownload = (file) => { const params = { mc: file.wjMc, path: file.wjPath, url: file.wjUrl, }; fetchDownloadFile({ params, sysToken }); }; const getCZLXMc = (text) => { const p = []; CZLX?.forEach((item) => { if (item.id === Number(text)) { p.push(item.mc); } }); return p[0]; }; const columns = [ { title: '处置类型', dataIndex: 'czlx', key: '', render: (text) => { return {getCZLXMc(text)}; }, }, { title: '处置情况', dataIndex: 'czqk', width: '10%', render: (text) => CzqkList.filter((i) => i.value === String(text))[0]?.text, }, { title: '情况说明', dataIndex: 'qksm', width: '15%', }, { title: '姓名', dataIndex: 'czMc', key: 'czMc', }, { title: '身份证号', dataIndex: 'czSfz', key: 'czSfz', }, { title: '警号', dataIndex: 'czJh', key: 'czJh', }, { title: '单位', dataIndex: 'czDw', key: 'czDw', }, { title: '法律文书', dataIndex: 'flwsMc', key: 'flwsMc', render: (text, record) => { return record?.wjList?.map((file, index) => { return ( handleDownload(file)}> {file.wjMc} {index === record?.wjList?.length - 1 ? '' : ';'} ); }); }, }, { title: '操作', key: 'action', render: (text, record) => { if (onlyRead) { return ( 删除 ); } else { return ( handleDelete(record.id)} okText="确定" cancelText="取消" > 删除 ); } }, }, ]; return (
处置明细
{!onlyRead && (
)}
{visible && ( )} ); }; const mapStateToProps = ({ doing, global, loading }) => ({ ...doing, ...global, loading: loading.effects['doing/fetchAddAJCZ'] || false, }); const mapDispatchToProps = (dispatch) => ({ fetchAJCZtable(params) { return dispatch({ type: 'doing/fetchAJCZtable', payload: { ...params } }); }, fetchAddAJCZ(params) { return dispatch({ type: 'doing/fetchAddAJCZ', payload: { ...params } }); }, fetchDeleteAJCZ(params) { return dispatch({ type: 'doing/fetchDeleteAJCZ', payload: { ...params } }); }, fetchDownloadFile(params) { return dispatch({ type: 'doing/fetchDownloadFile', payload: { ...params } }); }, fetchOrgTreeData(params) { return dispatch({ type: 'global/fetchOrgTreeData', payload: { ...params } }); }, fetchOrgDataByName(params) { return dispatch({ type: 'global/fetchOrgDataByName', payload: { ...params } }); }, }); export default connect(mapStateToProps, mapDispatchToProps)(CZBtn);