import React from 'react';
import { ModalForm, ProForm, ProFormText } from '@ant-design/pro-components';
import { upsertSmsSign } from '@/services/op-admin/message/sms';
import { message } from 'antd';


/**
 * @author bianlanzhou
 * @since 2024-09-24
 * @desc 创建/修改modal窗口
 */

class UpsertSmsSignatureModalForm extends React.Component<UpsertSmsSignatureModalFormProp> {
  render() {
    /** 提交方法 */
    const handleSubmit = (value: SMS.SignatureUpsertCmd) => {
      if (this.props.data) {
        value.id = this.props.data.id;
      }
      return upsertSmsSign(value).then(() => {
        message.success("操作成功!")
        this.props.callback();
        return true;
      }).catch((err) => {
        console.log(err)
        return false;
      });
    }
    return (
      <ModalForm<SMS.SignatureUpsertCmd>
        trigger={this.props.trigger}
        title="短信签名"
        onFinish={handleSubmit}
        initialValues={
          this.props.data
        }
      >
        <ProForm.Group >
          <ProFormText
            width="md"
            name="signatureName"
            label="签名名称"
            rules={[
              {
                required: true,
                message: '请填写签名名称',
              },
            ]}
            placeholder="请填写签名名称"
            required
          />
          <ProFormText
            width="md"
            name="signatureContent"
            label="签名内容"
            rules={[
              {
                required: true,
                message: '请填写签名内容',
              },
            ]}
            placeholder="请填写签名内容"
            required
          />
        </ProForm.Group>
      </ModalForm >
    );
  }
}
export default UpsertSmsSignatureModalForm;