Commit eff85365ae508afc7f69e6478f5f881af37c9800

Authored by ww
1 parent 4d63b828

fix(DEFECT-1273): 修复日期区间时间段起始结尾时间

... ... @@ -146,12 +146,16 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
146 146
147 147 if (Reflect.has(value, BuiltInVariable.SELECT_TIME_AGGREGATION)) {
148 148 const fieldMapping = unref(getParams).find(item => item.key === BuiltInVariable.DATE_RANGE)
149   - const [start, end] = ((fieldMapping || {}).value || '').split(GROUP_SEPARATOR)
150   - const aggregation = Reflect.get(value, BuiltInVariable.SELECT_TIME_AGGREGATION) || {}
151   - const result = { ...aggregation, [start]: aggregation.startTs, [end]: aggregation.endTs }
152   - Reflect.deleteProperty(result, SelectTimeAggregationFieldEnum.START_TS)
153   - Reflect.deleteProperty(result, SelectTimeAggregationFieldEnum.END_TS)
154   - Object.assign(value, { ...result, [start]: aggregation.startTs, [end]: aggregation.endTs })
  149 + if (fieldMapping?.mores) {
  150 + const [start, end] = ((fieldMapping || {}).value || '').split(GROUP_SEPARATOR)
  151 + const aggregation = Reflect.get(value, BuiltInVariable.SELECT_TIME_AGGREGATION) || {}
  152 + const result = { ...aggregation, [start]: aggregation.startTs, [end]: aggregation.endTs }
  153 + if (start && end) {
  154 + Reflect.deleteProperty(result, SelectTimeAggregationFieldEnum.START_TS)
  155 + Reflect.deleteProperty(result, SelectTimeAggregationFieldEnum.END_TS)
  156 + }
  157 + Object.assign(value, { ...result, [start]: aggregation.startTs, [end]: aggregation.endTs })
  158 + }
155 159 Reflect.deleteProperty(value, BuiltInVariable.SELECT_TIME_AGGREGATION)
156 160 }
157 161
... ... @@ -241,7 +245,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
241 245 value: params[BuiltInVariable.DATE_RANGE],
242 246 type: 'datetimerange',
243 247 clearable: true,
244   - defaultTime: ['00:00:00', '00:00:00'],
  248 + defaultTime: ['00:00:00', '23:59:59'],
245 249 onUpdateValue(value) {
246 250 params[BuiltInVariable.DATE_RANGE] = value
247 251 }
... ... @@ -344,7 +348,6 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
344 348 }] as FormItemRule
345 349 }
346 350
347   - const uuid = () => Number(Math.random().toString().substring(2)).toString(32)
348 351 const toFormSchemas = (builtInVariableKey: string, required: boolean, value: any, mores: boolean) => {
349 352 const groupList = (builtInVariableKey || '').split(GROUP_SEPARATOR)
350 353 return groupList.reduce((prev, next) => {
... ... @@ -401,18 +404,19 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
401 404 const setParams = (Params: Recordable = {}) => {
402 405 for (const { key, value, mores } of unref(getParams)) {
403 406 const splitKeys = value ? value.split(GROUP_SEPARATOR) : (key || '').split(GROUP_SEPARATOR)
  407 + const [ start, end ] = splitKeys
404 408 if (isDateComponent(key as BuiltInVariable)) {
405 409 if (key as BuiltInVariable === BuiltInVariable.DATE_FIXED) {
406   - params[key] = Params[splitKeys[0]] || null
  410 + params[key] = Params[start] || null
407 411 continue
408 412 }
409 413 if (mores) {
410 414 const { agg, interval, limit } = Params
411   - const startTs = Params[splitKeys[0]]
412   - const endTs = Params[splitKeys[1]]
  415 + const startTs = Params[start]
  416 + const endTs = Params[end]
413 417 params[BuiltInVariable.SELECT_TIME_AGGREGATION] = { agg, interval, startTs, endTs, limit }
414 418 } else {
415   - const value = [Params[splitKeys[0]], Params[splitKeys[1]]]
  419 + const value = [Params[start], Params[end]]
416 420 params[key] = value.every(Boolean) ? value : null
417 421 }
418 422 continue
... ... @@ -426,9 +430,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
426 430 const clearParams = () => {
427 431 Object.keys(params).forEach(key => {
428 432 Reflect.deleteProperty(params, key)
429   - // params[key] = null
430 433 })
431   - // params[BuiltInVariable.SELECT_TIME_AGGREGATION] = { startTs: null, endTs: null, limit: null, interval: null }
432 434 params[BuiltInVariable.SELECT_TIME_AGGREGATION] = {}
433 435 }
434 436
... ...
... ... @@ -98,7 +98,7 @@ watch(() => props.value, (target) => {
98 98 <NGi :span="16">
99 99 <NFormItem :show-label="false">
100 100 <NDatePicker v-model:value="timePeriod" type="datetimerange" placeholder="请选择时间范围"
101   - @update-value="handleTimePerionChange" clearable></NDatePicker>
  101 + @update-value="handleTimePerionChange" clearable :default-time="['00:00:00', '23:59:59']"></NDatePicker>
102 102 </NFormItem>
103 103 </NGi>
104 104 <NGi :span="4">
... ...