xrk-components 0.3.0 → 0.3.3

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 (62) hide show
  1. package/lib/index.css +7 -2
  2. package/lib/index.esm.js +107 -46
  3. package/lib/index.umd.js +107 -46
  4. package/lib/packages/base/button/index.d.ts +1 -1
  5. package/lib/packages/base/dialog/dialog.d.ts +11 -0
  6. package/lib/packages/base/dialog/index.d.ts +4 -3
  7. package/lib/packages/base/select/index.d.ts +4 -1
  8. package/lib/packages/xrk/table/table.d.ts +0 -13
  9. package/lib/packages/xrk/table/types/type.d.ts +2 -2
  10. package/package.json +1 -1
  11. package/packages/base/button/button.vue +0 -83
  12. package/packages/base/button/index.ts +0 -26
  13. package/packages/base/checkbox/checkbox-button.vue +0 -54
  14. package/packages/base/checkbox/checkbox-group.vue +0 -85
  15. package/packages/base/checkbox/checkbox.vue +0 -85
  16. package/packages/base/checkbox/index.ts +0 -62
  17. package/packages/base/date-picker/date-picker.vue +0 -144
  18. package/packages/base/date-picker/index.ts +0 -52
  19. package/packages/base/dialog/dialog.vue +0 -214
  20. package/packages/base/dialog/index.ts +0 -57
  21. package/packages/base/form/form-item.vue +0 -57
  22. package/packages/base/form/form.vue +0 -70
  23. package/packages/base/form/index.ts +0 -39
  24. package/packages/base/input/index.ts +0 -50
  25. package/packages/base/input/input.vue +0 -175
  26. package/packages/base/pagination/index.ts +0 -30
  27. package/packages/base/pagination/pagination.vue +0 -160
  28. package/packages/base/radio/index.ts +0 -49
  29. package/packages/base/radio/radio-button.vue +0 -46
  30. package/packages/base/radio/radio-group.vue +0 -77
  31. package/packages/base/radio/radio.vue +0 -74
  32. package/packages/base/select/index.ts +0 -62
  33. package/packages/base/select/select.vue +0 -258
  34. package/packages/base/switch/index.ts +0 -26
  35. package/packages/base/switch/switch.vue +0 -103
  36. package/packages/base/table/hooks/use-table.ts +0 -15
  37. package/packages/base/table/index.ts +0 -16
  38. package/packages/base/table/store/index.ts +0 -35
  39. package/packages/base/table/table-column.vue +0 -351
  40. package/packages/base/table/table.vue +0 -168
  41. package/packages/base/table/types/type.ts +0 -123
  42. package/packages/base/tag/index.ts +0 -52
  43. package/packages/base/tag/tag-group.vue +0 -182
  44. package/packages/base/tag/tag.vue +0 -54
  45. package/packages/base/tool-tip/index.ts +0 -30
  46. package/packages/base/tool-tip/tool-tip.vue +0 -108
  47. package/packages/components.ts +0 -33
  48. package/packages/functions.ts +0 -16
  49. package/packages/index.ts +0 -30
  50. package/packages/types.ts +0 -54
  51. package/packages/xrk/search/hooks/use-search.ts +0 -96
  52. package/packages/xrk/search/index.ts +0 -22
  53. package/packages/xrk/search/search.vue +0 -197
  54. package/packages/xrk/search/types/type.ts +0 -95
  55. package/packages/xrk/table/hooks/use-table.tsx +0 -34
  56. package/packages/xrk/table/index.ts +0 -10
  57. package/packages/xrk/table/table.vue +0 -218
  58. package/packages/xrk/table/types/type.ts +0 -31
  59. package/rollup.config.js +0 -59
  60. package/styles/element/index.scss +0 -5
  61. package/styles/element/mixin.scss +0 -40
  62. package/tools/check.ts +0 -9
