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

<script>
S
1  
shenjizhe 已提交
26 27 28
let defaultX = 20;
let defaultY = 20;

S
1  
shenjizhe 已提交
29 30 31
export default {
	data() {
		return {
S
1  
shenjizhe 已提交
32 33
			x: 0,
			y: 0,
S
1  
shenjizhe 已提交
34 35
			offsetX: defaultX,
			offsetY: defaultY,
S
1  
shenjizhe 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
			tables: [],
			columns: [
				{
					name: 'id',
					info: '唯一标识',
					tips: '字段名',
					type: 'text'
				},
				{
					name: 'name',
					info: '名称',
					tips: '请输入名称',
					type: 'text'
				},
				{
					name: 'pass',
					info: '密码',
					tips: '填入密码',
					type: 'password'
				},
				{
					name: 'level',
					info: '级别',
					tips: '级别',
					type: 'slider'
				},
				{
					name: 'salary',
					info: '工资',
					tips: '工资',
					type: 'digit'
				},
				{
					name: 'date',
					info: '日期',
					tips: '日期',
					type: 'date'
				},
				{
					name: 'datetime',
					info: '时间',
					tips: '事件',
					type: 'datetime'
				},
				{
					name: 'deleted',
					info: '是否删除',
					tips: '是否删除',
					type: 'switch'
				}
			],
			datas: {}
S
1  
shenjizhe 已提交
88 89 90
		};
	},
	methods: {
S
1  
shenjizhe 已提交
91
		onConfirm(action, data) {},
S
1  
shenjizhe 已提交
92
		resetTool() {
S
1  
shenjizhe 已提交
93 94 95 96 97 98
			console.log('1.reset');
			if (this.offsetX == defaultX) {
				this.offsetX += 0.0000001;
			} else {
				this.offsetX = defaultX;
			}
S
1  
shenjizhe 已提交
99
		},
100 101
		onStart(key, event, x, y) {
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1  
shenjizhe 已提交
102
		},
103 104
		onEnd(key, event, x, y) {
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1\  
shenjizhe 已提交
105
		},
S
1  
shenjizhe 已提交
106
		onStartTool(key, event, x, y) {
S
1  
shenjizhe 已提交
107
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1  
shenjizhe 已提交
108 109
		},
		onEndTool(key, event, x, y) {
S
1  
shenjizhe 已提交
110 111
			console.log(key + ':' + event + ':' + x + ':' + y);
			this.addEntity(x, y);
S
1  
shenjizhe 已提交
112
		},
S
1  
shenjizhe 已提交
113 114 115 116
		addEntity(x, y) {
			let count = this.tables.length;
			let tool = this.$refs.toolBar;
			let w = tool.width;
S
1  
shenjizhe 已提交
117 118 119 120
			this.resetTool();

			let _x = x - w + defaultX;
			let _y = y + defaultY;
S
1  
shenjizhe 已提交
121

S
1  
shenjizhe 已提交
122 123
			if (_x >= 0) {
				let table = { x: _x, y: _y, title: '实体' + count, entityName: 'test' + count, columns: [] };
S
1  
shenjizhe 已提交
124 125
				this.tables.push(table);
			}
S
1  
shenjizhe 已提交
126
		}
S
1  
shenjizhe 已提交
127 128 129 130 131
	}
};
</script>

<style lang="scss">
S
1  
shenjizhe 已提交
132
$window-height: 93vh;
S
1  
shenjizhe 已提交
133
$border-width: 5rpx;
S
1  
shenjizhe 已提交
134 135
$control-width: 200rpx;
$control-height: 200rpx;
S
1  
shenjizhe 已提交
136

S
1  
shenjizhe 已提交
137
.main-box {
S
1  
shenjizhe 已提交
138 139
	display: flex;
	flex-direction: row;
S
1  
shenjizhe 已提交
140
	justify-content: space-between;
S
1  
shenjizhe 已提交
141 142
}
.tool-bar {
S
1  
shenjizhe 已提交
143
	order: 1;
S
1  
shenjizhe 已提交
144
	flex: 1;
S
1  
shenjizhe 已提交
145
	height: $window-height;
S
1  
shenjizhe 已提交
146
	background-color: white;
S
1  
shenjizhe 已提交
147 148 149 150
	border-style: solid;
	border-width: $border-width;
}
.content-window {
S
1  
shenjizhe 已提交
151
	order: 2;
S
1  
shenjizhe 已提交
152
	flex: 7;
S
1  
shenjizhe 已提交
153 154
	margin-left: -$border-width;
	height: $window-height;
S
1  
shenjizhe 已提交
155

S
1  
shenjizhe 已提交
156 157
	border-style: solid;
	border-width: $border-width;
S
1  
shenjizhe 已提交
158
	background-color: gray;
159 160 161

	display: flex;
	flex-direction: row;
162
	flex-wrap: wrap;
S
1  
shenjizhe 已提交
163 164
}
.property-bar {
S
1  
shenjizhe 已提交
165
	order: 3;
S
1  
shenjizhe 已提交
166
	flex: 2;
S
1  
shenjizhe 已提交
167 168
	margin-left: -$border-width;
	height: $window-height;
S
1  
shenjizhe 已提交
169
	background-color: white;
S
1  
shenjizhe 已提交
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
	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>