index.min.js 2.8 KB

1
  1. "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Modal=exports.modal=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_modal=_interopRequireWildcard(require("./src/modal")),_vXETable=_interopRequireDefault(require("../v-x-e-table"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function(){return e},e}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!==_typeof(e)&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var o,r,l={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&((r=a?Object.getOwnPropertyDescriptor(e,o):null)&&(r.get||r.set)?Object.defineProperty(l,o,r):l[o]=e[o]);return l.default=e,t&&t.set(e,l),l}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var ModalClass=null;function openModal(e){var l=Object.assign({},e,{transfer:!0});return new Promise(function(t){var o,r;l&&l.id&&_modal.allActivedModals.some(function(e){return e.id===l.id})?t("exist"):(o=l.events||{},l.events=Object.assign({},o,{hide:function(e){o.hide&&o.hide.call(this,e),setTimeout(function(){return r.$destroy()},r.isMsg?500:100),t(e.type)}}),r=new ModalClass({el:document.createElement("div"),propsData:l}),setTimeout(function(){r.isDestroy?r.close():r.open()}))})}function closeModal(e){return(arguments.length?[getModal(e)]:_modal.allActivedModals).forEach(function(e){e&&(e.isDestroy=!0,e.close("close"))}),Promise.resolve()}function getModal(t){return _xeUtils.default.find(_modal.allActivedModals,function(e){return e.id===t})}var ModalController={get:getModal,close:closeModal,open:openModal},modal=ModalController;exports.modal=ModalController;var shortcutTypes=["alert","confirm","message"];shortcutTypes.forEach(function(l,a){var n=2===a?{mask:!1,lockView:!1,showHeader:!1}:{showFooter:!0};n.type=l,n.dblclickZoom=!1,1===a&&(n.status="question"),ModalController[l]=function(e,t,o){var r;return _xeUtils.default.isObject(e)?r=e:t&&(r=2===a?{status:t}:{title:t}),openModal(Object.assign({message:_xeUtils.default.toValueString(e),type:l},n,r,o))}});var Modal=Object.assign(_modal.default,{install:function(e){_vXETable.default._modal=1,e.component(_modal.default.name,_modal.default),ModalClass=e.extend(_modal.default),_vXETable.default.modal=ModalController,e.prototype.$vxe?e.prototype.$vxe.modal=ModalController:e.prototype.$vxe={modal:ModalController}}}),_default=exports.Modal=Modal;exports.default=Modal;