2021-03-03 15:06:52 +08:00
|
|
|
<template>
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-col>
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-row>
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-button icon="el-icon-setting" size="mini" @click="showConfig">
|
|
|
|
{{ $t('dataset.update_setting') }}
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-button>
|
|
|
|
</el-row>
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-row style="margin-top: 10px;">
|
|
|
|
<el-table
|
|
|
|
size="mini"
|
2021-03-09 16:04:16 +08:00
|
|
|
:data="taskLogData"
|
2021-03-04 15:38:37 +08:00
|
|
|
border
|
|
|
|
style="width: 100%"
|
|
|
|
>
|
|
|
|
<el-table-column
|
|
|
|
prop="name"
|
|
|
|
:label="$t('dataset.task_name')"
|
|
|
|
/>
|
|
|
|
<el-table-column
|
|
|
|
prop="startTime"
|
|
|
|
:label="$t('dataset.start_time')"
|
2021-03-09 16:04:16 +08:00
|
|
|
>
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ scope.row.startTime | timestampFormatDate }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-table-column
|
|
|
|
prop="endTime"
|
|
|
|
:label="$t('dataset.end_time')"
|
2021-03-09 16:04:16 +08:00
|
|
|
>
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ scope.row.endTime | timestampFormatDate }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-table-column
|
|
|
|
prop="status"
|
|
|
|
:label="$t('dataset.status')"
|
|
|
|
/>
|
|
|
|
</el-table>
|
2021-03-08 11:35:28 +08:00
|
|
|
<el-row style="margin-top: 10px;text-align: right;">
|
|
|
|
<el-pagination
|
2021-03-09 16:04:16 +08:00
|
|
|
:current-page="page.currentPage"
|
|
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
|
|
:page-size="page.pageSize"
|
2021-03-08 11:35:28 +08:00
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
2021-03-09 16:04:16 +08:00
|
|
|
:total="page.total"
|
2021-03-08 12:29:11 +08:00
|
|
|
@size-change="handleSizeChange"
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
/>
|
2021-03-08 11:35:28 +08:00
|
|
|
</el-row>
|
2021-03-04 15:38:37 +08:00
|
|
|
</el-row>
|
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
:title="table.name+' '+$t('dataset.update_setting')"
|
|
|
|
:visible="update_setting"
|
|
|
|
:show-close="false"
|
|
|
|
width="50%"
|
|
|
|
class="dialog-css"
|
|
|
|
>
|
|
|
|
<el-dialog
|
|
|
|
:title="$t('dataset.task_update')"
|
|
|
|
:visible="update_task"
|
|
|
|
:show-close="false"
|
|
|
|
width="50%"
|
|
|
|
class="dialog-css"
|
|
|
|
append-to-body
|
|
|
|
>
|
|
|
|
<el-col>
|
2021-03-19 16:57:52 +08:00
|
|
|
<el-form :form="taskForm" label-width="80px" size="mini">
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-form-item :label="$t('dataset.task_name')" prop="name">
|
|
|
|
<el-input
|
|
|
|
v-model="taskForm.name"
|
|
|
|
size="mini"
|
|
|
|
style="width: 50%"
|
|
|
|
:placeholder="$t('dataset.task_name')"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('dataset.update_type')" prop="type">
|
|
|
|
<el-select v-model="taskForm.type" size="mini">
|
|
|
|
<el-option
|
|
|
|
:label="$t('dataset.all_scope')"
|
2021-03-18 17:59:52 +08:00
|
|
|
value="all_scope"
|
2021-03-04 15:38:37 +08:00
|
|
|
/>
|
|
|
|
<el-option
|
|
|
|
:label="$t('dataset.add_scope')"
|
2021-03-18 17:59:52 +08:00
|
|
|
value="add_scope"
|
2021-03-04 15:38:37 +08:00
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('dataset.start_time')" prop="startTime">
|
|
|
|
<el-date-picker
|
|
|
|
v-model="taskForm.startTime"
|
|
|
|
type="datetime"
|
|
|
|
:placeholder="$t('dataset.select_data_time')"
|
|
|
|
size="mini"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('dataset.execute_rate')" prop="rate">
|
2021-03-19 16:57:52 +08:00
|
|
|
<el-select v-model="taskForm.rate" size="mini" @change="onRateChange">
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-option
|
|
|
|
:label="$t('dataset.execute_once')"
|
2021-03-18 17:59:52 +08:00
|
|
|
value="SIMPLE"
|
2021-03-04 15:38:37 +08:00
|
|
|
/>
|
|
|
|
<el-option
|
|
|
|
:label="$t('dataset.cron_config')"
|
2021-03-18 17:59:52 +08:00
|
|
|
value="CRON"
|
2021-03-04 15:38:37 +08:00
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2021-03-18 17:59:52 +08:00
|
|
|
<el-form-item v-if="taskForm.rate === 'CRON'" label="">
|
2021-03-10 14:31:21 +08:00
|
|
|
<el-input v-model="taskForm.cron" size="mini" style="width: 50%" />
|
2021-03-04 15:38:37 +08:00
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('dataset.end_time')" prop="end">
|
2021-03-18 17:59:52 +08:00
|
|
|
<el-select v-model="taskForm.end" size="mini">
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-option
|
|
|
|
:label="$t('dataset.no_limit')"
|
|
|
|
value="0"
|
|
|
|
/>
|
|
|
|
<el-option
|
|
|
|
:label="$t('dataset.set_end_time')"
|
|
|
|
value="1"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item v-if="taskForm.end === '1'" label="">
|
|
|
|
<el-date-picker
|
|
|
|
v-model="taskForm.endTime"
|
|
|
|
type="datetime"
|
|
|
|
:placeholder="$t('dataset.select_data_time')"
|
|
|
|
size="mini"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</el-col>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="closeTask">{{ $t('dataset.cancel') }}</el-button>
|
|
|
|
<el-button type="primary" size="mini" @click="saveTask(taskForm)">{{ $t('dataset.confirm') }}</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
<el-row>
|
|
|
|
<el-button icon="el-icon-download" size="mini">
|
|
|
|
{{ $t('dataset.sync_now') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button icon="el-icon-plus" size="mini" @click="addTask(undefined)">
|
|
|
|
{{ $t('dataset.add_task') }}
|
|
|
|
</el-button>
|
|
|
|
</el-row>
|
|
|
|
<el-row style="margin-top: 10px;">
|
|
|
|
<el-table
|
|
|
|
border
|
|
|
|
size="mini"
|
|
|
|
:data="taskData"
|
|
|
|
style="width: 100%"
|
2021-03-19 16:57:52 +08:00
|
|
|
height="240"
|
2021-03-04 15:38:37 +08:00
|
|
|
>
|
|
|
|
<el-table-column
|
|
|
|
prop="name"
|
|
|
|
:label="$t('dataset.start_time')"
|
|
|
|
/>
|
|
|
|
<el-table-column
|
|
|
|
prop="rate"
|
|
|
|
:label="$t('dataset.execute_rate')"
|
|
|
|
>
|
|
|
|
<template slot-scope="scope">
|
2021-03-18 17:59:52 +08:00
|
|
|
<span v-if="scope.row.rate === 'SIMPLE'">{{ $t('dataset.execute_once') }}</span>
|
|
|
|
<span v-if="scope.row.rate === 'SIMPLE_COMPLETE'">{{ $t('dataset.execute_once') }}</span>
|
|
|
|
<span v-if="scope.row.rate === 'CRON'">{{ $t('dataset.cron_config') }}</span>
|
2021-03-04 15:38:37 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
|
|
:label="$t('dataset.operate')"
|
|
|
|
>
|
|
|
|
<template slot-scope="scope" style="float: right">
|
|
|
|
<el-button
|
|
|
|
size="mini"
|
|
|
|
type="primary"
|
|
|
|
icon="el-icon-edit"
|
|
|
|
circle
|
2021-03-18 17:59:52 +08:00
|
|
|
:disabled="scope.row.rate === 'SIMPLE_COMPLETE'"
|
2021-03-05 16:16:47 +08:00
|
|
|
@click="addTask(scope.row)"
|
|
|
|
/>
|
2021-03-04 15:38:37 +08:00
|
|
|
<el-button
|
|
|
|
size="mini"
|
|
|
|
type="danger"
|
|
|
|
icon="el-icon-delete"
|
|
|
|
circle
|
2021-03-05 16:16:47 +08:00
|
|
|
@click="deleteTask(scope.row)"
|
|
|
|
/>
|
2021-03-04 15:38:37 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</el-row>
|
|
|
|
|
2021-03-18 17:59:52 +08:00
|
|
|
<el-divider />
|
|
|
|
|
|
|
|
<el-row style="height: 26px;">
|
|
|
|
<el-row>
|
2021-03-19 16:57:52 +08:00
|
|
|
<el-col :span="6"><div>{{ $t('dataset.incremental_update_type') }}:</div></el-col>
|
2021-03-18 17:59:52 +08:00
|
|
|
<el-col :span="18">
|
|
|
|
<el-radio-group v-model="incrementalUpdateType" size="small" @change="incrementalUpdateTypeChange">
|
2021-03-19 16:57:52 +08:00
|
|
|
<el-radio label="incrementalAdd">{{ $t('dataset.incremental_add') }}</el-radio>
|
|
|
|
<el-radio label="incrementalDelete">{{ $t('dataset.incremental_delete') }}</el-radio>
|
2021-03-18 17:59:52 +08:00
|
|
|
</el-radio-group>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
<el-row style="height: 26px;">
|
|
|
|
<el-row>
|
2021-03-19 16:57:52 +08:00
|
|
|
<el-col :span="6" style="height: 26px;"><div style="height: 26px;">{{ $t('dataset.param') }}:</div></el-col>
|
2021-03-18 17:59:52 +08:00
|
|
|
<el-col :span="18">
|
2021-03-19 16:57:52 +08:00
|
|
|
<el-button type="text" @click="insertParamToCodeMirror('${__last_update_time__}')">{{ $t('dataset.last_update_time') }}</el-button>
|
|
|
|
<el-button type="text" @click="insertParamToCodeMirror('${__current_update_time__}')">{{ $t('dataset.current_update_time') }}</el-button>
|
2021-03-18 17:59:52 +08:00
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
<el-row>
|
|
|
|
<el-col style="min-width: 200px;">
|
|
|
|
<codemirror
|
|
|
|
ref="myCm"
|
|
|
|
v-model="sql"
|
|
|
|
class="codemirror"
|
|
|
|
:options="sqlOption"
|
|
|
|
@ready="onCmReady"
|
|
|
|
@focus="onCmFocus"
|
|
|
|
@input="onCmCodeChange"
|
|
|
|
/>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
|
2021-03-04 15:38:37 +08:00
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="update_setting = false">{{ $t('dataset.close') }}</el-button>
|
2021-03-19 16:57:52 +08:00
|
|
|
<el-button size="mini" type="primary" @click="saveIncrementalConfig">{{ $t('dataset.confirm') }}</el-button>
|
2021-03-04 15:38:37 +08:00
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</el-col>
|
2021-03-03 15:06:52 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-03-04 15:38:37 +08:00
|
|
|
import { post } from '@/api/dataset/dataset'
|
2021-03-18 17:59:52 +08:00
|
|
|
import { codemirror } from 'vue-codemirror'
|
|
|
|
// 核心样式
|
|
|
|
import 'codemirror/lib/codemirror.css'
|
|
|
|
// 引入主题后还需要在 options 中指定主题才会生效
|
|
|
|
import 'codemirror/theme/solarized.css'
|
|
|
|
import 'codemirror/mode/sql/sql.js'
|
|
|
|
// require active-line.js
|
|
|
|
import 'codemirror/addon/selection/active-line.js'
|
|
|
|
// closebrackets
|
|
|
|
import 'codemirror/addon/edit/closebrackets.js'
|
|
|
|
// keyMap
|
|
|
|
import 'codemirror/mode/clike/clike.js'
|
|
|
|
import 'codemirror/addon/edit/matchbrackets.js'
|
|
|
|
import 'codemirror/addon/comment/comment.js'
|
|
|
|
import 'codemirror/addon/dialog/dialog.js'
|
|
|
|
import 'codemirror/addon/dialog/dialog.css'
|
|
|
|
import 'codemirror/addon/search/searchcursor.js'
|
|
|
|
import 'codemirror/addon/search/search.js'
|
|
|
|
import 'codemirror/keymap/emacs.js'
|
|
|
|
// 引入代码自动提示插件
|
|
|
|
import 'codemirror/addon/hint/show-hint.css'
|
|
|
|
import 'codemirror/addon/hint/sql-hint'
|
|
|
|
import 'codemirror/addon/hint/show-hint'
|
2021-03-04 15:38:37 +08:00
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
export default {
|
|
|
|
name: 'UpdateInfo',
|
2021-03-18 17:59:52 +08:00
|
|
|
components: { codemirror },
|
2021-03-03 15:06:52 +08:00
|
|
|
props: {
|
2021-03-05 16:16:47 +08:00
|
|
|
table: {
|
|
|
|
type: Object,
|
|
|
|
default: null
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
update_setting: false,
|
2021-03-04 15:38:37 +08:00
|
|
|
update_task: false,
|
|
|
|
taskForm: {
|
|
|
|
name: '',
|
2021-03-18 17:59:52 +08:00
|
|
|
type: 'all_scope',
|
2021-03-04 15:38:37 +08:00
|
|
|
startTime: '',
|
2021-03-18 17:59:52 +08:00
|
|
|
rate: 'SIMPLE',
|
2021-03-04 15:38:37 +08:00
|
|
|
cron: '',
|
|
|
|
endTime: '',
|
|
|
|
end: '0'
|
|
|
|
},
|
2021-03-09 16:04:16 +08:00
|
|
|
page: {
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
total: 0
|
|
|
|
},
|
|
|
|
taskLogData: [],
|
2021-03-04 15:38:37 +08:00
|
|
|
taskData: [],
|
|
|
|
taskFormRules: {
|
|
|
|
name: [
|
|
|
|
{ required: true, message: this.$t('dataset.required'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
type: [
|
|
|
|
{ required: true, message: this.$t('dataset.required'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
startTime: [
|
|
|
|
{ required: true, message: this.$t('dataset.required'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
rate: [
|
|
|
|
{ required: true, message: this.$t('dataset.required'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
end: [
|
|
|
|
{ required: true, message: this.$t('dataset.required'), trigger: 'change' }
|
|
|
|
]
|
2021-03-18 17:59:52 +08:00
|
|
|
},
|
|
|
|
sqlOption: {
|
|
|
|
tabSize: 2,
|
|
|
|
styleActiveLine: true,
|
|
|
|
lineNumbers: true,
|
|
|
|
line: true,
|
|
|
|
mode: 'text/x-sql',
|
|
|
|
theme: 'solarized',
|
|
|
|
hintOptions: { // 自定义提示选项
|
|
|
|
completeSingle: false // 当匹配只有一项的时候是否自动补全
|
|
|
|
}
|
|
|
|
},
|
|
|
|
incrementalUpdateType: 'incrementalAdd',
|
|
|
|
sql: '',
|
|
|
|
incrementalConfig: {}
|
2021-03-04 15:38:37 +08:00
|
|
|
}
|
|
|
|
},
|
2021-03-19 16:57:52 +08:00
|
|
|
computed: {
|
|
|
|
codemirror() {
|
|
|
|
return this.$refs.myCm.codemirror
|
|
|
|
}
|
|
|
|
},
|
2021-03-04 15:38:37 +08:00
|
|
|
watch: {
|
|
|
|
table() {
|
|
|
|
this.listTask()
|
2021-03-09 16:04:16 +08:00
|
|
|
this.listTaskLog()
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
},
|
2021-03-18 17:59:52 +08:00
|
|
|
mounted() {
|
|
|
|
window.onresize = () => {
|
|
|
|
return (() => {
|
|
|
|
this.height = window.innerHeight / 2
|
|
|
|
})()
|
|
|
|
}
|
|
|
|
this.height = window.innerHeight / 2
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
methods: {
|
2021-03-19 16:57:52 +08:00
|
|
|
incrementalUpdateTypeChange: function() {
|
|
|
|
if (this.incrementalUpdateType === 'incrementalAdd') {
|
|
|
|
if (this.sql) {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.incrementalConfig.incrementalDelete = this.sql
|
|
|
|
}
|
2021-03-19 16:57:52 +08:00
|
|
|
if (this.incrementalConfig.incrementalAdd) {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.sql = this.incrementalConfig.incrementalAdd
|
2021-03-19 16:57:52 +08:00
|
|
|
} else {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.sql = ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 16:57:52 +08:00
|
|
|
if (this.incrementalUpdateType === 'incrementalDelete') {
|
|
|
|
if (this.sql) {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.incrementalConfig.incrementalAdd = this.sql
|
|
|
|
}
|
2021-03-19 16:57:52 +08:00
|
|
|
if (this.incrementalConfig.incrementalDelete) {
|
|
|
|
this.sql = this.incrementalConfig.incrementalDelete
|
|
|
|
} else {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.sql = ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
showConfig() {
|
|
|
|
this.update_setting = true
|
2021-03-04 15:38:37 +08:00
|
|
|
this.listTask()
|
2021-03-18 17:59:52 +08:00
|
|
|
this.getIncrementalConfig()
|
2021-03-04 15:38:37 +08:00
|
|
|
},
|
|
|
|
addTask(task) {
|
|
|
|
if (!task) {
|
|
|
|
this.resetTaskForm()
|
|
|
|
this.taskForm.name = this.table.name + ' ' + this.$t('dataset.task_update')
|
|
|
|
this.taskForm.startTime = new Date()
|
|
|
|
} else {
|
|
|
|
this.taskForm = JSON.parse(JSON.stringify(task))
|
|
|
|
}
|
|
|
|
this.update_task = true
|
|
|
|
},
|
|
|
|
listTask() {
|
|
|
|
post('/dataset/task/list', { tableId: this.table.id }).then(response => {
|
|
|
|
this.taskData = response.data
|
|
|
|
})
|
|
|
|
},
|
2021-03-18 17:59:52 +08:00
|
|
|
getIncrementalConfig() {
|
|
|
|
post('/dataset/table/incrementalConfig', { tableId: this.table.id }).then(response => {
|
|
|
|
this.incrementalConfig = response.data
|
|
|
|
this.incrementalUpdateType = 'incrementalAdd'
|
2021-03-19 16:57:52 +08:00
|
|
|
if (this.incrementalConfig.incrementalAdd) {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.sql = this.incrementalConfig.incrementalAdd
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
saveIncrementalConfig() {
|
|
|
|
this.update_setting = false
|
2021-03-19 16:57:52 +08:00
|
|
|
if (this.incrementalUpdateType === 'incrementalAdd') {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.incrementalConfig.incrementalAdd = this.sql
|
2021-03-19 16:57:52 +08:00
|
|
|
} else {
|
2021-03-18 17:59:52 +08:00
|
|
|
this.incrementalConfig.incrementalDelete = this.sql
|
|
|
|
}
|
|
|
|
this.incrementalConfig.tableId = this.table.id
|
|
|
|
post('/dataset/table/save/incrementalConfig', this.incrementalConfig).then(response => {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('dataset.save_success'),
|
|
|
|
type: 'success',
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
2021-03-04 15:38:37 +08:00
|
|
|
saveTask(task) {
|
|
|
|
task.startTime = new Date(task.startTime).getTime()
|
|
|
|
task.endTime = new Date(task.endTime).getTime()
|
|
|
|
task.tableId = this.table.id
|
|
|
|
post('/dataset/task/save', task).then(response => {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('dataset.save_success'),
|
|
|
|
type: 'success',
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.update_task = false
|
|
|
|
this.resetTaskForm()
|
|
|
|
this.listTask()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
deleteTask(task) {
|
2021-03-08 10:05:09 +08:00
|
|
|
this.$confirm(this.$t('dataset.confirm_delete'), this.$t('dataset.tips'), {
|
|
|
|
confirmButtonText: this.$t('dataset.confirm'),
|
|
|
|
cancelButtonText: this.$t('dataset.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
post('/dataset/task/delete/' + task.id, null).then(response => {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('dataset.delete_success'),
|
|
|
|
type: 'success',
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.resetTaskForm()
|
|
|
|
this.listTask()
|
2021-03-04 15:38:37 +08:00
|
|
|
})
|
2021-03-08 10:05:09 +08:00
|
|
|
}).catch(() => {
|
2021-03-04 15:38:37 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
closeTask() {
|
|
|
|
this.update_task = false
|
|
|
|
this.resetTaskForm()
|
|
|
|
},
|
2021-03-05 14:19:23 +08:00
|
|
|
onRateChange() {
|
2021-03-18 17:59:52 +08:00
|
|
|
if (this.taskForm.rate === 'SIMPLE') {
|
2021-03-05 14:19:23 +08:00
|
|
|
this.taskForm.end = '0'
|
2021-03-08 11:35:28 +08:00
|
|
|
this.taskForm.endTime = ''
|
|
|
|
this.taskForm.cron = ''
|
2021-03-05 14:19:23 +08:00
|
|
|
}
|
|
|
|
},
|
2021-03-09 16:04:16 +08:00
|
|
|
listTaskLog() {
|
|
|
|
post('/dataset/taskLog/list/' + this.page.currentPage + '/' + this.page.pageSize, { tableId: this.table.id }).then(response => {
|
|
|
|
this.taskLogData = response.data.listObject
|
|
|
|
this.page.total = response.data.itemCount
|
|
|
|
})
|
|
|
|
},
|
2021-03-08 11:35:28 +08:00
|
|
|
handleSizeChange(val) {
|
2021-03-09 16:04:16 +08:00
|
|
|
this.listTaskLog()
|
2021-03-08 11:35:28 +08:00
|
|
|
},
|
|
|
|
handleCurrentChange(val) {
|
2021-03-09 16:04:16 +08:00
|
|
|
this.listTaskLog()
|
2021-03-08 11:35:28 +08:00
|
|
|
},
|
2021-03-04 15:38:37 +08:00
|
|
|
resetTaskForm() {
|
|
|
|
this.taskForm = {
|
|
|
|
name: '',
|
2021-03-18 17:59:52 +08:00
|
|
|
type: 'all_scope',
|
2021-03-04 15:38:37 +08:00
|
|
|
startTime: '',
|
2021-03-18 17:59:52 +08:00
|
|
|
rate: 'SIMPLE',
|
2021-03-04 15:38:37 +08:00
|
|
|
endTime: '',
|
|
|
|
end: '0'
|
|
|
|
}
|
2021-03-18 17:59:52 +08:00
|
|
|
},
|
2021-03-19 16:57:52 +08:00
|
|
|
showSQL(val) {
|
|
|
|
this.sql = val || ''
|
|
|
|
},
|
2021-03-18 17:59:52 +08:00
|
|
|
onCmReady(cm) {
|
|
|
|
this.codemirror.setSize('-webkit-fill-available', 'auto')
|
|
|
|
},
|
|
|
|
onCmFocus(cm) {
|
|
|
|
// console.log('the editor is focus!', cm)
|
|
|
|
},
|
|
|
|
onCmCodeChange(newCode) {
|
2021-03-19 16:57:52 +08:00
|
|
|
// console.log(newCode)
|
2021-03-18 17:59:52 +08:00
|
|
|
this.sql = newCode
|
|
|
|
this.$emit('codeChange', this.sql)
|
2021-03-19 16:57:52 +08:00
|
|
|
},
|
|
|
|
insertParamToCodeMirror(param) {
|
|
|
|
const pos1 = this.$refs.myCm.codemirror.getCursor()
|
|
|
|
const pos2 = {}
|
|
|
|
pos2.line = pos1.line
|
|
|
|
pos2.ch = pos1.ch
|
|
|
|
this.$refs.myCm.codemirror.replaceRange(param, pos2)
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.dialog-css >>> .el-dialog__header {
|
|
|
|
padding: 20px 20px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dialog-css >>> .el-dialog__body {
|
|
|
|
padding: 10px 20px 20px;
|
|
|
|
}
|
2021-03-04 15:38:37 +08:00
|
|
|
|
|
|
|
.el-form-item {
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
2021-03-18 17:59:52 +08:00
|
|
|
|
|
|
|
.codemirror {
|
2021-03-19 16:57:52 +08:00
|
|
|
height: 100px;
|
2021-03-18 17:59:52 +08:00
|
|
|
overflow-y: auto;
|
|
|
|
}
|
|
|
|
.codemirror >>> .CodeMirror-scroll {
|
2021-03-19 16:59:57 +08:00
|
|
|
height: 100px;
|
2021-03-18 17:59:52 +08:00
|
|
|
overflow-y: auto;
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
</style>
|