OrderNotesEditModal.tsx 1.29 KB
import { RESPONSE_CODE } from '@/constants/enum';
import { postServiceOrderNotesEdit } from '@/services';
import { ModalForm, ProFormTextArea } from '@ant-design/pro-components';
import { Form, message } from 'antd';
export default ({ setNotesEditVisible, notes, ids, notesType, onClose }) => {
  const [form] = Form.useForm<{ name: string; company: string }>();
  return (
    <ModalForm<{
      name: string;
      company: string;
    }>
      width={500}
      open
      title="修改备注"
      form={form}
      autoFocusFirstInput
      modalProps={{
        okText: '保存',
        cancelText: '取消',
        destroyOnClose: true,
        onCancel: () => {
          setNotesEditVisible(false);
        },
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
        let body = {
          id: ids[0],
          notes: values.name,
          notesType: notesType,
        };
        const res = await postServiceOrderNotesEdit({ data: body });
        if (res.result === RESPONSE_CODE.SUCCESS) {
          message.success(res.message);
          onClose();
        }
      }}
      onOpenChange={setNotesEditVisible}
    >
      <ProFormTextArea
        width="lg"
        name="name"
        initialValue={notes}
        placeholder="填写备注内容"
      />
    </ModalForm>
  );
};