test-er.vue 4.2 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
		<view ref="propertyBar" class="property-bar">
S
1  
shenjizhe 已提交
22
			<scroll-view class="property-table" scroll-y="true">
S
1  
shenjizhe 已提交
23
				<thirdlucky-data-table ref="tableView" border stripe :datas="datas" :columns="schemas" @selected="onSelected"></thirdlucky-data-table>
S
1  
shenjizhe 已提交
24
			</scroll-view>
S
1  
shenjizhe 已提交
25
			<view class="property-info"><thirdlucky-data-form ref="propertyView" :columns="columns" @confirm="onConfirm"></thirdlucky-data-form></view>
S
1  
shenjizhe 已提交
26
		</view>
S
1  
shenjizhe 已提交
27 28 29 30
	</view>
</template>

<script>
S
1  
shenjizhe 已提交
31 32 33
let defaultX = 20;
let defaultY = 20;

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

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

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

<style lang="scss">
S
1  
shenjizhe 已提交
145
$window-height: 93vh;
S
1  
shenjizhe 已提交
146
$border-width: 5rpx;
S
1  
shenjizhe 已提交
147 148
$control-width: 200rpx;
$control-height: 200rpx;
S
1  
shenjizhe 已提交
149

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

S
1  
shenjizhe 已提交
169 170
	border-style: solid;
	border-width: $border-width;
S
1  
shenjizhe 已提交
171
	background-color: gray;
172 173 174

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