UNPKG

@aliretail/react-materials-components

Version:
61 lines (54 loc) 1.75 kB
import _Dialog from "@alifd/next/es/dialog"; import _Loading from "@alifd/next/es/loading"; import _Message from "@alifd/next/es/message"; import * as React from 'react'; import { requestByItem } from "../utils"; var DeleteDialog = function DeleteDialog(props) { var requestItem = props.requestItem, visible = props.visible, setVisible = props.setVisible, deleteValue = props.deleteValue, deleteKey = props.deleteKey, getList = props.getList; var _React$useState = React.useState(false), loading = _React$useState[0], setLoading = _React$useState[1]; var onCloseDialog = function onCloseDialog() { setVisible(false); }; var onSubmit = function onSubmit() { try { setLoading(true); // 从接口刪除 requestByItem(requestItem, { key: deleteKey }).then(function (res) { if (res.result.success) { _Message.show({ type: 'success', content: '删除成功!' }); } }); } catch (e) { console.warn('error', e); } finally { setLoading(false); getList(); onCloseDialog(); } }; return /*#__PURE__*/React.createElement(_Dialog, { title: "\u5220\u9664", visible: visible, onCancel: onCloseDialog, onClose: onCloseDialog, onOk: onSubmit }, /*#__PURE__*/React.createElement(_Loading, { visible: loading }, /*#__PURE__*/React.createElement(_Message, { title: "\u786E\u8BA4\u8981\u5220\u9664[" + deleteValue + "]\u5206\u7EC4\u5417\uFF1F", type: "warning", shape: "addon" }, "\u5220\u9664\u540E\uFF0C\u8BE5\u5206\u7EC4\u4E0B\u7684\u5B50\u5206\u7EC4\u4E5F\u5C06\u88AB\u5220\u9664\u3002"))); }; export default DeleteDialog;