@uxda/appkit 4.1.16 → 4.1.19

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.
Files changed (116) hide show
  1. package/.eslintrc.mjs +7 -7
  2. package/README.md +187 -187
  3. package/babel.config.js +12 -12
  4. package/dist/appkit.css +25 -22
  5. package/dist/assets/asset-3B_CoPto +1 -0
  6. package/dist/index.js +1141 -1036
  7. package/package.json +77 -75
  8. package/project.config.json +15 -15
  9. package/project.tt.json +13 -13
  10. package/rollup.config.mjs +56 -56
  11. package/src/Appkit.ts +72 -65
  12. package/src/balance/api/endpoints.ts +126 -126
  13. package/src/balance/api/index.ts +82 -82
  14. package/src/balance/components/AccountView.vue +748 -748
  15. package/src/balance/components/BalanceCard.vue +205 -205
  16. package/src/balance/components/BalanceReminder.vue +85 -85
  17. package/src/balance/components/ConsumptionFilter.vue +218 -218
  18. package/src/balance/components/ConsumptionRules.vue +68 -68
  19. package/src/balance/components/DateFilter.vue +249 -227
  20. package/src/balance/components/DateRange.vue +80 -77
  21. package/src/balance/components/ListFilter.vue +63 -63
  22. package/src/balance/components/ListFilterPicker.vue +186 -186
  23. package/src/balance/components/SecondBalance.vue +71 -71
  24. package/src/balance/components/Tip.vue +45 -45
  25. package/src/balance/components/index.ts +13 -13
  26. package/src/balance/types.ts +91 -91
  27. package/src/components/bt-cropper/index.vue +774 -774
  28. package/src/components/bt-cropper/utils/calcCropper.js +42 -42
  29. package/src/components/bt-cropper/utils/calcImagePosition.js +23 -23
  30. package/src/components/bt-cropper/utils/calcImageSize.js +37 -37
  31. package/src/components/bt-cropper/utils/calcPointDistance.js +12 -12
  32. package/src/components/bt-cropper/utils/calcRightAndBottom.js +7 -7
  33. package/src/components/bt-cropper/utils/ratio.js +3 -3
  34. package/src/components/bt-cropper/utils/tools.js +25 -25
  35. package/src/components/dd-area/index.vue +225 -225
  36. package/src/components/dd-icon/doc.md +21 -21
  37. package/src/components/dd-icon/index.vue +23 -23
  38. package/src/components/dd-notice-bar/index.vue +78 -78
  39. package/src/components/dd-search/doc.md +34 -34
  40. package/src/components/dd-search/index.vue +168 -168
  41. package/src/components/dd-selector/index.vue +124 -124
  42. package/src/components/dd-skeleton/doc.md +19 -19
  43. package/src/components/dd-skeleton/index.vue +36 -36
  44. package/src/components/ocr-id/index.vue +114 -114
  45. package/src/components/ocr-id/types.d.ts +12 -12
  46. package/src/global.ts +6 -6
  47. package/src/index.ts +93 -89
  48. package/src/main.scss +1 -1
  49. package/src/notice/api/endpoints.ts +17 -17
  50. package/src/notice/api/index.ts +82 -82
  51. package/src/notice/components/NoticeBanner.vue +243 -243
  52. package/src/notice/components/NoticeEntry.vue +99 -99
  53. package/src/notice/components/NoticeList.vue +315 -315
  54. package/src/notice/components/NoticePopup.vue +162 -162
  55. package/src/notice/components/index.ts +5 -5
  56. package/src/notice/components/useCommonList.ts +86 -86
  57. package/src/notice/components/useNotice.ts +35 -35
  58. package/src/notice/index.ts +1 -1
  59. package/src/notice/types.ts +25 -25
  60. package/src/payment/api/config.ts +7 -7
  61. package/src/payment/api/endpoints.ts +103 -103
  62. package/src/payment/api/index.ts +76 -71
  63. package/src/payment/components/AmountPicker.vue +93 -93
  64. package/src/payment/components/RechargeResult.vue +69 -69
  65. package/src/payment/components/RechargeView.vue +154 -151
  66. package/src/payment/components/RightsPicker.vue +105 -105
  67. package/src/payment/components/TradeView.vue +294 -294
  68. package/src/payment/components/UserAgreement.vue +234 -234
  69. package/src/payment/components/index.ts +22 -22
  70. package/src/payment/index.ts +5 -5
  71. package/src/payment/services/index.ts +16 -16
  72. package/src/payment/services/invoke-recharge.ts +25 -25
  73. package/src/payment/services/request-payment.ts +58 -58
  74. package/src/payment/types.ts +28 -28
  75. package/src/register/components/SelfRegistration.vue +254 -254
  76. package/src/register/components/index.ts +2 -2
  77. package/src/shared/components/AppDrawer.vue +58 -58
  78. package/src/shared/components/AppVerify.vue +129 -129
  79. package/src/shared/components/DeviceVersion.vue +68 -68
  80. package/src/shared/components/EmptyView.vue +33 -33
  81. package/src/shared/components/OcrBusinessLicense.vue +133 -130
  82. package/src/shared/components/OcrIcon.vue +133 -132
  83. package/src/shared/components/PageHeader.vue +79 -79
  84. package/src/shared/components/index.ts +8 -8
  85. package/src/shared/composables/index.ts +7 -7
  86. package/src/shared/composables/useCountdown.ts +46 -46
  87. package/src/shared/composables/useCrypto.ts +76 -76
  88. package/src/shared/composables/useDragBox.ts +97 -97
  89. package/src/shared/composables/useEncode.ts +43 -43
  90. package/src/shared/composables/useSafeArea.ts +46 -46
  91. package/src/shared/composables/useTabbar.ts +24 -24
  92. package/src/shared/composables/useUpload.ts +54 -54
  93. package/src/shared/composables/useValidator.ts +31 -31
  94. package/src/shared/http/Http.ts +136 -136
  95. package/src/shared/http/index.ts +1 -1
  96. package/src/shared/http/types.ts +157 -157
  97. package/src/shared/index.ts +3 -3
  98. package/src/shared/weixin/payment.ts +38 -38
  99. package/src/styles/fonts.scss +2 -2
  100. package/src/styles/vars.scss +3 -3
  101. package/src/user/api/endpoints.ts +17 -17
  102. package/src/user/api/index.ts +87 -87
  103. package/src/user/components/LoginSetting.vue +114 -114
  104. package/src/user/components/UserBinding.vue +307 -307
  105. package/src/user/components/UserBindingSuccess.vue +80 -80
  106. package/src/user/components/UserEntry.vue +137 -137
  107. package/src/user/components/UserFeedback.vue +431 -431
  108. package/src/user/components/UserFeedbackEntry.vue +192 -192
  109. package/src/user/components/UserHeadCrop.vue +65 -65
  110. package/src/user/components/UserInfo.vue +637 -637
  111. package/src/user/components/UserResourceEmpty.vue +75 -75
  112. package/src/user/components/index.ts +21 -21
  113. package/src/user/index.ts +1 -1
  114. package/tsconfig.json +30 -30
  115. package/types/global.d.ts +21 -21
  116. package/types/vue.d.ts +10 -10
