提交 9acad24e 编写于 作者: KK's avatar KK

抽屉组件

上级 aa75fdea
...@@ -21,6 +21,8 @@ export class AppDrawer { ...@@ -21,6 +21,8 @@ export class AppDrawer {
*/ */
private static readonly $drawer = new AppDrawer(); private static readonly $drawer = new AppDrawer();
private $refs :any= {equipmentForm: HTMLFormElement,upload: HTMLFormElement}
/** /**
* 构造方法 * 构造方法
* *
...@@ -75,7 +77,10 @@ export class AppDrawer { ...@@ -75,7 +77,10 @@ export class AppDrawer {
} }
}).$mount(); }).$mount();
this.vueExample = vm; this.vueExample = vm;
document.body.appendChild(vm.$el); let app = document.getElementById("app");
if(app){
app.appendChild(vm.$el);
}
const comp: any = vm.$children[0]; const comp: any = vm.$children[0];
return comp.getSubject(); return comp.getSubject();
} catch (error) { } catch (error) {
......
<template> <template>
<drawer <div class="drawer">
:placement="placement" <div :id="uuid"></div>
:closable="false" <ion-menu
v-model="isShow" :side="placement"
:width="width" :content-id="uuid"
:ref='viewname'
@ionDidClose="close"
@on-visible-change="onVisibleChange($event)"> @on-visible-change="onVisibleChange($event)">
<ion-content>
<component <component
:is="viewname" :is="viewname"
class="viewcontainer2" class="viewcontainer2"
...@@ -16,8 +19,11 @@ ...@@ -16,8 +19,11 @@
@close="close($event)" @close="close($event)"
:ref="viewname"> :ref="viewname">
</component> </component>
</drawer> </ion-content>
</ion-menu>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Vue, Component, Prop, Provide, Emit, Watch } from "vue-property-decorator"; import { Vue, Component, Prop, Provide, Emit, Watch } from "vue-property-decorator";
import { Subject } from "rxjs"; import { Subject } from "rxjs";
...@@ -26,6 +32,7 @@ import { Subject } from "rxjs"; ...@@ -26,6 +32,7 @@ import { Subject } from "rxjs";
}) })
export default class AppDrawerCompponent extends Vue { export default class AppDrawerCompponent extends Vue {
/** /**
* 视图UI参数 * 视图UI参数
* *
...@@ -42,6 +49,14 @@ export default class AppDrawerCompponent extends Vue { ...@@ -42,6 +49,14 @@ export default class AppDrawerCompponent extends Vue {
*/ */
@Prop({ default: {} }) public context?: any; @Prop({ default: {} }) public context?: any;
/**
* 视图上下文
*
* @type {*}
* @memberof AppDrawerCompponent
*/
@Prop() public uuid?: any;
/** /**
* 视图参数 * 视图参数
* *
...@@ -66,13 +81,15 @@ export default class AppDrawerCompponent extends Vue { ...@@ -66,13 +81,15 @@ export default class AppDrawerCompponent extends Vue {
*/ */
public placement: string = ''; public placement: string = '';
/** /**
* 是否显示 * 是否显示
* *
* @type {boolean} * @type {boolean}
* @memberof AppDrawerCompponent * @memberof AppDrawerCompponent
*/ */
public isShow: boolean = false; public isShow: boolean = true;
/** /**
* 零时结果 * 零时结果
...@@ -123,7 +140,7 @@ export default class AppDrawerCompponent extends Vue { ...@@ -123,7 +140,7 @@ export default class AppDrawerCompponent extends Vue {
*/ */
public created() { public created() {
this.viewname = this.view.viewname; this.viewname = this.view.viewname;
this.placement = this.view.placement === 'DRAWER_LEFT' ? 'left' : 'right'; this.placement = this.view.placement === 'DRAWER_LEFT' ? 'start' : 'end';
if (this.view.width) { if (this.view.width) {
if (this.view.width.toString().indexOf('px') > 0) { if (this.view.width.toString().indexOf('px') > 0) {
if (!Object.is(this.view.width, '0px')) { if (!Object.is(this.view.width, '0px')) {
...@@ -157,6 +174,10 @@ export default class AppDrawerCompponent extends Vue { ...@@ -157,6 +174,10 @@ export default class AppDrawerCompponent extends Vue {
public mounted() { public mounted() {
this.isShow = true; this.isShow = true;
this.handleZIndex('ivu-drawer-mask', 'ivu-drawer-wrap'); this.handleZIndex('ivu-drawer-mask', 'ivu-drawer-wrap');
let drawer :any = this.$refs[this.viewname];
if(drawer){
drawer.open()
}
} }
/** /**
...@@ -177,16 +198,16 @@ export default class AppDrawerCompponent extends Vue { ...@@ -177,16 +198,16 @@ export default class AppDrawerCompponent extends Vue {
* @memberof AppDrawerCompponent * @memberof AppDrawerCompponent
*/ */
public handleZIndex(mask: string, wrap: string) { public handleZIndex(mask: string, wrap: string) {
const zIndex = this.$store.getters.getZIndex(); // const zIndex = this.$store.getters.getZIndex();
if (zIndex) { // if (zIndex) {
this.zIndex = zIndex + 100; // this.zIndex = zIndex + 100;
this.$store.commit('updateZIndex', this.zIndex); // this.$store.commit('updateZIndex', this.zIndex);
} // }
const element: Element = this.$el; // const element: Element = this.$el;
const maskTag: any = element.getElementsByClassName(mask)[0]; // const maskTag: any = element.getElementsByClassName(mask)[0];
const warpTag: any = element.getElementsByClassName(wrap)[0]; // const warpTag: any = element.getElementsByClassName(wrap)[0];
maskTag.style.zIndex = this.zIndex; // maskTag.style.zIndex = this.zIndex;
warpTag.style.zIndex = this.zIndex; // warpTag.style.zIndex = this.zIndex;
} }
/** /**
...@@ -199,6 +220,8 @@ export default class AppDrawerCompponent extends Vue { ...@@ -199,6 +220,8 @@ export default class AppDrawerCompponent extends Vue {
Object.assign(this.tempResult, { ret: 'OK' }, { datas: JSON.parse(JSON.stringify(result)) }); Object.assign(this.tempResult, { ret: 'OK' }, { datas: JSON.parse(JSON.stringify(result)) });
} }
this.isShow = false; this.isShow = false;
// (this.$refs.drawer as any).dismiss();
this.onVisibleChange(true);
} }
/** /**
...@@ -238,20 +261,7 @@ export default class AppDrawerCompponent extends Vue { ...@@ -238,20 +261,7 @@ export default class AppDrawerCompponent extends Vue {
this.isShow = true; this.isShow = true;
const title: any = this.$t('app.tabpage.sureclosetip.title'); const title: any = this.$t('app.tabpage.sureclosetip.title');
const contant: any = this.$t('app.tabpage.sureclosetip.content'); const contant: any = this.$t('app.tabpage.sureclosetip.content');
// this.$Modal.confirm({ }
// title: title,
// content: contant,
// onOk: () => {
// this.$store.commit('viewaction/setViewDataChange', { viewtag: _viewtag, viewdatachange: false });
// this.isShow = false;
// },
// onCancel: () => {
// this.isShow = true;
// }
// });
} else {
this.handleShowState($event);
}
} }
} }
...@@ -261,7 +271,7 @@ export default class AppDrawerCompponent extends Vue { ...@@ -261,7 +271,7 @@ export default class AppDrawerCompponent extends Vue {
* @memberof AppDrawerCompponent * @memberof AppDrawerCompponent
*/ */
public handleShowState($event: any) { public handleShowState($event: any) {
if ($event) { if (!$event) {
return; return;
} }
if (this.subject) { if (this.subject) {
...@@ -270,10 +280,12 @@ export default class AppDrawerCompponent extends Vue { ...@@ -270,10 +280,12 @@ export default class AppDrawerCompponent extends Vue {
} }
} }
setTimeout(() => { setTimeout(() => {
console.log(this.$el)
document.body.removeChild(this.$el); document.body.removeChild(this.$el);
this.$destroy(); this.$destroy();
this.subject = null; this.subject = null;
}, 500) }, 500)
} }
} }
</script> </script>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册