Skip to content

Commit dc7b06b

Browse files
committed
fix: 参数默认值的時間格式化
1 parent 5b780e8 commit dc7b06b

File tree

5 files changed

+110
-26
lines changed

5 files changed

+110
-26
lines changed

backend/src/main/java/io/dataease/dto/dataset/SqlVariableDetails.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import lombok.Data;
44

5+
import java.util.List;
6+
57
@Data
68
public class SqlVariableDetails {
79
private String variableName;
810
private String alias;
9-
private String type;
11+
private List<String> type;
1012
private String details;
1113
private String defaultValue;
1214

frontend/src/lang/en.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default {
131131
default_login: 'Normal'
132132
},
133133
commons: {
134+
default_value: 'Default Value',
134135
publish: 'publish',
135136
unpublished: 'unpublished',
136137
default_pwd: 'Default Pwd',
@@ -1115,6 +1116,14 @@ export default {
11151116
form_type: 'From Type'
11161117
},
11171118
dataset: {
1119+
select_year: 'Select Year',
1120+
select_month: 'Select Month',
1121+
select_date: 'Select Date',
1122+
select_time: 'Select Time',
1123+
time_year: 'Date-Year',
1124+
time_year_month: 'Date-Yearmonth',
1125+
time_year_month_day: 'Date-YearMonthDay',
1126+
time_all: 'TIme',
11181127
dataset_sync: ' ( Data sync... )',
11191128
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
11201129
datalist: 'Data Set',

frontend/src/lang/tw.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default {
131131
default_login: '普通登錄'
132132
},
133133
commons: {
134+
default_value: '默認值',
134135
publish: '發布',
135136
unpublished: '取消發布',
136137
default_pwd: '初始密碼',
@@ -1115,6 +1116,14 @@ export default {
11151116
form_type: '類別'
11161117
},
11171118
dataset: {
1119+
select_year: '選擇年',
1120+
select_month: '選擇月',
1121+
select_date: '選擇日期',
1122+
select_time: '選擇時間',
1123+
time_year: '日期-年',
1124+
time_year_month: '日期-年月',
1125+
time_year_month_day: '日期-年月日',
1126+
time_all: '日期-年月日時分秒',
11181127
dataset_sync: ' ( 資料同步中... )',
11191128
sheet_warn: '有多個 Sheet 頁,默認抽取第一個',
11201129
datalist: '數據集',

frontend/src/lang/zh.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default {
131131
default_login: '普通登录'
132132
},
133133
commons: {
134+
default_value: '默认值',
134135
publish: '发布',
135136
unpublished: '取消发布',
136137
default_pwd: '初始密码',
@@ -1117,6 +1118,14 @@ export default {
11171118
form_type: '类别'
11181119
},
11191120
dataset: {
1121+
select_year: '选择年',
1122+
select_month: '选择月',
1123+
select_date: '选择日期',
1124+
select_time: '选择时间',
1125+
time_year: '日期-年',
1126+
time_year_month: '日期-年月',
1127+
time_year_month_day: '日期-年月日',
1128+
time_all: '日期-年月日时分秒',
11201129
dataset_sync: ' ( 数据同步中... )',
11211130
sheet_warn: '有多个 Sheet 页,默认抽取第一个',
11221131
datalist: '数据集',

frontend/src/views/dataset/add/AddSQL.vue

Lines changed: 80 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,29 +105,50 @@
105105
<el-dialog :title="dialogTitle" :visible="showVariableMgm" :before-close="closeVariableMgm" width="60%"
106106
class="dialog-css" append-to-body>
107107
<el-table :data="variablesTmp" style="width: 80%">
108-
<el-table-column prop="variableName" label="名称" width="180">
108+
<el-table-column prop="variableName" :label="$t('commons.name')" width="180">
109109
</el-table-column>
110-
<el-table-column label="类型" width="180">
110+
<el-table-column :label="$t('table.type')" width="180">
111111
<template slot-scope="scope">
112-
<el-select v-model="scope.row.type" size="mini" style="display: inline-block;width: 120px;">
113-
<el-option
114-
v-for="item in fieldOptions"
115-
:key="item.value"
116-
:label="item.label"
117-
:value="item.value">
118-
<span style="float: left">
119-
<svg-icon v-if="item.value === 'TEXT'" icon-class="field_text" class="field-icon-text" />
120-
<svg-icon v-if="item.value === 'DATETIME'" icon-class="field_time" class="field-icon-time" />
121-
<svg-icon v-if="item.value === 'LONG' || item.value === 'DOUBLE'" icon-class="field_value" class="field-icon-value" />
122-
</span>
123-
<span style="float: left; color: #8492a6; font-size: 12px">{{ item.label }}</span>
124-
</el-option>
125-
</el-select>
112+
<el-cascader v-model="scope.row.type" size="mini" style="display: inline-block;width: 120px;" :options="fieldOptions" @change="variableTypeChange(scope.row)">
113+
</el-cascader>
126114
</template>
127115
</el-table-column>
128-
<el-table-column prop="defaultValue" label="默认值">
116+
<el-table-column prop="defaultValue" :label="$t('commons.default_value')">
129117
<template slot-scope="scope">
130-
<input type="text" v-model="scope.row.defaultValue" />
118+
<input v-if="scope.row.type[0] === 'TEXT'" type="text" v-model="scope.row.defaultValue" />
119+
<input v-if="scope.row.type[0] === 'LONG' || scope.row.type[0] === 'DOUBLE'" type="number" v-model="scope.row.defaultValue" />
120+
121+
<el-date-picker v-if="scope.row.type[0] === 'DATETIME-YEAR'"
122+
v-model="scope.row.defaultValue"
123+
type="year"
124+
value-format="yyyy"
125+
:placeholder="$t('dataset.select_year')">
126+
</el-date-picker>
127+
128+
<el-date-picker v-if="scope.row.type[0] === 'DATETIME-YEAR-MONTH'"
129+
v-model="scope.row.defaultValue"
130+
type="month"
131+
:format="scope.row.type[1]"
132+
:value-format="scope.row.type[1]"
133+
:placeholder="$t('dataset.select_month')">
134+
</el-date-picker>
135+
136+
<el-date-picker v-if="scope.row.type[0] === 'DATETIME-YEAR-MONTH-DAY'"
137+
v-model="scope.row.defaultValue"
138+
type="date"
139+
:format="scope.row.type[1]"
140+
:value-format="scope.row.type[1]"
141+
:placeholder="$t('dataset.select_date')">
142+
</el-date-picker>
143+
144+
<el-date-picker v-if="scope.row.type[0] === 'DATETIME'"
145+
v-model="scope.row.defaultValue"
146+
type="datetime"
147+
:format="scope.row.type[1]"
148+
:value-format="scope.row.type[1]"
149+
:placeholder="$t('dataset.select_time')">
150+
</el-date-picker>
151+
131152
</template>
132153
</el-table-column>
133154
</el-table>
@@ -210,9 +231,36 @@ export default {
210231
variablesTmp: [],
211232
fieldOptions: [
212233
{ label: this.$t('dataset.text'), value: 'TEXT' },
213-
{ label: this.$t('dataset.time'), value: 'DATETIME' },
214234
{ label: this.$t('dataset.value'), value: 'LONG' },
215-
{ label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 'DOUBLE' }
235+
{ label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 'DOUBLE' },
236+
{ label: this.$t('dataset.time_year'), value: 'DATETIME-YEAR' },
237+
{ label: this.$t('dataset.time_year_month'), value: 'DATETIME-YEAR-MONTH',
238+
children: [{
239+
value: 'yyyy-MM',
240+
label: 'YYYY-MM'
241+
}, {
242+
value: 'yyyy/MM',
243+
label: 'YYYY/MM'
244+
}]
245+
},
246+
{ label: this.$t('dataset.time_year_month_day'), value: 'DATETIME-YEAR-MONTH-DAY',
247+
children: [{
248+
value: 'yyyy-MM-dd',
249+
label: 'YYYY-MM-DD'
250+
}, {
251+
value: 'yyyy/MM/dd',
252+
label: 'YYYY/MM/DD'
253+
}]
254+
},
255+
{ label: this.$t('dataset.time_all'), value: 'DATETIME',
256+
children: [{
257+
value: 'yyyy-MM-dd HH:mm:ss',
258+
label: 'YYYY-MM-DD HH:MI:SS'
259+
}, {
260+
value: 'yyyy/MM/dd HH:mm:ss',
261+
label: 'YYYY/MM/DD HH:MI:SS'
262+
}]
263+
}
216264
],
217265
}
218266
},
@@ -303,6 +351,7 @@ export default {
303351
})
304352
return
305353
}
354+
this.parseVariable()
306355
post('/dataset/table/sqlPreview', {
307356
dataSourceId: this.dataSource,
308357
type: 'sql',
@@ -341,6 +390,7 @@ export default {
341390
})
342391
return
343392
}
393+
this.parseVariable()
344394
const table = {
345395
id: this.param.tableId,
346396
name: this.name,
@@ -353,14 +403,12 @@ export default {
353403
info: JSON.stringify({sql: this.sql.trim()})
354404
}
355405
post('/dataset/table/update', table).then(response => {
356-
// this.$store.dispatch('dataset/setSceneData', new Date().getTime())
357406
this.$emit('saveSuccess', table)
358407
this.cancel()
359408
})
360409
},
361410
362411
cancel() {
363-
// this.dataReset()
364412
if (this.param.tableId) {
365413
this.$emit('switchComponent', {name: 'ViewTable', param: this.param.table})
366414
} else {
@@ -392,6 +440,11 @@ export default {
392440
},
393441
394442
variableMgm() {
443+
this.parseVariable()
444+
this.dialogTitle = this.$t('sql_variable.variable_mgm')
445+
this.showVariableMgm = true
446+
},
447+
parseVariable(){
395448
this.variablesTmp = []
396449
var reg = new RegExp("\\${(.*?)}", "gim");
397450
var match = this.sql.match(reg);
@@ -408,22 +461,24 @@ export default {
408461
}
409462
}
410463
if(obj === undefined){
411-
obj = {variableName: name, alias: '', type: 'TEXT', required: false, defaultValue: '', details: ''}
464+
obj = {variableName: name, alias: '', type: [], required: false, defaultValue: '', details: ''}
465+
obj.type.push('TEXT')
412466
}
413467
this.variablesTmp.push(obj)
414468
}
415469
}
416470
}
417471
this.variables = JSON.parse(JSON.stringify(this.variablesTmp)).concat()
418-
this.dialogTitle = this.$t('sql_variable.variable_mgm')
419-
this.showVariableMgm = true
420472
},
421473
closeVariableMgm() {
422474
this.showVariableMgm = false
423475
},
424476
saveVariable(){
425477
this.variables = JSON.parse(JSON.stringify(this.variablesTmp)).concat()
426478
this.showVariableMgm = false
479+
},
480+
variableTypeChange(row){
481+
row.defaultValue = ''
427482
}
428483
}
429484
}

0 commit comments

Comments
 (0)