import React, { useState, useRef, useEffect } from 'react'; import { useIntl, FormattedMessage, useAccess } from '@umijs/max'; import type { FormInstance } from 'antd'; import { Button, message, Modal, Image } from 'antd'; import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components'; import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, RedoOutlined } from '@ant-design/icons'; // import { getNoticeList, removeNotice, addNotice, updateNotice, exportNotice } from '@/services/system/notice'; import { getBiddingDocumentList, saveBiddingDocument, deleteBiddingDocument, pushBiddingDocumentDetail,pushJoinList,pushJoin,pushBiddingDocumentDetailAll } from '@/services/JoinZZ/biddingDocument'; import BiddingDocumentForm from './edit'; import { getDictValueEnum } from '@/services/system/dict'; import moment from 'moment'; import { KeepAlive } from 'react-activation'; import './index.less' import DictTag from '../../../components/DictTag'; import { getDataEnumList } from '../../../services/system/Enum'; const stateEnum = [ { label: '待发布', value: 0 }, { label: '已发布', value: 1 }, ] const NoticeTableList: React.FC = () => { const formTableRef = useRef(); const [modalVisible, setModalVisible] = useState(false); const actionRef = useRef(); const intl = useIntl(); const [currentRow, setCurrentRow] = useState(); const [enumList,setEnumList] = useState() const handleRemoveOne = async (selectedRow: API.System.Notice) => { const hide = message.loading(intl.formatMessage({ id: 'public.loadingDelete' })); if (!selectedRow) return true; try { const params = [selectedRow.uuid]; const resp = await deleteBiddingDocument(params.join(',')); hide(); if (resp.code === 200) { message.success(intl.formatMessage({ id: 'public.deleteSuccess' })); } else { message.error(resp.msg); } return true; } catch (error) { hide(); message.error(intl.formatMessage({ id: 'public.deleteError' })); return false; } }; useEffect(() => { getEnum() }, []) const getEnum = ()=>{ getDataEnumList({ enumUuid: '2024810214616101' }).then((res) => { console.log(res.rows) const enumOptions = res.rows.map((item: any) => ({ label: item.dataName, value: item.uuid, })); setEnumList(enumOptions); // 设置 enumList }) } const columns: ProColumns[] = [ { title: '序号', dataIndex: 'id', valueType: 'text', hideInSearch: true, render: (_, record: any) => { // console.log('record---',_,record) return record.rowIndex; }, }, { title: '标题', dataIndex: 'title', valueType: 'text', }, { title: '展示日期', dataIndex: 'date', valueType: 'text', hideInSearch: true, }, { title: '浏览次数', dataIndex: 'vievNum', valueType: 'text', hideInSearch: true, }, { title: '状态', dataIndex: 'pushStatus', valueType: 'radio', request: async () => stateEnum, render: (_, record) => { return (); }, hideInSearch: true, }, { title: '操作', dataIndex: 'option', width: '120px', valueType: 'option', render: (_, record: any) => [ , , , ], }, ]; /** * 一键发布 */ const publishing = async () => { try { const resp = await pushJoinList(); if (resp.code === 200) { message.success('发布成功'); if(actionRef){ actionRef.current.reload(); } } else { message.error(resp.msg); } } catch (error) { } } return (
actionRef={actionRef} formRef={formTableRef} rowKey="uuid" key="newsList" search={{ labelWidth: 120, }} toolBarRender={() => [ , , ]} request={(params) => { return getBiddingDocumentList({ ...params } as API.System.NoticeListParams).then((res) => { res.rows.forEach((item: any, index: any) => { item.rowIndex = index + 1 }) const result = { data: res.rows, total: res.total, success: true, }; return result; }) } } columns={columns} />
{ let success = false; if (currentRow) { values.uuid = currentRow.uuid; } success = await saveBiddingDocument({ ...values }); if (success) { setModalVisible(false); setCurrentRow(undefined); if (actionRef.current) { actionRef.current.reload(); } } }} onCancel={() => { setModalVisible(false); setCurrentRow(undefined); }} currentRow={currentRow} open={modalVisible} />
); }; export default NoticeTableList;