2019-04-17 10:21:28 +08:00
|
|
|
import Modal, { destroyFns } from './Modal';
|
2019-01-12 11:33:27 +08:00
|
|
|
import modalConfirm from './confirm';
|
2020-03-24 16:58:53 +08:00
|
|
|
import InfoCircleOutlined from '@ant-design/icons-vue/InfoCircleOutlined';
|
|
|
|
import CheckCircleOutlined from '@ant-design/icons-vue/CheckCircleOutlined';
|
|
|
|
import CloseCircleOutlined from '@ant-design/icons-vue/CloseCircleOutlined';
|
|
|
|
import ExclamationCircleOutlined from '@ant-design/icons-vue/ExclamationCircleOutlined';
|
2019-08-28 10:50:19 +08:00
|
|
|
import Base from '../base';
|
2018-03-06 19:14:41 +08:00
|
|
|
|
|
|
|
// export { ActionButtonProps } from './ActionButton'
|
|
|
|
// export { ModalProps, ModalFuncProps } from './Modal'
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
const info = function(props) {
|
2018-03-06 19:14:41 +08:00
|
|
|
const config = {
|
|
|
|
type: 'info',
|
2019-05-28 11:37:38 +08:00
|
|
|
icon: h => {
|
2020-03-24 16:58:53 +08:00
|
|
|
return <InfoCircleOutlined />;
|
2019-05-13 19:09:21 +08:00
|
|
|
},
|
2018-03-06 19:14:41 +08:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
2018-03-06 19:14:41 +08:00
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
const success = function(props) {
|
2018-03-06 19:14:41 +08:00
|
|
|
const config = {
|
|
|
|
type: 'success',
|
2019-05-28 11:37:38 +08:00
|
|
|
icon: h => {
|
2020-03-24 16:58:53 +08:00
|
|
|
return <CheckCircleOutlined />;
|
2019-05-13 19:09:21 +08:00
|
|
|
},
|
2018-03-06 19:14:41 +08:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
2018-03-06 19:14:41 +08:00
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
const error = function(props) {
|
2018-03-06 19:14:41 +08:00
|
|
|
const config = {
|
|
|
|
type: 'error',
|
2019-05-28 11:37:38 +08:00
|
|
|
icon: h => {
|
2020-03-24 16:58:53 +08:00
|
|
|
return <CloseCircleOutlined />;
|
2019-05-13 19:09:21 +08:00
|
|
|
},
|
2018-03-06 19:14:41 +08:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
2018-03-06 19:14:41 +08:00
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
const warning = function(props) {
|
2018-03-06 19:14:41 +08:00
|
|
|
const config = {
|
|
|
|
type: 'warning',
|
2019-05-28 11:37:38 +08:00
|
|
|
icon: h => {
|
2020-03-24 16:58:53 +08:00
|
|
|
return <ExclamationCircleOutlined />;
|
2019-05-13 19:09:21 +08:00
|
|
|
},
|
2018-03-06 19:14:41 +08:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
|
|
|
const warn = warning;
|
2018-03-06 19:14:41 +08:00
|
|
|
|
2020-03-07 19:45:13 +08:00
|
|
|
const confirm = function confirmFn(props) {
|
2018-03-06 19:14:41 +08:00
|
|
|
const config = {
|
|
|
|
type: 'confirm',
|
|
|
|
okCancel: true,
|
|
|
|
...props,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
|
|
|
Modal.info = info;
|
|
|
|
Modal.success = success;
|
|
|
|
Modal.error = error;
|
|
|
|
Modal.warning = warning;
|
|
|
|
Modal.warn = warn;
|
|
|
|
Modal.confirm = confirm;
|
2018-03-06 19:14:41 +08:00
|
|
|
|
2020-03-07 19:45:13 +08:00
|
|
|
Modal.destroyAll = function destroyAllFn() {
|
2019-04-17 10:21:28 +08:00
|
|
|
while (destroyFns.length) {
|
|
|
|
const close = destroyFns.pop();
|
|
|
|
if (close) {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-19 13:21:57 +08:00
|
|
|
/* istanbul ignore next */
|
2019-01-12 11:33:27 +08:00
|
|
|
Modal.install = function(Vue) {
|
2019-08-28 10:50:19 +08:00
|
|
|
Vue.use(Base);
|
2019-01-12 11:33:27 +08:00
|
|
|
Vue.component(Modal.name, Modal);
|
|
|
|
};
|
2018-09-19 13:21:57 +08:00
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export default Modal;
|