test-er.vue 2.5 KB
Newer Older
S
1  
shenjizhe 已提交
1 2
<template>
	<view class="box">
S
1  
shenjizhe 已提交
3
		<movable-area ref="contentArea" class="content-window">
S
1  
shenjizhe 已提交
4 5
			<thirdlucky-uml-entity
				v-for="(table, index) in tables"
S
1  
shenjizhe 已提交
6 7
				:x="table.x"
				:y="table.y"
S
1  
shenjizhe 已提交
8
				:key="table.key"
S
1  
shenjizhe 已提交
9
				:entityName="table.entityName"
S
1  
shenjizhe 已提交
10 11
				:title="table.title"
				:columns="table.columns"
12
				:style="{ order: index }"
S
1  
shenjizhe 已提交
13 14 15 16
				@start="onStart"
				@end="onEnd"
			/>
		</movable-area>
S
1  
shenjizhe 已提交
17 18 19 20
		<movable-area ref="toolBar" class="tool-bar">
			<thirdlucky-uml-entity ref="entityTool" entityName="entity" title="实体" @start="onStartTool" @end="onEndTool" />
		</movable-area>
		<view ref="propertyBar" class="property-bar"></view>
S
1  
shenjizhe 已提交
21 22 23 24 25 26 27
	</view>
</template>

<script>
export default {
	data() {
		return {
28
			tables: []
S
1  
shenjizhe 已提交
29 30 31
		};
	},
	methods: {
S
1  
shenjizhe 已提交
32 33 34
		resetTool() {
			this.$refs.entityTool.reset();
		},
35 36
		onStart(key, event, x, y) {
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1  
shenjizhe 已提交
37
		},
38 39
		onEnd(key, event, x, y) {
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1\  
shenjizhe 已提交
40
		},
S
1  
shenjizhe 已提交
41
		onStartTool(key, event, x, y) {
S
1  
shenjizhe 已提交
42
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1  
shenjizhe 已提交
43 44
		},
		onEndTool(key, event, x, y) {
S
1  
shenjizhe 已提交
45 46
			console.log(key + ':' + event + ':' + x + ':' + y);
			this.addEntity(x, y);
S
1  
shenjizhe 已提交
47
		},
S
1  
shenjizhe 已提交
48 49 50 51 52
		addEntity(x, y) {
			let count = this.tables.length;
			let tool = this.$refs.toolBar;
			let w = tool.width;

S
1  
shenjizhe 已提交
53 54 55 56 57
			if(x-w>=0){
				let table = { x: x - w, y: y, title: '实体' + count, entityName: 'test' + count, columns: [] };
				this.tables.push(table);
			}
			
S
1  
shenjizhe 已提交
58 59
			this.resetTool();
		}
S
1  
shenjizhe 已提交
60 61 62 63 64
	}
};
</script>

<style lang="scss">
S
1  
shenjizhe 已提交
65
$window-height: 93vh;
S
1  
shenjizhe 已提交
66
$border-width: 5rpx;
S
1  
shenjizhe 已提交
67 68
$control-width: 200rpx;
$control-height: 200rpx;
S
1  
shenjizhe 已提交
69 70 71 72

.box {
	display: flex;
	flex-direction: row;
S
1  
shenjizhe 已提交
73
	justify-content: space-between;
S
1  
shenjizhe 已提交
74 75
}
.tool-bar {
S
1  
shenjizhe 已提交
76
	order: 1;
77
	width: 10%;
S
1  
shenjizhe 已提交
78 79 80 81 82 83 84
	height: $window-height;
	background-color: #ffffff;
	border-style: solid;
	margin-right: 0;
	border-width: $border-width;
}
.content-window {
S
1  
shenjizhe 已提交
85
	order: 2;
86
	width: 80%;
S
1  
shenjizhe 已提交
87 88
	margin-left: -$border-width;
	height: $window-height;
S
1  
shenjizhe 已提交
89

S
1  
shenjizhe 已提交
90 91
	border-style: solid;
	border-width: $border-width;
S
1  
shenjizhe 已提交
92
	background-color: #e3e3e3;
93 94 95

	display: flex;
	flex-direction: row;
96
	flex-wrap: wrap;
S
1  
shenjizhe 已提交
97 98
}
.property-bar {
S
1  
shenjizhe 已提交
99
	order: 3;
100
	width: 10%;
S
1  
shenjizhe 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
	margin-left: -$border-width;
	height: $window-height;
	background-color: #9d9d9d;
	border-style: solid;
	border-width: $border-width;
}

@keyframes example {
	0% {
		background-color: red;
		left: 0px;
		top: 0px;
	}
	25% {
		background-color: yellow;
		left: 200px;
		top: 0px;
	}
	50% {
		background-color: blue;
		left: 200px;
		top: 200px;
	}
	75% {
		background-color: green;
		left: 0px;
		top: 200px;
	}
	100% {
		background-color: red;
		left: 0px;
		top: 0px;
	}
}
</style>