@tplc/business 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.4.5](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.94...v0.4.5) (2025-03-24)
6
+
7
+
8
+ ### 🚀 Chore | 构建/工程依赖/工具
9
+
10
+ * **release:** 0.3.100 ([b2e8ec6](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/b2e8ec601f623535f7001bdd99bb03458ed14b84))
11
+ * **release:** 0.3.101 ([c547cbb](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/c547cbb175f74dcb7f52b07ece54da3d1698bc30))
12
+ * **release:** 0.3.95 ([f9ca9ff](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/f9ca9ff0416ef0bda24eea8dbf689b26129a78a5))
13
+ * **release:** 0.3.96 ([5f357d3](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/5f357d3ef08c67bd3d930d90eec47d61f6aaa66e))
14
+ * **release:** 0.3.97 ([d8e0beb](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/d8e0bebb7608cdd554156f7ab5879c711cc6c32a))
15
+ * **release:** 0.3.98 ([1b3a356](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/1b3a3564eae8c662f8fc1feb4445799f5b56bdbb))
16
+ * **release:** 0.3.99 ([7f9861f](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/7f9861f7a59476307b09a5f7bf0de9cf12ccf969))
17
+ * **release:** 0.4.1 ([fa913d1](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/fa913d1a0e9cadd70aac45147e0b1e4819606ef5))
18
+ * **release:** 0.4.2 ([cf71a5b](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/cf71a5b2e29e1fcfcd5527bb56abe7d8a920607d))
19
+ * **release:** 0.4.3 ([21d38cb](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/21d38cb80f3c41a0a4be99b4cbb28dd32c849c6e))
20
+ * **release:** 0.4.4 ([34e2c09](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/34e2c09c3c8d992c3cbcdaf3b1d4dc63a2d4a113))
21
+
22
+
23
+ ### ✨ Features | 新功能
24
+
25
+ * form 校验 ([51cce50](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/51cce50ece8f98479fecf9e30c26d755e6188c82))
26
+ * 修改 addresName ([bbc369d](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/bbc369dad73eb961c74b2aa1dfa6b833bb5cb572))
27
+ * 修改ui ([ae50efe](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/ae50efe91a667d8f040479d6274853c091a791f1))
28
+ * 修改地址 ([dba8297](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/dba82970fccf44096fed203b46316c7da2f9f9b9))
29
+ * 修改接口 ([d3a0193](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/d3a01931b2a4f86b992d9df0e390ce3bf5870cf4))
30
+ * 差协议弹出 ([53ecf7d](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/53ecf7dd6ee37cf94abaf3d8ffb2ad8adfcc1841))
31
+ * 新增tag ([74b9c29](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/74b9c2971b69986c6c0428406eeca0a57d66eef4))
32
+ * 调整全局 ([c7ef8db](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/c7ef8db507c2b199cebfed02c6051bc81fd6d6ff))
33
+ * 调整底部数据 ([9f72871](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/9f72871c2c3b3a70c2140828182cd3ecd527a3f7))
34
+ * 调整过滤选择 ([764ce1f](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/764ce1f68a6a851777835ea0ff5f0d588c715937))
35
+ * 还差数据统一 ([4f87b06](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/4f87b06331726ae4bf505c4ebae62076688ee9dc))
36
+
37
+ ### [0.4.4](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.4.3...v0.4.4) (2025-03-23)
38
+
39
+
40
+ ### ✨ Features | 新功能
41
+
42
+ * 修改 addresName ([bbc369d](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/bbc369dad73eb961c74b2aa1dfa6b833bb5cb572))
43
+
5
44
  ### [0.4.3](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.4.2...v0.4.3) (2025-03-23)
6
45
 
7
46
  ### [0.4.2](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.4.1...v0.4.2) (2025-03-23)
@@ -4,7 +4,7 @@
4
4
  @confirm="handleConfirm"
5
5
  type="daterange"
6
6
  use-default-slot
7
- :formatter="formatter"
7
+ :formatter="calendarFormatter(holidayInfo, translate)"
8
8
  :min-date="minDate"
9
9
  :max-date="maxDate"
10
10
  @open="emits('open')"
