|  | @@ -0,0 +1,115 @@
 | 
	
		
			
				|  |  | +import React, { useRef } from 'react'
 | 
	
		
			
				|  |  | +import { Button, message } from 'antd'
 | 
	
		
			
				|  |  | +import { ModalForm, ProFormRadio, ProFormText } from '@ant-design/pro-form'
 | 
	
		
			
				|  |  | +import type { ProFormColumnsType } from '@ant-design/pro-form'
 | 
	
		
			
				|  |  | +import ProTable from '@ant-design/pro-table'
 | 
	
		
			
				|  |  | +import type { ActionType } from '@ant-design/pro-table'
 | 
	
		
			
				|  |  | +import ShowTitleMenu from '../Attendance/components/ShowTitleMenu'
 | 
	
		
			
				|  |  | +import { useRequest } from 'umi'
 | 
	
		
			
				|  |  | +import { queryNoticeList, sendNotice } from '@/services/user/api'
 | 
	
		
			
				|  |  | +import consts from '@/utils/consts'
 | 
	
		
			
				|  |  | +import { PlusOutlined } from '@ant-design/icons'
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const Notification: React.FC = () => {
 | 
	
		
			
				|  |  | +  const tRef = useRef<ActionType>(null)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  const columns: ProFormColumnsType<API.NoticeItem>[] = [
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +      title: '标题',
 | 
	
		
			
				|  |  | +      dataIndex: 'title',
 | 
	
		
			
				|  |  | +      width: '30%'
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +      title: '内容',
 | 
	
		
			
				|  |  | +      dataIndex: 'content',
 | 
	
		
			
				|  |  | +      width: '50%'
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +      title: '推送时间',
 | 
	
		
			
				|  |  | +      dataIndex: 'createTime',
 | 
	
		
			
				|  |  | +      valueType: 'dateTime'
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  ]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  const { run: trySendNotice } = useRequest(sendNotice, {
 | 
	
		
			
				|  |  | +    manual: true,
 | 
	
		
			
				|  |  | +    onSuccess: () => {
 | 
	
		
			
				|  |  | +      tRef.current?.reload()
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onError: e => {
 | 
	
		
			
				|  |  | +      message.error(e.message)
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  })
 | 
	
		
			
				|  |  | +  return (
 | 
	
		
			
				|  |  | +    <div className="h-full w-full flex flex-row">
 | 
	
		
			
				|  |  | +      <ShowTitleMenu options={[{ label: '通知', value: 1 }]} defaultValue={1} />
 | 
	
		
			
				|  |  | +      <div className="w-max-3/4">
 | 
	
		
			
				|  |  | +        <div className="ml-8 bg-white shadow-md shadow-hex-3e2c5a relative">
 | 
	
		
			
				|  |  | +          {/* <div className="pb-3 border-b border-b-black border-opacity-8 mb-3 flex items-center justify-between">
 | 
	
		
			
				|  |  | +            <div>通知推送</div>
 | 
	
		
			
				|  |  | +          </div> */}
 | 
	
		
			
				|  |  | +          <ProTable
 | 
	
		
			
				|  |  | +            toolbar={{
 | 
	
		
			
				|  |  | +              title: '通知推送'
 | 
	
		
			
				|  |  | +            }}
 | 
	
		
			
				|  |  | +            actionRef={tRef}
 | 
	
		
			
				|  |  | +            columns={columns}
 | 
	
		
			
				|  |  | +            params={{ msgType: 1 }}
 | 
	
		
			
				|  |  | +            search={false}
 | 
	
		
			
				|  |  | +            toolbar={{
 | 
	
		
			
				|  |  | +              actions: [
 | 
	
		
			
				|  |  | +                <ModalForm
 | 
	
		
			
				|  |  | +                  key="modalForm"
 | 
	
		
			
				|  |  | +                  trigger={
 | 
	
		
			
				|  |  | +                    <Button type="primary">
 | 
	
		
			
				|  |  | +                      <PlusOutlined />
 | 
	
		
			
				|  |  | +                      新建通知
 | 
	
		
			
				|  |  | +                    </Button>
 | 
	
		
			
				|  |  | +                  }
 | 
	
		
			
				|  |  | +                  initialValues={{ msgType: 1 }}
 | 
	
		
			
				|  |  | +                  onFinish={async values => {
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                      await trySendNotice(values)
 | 
	
		
			
				|  |  | +                      message.success('添加成功')
 | 
	
		
			
				|  |  | +                      return true
 | 
	
		
			
				|  |  | +                    } catch (error) {
 | 
	
		
			
				|  |  | +                      return false
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                  }}>
 | 
	
		
			
				|  |  | +                  <ProFormText label="标题" name="title" required />
 | 
	
		
			
				|  |  | +                  <ProFormText label="内容" name="content" required />
 | 
	
		
			
				|  |  | +                  <ProFormRadio.Group
 | 
	
		
			
				|  |  | +                    label="类型"
 | 
	
		
			
				|  |  | +                    name="msgType"
 | 
	
		
			
				|  |  | +                    required
 | 
	
		
			
				|  |  | +                    options={[
 | 
	
		
			
				|  |  | +                      { label: '通知', value: 1 },
 | 
	
		
			
				|  |  | +                      { label: '消息', value: 2 }
 | 
	
		
			
				|  |  | +                    ]}></ProFormRadio.Group>
 | 
	
		
			
				|  |  | +                </ModalForm>
 | 
	
		
			
				|  |  | +              ]
 | 
	
		
			
				|  |  | +            }}
 | 
	
		
			
				|  |  | +            request={async (params, sort, filter) => {
 | 
	
		
			
				|  |  | +              const { code = -1, data = {} } = await queryNoticeList({
 | 
	
		
			
				|  |  | +                ...params,
 | 
	
		
			
				|  |  | +                ...sort,
 | 
	
		
			
				|  |  | +                ...filter
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +              const { message: notices = [], total = 0 } = data
 | 
	
		
			
				|  |  | +              return {
 | 
	
		
			
				|  |  | +                data: notices,
 | 
	
		
			
				|  |  | +                success: code === consts.RET_CODE.SUCCESS,
 | 
	
		
			
				|  |  | +                total
 | 
	
		
			
				|  |  | +              }
 | 
	
		
			
				|  |  | +            }}
 | 
	
		
			
				|  |  | +            bordered
 | 
	
		
			
				|  |  | +            pagination={{ defaultPageSize: 10 }}
 | 
	
		
			
				|  |  | +            rowKey={row => row.id}
 | 
	
		
			
				|  |  | +          />
 | 
	
		
			
				|  |  | +        </div>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +    </div>
 | 
	
		
			
				|  |  | +  )
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +export default Notification
 |