2019-01-12 03:33:27 +00:00
|
|
|
import Dialog from './Dialog';
|
|
|
|
import getDialogPropTypes from './IDialogPropTypes';
|
2020-05-13 10:36:53 +00:00
|
|
|
import Portal from '../_util/PortalWrapper';
|
2020-06-15 10:55:12 +00:00
|
|
|
import { getSlot } from '../_util/props-util';
|
2020-10-12 05:27:16 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2019-01-12 03:33:27 +00:00
|
|
|
const IDialogPropTypes = getDialogPropTypes();
|
2020-10-12 05:27:16 +00:00
|
|
|
const DialogWrap = defineComponent({
|
2020-01-18 09:06:09 +00:00
|
|
|
inheritAttrs: false,
|
2018-03-05 11:05:23 +00:00
|
|
|
props: {
|
|
|
|
...IDialogPropTypes,
|
|
|
|
visible: IDialogPropTypes.visible.def(false),
|
|
|
|
},
|
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
2020-05-13 10:36:53 +00:00
|
|
|
const { visible, getContainer, forceRender } = this.$props;
|
2020-06-15 10:55:12 +00:00
|
|
|
let dialogProps = {
|
|
|
|
...this.$props,
|
|
|
|
...this.$attrs,
|
2020-05-13 10:36:53 +00:00
|
|
|
ref: '_component',
|
|
|
|
key: 'dialog',
|
|
|
|
};
|
|
|
|
// 渲染在当前 dom 里;
|
|
|
|
if (getContainer === false) {
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
{...dialogProps}
|
|
|
|
getOpenCount={() => 2} // 不对 body 做任何操作。。
|
|
|
|
>
|
2020-06-15 10:55:12 +00:00
|
|
|
{getSlot(this)}
|
2020-05-13 10:36:53 +00:00
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
2018-03-05 11:05:23 +00:00
|
|
|
return (
|
2020-05-13 10:36:53 +00:00
|
|
|
<Portal
|
2018-03-05 11:05:23 +00:00
|
|
|
visible={visible}
|
2020-05-13 10:36:53 +00:00
|
|
|
forceRender={forceRender}
|
|
|
|
getContainer={getContainer}
|
2021-09-25 08:51:32 +00:00
|
|
|
v-slots={{
|
|
|
|
default: childProps => {
|
|
|
|
dialogProps = { ...dialogProps, ...childProps };
|
|
|
|
return <Dialog {...dialogProps}>{getSlot(this)}</Dialog>;
|
|
|
|
},
|
2018-03-05 11:05:23 +00:00
|
|
|
}}
|
2018-03-05 14:50:25 +00:00
|
|
|
/>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2018-03-05 11:05:23 +00:00
|
|
|
},
|
2020-10-12 05:27:16 +00:00
|
|
|
});
|
2018-03-05 11:05:23 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
export default DialogWrap;
|