/** * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug * Copyright (c) * Released under the AGPL-3.0 License. */ import React, { useState } from 'react'; import { observer } from 'mobx-react'; import { Modal, Form, Input, Tooltip, message } from 'antd'; import { ThunderboltOutlined, LoadingOutlined } from '@ant-design/icons'; import http from 'libs/http'; import store from './store'; export default observer(function () { const [form] = Form.useForm(); const [loading, setLoading] = useState(false); const [testLoading, setTestLoading] = useState('0'); function handleSubmit() { setLoading(true); const formData = form.getFieldsValue(); formData['id'] = store.record.id; http.post('/api/alarm/contact/', formData) .then(res => { message.success('操作成功'); store.formVisible = false; store.fetchRecords() }, () => setLoading(false)) } function handleTest(mode, name) { const value = form.getFieldValue(name) if (!value) return message.error('请输入后再执行测试') setTestLoading(mode) http.post('/api/alarm/test/', {mode, value}) .then(() => { message.success('执行成功') }) .finally(() => setTestLoading('0')) } function Test(props) { return (
{testLoading === props.mode ? ( ) : ( handleTest(props.mode, props.name)}/> )}
) } return ( store.formVisible = false} confirmLoading={loading} onOk={handleSubmit}>
钉钉收不到通知?请参考 官方文档 }>
) })