forked from github/dataease
feat: 日期格式的支持
This commit is contained in:
parent
bbea8ecef8
commit
8dca4400c1
@ -13,6 +13,7 @@ import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.request.dataset.MultFieldValuesRequest;
|
||||
import io.dataease.controller.response.DatasetTableField4Type;
|
||||
import io.dataease.dto.dataset.DatasetTableFieldDTO;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTable;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -106,9 +107,33 @@ public class DataSetTableFieldController {
|
||||
DatasetTableField datasetTableField = DatasetTableField.builder().build();
|
||||
datasetTableField.setTableId(tableId);
|
||||
datasetTableField.setGroupType("d");
|
||||
List<DatasetTableField> dimensionList = dataSetTableFieldsService.list(datasetTableField);
|
||||
List<DatasetTableFieldDTO> dimensionList = new ArrayList<>();
|
||||
dataSetTableFieldsService.list(datasetTableField).forEach(o -> {
|
||||
DatasetTableFieldDTO datasetTableFieldDTO = new DatasetTableFieldDTO();
|
||||
BeanUtils.copyProperties(o, datasetTableFieldDTO);
|
||||
List<Object> deTypeCascader = new ArrayList<>();
|
||||
deTypeCascader.add(datasetTableFieldDTO.getDeType());
|
||||
if (datasetTableFieldDTO.getDeExtractType() == 0 && datasetTableFieldDTO.getDeType() == 1) {
|
||||
deTypeCascader.add(datasetTableFieldDTO.getDateFormatType());
|
||||
}
|
||||
datasetTableFieldDTO.setDeTypeCascader(deTypeCascader);
|
||||
dimensionList.add(datasetTableFieldDTO);
|
||||
});
|
||||
|
||||
|
||||
datasetTableField.setGroupType("q");
|
||||
List<DatasetTableField> quotaList = dataSetTableFieldsService.list(datasetTableField);
|
||||
List<DatasetTableFieldDTO> quotaList = new ArrayList<>();
|
||||
dataSetTableFieldsService.list(datasetTableField).forEach(o -> {
|
||||
DatasetTableFieldDTO datasetTableFieldDTO = new DatasetTableFieldDTO();
|
||||
BeanUtils.copyProperties(o, datasetTableFieldDTO);
|
||||
List<Object> deTypeCascader = new ArrayList<>();
|
||||
deTypeCascader.add(datasetTableFieldDTO.getDeType());
|
||||
if (datasetTableFieldDTO.getDeExtractType() == 0 && datasetTableFieldDTO.getDeType() == 1) {
|
||||
deTypeCascader.add(datasetTableFieldDTO.getDateFormatType());
|
||||
}
|
||||
datasetTableFieldDTO.setDeTypeCascader(deTypeCascader);
|
||||
quotaList.add(datasetTableFieldDTO);
|
||||
});
|
||||
|
||||
DatasetTableField4Type datasetTableField4Type = new DatasetTableField4Type();
|
||||
datasetTableField4Type.setDimensionList(dimensionList);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.dataease.controller.response;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.dto.dataset.DatasetTableFieldDTO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class DatasetTableField4Type {
|
||||
@ApiModelProperty("维度")
|
||||
List<DatasetTableField> dimensionList;
|
||||
List<DatasetTableFieldDTO> dimensionList;
|
||||
@ApiModelProperty("指标")
|
||||
List<DatasetTableField> quotaList;
|
||||
List<DatasetTableFieldDTO> quotaList;
|
||||
}
|
||||
|
@ -3,7 +3,10 @@ package io.dataease.dto.dataset;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DatasetTableFieldDTO extends DatasetTableField {
|
||||
private String jsonPath;
|
||||
private List<Object> deTypeCascader;
|
||||
}
|
||||
|
@ -39,3 +39,6 @@ WHERE (`component` = 'msg/setting');
|
||||
|
||||
ALTER TABLE `panel_group`
|
||||
ADD COLUMN `panel_sort` bigint(13) NULL COMMENT '排序' AFTER `watermark_open`;
|
||||
|
||||
ALTER TABLE `dataset_table_field`
|
||||
ADD COLUMN `date_format_type` VARCHAR(255) NULL COMMENT '时间格式类型' AFTER `date_format`;
|
||||
|
@ -136,24 +136,24 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
property="deType"
|
||||
property="deTypeCascader"
|
||||
:label="$t('dataset.field_type')"
|
||||
min-width="200"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-cascader
|
||||
v-model="scope.row.deType"
|
||||
v-model="scope.row.deTypeCascader"
|
||||
size="small"
|
||||
popper-class="select-date-resolution-format"
|
||||
:disabled="!hasDataPermission('manage', param.privileges)"
|
||||
class="select-type"
|
||||
:options="fields"
|
||||
:options="getFields(scope.row)"
|
||||
@visible-change="getPopPosition"
|
||||
@change="saveEdit(scope.row)"
|
||||
>
|
||||
<template slot-scope="{ node, data }">
|
||||
<span
|
||||
v-if="node.level === 2 && node.label === '%Y-%m-%d'"
|
||||
v-if="node.level === 2"
|
||||
class="format-title"
|
||||
:style="popPosition"
|
||||
>{{ $t('chart.date_format') }}</span>
|
||||
@ -214,16 +214,16 @@
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
<!-- <el-input-->
|
||||
<!-- v-if="scope.row.deType === 1"-->
|
||||
<!-- v-model="scope.row.dateFormat"-->
|
||||
<!-- :placeholder="$t('dataset.date_format')"-->
|
||||
<!-- size="small"-->
|
||||
<!-- class="input-type"-->
|
||||
<!-- :disabled="!hasDataPermission('manage', param.privileges)"-->
|
||||
<!-- @blur="saveEdit(scope.row)"-->
|
||||
<!-- @keyup.enter.native="saveEdit(scope.row)"-->
|
||||
<!-- />-->
|
||||
<el-input
|
||||
v-if="scope.row.deType === 1 && scope.row.deExtractType === 0"
|
||||
v-model="scope.row.dateFormat"
|
||||
:placeholder="$t('dataset.date_format')"
|
||||
size="small"
|
||||
class="input-type"
|
||||
:disabled="!hasDataPermission('manage', param.privileges)"
|
||||
@blur="saveEdit(scope.row)"
|
||||
@keyup.enter.native="saveEdit(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@ -476,24 +476,24 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
property="deType"
|
||||
property="deTypeCascader"
|
||||
:label="$t('dataset.field_type')"
|
||||
min-width="200"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-cascader
|
||||
v-model="scope.row.deType"
|
||||
v-model="scope.row.deTypeCascader"
|
||||
size="small"
|
||||
popper-class="select-date-resolution-format"
|
||||
:disabled="!hasDataPermission('manage', param.privileges)"
|
||||
class="select-type"
|
||||
:options="fields"
|
||||
:options="getFields(scope.row)"
|
||||
@visible-change="getPopPosition"
|
||||
@change="saveEdit(scope.row)"
|
||||
>
|
||||
<template slot-scope="{ node, data }">
|
||||
<span
|
||||
v-if="node.level === 2 && node.label === '%Y-%m-%d'"
|
||||
v-if="node.level === 2"
|
||||
class="format-title"
|
||||
:style="popPosition"
|
||||
>{{ $t('chart.date_format') }}</span>
|
||||
@ -554,16 +554,16 @@
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
<!-- <el-input-->
|
||||
<!-- v-if="scope.row.deType === 1"-->
|
||||
<!-- v-model="scope.row.dateFormat"-->
|
||||
<!-- :placeholder="$t('dataset.date_format')"-->
|
||||
<!-- size="small"-->
|
||||
<!-- class="input-type"-->
|
||||
<!-- :disabled="!hasDataPermission('manage', param.privileges)"-->
|
||||
<!-- @blur="saveEdit(scope.row)"-->
|
||||
<!-- @keyup.enter.native="saveEdit(scope.row)"-->
|
||||
<!-- />-->
|
||||
<el-input
|
||||
v-if="scope.row.deType === 1 && scope.row.deExtractType === 0"
|
||||
v-model="scope.row.dateFormat"
|
||||
:placeholder="$t('dataset.date_format')"
|
||||
size="small"
|
||||
class="input-type"
|
||||
:disabled="!hasDataPermission('manage', param.privileges)"
|
||||
@blur="saveEdit(scope.row)"
|
||||
@keyup.enter.native="saveEdit(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@ -771,7 +771,7 @@ export default {
|
||||
quotaListData: []
|
||||
},
|
||||
popPosition: {},
|
||||
fields: [],
|
||||
dateformats: [],
|
||||
fieldActiveNames: ['d', 'q'],
|
||||
searchField: '',
|
||||
editCalcField: false,
|
||||
@ -835,24 +835,45 @@ export default {
|
||||
dateformats(this.param.id).then((response) => {
|
||||
const children = (response?.data || []).map(ele => ({ label: ele.dateformat, value: ele.dateformat }))
|
||||
children.push({ label: '自定义', value: 'custom' })
|
||||
this.fields = [
|
||||
this.dateformats = children
|
||||
})
|
||||
},
|
||||
getFields(item) {
|
||||
if(item.deExtractType == 0){
|
||||
const children = this.dateformats
|
||||
return [
|
||||
{ label: this.$t('dataset.text'), value: 0 },
|
||||
{ label: this.$t('dataset.time'), value: 1, children },
|
||||
{ label: this.$t('dataset.value'), value: 2 },
|
||||
{
|
||||
label:
|
||||
this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')',
|
||||
this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')',
|
||||
value: 3
|
||||
},
|
||||
{ label: this.$t('dataset.location'), value: 5 }
|
||||
]
|
||||
})
|
||||
}else {
|
||||
return [
|
||||
{ label: this.$t('dataset.text'), value: 0 },
|
||||
{ label: this.$t('dataset.time'), value: 1 },
|
||||
{ label: this.$t('dataset.value'), value: 2 },
|
||||
{ label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 3 },
|
||||
{ label: this.$t('dataset.location'), value: 5 }
|
||||
]
|
||||
}
|
||||
},
|
||||
saveEdit(item) {
|
||||
if (item.name && item.name.length > 50) {
|
||||
this.$message.error(this.$t('dataset.field_name_less_50'))
|
||||
return
|
||||
}
|
||||
item.deType = item.deTypeCascader[0]
|
||||
if (item.deTypeCascader.length === 2) { // 时间
|
||||
item.dateFormatType = item.deTypeCascader[1]
|
||||
if(item.dateFormatType !== 'custom'){
|
||||
item.dateFormat = item.dateFormatType
|
||||
}
|
||||
}
|
||||
|
||||
post('/dataset/field/save', item)
|
||||
.then((response) => {
|
||||
|
Loading…
Reference in New Issue
Block a user