Merge pull request #3284 from dataease/dev

merge dev
This commit is contained in:
fit2cloudrd 2022-09-30 16:49:39 +08:00 committed by GitHub
commit 6678d34e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1079 additions and 248 deletions

View File

@ -781,6 +781,8 @@ public class MysqlQueryProvider extends QueryProvider {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
if (f.getDeExtractType() == 4) { // 处理 tinyint if (f.getDeExtractType() == 4) { // 处理 tinyint
stringBuilder.append("concat(`").append(f.getOriginName()).append("`,'') AS ").append(f.getDataeaseName()); stringBuilder.append("concat(`").append(f.getOriginName()).append("`,'') AS ").append(f.getDataeaseName());
} if (f.getDeExtractType() == 1 && f.getType().equalsIgnoreCase("YEAR")) { // 处理 YEAR
stringBuilder.append("").append(String.format(MySQLConstants.DATE_FORMAT, "CONCAT(" + f.getOriginName() + ",'-01-01')", MySQLConstants.DEFAULT_DATE_FORMAT)).append(" AS ").append(f.getDataeaseName());
} else { } else {
stringBuilder.append("`").append(f.getOriginName()).append("` AS ").append(f.getDataeaseName()); stringBuilder.append("`").append(f.getOriginName()).append("` AS ").append(f.getDataeaseName());
} }

View File

@ -310,7 +310,7 @@ public class DatasourceService {
} }
return ResultHolder.success(datasourceDTO); return ResultHolder.success(datasourceDTO);
} catch (Exception e) { } catch (Exception e) {
return ResultHolder.error(Translator.get("I18N_DS_INVALID"), e.getMessage()); return ResultHolder.error(Translator.get("I18N_DS_INVALID") + ": " + e.getMessage());
} }
} }
@ -350,7 +350,7 @@ public class DatasourceService {
return ResultHolder.success("Success"); return ResultHolder.success("Success");
} catch (Exception e) { } catch (Exception e) {
datasourceStatus = "Error"; datasourceStatus = "Error";
return ResultHolder.error(Translator.get("I18N_DS_INVALID"), e.getMessage()); return ResultHolder.error(Translator.get("I18N_DS_INVALID") + ": " + e.getMessage());
} finally { } finally {
Datasource record = new Datasource(); Datasource record = new Datasource();
record.setStatus(datasourceStatus); record.setStatus(datasourceStatus);

View File

@ -239,3 +239,24 @@ RETURN concat(chartName,'-copy(',chartNameCount,')');
END END
;; ;;
delimiter ; delimiter ;
delete from sys_auth where (auth_source in ('6','700','710','810','910') and auth_source_type='menu' and auth_target='1' and auth_target_type='role');
delete from sys_auth_detail where auth_id in (select id from sys_auth where auth_source in ('6','700','710','810','910') and auth_source_type='menu' and auth_target='1' and auth_target_type='role');
COMMIT;
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`, `copy_from`, `copy_id`) VALUES ('0c045d89-85ea-4676-8b5e-4b3dae5a734d', '700', 'menu', '1', 'role', 1664521306828, NULL, 'admin', NULL, NULL, NULL);
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`, `copy_from`, `copy_id`) VALUES ('1a18aa12-8daa-4f47-b5eb-999e473273df', '6', 'menu', '1', 'role', 1630482450994, NULL, 'admin', NULL, NULL, NULL);
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`, `copy_from`, `copy_id`) VALUES ('37457802-97a6-4303-be89-cf82b4059db1', '910', 'menu', '1', 'role', 1664521307265, NULL, 'admin', NULL, NULL, NULL);
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`, `copy_from`, `copy_id`) VALUES ('9019e9e4-8ea6-47ea-9279-98d10be107fc', '710', 'menu', '1', 'role', 1664521307460, NULL, 'admin', NULL, NULL, NULL);
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`, `copy_from`, `copy_id`) VALUES ('d2368c49-33b0-46b2-894d-b182d1c03bd4', '810', 'menu', '1', 'role', 1664521307050, NULL, 'admin', NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('bfddec25-408d-11ed-8009-0242ac130005', '0c045d89-85ea-4676-8b5e-4b3dae5a734d', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('bfddf2e8-408d-11ed-8009-0242ac130005', '0c045d89-85ea-4676-8b5e-4b3dae5a734d', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('bfffbd09-408d-11ed-8009-0242ac130005', 'd2368c49-33b0-46b2-894d-b182d1c03bd4', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('bfffbf74-408d-11ed-8009-0242ac130005', 'd2368c49-33b0-46b2-894d-b182d1c03bd4', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('c01e6d09-408d-11ed-8009-0242ac130005', '37457802-97a6-4303-be89-cf82b4059db1', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('c01e6fb3-408d-11ed-8009-0242ac130005', '37457802-97a6-4303-be89-cf82b4059db1', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('c03c0af2-408d-11ed-8009-0242ac130005', '9019e9e4-8ea6-47ea-9279-98d10be107fc', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('c03c0dc3-408d-11ed-8009-0242ac130005', '9019e9e4-8ea6-47ea-9279-98d10be107fc', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1664521307000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('ddec6eab-0af8-11ec-a2b0-0242ac130003', '1a18aa12-8daa-4f47-b5eb-999e473273df', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482453000, NULL, NULL, NULL);
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`, `copy_id`) VALUES ('ddeccfa8-0af8-11ec-a2b0-0242ac130003', '1a18aa12-8daa-4f47-b5eb-999e473273df', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482453000, NULL, NULL, NULL);