@@ -20,6 +20,7 @@ import { useTranslate } from '@tplc/wot'
20
20
  import dayjs from 'dayjs/esm'
21
21
  import { ref } from 'vue'
22
22
  import { LcbHistoryResult, queryHolidayInfoList } from './api'
23
+ import { calendarFormatter } from '../../utils/formatter'
23
24
  const { translate } = useTranslate()
24
25
 
25
26
  defineOptions({
@@ -83,46 +84,6 @@ const getDayInfo = async () => {
83
84
  )
84
85
  }
85
86
 
86
- const formatter = (day: any) => {
87
- const date = new Date(day.date)
88
- const now = new Date()
89
-
90
- const year = date.getFullYear()
91
- const month = date.getMonth()
92
- const da = date.getDate()
93
- const nowYear = now.getFullYear()
94
- const nowMonth = now.getMonth()
95
- const nowDa = now.getDate()
96
-
97
- const info = holidayInfo.value[dayjs(day.date).format('YYYY-MM-DD')]
98
- if (info?.topText) {
99
- day.topInfo = info.topText
100
- }
101
- if (info?.bottomText) {
102
- day.bottomInfo = info.bottomText
103
- }
104
- if (info?.centerText) {
105
- day.text = info.centerText
106
- }
107
- if (year === nowYear && month === nowMonth && da === nowDa) {
108
- day.topInfo = translate('今天')
109
- }
110
-
111
- if (day.type === 'start') {
112
- day.topInfo = translate('开始')
113
- }
114
-
115
- if (day.type === 'end') {
116
- day.topInfo = translate('结束')
117
- }
118
-
119
- if (day.type === 'same') {
120
- day.bottomInfo = translate('开始/结束')
121
- }
122
- day.restFlag = info?.restFlag
123
-
124
- return day
125
- }
126
87
  const handleConfirm = ({ value }: { value: number[] }) => {
127
88
  model.value = value
128
89
  emits('confirm', value)
@@ -0,0 +1,4 @@
1
+ import { HolidayInfo } from './types'
2
+
3
+ export const queryHolidayInfoList = (data: { productType: string; productSkuId?: string }) =>
4
+ uni.$lcb.http.post<HolidayInfo[]>('/holiday/queryHolidayInfoList', data)
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <view
3
+ class="gap-0.25 flex flex-col p-2 justify-center border-solid border-1 border-#eeeeee rounded-1 relative"
4
+ @click="date?.status !== 0 ? (currentDate = date?.date) : undefined"
5
+ :class="{
6
+ 'bg-[var(--theme-bg-color)] text-primary !border-[var(--wot-primary-color)]':
7
+ currentDate === date?.date,
8
+ 'opacity-50': date?.status === 0,
9
+ [customClass]: true,
10
+ }"
11
+ >
12
+ <template v-if="date">
13
+ <text class="whitespace-nowrap">
14
+ {{ date.topText }} {{ dayjs(date.date).format('MM-DD') }}
15
+ </text>
16
+ <view class="text-[var(--font1-color)]">{{ date.price }}</view>
17
+ <view v-if="date.floorText" class="text-[var(--font2-color)]">
18
+ {{ date.floorText }}
19
+ </view>
20
+ <view
21
+ v-if="date.corner"
22
+ class="absolute top--2 left--0.25 bg-primary text-white text-2 px-2 py-0.25 rounded-tl-2 rounded-br-1"
23
+ >
24
+ {{ date.corner }}
25
+ </view>
26
+ </template>
27
+ <template v-if="showAll">
28
+ <text class="whitespace-nowrap">全部</text>
29
+ </template>
30
+ </view>
31
+ </template>
32
+ <script setup lang="ts">
33
+ import dayjs from 'dayjs/esm'
34
+ import { HolidayInfo } from '../../types'
35
+
36
+ defineProps<{
37
+ date?: HolidayInfo
38
+ showAll?: boolean
39
+ customClass: string
40
+ }>()
41
+
42
+ const currentDate = defineModel<string | undefined>()
43
+ </script>
@@ -1,9 +1,60 @@
1
1
  <template>
2
- <lcb-block></lcb-block>
2
+ <lcb-block v-bind="$props">
3
+ <view class="relative flex">
4
+ <!-- 左侧固定的"全部"选项 -->
5
+ <CalendarItem showAll v-model="currentDate" custom-class="mt-3" />
6
+
7
+ <scroll-view
8
+ scroll-x
9
+ class="whitespace-nowrap overflow-x-auto overflow-y-auto flex-1 w-0 pl-2 box-border"
10
+ :show-scrollbar="false"
11
+ :scroll-into-view="`id_${currentDate}`"
12
+ :scroll-with-animation="true"
13
+ >
14
+ <view class="flex gap-2 inline-flex h-full">
15
+ <CalendarItem
16
+ v-for="date in datePriceList"
17
+ :key="date.date"
18
+ :id="`id_${date.date}`"
19
+ :date="date"
20
+ custom-class="mt-3 !justify-start"
21
+ v-model="currentDate"
22
+ />
23
+ </view>
24
+ </scroll-view>
25
+ <view
26
+ class="flex flex-col justify-center items-center px-2 py-1 w-8 text-primary bg-white mt-3"
27
+ @click="onMore"
28
+ v-if="showMore"
29
+ >
30
+ <text class="text-center">更多时间</text>
31
+ <wd-icon name="caret-right-small" size="18px" />
32
+ </view>
33
+ </view>
34
+
35
+ <wd-calendar
36
+ ref="calendarRef"
37
+ :with-cell="false"
38
+ v-model="calendarValue"
39
+ :formatter="calendarFormatter(holidayInfo, t)"
40
+ @confirm="handleCalendarChange"
41
+ :modal="false"
42
+ v-bind="dateRange"
43
+ />
44
+ </lcb-block>
3
45
  </template>
4
46
 
5
47
  <script setup lang="ts">
6
- import { LcbCalendarFilterProps } from './types'
48
+ import { useTranslate } from '@tplc/wot'
49
+ import { CalendarExpose } from '@tplc/wot/types/components/wd-calendar/types'
50
+ import dayjs from 'dayjs/esm'
51
+ import 'dayjs/esm/locale/zh-cn'
52
+ import { onMounted, ref, watchEffect, inject, Ref } from 'vue'
53
+ import { HolidayInfo, LcbCalendarFilterProps } from './types'
54
+ import CalendarItem from './components/CalendarItem/index.vue'
55
+ import { queryHolidayInfoList } from './api'
56
+ import { FORM_KEY } from '../../constants'
57
+ import { calendarFormatter } from '../../utils/formatter'
7
58
  defineOptions({
8
59
  name: 'LcbCalendarFilter',
9
60
  options: {
@@ -12,7 +63,63 @@ defineOptions({
12
63
  styleIsolation: 'shared',
13
64
  },
14
65
  })
15
- withDefaults(defineProps<LcbCalendarFilterProps>(), {})
16
- </script>
66
+ const { translate: t } = useTranslate()
67
+ const props = withDefaults(defineProps<LcbCalendarFilterProps>(), {
68
+ showAll: true,
69
+ showMore: true,
70
+ formKey: 'date',
71
+ fontSize: 24,
72
+ })
73
+ const dateRange = ref({
74
+ minDate: dayjs().valueOf(),
75
+ maxDate: dayjs().add(30, 'day').valueOf(),
76
+ })
77
+ const currentDate = ref<string>()
78
+ const holidayInfo = ref<Record<string, HolidayInfo>>({})
79
+ const datePriceList = ref<HolidayInfo[]>()
80
+ const calendarRef = ref<CalendarExpose>()
81
+ const calendarValue = ref<number | number[] | null>(null)
82
+ const from = inject(FORM_KEY) as Ref<Record<string, any>>
83
+ onMounted(async () => {
84
+ const { data } = await queryHolidayInfoList({
85
+ productType: 'activity',
86
+ })
87
+ holidayInfo.value = data.reduce(
88
+ (acc, cur) => {
89
+ acc[cur.date] = cur
90
+ return acc
91
+ },
92
+ {} as Record<string, HolidayInfo>,
93
+ )
94
+ const sortedHolidayInfo = Object.keys(holidayInfo.value).sort((a, b) => {
95
+ return dayjs(a).valueOf() - dayjs(b).valueOf()
96
+ })
97
+ dateRange.value.minDate = dayjs(sortedHolidayInfo[0]).valueOf()
98
+ dateRange.value.maxDate = dayjs(sortedHolidayInfo[sortedHolidayInfo.length - 1]).valueOf()
99
+ handleCalendarChange({ value: dayjs().valueOf() })
100
+ })
101
+ const handleCalendarChange = ({ value }: { value: number }) => {
102
+ const targetDate = dayjs(value)
103
+ // 前七天
104
+ const startDate = targetDate.subtract(7, 'day')
105
+ // 往后算15天
106
+ const priceList: HolidayInfo[] = []
107
+ for (let i = 0; i < 15; i++) {
108
+ const date = startDate.add(i, 'day')
109
+ const formattedDate = date.format('YYYY-MM-DD')
110
+ const holidayData = holidayInfo.value[formattedDate]
111
+ if (holidayData) {
112
+ priceList.push(holidayData)
113
+ }
114
+ }
115
+ datePriceList.value = priceList as HolidayInfo[]
116
+ }
17
117
 
18
- <style lang="scss" scoped></style>
118
+ watchEffect(() => {
119
+ calendarValue.value = currentDate.value ? dayjs(currentDate.value).valueOf() : null
120
+ from!.value[props.formKey] = currentDate.value
121
+ })
122
+ const onMore = async () => {
123
+ calendarRef.value?.open()
124
+ }
125
+ </script>
@@ -1,3 +1,30 @@
1
- export interface LcbCalendarFilterProps {
2
- // Define the component's prop types here
1
+ import { LcbBlockProps } from '../../components/lcb-block/types'
2
+
3
+ export interface LcbCalendarFilterProps extends LcbBlockProps {
4
+ /**
5
+ * 是否显示"全部"按钮
6
+ * @default true
7
+ */
8
+ showAll?: boolean
9
+
10
+ /**
11
+ * 当前选中的日期值
12
+ */
13
+ showMore?: boolean
14
+
15
+ /**
16
+ * 表单key
17
+ */
18
+ formKey?: string
19
+ }
20
+
21
+ export interface HolidayInfo {
22
+ bottomText?: string
23
+ date: string
24
+ floorText?: string
25
+ price: number
26
+ topText?: string
27
+ status: number
28
+ corner?: string
29
+ restFlag: boolean
3
30
  }
@@ -2,7 +2,7 @@ export interface HotAddress {
2
2
  categoryName: string
3
3
  hint?: string
4
4
  tips?: string
5
- childHotAddress: ChildHotAddress[]
5
+ childAddress: ChildHotAddress[]
6
6
  }
7
7
 
8
8
  export interface ChildHotAddress {
@@ -32,7 +32,7 @@
32
32
  `${city.addressName},${city.keywords}`,
33
33
  [city.className || '']: true,
34
34
  }"
35
- v-for="city in item.childHotAddress"
35
+ v-for="city in item.childAddress"
36
36
  @click="onAddrClick(city, item.categoryName.includes('字母'))"
37
37
  :style="{
38
38
  fontSize: city?.addressName?.length > 4 ? '20rpx' : '24rpx',
@@ -89,7 +89,7 @@ const locationAddress = computed<HotAddress[]>(() => {
89
89
  categoryName: '定位',
90
90
  hint: '当前位置',
91
91
  tips: props.location.haveNotTip,
92
- childHotAddress: [
92
+ childAddress: [
93
93
  {
94
94
  addressName: props.location.haveNotCityName || props.location.cityName,
95
95
  cityId: props.location.haveNotCityId || props.location.cityId,
@@ -114,7 +114,7 @@ const historyLetter = computed<HotAddress[]>(() => {
114
114
  {
115
115
  categoryName: '历史',
116
116
  hint: '历史选择',
117
- childHotAddress: historyList.value,
117
+ childAddress: historyList.value,
118
118
  },
119
119
  ]
120
120
  : []
@@ -147,7 +147,7 @@ const indexBars = computed<HotAddress[]>(() => {
147
147
  ? ([
148
148
  {
149
149
  categoryName: '字母索引',
150
- childHotAddress: letterList.value.map((v) => {
150
+ childAddress: letterList.value.map((v) => {
151
151
  return {
152
152
  addressName: v,
153
153
  cityId: v,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -0,0 +1,5 @@
1
+ import { HolidayInfo } from './types'
2
+ export declare const queryHolidayInfoList: (data: {
3
+ productType: string
4
+ productSkuId?: string
5
+ }) => Promise<import('../../action').IResData<HolidayInfo[]>>
@@ -0,0 +1,40 @@
1
+ import { HolidayInfo } from '../../types'
2
+ declare let __VLS_typeProps: {
3
+ date?: HolidayInfo
4
+ showAll?: boolean
5
+ customClass: string
6
+ }
7
+ type __VLS_PublicProps = {
8
+ modelValue?: string | undefined
9
+ } & typeof __VLS_typeProps
10
+ declare const _default: import('vue').DefineComponent<
11
+ __VLS_TypePropsToOption<__VLS_PublicProps>,
12
+ {},
13
+ unknown,
14
+ {},
15
+ {},
16
+ import('vue').ComponentOptionsMixin,
17
+ import('vue').ComponentOptionsMixin,
18
+ {
19
+ 'update:modelValue': (modelValue: string | undefined) => void
20
+ },
21
+ string,
22
+ import('vue').PublicProps,
23
+ Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToOption<__VLS_PublicProps>>> & {
24
+ 'onUpdate:modelValue'?: ((modelValue: string | undefined) => any) | undefined
25
+ },
26
+ {},
27
+ {}
28
+ >
29
+ export default _default
30
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T
31
+ type __VLS_TypePropsToOption<T> = {
32
+ [K in keyof T]-?: {} extends Pick<T, K>
33
+ ? {
34
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>
35
+ }
36
+ : {
37
+ type: import('vue').PropType<T[K]>
38
+ required: true
39
+ }
40
+ }
@@ -1,8 +1,14 @@
1
+ import 'dayjs/esm/locale/zh-cn'
2
+ import { LcbCalendarFilterProps } from './types'
1
3
  declare const _default: import('vue').DefineComponent<
2
- Readonly<
3
- import('vue').ComponentPropsOptions<{
4
- [x: string]: unknown
5
- }>
4
+ __VLS_WithDefaults<
5
+ __VLS_TypePropsToOption<LcbCalendarFilterProps>,
6
+ {
7
+ showAll: boolean
8
+ showMore: boolean
9
+ formKey: string
10
+ fontSize: number
11
+ }
6
12
  >,
7
13
  {},
8
14
  unknown,
@@ -13,20 +19,48 @@ declare const _default: import('vue').DefineComponent<
13
19
  {},
14
20
  string,
15
21
  import('vue').PublicProps,
16
- | readonly string[]
17
- | Readonly<
18
- import('vue').ExtractPropTypes<
19
- Readonly<
20
- import('vue').ComponentObjectPropsOptions<{
21
- [x: string]: unknown
22
- }>
23
- >
22
+ Readonly<
23
+ import('vue').ExtractPropTypes<
24
+ __VLS_WithDefaults<
25
+ __VLS_TypePropsToOption<LcbCalendarFilterProps>,
26
+ {
27
+ showAll: boolean
28
+ showMore: boolean
29
+ formKey: string
30
+ fontSize: number
31
+ }
24
32
  >
25
- >,
26
- | {
27
- readonly [x: number]: string
28
- }
29
- | {},
33
+ >
34
+ >,
35
+ {
36
+ fontSize: number
37
+ showAll: boolean
38
+ showMore: boolean
39
+ formKey: string
40
+ },
30
41
  {}
31
42
  >
32
43
  export default _default
44
+ type __VLS_WithDefaults<P, D> = {
45
+ [K in keyof Pick<P, keyof P>]: K extends keyof D
46
+ ? __VLS_Prettify<
47
+ P[K] & {
48
+ default: D[K]
49
+ }
50
+ >
51
+ : P[K]
52
+ }
53
+ type __VLS_Prettify<T> = {
54
+ [K in keyof T]: T[K]
55
+ } & {}
56
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T
57
+ type __VLS_TypePropsToOption<T> = {
58
+ [K in keyof T]-?: {} extends Pick<T, K>
59
+ ? {
60
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>
61
+ }
62
+ : {
63
+ type: import('vue').PropType<T[K]>
64
+ required: true
65
+ }
66
+ }
@@ -1 +1,26 @@
1
- export interface LcbCalendarFilterProps {}
1
+ import { LcbBlockProps } from '../../components/lcb-block/types'
2
+ export interface LcbCalendarFilterProps extends LcbBlockProps {
3
+ /**
4
+ * 是否显示"全部"按钮
5
+ * @default true
6
+ */
7
+ showAll?: boolean
8
+ /**
9
+ * 当前选中的日期值
10
+ */
11
+ showMore?: boolean
12
+ /**
13
+ * 表单key
14
+ */
15
+ formKey?: string
16
+ }
17
+ export interface HolidayInfo {
18
+ bottomText?: string
19
+ date: string
20
+ floorText?: string
21
+ price: number
22
+ topText?: string
23
+ status: number
24
+ corner?: string
25
+ restFlag: boolean
26
+ }
@@ -2,7 +2,7 @@ export interface HotAddress {
2
2
  categoryName: string
3
3
  hint?: string
4
4
  tips?: string
5
- childHotAddress: ChildHotAddress[]
5
+ childAddress: ChildHotAddress[]
6
6
  }
7
7
  export interface ChildHotAddress {
8
8
  addressName: string
@@ -179,13 +179,13 @@ declare const _default: import('vue').DefineComponent<
179
179
  modelValue: unknown[]
180
180
  width: string | number
181
181
  height: string | number
182
+ showScrollbar: boolean
182
183
  columnCount: string | number
183
184
  columnGap: string | number
184
185
  idKey: string
185
186
  addTime: number
186
187
  leftGap: string | number
187
188
  rightGap: string | number
188
- showScrollbar: boolean
189
189
  },
190
190
  {}
191
191
  >
@@ -0,0 +1,5 @@
1
+ import { HolidayInfo } from '../components/lcb-calendar-filter/types'
2
+ export declare const calendarFormatter: (
3
+ holidayInfo: Record<string, HolidayInfo>,
4
+ t: (key: string) => string,
5
+ ) => (day: any) => any
@@ -0,0 +1,43 @@
1
+ import { HolidayInfo } from '../components/lcb-calendar-filter/types'
2
+ import dayjs from 'dayjs/esm'
3
+
4
+ export const calendarFormatter =
5
+ (holidayInfo: Record<string, HolidayInfo>, t: (key: string) => string) => (day: any) => {
6
+ const date = new Date(day.date)
7
+ const now = new Date()
8
+
9
+ const year = date.getFullYear()
10
+ const month = date.getMonth()
11
+ const da = date.getDate()
12
+ const nowYear = now.getFullYear()
13
+ const nowMonth = now.getMonth()
14
+ const nowDa = now.getDate()
15
+ const info = holidayInfo[dayjs(day.date).format('YYYY-MM-DD')]
16
+ if (info?.bottomText) {
17
+ day.bottomInfo = info.bottomText
18
+ }
19
+ if (year === nowYear && month === nowMonth && da === nowDa) {
20
+ day.topInfo = t('今天')
21
+ }
22
+ if (info?.floorText) {
23
+ day.floorText = info.floorText
24
+ }
25
+
26
+ if (day.type === 'start') {
27
+ day.topInfo = t('开始')
28
+ }
29
+
30
+ if (day.type === 'end') {
31
+ day.topInfo = t('结束')
32
+ }
33
+
34
+ if (day.type === 'same') {
35
+ day.bottomInfo = t('开始/结束')
36
+ }
37
+ if (info?.status !== 1) {
38
+ day.disabled = true
39
+ }
40
+ day.restFlag = info?.restFlag
41
+
42
+ return day
43
+ }