verce-vue-test 0.0.96 → 0.0.98

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/env.d.ts CHANGED
@@ -16,13 +16,15 @@ declare global {
16
16
 
17
17
  declare module 'vue' {
18
18
  export interface GlobalComponents {
19
+ DateRange: typeof import('./src/components/element-rewrite/DateRange.vue')['default']
19
20
  ElButtonPro: typeof import('./src/components/element-rewrite/ElButtonPro.vue')['default']
20
21
  ElFormDialog: typeof import('./src/components/element-rewrite/ElFormDialog.vue')['default']
21
22
  ElInputThousandth: typeof import('./src/components/element-rewrite/ElInputThousandth.vue')['default']
22
23
  ElTablePro: typeof import('./src/components/element-rewrite/ElTablePro.vue')['default']
23
24
  ElUploadButton: typeof import('./src/components/element-rewrite/ElUploadButton.vue')['default']
24
25
  LoginSuccessNotification: typeof import('./src/components/LoginSuccessNotification.vue')['default']
25
- NumberRange: typeof import('./src/components/NumberRange.vue')['default']
26
+ NumberRange: typeof import('./src/components/element-rewrite/NumberRange.vue')['default']
27
+ TokenTag: typeof import('./src/components/business/Public/TokenTag.vue')['default']
26
28
  WebsiteNoticeTitle: typeof import('./src/components/WebsiteNoticeTitle.vue')['default']
27
29
  IconCommunity: typeof import('./src/components/icons/IconCommunity.vue')['default']
28
30
  IconDocumentation: typeof import('./src/components/icons/IconDocumentation.vue')['default']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.96",
3
+ "version": "0.0.98",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,12 +13,17 @@
13
13
  </span>
14
14
  </template>
15
15
 
16
- <script setup name="TokenTag">
16
+ <script setup lang="ts" name="TokenTag">
17
17
  import { computed } from "vue"
18
18
 
19
19
  const DEFAULT_COLOR = "#667085"
20
20
 
21
- const currencyMap = {
21
+ type CurrencyDefinition = {
22
+ name: string
23
+ color: string
24
+ }
25
+
26
+ const currencyMap: Record<string, CurrencyDefinition> = {
22
27
  CNY: { name: "人民币", color: "#C7372F" },
23
28
  USD: { name: "美元", color: "#277A53" },
24
29
  HKD: { name: "港元", color: "#9F2147" },
@@ -36,17 +41,16 @@ const currencyMap = {
36
41
  KZT: { name: "哈萨克斯坦坚戈", color: "#0095C8" }
37
42
  }
38
43
 
39
- const props = defineProps({
40
- value: {
41
- type: [String, Number],
42
- required: true
43
- },
44
- // 紧凑模式下只展示币种代码,适合空间有限的表格列。
45
- compact: {
46
- type: Boolean,
47
- default: false
44
+ const props = withDefaults(
45
+ defineProps<{
46
+ value: string | number
47
+ /** 紧凑模式下只展示币种代码,适合空间有限的表格列。 */
48
+ compact?: boolean
49
+ }>(),
50
+ {
51
+ compact: false
48
52
  }
49
- })
53
+ )
50
54
 
51
55
  const currencyCode = computed(() => String(props.value ?? "").trim().toUpperCase())
52
56
  const currency = computed(() => currencyMap[currencyCode.value])
@@ -0,0 +1,368 @@
1
+ <template>
2
+ <div class="date-range" :class="{ 'is-disabled': disabled }">
3
+ <div class="date-range__row">
4
+ <el-date-picker
5
+ v-model="startVal"
6
+ class="date-range__picker"
7
+ :class="{ 'is-error': showError }"
8
+ :type="pickerType"
9
+ :placeholder="startPlaceholder"
10
+ :disabled="disabled"
11
+ :disabled-date="disabledStartDate"
12
+ :value-format="valueFormat"
13
+ :format="displayFormat"
14
+ clearable
15
+ @change="onStartChange"
16
+ @focus="onStartFocus"
17
+ @blur="onStartBlur"
18
+ />
19
+ <span class="date-range__separator">{{ separator }}</span>
20
+ <el-date-picker
21
+ v-model="endVal"
22
+ class="date-range__picker"
23
+ :class="{ 'is-error': showError }"
24
+ :type="pickerType"
25
+ :placeholder="endPlaceholder"
26
+ :disabled="disabled"
27
+ :disabled-date="disabledEndDate"
28
+ :value-format="valueFormat"
29
+ :format="displayFormat"
30
+ clearable
31
+ @change="onEndChange"
32
+ @focus="onEndFocus"
33
+ @blur="onEndBlur"
34
+ />
35
+ </div>
36
+ <span v-if="showError" class="date-range__error">
37
+ {{ activeErrorMessage }}
38
+ </span>
39
+ </div>
40
+ </template>
41
+
42
+ <script setup lang="ts" name="DateRange">
43
+ import { computed, ref, watch } from "vue"
44
+
45
+ export type DateRangeValue = [string | null, string | null]
46
+
47
+ /**
48
+ * 父级 v-model:约定前两格为 [start, end]。
49
+ * 使用 ReadonlyArray 以兼容表单里的 `string[]`、空数组等(避免 `DateRangeValue | []` 与 `string[]` 不兼容)。
50
+ */
51
+ export type DateRangeModelProp = ReadonlyArray<string | null>
52
+
53
+ export type MaxSpanDaysInput = number | [number]
54
+
55
+ function resolveMaxSpanDays(v: MaxSpanDaysInput | undefined): number | null {
56
+ if (v === undefined) return null
57
+ const n = Array.isArray(v) ? v[0] : v
58
+ if (typeof n !== "number" || !Number.isFinite(n) || n <= 0) return null
59
+ return Math.floor(n)
60
+ }
61
+
62
+ function startOfLocalDay(d: Date): Date {
63
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate())
64
+ }
65
+
66
+ /** 按自然日计:end 在 start 当天为 0,隔天为 1 … */
67
+ function calendarDayDiff(start: Date, end: Date): number {
68
+ const s = startOfLocalDay(start).getTime()
69
+ const e = startOfLocalDay(end).getTime()
70
+ return Math.round((e - s) / 86400000)
71
+ }
72
+
73
+ /** 含首尾的自然日个数,如 1 月 1 日~1 月 15 日为 15 */
74
+ function inclusiveDaySpan(start: Date, end: Date): number {
75
+ return calendarDayDiff(start, end) + 1
76
+ }
77
+
78
+ const props = withDefaults(
79
+ defineProps<{
80
+ /** 数组模式绑定值 [start, end];亦可能为空数组 */
81
+ modelValue?: DateRangeModelProp
82
+ /** 双字段模式 - 起始日期 */
83
+ start?: string | null
84
+ /** 双字段模式 - 结束日期 */
85
+ end?: string | null
86
+ startPlaceholder?: string
87
+ endPlaceholder?: string
88
+ separator?: string
89
+ /** date-picker 的 type,如 date / datetime / month / year */
90
+ pickerType?: "date" | "datetime" | "month" | "year"
91
+ /** 传给 el-date-picker 的 value-format */
92
+ valueFormat?: string
93
+ /** 传给 el-date-picker 的 format(显示格式) */
94
+ displayFormat?: string
95
+ disabled?: boolean
96
+ /** 是否限制结束日期不能早于开始日期(禁用不合法的日期) */
97
+ linkage?: boolean
98
+ /**
99
+ * 最长区间(自然日,含起止当天)。可传数字如 15,或单元素数组 [15]。
100
+ * 仅对 pickerType 为 date / datetime 生效。
101
+ */
102
+ maxSpanDays?: MaxSpanDaysInput
103
+ errorMessage?: string
104
+ /** 超出 maxSpanDays 时的提示(默认带天数) */
105
+ maxSpanErrorMessage?: string
106
+ }>(),
107
+ {
108
+ modelValue: undefined,
109
+ start: undefined,
110
+ end: undefined,
111
+ startPlaceholder: "开始日期",
112
+ endPlaceholder: "结束日期",
113
+ separator: "至",
114
+ pickerType: "date",
115
+ valueFormat: "YYYYMMDD",
116
+ displayFormat: "YYYY-MM-DD",
117
+ disabled: false,
118
+ linkage: true,
119
+ maxSpanDays: undefined,
120
+ errorMessage: "结束日期不能早于开始日期",
121
+ maxSpanErrorMessage: undefined
122
+ }
123
+ )
124
+
125
+ /** 使用 call-signature 形式,避免部分 vue-tsc 版本对对象形式 emits 推断成单事件而报 TS2769 */
126
+ const emit = defineEmits<{
127
+ (e: "update:modelValue", value: DateRangeValue): void
128
+ (e: "update:start", value: string | null): void
129
+ (e: "update:end", value: string | null): void
130
+ (e: "validate", valid: boolean): void
131
+ }>()
132
+
133
+ const isArrayMode = computed(() => props.modelValue !== undefined)
134
+
135
+ const startVal = ref<any>(null)
136
+ const endVal = ref<any>(null)
137
+
138
+ const startFocused = ref(false)
139
+ const endFocused = ref(false)
140
+ const hasBlurred = ref(false)
141
+
142
+ /** 解析绑定值:支持 YYYYMMDD(与默认 valueFormat 一致)及 ISO 等可被 Date 解析的字符串 */
143
+ function toDate(val: any): Date | null {
144
+ if (!val) return null
145
+ if (/^\d{8}$/.test(val)) {
146
+ const y = Number(val.slice(0, 4))
147
+ const m = Number(val.slice(4, 6)) - 1
148
+ const day = Number(val.slice(6, 8))
149
+ const d = new Date(y, m, day)
150
+ return Number.isNaN(d.getTime()) ? null : d
151
+ }
152
+ const d = new Date(val)
153
+ return Number.isNaN(d.getTime()) ? null : d
154
+ }
155
+
156
+ const effectiveMaxSpan = computed(() => resolveMaxSpanDays(props.maxSpanDays))
157
+
158
+ const spanConstraintApplies = computed(
159
+ () =>
160
+ effectiveMaxSpan.value !== null &&
161
+ (props.pickerType === "date" || props.pickerType === "datetime")
162
+ )
163
+
164
+ const orderInvalid = computed(() => {
165
+ const s = toDate(startVal.value)
166
+ const e = toDate(endVal.value)
167
+ return s !== null && e !== null && e < s
168
+ })
169
+
170
+ const spanInvalid = computed(() => {
171
+ if (!spanConstraintApplies.value || effectiveMaxSpan.value === null)
172
+ return false
173
+ const s = toDate(startVal.value)
174
+ const e = toDate(endVal.value)
175
+ if (s === null || e === null || e < s) return false
176
+ return inclusiveDaySpan(s, e) > effectiveMaxSpan.value
177
+ })
178
+
179
+ const rangeInvalid = computed(() => orderInvalid.value || spanInvalid.value)
180
+
181
+ const showError = computed(
182
+ () =>
183
+ hasBlurred.value &&
184
+ !startFocused.value &&
185
+ !endFocused.value &&
186
+ rangeInvalid.value
187
+ )
188
+
189
+ const activeErrorMessage = computed(() => {
190
+ if (!showError.value) return ""
191
+ if (orderInvalid.value) return props.errorMessage
192
+ if (spanInvalid.value && effectiveMaxSpan.value !== null) {
193
+ return (
194
+ props.maxSpanErrorMessage ??
195
+ `日期区间最长为 ${effectiveMaxSpan.value} 天(含起止当天)`
196
+ )
197
+ }
198
+ return props.errorMessage
199
+ })
200
+
201
+ const disabledStartDate = (date: Date): boolean => {
202
+ if (props.linkage && endVal.value) {
203
+ const e = toDate(endVal.value)
204
+ if (e !== null && date.getTime() > e.getTime()) return true
205
+ }
206
+ if (
207
+ spanConstraintApplies.value &&
208
+ effectiveMaxSpan.value !== null &&
209
+ endVal.value
210
+ ) {
211
+ const e = toDate(endVal.value)
212
+ if (e !== null) {
213
+ const maxDiff = effectiveMaxSpan.value - 1
214
+ if (calendarDayDiff(date, e) > maxDiff) return true
215
+ }
216
+ }
217
+ return false
218
+ }
219
+
220
+ const disabledEndDate = (date: Date): boolean => {
221
+ if (props.linkage && startVal.value) {
222
+ const s = toDate(startVal.value)
223
+ if (s !== null && date.getTime() < s.getTime()) return true
224
+ }
225
+ if (
226
+ spanConstraintApplies.value &&
227
+ effectiveMaxSpan.value !== null &&
228
+ startVal.value
229
+ ) {
230
+ const s = toDate(startVal.value)
231
+ if (s !== null) {
232
+ const maxDiff = effectiveMaxSpan.value - 1
233
+ if (calendarDayDiff(s, date) > maxDiff) return true
234
+ }
235
+ }
236
+ return false
237
+ }
238
+
239
+ function emitValue() {
240
+ const s = startVal.value || null
241
+ const e = endVal.value || null
242
+ if (isArrayMode.value) {
243
+ emit("update:modelValue", [s, e])
244
+ } else {
245
+ emit("update:start", s)
246
+ emit("update:end", e)
247
+ }
248
+ emit("validate", !rangeInvalid.value)
249
+ }
250
+
251
+ function onStartChange() {
252
+ emitValue()
253
+ }
254
+
255
+ function onEndChange() {
256
+ emitValue()
257
+ }
258
+
259
+ function onStartFocus() {
260
+ startFocused.value = true
261
+ hasBlurred.value = false
262
+ }
263
+
264
+ function onEndFocus() {
265
+ endFocused.value = true
266
+ hasBlurred.value = false
267
+ }
268
+
269
+ function onStartBlur() {
270
+ startFocused.value = false
271
+ emitValue()
272
+ if (!endFocused.value) hasBlurred.value = true
273
+ }
274
+
275
+ function onEndBlur() {
276
+ endFocused.value = false
277
+ emitValue()
278
+ if (!startFocused.value) hasBlurred.value = true
279
+ }
280
+
281
+ function validate(): boolean {
282
+ hasBlurred.value = true
283
+ return !rangeInvalid.value
284
+ }
285
+
286
+ function reset() {
287
+ startVal.value = null
288
+ endVal.value = null
289
+ hasBlurred.value = false
290
+ }
291
+
292
+ defineExpose({ validate, reset })
293
+
294
+ watch(
295
+ () => ({
296
+ isArr: isArrayMode.value,
297
+ s: isArrayMode.value ? props.modelValue?.[0] : props.start,
298
+ e: isArrayMode.value ? props.modelValue?.[1] : props.end
299
+ }),
300
+ ({ s, e }) => {
301
+ const newS = s || null
302
+ const newE = e || null
303
+ if (newS !== startVal.value) startVal.value = newS
304
+ if (newE !== endVal.value) endVal.value = newE
305
+ },
306
+ { immediate: true }
307
+ )
308
+ </script>
309
+
310
+ <style scoped>
311
+ .date-range {
312
+ display: flex;
313
+ flex-direction: column;
314
+ width: 100%;
315
+ min-width: 0;
316
+ box-sizing: border-box;
317
+ }
318
+
319
+ .date-range__row {
320
+ display: flex;
321
+ flex-direction: row;
322
+ flex-wrap: nowrap;
323
+ align-items: center;
324
+ gap: 8px;
325
+ width: 100%;
326
+ min-width: 0;
327
+ }
328
+
329
+ .date-range__picker {
330
+ flex: 1 1 0;
331
+ min-width: 0;
332
+ }
333
+
334
+ /* class 往往挂在 .el-date-editor 根上,用行容器做 :deep 更稳 */
335
+ .date-range__row :deep(.el-date-editor) {
336
+ width: 100%;
337
+ max-width: 100%;
338
+ }
339
+
340
+ .date-range__row :deep(.el-date-editor .el-input__wrapper) {
341
+ width: 100%;
342
+ }
343
+
344
+ .date-range__separator {
345
+ color: var(--el-text-color-primary);
346
+ font-size: 14px;
347
+ flex-shrink: 0;
348
+ white-space: nowrap;
349
+ }
350
+
351
+ .date-range.is-disabled .date-range__separator {
352
+ color: var(--el-text-color-placeholder);
353
+ }
354
+
355
+ .date-range__picker.is-error :deep(.el-input__wrapper) {
356
+ box-shadow: 0 0 0 1px var(--el-color-danger) inset;
357
+ }
358
+
359
+ .date-range__error {
360
+ display: block;
361
+ width: 100%;
362
+ min-width: 0;
363
+ color: var(--el-color-danger);
364
+ font-size: 12px;
365
+ line-height: 1.4;
366
+ padding-top: 4px;
367
+ }
368
+ </style>
@@ -29,10 +29,10 @@ function formatThousandth(val: string | number | undefined): string {
29
29
  const str = String(val)
30
30
  const num = Number(str)
31
31
  if (isNaN(num)) return ''
32
- const parts = str.split('.')
33
- const intPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
34
- if (parts.length > 1) {
35
- return intPart + '.' + parts[1]
32
+ const [integerPart = '', decimalPart] = str.split('.')
33
+ const intPart = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
34
+ if (decimalPart !== undefined) {
35
+ return intPart + '.' + decimalPart
36
36
  }
37
37
  return intPart
38
38
  }
@@ -44,9 +44,9 @@ function stripNonNumeric(val: string): string {
44
44
  result = result.slice(0, dotIndex + 1) + result.slice(dotIndex + 1).replace(/\./g, '')
45
45
  }
46
46
  if (dotIndex !== -1) {
47
- const parts = result.split('.')
48
- if (parts[1].length > 2) {
49
- result = parts[0] + '.' + parts[1].slice(0, 2)
47
+ const [integerPart = '', decimalPart = ''] = result.split('.')
48
+ if (decimalPart.length > 2) {
49
+ result = integerPart + '.' + decimalPart.slice(0, 2)
50
50
  }
51
51
  }
52
52
  return result
@@ -1,6 +1,7 @@
1
1
  import type { App, Component } from 'vue'
2
2
 
3
3
  import TokenTag from './business/Public/TokenTag.vue'
4
+ import DateRange from './element-rewrite/DateRange.vue'
4
5
  import ElButtonPro from './element-rewrite/ElButtonPro.vue'
5
6
  import ElFormDialog from './element-rewrite/ElFormDialog.vue'
6
7
  import ElInputThousandth from './element-rewrite/ElInputThousandth.vue'
@@ -33,6 +34,13 @@ const globalComponentDefinitions: GlobalComponentDefinition[] = [
33
34
  description: '增强版按钮,提供权限、防抖、节流和操作确认能力。',
34
35
  filePath: 'src/components/element-rewrite/ElButtonPro.vue',
35
36
  },
37
+ {
38
+ name: 'DateRange',
39
+ component: DateRange,
40
+ category: '表单组件',
41
+ description: '支持数组或双字段绑定、日期联动和最长区间校验的日期范围组件。',
42
+ filePath: 'src/components/element-rewrite/DateRange.vue',
43
+ },
36
44
  {
37
45
  name: 'ElFormDialog',
38
46
  component: ElFormDialog,
@@ -114,7 +114,7 @@ const router = createRouter({
114
114
  path: '/fund-cockpit',
115
115
  name: 'fundCockpit',
116
116
  meta: { fullscreen: true },
117
- component: () => import('../views/FundCockpitView.vue'),
117
+ component: () => import('../views/fund-cockpit/index.vue'),
118
118
  },
119
119
  {
120
120
  path: '/notice-announcement',
@@ -24,7 +24,7 @@ export function formatThousands(value: unknown, fallback = '') {
24
24
 
25
25
  const sign = normalizedValue.startsWith('-') ? '-' : ''
26
26
  const unsignedValue = sign ? normalizedValue.slice(1) : normalizedValue
27
- const [integerPart, decimalPart] = unsignedValue.split('.')
27
+ const [integerPart = '', decimalPart] = unsignedValue.split('.')
28
28
  const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
29
29
 
30
30
  return `${sign}${formattedInteger}${decimalPart === undefined ? '' : `.${decimalPart}`}`
@@ -164,7 +164,7 @@ const handleFormConfirm = (data: Record<string, any>) => {
164
164
  if (data.id) {
165
165
  const index = allData.value.findIndex(item => item.id === data.id)
166
166
  if (index !== -1) {
167
- allData.value[index] = { ...allData.value[index], ...data }
167
+ allData.value[index] = { ...allData.value[index]!, ...data } as Employee
168
168
  }
169
169
  ElMessage.success('编辑成功')
170
170
  } else {
@@ -9,60 +9,50 @@ import type {
9
9
  /** 查询外币资金调拨列表(140206001)。 */
10
10
  export function queryForeignCurrencyFundAllocations(
11
11
  params: ForeignCurrencyFundAllocationFilter,
12
- options?: any,
13
12
  ) {
14
13
  return baseHttpClient.post<any>(
15
14
  '/TAM/0001/140206001',
16
15
  params,
17
- options,
18
16
  )
19
17
  }
20
18
 
21
19
  /** 新增外币资金调拨,可通过 status 区分保存草稿和提交审批(120206001)。 */
22
20
  export function createForeignCurrencyFundAllocation(
23
21
  params: ForeignCurrencyFundAllocationCreateBody,
24
- options?: any,
25
22
  ) {
26
23
  return baseHttpClient.post<any>(
27
24
  '/TAM/0001/120206001',
28
25
  params,
29
- options,
30
26
  )
31
27
  }
32
28
 
33
29
  /** 导出外币资金调拨,查询条件与列表查询保持一致(140206019)。 */
34
30
  export function exportForeignCurrencyFundAllocations(
35
31
  params: ForeignCurrencyFundAllocationFilter,
36
- options?: any,
37
32
  ) {
38
33
  return baseHttpClient.post<any>(
39
34
  '/TAM/0001/140206019',
40
35
  params,
41
- options,
42
36
  )
43
37
  }
44
38
 
45
39
  /** 修改外币资金调拨,可通过 status 区分保存草稿和提交审批(120206002)。 */
46
40
  export function updateForeignCurrencyFundAllocation(
47
41
  params: ForeignCurrencyFundAllocationUpdateBody,
48
- options?: any,
49
42
  ) {
50
43
  return baseHttpClient.post<any>(
51
44
  '/TAM/0001/120206002',
52
45
  params,
53
- options,
54
46
  )
55
47
  }
56
48
 
57
49
  /** 根据调拨单号删除外币资金调拨(120206003)。 */
58
50
  export function deleteForeignCurrencyFundAllocation(
59
51
  refNo: string,
60
- options?: any,
61
52
  ) {
62
53
  return baseHttpClient.post<any>(
63
54
  '/TAM/0001/120206003',
64
55
  { refNos: refNo },
65
- options,
66
56
  )
67
57
  }
68
58
 
@@ -74,7 +64,6 @@ export function reviewForeignCurrencyFundAllocation(
74
64
  refNo: string,
75
65
  type: ForeignCurrencyFundAllocationReviewType,
76
66
  approveRjctReason = '',
77
- options?: any,
78
67
  ) {
79
68
  return baseHttpClient.post<any>(
80
69
  '/TAM/0001/120206004',
@@ -83,6 +72,5 @@ export function reviewForeignCurrencyFundAllocation(
83
72
  type,
84
73
  ...(type === 'N' ? { approveRjctReason } : {}),
85
74
  },
86
- options,
87
75
  )
88
76
  }