@litianxiang/portal-ui 0.0.1

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/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @litianxiang/portal-ui
2
+
3
+ 统一的流程表单公共控件库。
4
+
5
+ 目前只是搭好包结构,后续可以从各项目的 `components/control` 中逐步抽取 Base/Busi 系列组件到此包,并通过 pnpm workspace 或 npm 发布给各微服务项目复用。
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@litianxiang/portal-ui",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "module": "src/index.ts",
8
+ "types": "src/index.d.ts",
9
+ "files": [
10
+ "src"
11
+ ],
12
+ "scripts": {
13
+ "build": "echo \"TODO: add build step (vite/tsup)\""
14
+ },
15
+ "peerDependencies": {
16
+ "vue": "^3.5.0",
17
+ "element-plus": "^2.9.0"
18
+ },
19
+ "devDependencies": {
20
+ "typescript": "^5.6.3",
21
+ "vue": "^3.5.0",
22
+ "element-plus": "^2.9.0"
23
+ },
24
+ "license": "UNLICENSED"
25
+ }
@@ -0,0 +1,148 @@
1
+ <template>
2
+ <ElDatePicker
3
+ ref="dateRef"
4
+ v-model="dateValue"
5
+ :type="type"
6
+ :placeholder="placeholder"
7
+ :start-placeholder="startPlaceholder"
8
+ :end-placeholder="endPlaceholder"
9
+ :disabled="disabled"
10
+ :readonly="readonly"
11
+ :clearable="clearable"
12
+ :size="size"
13
+ :format="format"
14
+ :value-format="valueFormat"
15
+ :disabled-date="disabledDate"
16
+ :shortcuts="shortcuts"
17
+ :range-separator="rangeSeparator"
18
+ @change="handleChange"
19
+ @focus="handleFocus"
20
+ @blur="handleBlur"
21
+ @clear="handleClear"
22
+ />
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { ref, computed } from 'vue'
27
+ import { ElDatePicker } from 'element-plus'
28
+
29
+ type DateValue = string | Date | [string, string] | [Date, Date] | undefined
30
+
31
+ interface Shortcut {
32
+ text: string
33
+ value: Date | (() => Date) | [Date, Date] | (() => [Date, Date])
34
+ }
35
+
36
+ interface Props {
37
+ modelValue?: DateValue
38
+ field?: string
39
+ type?: 'date' | 'datetime' | 'daterange' | 'datetimerange' | 'month' | 'year' | 'week' | 'dates'
40
+ placeholder?: string
41
+ startPlaceholder?: string
42
+ endPlaceholder?: string
43
+ disabled?: boolean
44
+ readonly?: boolean
45
+ clearable?: boolean
46
+ size?: 'small' | 'default' | 'large'
47
+ format?: string
48
+ valueFormat?: string
49
+ disabledDate?: (date: Date) => boolean
50
+ shortcuts?: Shortcut[]
51
+ rangeSeparator?: string
52
+ }
53
+
54
+ const props = withDefaults(defineProps<Props>(), {
55
+ field: '',
56
+ type: 'date',
57
+ placeholder: '请选择日期',
58
+ startPlaceholder: '开始日期',
59
+ endPlaceholder: '结束日期',
60
+ disabled: false,
61
+ readonly: false,
62
+ clearable: true,
63
+ size: 'default',
64
+ format: 'YYYY-MM-DD',
65
+ valueFormat: 'YYYY-MM-DD',
66
+ rangeSeparator: '至'
67
+ })
68
+
69
+ const emit = defineEmits<{
70
+ 'update:modelValue': [value: DateValue]
71
+ 'change': [value: DateValue]
72
+ 'focus': [event: FocusEvent]
73
+ 'blur': [event: FocusEvent]
74
+ 'clear': []
75
+ }>()
76
+
77
+ const dateRef = ref()
78
+
79
+ const dateValue = computed<DateValue>({
80
+ get: () => props.modelValue,
81
+ set: (val: DateValue) => emit('update:modelValue', val)
82
+ })
83
+
84
+ const handleChange = (value: DateValue) => {
85
+ emit('change', value)
86
+ }
87
+
88
+ const handleFocus = (event: FocusEvent) => {
89
+ emit('focus', event)
90
+ }
91
+
92
+ const handleBlur = (event: FocusEvent) => {
93
+ emit('blur', event)
94
+ }
95
+
96
+ const handleClear = () => {
97
+ emit('clear')
98
+ }
99
+
100
+ const getValue = () => {
101
+ return props.modelValue
102
+ }
103
+
104
+ const setValue = (value: DateValue) => {
105
+ emit('update:modelValue', value)
106
+ }
107
+
108
+ const getDateObject = (): Date | [Date, Date] | undefined => {
109
+ if (!props.modelValue) return undefined
110
+ if (props.modelValue instanceof Date) return props.modelValue
111
+ if (typeof props.modelValue === 'string') return new Date(props.modelValue)
112
+ if (Array.isArray(props.modelValue)) {
113
+ return props.modelValue.map((v: string | Date) => v instanceof Date ? v : new Date(v)) as [Date, Date]
114
+ }
115
+ return undefined
116
+ }
117
+
118
+ const getFormattedValue = () => {
119
+ return props.modelValue
120
+ }
121
+
122
+ const clear = () => {
123
+ emit('update:modelValue', undefined)
124
+ }
125
+
126
+ const focus = () => {
127
+ dateRef.value?.focus()
128
+ }
129
+
130
+ const blur = () => {
131
+ dateRef.value?.blur()
132
+ }
133
+
134
+ const getField = () => {
135
+ return props.field ?? ''
136
+ }
137
+
138
+ defineExpose({
139
+ getValue,
140
+ setValue,
141
+ getDateObject,
142
+ getFormattedValue,
143
+ clear,
144
+ focus,
145
+ blur,
146
+ getField
147
+ })
148
+ </script>
@@ -0,0 +1,130 @@
1
+ <template>
2
+ <ElInput
3
+ ref="inputRef"
4
+ v-model="inputValue"
5
+ :type="type"
6
+ :placeholder="placeholder"
7
+ :disabled="disabled"
8
+ :readonly="readonly"
9
+ :clearable="clearable"
10
+ :show-password="showPassword"
11
+ :maxlength="maxLength"
12
+ :minlength="minLength"
13
+ :show-word-limit="showCount"
14
+ :size="size"
15
+ :prefix-icon="prefixIcon"
16
+ :suffix-icon="suffixIcon"
17
+ @input="handleInput"
18
+ @change="handleChange"
19
+ @focus="handleFocus"
20
+ @blur="handleBlur"
21
+ @clear="handleClear"
22
+ />
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { ref, computed, type Component } from 'vue'
27
+ import { ElInput, type InputInstance } from 'element-plus'
28
+
29
+ interface Props {
30
+ modelValue?: string
31
+ field?: string
32
+ type?: 'text' | 'password' | 'textarea'
33
+ placeholder?: string
34
+ disabled?: boolean
35
+ readonly?: boolean
36
+ clearable?: boolean
37
+ showPassword?: boolean
38
+ showCount?: boolean
39
+ maxLength?: number
40
+ minLength?: number
41
+ size?: 'small' | 'default' | 'large'
42
+ prefixIcon?: string | Component
43
+ suffixIcon?: string | Component
44
+ }
45
+
46
+ const props = withDefaults(defineProps<Props>(), {
47
+ field: '',
48
+ type: 'text',
49
+ disabled: false,
50
+ readonly: false,
51
+ clearable: false,
52
+ showPassword: false,
53
+ showCount: false,
54
+ size: 'default'
55
+ })
56
+
57
+ const emit = defineEmits<{
58
+ 'update:modelValue': [value: string]
59
+ 'input': [value: string]
60
+ 'change': [value: string]
61
+ 'focus': [event: FocusEvent]
62
+ 'blur': [event: FocusEvent]
63
+ 'clear': []
64
+ }>()
65
+
66
+ const inputRef = ref<InputInstance>()
67
+
68
+ const inputValue = computed({
69
+ get: () => props.modelValue ?? '',
70
+ set: (val: string) => emit('update:modelValue', val)
71
+ })
72
+
73
+ const handleInput = (value: string) => {
74
+ emit('input', value)
75
+ }
76
+
77
+ const handleChange = (value: string) => {
78
+ emit('change', value)
79
+ }
80
+
81
+ const handleFocus = (event: FocusEvent) => {
82
+ emit('focus', event)
83
+ }
84
+
85
+ const handleBlur = (event: FocusEvent) => {
86
+ emit('blur', event)
87
+ }
88
+
89
+ const handleClear = () => {
90
+ emit('clear')
91
+ }
92
+
93
+ const getValue = (): string => {
94
+ return props.modelValue ?? ''
95
+ }
96
+
97
+ const setValue = (value: string) => {
98
+ emit('update:modelValue', value)
99
+ }
100
+
101
+ const clear = () => {
102
+ emit('update:modelValue', '')
103
+ }
104
+
105
+ const focus = () => {
106
+ inputRef.value?.focus()
107
+ }
108
+
109
+ const blur = () => {
110
+ inputRef.value?.blur()
111
+ }
112
+
113
+ const select = () => {
114
+ inputRef.value?.select()
115
+ }
116
+
117
+ const getField = (): string => {
118
+ return props.field ?? ''
119
+ }
120
+
121
+ defineExpose({
122
+ getValue,
123
+ setValue,
124
+ clear,
125
+ focus,
126
+ blur,
127
+ select,
128
+ getField
129
+ })
130
+ </script>
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <ElInputNumber
3
+ ref="numberRef"
4
+ v-model="numberValue"
5
+ :min="min"
6
+ :max="max"
7
+ :step="step"
8
+ :step-strictly="stepStrictly"
9
+ :precision="precision"
10
+ :disabled="disabled"
11
+ :readonly="readonly"
12
+ :size="size"
13
+ :controls="controls"
14
+ :controls-position="controlsPosition"
15
+ :placeholder="placeholder"
16
+ @change="handleChange"
17
+ @focus="handleFocus"
18
+ @blur="handleBlur"
19
+ />
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import { ref, computed } from 'vue'
24
+ import { ElInputNumber, type InputNumberInstance } from 'element-plus'
25
+
26
+ interface Props {
27
+ modelValue?: number
28
+ field?: string
29
+ placeholder?: string
30
+ min?: number
31
+ max?: number
32
+ step?: number
33
+ stepStrictly?: boolean
34
+ precision?: number
35
+ disabled?: boolean
36
+ readonly?: boolean
37
+ controls?: boolean
38
+ controlsPosition?: '' | 'right'
39
+ size?: 'small' | 'default' | 'large'
40
+ }
41
+
42
+ const props = withDefaults(defineProps<Props>(), {
43
+ field: '',
44
+ step: 1,
45
+ stepStrictly: false,
46
+ disabled: false,
47
+ readonly: false,
48
+ controls: true,
49
+ controlsPosition: 'right',
50
+ size: 'default'
51
+ })
52
+
53
+ const emit = defineEmits<{
54
+ 'update:modelValue': [value: number | undefined]
55
+ 'change': [value: number | undefined, oldValue: number | undefined]
56
+ 'focus': [event: FocusEvent]
57
+ 'blur': [event: FocusEvent]
58
+ }>()
59
+
60
+ const numberRef = ref<InputNumberInstance>()
61
+
62
+ const numberValue = computed<number | undefined>({
63
+ get: () => props.modelValue,
64
+ set: (val: number | undefined) => emit('update:modelValue', val)
65
+ })
66
+
67
+ const handleChange = (value: number | undefined, oldValue: number | undefined) => {
68
+ emit('change', value, oldValue)
69
+ }
70
+
71
+ const handleFocus = (event: FocusEvent) => {
72
+ emit('focus', event)
73
+ }
74
+
75
+ const handleBlur = (event: FocusEvent) => {
76
+ emit('blur', event)
77
+ }
78
+
79
+ const getValue = () => {
80
+ return props.modelValue
81
+ }
82
+
83
+ const setValue = (value: number) => {
84
+ emit('update:modelValue', value)
85
+ }
86
+
87
+ const clear = () => {
88
+ emit('update:modelValue', undefined)
89
+ }
90
+
91
+ const increase = () => {
92
+ const currentValue = props.modelValue ?? 0
93
+ const step = props.step ?? 1
94
+ let newValue = currentValue + step
95
+ if (props.max !== undefined && newValue > props.max) {
96
+ newValue = props.max
97
+ }
98
+ emit('update:modelValue', newValue)
99
+ }
100
+
101
+ const decrease = () => {
102
+ const currentValue = props.modelValue ?? 0
103
+ const step = props.step ?? 1
104
+ let newValue = currentValue - step
105
+ if (props.min !== undefined && newValue < props.min) {
106
+ newValue = props.min
107
+ }
108
+ emit('update:modelValue', newValue)
109
+ }
110
+
111
+ const focus = () => {
112
+ numberRef.value?.focus()
113
+ }
114
+
115
+ const blur = () => {
116
+ numberRef.value?.blur()
117
+ }
118
+
119
+ const getField = () => {
120
+ return props.field ?? ''
121
+ }
122
+
123
+ defineExpose({
124
+ getValue,
125
+ setValue,
126
+ clear,
127
+ increase,
128
+ decrease,
129
+ focus,
130
+ blur,
131
+ getField
132
+ })
133
+ </script>
@@ -0,0 +1,156 @@
1
+ <template>
2
+ <ElSelect
3
+ ref="selectRef"
4
+ v-model="selectValue"
5
+ :placeholder="placeholder"
6
+ :disabled="disabled"
7
+ :multiple="multiple"
8
+ :filterable="filterable"
9
+ :clearable="clearable"
10
+ :size="size"
11
+ :collapse-tags="collapseTags"
12
+ :collapse-tags-tooltip="collapseTagsTooltip"
13
+ :max-collapse-tags="maxTagCount"
14
+ :no-data-text="emptyText"
15
+ @change="handleChange"
16
+ @focus="handleFocus"
17
+ @blur="handleBlur"
18
+ @clear="handleClear"
19
+ >
20
+ <ElOption
21
+ v-for="option in options"
22
+ :key="option.key"
23
+ :label="option.value"
24
+ :value="option.key"
25
+ :disabled="option.disabled"
26
+ />
27
+ </ElSelect>
28
+ </template>
29
+
30
+ <script setup lang="ts">
31
+ import { ref, computed } from 'vue'
32
+ import { ElSelect, ElOption, type SelectInstance } from 'element-plus'
33
+
34
+ interface IOption {
35
+ key: string | number
36
+ value: string
37
+ disabled?: boolean
38
+ }
39
+
40
+ interface Props {
41
+ modelValue?: string | number | (string | number)[]
42
+ field?: string
43
+ options?: IOption[]
44
+ placeholder?: string
45
+ disabled?: boolean
46
+ multiple?: boolean
47
+ filterable?: boolean
48
+ clearable?: boolean
49
+ collapseTags?: boolean
50
+ collapseTagsTooltip?: boolean
51
+ maxTagCount?: number
52
+ emptyText?: string
53
+ size?: 'small' | 'default' | 'large'
54
+ }
55
+
56
+ const props = withDefaults(defineProps<Props>(), {
57
+ field: '',
58
+ options: () => [],
59
+ placeholder: '请选择',
60
+ disabled: false,
61
+ multiple: false,
62
+ filterable: false,
63
+ clearable: false,
64
+ collapseTags: true,
65
+ collapseTagsTooltip: true,
66
+ maxTagCount: 3,
67
+ emptyText: '暂无数据',
68
+ size: 'default'
69
+ })
70
+
71
+ const emit = defineEmits<{
72
+ 'update:modelValue': [value: string | number | (string | number)[] | undefined]
73
+ 'change': [value: string | number | (string | number)[] | undefined]
74
+ 'focus': [event: FocusEvent]
75
+ 'blur': [event: FocusEvent]
76
+ 'clear': []
77
+ }>()
78
+
79
+ const selectRef = ref<SelectInstance>()
80
+
81
+ const selectValue = computed<string | number | (string | number)[] | undefined>({
82
+ get: () => props.modelValue,
83
+ set: (val: string | number | (string | number)[] | undefined) => emit('update:modelValue', val)
84
+ })
85
+
86
+ const handleChange = (value: string | number | (string | number)[]) => {
87
+ emit('change', value)
88
+ }
89
+
90
+ const handleFocus = (event: FocusEvent) => {
91
+ emit('focus', event)
92
+ }
93
+
94
+ const handleBlur = (event: FocusEvent) => {
95
+ emit('blur', event)
96
+ }
97
+
98
+ const handleClear = () => {
99
+ emit('clear')
100
+ }
101
+
102
+ const getValue = () => {
103
+ return props.modelValue
104
+ }
105
+
106
+ const setValue = (value: string | number | (string | number)[]) => {
107
+ emit('update:modelValue', value)
108
+ }
109
+
110
+ const getSelectedOption = () => {
111
+ if (!props.modelValue) return undefined
112
+ if (props.multiple && Array.isArray(props.modelValue)) {
113
+ return props.modelValue.map((key: string | number) => props.options.find((opt: IOption) => opt.key === key)!)
114
+ }
115
+ return props.options.find((opt: IOption) => opt.key === props.modelValue)
116
+ }
117
+
118
+ const getSelectedValue = () => {
119
+ if (!props.modelValue) return undefined
120
+ if (props.multiple && Array.isArray(props.modelValue)) {
121
+ return props.modelValue.map((key: string | number) => {
122
+ const option = props.options.find((opt: IOption) => opt.key === key)
123
+ return option?.value ?? ''
124
+ })
125
+ }
126
+ const option = props.options.find((opt: IOption) => opt.key === props.modelValue)
127
+ return option?.value
128
+ }
129
+
130
+ const clear = () => {
131
+ emit('update:modelValue', props.multiple ? [] : undefined)
132
+ }
133
+
134
+ const focus = () => {
135
+ selectRef.value?.focus()
136
+ }
137
+
138
+ const blur = () => {
139
+ selectRef.value?.blur()
140
+ }
141
+
142
+ const getField = () => {
143
+ return props.field ?? ''
144
+ }
145
+
146
+ defineExpose({
147
+ getValue,
148
+ setValue,
149
+ getSelectedOption,
150
+ getSelectedValue,
151
+ clear,
152
+ focus,
153
+ blur,
154
+ getField
155
+ })
156
+ </script>
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <ElInput
3
+ ref="textareaRef"
4
+ v-model="inputValue"
5
+ type="textarea"
6
+ :placeholder="placeholder"
7
+ :disabled="disabled"
8
+ :readonly="readonly"
9
+ :maxlength="maxLength"
10
+ :minlength="minLength"
11
+ :rows="rows"
12
+ :autosize="autosize"
13
+ :resize="resize"
14
+ :show-word-limit="showCount"
15
+ @input="handleInput"
16
+ @change="handleChange"
17
+ @focus="handleFocus"
18
+ @blur="handleBlur"
19
+ />
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import { ref, computed } from 'vue'
24
+ import { ElInput, type InputInstance } from 'element-plus'
25
+
26
+ interface Props {
27
+ modelValue?: string
28
+ field?: string
29
+ placeholder?: string
30
+ disabled?: boolean
31
+ readonly?: boolean
32
+ maxLength?: number
33
+ minLength?: number
34
+ rows?: number
35
+ autosize?: boolean | { minRows?: number; maxRows?: number }
36
+ resize?: 'none' | 'both' | 'horizontal' | 'vertical'
37
+ showCount?: boolean
38
+ }
39
+
40
+ const props = withDefaults(defineProps<Props>(), {
41
+ field: '',
42
+ disabled: false,
43
+ readonly: false,
44
+ rows: 3,
45
+ resize: 'vertical',
46
+ showCount: false
47
+ })
48
+
49
+ const emit = defineEmits<{
50
+ 'update:modelValue': [value: string]
51
+ 'input': [value: string]
52
+ 'change': [value: string]
53
+ 'focus': [event: FocusEvent]
54
+ 'blur': [event: FocusEvent]
55
+ }>()
56
+
57
+ const textareaRef = ref<InputInstance>()
58
+
59
+ const inputValue = computed({
60
+ get: () => props.modelValue ?? '',
61
+ set: (val: string) => emit('update:modelValue', val)
62
+ })
63
+
64
+ const handleInput = (value: string) => {
65
+ emit('input', value)
66
+ }
67
+
68
+ const handleChange = (value: string) => {
69
+ emit('change', value)
70
+ }
71
+
72
+ const handleFocus = (event: FocusEvent) => {
73
+ emit('focus', event)
74
+ }
75
+
76
+ const handleBlur = (event: FocusEvent) => {
77
+ emit('blur', event)
78
+ }
79
+
80
+ const getValue = (): string => {
81
+ return props.modelValue ?? ''
82
+ }
83
+
84
+ const setValue = (value: string) => {
85
+ emit('update:modelValue', value)
86
+ }
87
+
88
+ const clear = () => {
89
+ emit('update:modelValue', '')
90
+ }
91
+
92
+ const focus = () => {
93
+ textareaRef.value?.focus()
94
+ }
95
+
96
+ const blur = () => {
97
+ textareaRef.value?.blur()
98
+ }
99
+
100
+ const getLength = (): number => {
101
+ return (props.modelValue || '').length
102
+ }
103
+
104
+ const getField = (): string => {
105
+ return props.field ?? ''
106
+ }
107
+
108
+ defineExpose({
109
+ getValue,
110
+ setValue,
111
+ clear,
112
+ focus,
113
+ blur,
114
+ getLength,
115
+ getField
116
+ })
117
+ </script>
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <ElTimePicker
3
+ ref="timeRef"
4
+ v-model="timeValue"
5
+ :is-range="isRange"
6
+ :placeholder="placeholder"
7
+ :start-placeholder="startPlaceholder"
8
+ :end-placeholder="endPlaceholder"
9
+ :disabled="disabled"
10
+ :readonly="readonly"
11
+ :clearable="clearable"
12
+ :size="size"
13
+ :format="format"
14
+ :value-format="valueFormat"
15
+ :disabled-hours="disabledHours"
16
+ :disabled-minutes="disabledMinutes"
17
+ :disabled-seconds="disabledSeconds"
18
+ :range-separator="rangeSeparator"
19
+ :arrow-control="arrowControl"
20
+ @change="handleChange"
21
+ @focus="handleFocus"
22
+ @blur="handleBlur"
23
+ @clear="handleClear"
24
+ />
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { ref, computed } from 'vue'
29
+ import { ElTimePicker } from 'element-plus'
30
+
31
+ type TimeValue = string | Date | [string, string] | [Date, Date] | undefined
32
+
33
+ interface Props {
34
+ modelValue?: TimeValue
35
+ field?: string
36
+ isRange?: boolean
37
+ placeholder?: string
38
+ startPlaceholder?: string
39
+ endPlaceholder?: string
40
+ disabled?: boolean
41
+ readonly?: boolean
42
+ clearable?: boolean
43
+ size?: 'small' | 'default' | 'large'
44
+ format?: string
45
+ valueFormat?: string
46
+ disabledHours?: () => number[]
47
+ disabledMinutes?: (hour: number) => number[]
48
+ disabledSeconds?: (hour: number, minute: number) => number[]
49
+ rangeSeparator?: string
50
+ arrowControl?: boolean
51
+ }
52
+
53
+ const props = withDefaults(defineProps<Props>(), {
54
+ field: '',
55
+ isRange: false,
56
+ placeholder: '请选择时间',
57
+ startPlaceholder: '开始时间',
58
+ endPlaceholder: '结束时间',
59
+ disabled: false,
60
+ readonly: false,
61
+ clearable: true,
62
+ size: 'default',
63
+ format: 'HH:mm:ss',
64
+ valueFormat: 'HH:mm:ss',
65
+ rangeSeparator: '至',
66
+ arrowControl: false
67
+ })
68
+
69
+ const emit = defineEmits<{
70
+ 'update:modelValue': [value: TimeValue]
71
+ 'change': [value: TimeValue]
72
+ 'focus': [event: FocusEvent]
73
+ 'blur': [event: FocusEvent]
74
+ 'clear': []
75
+ }>()
76
+
77
+ const timeRef = ref()
78
+
79
+ const timeValue = computed<TimeValue>({
80
+ get: () => props.modelValue,
81
+ set: (val: TimeValue) => emit('update:modelValue', val)
82
+ })
83
+
84
+ const handleChange = (value: TimeValue) => {
85
+ emit('change', value)
86
+ }
87
+
88
+ const handleFocus = (event: FocusEvent) => {
89
+ emit('focus', event)
90
+ }
91
+
92
+ const handleBlur = (event: FocusEvent) => {
93
+ emit('blur', event)
94
+ }
95
+
96
+ const handleClear = () => {
97
+ emit('clear')
98
+ }
99
+
100
+ const getValue = () => {
101
+ return props.modelValue
102
+ }
103
+
104
+ const setValue = (value: TimeValue) => {
105
+ emit('update:modelValue', value)
106
+ }
107
+
108
+ const getFormattedValue = () => {
109
+ return props.modelValue
110
+ }
111
+
112
+ const clear = () => {
113
+ emit('update:modelValue', undefined)
114
+ }
115
+
116
+ const focus = () => {
117
+ timeRef.value?.focus()
118
+ }
119
+
120
+ const blur = () => {
121
+ timeRef.value?.blur()
122
+ }
123
+
124
+ const getField = () => {
125
+ return props.field ?? ''
126
+ }
127
+
128
+
129
+ defineExpose({
130
+ getValue,
131
+ setValue,
132
+ getFormattedValue,
133
+ clear,
134
+ focus,
135
+ blur,
136
+ getField
137
+ })
138
+ </script>
package/src/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { DefineComponent } from 'vue'
2
+
3
+ export const BaseInput: DefineComponent<any, any, any>
4
+ export const BaseSelect: DefineComponent<any, any, any>
5
+ export const BaseNumber: DefineComponent<any, any, any>
6
+ export const BaseTextarea: DefineComponent<any, any, any>
7
+ export const BaseDate: DefineComponent<any, any, any>
8
+ export const BaseTime: DefineComponent<any, any, any>
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ // 公共表单控件库入口
2
+ // 统一导出基础表单控件,供各微服务项目复用
3
+
4
+ export { default as BaseInput } from './components/control/base/base-input.vue'
5
+ export { default as BaseSelect } from './components/control/base/base-select.vue'
6
+ export { default as BaseNumber } from './components/control/base/base-number.vue'
7
+ export { default as BaseTextarea } from './components/control/base/base-textarea.vue'
8
+ export { default as BaseDate } from './components/control/base/base-date.vue'
9
+ export { default as BaseTime } from './components/control/base/base-time.vue'
10
+