百分比组件

dev
zhenghuang 4 years ago
parent 9780b414ed
commit e00a8a22b7

@ -222,7 +222,7 @@ public class MysqlQueryProvider extends QueryProvider {
} }
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段 // 处理纵轴字段
yFields.add(getYFields(y, originField, fieldAlias)); yFields.add(getYFields(y, originField, fieldAlias, table));
// 处理纵轴过滤 // 处理纵轴过滤
yWheres.addAll(getYWheres(y, originField, fieldAlias)); yWheres.addAll(getYWheres(y, originField, fieldAlias));
// 处理纵轴排序 // 处理纵轴排序
@ -976,7 +976,7 @@ public class MysqlQueryProvider extends QueryProvider {
return list; return list;
} }
private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias) { private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias, String tableName) {
String fieldName = ""; String fieldName = "";
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) { if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
fieldName = MySQLConstants.AGG_COUNT; fieldName = MySQLConstants.AGG_COUNT;
@ -987,6 +987,8 @@ public class MysqlQueryProvider extends QueryProvider {
String cast = String.format(MySQLConstants.CAST, originField, y.getDeType() == 2 ? MySQLConstants.DEFAULT_INT_FORMAT : MySQLConstants.DEFAULT_FLOAT_FORMAT); String cast = String.format(MySQLConstants.CAST, originField, y.getDeType() == 2 ? MySQLConstants.DEFAULT_INT_FORMAT : MySQLConstants.DEFAULT_FLOAT_FORMAT);
String agg = String.format(MySQLConstants.AGG_FIELD, y.getSummary(), cast); String agg = String.format(MySQLConstants.AGG_FIELD, y.getSummary(), cast);
fieldName = String.format(MySQLConstants.CAST, agg, MySQLConstants.DEFAULT_FLOAT_FORMAT); fieldName = String.format(MySQLConstants.CAST, agg, MySQLConstants.DEFAULT_FLOAT_FORMAT);
} else if (StringUtils.equalsIgnoreCase(y.getSummary(), "ratio")) {
fieldName = "sum(" + originField + ")/(SELECT sum(" + y.getOriginName() + ") FROM " + tableName + ")*100";
} else { } else {
String cast = String.format(MySQLConstants.CAST, originField, y.getDeType() == 2 ? MySQLConstants.DEFAULT_INT_FORMAT : MySQLConstants.DEFAULT_FLOAT_FORMAT); String cast = String.format(MySQLConstants.CAST, originField, y.getDeType() == 2 ? MySQLConstants.DEFAULT_INT_FORMAT : MySQLConstants.DEFAULT_FLOAT_FORMAT);
fieldName = String.format(MySQLConstants.AGG_FIELD, y.getSummary(), cast); fieldName = String.format(MySQLConstants.AGG_FIELD, y.getSummary(), cast);
@ -997,6 +999,9 @@ public class MysqlQueryProvider extends QueryProvider {
.fieldAlias(fieldAlias) .fieldAlias(fieldAlias)
.build(); .build();
} }
private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias) {
return this.getYFields(y, originField, fieldAlias, null);
}
private List<SQLObj> getYWheres(ChartViewFieldDTO y, String originField, String fieldAlias) { private List<SQLObj> getYWheres(ChartViewFieldDTO y, String originField, String fieldAlias) {
List<SQLObj> list = new ArrayList<>(); List<SQLObj> list = new ArrayList<>();

Binary file not shown.

Binary file not shown.

@ -672,6 +672,7 @@ export default {
min: '最小值', min: '最小值',
stddev_pop: '标准差', stddev_pop: '标准差',
var_pop: '方差', var_pop: '方差',
ratio: '百分比',
quick_calc: '快速计算', quick_calc: '快速计算',
show_name_set: '显示名设置', show_name_set: '显示名设置',
color: '颜色', color: '颜色',

@ -40,7 +40,7 @@
</span> </span>
<span class="item-span-style" :title="item.name">{{ item.name }}</span> <span class="item-span-style" :title="item.name">{{ item.name }}</span>
<span v-if="item.summary" class="summary-span">{{ <span v-if="item.summary" class="summary-span">{{
$t("chart." + item.summary) $t('chart.' + item.summary)
}}</span> }}</span>
</el-tag> </el-tag>
<el-dropdown v-else trigger="click" size="mini" @command="clickItem"> <el-dropdown v-else trigger="click" size="mini" @command="clickItem">
@ -86,7 +86,7 @@
item.name item.name
}}</span> }}</span>
<span v-if="item.summary" class="summary-span">{{ <span v-if="item.summary" class="summary-span">{{
$t("chart." + item.summary) $t('chart.' + item.summary)
}}</span> }}</span>
<i <i
class="el-icon-arrow-down el-icon--right" class="el-icon-arrow-down el-icon--right"
@ -104,10 +104,10 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-notebook-2" /> <i class="el-icon-notebook-2" />
<span>{{ $t("chart.summary") }}</span> <span>{{ $t('chart.summary') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.summary) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.summary) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
@ -115,66 +115,59 @@
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id === 'count' || item.id === 'count' ||
item.deType === 0 || item.deType === 0 ||
item.deType === 1 item.deType === 1
" "
:command="beforeSummary('count')" :command="beforeSummary('count')"
>{{ $t("chart.count") }}</el-dropdown-item >{{ $t('chart.count') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('sum')" :command="beforeSummary('sum')"
>{{ $t("chart.sum") }}</el-dropdown-item >{{ $t('chart.sum') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('avg')" :command="beforeSummary('avg')"
>{{ $t("chart.avg") }}</el-dropdown-item >{{ $t('chart.avg') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('max')" :command="beforeSummary('max')"
>{{ $t("chart.max") }}</el-dropdown-item >{{ $t('chart.max') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('min')" :command="beforeSummary('min')"
>{{ $t("chart.min") }}</el-dropdown-item >{{ $t('chart.min') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('stddev_pop')" :command="beforeSummary('stddev_pop')"
>{{ $t("chart.stddev_pop") }}</el-dropdown-item >{{ $t('chart.stddev_pop') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('var_pop')" :command="beforeSummary('var_pop')"
>{{ $t("chart.var_pop") }}</el-dropdown-item >{{ $t('chart.var_pop') }}</el-dropdown-item>
>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-dropdown-item> </el-dropdown-item>
@ -189,31 +182,31 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-c-scale-to-original" /> <i class="el-icon-c-scale-to-original" />
<span>{{ $t("chart.dateStyle") }}</span> <span>{{ $t('chart.dateStyle') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.dateStyle) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.dateStyle) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeDateStyle('y')">{{ <el-dropdown-item :command="beforeDateStyle('y')">{{
$t("chart.y") $t('chart.y')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeDateStyle('y_M')">{{ <el-dropdown-item :command="beforeDateStyle('y_M')">{{
$t("chart.y_M") $t('chart.y_M')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeDateStyle('y_M_d')">{{ <el-dropdown-item :command="beforeDateStyle('y_M_d')">{{
$t("chart.y_M_d") $t('chart.y_M_d')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeDateStyle('H_m_s')">{{ <el-dropdown-item :command="beforeDateStyle('H_m_s')">{{
$t("chart.H_m_s") $t('chart.H_m_s')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeDateStyle('y_M_d_H_m')">{{ <el-dropdown-item :command="beforeDateStyle('y_M_d_H_m')">{{
$t("chart.y_M_d_H_m") $t('chart.y_M_d_H_m')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeDateStyle('y_M_d_H_m_s')">{{ <el-dropdown-item :command="beforeDateStyle('y_M_d_H_m_s')">{{
$t("chart.y_M_d_H_m_s") $t('chart.y_M_d_H_m_s')
}}</el-dropdown-item> }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -228,20 +221,20 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-timer" /> <i class="el-icon-timer" />
<span>{{ $t("chart.datePattern") }}</span> <span>{{ $t('chart.datePattern') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.datePattern) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.datePattern) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeDatePattern('date_sub')" <el-dropdown-item
>{{ $t("chart.date_sub") }}(1990-01-01)</el-dropdown-item :command="beforeDatePattern('date_sub')"
> >{{ $t('chart.date_sub') }}(1990-01-01)</el-dropdown-item>
<el-dropdown-item :command="beforeDatePattern('date_split')" <el-dropdown-item
>{{ $t("chart.date_split") }}(1990/01/01)</el-dropdown-item :command="beforeDatePattern('date_split')"
> >{{ $t('chart.date_split') }}(1990/01/01)</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-dropdown-item> </el-dropdown-item>
@ -259,22 +252,22 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-sort" /> <i class="el-icon-sort" />
<span>{{ $t("chart.sort") }}</span> <span>{{ $t('chart.sort') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.sort) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.sort) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeSort('none')">{{ <el-dropdown-item :command="beforeSort('none')">{{
$t("chart.none") $t('chart.none')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('asc')">{{ <el-dropdown-item :command="beforeSort('asc')">{{
$t("chart.asc") $t('chart.asc')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('desc')">{{ <el-dropdown-item :command="beforeSort('desc')">{{
$t("chart.desc") $t('chart.desc')
}}</el-dropdown-item> }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -284,7 +277,7 @@
divided divided
:command="beforeClickItem('remove')" :command="beforeClickItem('remove')"
> >
<span>{{ $t("chart.delete") }}</span> <span>{{ $t('chart.delete') }}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</span> </span>
@ -294,94 +287,94 @@
<script> <script>
export default { export default {
name: "ChartDragItem", name: 'ChartDragItem',
props: { props: {
param: { param: {
type: Object, type: Object,
required: true, required: true
}, },
item: { item: {
type: Object, type: Object,
required: true, required: true
}, },
index: { index: {
type: Number, type: Number,
required: true, required: true
}, },
conf: { conf: {
type: String, type: String,
required: true, required: true
}, }
}, },
data() { data() {
return {}; return {}
}, },
mounted() {}, mounted() {},
methods: { methods: {
clickItem(param) { clickItem(param) {
if (!param) { if (!param) {
return; return
} }
switch (param.type) { switch (param.type) {
case "remove": case 'remove':
this.removeItem(); this.removeItem()
break; break
default: default:
break; break
} }
}, },
beforeClickItem(type) { beforeClickItem(type) {
return { return {
type: type, type: type
}; }
}, },
sort(param) { sort(param) {
// console.log(param) // console.log(param)
this.item.sort = param.type; this.item.sort = param.type
this.$emit("onItemChange", this.item); this.$emit('onItemChange', this.item)
}, },
beforeSort(type) { beforeSort(type) {
return { return {
type: type, type: type
}; }
}, },
summary(param) { summary(param) {
// console.log(param) // console.log(param)
this.item.summary = param.type; this.item.summary = param.type
this.$emit("onItemChange", this.item); this.$emit('onItemChange', this.item)
}, },
beforeSummary(type) { beforeSummary(type) {
return { return {
type: type, type: type
}; }
}, },
removeItem() { removeItem() {
this.item.index = this.index; this.item.index = this.index
this.$emit("onItemRemove", this.item); this.$emit('onItemRemove', this.item)
}, },
dateStyle(param) { dateStyle(param) {
// console.log(param) // console.log(param)
this.item.dateStyle = param.type; this.item.dateStyle = param.type
this.$emit("onItemChange", this.item); this.$emit('onItemChange', this.item)
}, },
beforeDateStyle(type) { beforeDateStyle(type) {
return { return {
type: type, type: type
}; }
}, },
datePattern(param) { datePattern(param) {
// console.log(param) // console.log(param)
this.item.datePattern = param.type; this.item.datePattern = param.type
this.$emit("onItemChange", this.item); this.$emit('onItemChange', this.item)
}, },
beforeDatePattern(type) { beforeDatePattern(type) {
return { return {
type: type, type: type
}; }
}, }
}, }
}; }
</script> </script>
<style scoped> <style scoped>

@ -57,8 +57,7 @@
<span <span
v-if="chart.type !== 'table-info' && item.summary" v-if="chart.type !== 'table-info' && item.summary"
class="summary-span" class="summary-span"
>{{ $t("chart." + item.summary) }}</span >{{ $t('chart.' + item.summary) }}</span>
>
</el-tag> </el-tag>
<el-dropdown v-else trigger="click" size="mini" @command="clickItem"> <el-dropdown v-else trigger="click" size="mini" @command="clickItem">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
@ -120,8 +119,7 @@
<span <span
v-if="chart.type !== 'table-info' && item.summary" v-if="chart.type !== 'table-info' && item.summary"
class="summary-span" class="summary-span"
>{{ $t("chart." + item.summary) }}</span >{{ $t('chart.' + item.summary) }}</span>
>
<i <i
class="el-icon-arrow-down el-icon--right" class="el-icon-arrow-down el-icon--right"
style="position: absolute; top: 6px; right: 10px" style="position: absolute; top: 6px; right: 10px"
@ -138,19 +136,19 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-s-data" /> <i class="el-icon-s-data" />
<span>{{ $t("chart.chart_type") }}</span> <span>{{ $t('chart.chart_type') }}</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeSwitch('bar')">{{ <el-dropdown-item :command="beforeSwitch('bar')">{{
$t("chart.chart_bar") $t('chart.chart_bar')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSwitch('line')">{{ <el-dropdown-item :command="beforeSwitch('line')">{{
$t("chart.chart_line") $t('chart.chart_line')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSwitch('scatter')">{{ <el-dropdown-item :command="beforeSwitch('scatter')">{{
$t("chart.chart_scatter") $t('chart.chart_scatter')
}}</el-dropdown-item> }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -168,10 +166,10 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-notebook-2" /> <i class="el-icon-notebook-2" />
<span>{{ $t("chart.summary") }}</span> <span>{{ $t('chart.summary') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.summary) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.summary) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
@ -179,66 +177,59 @@
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id === 'count' || item.id === 'count' ||
item.deType === 0 || item.deType === 0 ||
item.deType === 1 item.deType === 1
" "
:command="beforeSummary('count')" :command="beforeSummary('count')"
>{{ $t("chart.count") }}</el-dropdown-item >{{ $t('chart.count') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('sum')" :command="beforeSummary('sum')"
>{{ $t("chart.sum") }}</el-dropdown-item >{{ $t('chart.sum') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('avg')" :command="beforeSummary('avg')"
>{{ $t("chart.avg") }}</el-dropdown-item >{{ $t('chart.avg') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('max')" :command="beforeSummary('max')"
>{{ $t("chart.max") }}</el-dropdown-item >{{ $t('chart.max') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('min')" :command="beforeSummary('min')"
>{{ $t("chart.min") }}</el-dropdown-item >{{ $t('chart.min') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('stddev_pop')" :command="beforeSummary('stddev_pop')"
>{{ $t("chart.stddev_pop") }}</el-dropdown-item >{{ $t('chart.stddev_pop') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('var_pop')" :command="beforeSummary('var_pop')"
>{{ $t("chart.var_pop") }}</el-dropdown-item >{{ $t('chart.var_pop') }}</el-dropdown-item>
>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-dropdown-item> </el-dropdown-item>
@ -268,22 +259,22 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-sort" /> <i class="el-icon-sort" />
<span>{{ $t("chart.sort") }}</span> <span>{{ $t('chart.sort') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.sort) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.sort) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeSort('none')">{{ <el-dropdown-item :command="beforeSort('none')">{{
$t("chart.none") $t('chart.none')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('asc')">{{ <el-dropdown-item :command="beforeSort('asc')">{{
$t("chart.asc") $t('chart.asc')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('desc')">{{ <el-dropdown-item :command="beforeSort('desc')">{{
$t("chart.desc") $t('chart.desc')
}}</el-dropdown-item> }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -292,21 +283,21 @@
icon="el-icon-files" icon="el-icon-files"
:command="beforeClickItem('filter')" :command="beforeClickItem('filter')"
> >
<span>{{ $t("chart.filter") }}...</span> <span>{{ $t('chart.filter') }}...</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
icon="el-icon-edit-outline" icon="el-icon-edit-outline"
divided divided
:command="beforeClickItem('rename')" :command="beforeClickItem('rename')"
> >
<span>{{ $t("chart.show_name_set") }}</span> <span>{{ $t('chart.show_name_set') }}</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
icon="el-icon-delete" icon="el-icon-delete"
divided divided
:command="beforeClickItem('remove')" :command="beforeClickItem('remove')"
> >
<span>{{ $t("chart.delete") }}</span> <span>{{ $t('chart.delete') }}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</span> </span>
@ -316,110 +307,110 @@
<script> <script>
export default { export default {
name: "QuotaExtItem", name: 'QuotaExtItem',
props: { props: {
param: { param: {
type: Object, type: Object,
required: true, required: true
}, },
item: { item: {
type: Object, type: Object,
required: true, required: true
}, },
index: { index: {
type: Number, type: Number,
required: true, required: true
}, },
chart: { chart: {
type: Object, type: Object,
required: true, required: true
}, }
}, },
data() { data() {
return {}; return {}
}, },
mounted() {}, mounted() {},
methods: { methods: {
clickItem(param) { clickItem(param) {
if (!param) { if (!param) {
return; return
} }
switch (param.type) { switch (param.type) {
case "rename": case 'rename':
this.showRename(); this.showRename()
break; break
case "remove": case 'remove':
this.removeItem(); this.removeItem()
break; break
case "filter": case 'filter':
this.editFilter(); this.editFilter()
break; break
default: default:
break; break
} }
}, },
beforeClickItem(type) { beforeClickItem(type) {
return { return {
type: type, type: type
}; }
}, },
summary(param) { summary(param) {
// console.log(param) // console.log(param)
this.item.summary = param.type; this.item.summary = param.type
this.$emit("onQuotaItemChange", this.item); this.$emit('onQuotaItemChange', this.item)
}, },
beforeSummary(type) { beforeSummary(type) {
return { return {
type: type, type: type
}; }
}, },
switchChartType(param) { switchChartType(param) {
// console.log(param) // console.log(param)
this.item.chartType = param.type; this.item.chartType = param.type
this.$emit("onQuotaItemChange", this.item); this.$emit('onQuotaItemChange', this.item)
}, },
beforeSwitch(type) { beforeSwitch(type) {
return { return {
type: type, type: type
}; }
}, },
quickCalc(param) {}, quickCalc(param) {},
beforeQuickCalc(type) { beforeQuickCalc(type) {
return { return {
type: type, type: type
}; }
}, },
sort(param) { sort(param) {
// console.log(param) // console.log(param)
this.item.sort = param.type; this.item.sort = param.type
this.$emit("onQuotaItemChange", this.item); this.$emit('onQuotaItemChange', this.item)
}, },
beforeSort(type) { beforeSort(type) {
return { return {
type: type, type: type
}; }
}, },
showRename() { showRename() {
this.item.index = this.index; this.item.index = this.index
this.item.renameType = "quotaExt"; this.item.renameType = 'quotaExt'
this.$emit("onNameEdit", this.item); this.$emit('onNameEdit', this.item)
}, },
removeItem() { removeItem() {
this.item.index = this.index; this.item.index = this.index
this.item.removeType = "quotaExt"; this.item.removeType = 'quotaExt'
this.$emit("onQuotaItemRemove", this.item); this.$emit('onQuotaItemRemove', this.item)
}, },
editFilter() { editFilter() {
this.item.index = this.index; this.item.index = this.index
this.item.filterType = "quotaExt"; this.item.filterType = 'quotaExt'
this.$emit("editItemFilter", this.item); this.$emit('editItemFilter', this.item)
}, }
}, }
}; }
</script> </script>
<style scoped> <style scoped>

@ -57,8 +57,7 @@
<span <span
v-if="chart.type !== 'table-info' && item.summary" v-if="chart.type !== 'table-info' && item.summary"
class="summary-span" class="summary-span"
>{{ $t("chart." + item.summary) }}</span >{{ $t('chart.' + item.summary) }}</span>
>
</el-tag> </el-tag>
<el-dropdown v-else trigger="click" size="mini" @command="clickItem"> <el-dropdown v-else trigger="click" size="mini" @command="clickItem">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
@ -120,8 +119,7 @@
<span <span
v-if="chart.type !== 'table-info' && item.summary" v-if="chart.type !== 'table-info' && item.summary"
class="summary-span" class="summary-span"
>{{ $t("chart." + item.summary) }}</span >{{ $t('chart.' + item.summary) }}</span>
>
<i <i
class="el-icon-arrow-down el-icon--right" class="el-icon-arrow-down el-icon--right"
style="position: absolute; top: 6px; right: 10px" style="position: absolute; top: 6px; right: 10px"
@ -138,19 +136,19 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-s-data" /> <i class="el-icon-s-data" />
<span>{{ $t("chart.chart_type") }}</span> <span>{{ $t('chart.chart_type') }}</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeSwitch('bar')">{{ <el-dropdown-item :command="beforeSwitch('bar')">{{
$t("chart.chart_bar") $t('chart.chart_bar')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSwitch('line')">{{ <el-dropdown-item :command="beforeSwitch('line')">{{
$t("chart.chart_line") $t('chart.chart_line')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSwitch('scatter')">{{ <el-dropdown-item :command="beforeSwitch('scatter')">{{
$t("chart.chart_scatter") $t('chart.chart_scatter')
}}</el-dropdown-item> }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -168,10 +166,10 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-notebook-2" /> <i class="el-icon-notebook-2" />
<span>{{ $t("chart.summary") }}</span> <span>{{ $t('chart.summary') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.summary) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.summary) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
@ -179,66 +177,67 @@
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id === 'count' || item.id === 'count' ||
item.deType === 0 || item.deType === 0 ||
item.deType === 1 item.deType === 1
" "
:command="beforeSummary('count')" :command="beforeSummary('count')"
>{{ $t("chart.count") }}</el-dropdown-item >{{ $t('chart.count') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('sum')" :command="beforeSummary('sum')"
>{{ $t("chart.sum") }}</el-dropdown-item >{{ $t('chart.sum') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('avg')" :command="beforeSummary('avg')"
>{{ $t("chart.avg") }}</el-dropdown-item >{{ $t('chart.avg') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('max')" :command="beforeSummary('max')"
>{{ $t("chart.max") }}</el-dropdown-item >{{ $t('chart.max') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('min')" :command="beforeSummary('min')"
>{{ $t("chart.min") }}</el-dropdown-item >{{ $t('chart.min') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('stddev_pop')" :command="beforeSummary('stddev_pop')"
>{{ $t("chart.stddev_pop") }}</el-dropdown-item >{{ $t('chart.stddev_pop') }}</el-dropdown-item>
>
<el-dropdown-item <el-dropdown-item
v-if=" v-if="
item.id !== 'count' && item.id !== 'count' &&
item.deType !== 0 && item.deType !== 0 &&
item.deType !== 1 item.deType !== 1
" "
:command="beforeSummary('var_pop')" :command="beforeSummary('var_pop')"
>{{ $t("chart.var_pop") }}</el-dropdown-item >{{ $t('chart.var_pop') }}</el-dropdown-item>
> <el-dropdown-item
v-if="
item.id !== 'count' &&
item.deType !== 0 &&
item.deType !== 1
"
:command="beforeSummary('ratio')"
>{{ $t('chart.ratio') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-dropdown-item> </el-dropdown-item>
@ -268,22 +267,22 @@
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
<i class="el-icon-sort" /> <i class="el-icon-sort" />
<span>{{ $t("chart.sort") }}</span> <span>{{ $t('chart.sort') }}</span>
<span class="summary-span-item" <span
>({{ $t("chart." + item.sort) }})</span class="summary-span-item"
> >({{ $t('chart.' + item.sort) }})</span>
</span> </span>
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeSort('none')">{{ <el-dropdown-item :command="beforeSort('none')">{{
$t("chart.none") $t('chart.none')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('asc')">{{ <el-dropdown-item :command="beforeSort('asc')">{{
$t("chart.asc") $t('chart.asc')
}}</el-dropdown-item> }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('desc')">{{ <el-dropdown-item :command="beforeSort('desc')">{{
$t("chart.desc") $t('chart.desc')
}}</el-dropdown-item> }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -292,21 +291,21 @@
icon="el-icon-files" icon="el-icon-files"
:command="beforeClickItem('filter')" :command="beforeClickItem('filter')"
> >
<span>{{ $t("chart.filter") }}...</span> <span>{{ $t('chart.filter') }}...</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
icon="el-icon-edit-outline" icon="el-icon-edit-outline"
divided divided
:command="beforeClickItem('rename')" :command="beforeClickItem('rename')"
> >
<span>{{ $t("chart.show_name_set") }}</span> <span>{{ $t('chart.show_name_set') }}</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
icon="el-icon-delete" icon="el-icon-delete"
divided divided
:command="beforeClickItem('remove')" :command="beforeClickItem('remove')"
> >
<span>{{ $t("chart.delete") }}</span> <span>{{ $t('chart.delete') }}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</span> </span>
@ -316,109 +315,109 @@
<script> <script>
export default { export default {
name: "QuotaItem", name: 'QuotaItem',
props: { props: {
param: { param: {
type: Object, type: Object,
required: true, required: true
}, },
item: { item: {
type: Object, type: Object,
required: true, required: true
}, },
index: { index: {
type: Number, type: Number,
required: true, required: true
}, },
chart: { chart: {
type: Object, type: Object,
required: true, required: true
}, }
}, },
data() { data() {
return {}; return {}
}, },
mounted() {}, mounted() {},
methods: { methods: {
clickItem(param) { clickItem(param) {
if (!param) { if (!param) {
return; return
} }
switch (param.type) { switch (param.type) {
case "rename": case 'rename':
this.showRename(); this.showRename()
break; break
case "remove": case 'remove':
this.removeItem(); this.removeItem()
break; break
case "filter": case 'filter':
this.editFilter(); this.editFilter()
break; break
default: default:
break; break
} }
}, },
beforeClickItem(type) { beforeClickItem(type) {
return { return {
type: type, type: type
}; }
}, },
summary(param) { summary(param) {
this.item.summary = param.type; this.item.summary = param.type
this.$emit("onQuotaItemChange", this.item); this.$emit('onQuotaItemChange', this.item)
}, },
beforeSummary(type) { beforeSummary(type) {
return { return {
type: type, type: type
}; }
}, },
switchChartType(param) { switchChartType(param) {
// console.log(param) // console.log(param)
this.item.chartType = param.type; this.item.chartType = param.type
this.$emit("onQuotaItemChange", this.item); this.$emit('onQuotaItemChange', this.item)
}, },
beforeSwitch(type) { beforeSwitch(type) {
return { return {
type: type, type: type
}; }
}, },
quickCalc(param) {}, quickCalc(param) {},
beforeQuickCalc(type) { beforeQuickCalc(type) {
return { return {
type: type, type: type
}; }
}, },
sort(param) { sort(param) {
// console.log(param) // console.log(param)
this.item.sort = param.type; this.item.sort = param.type
this.$emit("onQuotaItemChange", this.item); this.$emit('onQuotaItemChange', this.item)
}, },
beforeSort(type) { beforeSort(type) {
return { return {
type: type, type: type
}; }
}, },
showRename() { showRename() {
this.item.index = this.index; this.item.index = this.index
this.item.renameType = "quota"; this.item.renameType = 'quota'
this.$emit("onNameEdit", this.item); this.$emit('onNameEdit', this.item)
}, },
removeItem() { removeItem() {
this.item.index = this.index; this.item.index = this.index
this.item.removeType = "quota"; this.item.removeType = 'quota'
this.$emit("onQuotaItemRemove", this.item); this.$emit('onQuotaItemRemove', this.item)
}, },
editFilter() { editFilter() {
this.item.index = this.index; this.item.index = this.index
this.item.filterType = "quota"; this.item.filterType = 'quota'
this.$emit("editItemFilter", this.item); this.$emit('editItemFilter', this.item)
}, }
}, }
}; }
</script> </script>
<style scoped> <style scoped>

@ -8,14 +8,14 @@
<el-icon name="back" class="back-button" @click.native="backToList" /> <el-icon name="back" class="back-button" @click.native="backToList" />
{{ {{
params && params &&
params.id && params.id &&
params.showModel && params.showModel &&
params.showModel === "show" && params.showModel === 'show' &&
!canEdit !canEdit
? $t("datasource.show_info") ? $t('datasource.show_info')
: formType == "add" : formType == 'add'
? $t("datasource.create") ? $t('datasource.create')
: $t("datasource.modify") : $t('datasource.modify')
}} }}
</template> </template>
<div> <div>
@ -28,10 +28,10 @@
size="small" size="small"
:disabled=" :disabled="
params && params &&
params.id && params.id &&
params.showModel && params.showModel &&
params.showModel === 'show' && params.showModel === 'show' &&
!canEdit !canEdit
" "
label-width="auto" label-width="auto"
label-position="right" label-position="right"
@ -49,7 +49,7 @@
class="select-width" class="select-width"
:disabled=" :disabled="
formType == 'modify' || formType == 'modify' ||
(formType === 'add' && params && !!params.type) (formType === 'add' && params && !!params.type)
" "
@change="changeType()" @change="changeType()"
> >
@ -99,13 +99,11 @@
<el-radio <el-radio
v-model="form.configuration.connectionType" v-model="form.configuration.connectionType"
label="sid" label="sid"
>{{ $t("datasource.oracle_sid") }}</el-radio >{{ $t('datasource.oracle_sid') }}</el-radio>
>
<el-radio <el-radio
v-model="form.configuration.connectionType" v-model="form.configuration.connectionType"
label="serviceName" label="serviceName"
>{{ $t("datasource.oracle_service_name") }}</el-radio >{{ $t('datasource.oracle_service_name') }}</el-radio>
>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
@ -152,7 +150,7 @@
<el-form-item <el-form-item
v-if=" v-if="
form.configuration.dataSourceType == 'jdbc' && form.configuration.dataSourceType == 'jdbc' &&
form.type !== 'oracle' form.type !== 'oracle'
" "
:label="$t('datasource.extra_params')" :label="$t('datasource.extra_params')"
> >
@ -177,20 +175,20 @@
<el-form-item <el-form-item
v-if=" v-if="
form.type == 'oracle' || form.type == 'oracle' ||
form.type == 'sqlServer' || form.type == 'sqlServer' ||
form.type == 'pg' form.type == 'pg'
" "
> >
<el-button icon="el-icon-plus" size="mini" @click="getSchema()"> <el-button icon="el-icon-plus" size="mini" @click="getSchema()">
{{ $t("datasource.get_schema") }} {{ $t('datasource.get_schema') }}
</el-button> </el-button>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if=" v-if="
form.type == 'oracle' || form.type == 'oracle' ||
form.type == 'sqlServer' || form.type == 'sqlServer' ||
form.type == 'pg' form.type == 'pg'
" "
:label="$t('datasource.schema')" :label="$t('datasource.schema')"
> >
@ -298,11 +296,9 @@
:label="$t('datasource.table_name')" :label="$t('datasource.table_name')"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span <span><i class="el-icon-coin" />&nbsp;&nbsp;{{
><i class="el-icon-coin" />&nbsp;&nbsp;{{ scope.row
scope.row }}</span>
}}</span
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -334,8 +330,8 @@
<span <span
v-if=" v-if="
scope.row.fieldType.indexOf('CHAR') >= 0 || scope.row.fieldType.indexOf('CHAR') >= 0 ||
scope.row.fieldType.indexOf('TEXT') >= 0 || scope.row.fieldType.indexOf('TEXT') >= 0 ||
scope.row.fieldType.indexOf('BLOB') >= 0 scope.row.fieldType.indexOf('BLOB') >= 0
" "
> >
<svg-icon <svg-icon
@ -343,13 +339,13 @@
class="field-icon-text" class="field-icon-text"
/> />
<span class="field-class">{{ <span class="field-class">{{
$t("dataset.text") $t('dataset.text')
}}</span> }}</span>
</span> </span>
<span <span
v-if=" v-if="
scope.row.fieldType.indexOf('DATE') >= 0 || scope.row.fieldType.indexOf('DATE') >= 0 ||
scope.row.fieldType.indexOf('TIME') >= 0 scope.row.fieldType.indexOf('TIME') >= 0
" "
> >
<svg-icon <svg-icon
@ -357,15 +353,15 @@
class="field-icon-time" class="field-icon-time"
/> />
<span class="field-class">{{ <span class="field-class">{{
$t("dataset.time") $t('dataset.time')
}}</span> }}</span>
</span> </span>
<span <span
v-if=" v-if="
scope.row.fieldType.indexOf('INT') >= 0 || scope.row.fieldType.indexOf('INT') >= 0 ||
scope.row.fieldType.indexOf('FLOAT') >= 0 || scope.row.fieldType.indexOf('FLOAT') >= 0 ||
scope.row.fieldType.indexOf('DOUBLE') >= 0 || scope.row.fieldType.indexOf('DOUBLE') >= 0 ||
scope.row.fieldType.indexOf('DECIMAL') >= 0 scope.row.fieldType.indexOf('DECIMAL') >= 0
" "
> >
<svg-icon <svg-icon
@ -373,17 +369,16 @@
class="field-icon-value" class="field-icon-value"
/> />
<span class="field-class">{{ <span class="field-class">{{
$t("dataset.value") $t('dataset.value')
}}</span> }}</span>
<span <span
v-if=" v-if="
scope.row.fieldType.indexOf('FLOAT') >= 0 || scope.row.fieldType.indexOf('FLOAT') >= 0 ||
scope.row.fieldType.indexOf('DOUBLE') >= 0 || scope.row.fieldType.indexOf('DOUBLE') >= 0 ||
scope.row.fieldType.indexOf('DECIMAL') >= 0 scope.row.fieldType.indexOf('DECIMAL') >= 0
" "
class="field-class" class="field-class"
>{{ "(" + $t("dataset.float") + ")" }}</span >{{ '(' + $t('dataset.float') + ')' }}</span>
>
</span> </span>
<span>({{ scope.row.fieldType }})</span> <span>({{ scope.row.fieldType }})</span>
</span> </span>
@ -423,8 +418,7 @@
: hasDataPermission('manage', params.privileges) : hasDataPermission('manage', params.privileges)
" "
@click="validaDatasource" @click="validaDatasource"
>{{ $t("commons.validate") }}</el-button >{{ $t('commons.validate') }}</el-button>
>
<el-button <el-button
v-if=" v-if="
formType === 'add' formType === 'add'
@ -433,8 +427,7 @@
" "
type="primary" type="primary"
@click="save" @click="save"
>{{ $t("commons.save") }}</el-button >{{ $t('commons.save') }}</el-button>
>
</div> </div>
<div v-else slot="footer" class="dialog-footer"> <div v-else slot="footer" class="dialog-footer">
<el-button <el-button
@ -444,8 +437,7 @@
: hasDataPermission('manage', params.privileges) : hasDataPermission('manage', params.privileges)
" "
@click="validaDatasource" @click="validaDatasource"
>{{ $t("commons.validate") }}</el-button >{{ $t('commons.validate') }}</el-button>
>
<el-button <el-button
v-if=" v-if="
formType === 'add' formType === 'add'
@ -454,8 +446,7 @@
" "
type="primary" type="primary"
@click="changeEdit" @click="changeEdit"
>{{ $t("commons.edit") }}</el-button >{{ $t('commons.edit') }}</el-button>
>
</div> </div>
</div> </div>
</div> </div>
@ -463,168 +454,168 @@
</template> </template>
<script> <script>
import LayoutContent from "@/components/business/LayoutContent"; import LayoutContent from '@/components/business/LayoutContent'
import { post } from "@/api/dataset/dataset"; import { post } from '@/api/dataset/dataset'
import { import {
addDs, addDs,
editDs, editDs,
getSchema, getSchema,
validateDs, validateDs,
validateDsById, validateDsById
} from "@/api/system/datasource"; } from '@/api/system/datasource'
import { $confirm } from "@/utils/message"; import { $confirm } from '@/utils/message'
export default { export default {
name: "DsForm", name: 'DsForm',
components: { LayoutContent }, components: { LayoutContent },
props: { props: {
params: { params: {
type: Object, type: Object,
default: null, default: null
}, }
}, },
data() { data() {
return { return {
form: { form: {
configuration: { configuration: {
initialPoolSize: 5, initialPoolSize: 5,
extraParams: "", extraParams: '',
minPoolSize: 5, minPoolSize: 5,
maxPoolSize: 50, maxPoolSize: 50,
maxIdleTime: 30, maxIdleTime: 30,
acquireIncrement: 5, acquireIncrement: 5,
idleConnectionTestPeriod: 5, idleConnectionTestPeriod: 5,
connectTimeout: 5, connectTimeout: 5
}, }
}, },
rule: { rule: {
name: [ name: [
{ {
required: true, required: true,
message: this.$t("datasource.input_name"), message: this.$t('datasource.input_name'),
trigger: "blur", trigger: 'blur'
}, },
{ {
min: 2, min: 2,
max: 25, max: 25,
message: this.$t("datasource.input_limit_2_25", [2, 25]), message: this.$t('datasource.input_limit_2_25', [2, 25]),
trigger: "blur", trigger: 'blur'
}, }
], ],
desc: [ desc: [
{ {
min: 0, min: 0,
max: 50, max: 50,
message: this.$t("datasource.input_limit_0_50"), message: this.$t('datasource.input_limit_0_50'),
trigger: "blur", trigger: 'blur'
}, }
], ],
type: [ type: [
{ {
required: true, required: true,
message: this.$t("datasource.please_choose_type"), message: this.$t('datasource.please_choose_type'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.dataBase": [ 'configuration.dataBase': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_data_base"), message: this.$t('datasource.please_input_data_base'),
trigger: "blur", trigger: 'blur'
}, }
], ],
"configuration.connectionType": [ 'configuration.connectionType': [
{ {
required: true, required: true,
message: this.$t("datasource.please_select_oracle_type"), message: this.$t('datasource.please_select_oracle_type'),
trigger: "blur", trigger: 'blur'
}, }
], ],
"configuration.username": [ 'configuration.username': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_user_name"), message: this.$t('datasource.please_input_user_name'),
trigger: "blur", trigger: 'blur'
}, }
], ],
"configuration.password": [ 'configuration.password': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_password"), message: this.$t('datasource.please_input_password'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.host": [ 'configuration.host': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_host"), message: this.$t('datasource.please_input_host'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.url": [ 'configuration.url': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_url"), message: this.$t('datasource.please_input_url'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.port": [ 'configuration.port': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_port"), message: this.$t('datasource.please_input_port'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.initialPoolSize": [ 'configuration.initialPoolSize': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_initial_pool_size"), message: this.$t('datasource.please_input_initial_pool_size'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.minPoolSize": [ 'configuration.minPoolSize': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_min_pool_size"), message: this.$t('datasource.please_input_min_pool_size'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.maxPoolSize": [ 'configuration.maxPoolSize': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_max_pool_size"), message: this.$t('datasource.please_input_max_pool_size'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.maxIdleTime": [ 'configuration.maxIdleTime': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_max_idle_time"), message: this.$t('datasource.please_input_max_idle_time'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.acquireIncrement": [ 'configuration.acquireIncrement': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_acquire_increment"), message: this.$t('datasource.please_input_acquire_increment'),
trigger: "change", trigger: 'change'
}, }
], ],
"configuration.connectTimeout": [ 'configuration.connectTimeout': [
{ {
required: true, required: true,
message: this.$t("datasource.please_input_connect_timeout"), message: this.$t('datasource.please_input_connect_timeout'),
trigger: "change", trigger: 'change'
}, }
], ]
}, },
allTypes: [ allTypes: [
{ {
name: "mysql", name: 'mysql',
label: "MySQL", label: 'MySQL',
type: "jdbc", type: 'jdbc',
extraParams: extraParams:
"characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true", 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
}, },
// { name: 'oracle', label: 'Oracle', type: 'jdbc'}, // { name: 'oracle', label: 'Oracle', type: 'jdbc'},
// { name: 'pg', label: 'PostgreSQL', type: 'jdbc', extraParams: '' }, // { name: 'pg', label: 'PostgreSQL', type: 'jdbc', extraParams: '' },
@ -632,18 +623,18 @@ export default {
// { name: 'ds_doris', label: 'Doris', type: 'jdbc', extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true' }, // { name: 'ds_doris', label: 'Doris', type: 'jdbc', extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true' },
// { name: 'ck', label: 'ClickHouse', type: 'jdbc', extraParams: '' } // { name: 'ck', label: 'ClickHouse', type: 'jdbc', extraParams: '' }
{ {
name: "mariadb", name: 'mariadb',
label: "MariaDB", label: 'MariaDB',
type: "jdbc", type: 'jdbc',
extraParams: extraParams:
"characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true", 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
}, },
{ {
name: "sqlServer", name: 'sqlServer',
label: "SQL Server", label: 'SQL Server',
type: "jdbc", type: 'jdbc',
extraParams: "", extraParams: ''
}, }
], ],
schemas: [], schemas: [],
canEdit: false, canEdit: false,
@ -654,100 +645,100 @@ export default {
tableLoading: false, tableLoading: false,
tableFields: [], tableFields: [],
showTableFields: false, showTableFields: false,
dataList: [], dataList: []
}; }
}, },
watch: { watch: {
form: { form: {
handler(val, old) { handler(val, old) {
if (val.id) { if (val.id) {
const _this = this; const _this = this
post("/datasource/getTables", { id: val.id }).then((response) => { post('/datasource/getTables', { id: val.id }).then((response) => {
_this.tables = response.data; _this.tables = response.data
_this.tableData = []; _this.tableData = []
_this.tables.forEach((item) => { _this.tables.forEach((item) => {
_this.tableData.push(item.name); _this.tableData.push(item.name)
}); })
_this.showTableList = _this.tableData.length > 0; _this.showTableList = _this.tableData.length > 0
}); })
} }
}, },
deep: true, deep: true
}, }
}, },
created() { created() {
if (this.params && this.params.id) { if (this.params && this.params.id) {
const row = this.params; const row = this.params
this.edit(row); this.edit(row)
} else { } else {
this.create(); this.create()
if (this.params && this.params.type) { if (this.params && this.params.type) {
this.setType(); this.setType()
} }
} }
}, },
mounted() {}, mounted() {},
methods: { methods: {
handleCurrentChange(row) { handleCurrentChange(row) {
const _this = this; const _this = this
const ds = JSON.parse(JSON.stringify(this.form)); const ds = JSON.parse(JSON.stringify(this.form))
ds.configuration = JSON.stringify(ds.configuration); ds.configuration = JSON.stringify(ds.configuration)
this.tableLoading = true; this.tableLoading = true
post("/datasource/getData/" + row + "/10", ds) post('/datasource/getData/' + row + '/10', ds)
.then((response) => { .then((response) => {
_this.tableFields = response.data.fieldList; _this.tableFields = response.data.fieldList
_this.showTableFields = _this.tableFields.length > 0; _this.showTableFields = _this.tableFields.length > 0
_this.dataList = response.data.dataList; _this.dataList = response.data.dataList
}) })
.finally((_) => { .finally((_) => {
this.tableLoading = false; this.tableLoading = false
}); })
}, },
setType() { setType() {
this.form.type = this.params.type; this.form.type = this.params.type
this.form.configuration = { this.form.configuration = {
initialPoolSize: 5, initialPoolSize: 5,
extraParams: "", extraParams: '',
minPoolSize: 5, minPoolSize: 5,
maxPoolSize: 50, maxPoolSize: 50,
maxIdleTime: 30, maxIdleTime: 30,
acquireIncrement: 5, acquireIncrement: 5,
idleConnectionTestPeriod: 5, idleConnectionTestPeriod: 5,
connectTimeout: 5, connectTimeout: 5
}; }
this.changeType(); this.changeType()
}, },
changeEdit() { changeEdit() {
this.canEdit = true; this.canEdit = true
this.formType = "modify"; this.formType = 'modify'
}, },
create() { create() {
this.formType = "add"; this.formType = 'add'
this.canEdit = true; this.canEdit = true
}, },
edit(row) { edit(row) {
this.formType = "modify"; this.formType = 'modify'
this.form = Object.assign({}, row); this.form = Object.assign({}, row)
this.originConfiguration = this.form.configuration; this.originConfiguration = this.form.configuration
this.form.configuration = JSON.parse(this.form.configuration); this.form.configuration = JSON.parse(this.form.configuration)
}, },
reset() { reset() {
this.$refs.dsForm.resetFields(); this.$refs.dsForm.resetFields()
}, },
save() { save() {
if ( if (
!this.form.configuration.schema && !this.form.configuration.schema &&
(this.form.type === "oracle" || this.form.type === "sqlServer") (this.form.type === 'oracle' || this.form.type === 'sqlServer')
) { ) {
this.$message.error(this.$t("datasource.please_choose_schema")); this.$message.error(this.$t('datasource.please_choose_schema'))
return; return
} }
if ( if (
this.form.configuration.dataSourceType === "jdbc" && this.form.configuration.dataSourceType === 'jdbc' &&
this.form.configuration.port <= 0 this.form.configuration.port <= 0
) { ) {
this.$message.error(this.$t("datasource.port_no_less_then_0")); this.$message.error(this.$t('datasource.port_no_less_then_0'))
return; return
} }
if ( if (
this.form.configuration.initialPoolSize < 0 || this.form.configuration.initialPoolSize < 0 ||
@ -758,118 +749,118 @@ export default {
this.form.configuration.idleConnectionTestPeriod < 0 || this.form.configuration.idleConnectionTestPeriod < 0 ||
this.form.configuration.connectTimeout < 0 this.form.configuration.connectTimeout < 0
) { ) {
this.$message.error(this.$t("datasource.no_less_then_0")); this.$message.error(this.$t('datasource.no_less_then_0'))
return; return
} }
this.$refs.dsForm.validate((valid) => { this.$refs.dsForm.validate((valid) => {
if (valid) { if (valid) {
const method = this.formType === "add" ? addDs : editDs; const method = this.formType === 'add' ? addDs : editDs
const form = JSON.parse(JSON.stringify(this.form)); const form = JSON.parse(JSON.stringify(this.form))
form.configuration = JSON.stringify(form.configuration); form.configuration = JSON.stringify(form.configuration)
if ( if (
this.formType !== "add" && this.formType !== 'add' &&
this.originConfiguration !== form.configuration this.originConfiguration !== form.configuration
) { ) {
$confirm(this.$t("datasource.edit_datasource_msg"), () => { $confirm(this.$t('datasource.edit_datasource_msg'), () => {
method(form).then((res) => { method(form).then((res) => {
this.$success(this.$t("commons.save_success")); this.$success(this.$t('commons.save_success'))
this.refreshTree(); this.refreshTree()
this.backToList(); this.backToList()
}); })
}); })
} else { } else {
method(form).then((res) => { method(form).then((res) => {
this.$success(this.$t("commons.save_success")); this.$success(this.$t('commons.save_success'))
this.refreshTree(); this.refreshTree()
this.backToList(); this.backToList()
}); })
} }
} else { } else {
return false; return false
} }
}); })
}, },
getSchema() { getSchema() {
this.$refs.dsForm.validate((valid) => { this.$refs.dsForm.validate((valid) => {
if (valid) { if (valid) {
const data = JSON.parse(JSON.stringify(this.form)); const data = JSON.parse(JSON.stringify(this.form))
data.configuration = JSON.stringify(data.configuration); data.configuration = JSON.stringify(data.configuration)
getSchema(data).then((res) => { getSchema(data).then((res) => {
this.schemas = res.data; this.schemas = res.data
this.$success(this.$t("commons.success")); this.$success(this.$t('commons.success'))
}); })
} else { } else {
return false; return false
} }
}); })
}, },
validaDatasource() { validaDatasource() {
if (!this.form.configuration.schema && this.form.type === "oracle") { if (!this.form.configuration.schema && this.form.type === 'oracle') {
this.$message.error(this.$t("datasource.please_choose_schema")); this.$message.error(this.$t('datasource.please_choose_schema'))
return; return
} }
if ( if (
this.form.configuration.dataSourceType === "jdbc" && this.form.configuration.dataSourceType === 'jdbc' &&
this.form.configuration.port <= 0 this.form.configuration.port <= 0
) { ) {
this.$message.error(this.$t("datasource.port_no_less_then_0")); this.$message.error(this.$t('datasource.port_no_less_then_0'))
return; return
} }
this.$refs.dsForm.validate((valid) => { this.$refs.dsForm.validate((valid) => {
if (valid) { if (valid) {
const data = JSON.parse(JSON.stringify(this.form)); const data = JSON.parse(JSON.stringify(this.form))
data.configuration = JSON.stringify(data.configuration); data.configuration = JSON.stringify(data.configuration)
if (data.showModel === "show" && !this.canEdit) { if (data.showModel === 'show' && !this.canEdit) {
validateDsById(data.id) validateDsById(data.id)
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
this.$success(this.$t("datasource.validate_success")); this.$success(this.$t('datasource.validate_success'))
} else { } else {
this.$error(this.$t(res.message)); this.$error(this.$t(res.message))
} }
this.refreshTree(); this.refreshTree()
}) })
.catch((res) => { .catch((res) => {
this.$error(res.message); this.$error(res.message)
}); })
} else { } else {
validateDs(data) validateDs(data)
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
this.tableData = res.data; this.tableData = res.data
console.log(this.tableData); console.log(this.tableData)
this.showTableList = true; this.showTableList = true
this.$success(this.$t("datasource.validate_success")); this.$success(this.$t('datasource.validate_success'))
} else { } else {
this.$error(this.$t(res.message)); this.$error(this.$t(res.message))
} }
}) })
.catch((res) => { .catch((res) => {
this.$error(res.message); this.$error(res.message)
}); })
} }
} else { } else {
return false; return false
} }
}); })
}, },
changeType() { changeType() {
for (let i = 0; i < this.allTypes.length; i++) { for (let i = 0; i < this.allTypes.length; i++) {
if (this.allTypes[i].name === this.form.type) { if (this.allTypes[i].name === this.form.type) {
this.form.configuration.dataSourceType = this.allTypes[i].type; this.form.configuration.dataSourceType = this.allTypes[i].type
this.form.configuration.extraParams = this.allTypes[i].extraParams; this.form.configuration.extraParams = this.allTypes[i].extraParams
} }
} }
}, },
backToList() { backToList() {
this.$emit("switch-component", {}); this.$emit('switch-component', {})
// this.$router.push({ name: 'datasource' }) // this.$router.push({ name: 'datasource' })
}, },
refreshTree() { refreshTree() {
this.$emit("refresh-left-tree"); this.$emit('refresh-left-tree')
}, }
}, }
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.back-button { .back-button {

@ -0,0 +1,2 @@
package com.ipsos.plugins.xpack.auth.service.impl;public class AuthXpackDefaultService {
}
Loading…
Cancel
Save