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.
92 lines
2.3 KiB
92 lines
2.3 KiB
import api from "@/api"
|
|
import MyTable from "@/components/MyTable"
|
|
import { EditOutlined } from "@ant-design/icons"
|
|
import { Button, Form, Modal, notification } from "antd"
|
|
import TextArea from "antd/lib/input/TextArea"
|
|
import React, { useRef, useState } from "react"
|
|
|
|
const EmailList = () => {
|
|
|
|
const [visible, setVisible] = useState(false)
|
|
const currentItem = useRef({} as any)
|
|
const tableRef = useRef(null)
|
|
const [form] = Form.useForm()
|
|
|
|
const columns = [
|
|
{
|
|
title: '操作',
|
|
width: 100,
|
|
render: (row) => {
|
|
return (
|
|
<div style={{ display: "flex", alignItems: 'center' }}>
|
|
<EditOutlined style={{ marginRight: 20 }} onClick={() => updateNotify(row)} />
|
|
</div>
|
|
);
|
|
}
|
|
},
|
|
{
|
|
title: '标题',
|
|
dataIndex: 'title',
|
|
width: 200
|
|
},
|
|
{
|
|
title: '内容',
|
|
dataIndex: 'content',
|
|
render: (content) => (
|
|
<div style={{ maxWidth: 700 }}>{content}</div>
|
|
)
|
|
}
|
|
]
|
|
|
|
const updateNotify = (item) => {
|
|
currentItem.current = item;
|
|
form.setFieldsValue(item)
|
|
setVisible(true)
|
|
}
|
|
|
|
const onFinish = async (values) => {
|
|
setVisible(false)
|
|
const res: any = await api.update_emailList({
|
|
...values,
|
|
id: currentItem.current.id
|
|
})
|
|
if (res.code === 0) {
|
|
tableRef.current.update()
|
|
form.resetFields()
|
|
notification.success({
|
|
message: "修改成功"
|
|
})
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<MyTable
|
|
apiFun={api.get_emailList}
|
|
columns={columns}
|
|
ref={tableRef}
|
|
/>
|
|
<Modal
|
|
visible={visible}
|
|
onCancel={() => setVisible(false)}
|
|
title={`修改《${currentItem.current.title}》邮件模版`}
|
|
footer={() => null}
|
|
>
|
|
<Form form={form} onFinish={onFinish}>
|
|
<Form.Item label="标题" name="title">
|
|
<TextArea />
|
|
</Form.Item>
|
|
<Form.Item label="内容" name="content">
|
|
<TextArea style={{ minHeight: 200 }} />
|
|
</Form.Item>
|
|
<Form.Item style={{ display: 'flex' }} label="操作">
|
|
<Button onClick={() => setVisible(false)}>取消</Button>
|
|
<Button style={{ marginLeft: 20 }} type="primary" htmlType="submit">确认</Button>
|
|
</Form.Item>
|
|
</Form>
|
|
</Modal>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default EmailList
|