Skip to content

Commit d1c335f

Browse files
committed
#10 任务构建页面,选择数据源之后页面的模板切换了,但是上一步选择的数据源没有带过来,需要重新选择 #10
1 parent d8c9b93 commit d1c335f

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// 公共的组件,来做为中间传达的工具
2+
import Vue from 'vue'
3+
export default new Vue({
4+
data() {
5+
return {
6+
dataSourceId: ''
7+
}
8+
}
9+
})

src/views/datax/json-build/writer.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div class="app-container">
3-
<RDBMSWriter v-if="dataSource!=='hive' && dataSource!=='hbase' && dataSource!=='mongodb'" ref="rdbmswriter" @selectDataSource="showDataSource" />
4-
<HiveWriter v-if="dataSource==='hive'" ref="hivewriter" @selectDataSource="showDataSource" />
5-
<HBaseWriter v-if="dataSource==='hbase'" ref="hbasewriter" @selectDataSource="showDataSource" />
6-
<MongoDBWriter v-if="dataSource==='mongodb'" ref="mongodbwriter" @selectDataSource="showDataSource" />
3+
<RDBMSWriter v-show="dataSource!=='hive' && dataSource!=='hbase' && dataSource!=='mongodb'" ref="rdbmswriter" @selectDataSource="showDataSource" />
4+
<HiveWriter v-show="dataSource==='hive'" ref="hivewriter" @selectDataSource="showDataSource" />
5+
<HBaseWriter v-show="dataSource==='hbase'" ref="hbasewriter" @selectDataSource="showDataSource" />
6+
<MongoDBWriter v-show="dataSource==='mongodb'" ref="mongodbwriter" @selectDataSource="showDataSource" />
77

88
</div>
99
</template>
@@ -49,6 +49,7 @@ export default {
4949
},
5050
showDataSource(data) {
5151
this.dataSource = data
52+
this.getData()
5253
},
5354
sendTableNameAndColumns(fromTableName, fromColumnList) {
5455
this.$refs.hivewriter.fromTableName = fromTableName

src/views/datax/json-build/writer/HBaseWriter.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<script>
6464
import * as dsQueryApi from '@/api/ds-query'
6565
import { list as jdbcDsList } from '@/api/datax-jdbcDatasource'
66+
import Bus from '../busWriter'
6667
export default {
6768
name: 'HBaseWriter',
6869
data() {
@@ -121,6 +122,11 @@ export default {
121122
readerForm: this.getReaderData()
122123
}
123124
},
125+
watch: {
126+
'writerForm.datasourceId': function(oldVal, newVal) {
127+
this.getTables('reader')
128+
}
129+
},
124130
created() {
125131
this.getJdbcDs()
126132
},
@@ -153,6 +159,7 @@ export default {
153159
this.dataSource = item.datasource
154160
}
155161
})
162+
Bus.dataSourceId = e
156163
this.$emit('selectDataSource', this.dataSource)
157164
// 获取可用表
158165
this.getTables()
@@ -194,6 +201,9 @@ export default {
194201
this.writerForm.isIndeterminate = false
195202
},
196203
getData() {
204+
if (Bus.dataSourceId) {
205+
this.writerForm.datasourceId = Bus.dataSourceId
206+
}
197207
return this.writerForm
198208
},
199209
getReaderData() {

src/views/datax/json-build/writer/HiveWriter.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<script>
7777
import * as dsQueryApi from '@/api/ds-query'
7878
import { list as jdbcDsList } from '@/api/datax-jdbcDatasource'
79+
import Bus from '../busWriter'
7980
export default {
8081
name: 'HiveWriter',
8182
data() {
@@ -120,6 +121,11 @@ export default {
120121
]
121122
}
122123
},
124+
watch: {
125+
'writerForm.datasourceId': function(oldVal, newVal) {
126+
this.getTables('reader')
127+
}
128+
},
123129
created() {
124130
this.getJdbcDs()
125131
},
@@ -152,6 +158,7 @@ export default {
152158
this.dataSource = item.datasource
153159
}
154160
})
161+
Bus.dataSourceId = e
155162
this.$emit('selectDataSource', this.dataSource)
156163
// 获取可用表
157164
this.getTables()
@@ -193,6 +200,9 @@ export default {
193200
this.writerForm.isIndeterminate = false
194201
},
195202
getData() {
203+
if (Bus.dataSourceId) {
204+
this.writerForm.datasourceId = Bus.dataSourceId
205+
}
196206
return this.writerForm
197207
},
198208
getReaderData() {

src/views/datax/json-build/writer/MongoDBWriter.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<script>
5858
import * as dsQueryApi from '@/api/ds-query'
5959
import { list as jdbcDsList } from '@/api/datax-jdbcDatasource'
60+
import Bus from '../busWriter'
6061
export default {
6162
name: 'MongoDBWriter',
6263
data() {
@@ -90,6 +91,11 @@ export default {
9091
readerForm: this.getReaderData()
9192
}
9293
},
94+
watch: {
95+
'writerForm.datasourceId': function(oldVal, newVal) {
96+
this.getTables()
97+
}
98+
},
9399
created() {
94100
this.getJdbcDs()
95101
},
@@ -122,6 +128,7 @@ export default {
122128
this.dataSource = item.datasource
123129
}
124130
})
131+
Bus.dataSourceId = e
125132
this.$emit('selectDataSource', this.dataSource)
126133
// 获取可用表
127134
this.getTables()
@@ -163,6 +170,9 @@ export default {
163170
this.writerForm.isIndeterminate = false
164171
},
165172
getData() {
173+
if (Bus.dataSourceId) {
174+
this.writerForm.datasourceId = Bus.dataSourceId
175+
}
166176
return this.writerForm
167177
},
168178
getReaderData() {

src/views/datax/json-build/writer/RDBMSWriter.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<script>
5252
import * as dsQueryApi from '@/api/ds-query'
5353
import { list as jdbcDsList } from '@/api/datax-jdbcDatasource'
54+
import Bus from '../busWriter'
5455
export default {
5556
name: 'RDBMSWriter',
5657
data() {
@@ -76,6 +77,11 @@ export default {
7677
}
7778
}
7879
},
80+
watch: {
81+
'writerForm.datasourceId': function(oldVal, newVal) {
82+
this.getTables('reader')
83+
}
84+
},
7985
created() {
8086
this.getJdbcDs()
8187
},
@@ -108,6 +114,7 @@ export default {
108114
this.dataSource = item.datasource
109115
}
110116
})
117+
Bus.dataSourceId = e
111118
this.$emit('selectDataSource', this.dataSource)
112119
// 获取可用表
113120
this.getTables()
@@ -149,6 +156,9 @@ export default {
149156
this.writerForm.isIndeterminate = false
150157
},
151158
getData() {
159+
if (Bus.dataSourceId) {
160+
this.writerForm.datasourceId = Bus.dataSourceId
161+
}
152162
return this.writerForm
153163
},
154164
getReaderData() {

0 commit comments

Comments
 (0)