105
105
<el-dialog :title =" dialogTitle" :visible =" showVariableMgm" :before-close =" closeVariableMgm" width =" 60%"
106
106
class =" dialog-css" append-to-body >
107
107
<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" >
109
109
</el-table-column >
110
- <el-table-column label =" 类型 " width =" 180" >
110
+ <el-table-column : label =" $t('table.type') " width =" 180" >
111
111
<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 >
126
114
</template >
127
115
</el-table-column >
128
- <el-table-column prop =" defaultValue" label =" 默认值 " >
116
+ <el-table-column prop =" defaultValue" : label =" $t('commons.default_value') " >
129
117
<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
+
131
152
</template >
132
153
</el-table-column >
133
154
</el-table >
@@ -210,9 +231,36 @@ export default {
210
231
variablesTmp: [],
211
232
fieldOptions: [
212
233
{ label: this .$t (' dataset.text' ), value: ' TEXT' },
213
- { label: this .$t (' dataset.time' ), value: ' DATETIME' },
214
234
{ 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
+ }
216
264
],
217
265
}
218
266
},
@@ -303,6 +351,7 @@ export default {
303
351
})
304
352
return
305
353
}
354
+ this .parseVariable ()
306
355
post (' /dataset/table/sqlPreview' , {
307
356
dataSourceId: this .dataSource ,
308
357
type: ' sql' ,
@@ -341,6 +390,7 @@ export default {
341
390
})
342
391
return
343
392
}
393
+ this .parseVariable ()
344
394
const table = {
345
395
id: this .param .tableId ,
346
396
name: this .name ,
@@ -353,14 +403,12 @@ export default {
353
403
info: JSON .stringify ({sql: this .sql .trim ()})
354
404
}
355
405
post (' /dataset/table/update' , table).then (response => {
356
- // this.$store.dispatch('dataset/setSceneData', new Date().getTime())
357
406
this .$emit (' saveSuccess' , table)
358
407
this .cancel ()
359
408
})
360
409
},
361
410
362
411
cancel () {
363
- // this.dataReset()
364
412
if (this .param .tableId ) {
365
413
this .$emit (' switchComponent' , {name: ' ViewTable' , param: this .param .table })
366
414
} else {
@@ -392,6 +440,11 @@ export default {
392
440
},
393
441
394
442
variableMgm () {
443
+ this .parseVariable ()
444
+ this .dialogTitle = this .$t (' sql_variable.variable_mgm' )
445
+ this .showVariableMgm = true
446
+ },
447
+ parseVariable (){
395
448
this .variablesTmp = []
396
449
var reg = new RegExp (" \\ ${(.*?)}" , " gim" );
397
450
var match = this .sql .match (reg);
@@ -408,22 +461,24 @@ export default {
408
461
}
409
462
}
410
463
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' )
412
466
}
413
467
this .variablesTmp .push (obj)
414
468
}
415
469
}
416
470
}
417
471
this .variables = JSON .parse (JSON .stringify (this .variablesTmp )).concat ()
418
- this .dialogTitle = this .$t (' sql_variable.variable_mgm' )
419
- this .showVariableMgm = true
420
472
},
421
473
closeVariableMgm () {
422
474
this .showVariableMgm = false
423
475
},
424
476
saveVariable (){
425
477
this .variables = JSON .parse (JSON .stringify (this .variablesTmp )).concat ()
426
478
this .showVariableMgm = false
479
+ },
480
+ variableTypeChange (row ){
481
+ row .defaultValue = ' '
427
482
}
428
483
}
429
484
}
0 commit comments