@@ -1,227 +1,249 @@
1
- <template>
2
- <div class="consumption-date-filter">
3
- <div class="date-filter-header">日期选择</div>
4
- <div class="content">
5
- <div class="title">自定义</div>
6
- <div class="time">
7
- <div
8
- class="item"
9
- :class="focused === 'from' ? 'current' : ''"
10
- @click="switchDateInput('from')"
11
- >
12
- {{ formatDate(result.from) }}
13
- </div>
14
- <div class="line">-</div>
15
- <div class="item" :class="focused === 'to' ? 'current' : ''" @click="switchDateInput('to')">
16
- {{ formatDate(result.to) }}
17
- </div>
18
- </div>
19
- </div>
20
- <div class="buttons spa-between">
21
- <div class="btn" @click="reset">重置</div>
22
- <div class="btn confirm" @click="onOkClick">确定</div>
23
- </div>
24
- <div class="bottom"></div>
25
- <nut-popup v-model:visible="datePickerOpen" position="bottom">
26
- <nut-date-picker
27
- v-model="focusedDate"
28
- :min-date="minDate"
29
- :max-date="maxDate"
30
- :is-show-chinese="false"
31
- :three-dimensional="false"
32
- @cancel="datePickerOpen = false"
33
- @confirm="onDatePickerComplete"
34
- ></nut-date-picker>
35
- </nut-popup>
36
- </div>
37
- </template>
38
-
39
- <script lang="ts" setup>
40
- import { reactive, ref, watch } from 'vue'
41
-
42
- type DateFilterProps = {
43
- from: string
44
- to: string
45
- }
46
-
47
- const props = defineProps<DateFilterProps>()
48
-
49
- const emit = defineEmits(['complete', 'reset'])
50
-
51
- watch(
52
- () => `${props.from}${props.to}`,
53
- () => {
54
- result.from = props.from
55
- result.to = props.to
56
- }
57
- )
58
-
59
- /**
60
- * 日期范围结果
61
- */
62
- const result = reactive<DateFilterProps>({ ...props })
63
-
64
- /**
65
- * 目前激活的日期输入框
66
- */
67
- const focused = ref<string>('from')
68
- const focusedDate = ref<any>(props.from)
69
-
70
- const minDate = ref<any>()
71
- const maxDate = ref<Date>(new Date())
72
- const datePickerOpen = ref<boolean>(false)
73
-
74
- /**
75
- * 日期重置
76
- */
77
- function reset() {
78
- emit('reset')
79
- }
80
-
81
- /**
82
- * 确认,提交新时间
83
- */
84
- function onOkClick() {
85
- emit('complete', result)
86
- }
87
-
88
- function formatDate(date: string) {
89
- const [year, month, day] = date.split('-')
90
- return year + '年' + month + '月' + day + '日'
91
- }
92
-
93
- function onDatePickerComplete({ selectedValue, selectedOptions }) {
94
- let time = selectedOptions.map((val: any) => val.text).join('-')
95
- if (focused.value === 'from') {
96
- // 如果选择的时间比结束时间大,结束时间改为开始时间
97
- result.from = new Date(time) > new Date(result.to) ? result.to : time
98
- } else {
99
- result.to = time
100
- }
101
- datePickerOpen.value = false
102
- }
103
-
104
- /**
105
- * 切换时间逻辑:初始化时有时间,默认聚焦开始时间
106
- * 当选择开始时间大于结束时间,结束时间改为开始时间
107
- * 时间选择器都要小于当前时间,结束时间的时间选择器要以开始时间为最小值,
108
- */
109
- function switchDateInput(shift: string) {
110
- // 要设置一下结束时间的起始值 开始时间往前倒5年
111
- if (shift === 'from') {
112
- let time = result.from.split('-').map(Number)
113
- minDate.value = new Date(time[0] - 5, 1, 1)
114
- } else {
115
- let time = result.from.split('-').map(Number)
116
- minDate.value = new Date(time[0], time[1] - 1, time[2])
117
- }
118
- focusedDate.value = new Date(result[shift])
119
- focused.value = shift
120
- datePickerOpen.value = true
121
- }
122
- </script>
123
- <style lang="scss">
124
- .consumption-date-filter {
125
- height: 100%;
126
- display: flex;
127
- flex-direction: column;
128
- width: 100%;
129
- position: relative;
130
- .date-filter-header {
131
- text-align: center;
132
- height: 44px;
133
- line-height: 44px;
134
- color: #353535;
135
- font-size: 17px;
136
- background-color: #f5f5f5;
137
- }
138
- .content {
139
- flex: 1;
140
- margin: 15px;
141
- overflow-y: scroll;
142
- color: #353535;
143
- font-size: 13px;
144
- .title {
145
- opacity: 0.6;
146
- line-height: 18px;
147
- }
148
- .info {
149
- display: grid;
150
- grid-template-columns: 1fr 1fr 1fr;
151
- grid-gap: 10px;
152
- margin: 10px 0;
153
- .item {
154
- height: 30px;
155
- line-height: 30px;
156
- border: 1px solid #ccc;
157
- border-radius: 6px;
158
- text-align: center;
159
- }
160
- .current {
161
- border: 1px solid;
162
- border-image-source: linear-gradient(
163
- 180deg,
164
- rgba(239, 208, 130, 0.8) 0%,
165
- rgba(255, 185, 120, 0.8) 100%
166
- );
167
- background: linear-gradient(
168
- 180deg,
169
- rgba(239, 208, 130, 0.8) 0%,
170
- rgba(255, 185, 120, 0.8) 100%
171
- ),
172
- linear-gradient(180deg, #fff7e3 0%, #fefde6 100%);
173
- }
174
- }
175
- }
176
- .buttons {
177
- margin: 0 15px;
178
- display: flex;
179
- justify-content: space-between;
180
- align-items: center;
181
- .btn {
182
- flex: 1;
183
- height: 40px;
184
- line-height: 40px;
185
- text-align: center;
186
- border: 1px solid #ccc;
187
- box-sizing: border-box;
188
- color: #666;
189
- font-size: 16px;
190
- border-radius: 6px;
191
- }
192
- .confirm {
193
- margin-left: 11px;
194
- color: #000;
195
- border: none;
196
- background: linear-gradient(90deg, #ffebc1 0%, #ffd7a7 52.29%, #ffb875 100%);
197
- }
198
- }
199
- .time {
200
- display: flex;
201
- justify-content: flex-start;
202
- align-items: center;
203
- margin: 10px 0 30px 0;
204
- .line {
205
- margin: 0 8px;
206
- }
207
- .item {
208
- height: 30px;
209
- line-height: 30px;
210
- padding: 0 15px;
211
- font-size: 13px;
212
- color: #353535;
213
- border: 1px solid transparent;
214
- box-sizing: border-box;
215
- background: rgba(#f5f5f5, 0.8);
216
- border-radius: 6px;
217
- }
218
- .current {
219
- border: 1px solid #353535;
220
- }
221
- }
222
- .bottom {
223
- height: 32px;
224
- background: #fff;
225
- }
226
- }
227
- </style>
1
+ <template>
2
+ <div class="appkit-date-filter">
3
+ <div class="date-filter-header">日期选择</div>
4
+ <div class="content">
5
+ <div class="title">自定义</div>
6
+ <div class="time">
7
+ <div
8
+ class="item"
9
+ :class="focused === 'from' ? 'current' : ''"
10
+ @click="switchDateInput('from')"
11
+ >
12
+ {{ formatDate(result.from) }}
13
+ </div>
14
+ <div class="line">-</div>
15
+ <div class="item" :class="focused === 'to' ? 'current' : ''" @click="switchDateInput('to')">
16
+ {{ formatDate(result.to) }}
17
+ </div>
18
+ </div>
19
+ </div>
20
+ <div class="buttons spa-between">
21
+ <div class="btn" @click="reset">重置</div>
22
+ <div class="btn confirm" @click="onOkClick">确定</div>
23
+ </div>
24
+ <div class="bottom"></div>
25
+ <nut-popup v-model:visible="datePickerOpen"
26
+ class="appkit-date-filter-picker-popup"
27
+ position="bottom"
28
+ overlay-class="appkit-date-filter-picker-overlay">
29
+ <nut-date-picker
30
+ v-model="focusedDate"
31
+ :min-date="minDate"
32
+ :max-date="maxDate"
33
+ :is-show-chinese="false"
34
+ :three-dimensional="false"
35
+ @cancel="onDatePickerCancel"
36
+ @confirm="onDatePickerComplete" />
37
+ </nut-popup>
38
+ </div>
39
+ </template>
40
+
41
+ <script lang="ts" setup>
42
+ import { reactive, ref, watch } from 'vue'
43
+ import { usePopup } from '@uxda/nutshell/taro'
44
+
45
+ type DateFilterProps = {
46
+ from: string
47
+ to: string
48
+ }
49
+
50
+ const props = defineProps<DateFilterProps>()
51
+
52
+ const emit = defineEmits(['complete', 'reset']),
53
+ state = usePopup()
54
+
55
+ watch(
56
+ () => `${props.from}${props.to}`,
57
+ () => {
58
+ result.from = props.from
59
+ result.to = props.to
60
+ }
61
+ )
62
+
63
+ /**
64
+ * 日期范围结果
65
+ */
66
+ const result = reactive<DateFilterProps>({ ...props })
67
+
68
+ /**
69
+ * 目前激活的日期输入框
70
+ */
71
+ const focused = ref<string>('from')
72
+ const focusedDate = ref<any>(props.from)
73
+
74
+ const minDate = ref<any>()
75
+ const maxDate = ref<Date>(new Date())
76
+ const datePickerOpen = ref<boolean>(false)
77
+
78
+ state.beforeClose = () => {
79
+ datePickerOpen.value = false
80
+ return true
81
+ }
82
+
83
+ /**
84
+ * 日期重置
85
+ */
86
+ function reset() {
87
+ emit('reset')
88
+ }
89
+
90
+ /**
91
+ * 确认,提交新时间
92
+ */
93
+ function onOkClick() {
94
+ emit('complete', result)
95
+ }
96
+
97
+ function formatDate(date: string) {
98
+ const [year, month, day] = date.split('-')
99
+ return year + '年' + month + '月' + day + '日'
100
+ }
101
+
102
+ function onDatePickerComplete({ selectedValue, selectedOptions }) {
103
+ let time = selectedOptions.map((val: any) => val.text).join('-')
104
+ if (focused.value === 'from') {
105
+ // 如果选择的时间比结束时间大,结束时间改为开始时间
106
+ result.from = new Date(time) > new Date(result.to) ? result.to : time
107
+ } else {
108
+ result.to = time
109
+ }
110
+ datePickerOpen.value = false
111
+ state.couldClose = true
112
+ }
113
+
114
+ function onDatePickerCancel () {
115
+ datePickerOpen.value = false
116
+ state.couldClose = true
117
+ }
118
+
119
+ /**
120
+ * 切换时间逻辑:初始化时有时间,默认聚焦开始时间
121
+ * 当选择开始时间大于结束时间,结束时间改为开始时间
122
+ * 时间选择器都要小于当前时间,结束时间的时间选择器要以开始时间为最小值,
123
+ */
124
+ function switchDateInput (shift: string) {
125
+ // 要设置一下结束时间的起始值 开始时间往前倒5年
126
+ if (shift === 'from') {
127
+ let time = result.from.split('-').map(Number)
128
+ minDate.value = new Date(time[0] - 5, 1, 1)
129
+ } else {
130
+ let time = result.from.split('-').map(Number)
131
+ minDate.value = new Date(time[0], time[1] - 1, time[2])
132
+ }
133
+ focusedDate.value = new Date(result[shift])
134
+ focused.value = shift
135
+ datePickerOpen.value = true
136
+ // 不允许浮窗关闭
137
+ state.couldClose = false
138
+ }
139
+ </script>
140
+ <style lang="scss">
141
+ .appkit-date-filter {
142
+ height: 100%;
143
+ display: flex;
144
+ flex-direction: column;
145
+ width: 100%;
146
+ position: relative;
147
+ .date-filter-header {
148
+ text-align: center;
149
+ height: 44px;
150
+ line-height: 44px;
151
+ color: #353535;
152
+ font-size: 17px;
153
+ background-color: #f5f5f5;
154
+ }
155
+ .content {
156
+ flex: 1;
157
+ margin: 15px;
158
+ overflow-y: scroll;
159
+ color: #353535;
160
+ font-size: 13px;
161
+ .title {
162
+ opacity: 0.6;
163
+ line-height: 18px;
164
+ }
165
+ .info {
166
+ display: grid;
167
+ grid-template-columns: 1fr 1fr 1fr;
168
+ grid-gap: 10px;
169
+ margin: 10px 0;
170
+ .item {
171
+ height: 30px;
172
+ line-height: 30px;
173
+ border: 1px solid #ccc;
174
+ border-radius: 6px;
175
+ text-align: center;
176
+ }
177
+ .current {
178
+ border: 1px solid;
179
+ border-image-source: linear-gradient(
180
+ 180deg,
181
+ rgba(239, 208, 130, 0.8) 0%,
182
+ rgba(255, 185, 120, 0.8) 100%
183
+ );
184
+ background: linear-gradient(
185
+ 180deg,
186
+ rgba(239, 208, 130, 0.8) 0%,
187
+ rgba(255, 185, 120, 0.8) 100%
188
+ ),
189
+ linear-gradient(180deg, #fff7e3 0%, #fefde6 100%);
190
+ }
191
+ }
192
+ }
193
+ .buttons {
194
+ margin: 32px 15px 0 15px;
195
+ display: flex;
196
+ justify-content: space-between;
197
+ align-items: center;
198
+ .btn {
199
+ flex: 1;
200
+ height: 40px;
201
+ line-height: 40px;
202
+ text-align: center;
203
+ border: 1px solid #ccc;
204
+ box-sizing: border-box;
205
+ color: #666;
206
+ font-size: 16px;
207
+ border-radius: 6px;
208
+ }
209
+ .confirm {
210
+ margin-left: 11px;
211
+ color: #000;
212
+ border: none;
213
+ background: linear-gradient(90deg, #ffebc1 0%, #ffd7a7 52.29%, #ffb875 100%);
214
+ }
215
+ }
216
+ .time {
217
+ display: flex;
218
+ justify-content: flex-start;
219
+ align-items: center;
220
+ margin: 10px 0 30px 0;
221
+ .line {
222
+ margin: 0 8px;
223
+ }
224
+ .item {
225
+ height: 30px;
226
+ line-height: 30px;
227
+ padding: 0 15px;
228
+ font-size: 13px;
229
+ color: #353535;
230
+ border: 1px solid transparent;
231
+ box-sizing: border-box;
232
+ background: rgba(#f5f5f5, 0.8);
233
+ border-radius: 6px;
234
+ }
235
+ .current {
236
+ border: 1px solid #353535;
237
+ }
238
+ }
239
+ .bottom {
240
+ height: 32px;
241
+ background: #fff;
242
+ }
243
+ }
244
+ .nut-overlay {
245
+ &.date-filter-picker-overlay {
246
+ height: 100vh;
247
+ }
248
+ }
249
+ </style>
@@ -1,78 +1,81 @@
1
- <template>
2
- <div class="date-range" @click="openDateRangePicker">
3
- <div class="text">{{ dateRangeDisplay }}</div>
4
- <img
5
- style="margin-top: -2px"
6
- class="time-icon"
7
- src="https://cdn.ddjf.com/static/images/bpms-workBench/clound-bean-down.png"
8
- />
9
- </div>
10
- </template>
11
-
12
- <script lang="ts" setup>
13
- import { computed, PropType, reactive } from 'vue'
14
- import { useNutshell } from '@uxda/nutshell/taro'
15
- import DateFilter from './DateFilter.vue'
16
- import dayjs from 'dayjs'
17
-
18
- const $n = useNutshell()
19
-
20
- export type DateRangeModel = {
21
- from: string,
22
- to: string
23
- }
24
-
25
- const model = defineModel({
26
- type: Object as PropType<DateRangeModel>,
27
- required: false,
28
- default: {
29
- from: dayjs().add(-1, 'M').format('YYYY-MM-DD'),
30
- to: dayjs().format('YYYY-MM-DD')
31
- }
32
- })
33
-
34
- const openDateRangePicker = () => {
35
- $n.sheet({
36
- component: DateFilter,
37
- props: {
38
- from: model.value.from,
39
- to: model.value.to,
40
- },
41
- onComplete (result: any) {
42
- console.log('===openDateFilter complete', result)
43
- model.value = {
44
- from: result.from,
45
- to: result.to
46
- }
47
- }
48
- })
49
- }
50
-
51
- const dateRangeDisplay = computed(() => {
52
- let startTime = (model.value.from || '').replace(/-/g, '.').substring(2)
53
- let endTime = (model.value.to || '').replace(/-/g, '.').substring(2)
54
- return startTime + '-' + endTime
55
- })
56
-
57
- </script>
58
-
59
- <style lang="scss">
60
- .date-range {
61
- height: 22px;
62
- padding-right: 5px;
63
- flex: 1;
64
- display: flex;
65
- align-items: center;
66
- .text {
67
- width: fit-content;
68
- white-space: nowrap;
69
- }
70
- .time-icon {
71
- display: block;
72
- font-size: 0;
73
- width: 12px;
74
- height: 12px;
75
- margin-left: 4px;
76
- }
77
- }
1
+ <template>
2
+ <div class="date-range" @click="openDateRangePicker">
3
+ <div class="text">{{ dateRangeDisplay }}</div>
4
+ <img
5
+ style="margin-top: -2px"
6
+ class="time-icon"
7
+ src="https://cdn.ddjf.com/static/images/bpms-workBench/clound-bean-down.png"
8
+ />
9
+ </div>
10
+ </template>
11
+
12
+ <script lang="ts" setup>
13
+ import { computed, PropType, ref } from 'vue'
14
+ import { useNutshell } from '@uxda/nutshell/taro'
15
+ import DateFilter from './DateFilter.vue'
16
+ import dayjs from 'dayjs'
17
+
18
+ const $n = useNutshell()
19
+
20
+ export type DateRangeModel = {
21
+ from: string,
22
+ to: string
23
+ }
24
+
25
+ const model = defineModel({
26
+ type: Object as PropType<DateRangeModel>,
27
+ required: false,
28
+ default: {
29
+ from: dayjs().add(-1, 'M').format('YYYY-MM-DD'),
30
+ to: dayjs().format('YYYY-MM-DD')
31
+ }
32
+ })
33
+
34
+ const openDateRangePicker = () => {
35
+ const child = ref()
36
+ $n.sheet({
37
+ component: DateFilter,
38
+ ref: child,
39
+ props: {
40
+ from: model.value.from,
41
+ to: model.value.to,
42
+ },
43
+ modal: true, // 不允许点击 overlay 关闭弹窗
44
+ mask: true,
45
+ onComplete (result: any) {
46
+ model.value = {
47
+ from: result.from,
48
+ to: result.to
49
+ }
50
+ }
51
+ })
52
+ }
53
+
54
+ const dateRangeDisplay = computed(() => {
55
+ let startTime = (model.value.from || '').replace(/-/g, '.').substring(2)
56
+ let endTime = (model.value.to || '').replace(/-/g, '.').substring(2)
57
+ return startTime + '-' + endTime
58
+ })
59
+
60
+ </script>
61
+
62
+ <style lang="scss">
63
+ .date-range {
64
+ height: 22px;
65
+ padding-right: 5px;
66
+ flex: 1;
67
+ display: flex;
68
+ align-items: center;
69
+ .text {
70
+ width: fit-content;
71
+ white-space: nowrap;
72
+ }
73
+ .time-icon {
74
+ display: block;
75
+ font-size: 0;
76
+ width: 12px;
77
+ height: 12px;
78
+ margin-left: 4px;
79
+ }
80
+ }
78
81
  </style>