| | |
| | | import { PageContainer, ProTable } from '@ant-design/pro-components'; |
| | | import { buildProTableDataSource, sendRequest, showDelConfirm } from '@/utils/antdUtils'; |
| | | import { Button, message, Space, Select } from 'antd'; |
| | | import { useRef, useState } from 'react'; |
| | | import { Button, message, Space, Select, Cascader } from 'antd'; |
| | | import { useRef, useState, useEffect } from 'react'; |
| | | import { Access, history, useAccess } from 'umi'; |
| | | import { getList, setStatus } from './service' |
| | | import { getList, setStatus, getUnitList,systemPostList } from './service' |
| | | import { render } from 'react-dom'; |
| | | const Banner = () => { |
| | | |
| | | const actionRef = useRef(); |
| | | const access = useAccess(); |
| | | const [items, setItems] = useState([]); |
| | | const [positionList, setPositionList] = useState([]); |
| | | |
| | | const columns = [ |
| | | { |
| | |
| | | }, |
| | | { |
| | | title: '所在单位', |
| | | dataIndex: 'department', |
| | | renderFormItem: (_, { type, defaultRender, ...rest }, form) => { |
| | | dataIndex: 'departmentId', |
| | | renderFormItem: () => { |
| | | return ( |
| | | <Select |
| | | key="searchSelect" |
| | | allowClear |
| | | <Cascader |
| | | options={items} |
| | | fieldNames={{ value: 'key', label: 'name' }} |
| | | placeholder="请选择" |
| | | filterOption={false} |
| | | options={[{ label: '市级', value: '1' }, { label: '区县', value: '2' }, { label: '街道', value: '3' }, { label: '社区', value: '4' }, { label: '党员', value: '5' }]} |
| | | > |
| | | </Select > |
| | | ) |
| | | displayRender={(label) => label[label.length - 1]} |
| | | changeOnSelect={true} |
| | | /> |
| | | ); |
| | | }, |
| | | render: (_, record) => { |
| | | return record.department |
| | |
| | | allowClear |
| | | placeholder="请选择" |
| | | filterOption={false} |
| | | options={[{ label: '市级', value: '1' }, { label: '区县', value: '2' }, { label: '街道', value: '3' }, { label: '社区', value: '4' }, { label: '党员', value: '5' }]} |
| | | fieldNames={{ label: 'name', value: 'id' }} |
| | | options={positionList} |
| | | > |
| | | </Select > |
| | | ) |
| | |
| | | title: '诉求应处理时间', |
| | | dataIndex: 'responseTime', |
| | | hideInSearch: true, |
| | | render: (_, record) => { |
| | | return record.responseTime.split('T')[0] |
| | | |
| | | } |
| | | }, |
| | | { |
| | | title: '提示类型', |
| | |
| | | render: (text, record) => { |
| | | return ( |
| | | <Space> |
| | | <Access accessible={access['/message_notification/mark_read']}> |
| | | <Button |
| | | type="link" |
| | | onClick={() => { |
| | | showDelConfirm(async () => { |
| | | let status = await sendRequest(setStatus, record.id) |
| | | if (status) { |
| | | actionRef.current.reload(); |
| | | } |
| | | }, '确认将所选信息标记为已读吗?'); |
| | | }} |
| | | > |
| | | 标记已读 |
| | | </Button> |
| | | </Access> |
| | | {record.readStatus == 0 && ( |
| | | <Access accessible={access['/message_notification/mark_read']}> |
| | | <Button |
| | | type="link" |
| | | onClick={() => { |
| | | showDelConfirm(async () => { |
| | | let status = await sendRequest(setStatus, record.id) |
| | | if (status) { |
| | | actionRef.current.reload(); |
| | | } |
| | | }, '确认将所选信息标记为已读吗?', '确定', '取消', '操作提示'); |
| | | }} |
| | | > |
| | | 标记已读 |
| | | </Button> |
| | | </Access> |
| | | )} |
| | | |
| | | </Space > |
| | | ); |
| | | }, |
| | | }, |
| | | ] |
| | | useEffect(() => { |
| | | fetchUnit(); |
| | | systemPostList({ pageNum: 1, pageSize: 10000 }).then(res => { |
| | | setPositionList(() => res.data.records) |
| | | }) |
| | | }, []); |
| | | |
| | | const fetchUnit = () => { |
| | | getUnitList().then((res) => { |
| | | if (res.code == 200 && res.data) { |
| | | const traverseItems = (items) => { |
| | | return items.map((item) => { |
| | | item.key = item.id; |
| | | item.title = '1'; |
| | | if (item.child && item.child.length > 0) { |
| | | item.children = traverseItems(item.child); |
| | | } |
| | | return item; |
| | | }); |
| | | }; |
| | | setItems(traverseItems(res.data)); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | return <div> |
| | | <PageContainer title='消息通知'> |
| | | <PageContainer title='消息通知' header={{ |
| | | breadcrumb: {}, |
| | | }}> |
| | | <ProTable |
| | | rowKey='id' |
| | | actionRef={actionRef} |
| | |
| | | }} |
| | | search={{ labelWidth: 140 }} |
| | | request={(params) => { |
| | | params.bannerType = Number(params.bannerType) |
| | | if (params.departmentId) { |
| | | params.departmentId = params.departmentId[params.departmentId.length - 1]; |
| | | } |
| | | return buildProTableDataSource(getList, params) |
| | | }} |
| | | toolBarRender={false} |