DelModal.jsx 1.38 KB
Newer Older
Maofei94's avatar
Maofei94 committed
1 2
import React, { useState } from 'react';
import { notification } from 'antd';
3
import SiteModal from '@/components/Modal/SiteModa';
邓超's avatar
邓超 committed
4
import { deleteStation } from '@/services/siteManage/api';
Maofei94's avatar
Maofei94 committed
5 6 7 8 9
const DelModal = props => {
  const { confirmModal, stationId } = props;
  const [loading, setLoading] = useState(false);
  const onSubmit = props => {
    setLoading(true);
10 11
    deleteStation({
      stationID: stationId,
Maofei94's avatar
Maofei94 committed
12 13 14
    })
      .then(res => {
        setLoading(false);
15
        if (res.msg==='') {
Maofei94's avatar
Maofei94 committed
16 17 18 19 20 21 22 23 24 25
          notification.success({
            message: '通知',
            duration: 3,
            description: '删除成功',
          });
          confirmModal();
        } else {
          notification.error({
            message: '提示',
            duration: 3,
26
            description: res.msg,
Maofei94's avatar
Maofei94 committed
27 28 29 30 31
          });
        }
      })
      .catch(err => {
        setLoading(false);
32 33 34
        notification.error({
          message: '提示',
          duration: 3,
Maofei94's avatar
Maofei94 committed
35
          description: err,
36 37
        });
      });
Maofei94's avatar
Maofei94 committed
38 39 40 41 42 43 44
  };
  return (
    <SiteModal
      {...props}
      title="删除站点"
      bodyStyle={{ width: '100%', minHeight: '50px' }}
      style={{ top: 200 }}
45
      width="400px"
Maofei94's avatar
Maofei94 committed
46 47
      destroyOnClose
      cancelText="取消"
Maofei94's avatar
Maofei94 committed
48
      okText="确认"
Maofei94's avatar
Maofei94 committed
49
      onOk={() => onSubmit()}
50 51 52 53
      confirmLoading={loading}
    >
      是否删除该站点?
    </SiteModal>
Maofei94's avatar
Maofei94 committed
54 55
  );
};
56

Maofei94's avatar
Maofei94 committed
57
export default DelModal;