Merge remote-tracking branch 'origin/dev-v2' into dev-v2

This commit is contained in:
junjun 2023-11-28 16:40:03 +08:00
commit 3d21167a32
6 changed files with 192 additions and 31 deletions

View File

@ -351,7 +351,7 @@ public class ExcelUtils {
ReadCellData<?> cellData = headMap.get(key);
String value = cellData.getStringValue();
if (StringUtils.isEmpty(value)) {
DEException.throwException(context.readSheetHolder().getSheetName() + ", 首行行中不允许有空单元格!");
continue;
}
headerKey.add(key);
header.add(value);

View File

@ -755,7 +755,7 @@ public class DatasourceServer implements DatasourceApi {
}
}
}
if (CollectionUtils.isEmpty(excelSheetDataList)) {
if (CollectionUtils.isEmpty(excelSheetDataList) || excelSheetDataList.size() != datasetTableDTOS.size()) {
DEException.throwException("上传文件与源文件不一致,请检查文件!");
}
excelFileData.setSheets(excelSheetDataList);

View File

@ -4,7 +4,7 @@ import { Calendar } from '@element-plus/icons-vue'
import { type DatePickType } from 'element-plus-secondary'
import {
getThisYear,
getlastYear,
getLastYear,
getThisMonth,
getLastMonth,
getToday,
@ -15,6 +15,8 @@ import {
} from './time-format'
interface SelectConfig {
timeType: string
defaultValue: string
selectValue: string
relativeToCurrent: string
defaultValueCheck: boolean
id: string
@ -30,6 +32,8 @@ const props = defineProps({
type: Object as PropType<SelectConfig>,
default: () => {
return {
defaultValue: '',
selectValue: '',
timeType: 'fixed',
relativeToCurrent: 'custom',
timeNum: 0,
@ -52,6 +56,7 @@ const timeConfig = computed(() => {
timeNum,
relativeToCurrentType,
around,
defaultValueCheck,
arbitraryTime,
timeGranularity
} = config.value
@ -60,6 +65,7 @@ const timeConfig = computed(() => {
timeNum,
relativeToCurrentType,
around,
defaultValueCheck,
arbitraryTime,
timeGranularity
}
@ -75,6 +81,14 @@ watch(
}
)
watch(
() => selectValue.value,
val => {
config.value.defaultValue = val
config.value.selectValue = val
}
)
watch(
() => config.value.id,
() => {
@ -88,13 +102,19 @@ const init = () => {
timeNum,
relativeToCurrentType,
around,
defaultValueCheck,
arbitraryTime,
timeGranularity
} = timeConfig.value
if (!defaultValueCheck) {
selectValue.value = null
return
}
if (relativeToCurrent === 'custom') {
selectValue.value = getCustomTime(
timeNum,
relativeToCurrentType,
timeGranularity,
around,
timeGranularity === 'datetime' ? arbitraryTime : null
)
@ -104,7 +124,7 @@ const init = () => {
selectValue.value = getThisYear()
break
case 'lastYear':
selectValue.value = getlastYear()
selectValue.value = getLastYear()
break
case 'thisMonth':
selectValue.value = getThisMonth()

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { ref, reactive, nextTick, computed, shallowRef, toRefs, watch, unref } from 'vue'
import { ref, reactive, nextTick, computed, shallowRef, toRefs, watch } from 'vue'
import { storeToRefs } from 'pinia'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { useI18n } from '@/hooks/web/useI18n'
@ -421,15 +421,17 @@ const weightlessness = () => {
}
const parameterCompletion = () => {
curComponent.value = {
const attributes = {
timeType: 'fixed',
relativeToCurrent: 'custom',
timeNum: 0,
relativeToCurrentType: 'year',
around: 'f',
arbitraryTime: new Date(),
...unref(curComponent)
arbitraryTime: new Date()
}
Object.entries(attributes).forEach(([key, val]) => {
!curComponent.value[key] && (curComponent.value[key] = val)
})
}
const handleCondition = item => {
@ -539,6 +541,26 @@ const relativeToCurrentList = computed(() => {
}
]
break
case 'datetime':
list = [
{
label: '今天',
value: 'today'
},
{
label: '昨天',
value: 'yesterday'
},
{
label: '月初',
value: 'monthBeginning'
},
{
label: '年初',
value: 'yearBeginning'
}
]
break
default:
break

View File

@ -1,9 +1,13 @@
function getThisYear() {
return new Date(`${new Date().getFullYear()}`)
return new Date(`${new Date().getFullYear()}/1`)
}
function getlastYear() {
return new Date(`${new Date().getFullYear() - 1}`)
function getLastYear() {
return new Date(`${new Date().getFullYear() - 1}/1`)
}
function getNextYear() {
return new Date(`${new Date().getFullYear() + 1}/1`)
}
function getThisMonth() {
@ -16,14 +20,19 @@ function getLastMonth() {
return new Date(`${date.getFullYear()}/${date.getMonth()}`)
}
function getNextMonth() {
const date = getCustomTime(1, 'month', 'month', 'b')
return new Date(`${date.getFullYear()}/${date.getMonth() + 1}`)
}
function getToday() {
const date = new Date()
return new Date(`${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`)
}
function getYesterday() {
const date = new Date()
return new Date(date.getTime() - 24 * 60 * 60 * 1000)
const date = new Date(new Date().getTime() - 24 * 60 * 60 * 1000)
return new Date(`${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`)
}
function getMonthBeginning() {
@ -36,7 +45,13 @@ function getYearBeginning() {
return new Date(`${date.getFullYear()}/1/1`)
}
function getCustomTime(timeNum: number, timeType: string, around: string, arbitraryTime?: string) {
function getCustomTime(
timeNum: number,
timeType: string,
timeGranularity: string,
around: string,
arbitraryTime?: string
) {
const date = new Date()
const num = around === 'f' ? -timeNum : timeNum
const year = date.getFullYear()
@ -48,14 +63,10 @@ function getCustomTime(timeNum: number, timeType: string, around: string, arbitr
if (resultMonth > 12) {
resultYear += parseInt(`${resultMonth / 12}`)
resultMonth = resultMonth % 12
}
if (resultMonth < 0) {
} else if (resultMonth < 0) {
resultYear += parseInt(`${resultMonth / 12}`) - 1
resultMonth = month + (resultMonth % 12)
}
if (resultMonth === 0) {
} else if (resultMonth === 0) {
resultYear += parseInt(`${resultMonth / 12}`) - 1
resultMonth = 12
}
@ -73,17 +84,118 @@ function getCustomTime(timeNum: number, timeType: string, around: string, arbitr
time.setDate(resultDate)
return time
}
return new Date(`${resultYear}/${resultMonth}/${resultDate}`)
switch (timeGranularity) {
case 'year':
return new Date(`${resultYear}/1`)
case 'month':
return new Date(`${resultYear}/${resultMonth}/1`)
case 'date':
return new Date(`${resultYear}/${resultMonth}/${resultDate}`)
default:
break
}
}
function getDynamicRange({
relativeToCurrent,
timeNum,
relativeToCurrentType,
around,
arbitraryTime,
timeGranularity
}) {
let selectValue = null
if (relativeToCurrent === 'custom') {
const startTime = getCustomTime(timeNum, relativeToCurrentType, timeGranularity, around)
const endTime = getCustomTime(
timeNum + (around === 'f' ? -1 : 1),
relativeToCurrentType,
timeGranularity,
around
)
switch (timeGranularity) {
case 'year':
selectValue = [startTime.getTime(), endTime.getTime() - 1000]
break
case 'month':
selectValue = [startTime.getTime(), endTime.getTime() - 1000]
break
case 'date':
const dateVal = getCustomTime(timeNum, relativeToCurrentType, timeGranularity, around)
selectValue = [dateVal.getTime(), dateVal.getTime() + 24 * 3600 * 1000 - 1000]
break
case 'datetime':
const datetimeVal = getCustomTime(
timeNum,
relativeToCurrentType,
timeGranularity,
around,
arbitraryTime
)
selectValue = [datetimeVal.getTime(), datetimeVal.getTime()]
break
default:
break
}
} else {
const isDateTime = timeGranularity === 'datetime'
switch (relativeToCurrent) {
case 'thisYear':
selectValue = [getThisYear().getTime(), getNextYear().getTime() - 1000]
break
case 'lastYear':
selectValue = [getLastYear().getTime(), getYearBeginning().getTime() - 1000]
break
case 'thisMonth':
selectValue = [getThisMonth().getTime(), getNextMonth().getTime() - 1000]
break
case 'lastMonth':
selectValue = [getLastMonth().getTime(), getMonthBeginning().getTime() - 1000]
break
case 'today':
const todayVal = getToday().getTime()
selectValue = [todayVal, isDateTime ? todayVal : todayVal + 24 * 3600 * 1000 - 1000]
break
case 'yesterday':
const yesterdayVal = getYesterday().getTime()
selectValue = [
yesterdayVal,
isDateTime ? yesterdayVal : yesterdayVal + 24 * 3600 * 1000 - 1000
]
break
case 'monthBeginning':
const monthBeginningVal = getMonthBeginning().getTime()
selectValue = [
monthBeginningVal,
isDateTime ? monthBeginningVal : monthBeginningVal + 24 * 3600 * 1000 - 1000
]
break
case 'yearBeginning':
const yearBeginningVal = getYearBeginning().getTime()
selectValue = [
yearBeginningVal,
isDateTime ? yearBeginningVal : yearBeginningVal + 24 * 3600 * 1000 - 1000
]
break
default:
break
}
}
return selectValue
}
export {
getThisYear,
getlastYear,
getLastYear,
getThisMonth,
getLastMonth,
getToday,
getYesterday,
getMonthBeginning,
getYearBeginning,
getCustomTime
getCustomTime,
getDynamicRange
}

View File

@ -1,6 +1,6 @@
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia'
import { getDynamicRange } from '@/custom-component/v-query/time-format'
const dvMainStore = dvMainStoreWithOut()
const { componentData } = storeToRefs(dvMainStore)
@ -91,6 +91,7 @@ export const searchQuery = (queryComponentList, filter, curComponentId, firstLoa
const {
selectValue: value,
defaultValueCheck,
timeType = 'fixed',
defaultValue,
parameters = [],
parametersCheck = false,
@ -99,13 +100,19 @@ export const searchQuery = (queryComponentList, filter, curComponentId, firstLoa
displayType,
multiple
} = item
selectValue = getValueByDefaultValueCheckOrFirstLoad(
defaultValueCheck,
defaultValue,
value,
firstLoad,
multiple
)
if (timeType === 'dynamic' && +displayType === 1 && firstLoad && !value?.length) {
selectValue = getDynamicRange(item)
item.defaultValue = new Date(selectValue[0])
item.selectValue = new Date(selectValue[0])
} else {
selectValue = getValueByDefaultValueCheckOrFirstLoad(
defaultValueCheck,
defaultValue,
value,
firstLoad,
multiple
)
}
if (
!!selectValue?.length ||
Object.prototype.toString.call(selectValue) === '[object Date]'