Merge pull request #3238 from dataease/pr@dev_dataset_source

Pr@dev dataset source
This commit is contained in:
xuwei-fit2cloud 2022-09-28 16:54:06 +08:00 committed by GitHub
commit d38e556671
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 219 additions and 112 deletions

View File

@ -145,11 +145,12 @@ export function batchEdit(data) {
})
}
export function post(url, data, showLoading = true, timeout = 60000) {
export function post(url, data, showLoading = true, timeout = 60000, hideMsg) {
return request({
url: url,
method: 'post',
loading: showLoading,
hideMsg,
data
})
}

View File

@ -12,7 +12,7 @@ export default {
});
},
handlerConfirm(options,confirmButtonTextInfo) {
let { title, content, type = 'danger', cb, confirmButtonText = confirmButtonTextInfo?confirmButtonTextInfo:this.$t('commons.delete'), showCancelButton = true, cancelButtonText = this.$t("commons.cancel"), cancelCb = () => {} } = options;
let { title, content, type = 'danger', cb, confirmButtonText = confirmButtonTextInfo?confirmButtonTextInfo:this.$t('commons.delete'), showCancelButton = true, cancelButtonText = this.$t("commons.cancel"), cancelCb = () => {}, finallyCb = () => {} } = options;
let text = content ? `<span>${ this.$t(title) }</span><br><span class="use-html">${ this.$t(content) }</span>` : this.$t(title);
const dangerouslyUseHTMLString = Boolean(content);
let customClass = `de-confirm de-confirm-fail ${ dangerouslyUseHTMLString && 'de-use-html'}`
@ -34,8 +34,11 @@ export default {
.then(() => {
cb();
})
.catch(() => {
cancelCb()
.catch((action) => {
cancelCb(action)
})
.finally(() => {
finallyCb()
});
},
},

View File

@ -17,7 +17,7 @@ export const $confirm = (message, callback, options = {}) => {
const title = i18n.t('commons.message_box.confirm')
MessageBox.confirm(message, title, defaultOptions).then(() => {
callback()
})
}).catch(() => {})
}
export const $success = (message, duration) => {

View File

@ -116,7 +116,7 @@ service.interceptors.response.use(response => {
msg = error.message
}
!config.hideMsg && (!headers['authentication-status']) && $error(msg)
return Promise.reject(error)
return Promise.reject(config.url === '/dataset/table/sqlPreview' ? msg : error)
})
const checkDownError = response => {
if (response.request && response.request.responseType && response.request.responseType === 'blob' && response.headers && response.headers['de-down-error-msg']) {

View File

@ -5,14 +5,16 @@
</p>
<div v-show="showLeft" class="table-list">
<p class="select-ds">
<span>{{ $t('deDataset.select_data_table ') }}
<span
>{{ $t('deDataset.select_data_table ') }}
<el-tooltip class="item" effect="dark" placement="right">
<div slot="content">
{{ $t('dataset.excel_info_1') }}<br>
{{ $t('dataset.excel_info_2') }}<br>
{{ $t('dataset.excel_info_1') }}<br />
{{ $t('dataset.excel_info_2') }}<br />
{{ $t('dataset.excel_info_3') }}
</div>
<i class="el-icon-warning-outline" /> </el-tooltip></span>
<i class="el-icon-warning-outline" /> </el-tooltip
></span>
<i class="el-icon-d-arrow-left" @click="showLeft = false" />
</p>
<el-upload
@ -34,7 +36,7 @@
:loading="uploading"
secondary
:disabled="uploading"
>{{ $t('deDataset.upload_data') }}
>{{ $t('deDataset.upload_data') }}
</deBtn>
</el-upload>
<div class="table-checkbox-list">
@ -53,7 +55,10 @@
>
<span slot-scope="{ data }" class="custom-tree-node">
{{ data.excelLable }}
<span v-if="data.nameExsit && !param.tableId" class="error-name-exsit">
<span
v-if="data.nameExsit && !param.tableId"
class="error-name-exsit"
>
<svg-icon icon-class="exclamationmark" class="ds-icon-scene" />
</span>
</span>
@ -118,24 +123,20 @@
<svg-icon
v-if="field.fieldType === 'TEXT'"
icon-class="field_text"
class="field-icon-text"
/>
class="field-icon-text" />
<svg-icon
v-if="field.fieldType === 'DATETIME'"
icon-class="field_time"
class="field-icon-time"
/>
class="field-icon-time" />
<svg-icon
v-if="
field.fieldType === 'LONG' ||
field.fieldType === 'DOUBLE'
field.fieldType === 'DOUBLE'
"
icon-class="field_value"
class="field-icon-value"
/>
<i
class="el-icon-arrow-down el-icon--right"
/></span>
class="field-icon-value" />
<i class="el-icon-arrow-down el-icon--right"
/></span>
<el-dropdown-menu
slot="dropdown"
style="width: 178px"
@ -145,32 +146,34 @@
v-for="item in fieldOptions"
:key="item.value"
:command="item.value"
><span>
<svg-icon
v-if="item.value === 'TEXT'"
icon-class="field_text"
class="field-icon-text"
/>
<svg-icon
v-if="item.value === 'DATETIME'"
icon-class="field_time"
class="field-icon-time"
/>
<svg-icon
v-if="
item.value === 'LONG' || item.value === 'DOUBLE'
"
icon-class="field_value"
class="field-icon-value"
/>
</span>
><span>
<svg-icon
v-if="item.value === 'TEXT'"
icon-class="field_text"
class="field-icon-text"
/>
<svg-icon
v-if="item.value === 'DATETIME'"
icon-class="field_time"
class="field-icon-time"
/>
<svg-icon
v-if="
item.value === 'LONG' || item.value === 'DOUBLE'
"
icon-class="field_value"
class="field-icon-value"
/>
</span>
<span
style="
color: #8492a6;
font-size: 14px;
margin-left: 10px;
"
>{{ item.label }}</span></el-dropdown-item>
>{{ item.label }}</span
></el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
<span style="font-size: 14px; margin-left: 10px">
@ -219,7 +222,7 @@ export default {
originName: {
type: String,
default: ''
},
}
},
data() {
return {
@ -292,9 +295,7 @@ export default {
this.defaultCheckedKeys.splice(index, 1)
}
this.validateName()
const labelList = this.$refs.tree
.getCheckedNodes()
.map((ele) => ele.id)
const labelList = this.$refs.tree.getCheckedNodes().map((ele) => ele.id)
const excelList = this.excelData.map((ele) => ele.id)
this.$emit(
'setTableNum',
@ -351,7 +352,7 @@ export default {
},
calHeight() {
const that = this
setTimeout(function() {
setTimeout(function () {
const currentHeight = document.documentElement.clientHeight
that.height = currentHeight - 56 - 30 - 26 - 25 - 35 - 10 - 37 - 20 - 10
}, 10)
@ -478,14 +479,15 @@ export default {
this.param.tableId &&
(effectExtField || changeFiled)
) {
var msg = effectExtField
? i18n.t('dataset.task.effect_ext_field') +
', ' +
i18n.t('dataset.task.excel_replace_msg')
: i18n.t('dataset.task.excel_replace_msg')
$confirm(msg, () => {
this.saveExcelData(sheetFileMd5, table)
})
const options = {
title: 'deDataset.replace_the_data',
confirmButtonText: this.$t('commons.confirm'),
content:
'替换可能会影响自定义数据集、关联数据集、仪表板等,是否替换?',
type: 'primary',
cb: () => this.saveExcelData(sheetFileMd5, table)
}
this.handlerConfirm(options)
} else {
this.saveExcelData(sheetFileMd5, table)
}
@ -495,25 +497,23 @@ export default {
new Set(sheetFileMd5).size !== sheetFileMd5.length &&
!this.param.tableId
) {
this.$confirm(
this.$t('dataset.task.excel_replace_msg'),
this.$t('dataset.merge_title'),
{
distinguishCancelAndClose: true,
confirmButtonText: this.$t('dataset.merge'),
cancelButtonText: this.$t('dataset.no_merge'),
type: 'info'
}
)
.then(() => {
const options = {
title: 'dataset.merge_title',
content: 'dataset.task.excel_replace_msg',
confirmButtonText: this.$t('dataset.merge'),
cancelButtonText: this.$t('dataset.no_merge'),
type: 'primary',
cb: () => {
table.mergeSheet = true
this.loading = true
post('/dataset/table/update', table).then((response) => {
this.openMessageSuccess('deDataset.set_saved_successfully')
this.cancel(response.data)
})
})
.catch((action) => {
}).finally(() => {
this.loading = false
})
},
cancelCb: (action) => {
if (action === 'close') {
return
}
@ -527,10 +527,9 @@ export default {
.finally(() => {
this.loading = false
})
})
.finally(() => {
this.loading = false
})
}
}
this.handlerConfirm(options)
} else {
this.loading = true
post('/dataset/table/update', table)

View File

@ -179,7 +179,7 @@
:image-size="60"
:image="errImg"
:description="$t('deDataset.run_failed')"
/>
>{{ errMsgCont }}</el-empty>
<ux-grid
v-else
ref="plxTable"
@ -386,6 +386,7 @@ export default {
tableData: [],
fieldData: [],
errMsg: false,
errMsgCont: '',
options: [],
sql: '',
dataReference: false,
@ -601,6 +602,7 @@ export default {
getSQLPreview() {
this.errMsg = false
this.errMsgCont = ''
this.initFlag = false
if (!this.dataSource || this.datasource === '') {
this.openMessageSuccess('dataset.pls_slc_data_source', 'error')
@ -608,7 +610,7 @@ export default {
}
this.parseVariable()
this.fields = []
this.$refs.plxTable.reloadData([])
this.$refs.plxTable?.reloadData([])
post('/dataset/table/sqlPreview', {
dataSourceId: this.dataSource,
type: 'sql',
@ -617,7 +619,7 @@ export default {
sql: Base64.encode(this.sql.trim()),
isBase64Encryption: true
})
})
}, true, 60000, true)
.then((response) => {
this.fields = response.data.fields
this.data = response.data.data
@ -626,7 +628,8 @@ export default {
this.$refs.plxTable?.reloadData(datas)
})
})
.catch((err) => {
.catch((err, msg) => {
this.errMsgCont = err
this.errMsg = true
})
},

View File

@ -40,8 +40,20 @@
`(${$t('dataset.preview_show')} 1000 ${$t('dataset.preview_item')})`
}}</span>
<span @mousedown="mousedownDrag" class="drag"></span>
<el-button
class="de-text-btn posi-right"
type="text"
size="small"
@click="previewData"
>
{{ $t('deDataset.data_preview') }}
</el-button>
</div>
<union-preview :unionHeight="unionHeight" :table="previewTable" :dataset="dataset" />
<union-preview
:unionHeight="unionHeight"
:table="previewTable"
:dataset="dataset"
/>
</div>
<!--选择数据集-->
<el-drawer
@ -108,9 +120,10 @@ import UnionEdit from '@/views/dataset/add/union/UnionEdit'
import { post } from '@/api/dataset/dataset'
import UnionPreview from '@/views/dataset/add/union/UnionPreview'
import cancelMix from './cancelMix'
import msgCfm from '@/components/msgCfm/index'
export default {
name: 'AddUnion',
mixins: [cancelMix],
mixins: [cancelMix, msgCfm],
components: {
UnionPreview,
UnionEdit,
@ -216,7 +229,7 @@ export default {
this.openMessageSuccess('dataset.char_can_not_more_50', 'error')
return
}
this.loading = true;
this.loading = true
const table = {
id: this.param.tableId,
name: this.param.name,
@ -226,12 +239,14 @@ export default {
mode: this.dataset[0].currentDs.mode,
info: '{"union":' + JSON.stringify(this.dataset) + '}'
}
post('/dataset/table/update', table).then((response) => {
this.$emit('saveSuccess', table)
this.cancel(response.data)
}).finally(() => {
this.loading = false;
})
post('/dataset/table/update', table)
.then((response) => {
this.$emit('saveSuccess', table)
this.cancel(response.data)
})
.finally(() => {
this.loading = false
})
},
selectDs() {
this.selectDsDialog = true
@ -367,7 +382,7 @@ export default {
.unio-editer-container {
min-height: 298px;
width: 100%;
background: #F5F6F7;
background: #f5f6f7;
}
.preview-container {
@ -382,12 +397,20 @@ export default {
height: 54px;
display: flex;
align-items: center;
position: relative;
padding: 16px 24px;
font-weight: 500;
position: relative;
color: var(--deTextPrimary, #1f2329);
border-bottom: 1px solid rgba(31, 35, 41, 0.15);
.posi-right {
position: absolute;
right: 24px;
top: 50%;
transform: translateY(-50%);
}
.result-num {
font-weight: 400;
color: var(--deTextSecondary, #646a73);

View File

@ -49,19 +49,6 @@
</template>
</el-table-column>
<el-table-column
prop="lastExecTime"
key="lastExecTime"
min-width="178"
:label="$t('dataset.task.last_exec_time')"
>
<template slot-scope="scope">
<span>
{{ scope.row.lastExecTime | timestampFormatDate }}
</span>
</template>
</el-table-column>
<el-table-column
prop="lastExecStatus"
key="lastExecStatus"
@ -80,6 +67,19 @@
</template>
</el-table-column>
<el-table-column
prop="lastExecTime"
key="lastExecTime"
min-width="178"
:label="$t('dataset.task.last_exec_time')"
>
<template slot-scope="scope">
<span>
{{ scope.row.lastExecTime | timestampFormatDate }}
</span>
</template>
</el-table-column>
<el-table-column
prop="nextExecTime"
key="nextExecTime"
@ -269,7 +269,7 @@
<el-input
v-model="taskForm.name"
size="small"
:placeholder="$t('dataset.task_name')"
:placeholder="$t('fu.search_bar.please_input') + $t('dataset.task_name')"
/>
</el-form-item>
<el-form-item :label="$t('dataset.update_type')" prop="type">
@ -280,7 +280,7 @@
>
</el-radio-group>
</el-form-item>
<div class="add-scope-cont" v-if="taskForm.type === 'add_scope'">
<div class="add-scope-cont" v-if="taskForm.type === 'add_scope' && table.type !== 'api'">
<el-form-item
prop="type"
:label="$t('dataset.incremental_update_type')"
@ -542,7 +542,7 @@ export default {
startTime: [
{
required: true,
message: this.$t('dataset.required'),
message: this.$t('components.time_is_required'),
trigger: 'change'
}
],

View File

@ -2,7 +2,7 @@
<div class="de-dataset-form">
<div class="top">
<span class="name">
<i @click="back" class="el-icon-arrow-left"></i>
<i @click="logOutTips" class="el-icon-arrow-left"></i>
<svg-icon
style="margin: 0 9.5px 0 16.2px"
:icon-class="`de-${datasetType}-new`"
@ -53,9 +53,11 @@ import AddExcel from './add/AddExcel'
import AddUnion from '@/views/dataset/add/AddUnion'
import { post } from '@/api/dataset/dataset'
import { datasetTypeMap } from './group/options'
import msgCfm from '@/components/msgCfm/index'
export default {
name: 'DatasetForm',
components: { AddDB, AddSQL, AddExcel, AddApi, AddUnion },
mixins: [msgCfm],
data() {
return {
originName: '',
@ -132,6 +134,18 @@ export default {
back() {
this.$router.push('/dataset/index')
},
logOutTips() {
const options = {
title: 'role.tips',
confirmButtonText: this.$t('commons.confirm'),
content: 'system_parameter_setting.sure_to_exit',
type: 'primary',
cb: () => {
this.back()
}
}
this.handlerConfirm(options)
},
nameBlur() {
this.nameExsitValidator()
this.showInput = this.nameExsit

View File

@ -562,6 +562,7 @@ export default {
} else {
const currentNodeId = sessionStorage.getItem('dataset-current-node')
if (currentNodeId) {
sessionStorage.setItem('dataset-current-node', '')
this.dfsTableData(this.tData, currentNodeId)
}
}

View File

@ -246,7 +246,7 @@
"
:label="$t('datasource.extra_params')"
>
<el-input v-model="form.configuration.extraParams" autocomplete="off" />
<el-input :placeholder="$t('fu.search_bar.please_input') + $t('datasource.extra_params')" v-model="form.configuration.extraParams" autocomplete="off" />
</el-form-item>
<el-form-item
@ -495,7 +495,7 @@
<div class="row-rules">
<span>{{ $t('datasource.column_info') }}</span>
</div>
<div class="table-container">
<div class="table-container de-svg-in-table">
<el-table
ref="apiItemTable"
:data="apiItem.jsonFields"
@ -525,7 +525,7 @@
<el-input
v-model="scope.row.name"
:disabled="scope.row.children"
size="mini"
size="small"
type="text"
@change="fieldNameChange(scope.row)"
/>
@ -540,7 +540,8 @@
<el-select
v-model="scope.row.deExtractType"
:disabled="scope.row.children"
size="mini"
size="small"
class="select-type"
style="display: inline-block; width: 120px"
@change="fieldTypeChange(scope.row)"
>
@ -567,6 +568,20 @@
>{{ item.label }}</span>
</el-option>
</el-select>
<span class="select-svg-icon">
<span v-if="scope.row.deType === 0">
<svg-icon
icon-class="field_text"
class="field-icon-text"
/>
</span>
<span v-if="[ 2, 3 ].includes(scope.row.deType)">
<svg-icon
icon-class="field_value"
class="field-icon-value"
/>
</span>
</span>
</template>
</el-table-column>
</el-table>
@ -712,7 +727,7 @@ export default {
name: [
{
required: true,
message: i18n.t('datasource.input_name'),
validator: this.nameRepeat,
trigger: 'blur'
}
],
@ -955,6 +970,22 @@ export default {
}
})
},
nameRepeat(rule, value, callback) {
let hasRepeatName = false
this.form.apiConfiguration.forEach((item) => {
if (
item.name === this.apiItem.name &&
item.serialNumber !== this.apiItem.serialNumber
) {
hasRepeatName = true
}
})
if (hasRepeatName) {
callback(new Error(i18n.t('theme.name_repeat')));
return
}
callback();
},
next() {
if (this.active === 1) {
let hasRepeatName = false
@ -1504,4 +1535,23 @@ export default {
}
}
}
.de-svg-in-table {
.select-type {
width: 180px;
::v-deep.el-input__inner {
padding-left: 32px;
}
}
.select-svg-icon {
position: absolute;
left: 24px;
top: 15px;
}
::v-deep.el-table__expand-icon {
.el-icon-arrow-right::before {
content: "\E791" !important;
}
}
}
</style>

View File

@ -2,7 +2,7 @@
<div class="de-ds-form" v-loading="formLoading">
<div class="de-ds-top">
<span class="name">
<i @click="backToList" class="el-icon-arrow-left"></i>
<i @click="logOutTips" class="el-icon-arrow-left"></i>
{{
params &&
params.id &&
@ -17,7 +17,7 @@
</span>
<div class="apply">
<template v-if="canEdit">
<deBtn secondary @click="backToList"
<deBtn secondary @click="logOutTips"
>{{ $t('commons.cancel') }}
</deBtn>
<deBtn
@ -189,7 +189,7 @@ export default {
name: [
{
required: true,
message: i18n.t('datasource.input_name'),
validator: this.nameRepeat,
trigger: 'blur'
},
{
@ -834,6 +834,18 @@ export default {
backToList() {
this.$router.push('/datasource/index')
},
logOutTips() {
const options = {
title: 'role.tips',
confirmButtonText: this.$t('commons.confirm'),
content: 'system_parameter_setting.sure_to_exit',
type: 'primary',
cb: () => {
this.backToList()
}
}
this.handlerConfirm(options)
},
refreshType(form) {
this.$emit('refresh-type', form)
},

View File

@ -15,6 +15,7 @@
@click.native="selectDataset"
:label="$t('chart.select_dataset')"
prop="datasetName"
:disabled="taskForm.id"
>
<el-input
v-model="taskForm.datasetName"