test-er.vue 4.6 KB
Newer Older
S
1  
shenjizhe 已提交
1
<template>
S
1  
shenjizhe 已提交
2 3 4 5
	<view class="main-box">
		<movable-area ref="contentArea" class="content-window">
			<thirdlucky-uml-entity
				v-for="(table, index) in tables"
S
1  
shenjizhe 已提交
6
				:ref="table.key"
S
1  
shenjizhe 已提交
7 8 9 10 11
				:x="table.x"
				:y="table.y"
				:key="table.key"
				:entityName="table.entityName"
				:title="table.title"
S
1  
shenjizhe 已提交
12
				:columns="table.columns"
S
1  
shenjizhe 已提交
13 14 15 16 17 18
				:style="{ order: index }"
				@start="onStart"
				@end="onEnd"
			/>
		</movable-area>
		<movable-area ref="toolBar" class="tool-bar">
S
1  
shenjizhe 已提交
19
			<thirdlucky-uml-entity ref="entityTool" :x="offsetX" :y="offsetY" entityName="entity" title="实体" @start="onStartTool" @end="onEndTool" />
S
1  
shenjizhe 已提交
20
		</movable-area>
S
1  
shenjizhe 已提交
21 22 23
		<!-- 		<uni-popup ref="popup" type="top">
			<thirdlucky-data-form ref="tableView" class="entity-info" :columns="columns" @confirm="onConfirm"></thirdlucky-data-form>
		</uni-popup> -->
S
1  
shenjizhe 已提交
24
		<view ref="propertyBar" class="property-bar">
S
1  
shenjizhe 已提交
25 26 27 28 29 30 31 32
			<!-- <scroll-view style="background-color: #a1a1a1;height: 10%;" scroll-y="true">
				<text>123</text><br/>
				<text>123</text><br/>
				<text>123</text><br/>
				<text>123</text><br/>
			</scroll-view>
			<scroll-view style="background-color: #aaaaff;height: 50%;">123</scroll-view> -->
			<scroll-view class="property-table" scroll-y="true">
S
1  
shenjizhe 已提交
33
				<thirdlucky-data-table ref="tableView" border stripe :datas="datas" :columns="schemas" @selected="onSelected"></thirdlucky-data-table>
S
1  
shenjizhe 已提交
34
			</scroll-view>
S
1  
shenjizhe 已提交
35
			<view class="property-info"><thirdlucky-data-form ref="propertyView" :columns="columns" @confirm="onConfirm"></thirdlucky-data-form></view>
S
1  
shenjizhe 已提交
36
		</view>
S
1  
shenjizhe 已提交
37 38 39 40
	</view>
</template>

<script>
S
1  
shenjizhe 已提交
41 42 43
let defaultX = 20;
let defaultY = 20;

S
1  
shenjizhe 已提交
44 45 46
export default {
	data() {
		return {
S
1  
shenjizhe 已提交
47 48
			currentEntityKey: '',
			currentColumnKey: '',
S
1  
shenjizhe 已提交
49 50
			x: 0,
			y: 0,
S
1  
shenjizhe 已提交
51 52
			offsetX: defaultX,
			offsetY: defaultY,
S
1  
shenjizhe 已提交
53 54 55 56
			tables: [],
			columns: [
				{
					name: 'name',
S
1  
shenjizhe 已提交
57 58
					info: '列名',
					tips: '',
S
1  
shenjizhe 已提交
59 60 61
					type: 'text'
				},
				{
S
1  
shenjizhe 已提交
62 63 64 65
					name: 'type',
					info: '类型',
					tips: '',
					type: 'text'
S
1  
shenjizhe 已提交
66 67
				},
				{
S
1  
shenjizhe 已提交
68 69 70
					name: 'info',
					info: '描述',
					tips: '',
S
1  
shenjizhe 已提交
71
					type: 'text'
S
1  
shenjizhe 已提交
72 73
				}
			],
S
1  
shenjizhe 已提交
74 75 76 77 78 79
			schemas: [
				{
					name: 'name',
					info: '列名',
					tips: '',
					type: 'text'
S
1  
shenjizhe 已提交
80
				}
S
1  
shenjizhe 已提交
81
			],
S
1  
shenjizhe 已提交
82
			datas: [
S
1  
shenjizhe 已提交
83 84 85 86 87 88 89 90
				{ name: '1', info: 'test1' },
				{ name: '2', info: 'test2' },
				{ name: '3', info: 'test3' },
				{ name: '4', info: 'test4' },
				{ name: '5', info: 'test5' },
				{ name: '6', info: 'test6' },
				{ name: '7', info: 'test7' },
				{ name: '8', info: 'test8' }
S
1  
shenjizhe 已提交
91
			]
S
1  
shenjizhe 已提交
92 93
		};
	},
S
1  
shenjizhe 已提交
94 95 96 97 98 99 100
	computed: {
		tableDats() {
			return datas.map(function(data) {
				data.name;
			});
		}
	},
S
1  
shenjizhe 已提交
101
	methods: {
S
1  
shenjizhe 已提交
102
		onSelected(rindex, id, data) {
S
1  
shenjizhe 已提交
103
			console.log('选中' + rindex);
S
1  
shenjizhe 已提交
104
			console.log(data);
S
1  
shenjizhe 已提交
105
		},
S
1  
shenjizhe 已提交
106
		onConfirm(action, data) {},
S
1  
shenjizhe 已提交
107
		resetTool() {
S
1  
shenjizhe 已提交
108
			// console.log('1.reset:OFFSET=' + this.offsetX);
S
1  
shenjizhe 已提交
109 110 111 112 113
			if (this.offsetX == defaultX) {
				this.offsetX += 0.0000001;
			} else {
				this.offsetX = defaultX;
			}
S
1  
shenjizhe 已提交
114
		},
115 116
		onStart(key, event, x, y) {
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1  
shenjizhe 已提交
117
		},
118 119
		onEnd(key, event, x, y) {
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1\  
shenjizhe 已提交
120
		},
S
1  
shenjizhe 已提交
121
		onStartTool(key, event, x, y) {
S
1  
shenjizhe 已提交
122
			console.log(key + ':' + event + ':' + x + ':' + y);
S
1  
shenjizhe 已提交
123 124
		},
		onEndTool(key, event, x, y) {
S
1  
shenjizhe 已提交
125 126
			console.log(key + ':' + event + ':' + x + ':' + y);
			this.addEntity(x, y);
S
1  
shenjizhe 已提交
127
		},
S
1  
shenjizhe 已提交
128 129 130 131
		addEntity(x, y) {
			let count = this.tables.length;
			let tool = this.$refs.toolBar;
			let w = tool.width;
S
1  
shenjizhe 已提交
132 133 134 135
			this.resetTool();

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

S
1  
shenjizhe 已提交
137
			if (_x >= 0) {
S
1  
shenjizhe 已提交
138 139 140
				let title = '实体' + count;
				let key = 'entity' + count;
				let table = { x: _x, y: _y, title: title, entityName: key, columns: [] };
S
1  
shenjizhe 已提交
141 142
				this.tables.push(table);
			}
S
1  
shenjizhe 已提交
143
		}
S
1  
shenjizhe 已提交
144 145 146 147 148
	}
};
</script>