@@ -15,9 +15,10 @@ export declare type BaseDialogProps = {
15
15
  width?: string | number;
16
16
  title?: string;
17
17
  content?: string;
18
- titleRender?: () => Component;
19
- contentRender?: () => Component;
20
- footerRender?: () => Component;
18
+ showFooter?: boolean;
19
+ titleRender?: (done: Function) => Component;
20
+ contentRender?: (done: Function) => Component;
21
+ footerRender?: (done: Function) => Component;
21
22
  confirmBtnConfig?: DialogBtnConfigProps;
22
23
  cancelBtnConfig?: DialogBtnConfigProps;
23
24
  onClose?: () => Promise<void> | void;
@@ -26,8 +26,11 @@ export interface BaseSelectProps {
26
26
  filterable?: boolean;
27
27
  allowCreate?: boolean;
28
28
  fitInputWidth?: boolean;
29
+ /**
30
+ * 自定义筛选方法
31
+ */
29
32
  filterMethod?: (searchVal: string) => Array<SelectValueType>;
30
- remoteMethod?: Function;
33
+ remoteMethod?: (searchVal?: string) => any;
31
34
  loadingText?: string;
32
35
  noMatchText?: string;
33
36
  noDataText?: string;
@@ -19,12 +19,6 @@ declare const _default: import("vue").DefineComponent<{
19
19
  paginationConfig: {
20
20
  type: ObjectConstructor;
21
21
  required: false;
22
- default: () => {
23
- pageNoKey: string;
24
- pageSizeKey: string;
25
- paginationPageSize: number;
26
- paginationCurrentPage: number;
27
- };
28
22
  };
29
23
  }, (_ctx: any, _cache: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
30
24
  [key: string]: any;
@@ -49,15 +43,8 @@ declare const _default: import("vue").DefineComponent<{
49
43
  paginationConfig: {
50
44
  type: ObjectConstructor;
51
45
  required: false;
52
- default: () => {
53
- pageNoKey: string;
54
- pageSizeKey: string;
55
- paginationPageSize: number;
56
- paginationCurrentPage: number;
57
- };
58
46
  };
59
47
  }>>, {
60
48
  requestNow: boolean;
61
- paginationConfig: Record<string, any>;
62
49
  }>;
63
50
  export default _default;
@@ -15,7 +15,7 @@ export declare type XrkTableProps = {
15
15
  paginationConfig?: {
16
16
  pageNoKey?: string;
17
17
  pageSizeKey?: string;
18
- paginationPageSize: number;
19
- paginationCurrentPage: number;
18
+ paginationPageSize?: number;
19
+ paginationCurrentPage?: number;
20
20
  };
21
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xrk-components",
3
- "version": "0.3.0",
3
+ "version": "0.3.3",
4
4
  "description": "",
5
5
  "main": "lib/index.esm.js",
6
6
  "typings": "lib/packages/index.d.ts",
@@ -1,83 +0,0 @@
1
- <!--
2
- * @Description:
3
- * @Date: 2022-06-21 11:14:09
4
- -->
5
- <template>
6
- <el-button
7
- @click="handleClick"
8
- :loading="isLoading"
9
- :size="size"
10
- :type="type"
11
- :plain="plain"
12
- :round="round"
13
- :circle="circle"
14
- :disabled="disabled"
15
- :autofocus="autofocus"
16
- :autoInsertSpace="autoInsertSpace"
17
- :nativeType="nativeType"
18
- :loadingIcon="loadingIcon"
19
- :icon="icon"
20
- >
21
- <slot></slot>
22
- </el-button>
23
- </template>
24
-
25
- <script lang="tsx">
26
- export default {
27
- name: 'base-button'
28
- };
29
- </script>
30
-
31
- <script lang="tsx" setup>
32
- import { Component, computed, ref } from 'vue';
33
- import { ElButton } from 'element-plus';
34
- import { BaseButtonProps } from './index';
35
-
36
- const _props = withDefaults(
37
- defineProps<{
38
- click?: any; // 自定义方法 , 用于事件同步执行
39
- loading?: boolean; // 是否为加载中状态
40
- loadingIcon?: any; // 自定义加载中状态图标组件
41
- size?: 'large' | 'default' | 'small'; // 尺寸
42
- type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
43
- plain?: boolean; // 是否为朴素按钮
44
- round?: boolean; // 是否为圆角按钮
45
- circle?: boolean; // 是否为圆形按钮
46
- disabled?: boolean; // 按钮是否为禁用状态
47
- autofocus?: boolean; // 原生 autofocus 属性
48
- autoInsertSpace?: boolean; // 自动在两个中文字符之间插入空格
49
- nativeType?: 'button' | 'submit' | 'reset'; // 原生 type 属性
50
- icon?: any; // 图标组件
51
- }>(),
52
- {
53
- type: 'primary',
54
- size: 'default'
55
- }
56
- );
57
-
58
- const props = _props as Readonly<BaseButtonProps>;
59
-
60
- const { handleClick, isLoading } = (() => {
61
- const _loading = ref<boolean>(false);
62
- const isLoading = computed(() => {
63
- return props.loading || _loading.value;
64
- });
65
- return {
66
- isLoading: isLoading,
67
- handleClick: (props.click
68
- ? async () => {
69
- _loading.value = true;
70
- try {
71
- await props.click?.();
72
- _loading.value = false;
73
- } catch (error) {
74
- console.warn(error);
75
- _loading.value = false;
76
- }
77
- }
78
- : undefined) as ((evt: MouseEvent) => any) | undefined
79
- };
80
- })();
81
- </script>
82
-
83
- <style lang="scss" scoped></style>
@@ -1,26 +0,0 @@
1
- /*
2
- * @Description:
3
- * @Date: 2022-06-30 22:57:42
4
- */
5
- import { Component, DefineComponent } from 'vue';
6
- import _BaseButton from './button.vue';
7
-
8
- export type BaseButtonProps = {
9
- click?: (...preload: Array<any>) => Promise<any> | void | any; // 自定义方法 , 用于事件同步执行
10
- loading?: boolean; // 是否为加载中状态
11
- loadingIcon?: string | Component; // 自定义加载中状态图标组件
12
- size?: 'large' | 'default' | 'small'; // 尺寸
13
- type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
14
- plain?: boolean; // 是否为朴素按钮
15
- round?: boolean; // 是否为圆角按钮
16
- circle?: boolean; // 是否为圆形按钮
17
- disabled?: boolean; // 按钮是否为禁用状态
18
- autofocus?: boolean; // 原生 autofocus 属性
19
- autoInsertSpace?: boolean; // 自动在两个中文字符之间插入空格
20
- nativeType?: 'button' | 'submit' | 'reset'; // 原生 type 属性
21
- icon?: string | Component; // 图标组件
22
-
23
- onClick?: Function;
24
- };
25
-
26
- export const BaseButton = _BaseButton as DefineComponent<BaseButtonProps>;
@@ -1,54 +0,0 @@
1
- <!--
2
- * @Description:
3
- * @Date: 2022-06-21 11:16:37
4
- -->
5
- <template>
6
- <el-checkbox-button
7
- :model-value="modelValue"
8
- :size="size"
9
- :name="name"
10
- :label="label"
11
- :disabled="disabled"
12
- :border="border"
13
- :true-label="trueLabel"
14
- :false-label="falseLabel"
15
- :checked="checked"
16
- @change="handleChange"
17
- >
18
- <slot></slot>
19
- </el-checkbox-button>
20
- </template>
21
-
22
- <script lang="tsx">
23
- export default {
24
- name: 'base-checkbox-button'
25
- };
26
- </script>
27
-
28
- <script lang="tsx" setup>
29
- import { ElCheckboxButton } from 'element-plus';
30
-
31
- defineProps<{
32
- modelValue?: string | number | boolean; // 选中项绑定值
33
- size?: 'large' | 'default' | 'small'; // Checkbox 的尺寸
34
- name?: string; // 原生 name 属性
35
- label?: string | number | boolean; // 选中状态的值(只有在checkbox-group或者绑定对象类型为array时有效)
36
- disabled?: boolean; // 是否禁用
37
- border?: boolean; // 是否显示边框
38
- trueLabel?: string | number; // 选中时的值
39
- falseLabel?: string | number; // 没有选中时的值
40
- checked?: boolean; // 当前是否勾选
41
- }>();
42
-
43
- const emits = defineEmits<{
44
- (event: 'change', activeValue: any): void;
45
- (event: 'update:modelValue', activeValue: any): void;
46
- }>();
47
-
48
- const handleChange = (activeValue: any) => {
49
- emits('update:modelValue', activeValue);
50
- emits('change', activeValue);
51
- };
52
- </script>
53
-
54
- <style lang="scss" scoped></style>
@@ -1,85 +0,0 @@
1
- <!--
2
- * @Description:
3
- * @Date: 2022-06-21 11:16:37
4
- -->
5
- <template>
6
- <el-checkbox-group
7
- class="base-checkbox-group"
8
- :model-value="modelValue"
9
- :size="size"
10
- :disabled="disabled"
11
- :text-color="textColor"
12
- :fill="fill"
13
- :label="label"
14
- :min="min"
15
- :max="max"
16
- @change="handleChange"
17
- >
18
- <div style="display: inline-block" v-loading="_loading">
19
- <slot></slot>
20
- </div>
21
- </el-checkbox-group>
22
- </template>
23
-
24
- <script lang="tsx">
25
- export default {
26
- name: 'base-checkbox-group'
27
- };
28
- </script>
29
-
30
- <script lang="tsx" setup>
31
- import { ref } from 'vue';
32
- import { ElCheckboxGroup, vLoading as _vLoading } from 'element-plus';
33
- import { isFunction } from '../../../tools/check';
34
-
35
- const vLoading = _vLoading;
36
- const props = defineProps<{
37
- modelValue?: Array<any>; // 绑定值
38
- size?: 'large' | 'default' | 'small'; // 多选框组尺寸
39
- disabled?: boolean; // 是否禁用
40
- textColor?: string; // 当按钮为活跃状态时的字体颜色
41
- fill?: string; // 当按钮为活跃状态时的边框和背景颜色
42
- label?: string; // 为屏幕阅读器准备的标签
43
- min?: number; // 可被勾选的 checkbox 的最小数量
44
- max?: number; // 可被勾选的 checkbox 的最大数量
45
-
46
- checkBefore?: (activeValue: any, done: Function) => void;
47
- }>();
48
-
49
- const emits = defineEmits<{
50
- (event: 'change', activeValue: any): void;
51
- (event: 'update:modelValue', activeValue: any): void;
52
- }>();
53
-
54
- const _loading = ref(false);
55
-
56
- const handleChange = async (activeValue: any) => {
57
- if (_loading.value) return;
58
- _loading.value = true;
59
- try {
60
- if (
61
- (props.modelValue?.length || 0) < activeValue?.length &&
62
- isFunction(props.checkBefore)
63
- ) {
64
- await props.checkBefore(activeValue, () => {
65
- emits('update:modelValue', activeValue);
66
- emits('change', activeValue);
67
- });
68
- } else {
69
- emits('update:modelValue', activeValue);
70
- emits('change', activeValue);
71
- }
72
- } catch (error) {}
73
- _loading.value = false;
74
- };
75
- </script>
76
-
77
- <style lang="scss" scoped>
78
- .base-checkbox-group {
79
- ::v-deep {
80
- .xrk-loading-spinner .circular {
81
- width: 20px;
82
- }
83
- }
84
- }
85
- </style>
@@ -1,85 +0,0 @@
1
- <!--
2
- * @Description:
3
- * @Date: 2022-06-21 11:16:37
4
- -->
5
- <template>
6
- <el-checkbox
7
- class="base-checkbox"
8
- :model-value="modelValue"
9
- :size="size"
10
- :name="name"
11
- :label="label"
12
- :disabled="disabled"
13
- :border="border"
14
- :true-label="trueLabel"
15
- :false-label="falseLabel"
16
- :checked="checked"
17
- :indeterminate="indeterminate"
18
- v-loading="_loading"
19
- @change="handleChange"
20
- >
21
- <slot></slot>
22
- </el-checkbox>
23
- </template>
24
-
25
- <script lang="tsx">
26
- export default {
27
- name: 'base-checkbox'
28
- };
29
- </script>
30
-
31
- <script lang="tsx" setup>
32
- import { ref } from 'vue';
33
- import { ElCheckbox, vLoading as _vLoading } from 'element-plus';
34
- import { isFunction } from '../../../tools/check';
35
-
36
- const vLoading = _vLoading;
37
- const props = defineProps<{
38
- modelValue?: string | number | boolean; // 选中项绑定值
39
- size?: 'large' | 'default' | 'small'; // Checkbox 的尺寸
40
- name?: string; // 原生 name 属性
41
- label?: string | number | boolean; // 选中状态的值(只有在checkbox-group或者绑定对象类型为array时有效)
42
- disabled?: boolean; // 是否禁用
43
- border?: boolean; // 是否显示边框
44
- trueLabel?: string | number; // 选中时的值
45
- falseLabel?: string | number; // 没有选中时的值
46
- checked?: boolean; // 当前是否勾选
47
- indeterminate?: boolean; // 设置 indeterminate 状态,只负责样式控制
48
-
49
- checkBefore?: (activeValue: any, done: Function) => void;
50
- }>();
51
-
52
- const emits = defineEmits<{
53
- (event: 'change', activeValue: any): void;
54
- (event: 'update:modelValue', activeValue: any): void;
55
- }>();
56
-
57
- const _loading = ref(false);
58
-
59
- const handleChange = async (activeValue: any) => {
60
- if (_loading.value) return;
61
- _loading.value = true;
62
- try {
63
- if (activeValue && isFunction(props.checkBefore)) {
64
- await props.checkBefore(activeValue, () => {
65
- emits('update:modelValue', activeValue);
66
- emits('change', activeValue);
67
- });
68
- } else {
69
- emits('update:modelValue', activeValue);
70
- emits('change', activeValue);
71
- }
72
- } catch (error) {}
73
- _loading.value = false;
74
- };
75
- </script>
76
-
77
- <style lang="scss" scoped>
78
- .base-checkbox {
79
- ::v-deep {
80
- .xrk-loading-spinner .circular {
81
- width: 20px;
82
- }
83
- }
84
- }
85
- </style>
@@ -1,62 +0,0 @@
1
- /*
2
- * @Description:
3
- * @Date: 2022-07-01 10:29:26
4
- */
5
- import { DefineComponent } from 'vue';
6
- import _BaseCheckboxButton from './checkbox-button.vue';
7
- import _BaseCheckboxGroup from './checkbox-group.vue';
8
- import _BaseCheckbox from './checkbox.vue';
9
-
10
- export type BaseCheckboxButtonProps = {
11
- modelValue?: string | number | boolean; // 选中项绑定值
12
- size?: 'large' | 'default' | 'small'; // Checkbox 的尺寸
13
- name?: string; // 原生 name 属性
14
- label?: string | number | boolean; // 选中状态的值(只有在checkbox-group或者绑定对象类型为array时有效)
15
- disabled?: boolean; // 是否禁用
16
- border?: boolean; // 是否显示边框
17
- trueLabel?: string | number; // 选中时的值
18
- falseLabel?: string | number; // 没有选中时的值
19
- checked?: boolean; // 当前是否勾选
20
-
21
- onChange?: (activeValue: any) => void;
22
- onClick?: (payload?: MouseEvent) => void;
23
- };
24
-
25
- export type BaseCheckboxGroupProps = {
26
- modelValue?: Array<any>; // 绑定值
27
- size?: 'large' | 'default' | 'small'; // 多选框组尺寸
28
- disabled?: boolean; // 是否禁用
29
- textColor?: string; // 当按钮为活跃状态时的字体颜色
30
- fill?: string; // 当按钮为活跃状态时的边框和背景颜色
31
- label?: string; // 为屏幕阅读器准备的标签
32
- min?: number; // 可被勾选的 checkbox 的最小数量
33
- max?: number; // 可被勾选的 checkbox 的最大数量
34
- checkBefore?: (activeValue: any, done: Function) => void;
35
-
36
- onChange?: (activeValue: any) => void;
37
- };
38
-
39
- export type BaseCheckboxProps = {
40
- modelValue?: string | number | boolean; // 选中项绑定值
41
- size?: 'large' | 'default' | 'small'; // Checkbox 的尺寸
42
- name?: string; // 原生 name 属性
43
- label?: string | number | boolean; // 选中状态的值(只有在checkbox-group或者绑定对象类型为array时有效)
44
- disabled?: boolean; // 是否禁用
45
- border?: boolean; // 是否显示边框
46
- trueLabel?: string | number; // 选中时的值
47
- falseLabel?: string | number; // 没有选中时的值
48
- checked?: boolean; // 当前是否勾选
49
- indeterminate?: boolean; // 设置 indeterminate 状态,只负责样式控制
50
- checkBefore?: (activeValue: any, done: Function) => void;
51
-
52
- onChange?: (activeValue: any) => void;
53
- onClick?: (payload?: MouseEvent) => void;
54
- };
55
-
56
- export const BaseCheckboxButton =
57
- _BaseCheckboxButton as DefineComponent<BaseCheckboxButtonProps>;
58
-
59
- export const BaseCheckboxGroup =
60
- _BaseCheckboxGroup as DefineComponent<BaseCheckboxGroupProps>;
61
-
62
- export const BaseCheckbox = _BaseCheckbox as DefineComponent<BaseCheckboxProps>;
@@ -1,144 +0,0 @@
1
- <!--
2
- * @Description:
3
- * @Date: 2022-06-21 11:17:01
4
- -->
5
- <template>
6
- <el-date-picker
7
- v-model="dateValue"
8
- :readonly="readonly"
9
- :disabled="disabled"
10
- :size="size"
11
- :editable="editable"
12
- :clearable="clearable"
13
- :placeholder="placeholder"
14
- :start-placeholder="startPlaceholder"
15
- :end-placeholder="endPlaceholder"
16
- :type="type"
17
- :format="format"
18
- :popper-class="popperClass"
19
- :range-separator="rangeSeparator"
20
- :default-value="defaultValue"
21
- :default-time="defaultTime"
22
- :value-format="valueFormat"
23
- :unlink-panels="unlinkPanels"
24
- :prefix-icon="prefixIcon"
25
- :clear-icon="clearIcon"
26
- :validate-event="validateEvent"
27
- :disabled-date="_disabledDate"
28
- :shortcuts="shortcuts"
29
- :cell-class-name="cellClassName"
30
- :teleported="teleported"
31
- @change="handleChange"
32
- @visible-change="handleVisibleChange"
33
- @calendar-change="handleCalendarChange"
34
- ></el-date-picker>
35
- </template>
36
-
37
- <script lang="tsx">
38
- export default {
39
- name: 'base-date-picker'
40
- };
41
- </script>
42
- <script lang="tsx" setup>
43
- import { withDefaults, ref, Component, computed, watch } from 'vue';
44
- import { ElDatePicker } from 'element-plus';
45
- import { isFunction } from '../../../tools/check';
46
- import { BaseDatePickerProps } from './index';
47
-
48
- const _props = withDefaults(
49
- defineProps<{
50
- modelValue?: any; // 选中项绑定值
51
- readonly?: boolean; // 只读
52
- disabled?: boolean; // 禁用
53
- size?: 'large' | 'default' | 'small'; // 输入框尺寸
54
- editable?: boolean; // 文本框可输入
55
- clearable?: boolean; // 是否显示清除按钮
56
- placeholder?: string; // 非范围选择时的占位内容
57
- startPlaceholder?: string; // 范围选择时开始日期的占位内容
58
- endPlaceholder?: string; // 范围选择时结束日期的占位内容
59
- type?:
60
- | 'year'
61
- | 'month'
62
- | 'date'
63
- | 'dates'
64
- | 'datetime'
65
- | 'week'
66
- | 'datetimerange'
67
- | 'daterange'
68
- | 'monthrange'; // 显示类型
69
- format?: string; // 显示在输入框中的格式
70
- popperClass?: string; // DatePicker 下拉框的类名
71
- rangeSeparator?: string; // 选择范围时的分隔符
72
- defaultValue?: any; // 可选,选择器打开时默认显示的时间
73
- defaultTime?: any; // 范围选择时选中日期所使用的当日内具体时刻
74
- valueFormat?: string; // 可选,绑定值的格式。 不指定则绑定值为 Date 对象
75
- unlinkPanels?: boolean; // 在范围选择器里取消两个日期面板之间的联动
76
- prefixIcon?: any; // 自定义前缀图标
77
- clearIcon?: any; // 自定义清除图标
78
- validateEvent?: boolean; // 输入时是否触发表单的校验
79
- disabledDate?: (date: Date, startDt: Date | null) => boolean; // 一个用来判断该日期是否被禁用的函数,接受一个 Date 对象作为参数。 应该返回一个 Boolean 值。
80
- shortcuts?: any; // 设置快捷选项,需要传入数组对象
81
- cellClassName?: (date: Date) => string; // 设置自定义类名
82
- teleported?: boolean; // 是否将 date-picker 的下拉列表插入至 body 元素
83
- }>(),
84
- {
85
- type: 'date',
86
- placeholder: '请选择日期',
87
- startPlaceholder: '请选择开始日期',
88
- endPlaceholder: '请选择结束日期',
89
- teleported: true,
90
- clearable: true
91
- }
92
- );
93
-
94
- const props = _props as Readonly<BaseDatePickerProps>;
95
-
96
- const emits = defineEmits<{
97
- (event: 'change', activeValue: any): void;
98
- (event: 'visibleChange', visibility: boolean): void;
99
- (event: 'calendarChange', val: [Date, Date | null]): void;
100
- (event: 'update:modelValue', activeValue: any): void;
101
- }>();
102
-
103
- // 越过类型不匹配导致的ts报错
104
- const defaultTime = computed(() => props.defaultTime) as any;
105
-
106
- const valueFormat = computed(
107
- () =>
108
- props.valueFormat ||
109
- (props.type &&
110
- (['datetime', 'datetimerange'].includes(props.type)
111
- ? 'YYYY-MM-DD HH:mm:ss'
112
- : 'YYYY-MM-DD'))
113
- );
114
-
115
- const startDt = ref<Date | null>(null);
116
- const dateValue = ref<any>(props.modelValue);
117
- // 父组件值发生改变时,同步dateValue
118
- watch(
119
- () => props.modelValue,
120
- newV => {
121
- dateValue.value = newV;
122
- }
123
- );
124
-
125
- const _disabledDate = (date: Date) => {
126
- if (isFunction(props?.disabledDate)) {
127
- return props?.disabledDate?.(date, startDt.value);
128
- }
129
- };
130
-
131
- const handleChange: any = (val: typeof props.modelValue) => {
132
- emits('update:modelValue', val);
133
- emits('change', val);
134
- };
135
- const handleVisibleChange: any = (visibility: boolean) => {
136
- emits('visibleChange', visibility);
137
- };
138
- const handleCalendarChange: any = (val: [Date, Date | null]) => {
139
- startDt.value = val[0];
140
- emits('calendarChange', val);
141
- };
142
- </script>
143
-
144
- <style lang="scss" scoped></style>
@@ -1,52 +0,0 @@
1
- /*
2
- * @Description:
3
- * @Date: 2022-06-29 19:10:13
4
- */
5
- import { Component, DefineComponent } from 'vue';
6
- import _BaseDatePicker from './date-picker.vue';
7
-
8
- export type BaseDatePickerProps = {
9
- modelValue?: string | Date | Array<Date | string>; // 选中项绑定值
10
- readonly?: boolean; // 只读
11
- disabled?: boolean; // 禁用
12
- size?: 'large' | 'default' | 'small'; // 输入框尺寸
13
- editable?: boolean; // 文本框可输入
14
- clearable?: boolean; // 是否显示清除按钮
15
- placeholder?: string; // 非范围选择时的占位内容
16
- startPlaceholder?: string; // 范围选择时开始日期的占位内容
17
- endPlaceholder?: string; // 范围选择时结束日期的占位内容
18
- type?:
19
- | 'year'
20
- | 'month'
21
- | 'date'
22
- | 'dates'
23
- | 'datetime'
24
- | 'week'
25
- | 'datetimerange'
26
- | 'daterange'
27
- | 'monthrange'; // 显示类型
28
- format?: string; // 显示在输入框中的格式
29
- popperClass?: string; // DatePicker 下拉框的类名
30
- rangeSeparator?: string; // 选择范围时的分隔符
31
- defaultValue?: Date; // 可选,选择器打开时默认显示的时间
32
- defaultTime?: Array<Date>; // 范围选择时选中日期所使用的当日内具体时刻
33
- valueFormat?: string; // 可选,绑定值的格式。 不指定则绑定值为 Date 对象
34
- unlinkPanels?: boolean; // 在范围选择器里取消两个日期面板之间的联动
35
- prefixIcon?: string | Component; // 自定义前缀图标
36
- clearIcon?: string | Component; // 自定义清除图标
37
- validateEvent?: boolean; // 输入时是否触发表单的校验
38
- disabledDate?: (date: Date, startDt: Date | null) => boolean; // 一个用来判断该日期是否被禁用的函数,接受一个 Date 对象作为参数。 应该返回一个 Boolean 值。
39
- shortcuts?: Array<{
40
- text: string;
41
- value: Date | (() => void);
42
- }>; // 设置快捷选项,需要传入数组对象
43
- cellClassName?: (date: Date) => string; // 设置自定义类名
44
- teleported?: boolean; // 是否将 date-picker 的下拉列表插入至 body 元素
45
-
46
- onChange?: (activeValue: any) => void;
47
- onVisibleChange?: (visibility: boolean) => void;
48
- onCalendarChange?: (val: [Date, Date | null]) => void;
49
- };
50
-
51
- export const BaseDatePicker =
52
- _BaseDatePicker as DefineComponent<BaseDatePickerProps>;