DelModal.jsx 1.48 KB
Newer Older
1 2 3
import React, { useState } from 'react';
import { notification } from 'antd';
import SiteModal from '@/components/Modal/SiteModa';
邓超's avatar
邓超 committed
4
import { deleteRole } from '@/services/RoleManage/api';
5
const DelModal = props => {
Maofei94's avatar
Maofei94 committed
6
  const { confirmModal, itemObj } = props;
7 8 9
  const [loading, setLoading] = useState(false);
  const onSubmit = props => {
    setLoading(true);
Maofei94's avatar
Maofei94 committed
10 11
    deleteRole({
      roleID: itemObj.roleID || '',
12 13 14
    })
      .then(res => {
        setLoading(false);
15
        if (res.msg==='') {
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,
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
          });
        }
      })
      .catch(err => {
        setLoading(false);
        notification.error({
          message: '提示',
          duration: 3,
          description: err,
        });
      });
  };
  return (
    <SiteModal
      {...props}
      title="删除角色"
      bodyStyle={{ width: '100%', minHeight: '50px' }}
      style={{ top: 200 }}
      width="400px"
      destroyOnClose
      cancelText="取消"
Maofei94's avatar
Maofei94 committed
48
      okText="确认"
49 50 51
      onOk={() => onSubmit()}
      confirmLoading={loading}
    >
Maofei94's avatar
Maofei94 committed
52 53 54 55 56
      是否删除角色
      <span style={{ color: 'red' }}>
        {itemObj.roleName && itemObj.roleName}
      </span>
      ?
57 58 59 60 61
    </SiteModal>
  );
};

export default DelModal;