@uxda/appkit 4.1.25 → 4.1.28

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