From d3dd0cfed10cc22f32686c4dac62138075f64d73 Mon Sep 17 00:00:00 2001 From: wangxinpo <1124434059@qq.com> Date: Sat, 18 May 2024 16:38:12 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=8A=A5=E9=94=99?= =?UTF-8?q?=20-=20=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AFbug=20-=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=20-=20=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=BC=82=E5=B8=B8=E8=A1=A8=E5=8D=95=E4=B8=8D=E5=85=B3?= =?UTF-8?q?=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front-ui/src/views/datasource/DsConfig.vue | 35 ++- front-ui/src/views/job/JobList.vue | 2 +- front-ui/src/views/job/JobSaveOrUpdate.vue | 207 +++++++++++------- .../views/job/JobSaveOrUpdateStreaming.vue | 19 +- .../src/views/jobrelation/JobRelationSave.vue | 19 +- 5 files changed, 180 insertions(+), 102 deletions(-) diff --git a/front-ui/src/views/datasource/DsConfig.vue b/front-ui/src/views/datasource/DsConfig.vue index db7f0dc..a8856e5 100644 --- a/front-ui/src/views/datasource/DsConfig.vue +++ b/front-ui/src/views/datasource/DsConfig.vue @@ -250,19 +250,40 @@ export default { if (this.type === 'add') { console.log(values) addObj(values).then(res => { - if (res.status !== '0') { + if (res.status === '0') { + this.$emit('ok') + this.confirmLoading = false + // 清楚表单数据 + this.handleCancel() + this.$message.success('新增成功') + } + else{ + this.confirmLoading = false this.$message.error(res.errstr) } + }).catch(err => { + this.confirmLoading = false + this.$message.error(err.errstr) }) } else if (this.type === 'edit') { console.log('----', values) - await putObj(values) + await putObj(values).then(res => { + if (res.status === '0') { + this.$emit('ok') + this.confirmLoading = false + // 清楚表单数据 + this.handleCancel() + this.$message.success('修改成功') + } + else{ + this.confirmLoading = false + this.$message.error(res.errstr) + } + }).catch(err => { + this.confirmLoading = false + this.$message.error(err.errstr) + }) } - setTimeout(() => { - this.confirmLoading = false - this.$emit('ok', { type: this.type }) - this.visible = false - }, 1500) } }) selectTables = [] diff --git a/front-ui/src/views/job/JobList.vue b/front-ui/src/views/job/JobList.vue index af252b2..b6050e2 100644 --- a/front-ui/src/views/job/JobList.vue +++ b/front-ui/src/views/job/JobList.vue @@ -8,7 +8,7 @@ :dataSource="tableData" :loading="loading" :pagination="pagination" - :rowKey="record => record.id" + :rowKey="record => record.job_id" @change="handleTableChange" > diff --git a/front-ui/src/views/job/JobSaveOrUpdate.vue b/front-ui/src/views/job/JobSaveOrUpdate.vue index 126e3d4..b0bd458 100644 --- a/front-ui/src/views/job/JobSaveOrUpdate.vue +++ b/front-ui/src/views/job/JobSaveOrUpdate.vue @@ -21,71 +21,68 @@ > + v-decorator="['jobName', {rules: [{required: true, message: '请输入任务名称'}],initialValue: jobName}]" + /> - - - - - + + + + {{ table.name }} - - - - + + + + + {{ table.name }} - - - - - - - -
- -
- - +
+ + + + + + + {{ table }} - - -
- -
- + +
+ + + {{ table }} - - -
- - -
-
- - + + + +
+ + + {{ item.label }} + + -
-
- - - + +
+
+
- 开启数据覆盖: + 开启数据覆盖:

请选择增量字段:

@@ -118,9 +115,8 @@ > + v-decorator="['schedulerConf', {rules: [{required: true, message: '请输入crontab表达式', trigger: 'blur'}],initialValue: schedulerConf}]"/>
- @@ -215,7 +211,11 @@ export default { incrementField: '', selectloading: false, redisToType: 'string', - redisToValue: '' + redisToValue: '', + redis_type_validateStatus: '', + redis_value_validateStatus: '', + redis_type_help: '', + redis_value_help: '', } }, computed: { @@ -228,27 +228,52 @@ export default { }, isStreaming () { return this.jobType === 'streaming' + }, + // 是否覆盖 + trans_cover() + { + return Boolean(this.cover) } }, methods: { + // 校验redis + validate_redis() { + if (!this.redisToType) { + this.redis_type_validateStatus = 'error' + this.redis_type_help = '请选择Type' + }else{ + this.redis_type_validateStatus = '' + this.redis_type_help = '' + } + if (!this.redisToValue) { + this.redis_value_validateStatus = 'error' + this.redis_value_help = '请输入Value' + }else{ + this.redis_value_validateStatus = '' + this.redis_value_help = '' + } + }, handleSubmit () { + // 如果目标数据源是redis 则设置为全量 + if (this.isRedisTo) { + // 同步redis数据源表单数据 + this.form.setFieldsValue({['selectedTargetTable']: this.redisToType + this.redisSpitKey + this.redisToValue}) + // 则校验redis数据 + this.validate_redis() + } this.form.validateFields(async (err, values) => { - this.confirmLoading = true if (!err) { this.confirmLoading = true - if (this.redisToValue !== '') { - this.selectedTargetTable = (this.redisToType + this.redisSpitKey + this.redisToValue) - } - const formData = { 'job_id': this.jobId, - 'from_ds_id': this.selectedDataSource, - 'to_ds_id': this.selectedTargetSource, - 'from_tb_name': this.selectedSourceTable, - 'to_tb_name': this.selectedTargetTable, - 'scheduler_conf': this.schedulerConf, + // 提交表单数据 + 'from_ds_id': this.form.getFieldValue('selectedDataSource'), + 'to_ds_id': this.form.getFieldValue('selectedTargetSource'), + 'from_tb_name': this.form.getFieldValue('selectedSourceTable'), + 'to_tb_name': this.form.getFieldValue('selectedTargetTable'), + 'job_name': this.form.getFieldValue('jobName'), + 'scheduler_conf': this.form.getFieldValue('schedulerConf'), 'field_mappings': this.mappings, - 'job_name': this.jobName, 'cover': this.cover, 'sync_mode': { 'mode': this.syncMode, @@ -258,20 +283,37 @@ export default { console.log(this.jobId) if (this.type === 'edit') { modifyObj(formData).then(res => { - this.confirmLoading = false - this.$emit('ok') - this.visible = false + if (res.status === '0') { + this.$emit('ok') + this.confirmLoading = false + // 清楚表单数据 + this.handleCancel() + this.$message.success('修改成功') + } + else{ + this.confirmLoading = false + this.$message.error(res.errstr) + } }).catch(err => { + this.confirmLoading = false this.$message.error(err.errstr) }) } else { addObj(formData).then(res => { - if (res.status !== '0') { - this.confirmLoading = false + if (res.status === '0') { this.$emit('ok') - this.visible = false + this.confirmLoading = false + // 清楚表单数据 + this.handleCancel() + this.$message.success('新增成功') + } + else{ + this.confirmLoading = false this.$message.error(res.errstr) } + }).catch(err => { + this.confirmLoading = false + this.$message.error(err.errstr) }) } // setTimeout(() => { @@ -349,6 +391,10 @@ export default { }, handleFromChange (value) { this.selectedDataSource = value + // 切换数据源同步表单数据 + this.form.setFieldsValue({['selectedDataSource']: value}) + // 清空表单中来源表 + this.form.setFieldsValue({['selectedSourceTable']: ''}) this.selectloading = true fetchTables(value).then(res => { this.selectloading = false @@ -357,6 +403,10 @@ export default { }, handleToDsChange (value) { this.selectedTargetSource = value + // 切换目标数据源同步表单数据 + this.form.setFieldsValue({['selectedTargetSource']: value}) + // 清空表单中目标表 + this.form.setFieldsValue({['selectedTargetTable']: ''}) console.log('当前选中数据源类型', this.selectedTargetSource, this.isRedisTo) // 如果目标数据源是redis 则设置为全量 if (this.toDsList.find(item => { return item.dsId === this.selectedTargetSource })?.type === 4) { @@ -372,6 +422,8 @@ export default { }, handleFromTbChange (value) { this.selectloading = true + // 切换来源表同步表单数据 + this.form.setFieldsValue({['selectedSourceTable']: value}) this.selectedSourceTable = value this.queryParam = { 'ds_id': this.selectedDataSource, @@ -389,11 +441,7 @@ export default { console.log(val) }, changeCover (checked) { - if (checked) { - this.cover = 1 - } else { - this.cover = 0 - } + this.cover = checked }, changeSyncConfig (value) { if (value.target.value === 'increment') { @@ -408,6 +456,8 @@ export default { handleToTbChange (value) { this.selectloading = true this.selectedTargetTable = value + // 切换目标表同步表单数据 + this.form.setFieldsValue({['selectedTargetTable']: value}) this.queryParam = { 'ds_id': this.selectedTargetSource, 'name': value @@ -439,6 +489,12 @@ export default { this.incrementField = '' this.schedulerConf = '' this.jobName = '' + this.syncMode = 'overwrite' + this.form.resetFields() + this.redis_value_help = '' + this.redis_type_help = '' + this.redis_value_validateStatus = '' + this.redis_type_validateStatus = '' }, removeMapping (index) { this.mappings.splice(index, 1) @@ -450,17 +506,12 @@ export default {