@hbdlzy/ui-core 0.1.4 → 0.1.6
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 +7 -0
- package/components.manifest.json +32 -35
- package/dist/components/BaseCard/BaseCard.types.d.ts +36 -36
- package/dist/components/BaseCard/BaseCard.vue.d.ts +122 -122
- package/dist/components/BaseCard/index.d.ts +3 -3
- package/dist/components/BaseEChart/BaseEChart.types.d.ts +26 -26
- package/dist/components/BaseEChart/BaseEChart.vue.d.ts +66 -66
- package/dist/components/BaseEChart/index.d.ts +3 -3
- package/dist/components/BaseExportButton/BaseExportButton.types.d.ts +21 -21
- package/dist/components/BaseExportButton/BaseExportButton.utils.d.ts +4 -4
- package/dist/components/BaseExportButton/BaseExportButton.vue.d.ts +128 -128
- package/dist/components/BaseExportButton/index.d.ts +5 -5
- package/dist/components/BaseTable/BaseTable.types.d.ts +163 -163
- package/dist/components/BaseTable/BaseTable.vue.d.ts +157 -157
- package/dist/components/BaseTable/index.d.ts +3 -3
- package/dist/components/OutlinedCascader/OutlinedCascader.types.d.ts +28 -25
- package/dist/components/OutlinedCascader/OutlinedCascader.vue.d.ts +94 -85
- package/dist/components/OutlinedCascader/index.d.ts +3 -3
- package/dist/components/OutlinedDatePicker/OutlinedDatePicker.types.d.ts +30 -27
- package/dist/components/OutlinedDatePicker/OutlinedDatePicker.vue.d.ts +97 -88
- package/dist/components/OutlinedDatePicker/index.d.ts +3 -3
- package/dist/components/OutlinedDateTimePicker/OutlinedDateTimePicker.types.d.ts +29 -26
- package/dist/components/OutlinedDateTimePicker/OutlinedDateTimePicker.vue.d.ts +106 -97
- package/dist/components/OutlinedDateTimePicker/index.d.ts +3 -3
- package/dist/components/OutlinedInput/OutlinedInput.types.d.ts +32 -29
- package/dist/components/OutlinedInput/OutlinedInput.vue.d.ts +106 -97
- package/dist/components/OutlinedInput/index.d.ts +3 -3
- package/dist/components/OutlinedSelect/OutlinedSelect.types.d.ts +41 -38
- package/dist/components/OutlinedSelect/OutlinedSelect.vue.d.ts +125 -116
- package/dist/components/OutlinedSelect/index.d.ts +3 -3
- package/dist/components/OutlinedTimePicker/OutlinedTimePicker.types.d.ts +31 -28
- package/dist/components/OutlinedTimePicker/OutlinedTimePicker.vue.d.ts +103 -94
- package/dist/components/OutlinedTimePicker/index.d.ts +3 -3
- package/dist/components/OutlinedTreeSelect/OutlinedTreeSelect.types.d.ts +49 -46
- package/dist/components/OutlinedTreeSelect/OutlinedTreeSelect.vue.d.ts +146 -137
- package/dist/components/OutlinedTreeSelect/index.d.ts +3 -3
- package/dist/echarts/index.d.ts +9 -9
- package/dist/excel/exportExcel.d.ts +18 -18
- package/dist/index.cjs +42 -1
- package/dist/index.d.ts +27 -30
- package/dist/index.js +643 -644
- package/dist/ripple/index.d.ts +2 -0
- package/dist/style.css +1 -1
- package/package.json +6 -4
- package/src/components/BaseExportButton/BaseExportButton.vue +1 -3
- package/src/components/BaseTable/BaseTable.types.ts +1 -1
- package/src/components/OutlinedCascader/OutlinedCascader.types.ts +3 -0
- package/src/components/OutlinedCascader/OutlinedCascader.vue +71 -6
- package/src/components/OutlinedCascader/README.md +3 -0
- package/src/components/OutlinedDatePicker/OutlinedDatePicker.types.ts +3 -0
- package/src/components/OutlinedDatePicker/OutlinedDatePicker.vue +71 -6
- package/src/components/OutlinedDatePicker/README.md +3 -0
- package/src/components/OutlinedDateTimePicker/OutlinedDateTimePicker.types.ts +3 -0
- package/src/components/OutlinedDateTimePicker/OutlinedDateTimePicker.vue +144 -64
- package/src/components/OutlinedDateTimePicker/README.md +3 -0
- package/src/components/OutlinedInput/OutlinedInput.types.ts +3 -0
- package/src/components/OutlinedInput/OutlinedInput.vue +87 -8
- package/src/components/OutlinedInput/README.md +3 -0
- package/src/components/OutlinedSelect/OutlinedSelect.types.ts +3 -0
- package/src/components/OutlinedSelect/OutlinedSelect.vue +72 -6
- package/src/components/OutlinedSelect/README.md +3 -0
- package/src/components/OutlinedTimePicker/OutlinedTimePicker.types.ts +3 -0
- package/src/components/OutlinedTimePicker/OutlinedTimePicker.vue +75 -8
- package/src/components/OutlinedTimePicker/README.md +3 -0
- package/src/components/OutlinedTreeSelect/OutlinedTreeSelect.types.ts +3 -0
- package/src/components/OutlinedTreeSelect/OutlinedTreeSelect.vue +72 -6
- package/src/components/OutlinedTreeSelect/README.md +3 -0
- package/src/index.ts +5 -4
- package/src/ripple/index.ts +213 -0
- package/dist/components/BaseDialog/BaseDialog.types.d.ts +0 -25
- package/dist/components/BaseDialog/BaseDialog.vue.d.ts +0 -100
- package/dist/components/BaseDialog/index.d.ts +0 -3
- package/dist/components/BaseSearchForm/BaseSearchForm.types.d.ts +0 -42
- package/dist/components/BaseSearchForm/BaseSearchForm.utils.d.ts +0 -5
- package/dist/components/BaseSearchForm/BaseSearchForm.vue.d.ts +0 -88
- package/dist/components/BaseSearchForm/index.d.ts +0 -4
- package/src/components/BaseDialog/BaseDialog.types.ts +0 -28
- package/src/components/BaseDialog/BaseDialog.vue +0 -158
- package/src/components/BaseDialog/README.md +0 -69
- package/src/components/BaseDialog/index.ts +0 -10
- package/src/components/BaseSearchForm/BaseSearchForm.types.ts +0 -46
- package/src/components/BaseSearchForm/BaseSearchForm.utils.ts +0 -41
- package/src/components/BaseSearchForm/BaseSearchForm.vue +0 -267
- package/src/components/BaseSearchForm/README.md +0 -66
- package/src/components/BaseSearchForm/index.ts +0 -20
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export type BaseSearchFormCssValue = string | number;
|
|
2
|
-
export type BaseSearchFormFieldType = 'input' | 'select' | 'date' | 'dateRange' | 'slot';
|
|
3
|
-
export type BaseSearchFormOptionValue = string | number | boolean;
|
|
4
|
-
export type BaseSearchFormModel = Record<string, unknown>;
|
|
5
|
-
export interface BaseSearchFormOption {
|
|
6
|
-
label: string;
|
|
7
|
-
value: BaseSearchFormOptionValue;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface BaseSearchFormField {
|
|
11
|
-
key: string;
|
|
12
|
-
label?: string;
|
|
13
|
-
type?: BaseSearchFormFieldType;
|
|
14
|
-
placeholder?: string;
|
|
15
|
-
options?: BaseSearchFormOption[];
|
|
16
|
-
span?: number;
|
|
17
|
-
collapsed?: boolean;
|
|
18
|
-
hidden?: boolean;
|
|
19
|
-
clearable?: boolean;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
props?: Record<string, unknown>;
|
|
22
|
-
}
|
|
23
|
-
export interface BaseSearchFormProps {
|
|
24
|
-
modelValue?: BaseSearchFormModel;
|
|
25
|
-
fields: BaseSearchFormField[];
|
|
26
|
-
collapsed?: boolean;
|
|
27
|
-
showCollapse?: boolean;
|
|
28
|
-
columns?: number;
|
|
29
|
-
labelWidth?: BaseSearchFormCssValue;
|
|
30
|
-
fieldWidth?: BaseSearchFormCssValue;
|
|
31
|
-
gutter?: number;
|
|
32
|
-
submitText?: string;
|
|
33
|
-
resetText?: string;
|
|
34
|
-
expandText?: string;
|
|
35
|
-
collapseText?: string;
|
|
36
|
-
}
|
|
37
|
-
export interface BaseSearchFormExpose {
|
|
38
|
-
submit: () => void;
|
|
39
|
-
reset: () => void;
|
|
40
|
-
setFieldValue: (key: string, value: unknown) => void;
|
|
41
|
-
getModel: () => BaseSearchFormModel;
|
|
42
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BaseSearchFormField, BaseSearchFormModel } from './BaseSearchForm.types';
|
|
2
|
-
export declare function cloneSearchFormModel(model?: BaseSearchFormModel): BaseSearchFormModel;
|
|
3
|
-
export declare function getVisibleSearchFields(fields: BaseSearchFormField[], collapsed: boolean): BaseSearchFormField[];
|
|
4
|
-
export declare function resetSearchFormModel(fields: BaseSearchFormField[]): BaseSearchFormModel;
|
|
5
|
-
export declare function toSearchFormCssValue(value?: string | number): string | undefined;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { BaseSearchFormField, BaseSearchFormModel, BaseSearchFormProps } from './BaseSearchForm.types';
|
|
2
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<BaseSearchFormProps>, {
|
|
3
|
-
modelValue: () => {};
|
|
4
|
-
collapsed: boolean;
|
|
5
|
-
showCollapse: boolean;
|
|
6
|
-
columns: number;
|
|
7
|
-
labelWidth: number;
|
|
8
|
-
fieldWidth: undefined;
|
|
9
|
-
gutter: number;
|
|
10
|
-
submitText: string;
|
|
11
|
-
resetText: string;
|
|
12
|
-
expandText: string;
|
|
13
|
-
collapseText: string;
|
|
14
|
-
}>>, {
|
|
15
|
-
submit: () => void;
|
|
16
|
-
reset: () => void;
|
|
17
|
-
setFieldValue: (key: string, value: unknown) => void;
|
|
18
|
-
getModel: () => BaseSearchFormModel;
|
|
19
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
-
"update:modelValue": (value: BaseSearchFormModel) => void;
|
|
21
|
-
search: (value: BaseSearchFormModel) => void;
|
|
22
|
-
reset: (value: BaseSearchFormModel) => void;
|
|
23
|
-
"field-change": (key: string, value: unknown, model: BaseSearchFormModel) => void;
|
|
24
|
-
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<BaseSearchFormProps>, {
|
|
25
|
-
modelValue: () => {};
|
|
26
|
-
collapsed: boolean;
|
|
27
|
-
showCollapse: boolean;
|
|
28
|
-
columns: number;
|
|
29
|
-
labelWidth: number;
|
|
30
|
-
fieldWidth: undefined;
|
|
31
|
-
gutter: number;
|
|
32
|
-
submitText: string;
|
|
33
|
-
resetText: string;
|
|
34
|
-
expandText: string;
|
|
35
|
-
collapseText: string;
|
|
36
|
-
}>>> & Readonly<{
|
|
37
|
-
onReset?: ((value: BaseSearchFormModel) => any) | undefined;
|
|
38
|
-
onSearch?: ((value: BaseSearchFormModel) => any) | undefined;
|
|
39
|
-
"onUpdate:modelValue"?: ((value: BaseSearchFormModel) => any) | undefined;
|
|
40
|
-
"onField-change"?: ((key: string, value: unknown, model: BaseSearchFormModel) => any) | undefined;
|
|
41
|
-
}>, {
|
|
42
|
-
modelValue: BaseSearchFormModel;
|
|
43
|
-
collapsed: boolean;
|
|
44
|
-
showCollapse: boolean;
|
|
45
|
-
columns: number;
|
|
46
|
-
labelWidth: import("./BaseSearchForm.types").BaseSearchFormCssValue;
|
|
47
|
-
fieldWidth: import("./BaseSearchForm.types").BaseSearchFormCssValue;
|
|
48
|
-
gutter: number;
|
|
49
|
-
submitText: string;
|
|
50
|
-
resetText: string;
|
|
51
|
-
expandText: string;
|
|
52
|
-
collapseText: string;
|
|
53
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, Partial<Record<string, (_: {
|
|
54
|
-
field: BaseSearchFormField;
|
|
55
|
-
model: BaseSearchFormModel;
|
|
56
|
-
value: unknown;
|
|
57
|
-
setValue: (value: unknown) => void;
|
|
58
|
-
}) => any>> & {
|
|
59
|
-
"actions-before"?(_: {
|
|
60
|
-
model: BaseSearchFormModel;
|
|
61
|
-
}): any;
|
|
62
|
-
"actions-after"?(_: {
|
|
63
|
-
model: BaseSearchFormModel;
|
|
64
|
-
}): any;
|
|
65
|
-
}>;
|
|
66
|
-
export default _default;
|
|
67
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
68
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
69
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
70
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
71
|
-
} : {
|
|
72
|
-
type: import('vue').PropType<T[K]>;
|
|
73
|
-
required: true;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
type __VLS_WithDefaults<P, D> = {
|
|
77
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
78
|
-
default: D[K];
|
|
79
|
-
}> : P[K];
|
|
80
|
-
};
|
|
81
|
-
type __VLS_Prettify<T> = {
|
|
82
|
-
[K in keyof T]: T[K];
|
|
83
|
-
} & {};
|
|
84
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
85
|
-
new (): {
|
|
86
|
-
$slots: S;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import BaseSearchForm from './BaseSearchForm.vue';
|
|
2
|
-
export default BaseSearchForm;
|
|
3
|
-
export { cloneSearchFormModel, getVisibleSearchFields, resetSearchFormModel, toSearchFormCssValue } from './BaseSearchForm.utils';
|
|
4
|
-
export type { BaseSearchFormCssValue, BaseSearchFormExpose, BaseSearchFormField, BaseSearchFormFieldType, BaseSearchFormModel, BaseSearchFormOption, BaseSearchFormOptionValue, BaseSearchFormProps } from './BaseSearchForm.types';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type BaseDialogCssValue = string | number
|
|
2
|
-
|
|
3
|
-
export type BaseDialogBeforeConfirm = () => boolean | void | Promise<boolean | void>
|
|
4
|
-
|
|
5
|
-
export interface BaseDialogProps {
|
|
6
|
-
modelValue?: boolean
|
|
7
|
-
title?: string
|
|
8
|
-
width?: BaseDialogCssValue
|
|
9
|
-
top?: string
|
|
10
|
-
fullscreen?: boolean
|
|
11
|
-
appendToBody?: boolean
|
|
12
|
-
destroyOnClose?: boolean
|
|
13
|
-
closeOnClickModal?: boolean
|
|
14
|
-
closeOnPressEscape?: boolean
|
|
15
|
-
showClose?: boolean
|
|
16
|
-
showFooter?: boolean
|
|
17
|
-
confirmText?: string
|
|
18
|
-
cancelText?: string
|
|
19
|
-
confirmLoading?: boolean
|
|
20
|
-
confirmDisabled?: boolean
|
|
21
|
-
beforeConfirm?: BaseDialogBeforeConfirm
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface BaseDialogExpose {
|
|
25
|
-
open: () => void
|
|
26
|
-
close: () => void
|
|
27
|
-
confirm: () => Promise<void>
|
|
28
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-dialog
|
|
3
|
-
class="base-dialog"
|
|
4
|
-
:model-value="modelValue"
|
|
5
|
-
:title="title"
|
|
6
|
-
:width="normalizedWidth"
|
|
7
|
-
:top="top"
|
|
8
|
-
:fullscreen="fullscreen"
|
|
9
|
-
:append-to-body="appendToBody"
|
|
10
|
-
:destroy-on-close="destroyOnClose"
|
|
11
|
-
:close-on-click-modal="closeOnClickModal"
|
|
12
|
-
:close-on-press-escape="closeOnPressEscape"
|
|
13
|
-
:show-close="showClose"
|
|
14
|
-
@update:model-value="handleModelValueUpdate"
|
|
15
|
-
@open="emit('open')"
|
|
16
|
-
@opened="emit('opened')"
|
|
17
|
-
@close="emit('close')"
|
|
18
|
-
@closed="emit('closed')"
|
|
19
|
-
>
|
|
20
|
-
<template
|
|
21
|
-
v-if="$slots.header"
|
|
22
|
-
#header
|
|
23
|
-
>
|
|
24
|
-
<slot name="header" />
|
|
25
|
-
</template>
|
|
26
|
-
|
|
27
|
-
<div class="base-dialog__body">
|
|
28
|
-
<slot />
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<template
|
|
32
|
-
v-if="showFooter"
|
|
33
|
-
#footer
|
|
34
|
-
>
|
|
35
|
-
<slot name="footer">
|
|
36
|
-
<div class="base-dialog__footer">
|
|
37
|
-
<el-button @click="cancel">
|
|
38
|
-
{{ cancelText }}
|
|
39
|
-
</el-button>
|
|
40
|
-
<el-button
|
|
41
|
-
type="primary"
|
|
42
|
-
:loading="mergedConfirmLoading"
|
|
43
|
-
:disabled="confirmDisabled"
|
|
44
|
-
@click="confirm"
|
|
45
|
-
>
|
|
46
|
-
{{ confirmText }}
|
|
47
|
-
</el-button>
|
|
48
|
-
</div>
|
|
49
|
-
</slot>
|
|
50
|
-
</template>
|
|
51
|
-
</el-dialog>
|
|
52
|
-
</template>
|
|
53
|
-
|
|
54
|
-
<script setup lang="ts">
|
|
55
|
-
import { computed, ref } from 'vue'
|
|
56
|
-
import type { BaseDialogExpose, BaseDialogProps } from './BaseDialog.types'
|
|
57
|
-
|
|
58
|
-
defineOptions({
|
|
59
|
-
name: 'BaseDialog'
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
const props = withDefaults(defineProps<BaseDialogProps>(), {
|
|
63
|
-
modelValue: false,
|
|
64
|
-
title: '',
|
|
65
|
-
width: '560px',
|
|
66
|
-
top: '12vh',
|
|
67
|
-
fullscreen: false,
|
|
68
|
-
appendToBody: false,
|
|
69
|
-
destroyOnClose: false,
|
|
70
|
-
closeOnClickModal: false,
|
|
71
|
-
closeOnPressEscape: true,
|
|
72
|
-
showClose: true,
|
|
73
|
-
showFooter: true,
|
|
74
|
-
confirmText: '确定',
|
|
75
|
-
cancelText: '取消',
|
|
76
|
-
confirmLoading: false,
|
|
77
|
-
confirmDisabled: false,
|
|
78
|
-
beforeConfirm: undefined
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const emit = defineEmits<{
|
|
82
|
-
(event: 'update:modelValue', value: boolean): void
|
|
83
|
-
(event: 'open'): void
|
|
84
|
-
(event: 'opened'): void
|
|
85
|
-
(event: 'close'): void
|
|
86
|
-
(event: 'closed'): void
|
|
87
|
-
(event: 'cancel'): void
|
|
88
|
-
(event: 'confirm'): void
|
|
89
|
-
}>()
|
|
90
|
-
|
|
91
|
-
const innerConfirmLoading = ref(false)
|
|
92
|
-
|
|
93
|
-
const normalizedWidth = computed(() => toCssValue(props.width))
|
|
94
|
-
const mergedConfirmLoading = computed(() => props.confirmLoading || innerConfirmLoading.value)
|
|
95
|
-
|
|
96
|
-
function toCssValue(value?: string | number) {
|
|
97
|
-
if (value === undefined || value === null || value === '') {
|
|
98
|
-
return undefined
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return typeof value === 'number' ? `${value}px` : value
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function handleModelValueUpdate(value: boolean) {
|
|
105
|
-
emit('update:modelValue', value)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function open() {
|
|
109
|
-
emit('update:modelValue', true)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function close() {
|
|
113
|
-
emit('update:modelValue', false)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function cancel() {
|
|
117
|
-
emit('cancel')
|
|
118
|
-
close()
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function confirm() {
|
|
122
|
-
if (mergedConfirmLoading.value || props.confirmDisabled) {
|
|
123
|
-
return
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
innerConfirmLoading.value = true
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
const result = await props.beforeConfirm?.()
|
|
130
|
-
if (result === false) {
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
emit('confirm')
|
|
135
|
-
} finally {
|
|
136
|
-
innerConfirmLoading.value = false
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
defineExpose<BaseDialogExpose>({
|
|
141
|
-
open,
|
|
142
|
-
close,
|
|
143
|
-
confirm
|
|
144
|
-
})
|
|
145
|
-
</script>
|
|
146
|
-
|
|
147
|
-
<style scoped>
|
|
148
|
-
.base-dialog__body {
|
|
149
|
-
min-width: 0;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.base-dialog__footer {
|
|
153
|
-
display: flex;
|
|
154
|
-
align-items: center;
|
|
155
|
-
justify-content: flex-end;
|
|
156
|
-
gap: 8px;
|
|
157
|
-
}
|
|
158
|
-
</style>
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# BaseDialog
|
|
2
|
-
|
|
3
|
-
`BaseDialog` 用于统一新增、编辑、确认类弹窗,封装常见页脚、确认 loading、异步确认和取消关闭逻辑。
|
|
4
|
-
|
|
5
|
-
## 基础用法
|
|
6
|
-
|
|
7
|
-
```vue
|
|
8
|
-
<template>
|
|
9
|
-
<BaseDialog
|
|
10
|
-
v-model="visible"
|
|
11
|
-
title="新增记录"
|
|
12
|
-
:before-confirm="submitForm"
|
|
13
|
-
@confirm="visible = false"
|
|
14
|
-
>
|
|
15
|
-
<el-form>
|
|
16
|
-
<el-form-item label="名称">
|
|
17
|
-
<el-input v-model="form.name" />
|
|
18
|
-
</el-form-item>
|
|
19
|
-
</el-form>
|
|
20
|
-
</BaseDialog>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script setup lang="ts">
|
|
24
|
-
import { reactive, ref } from 'vue'
|
|
25
|
-
import { BaseDialog } from '@hbdlzy/ui-core'
|
|
26
|
-
|
|
27
|
-
const visible = ref(false)
|
|
28
|
-
const form = reactive({ name: '' })
|
|
29
|
-
|
|
30
|
-
async function submitForm() {
|
|
31
|
-
if (!form.name) {
|
|
32
|
-
return false
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Props
|
|
39
|
-
|
|
40
|
-
- `modelValue`: 弹窗显示状态
|
|
41
|
-
- `title`: 标题
|
|
42
|
-
- `width`: 宽度
|
|
43
|
-
- `top`: 顶部距离
|
|
44
|
-
- `fullscreen`: 是否全屏
|
|
45
|
-
- `appendToBody`: 是否插入 body
|
|
46
|
-
- `destroyOnClose`: 关闭后销毁内容
|
|
47
|
-
- `closeOnClickModal`: 点击遮罩关闭
|
|
48
|
-
- `showFooter`: 是否显示默认页脚
|
|
49
|
-
- `confirmText`: 确认按钮文案
|
|
50
|
-
- `cancelText`: 取消按钮文案
|
|
51
|
-
- `confirmLoading`: 外部确认 loading
|
|
52
|
-
- `confirmDisabled`: 禁用确认按钮
|
|
53
|
-
- `beforeConfirm`: 确认前钩子,返回 `false` 可阻止确认事件
|
|
54
|
-
|
|
55
|
-
## Events
|
|
56
|
-
|
|
57
|
-
- `update:modelValue`
|
|
58
|
-
- `open`
|
|
59
|
-
- `opened`
|
|
60
|
-
- `close`
|
|
61
|
-
- `closed`
|
|
62
|
-
- `cancel`
|
|
63
|
-
- `confirm`
|
|
64
|
-
|
|
65
|
-
## Slots
|
|
66
|
-
|
|
67
|
-
- 默认插槽:弹窗内容
|
|
68
|
-
- `header`: 自定义头部
|
|
69
|
-
- `footer`: 自定义底部
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export type BaseSearchFormCssValue = string | number
|
|
2
|
-
export type BaseSearchFormFieldType = 'input' | 'select' | 'date' | 'dateRange' | 'slot'
|
|
3
|
-
export type BaseSearchFormOptionValue = string | number | boolean
|
|
4
|
-
export type BaseSearchFormModel = Record<string, unknown>
|
|
5
|
-
|
|
6
|
-
export interface BaseSearchFormOption {
|
|
7
|
-
label: string
|
|
8
|
-
value: BaseSearchFormOptionValue
|
|
9
|
-
disabled?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface BaseSearchFormField {
|
|
13
|
-
key: string
|
|
14
|
-
label?: string
|
|
15
|
-
type?: BaseSearchFormFieldType
|
|
16
|
-
placeholder?: string
|
|
17
|
-
options?: BaseSearchFormOption[]
|
|
18
|
-
span?: number
|
|
19
|
-
collapsed?: boolean
|
|
20
|
-
hidden?: boolean
|
|
21
|
-
clearable?: boolean
|
|
22
|
-
disabled?: boolean
|
|
23
|
-
props?: Record<string, unknown>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface BaseSearchFormProps {
|
|
27
|
-
modelValue?: BaseSearchFormModel
|
|
28
|
-
fields: BaseSearchFormField[]
|
|
29
|
-
collapsed?: boolean
|
|
30
|
-
showCollapse?: boolean
|
|
31
|
-
columns?: number
|
|
32
|
-
labelWidth?: BaseSearchFormCssValue
|
|
33
|
-
fieldWidth?: BaseSearchFormCssValue
|
|
34
|
-
gutter?: number
|
|
35
|
-
submitText?: string
|
|
36
|
-
resetText?: string
|
|
37
|
-
expandText?: string
|
|
38
|
-
collapseText?: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface BaseSearchFormExpose {
|
|
42
|
-
submit: () => void
|
|
43
|
-
reset: () => void
|
|
44
|
-
setFieldValue: (key: string, value: unknown) => void
|
|
45
|
-
getModel: () => BaseSearchFormModel
|
|
46
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BaseSearchFormField,
|
|
3
|
-
BaseSearchFormModel
|
|
4
|
-
} from './BaseSearchForm.types'
|
|
5
|
-
|
|
6
|
-
export function cloneSearchFormModel(model?: BaseSearchFormModel): BaseSearchFormModel {
|
|
7
|
-
return { ...(model || {}) }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function getVisibleSearchFields(
|
|
11
|
-
fields: BaseSearchFormField[],
|
|
12
|
-
collapsed: boolean
|
|
13
|
-
): BaseSearchFormField[] {
|
|
14
|
-
return fields.filter((field) => {
|
|
15
|
-
if (field.hidden) {
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return !collapsed || !field.collapsed
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function resetSearchFormModel(fields: BaseSearchFormField[]): BaseSearchFormModel {
|
|
24
|
-
return fields.reduce<BaseSearchFormModel>((model, field) => {
|
|
25
|
-
if (field.type === 'dateRange') {
|
|
26
|
-
model[field.key] = []
|
|
27
|
-
return model
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
model[field.key] = ''
|
|
31
|
-
return model
|
|
32
|
-
}, {})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function toSearchFormCssValue(value?: string | number) {
|
|
36
|
-
if (value === undefined || value === null || value === '') {
|
|
37
|
-
return undefined
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return typeof value === 'number' ? `${value}px` : value
|
|
41
|
-
}
|