forked from github/dataease
fix: 参数默认值的時間格式化
This commit is contained in:
parent
5b780e8b85
commit
dc7b06bca5
@ -2,11 +2,13 @@ package io.dataease.dto.dataset;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SqlVariableDetails {
|
||||
private String variableName;
|
||||
private String alias;
|
||||
private String type;
|
||||
private List<String> type;
|
||||
private String details;
|
||||
private String defaultValue;
|
||||
|
||||
|
@ -131,6 +131,7 @@ export default {
|
||||
default_login: 'Normal'
|
||||
},
|
||||
commons: {
|
||||
default_value: 'Default Value',
|
||||
publish: 'publish',
|
||||
unpublished: 'unpublished',
|
||||
default_pwd: 'Default Pwd',
|
||||
@ -1115,6 +1116,14 @@ export default {
|
||||
form_type: 'From Type'
|
||||
},
|
||||
dataset: {
|
||||
select_year: 'Select Year',
|
||||
select_month: 'Select Month',
|
||||
select_date: 'Select Date',
|
||||
select_time: 'Select Time',
|
||||
time_year: 'Date-Year',
|
||||
time_year_month: 'Date-Yearmonth',
|
||||
time_year_month_day: 'Date-YearMonthDay',
|
||||
time_all: 'TIme',
|
||||
dataset_sync: ' ( Data sync... )',
|
||||
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
|
||||
datalist: 'Data Set',
|
||||
|
@ -131,6 +131,7 @@ export default {
|
||||
default_login: '普通登錄'
|
||||
},
|
||||
commons: {
|
||||
default_value: '默認值',
|
||||
publish: '發布',
|
||||
unpublished: '取消發布',
|
||||
default_pwd: '初始密碼',
|
||||
@ -1115,6 +1116,14 @@ export default {
|
||||
form_type: '類別'
|
||||
},
|
||||
dataset: {
|
||||
select_year: '選擇年',
|
||||
select_month: '選擇月',
|
||||
select_date: '選擇日期',
|
||||
select_time: '選擇時間',
|
||||
time_year: '日期-年',
|
||||
time_year_month: '日期-年月',
|
||||
time_year_month_day: '日期-年月日',
|
||||
time_all: '日期-年月日時分秒',
|
||||
dataset_sync: ' ( 資料同步中... )',
|
||||
sheet_warn: '有多個 Sheet 頁,默認抽取第一個',
|
||||
datalist: '數據集',
|
||||
|
@ -131,6 +131,7 @@ export default {
|
||||
default_login: '普通登录'
|
||||
},
|
||||
commons: {
|
||||
default_value: '默认值',
|
||||
publish: '发布',
|
||||
unpublished: '取消发布',
|
||||
default_pwd: '初始密码',
|
||||
@ -1117,6 +1118,14 @@ export default {
|
||||
form_type: '类别'
|
||||
},
|
||||
dataset: {
|
||||
select_year: '选择年',
|
||||
select_month: '选择月',
|
||||
select_date: '选择日期',
|
||||
select_time: '选择时间',
|
||||
time_year: '日期-年',
|
||||
time_year_month: '日期-年月',
|
||||
time_year_month_day: '日期-年月日',
|
||||
time_all: '日期-年月日时分秒',
|
||||
dataset_sync: ' ( 数据同步中... )',
|
||||
sheet_warn: '有多个 Sheet 页,默认抽取第一个',
|
||||
datalist: '数据集',
|
||||
|
@ -105,29 +105,50 @@
|
||||
<el-dialog :title="dialogTitle" :visible="showVariableMgm" :before-close="closeVariableMgm" width="60%"
|
||||
class="dialog-css" append-to-body>
|
||||
<el-table :data="variablesTmp" style="width: 80%">
|
||||
<el-table-column prop="variableName" label="名称" width="180">
|
||||
<el-table-column prop="variableName" :label="$t('commons.name')" width="180">
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" width="180">
|
||||
<el-table-column :label="$t('table.type')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.type" size="mini" style="display: inline-block;width: 120px;">
|
||||
<el-option
|
||||
v-for="item in fieldOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
<span style="float: left">
|
||||
<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="float: left; color: #8492a6; font-size: 12px">{{ item.label }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-cascader v-model="scope.row.type" size="mini" style="display: inline-block;width: 120px;" :options="fieldOptions" @change="variableTypeChange(scope.row)">
|
||||
</el-cascader>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="defaultValue" label="默认值">
|
||||
<el-table-column prop="defaultValue" :label="$t('commons.default_value')">
|
||||
<template slot-scope="scope">
|
||||
<input type="text" v-model="scope.row.defaultValue" />
|
||||
<input v-if="scope.row.type[0] === 'TEXT'" type="text" v-model="scope.row.defaultValue" />
|
||||
<input v-if="scope.row.type[0] === 'LONG' || scope.row.type[0] === 'DOUBLE'" type="number" v-model="scope.row.defaultValue" />
|
||||
|
||||
<el-date-picker v-if="scope.row.type[0] === 'DATETIME-YEAR'"
|
||||
v-model="scope.row.defaultValue"
|
||||
type="year"
|
||||
value-format="yyyy"
|
||||
:placeholder="$t('dataset.select_year')">
|
||||
</el-date-picker>
|
||||
|
||||
<el-date-picker v-if="scope.row.type[0] === 'DATETIME-YEAR-MONTH'"
|
||||
v-model="scope.row.defaultValue"
|
||||
type="month"
|
||||
:format="scope.row.type[1]"
|
||||
:value-format="scope.row.type[1]"
|
||||
:placeholder="$t('dataset.select_month')">
|
||||
</el-date-picker>
|
||||
|
||||
<el-date-picker v-if="scope.row.type[0] === 'DATETIME-YEAR-MONTH-DAY'"
|
||||
v-model="scope.row.defaultValue"
|
||||
type="date"
|
||||
:format="scope.row.type[1]"
|
||||
:value-format="scope.row.type[1]"
|
||||
:placeholder="$t('dataset.select_date')">
|
||||
</el-date-picker>
|
||||
|
||||
<el-date-picker v-if="scope.row.type[0] === 'DATETIME'"
|
||||
v-model="scope.row.defaultValue"
|
||||
type="datetime"
|
||||
:format="scope.row.type[1]"
|
||||
:value-format="scope.row.type[1]"
|
||||
:placeholder="$t('dataset.select_time')">
|
||||
</el-date-picker>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -210,9 +231,36 @@ export default {
|
||||
variablesTmp: [],
|
||||
fieldOptions: [
|
||||
{ label: this.$t('dataset.text'), value: 'TEXT' },
|
||||
{ label: this.$t('dataset.time'), value: 'DATETIME' },
|
||||
{ label: this.$t('dataset.value'), value: 'LONG' },
|
||||
{ label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 'DOUBLE' }
|
||||
{ label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 'DOUBLE' },
|
||||
{ label: this.$t('dataset.time_year'), value: 'DATETIME-YEAR' },
|
||||
{ label: this.$t('dataset.time_year_month'), value: 'DATETIME-YEAR-MONTH',
|
||||
children: [{
|
||||
value: 'yyyy-MM',
|
||||
label: 'YYYY-MM'
|
||||
}, {
|
||||
value: 'yyyy/MM',
|
||||
label: 'YYYY/MM'
|
||||
}]
|
||||
},
|
||||
{ label: this.$t('dataset.time_year_month_day'), value: 'DATETIME-YEAR-MONTH-DAY',
|
||||
children: [{
|
||||
value: 'yyyy-MM-dd',
|
||||
label: 'YYYY-MM-DD'
|
||||
}, {
|
||||
value: 'yyyy/MM/dd',
|
||||
label: 'YYYY/MM/DD'
|
||||
}]
|
||||
},
|
||||
{ label: this.$t('dataset.time_all'), value: 'DATETIME',
|
||||
children: [{
|
||||
value: 'yyyy-MM-dd HH:mm:ss',
|
||||
label: 'YYYY-MM-DD HH:MI:SS'
|
||||
}, {
|
||||
value: 'yyyy/MM/dd HH:mm:ss',
|
||||
label: 'YYYY/MM/DD HH:MI:SS'
|
||||
}]
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
@ -303,6 +351,7 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
this.parseVariable()
|
||||
post('/dataset/table/sqlPreview', {
|
||||
dataSourceId: this.dataSource,
|
||||
type: 'sql',
|
||||
@ -341,6 +390,7 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
this.parseVariable()
|
||||
const table = {
|
||||
id: this.param.tableId,
|
||||
name: this.name,
|
||||
@ -353,14 +403,12 @@ export default {
|
||||
info: JSON.stringify({sql: this.sql.trim()})
|
||||
}
|
||||
post('/dataset/table/update', table).then(response => {
|
||||
// this.$store.dispatch('dataset/setSceneData', new Date().getTime())
|
||||
this.$emit('saveSuccess', table)
|
||||
this.cancel()
|
||||
})
|
||||
},
|
||||
|
||||
cancel() {
|
||||
// this.dataReset()
|
||||
if (this.param.tableId) {
|
||||
this.$emit('switchComponent', {name: 'ViewTable', param: this.param.table})
|
||||
} else {
|
||||
@ -392,6 +440,11 @@ export default {
|
||||
},
|
||||
|
||||
variableMgm() {
|
||||
this.parseVariable()
|
||||
this.dialogTitle = this.$t('sql_variable.variable_mgm')
|
||||
this.showVariableMgm = true
|
||||
},
|
||||
parseVariable(){
|
||||
this.variablesTmp = []
|
||||
var reg = new RegExp("\\${(.*?)}", "gim");
|
||||
var match = this.sql.match(reg);
|
||||
@ -408,15 +461,14 @@ export default {
|
||||
}
|
||||
}
|
||||
if(obj === undefined){
|
||||
obj = {variableName: name, alias: '', type: 'TEXT', required: false, defaultValue: '', details: ''}
|
||||
obj = {variableName: name, alias: '', type: [], required: false, defaultValue: '', details: ''}
|
||||
obj.type.push('TEXT')
|
||||
}
|
||||
this.variablesTmp.push(obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.variables = JSON.parse(JSON.stringify(this.variablesTmp)).concat()
|
||||
this.dialogTitle = this.$t('sql_variable.variable_mgm')
|
||||
this.showVariableMgm = true
|
||||
},
|
||||
closeVariableMgm() {
|
||||
this.showVariableMgm = false
|
||||
@ -424,6 +476,9 @@ export default {
|
||||
saveVariable(){
|
||||
this.variables = JSON.parse(JSON.stringify(this.variablesTmp)).concat()
|
||||
this.showVariableMgm = false
|
||||
},
|
||||
variableTypeChange(row){
|
||||
row.defaultValue = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user