File diff suppressed because one or more lines are too long

View File

@ -222,13 +222,13 @@ I18N_START_TIME=Start time
I18N_END_TIME=End time I18N_END_TIME=End time
I18N_STATUS=Status I18N_STATUS=Status
I18N_DATA=Data I18N_DATA=Data
I18N_SYNC_LOG=Sync log I18N_SYNC_LOG=Sync logI18N_DS_INVALID
I18N_USER_DONOT_EXIST=User does not exist I18N_USER_DONOT_EXIST=User does not exist
I18N_USER_SOURCE_PWD_ERROR=Source password error I18N_USER_SOURCE_PWD_ERROR=Source password error
I18N_USER_PWD_FORMAT_ERROR=Password format error I18N_USER_PWD_FORMAT_ERROR=Password format error
I18N_DS_INVALID=Datasource is invalid. I18N_DS_INVALID=Datasource is invalid
I18N_DS_INVALID_TABLE=Datasource has invalid tables I18N_DS_INVALID_TABLE=Datasource has invalid tables

View File

@ -228,7 +228,7 @@ I18N_USER_DONOT_EXIST=\u7528\u6237\u4E0D\u5B58\u5728
I18N_USER_SOURCE_PWD_ERROR=\u539F\u59CB\u5BC6\u7801\u9519\u8BEF I18N_USER_SOURCE_PWD_ERROR=\u539F\u59CB\u5BC6\u7801\u9519\u8BEF
I18N_USER_PWD_FORMAT_ERROR=\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF I18N_USER_PWD_FORMAT_ERROR=\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF
I18N_DS_INVALID=\u6570\u636E\u6E90\u65E0\u6548. I18N_DS_INVALID=\u6570\u636E\u6E90\u65E0\u6548
I18N_DS_INVALID_TABLE=\u6570\u636E\u6E90\u4E2D\u6709\u65E0\u6548\u7684\u8868 I18N_DS_INVALID_TABLE=\u6570\u636E\u6E90\u4E2D\u6709\u65E0\u6548\u7684\u8868

View File

@ -224,7 +224,7 @@ I18N_USER_DONOT_EXIST=\u7528\u6236\u4E0D\u5B58\u5728
I18N_USER_SOURCE_PWD_ERROR=\u539F\u59CB\u5BC6\u78BC\u932F\u8AA4 I18N_USER_SOURCE_PWD_ERROR=\u539F\u59CB\u5BC6\u78BC\u932F\u8AA4
I18N_USER_PWD_FORMAT_ERROR=\u5BC6\u78BC\u683C\u5F0F\u932F\u8AA4 I18N_USER_PWD_FORMAT_ERROR=\u5BC6\u78BC\u683C\u5F0F\u932F\u8AA4
I18N_DS_INVALID=\u6578\u64DA\u6E90\u7121\u6548. I18N_DS_INVALID=\u6578\u64DA\u6E90\u7121\u6548
I18N_DS_INVALID_TABLE=\u6578\u64DA\u6E90\u4E2D\u6709\u7121\u6548\u7684\u8868 I18N_DS_INVALID_TABLE=\u6578\u64DA\u6E90\u4E2D\u6709\u7121\u6548\u7684\u8868

View File