<style lang="scss">
S
1  
shenjizhe 已提交
149
$window-height: 93vh;
S
1  
shenjizhe 已提交
150
$border-width: 5rpx;
S
1  
shenjizhe 已提交
151 152
$control-width: 200rpx;
$control-height: 200rpx;
S
1  
shenjizhe 已提交
153

S
1  
shenjizhe 已提交
154
.main-box {
S
1  
shenjizhe 已提交
155 156
	display: flex;
	flex-direction: row;
S
1  
shenjizhe 已提交
157
	justify-content: space-between;
S
1  
shenjizhe 已提交
158 159
}
.tool-bar {
S
1  
shenjizhe 已提交
160
	order: 1;
S
1  
shenjizhe 已提交
161
	flex: 1;
S
1  
shenjizhe 已提交
162
	height: $window-height;
S
1  
shenjizhe 已提交
163
	background-color: white;
S
1  
shenjizhe 已提交
164 165 166 167
	border-style: solid;
	border-width: $border-width;
}
.content-window {
S
1  
shenjizhe 已提交
168
	order: 2;
S
1  
shenjizhe 已提交
169
	flex: 7;
S
1  
shenjizhe 已提交
170 171
	margin-left: -$border-width;
	height: $window-height;
S
1  
shenjizhe 已提交
172

S
1  
shenjizhe 已提交
173 174
	border-style: solid;
	border-width: $border-width;
S
1  
shenjizhe 已提交
175
	background-color: gray;
176 177 178

	display: flex;
	flex-direction: row;
179
	flex-wrap: wrap;
S
1  
shenjizhe 已提交
180 181
}
.property-bar {
S
1  
shenjizhe 已提交
182 183
	display: flex;
	flex-direction: column;
S
1  
shenjizhe 已提交
184
	justify-content: end;
S
1  
shenjizhe 已提交
185
	order: 3;
S
1  
shenjizhe 已提交
186
	flex: 2;
S
1  
shenjizhe 已提交
187 188 189
	margin-left: -$border-width;
	border-style: solid;
	border-width: $border-width;
S
1  
shenjizhe 已提交
190 191 192
	height: $window-height;
	background-color: white;
}
S
1  
shenjizhe 已提交
193 194 195 196 197 198 199
// .entity-info {
// 	order: 1;
// 	flex: 1;
// 	position: absolute;
// 	// top: 0;
// }
.property-table {
S
1  
shenjizhe 已提交
200
	order: 1;
S
1  
shenjizhe 已提交
201 202
	// flex: 1;
	height: 60%;
S
1  
shenjizhe 已提交
203
}
S
1  
shenjizhe 已提交
204
.property-info {
S
1  
shenjizhe 已提交
205 206
	order: 2;
	flex: 1;
S
1  
shenjizhe 已提交
207 208
	position: absolute;
	bottom: -39rpx;
S
1  
shenjizhe 已提交
209 210
}
</style>