
3 changed files with 236 additions and 152 deletions
-
181src/tis_app_template_kt/src/components/Dialog/DialogPc.vue
-
171src/tis_app_template_kt/src/components/Dialog/Pc.vue
-
36src/tis_app_template_kt/src/tis/bus.js
@ -1,159 +1,38 @@ |
|||||
<template> |
<template> |
||||
<VueDragResize v-show="centerDialogVisible" :isDraggable="isDraggable" parentLimitation :isResizable="isResizable" |
|
||||
ref="dragEl" |
|
||||
:parentW="parentW" |
|
||||
:parentH="parentH" :minh="minh" :minw="minw" |
|
||||
:z="400" |
|
||||
:x="left" |
|
||||
:y="top" |
|
||||
:w="width" |
|
||||
:h="height" |
|
||||
v-on:resizing="resize" |
|
||||
v-on:dragging="resize" class="drag-container"> |
|
||||
<div class="header"> |
|
||||
<span>{{DialogWidget && DialogWidget.name}}</span> |
|
||||
<div class="action"> |
|
||||
<div class="maxsize" @click='onMaxSize'>最大化</div> |
|
||||
<div class="minisize" @click="minisize">最小化</div> |
|
||||
<div class="close" @click="onClose">关闭</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
<component |
|
||||
class="content" |
|
||||
@onShow="onShow" |
|
||||
@onClose="onClose" |
|
||||
:is="DialogWidget && actives"></component> |
|
||||
</VueDragResize> |
|
||||
|
<div> |
||||
|
<Pc v-for="(dialog, index) in list" :key="dialog.component" :dialog="dialog" /> |
||||
|
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
//import VueDragResize from "../vueDragResize/vue-drag-resize.vue"; |
|
||||
import VueDragResize from 'vue-drag-resize' |
|
||||
import {dialogMixins} from './dialogMixins' |
|
||||
import bus from '../../tis/bus' |
|
||||
|
|
||||
export default { |
|
||||
name: "DialogPc", |
|
||||
mixins: [dialogMixins], |
|
||||
components: { |
|
||||
VueDragResize, |
|
||||
}, |
|
||||
computed: { |
|
||||
parentW() { |
|
||||
return window.outerWidth; |
|
||||
}, |
|
||||
parentH() { |
|
||||
return window.outerHeight; |
|
||||
}, |
|
||||
isDraggable() { |
|
||||
return true; |
|
||||
}, |
|
||||
isResizable() { |
|
||||
return true; |
|
||||
}, |
|
||||
isTitle() { |
|
||||
return true; |
|
||||
}, |
|
||||
minh() { |
|
||||
return 40; |
|
||||
}, |
|
||||
minw() { |
|
||||
return 280; |
|
||||
}, |
|
||||
}, |
|
||||
data() { |
|
||||
|
|
||||
return { |
|
||||
isMax:false, |
|
||||
isDestory:false, |
|
||||
showSizeChoice: false, |
|
||||
curWidth:600, |
|
||||
curHeight:500, |
|
||||
width: Math.round(window.innerWidth * .6), |
|
||||
height: Math.round(window.innerHeight * .6), |
|
||||
top: Math.round(window.innerHeight * .2), |
|
||||
left: Math.round(window.innerWidth * .2), |
|
||||
}; |
|
||||
}, |
|
||||
methods: { |
|
||||
resize(newRect) { |
|
||||
this.width = newRect.width; |
|
||||
this.height = newRect.height; |
|
||||
this.top = newRect.top; |
|
||||
this.left = newRect.left; |
|
||||
|
|
||||
this.curWidth = newRect.width; |
|
||||
this.curHeight = newRect.height; |
|
||||
}, |
|
||||
onMaxSize(){ |
|
||||
this.$refs.dragEl.$el.style.left = 0 |
|
||||
this.$refs.dragEl.$el.style.top = 0 |
|
||||
const $contentEl = this.$refs.dragEl.$el.firstChild |
|
||||
$contentEl.style.width = window.innerWidth + 'px' |
|
||||
$contentEl.style.height = window.innerHeight + 'px' |
|
||||
return; |
|
||||
this.isMax = !this.isMax; |
|
||||
this.left = 0 |
|
||||
this.top = 0 |
|
||||
this.$nextTick(() => { |
|
||||
this.width = window.innerWidth |
|
||||
this.height = window.innerHeight |
|
||||
}) |
|
||||
}, |
|
||||
minisize() { |
|
||||
this.centerDialogVisible = false; |
|
||||
this.$tis.minimizeComponent(this.actives) |
|
||||
}, |
|
||||
onClose() { |
|
||||
this.centerDialogVisible = false; |
|
||||
this.$tis.closeComponent([this.actives]); |
|
||||
}, |
|
||||
toggle() { |
|
||||
this.showSizeChoice = !this.showSizeChoice; |
|
||||
}, |
|
||||
onChangeSize() { |
|
||||
this.resize({ |
|
||||
width: this.width, |
|
||||
height: this.height, |
|
||||
top: this.top, |
|
||||
left: this.left, |
|
||||
}); |
|
||||
}, |
|
||||
} |
|
||||
|
import Pc from './Pc' |
||||
|
export default { |
||||
|
name: 'DialogPc', |
||||
|
components: { Pc }, |
||||
|
data() { |
||||
|
return { |
||||
} |
} |
||||
</script> |
|
||||
|
|
||||
<style lang="scss" scoped> |
|
||||
.header { |
|
||||
|
|
||||
height: 40px; |
|
||||
background: rgba(0,0,0,.5); |
|
||||
align-items: center; |
|
||||
display: flex; |
|
||||
justify-content: space-between; |
|
||||
color: white; |
|
||||
padding: 0 10px; |
|
||||
.action{ |
|
||||
display: flex; |
|
||||
|
|
||||
&>div{ |
|
||||
margin: 0 5px; |
|
||||
cursor: pointer; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
.content{ |
|
||||
flex: 1; |
|
||||
overflow-y: auto; |
|
||||
background: #fff; |
|
||||
::v-deep { |
|
||||
.footer:after { |
|
||||
content: ''; |
|
||||
clear: both; |
|
||||
|
}, |
||||
|
asyncComputed: { |
||||
|
list: { |
||||
|
async get() { |
||||
|
const list = this.$tis.getActivesByType('PopupWidget') |
||||
|
for (let component of list) { |
||||
|
if (typeof component.component === 'string') { |
||||
|
await this.$tis.loadComponent(component.component) |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
|
let newList = list.map(v => ({ component: v.component.name || v.component, status: v.status, name: v.name, zIndex: v.zIndex })) |
||||
|
console.log(newList, '---') |
||||
|
return newList |
||||
|
}, |
||||
|
default() { |
||||
|
return [] |
||||
|
} |
||||
} |
} |
||||
.drag-container { |
|
||||
border: 1px solid #ddd; |
|
||||
} |
|
||||
</style> |
|
||||
|
}, |
||||
|
methods: { |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,171 @@ |
|||||
|
<template> |
||||
|
<VueDragResize v-show="dialog.status !== 'minimize'" :isDraggable="isDraggable" parentLimitation :isResizable="isResizable" |
||||
|
ref="dragEl" |
||||
|
:parentW="parentW" |
||||
|
:parentH="parentH" :minh="minh" :minw="minw" |
||||
|
:z="dialog.zIndex" |
||||
|
:x="left" |
||||
|
:y="top" |
||||
|
:w="width" |
||||
|
:h="height" |
||||
|
@click="activeComponent" |
||||
|
v-on:resizing="resize" |
||||
|
v-on:dragging="resize" class="drag-container"> |
||||
|
<div class="header"> |
||||
|
<span>{{dialog && dialog.name}}</span> |
||||
|
<div class="action"> |
||||
|
<div class="maxsize" @click='onMaxSize'>最大化</div> |
||||
|
<div class="minisize" @click="minisize">最小化</div> |
||||
|
<div class="close" @click="onClose">关闭</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<component |
||||
|
class="content" |
||||
|
@onShow="onShow" |
||||
|
@onClose="onClose" |
||||
|
:is="dialog.component"></component> |
||||
|
</VueDragResize> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
//import VueDragResize from "../vueDragResize/vue-drag-resize.vue"; |
||||
|
import VueDragResize from 'vue-drag-resize' |
||||
|
//import {dialogMixins} from './dialogMixins' |
||||
|
|
||||
|
export default { |
||||
|
props: { |
||||
|
dialog: { |
||||
|
type: Object, |
||||
|
default: function () { |
||||
|
return {} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
//mixins: [dialogMixins], |
||||
|
components: { |
||||
|
VueDragResize, |
||||
|
}, |
||||
|
computed: { |
||||
|
parentW() { |
||||
|
return window.outerWidth; |
||||
|
}, |
||||
|
parentH() { |
||||
|
return window.outerHeight; |
||||
|
}, |
||||
|
isDraggable() { |
||||
|
return true; |
||||
|
}, |
||||
|
isResizable() { |
||||
|
return true; |
||||
|
}, |
||||
|
isTitle() { |
||||
|
return true; |
||||
|
}, |
||||
|
minh() { |
||||
|
return 40; |
||||
|
}, |
||||
|
minw() { |
||||
|
return 280; |
||||
|
}, |
||||
|
}, |
||||
|
data() { |
||||
|
|
||||
|
return { |
||||
|
isMax:false, |
||||
|
isDestory:false, |
||||
|
showSizeChoice: false, |
||||
|
curWidth:600, |
||||
|
curHeight:500, |
||||
|
width: Math.round(window.innerWidth * .6), |
||||
|
height: Math.round(window.innerHeight * .6), |
||||
|
top: Math.round(window.innerHeight * .2), |
||||
|
left: Math.round(window.innerWidth * .2), |
||||
|
}; |
||||
|
}, |
||||
|
methods: { |
||||
|
resize(newRect) { |
||||
|
this.width = newRect.width; |
||||
|
this.height = newRect.height; |
||||
|
this.top = newRect.top; |
||||
|
this.left = newRect.left; |
||||
|
|
||||
|
this.curWidth = newRect.width; |
||||
|
this.curHeight = newRect.height; |
||||
|
}, |
||||
|
onMaxSize(){ |
||||
|
this.$refs.dragEl.$el.style.left = 0 |
||||
|
this.$refs.dragEl.$el.style.top = 0 |
||||
|
const $contentEl = this.$refs.dragEl.$el.firstChild |
||||
|
$contentEl.style.width = window.innerWidth + 'px' |
||||
|
$contentEl.style.height = window.innerHeight + 'px' |
||||
|
return; |
||||
|
this.isMax = !this.isMax; |
||||
|
this.left = 0 |
||||
|
this.top = 0 |
||||
|
this.$nextTick(() => { |
||||
|
this.width = window.innerWidth |
||||
|
this.height = window.innerHeight |
||||
|
}) |
||||
|
}, |
||||
|
minisize() { |
||||
|
console.log(this.dialog) |
||||
|
this.$tis.minimizeComponent(this.dialog.component) |
||||
|
}, |
||||
|
onClose() { |
||||
|
this.centerDialogVisible = false; |
||||
|
this.$tis.closeComponent([this.dialog.component]); |
||||
|
}, |
||||
|
toggle() { |
||||
|
this.showSizeChoice = !this.showSizeChoice; |
||||
|
}, |
||||
|
onChangeSize() { |
||||
|
this.resize({ |
||||
|
width: this.width, |
||||
|
height: this.height, |
||||
|
top: this.top, |
||||
|
left: this.left, |
||||
|
}); |
||||
|
}, |
||||
|
onShow() { |
||||
|
}, |
||||
|
activeComponent() { |
||||
|
this.$tis.activeComponent(this.dialog.component) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.header { |
||||
|
|
||||
|
height: 40px; |
||||
|
background: rgba(0,0,0,.5); |
||||
|
align-items: center; |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
color: white; |
||||
|
padding: 0 10px; |
||||
|
.action{ |
||||
|
display: flex; |
||||
|
|
||||
|
&>div{ |
||||
|
margin: 0 5px; |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
.content{ |
||||
|
flex: 1; |
||||
|
overflow-y: auto; |
||||
|
background: #fff; |
||||
|
::v-deep { |
||||
|
.footer:after { |
||||
|
content: ''; |
||||
|
clear: both; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
.drag-container { |
||||
|
border: 1px solid #ddd; |
||||
|
} |
||||
|
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue