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

Maofei94's avatar
Maofei94 committed
65
export default DelModal;