@ -23,8 +23,8 @@
<el-dropdown-item v-if="linkageSettingShow" icon="el-icon-link" @click.native="linkageSetting">{{ $t('panel.linkage_setting') }}</el-dropdown-item> <el-dropdown-item v-if="linkageSettingShow" icon="el-icon-link" @click.native="linkageSetting">{{ $t('panel.linkage_setting') }}</el-dropdown-item>
<el-dropdown-item v-if="'de-tabs'===curComponent.type" icon="el-icon-plus" @click.native="addTab">{{ $t('panel.add_tab') }}</el-dropdown-item> <el-dropdown-item v-if="'de-tabs'===curComponent.type" icon="el-icon-plus" @click.native="addTab">{{ $t('panel.add_tab') }}</el-dropdown-item>
<el-dropdown-item v-if="linkJumpSetShow" icon="el-icon-connection" @click.native="linkJumpSet">{{ $t('panel.setting_jump') }}</el-dropdown-item> <el-dropdown-item v-if="linkJumpSetShow" icon="el-icon-connection" @click.native="linkJumpSet">{{ $t('panel.setting_jump') }}</el-dropdown-item>
<el-dropdown-item icon="el-icon-magic-stick" @click.native="boardSet">{{ $t('panel.component_style') }}</el-dropdown-item> <el-dropdown-item v-if="curComponent.type != 'custom-button'" icon="el-icon-magic-stick" @click.native="boardSet">{{ $t('panel.component_style') }}</el-dropdown-item>
<el-dropdown-item @click.native="hyperlinksSet"> <el-dropdown-item v-if="curComponent.type != 'custom-button'" @click.native="hyperlinksSet">
<i class="icon iconfont icon-font icon-chaolianjie1" /> <i class="icon iconfont icon-font icon-chaolianjie1" />
{{ $t('panel.hyperlinks') }} {{ $t('panel.hyperlinks') }}
</el-dropdown-item> </el-dropdown-item>

View File

