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

Maofei94's avatar
Maofei94 committed
59
export default DelModal;