@ -380,7 +380,11 @@ export function adaptCurThemeCommonStyle(component) {
} else if (isTabComponent(component.component)) { } else if (isTabComponent(component.component)) {
const tabStyle = store.state.canvasStyleData.chartInfo.tabStyle const tabStyle = store.state.canvasStyleData.chartInfo.tabStyle
for (const styleKey in tabStyle) { for (const styleKey in tabStyle) {
if(typeof tabStyle[styleKey] === 'string'){
Vue.set(component.style, styleKey, tabStyle[styleKey]) Vue.set(component.style, styleKey, tabStyle[styleKey])
}else{
Vue.set(component.style, styleKey, null)
}
} }
} else { } else {
if (component.style.color) { if (component.style.color) {

View File

@ -596,6 +596,7 @@ export default {
handler() { handler() {
if (hasDataPermission('manage', this.param.privileges)) { if (hasDataPermission('manage', this.param.privileges)) {
this.listTask() this.listTask()
this.getIncrementalConfig()
} }
this.listTaskLog() this.listTaskLog()
}, },
@ -792,19 +793,6 @@ export default {
return false return false
// !hasDataPermission('manage',task.privileges) // !hasDataPermission('manage',task.privileges)
}, },
deleteTask(task) {
const options = {
title: '确定删除该任务吗?',
type: 'primary',
cb: () => {
post('/dataset/task/delete/' + task.id, null).then((response) => {
this.openMessageSuccess('commons.delete_success')
this.initSearch()
})
}
}
this.handlerConfirm(options)
},
selectDataset(row) { selectDataset(row) {
this.disableForm = this.disableEdit(row) this.disableForm = this.disableEdit(row)
this.addTask(row) this.addTask(row)
@ -869,6 +857,23 @@ export default {
} }
}) })
}, },
getIncrementalConfig() {
post('/dataset/table/incrementalConfig', { tableId: this.table.id }).then(response => {
this.incrementalConfig = response.data
if (this.incrementalConfig.incrementalAdd.length === 0 && this.incrementalConfig.incrementalDelete.length === 0) {
this.incrementalUpdateType = 'incrementalAdd'
this.sql = ''
return
}
if (this.incrementalConfig.incrementalAdd.length > 0) {
this.incrementalUpdateType = 'incrementalAdd'
this.sql = this.incrementalConfig.incrementalAdd
} else {
this.incrementalUpdateType = 'incrementalDelete'
this.sql = this.incrementalConfig.incrementalDelete
}
})
},
deleteTask(task) { deleteTask(task) {
this.$confirm( this.$confirm(
this.$t('dataset.confirm_delete'), this.$t('dataset.confirm_delete'),

View File

@ -243,7 +243,7 @@
" "
:label="$t('datasource.extra_params')" :label="$t('datasource.extra_params')"
> >
<el-input :placeholder="$t('fu.search_bar.please_input') + $t('datasource.extra_params')" v-model="form.configuration.extraParams" autocomplete="off" /> <el-input v-model="form.configuration.extraParams" :placeholder="$t('fu.search_bar.please_input') + $t('datasource.extra_params')" autocomplete="off" />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
@ -725,7 +725,8 @@ export default {
{ {
required: true, required: true,
validator: this.nameRepeat, validator: this.nameRepeat,
trigger: 'blur' trigger: 'blur',
message: i18n.t('commons.input_name')
} }
], ],
desc: [ desc: [
@ -969,6 +970,10 @@ export default {
}) })
}, },
nameRepeat(rule, value, callback) { nameRepeat(rule, value, callback) {
if (!value) {
callback(new Error(i18n.t('commons.input_name')))
return
}
let hasRepeatName = false let hasRepeatName = false
this.form.apiConfiguration.forEach((item) => { this.form.apiConfiguration.forEach((item) => {
if ( if (
@ -979,10 +984,10 @@ export default {
} }
}) })
if (hasRepeatName) { if (hasRepeatName) {
callback(new Error(i18n.t('theme.name_repeat'))); callback(new Error(i18n.t('theme.name_repeat')))
return return
} }
callback(); callback()
}, },
next() { next() {
if (this.active === 1) { if (this.active === 1) {

View File

@ -166,7 +166,7 @@
>{{ >{{
$t(`dataset.${scope.row.lastExecStatus.toLocaleLowerCase()}`) $t(`dataset.${scope.row.lastExecStatus.toLocaleLowerCase()}`)
}} }}
<svg-icon style="cursor: pointer;" v-if="scope.row.lastExecStatus === 'Error'" @click="showErrorMassage(scope.row.msg)" icon-class="icon-maybe" class="field-icon-location" /> <svg-icon v-if="scope.row.lastExecStatus === 'Error'" style="cursor: pointer;" icon-class="icon-maybe" class="field-icon-location" @click="showErrorMassage(scope.row.msg)" />
</span> </span>
<span v-else>-</span> <span v-else>-</span>
</template> </template>
@ -202,7 +202,8 @@
:label="$t('dataset.task.task_status')" :label="$t('dataset.task.task_status')"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span :class="[`de-${scope.row.status}-result`, 'de-status']" <span
:class="[`de-${scope.row.status}-result`, 'de-status']"
>{{ $t(`dataset.task.${scope.row.status.toLocaleLowerCase()}`) }} >{{ $t(`dataset.task.${scope.row.status.toLocaleLowerCase()}`) }}
</span> </span>
</template> </template>
@ -589,12 +590,13 @@ export default {
}, },
selectDataset(row) { selectDataset(row) {
if (row) { if (row) {
const { datasetName, id } = row const { datasetName, id, tableId } = row
this.$router.push({ this.$router.push({
path: '/task-ds-form', path: '/task-ds-form',
query: { query: {
datasetName, datasetName,
id id,
tableId
} }
}) })
} else { } else {

View File

@ -1,5 +1,5 @@
<template> <template>
<de-layout-content :header="header" backPath="/system/system-task/dataset"> <de-layout-content :header="header" back-path="/system/system-task/dataset">
<div class="dataset-editer-form"> <div class="dataset-editer-form">
<div class="w600"> <div class="w600">
<el-form <el-form
@ -12,9 +12,9 @@
:rules="taskFormRules" :rules="taskFormRules"
> >
<el-form-item <el-form-item
@click.native="selectDataset"
:label="$t('chart.select_dataset')" :label="$t('chart.select_dataset')"
prop="datasetName" prop="datasetName"
@click.native="selectDataset"
> >
<el-input <el-input
v-model="taskForm.datasetName" v-model="taskForm.datasetName"
@ -37,11 +37,10 @@
$t("dataset.all_scope") $t("dataset.all_scope")
}}</el-radio> }}</el-radio>
<el-radio label="add_scope"> <el-radio label="add_scope">
{{ $t("dataset.add_scope") }}</el-radio {{ $t("dataset.add_scope") }}</el-radio>
>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<div class="add-scope-cont" v-if="taskForm.type === 'add_scope'"> <div v-if="taskForm.type === 'add_scope'" class="add-scope-cont">
<el-form-item <el-form-item
prop="type" prop="type"
:label="$t('dataset.incremental_update_type')" :label="$t('dataset.incremental_update_type')"
@ -65,16 +64,14 @@
type="text" type="text"
size="small" size="small"
@click="insertParamToCodeMirror('${__last_update_time__}')" @click="insertParamToCodeMirror('${__last_update_time__}')"
>{{ $t("dataset.last_update_time") }}</el-button >{{ $t("dataset.last_update_time") }}</el-button>
>
<el-button <el-button
type="text" type="text"
size="small" size="small"
@click=" @click="
insertParamToCodeMirror('${__current_update_time__}') insertParamToCodeMirror('${__current_update_time__}')
" "
>{{ $t("dataset.current_update_time") }}</el-button >{{ $t("dataset.current_update_time") }}</el-button>
>
</div> </div>
</div> </div>
<div class="codemirror-cont"> <div class="codemirror-cont">
@ -102,7 +99,7 @@
}}</el-radio> }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<div class="execute-rate-cont" v-if="taskForm.rate !== 'SIMPLE'"> <div v-if="taskForm.rate !== 'SIMPLE'" class="execute-rate-cont">
<el-form-item <el-form-item
v-if="taskForm.rate === 'SIMPLE_CRON'" v-if="taskForm.rate === 'SIMPLE_CRON'"
:label="$t('dataset.execute_rate')" :label="$t('dataset.execute_rate')"
@ -116,7 +113,7 @@
:min="1" :min="1"
size="small" size="small"
@change="onSimpleCronChange()" @change="onSimpleCronChange()"
></el-input-number> />
<el-select <el-select
v-model="taskForm.extraData.simple_cron_type" v-model="taskForm.extraData.simple_cron_type"
filterable filterable
@ -131,14 +128,14 @@
</div> </div>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
prop="cron"
v-if="taskForm.rate === 'CRON' && showCron" v-if="taskForm.rate === 'CRON' && showCron"
prop="cron"
:label="$t('emailtask.cron_exp')" :label="$t('emailtask.cron_exp')"
> >
<el-popover v-model="cronEdit"> <el-popover v-model="cronEdit">
<cron <cron
:isRate="taskForm.rate === 'CRON'"
v-model="taskForm.cron" v-model="taskForm.cron"
:is-rate="taskForm.rate === 'CRON'"
@close="cronEdit = false" @close="cronEdit = false"
/> />
<el-input <el-input
@ -161,8 +158,7 @@
type="datetime" type="datetime"
:placeholder="$t('dataset.start_time')" :placeholder="$t('dataset.start_time')"
size="small" size="small"
> />
</el-date-picker>
<svg-icon icon-class="icon_calendar_outlined" class="icon-calendar-outlined" /> <svg-icon icon-class="icon_calendar_outlined" class="icon-calendar-outlined" />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
@ -188,13 +184,13 @@
</el-form> </el-form>
<table-selector <table-selector
ref="tableSelector" ref="tableSelector"
previewForTask="true" preview-for-task="true"
privileges="manage" privileges="manage"
@getTableId="getTableId"
:mode="1" :mode="1"
:clear-empty-dir="true" :clear-empty-dir="true"
:custom-type="['db', 'sql', 'api']" :custom-type="['db', 'sql', 'api']"
show-mode="datasetTask" show-mode="datasetTask"
@getTableId="getTableId"
/> />
</div> </div>
<div v-if="!disableForm" class="de-foot-layout"> <div v-if="!disableForm" class="de-foot-layout">
@ -210,30 +206,30 @@
</template> </template>
<script> <script>
import { post } from "@/api/dataset/dataset"; import { post } from '@/api/dataset/dataset'
import DeLayoutContent from "@/components/business/DeLayoutContent"; import DeLayoutContent from '@/components/business/DeLayoutContent'
import { hasDataPermission } from "@/utils/permission"; import { hasDataPermission } from '@/utils/permission'
import msgCfm from "@/components/msgCfm/index"; import msgCfm from '@/components/msgCfm/index'
import cron from "@/components/cron/cron"; import cron from '@/components/cron/cron'
import { codemirror } from "vue-codemirror"; import { codemirror } from 'vue-codemirror'
import "codemirror/lib/codemirror.css"; import 'codemirror/lib/codemirror.css'
import "codemirror/theme/eclipse.css"; import 'codemirror/theme/eclipse.css'
import "codemirror/mode/sql/sql.js"; import 'codemirror/mode/sql/sql.js'
import "codemirror/addon/selection/active-line.js"; import 'codemirror/addon/selection/active-line.js'
import "codemirror/addon/edit/closebrackets.js"; import 'codemirror/addon/edit/closebrackets.js'
import "codemirror/mode/clike/clike.js"; import 'codemirror/mode/clike/clike.js'
import "codemirror/addon/edit/matchbrackets.js"; import 'codemirror/addon/edit/matchbrackets.js'
import "codemirror/addon/comment/comment.js"; import 'codemirror/addon/comment/comment.js'
import "codemirror/addon/dialog/dialog.js"; import 'codemirror/addon/dialog/dialog.js'
import "codemirror/addon/dialog/dialog.css"; import 'codemirror/addon/dialog/dialog.css'
import "codemirror/addon/search/searchcursor.js"; import 'codemirror/addon/search/searchcursor.js'
import "codemirror/addon/search/search.js"; import 'codemirror/addon/search/search.js'
import "codemirror/keymap/emacs.js"; import 'codemirror/keymap/emacs.js'
import "codemirror/addon/hint/show-hint.css"; import 'codemirror/addon/hint/show-hint.css'
import "codemirror/addon/hint/sql-hint"; import 'codemirror/addon/hint/sql-hint'
import "codemirror/addon/hint/show-hint"; import 'codemirror/addon/hint/show-hint'
import TableSelector from "./TableSelector"; import TableSelector from './TableSelector'
export default { export default {
components: { cron, codemirror, TableSelector, DeLayoutContent }, components: { cron, codemirror, TableSelector, DeLayoutContent },
@ -242,80 +238,80 @@ export default {
return { return {
disableForm: false, disableForm: false,
table: { table: {
name: "", name: '',
id: "", id: ''
}, },
showCron: false, showCron: false,
taskForm: { taskForm: {
name: "", name: '',
type: "all_scope", type: 'all_scope',
startTime: "", startTime: '',
tableId: "", tableId: '',
rate: "SIMPLE", rate: 'SIMPLE',
cron: "", cron: '',
endTime: "", endTime: '',
end: "0", end: '0',
extraData: { extraData: {
simple_cron_type: "hour", simple_cron_type: 'hour',
simple_cron_value: 1, simple_cron_value: 1
}, }
}, },
taskFormRules: { taskFormRules: {
name: [ name: [
{ {
required: true, required: true,
message: this.$t("dataset.required"), message: this.$t('dataset.required'),
trigger: "change", trigger: 'change'
}, },
{ {
min: 2, min: 2,
max: 50, max: 50,
message: this.$t("datasource.input_limit_2_50", [2, 50]), message: this.$t('datasource.input_limit_2_50', [2, 50]),
trigger: "blur", trigger: 'blur'
}, }
], ],
type: [ type: [
{ {
required: true, required: true,
message: this.$t("dataset.required"), message: this.$t('dataset.required'),
trigger: "change", trigger: 'change'
}, }
], ],
startTime: [ startTime: [
{ {
required: true, required: true,
message: this.$t("components.time_is_required"), message: this.$t('components.time_is_required'),
trigger: "change", trigger: 'change'
}, }
], ],
rate: [ rate: [
{ {
required: true, required: true,
message: this.$t("dataset.required"), message: this.$t('dataset.required'),
trigger: "change", trigger: 'change'
}, }
], ],
end: [ end: [
{ {
required: true, required: true,
message: this.$t("dataset.required"), message: this.$t('dataset.required'),
trigger: "change", trigger: 'change'
}, }
], ],
cron: [ cron: [
{ {
required: true, required: true,
message: this.$t("dataset.required"), message: this.$t('dataset.required'),
trigger: "change", trigger: 'change'
}, }
], ],
datasetName: [ datasetName: [
{ {
required: true, required: true,
message: this.$t("components.data_set_required"), message: this.$t('components.data_set_required'),
trigger: "change", trigger: 'change'
}, }
], ]
}, },
cronEdit: false, cronEdit: false,
sqlOption: { sqlOption: {
@ -323,230 +319,231 @@ export default {
styleActiveLine: true, styleActiveLine: true,
lineNumbers: true, lineNumbers: true,
line: true, line: true,
mode: "text/x-sql", mode: 'text/x-sql',
theme: "eclipse", theme: 'eclipse',
hintOptions: { hintOptions: {
// //
completeSingle: false, // completeSingle: false //
}, }
}, },
incrementalConfig: {}, incrementalConfig: {},
sql: "", sql: '',
incrementalUpdateType: "incrementalAdd", incrementalUpdateType: 'incrementalAdd'
}; }
}, },
computed: { computed: {
header() { header() {
return this.disableForm return this.disableForm
? "查看任务" ? '查看任务'
: this.taskDetail.id : this.taskDetail.id
? "编辑任务" ? '编辑任务'
: "添加任务"; : '添加任务'
}, }
}, },
created() { created() {
const { datasetName, id } = this.$route.query; const { datasetName, id, tableId } = this.$route.query
this.taskDetail = { datasetName, id }; this.taskDetail = { datasetName, id, tableId }
if (!id) { if (!id) {
this.taskForm.startTime = new Date() this.taskForm.startTime = new Date()
return; return
}; }
this.getTaskDetail(id); this.getTaskDetail(id)
this.getIncrementalConfig(tableId)
}, },
methods: { methods: {
getTaskDetail(id) { getTaskDetail(id) {
post(`/dataset/task/detail/${id}`, {}).then((res) => { post(`/dataset/task/detail/${id}`, {}).then((res) => {
if (res.data.extraData) { if (res.data.extraData) {
res.data.extraData = JSON.parse(res.data.extraData); res.data.extraData = JSON.parse(res.data.extraData)
} }
this.taskForm = res.data; this.taskForm = res.data
this.showCron = this.taskForm.rate === 'CRON' this.showCron = this.taskForm.rate === 'CRON'
this.disableForm = this.disableEdit(); this.disableForm = this.disableEdit()
}); })
}, },
selectDataset() { selectDataset() {
if (this.taskForm.id) return; if (this.taskForm.id) return
this.$refs.tableSelector.init(); this.$refs.tableSelector.init()
}, },
getTableId(id, name) { getTableId(id, name) {
this.taskForm.tableId = id; this.taskForm.tableId = id
this.$set(this.taskForm, "datasetName", name); this.$set(this.taskForm, 'datasetName', name)
}, },
onRateChange() { onRateChange() {
if (this.taskForm.rate === "SIMPLE") { if (this.taskForm.rate === 'SIMPLE') {
this.taskForm.end = "0"; this.taskForm.end = '0'
this.taskForm.endTime = ""; this.taskForm.endTime = ''
this.taskForm.cron = ""; this.taskForm.cron = ''
this.showCron = false; this.showCron = false
} }
if (this.taskForm.rate === "SIMPLE_CRON") { if (this.taskForm.rate === 'SIMPLE_CRON') {
this.taskForm.cron = "0 0 0/1 * * ? *"; this.taskForm.cron = '0 0 0/1 * * ? *'
this.showCron = false; this.showCron = false
} }
if (this.taskForm.rate === "CRON") { if (this.taskForm.rate === 'CRON') {
this.taskForm.cron = "00 00 * ? * * *"; this.taskForm.cron = '00 00 * ? * * *'
this.$nextTick(() => { this.$nextTick(() => {
this.showCron = true; this.showCron = true
}); })
} }
}, },
disableEdit() { disableEdit() {
const { privileges, rate, status } = this.taskForm; const { privileges, rate, status } = this.taskForm
return ( return (
rate === "SIMPLE" || rate === 'SIMPLE' ||
status === "Stopped" || status === 'Stopped' ||
!hasDataPermission("manage", privileges) !hasDataPermission('manage', privileges)
); )
}, },
onCmReady(cm) { onCmReady(cm) {
// this.codemirror.setSize("-webkit-fill-available", "auto"); // this.codemirror.setSize("-webkit-fill-available", "auto");
}, },
onCmFocus(cm) {}, onCmFocus(cm) {},
onCmCodeChange(newCode) { onCmCodeChange(newCode) {
this.sql = newCode; this.sql = newCode
this.$emit("codeChange", this.sql); this.$emit('codeChange', this.sql)
}, },
closeTask() { closeTask() {
this.$router.back(); this.$router.back()
}, },
onSimpleCronChange() { onSimpleCronChange() {
if (this.taskForm.extraData.simple_cron_type === "minute") { if (this.taskForm.extraData.simple_cron_type === 'minute') {
if ( if (
this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value < 1 ||
this.taskForm.extraData.simple_cron_value > 59 this.taskForm.extraData.simple_cron_value > 59
) { ) {
this.$message({ this.$message({
message: this.$t("cron.minute_limit"), message: this.$t('cron.minute_limit'),
type: "warning", type: 'warning',
showClose: true, showClose: true
}); })
this.taskForm.extraData.simple_cron_value = 59; this.taskForm.extraData.simple_cron_value = 59
} }
this.taskForm.cron = this.taskForm.cron =
"0 0/" + this.taskForm.extraData.simple_cron_value + " * * * ? *"; '0 0/' + this.taskForm.extraData.simple_cron_value + ' * * * ? *'
return; return
} }
if (this.taskForm.extraData.simple_cron_type === "hour") { if (this.taskForm.extraData.simple_cron_type === 'hour') {
if ( if (
this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value < 1 ||
this.taskForm.extraData.simple_cron_value > 23 this.taskForm.extraData.simple_cron_value > 23
) { ) {
this.$message({ this.$message({
message: this.$t("cron.hour_limit"), message: this.$t('cron.hour_limit'),
type: "warning", type: 'warning',
showClose: true, showClose: true
}); })
this.taskForm.extraData.simple_cron_value = 23; this.taskForm.extraData.simple_cron_value = 23
} }
this.taskForm.cron = this.taskForm.cron =
"0 0 0/" + this.taskForm.extraData.simple_cron_value + " * * ? *"; '0 0 0/' + this.taskForm.extraData.simple_cron_value + ' * * ? *'
return; return
} }
if (this.taskForm.extraData.simple_cron_type === "day") { if (this.taskForm.extraData.simple_cron_type === 'day') {
if ( if (
this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value < 1 ||
this.taskForm.extraData.simple_cron_value > 31 this.taskForm.extraData.simple_cron_value > 31
) { ) {
this.$message({ this.$message({
message: this.$t("cron.day_limit"), message: this.$t('cron.day_limit'),
type: "warning", type: 'warning',
showClose: true, showClose: true
}); })
this.taskForm.extraData.simple_cron_value = 31; this.taskForm.extraData.simple_cron_value = 31
} }
this.taskForm.cron = this.taskForm.cron =
"0 0 0 1/" + this.taskForm.extraData.simple_cron_value + " * ? *"; '0 0 0 1/' + this.taskForm.extraData.simple_cron_value + ' * ? *'
return; return
} }
}, },
insertParamToCodeMirror(param) { insertParamToCodeMirror(param) {
const pos1 = this.$refs.myCm.codemirror.getCursor(); const pos1 = this.$refs.myCm.codemirror.getCursor()
const pos2 = {}; const pos2 = {}
pos2.line = pos1.line; pos2.line = pos1.line
pos2.ch = pos1.ch; pos2.ch = pos1.ch
this.$refs.myCm.codemirror.replaceRange(param, pos2); this.$refs.myCm.codemirror.replaceRange(param, pos2)
}, },
saveTask(task) { saveTask(task) {
this.$refs.taskForm.validate((valid) => { this.$refs.taskForm.validate((valid) => {
if (valid) { if (valid) {
if (task.rate !== "SIMPLE") { if (task.rate !== 'SIMPLE') {
if (this.incrementalUpdateType === "incrementalAdd") { if (this.incrementalUpdateType === 'incrementalAdd') {
this.incrementalConfig.incrementalAdd = this.sql; this.incrementalConfig.incrementalAdd = this.sql
} else { } else {
this.incrementalConfig.incrementalDelete = this.sql; this.incrementalConfig.incrementalDelete = this.sql
} }
this.incrementalConfig.tableId = task.tableId; this.incrementalConfig.tableId = task.tableId
} }
task.startTime = new Date(task.startTime).getTime(); task.startTime = new Date(task.startTime).getTime()
task.endTime = new Date(task.endTime).getTime(); task.endTime = new Date(task.endTime).getTime()
const form = JSON.parse(JSON.stringify(task)); const form = JSON.parse(JSON.stringify(task))
form.extraData = JSON.stringify(form.extraData); form.extraData = JSON.stringify(form.extraData)
const dataSetTaskRequest = { const dataSetTaskRequest = {
datasetTableTask: form, datasetTableTask: form,
datasetTableIncrementalConfig: datasetTableIncrementalConfig:
task.type === "add_scope" ? this.incrementalConfig : undefined, task.type === 'add_scope' ? this.incrementalConfig : undefined
};
post("/dataset/task/save", dataSetTaskRequest).then((response) => {
this.openMessageSuccess("dataset.save_success");
this.closeTask();
});
} else {
return false;
} }
}); post('/dataset/task/save', dataSetTaskRequest).then((response) => {
this.openMessageSuccess('dataset.save_success')
this.closeTask()
})
} else {
return false
}
})
}, },
getIncrementalConfig(tableId) { getIncrementalConfig(tableId) {
post("/dataset/table/incrementalConfig", { tableId: tableId }).then( post('/dataset/table/incrementalConfig', { tableId: tableId }).then(
(response) => { (response) => {
this.incrementalConfig = response.data; this.incrementalConfig = response.data
if ( if (
this.incrementalConfig.incrementalAdd.length === 0 && this.incrementalConfig.incrementalAdd.length === 0 &&
this.incrementalConfig.incrementalDelete.length === 0 this.incrementalConfig.incrementalDelete.length === 0
) { ) {
this.incrementalUpdateType = "incrementalAdd"; this.incrementalUpdateType = 'incrementalAdd'
this.sql = ""; this.sql = ''
return; return
} }
if (this.incrementalConfig.incrementalAdd.length > 0) { if (this.incrementalConfig.incrementalAdd.length > 0) {
this.incrementalUpdateType = "incrementalAdd"; this.incrementalUpdateType = 'incrementalAdd'
this.sql = this.incrementalConfig.incrementalAdd; this.sql = this.incrementalConfig.incrementalAdd
} else { } else {
this.incrementalUpdateType = "incrementalDelete"; this.incrementalUpdateType = 'incrementalDelete'
this.sql = this.incrementalConfig.incrementalDelete; this.sql = this.incrementalConfig.incrementalDelete
} }
} }
); )
}, },
incrementalUpdateTypeChange: function () { incrementalUpdateTypeChange: function() {
if (this.incrementalUpdateType === "incrementalAdd") { if (this.incrementalUpdateType === 'incrementalAdd') {
if (this.sql) { if (this.sql) {
this.incrementalConfig.incrementalDelete = this.sql; this.incrementalConfig.incrementalDelete = this.sql
} else { } else {
this.incrementalConfig.incrementalDelete = ""; this.incrementalConfig.incrementalDelete = ''
} }
if (this.incrementalConfig.incrementalAdd) { if (this.incrementalConfig.incrementalAdd) {
this.sql = this.incrementalConfig.incrementalAdd; this.sql = this.incrementalConfig.incrementalAdd
} else { } else {
this.sql = ""; this.sql = ''
} }
} }
if (this.incrementalUpdateType === "incrementalDelete") { if (this.incrementalUpdateType === 'incrementalDelete') {
if (this.sql) { if (this.sql) {
this.incrementalConfig.incrementalAdd = this.sql; this.incrementalConfig.incrementalAdd = this.sql
} else { } else {
this.incrementalConfig.incrementalAdd = ""; this.incrementalConfig.incrementalAdd = ''
} }
if (this.incrementalConfig.incrementalDelete) { if (this.incrementalConfig.incrementalDelete) {
this.sql = this.incrementalConfig.incrementalDelete; this.sql = this.incrementalConfig.incrementalDelete
} else { } else {
this.sql = ""; this.sql = ''
} }
} }
}, }
}, }
}; }
</script> </script>
<style lang="scss"> <style lang="scss">