hy-app 0.6.4 → 0.6.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/attributes.json +1 -1
- package/components/hy-address-picker/hy-address-picker.vue +249 -249
- package/components/hy-address-picker/props.ts +103 -103
- package/components/hy-button/hy-button.vue +320 -289
- package/components/hy-button/props.ts +143 -143
- package/components/hy-button/typing.d.ts +43 -35
- package/components/hy-calendar/header.vue +58 -58
- package/components/hy-calendar/hy-calendar.vue +8 -6
- package/components/hy-calendar/month.vue +402 -402
- package/components/hy-calendar/props.ts +169 -169
- package/components/hy-calendar/typing.d.ts +47 -45
- package/components/hy-cell-item/hy-cell-item.vue +161 -161
- package/components/hy-cell-item/props.ts +59 -59
- package/components/hy-check-button/hy-check-button.vue +135 -135
- package/components/hy-code-input/hy-code-input.vue +231 -231
- package/components/hy-code-input/props.ts +90 -90
- package/components/hy-config-provider/hy-config-provider.vue +53 -53
- package/components/hy-config-provider/props.ts +30 -30
- package/components/hy-coupon/hy-coupon.vue +183 -183
- package/components/hy-coupon/props.ts +108 -108
- package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
- package/components/hy-datetime-picker/props.ts +144 -144
- package/components/hy-datetime-picker/typing.d.ts +2 -0
- package/components/hy-divider/props.ts +83 -83
- package/components/hy-empty/icon.ts +72 -72
- package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
- package/components/hy-form/hy-form.vue +220 -220
- package/components/hy-icon/hy-icon.vue +112 -112
- package/components/hy-index-bar/hy-index-bar.vue +185 -185
- package/components/hy-index-bar/index.scss +64 -64
- package/components/hy-index-bar/props.ts +94 -94
- package/components/hy-index-bar/typing.d.ts +36 -36
- package/components/hy-input/hy-input.vue +333 -333
- package/components/hy-input/props.ts +186 -186
- package/components/hy-modal/hy-modal.vue +211 -211
- package/components/hy-modal/props.ts +94 -94
- package/components/hy-modal/typing.d.ts +16 -16
- package/components/hy-notice-bar/hy-row-notice.vue +121 -121
- package/components/hy-notify/hy-notify.vue +174 -174
- package/components/hy-number-step/hy-number-step.vue +367 -367
- package/components/hy-overlay/hy-overlay.vue +61 -61
- package/components/hy-overlay/props.ts +38 -38
- package/components/hy-pagination/hy-pagination.vue +136 -136
- package/components/hy-pagination/props.ts +58 -58
- package/components/hy-parse/hy-parse.vue +550 -550
- package/components/hy-parse/node/node.vue +781 -781
- package/components/hy-parse/parser.js +1455 -1455
- package/components/hy-parse/props.ts +19 -19
- package/components/hy-parse/typing.d.ts +68 -68
- package/components/hy-picker/hy-picker.vue +435 -435
- package/components/hy-picker/props.ts +122 -122
- package/components/hy-picker/typing.d.ts +38 -38
- package/components/hy-qrcode/props.ts +72 -72
- package/components/hy-qrcode/qrcode.js.bak +1433 -1433
- package/components/hy-radio/props.ts +97 -97
- package/components/hy-read-more/props.ts +48 -48
- package/components/hy-search/props.ts +133 -133
- package/components/hy-signature/canvasHelper.ts +51 -51
- package/components/hy-signature/props.ts +121 -121
- package/components/hy-skeleton/hy-skeleton.vue +142 -142
- package/components/hy-skeleton/props.ts +46 -46
- package/components/hy-skeleton/typing.d.ts +31 -31
- package/components/hy-steps/hy-steps.vue +275 -275
- package/components/hy-steps/typing.d.ts +25 -25
- package/components/hy-swiper/hy-swiper.vue +3 -3
- package/components/hy-swiper/index.scss +5 -5
- package/components/hy-swiper/props.ts +0 -1
- package/components/hy-table/hy-table.vue +630 -630
- package/components/hy-table/props.ts +62 -62
- package/components/hy-table/typing.d.ts +29 -29
- package/components/hy-tabs/hy-tabs.vue +336 -335
- package/components/hy-tabs/props.ts +84 -77
- package/components/hy-tag/hy-tag.vue +173 -173
- package/components/hy-tag/props.ts +89 -89
- package/components/hy-text/hy-text.vue +237 -237
- package/components/hy-text/props.ts +115 -115
- package/components/hy-textarea/hy-textarea.vue +198 -198
- package/components/hy-toast/hy-toast.vue +200 -200
- package/components/hy-toast/props.ts +3 -3
- package/components/hy-transition/hy-transition.vue +157 -157
- package/components/hy-transition/props.ts +32 -32
- package/components/hy-upload/hy-upload.vue +384 -384
- package/components/hy-watermark/hy-watermark.vue +1058 -1058
- package/components/hy-watermark/props.ts +109 -109
- package/global.d.ts +94 -94
- package/libs/api/http.ts +119 -119
- package/libs/composables/index.ts +8 -8
- package/libs/composables/useMessage.ts +149 -149
- package/libs/composables/useToast.ts +45 -45
- package/libs/composables/useTranslate.ts +10 -10
- package/libs/css/_config.scss +5 -5
- package/libs/index.ts +8 -8
- package/libs/locale/index.ts +32 -32
- package/libs/locale/lang/en-US.ts +84 -84
- package/libs/locale/lang/zh-CN.ts +87 -87
- package/libs/typing/index.ts +2 -2
- package/libs/typing/modules/common.d.ts +139 -139
- package/libs/typing/modules/form.ts +176 -176
- package/libs/typing/modules/http.d.ts +19 -19
- package/libs/typing/modules/index.d.ts +12 -12
- package/libs/utils/inside.ts +340 -340
- package/libs/utils/inspect.ts +140 -140
- package/libs/utils/utils.ts +525 -525
- package/package.json +81 -81
- package/tags.json +1 -1
- package/web-types.json +1 -1
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<hy-transition
|
|
3
|
-
:show="show"
|
|
4
|
-
:custom-class="`hy-overlay ${customClass}`"
|
|
5
|
-
:duration="duration"
|
|
6
|
-
:custom-style="overlayStyle"
|
|
7
|
-
@click="clickHandler"
|
|
8
|
-
>
|
|
9
|
-
<slot />
|
|
10
|
-
</hy-transition>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
export default {
|
|
15
|
-
name: 'hy-overlay',
|
|
16
|
-
options: {
|
|
17
|
-
addGlobalClass: true,
|
|
18
|
-
virtualHost: true,
|
|
19
|
-
styleIsolation: 'shared'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<script setup lang="ts">
|
|
25
|
-
import { computed } from 'vue'
|
|
26
|
-
import type { CSSProperties } from 'vue'
|
|
27
|
-
import type { IOverlayEmits } from './typing'
|
|
28
|
-
import overlayProps from './props'
|
|
29
|
-
// 组件
|
|
30
|
-
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
|
|
34
|
-
* @displayName hy-overlay
|
|
35
|
-
*/
|
|
36
|
-
defineOptions({})
|
|
37
|
-
|
|
38
|
-
const props = defineProps(overlayProps)
|
|
39
|
-
const emit = defineEmits<IOverlayEmits>()
|
|
40
|
-
|
|
41
|
-
const overlayStyle = computed<CSSProperties>(() => {
|
|
42
|
-
const style: CSSProperties = {
|
|
43
|
-
position: 'fixed',
|
|
44
|
-
top: 0,
|
|
45
|
-
left: 0,
|
|
46
|
-
right: 0,
|
|
47
|
-
zIndex: props.zIndex,
|
|
48
|
-
bottom: 0,
|
|
49
|
-
pointerEvents: !props.LockScroll ? 'none' : 'auto',
|
|
50
|
-
'background-color': `rgba(0, 0, 0, ${props.opacity})`
|
|
51
|
-
}
|
|
52
|
-
return Object.assign(style, props.customStyle)
|
|
53
|
-
})
|
|
54
|
-
const clickHandler = () => {
|
|
55
|
-
emit('click')
|
|
56
|
-
}
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
|
-
<style lang="scss" scoped>
|
|
60
|
-
@import './index.scss';
|
|
61
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<hy-transition
|
|
3
|
+
:show="show"
|
|
4
|
+
:custom-class="`hy-overlay ${customClass}`"
|
|
5
|
+
:duration="duration"
|
|
6
|
+
:custom-style="overlayStyle"
|
|
7
|
+
@click="clickHandler"
|
|
8
|
+
>
|
|
9
|
+
<slot />
|
|
10
|
+
</hy-transition>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
export default {
|
|
15
|
+
name: 'hy-overlay',
|
|
16
|
+
options: {
|
|
17
|
+
addGlobalClass: true,
|
|
18
|
+
virtualHost: true,
|
|
19
|
+
styleIsolation: 'shared'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import { computed } from 'vue'
|
|
26
|
+
import type { CSSProperties } from 'vue'
|
|
27
|
+
import type { IOverlayEmits } from './typing'
|
|
28
|
+
import overlayProps from './props'
|
|
29
|
+
// 组件
|
|
30
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
|
|
34
|
+
* @displayName hy-overlay
|
|
35
|
+
*/
|
|
36
|
+
defineOptions({})
|
|
37
|
+
|
|
38
|
+
const props = defineProps(overlayProps)
|
|
39
|
+
const emit = defineEmits<IOverlayEmits>()
|
|
40
|
+
|
|
41
|
+
const overlayStyle = computed<CSSProperties>(() => {
|
|
42
|
+
const style: CSSProperties = {
|
|
43
|
+
position: 'fixed',
|
|
44
|
+
top: 0,
|
|
45
|
+
left: 0,
|
|
46
|
+
right: 0,
|
|
47
|
+
zIndex: props.zIndex,
|
|
48
|
+
bottom: 0,
|
|
49
|
+
pointerEvents: !props.LockScroll ? 'none' : 'auto',
|
|
50
|
+
'background-color': `rgba(0, 0, 0, ${props.opacity})`
|
|
51
|
+
}
|
|
52
|
+
return Object.assign(style, props.customStyle)
|
|
53
|
+
})
|
|
54
|
+
const clickHandler = () => {
|
|
55
|
+
emit('click')
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<style lang="scss" scoped>
|
|
60
|
+
@import './index.scss';
|
|
61
|
+
</style>
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
-
|
|
3
|
-
const overlayProps = {
|
|
4
|
-
/** 是否显示遮罩 */
|
|
5
|
-
show: {
|
|
6
|
-
type: Boolean,
|
|
7
|
-
default: false
|
|
8
|
-
},
|
|
9
|
-
/** zIndex 层级 */
|
|
10
|
-
zIndex: {
|
|
11
|
-
type: Number,
|
|
12
|
-
default: 10070
|
|
13
|
-
},
|
|
14
|
-
/** 动画时长,单位毫秒 */
|
|
15
|
-
duration: {
|
|
16
|
-
type: Number,
|
|
17
|
-
default: 300
|
|
18
|
-
},
|
|
19
|
-
/** 不透明度值,当做rgba的第四个参数 */
|
|
20
|
-
opacity: {
|
|
21
|
-
type: Number,
|
|
22
|
-
default: 0.5
|
|
23
|
-
},
|
|
24
|
-
/** 是否锁住底部滚动 */
|
|
25
|
-
LockScroll: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
default: true
|
|
28
|
-
},
|
|
29
|
-
/** 定义需要用到的外部样式 */
|
|
30
|
-
customStyle: {
|
|
31
|
-
type: Object as PropType<CSSProperties>,
|
|
32
|
-
default: () => {}
|
|
33
|
-
},
|
|
34
|
-
/** 自定义外部类名 */
|
|
35
|
-
customClass: String
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default overlayProps
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
const overlayProps = {
|
|
4
|
+
/** 是否显示遮罩 */
|
|
5
|
+
show: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
},
|
|
9
|
+
/** zIndex 层级 */
|
|
10
|
+
zIndex: {
|
|
11
|
+
type: Number,
|
|
12
|
+
default: 10070
|
|
13
|
+
},
|
|
14
|
+
/** 动画时长,单位毫秒 */
|
|
15
|
+
duration: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: 300
|
|
18
|
+
},
|
|
19
|
+
/** 不透明度值,当做rgba的第四个参数 */
|
|
20
|
+
opacity: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: 0.5
|
|
23
|
+
},
|
|
24
|
+
/** 是否锁住底部滚动 */
|
|
25
|
+
LockScroll: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true
|
|
28
|
+
},
|
|
29
|
+
/** 定义需要用到的外部样式 */
|
|
30
|
+
customStyle: {
|
|
31
|
+
type: Object as PropType<CSSProperties>,
|
|
32
|
+
default: () => {}
|
|
33
|
+
},
|
|
34
|
+
/** 自定义外部类名 */
|
|
35
|
+
customClass: String
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default overlayProps
|
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="hy-pagination" :style="customStyle" v-if="!(hideIfOnePage && totalPageNum === 1)">
|
|
3
|
-
<view class="hy-pagination__content">
|
|
4
|
-
<hy-button
|
|
5
|
-
:plain="modelValue > 1"
|
|
6
|
-
type="info"
|
|
7
|
-
size="small"
|
|
8
|
-
:disabled="modelValue <= 1"
|
|
9
|
-
shape="circle"
|
|
10
|
-
class="hy-pagination__nav"
|
|
11
|
-
@click="sub"
|
|
12
|
-
>
|
|
13
|
-
<text v-if="!showIcon">{{ prevText }}</text>
|
|
14
|
-
<hy-icon
|
|
15
|
-
v-else
|
|
16
|
-
:class="`hy-pagination__left hy-pagination__icon ${
|
|
17
|
-
modelValue <= 1
|
|
18
|
-
? 'hy-pagination__nav--disabled'
|
|
19
|
-
: 'hy-pagination__nav--active'
|
|
20
|
-
}`"
|
|
21
|
-
:name="IconConfig.LEFT"
|
|
22
|
-
></hy-icon>
|
|
23
|
-
</hy-button>
|
|
24
|
-
<view class="hy-pagination__size">
|
|
25
|
-
<text class="hy-pagination__current">{{ modelValue }}</text>
|
|
26
|
-
<text class="hy-pagination__separator">/</text>
|
|
27
|
-
<text>{{ totalPageNum }}</text>
|
|
28
|
-
</view>
|
|
29
|
-
<hy-button
|
|
30
|
-
:plain="modelValue < totalPageNum"
|
|
31
|
-
type="info"
|
|
32
|
-
size="small"
|
|
33
|
-
:disabled="modelValue >= totalPageNum"
|
|
34
|
-
shape="circle"
|
|
35
|
-
@click="add"
|
|
36
|
-
>
|
|
37
|
-
<text v-if="!showIcon">{{ nextText }}</text>
|
|
38
|
-
<hy-icon
|
|
39
|
-
v-else
|
|
40
|
-
:custom-class="`hy-pagination__icon ${
|
|
41
|
-
modelValue >= totalPageNum
|
|
42
|
-
? 'hy-pagination__nav--disabled'
|
|
43
|
-
: 'hy-pagination__nav--active'
|
|
44
|
-
}`"
|
|
45
|
-
:name="IconConfig.RIGHT"
|
|
46
|
-
></hy-icon>
|
|
47
|
-
</hy-button>
|
|
48
|
-
</view>
|
|
49
|
-
<view class="hy-pagination__message" v-if="showMessage">
|
|
50
|
-
<text>{{ t('page', modelValue) }},</text>
|
|
51
|
-
<text v-if="total">{{ t('total', total) }},</text>
|
|
52
|
-
<text>{{ t('size', pageSize) }}</text>
|
|
53
|
-
</view>
|
|
54
|
-
</view>
|
|
55
|
-
</template>
|
|
56
|
-
|
|
57
|
-
<script lang="ts">
|
|
58
|
-
export default {
|
|
59
|
-
name: 'hy-pagination',
|
|
60
|
-
options: {
|
|
61
|
-
virtualHost: true,
|
|
62
|
-
addGlobalClass: true,
|
|
63
|
-
styleIsolation: 'shared'
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<script lang="ts" setup>
|
|
69
|
-
import { ref, watch } from 'vue'
|
|
70
|
-
import type { IPaginationEmits } from './typing'
|
|
71
|
-
import { IconConfig, useTranslate } from '../../libs'
|
|
72
|
-
import paginationProps from './props'
|
|
73
|
-
// 组件
|
|
74
|
-
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
75
|
-
import HyButton from '../hy-button/hy-button.vue'
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 当数据量过多时,使用分页分解数据。
|
|
79
|
-
* @displayName hy-pagination
|
|
80
|
-
*/
|
|
81
|
-
defineOptions({})
|
|
82
|
-
|
|
83
|
-
const props = defineProps(paginationProps)
|
|
84
|
-
const emit = defineEmits<IPaginationEmits>()
|
|
85
|
-
|
|
86
|
-
const { t } = useTranslate('pagination')
|
|
87
|
-
const totalPageNum = ref<number>(0) // 总页数
|
|
88
|
-
|
|
89
|
-
watch(
|
|
90
|
-
() => props.totalPage,
|
|
91
|
-
(newValue) => {
|
|
92
|
-
if (!totalPageNum.value && newValue) {
|
|
93
|
-
totalPageNum.value = totalPageNum.value
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
{ immediate: true, deep: true }
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
watch(
|
|
100
|
-
() => props.total,
|
|
101
|
-
() => {
|
|
102
|
-
updateTotalPage()
|
|
103
|
-
},
|
|
104
|
-
{ immediate: true, deep: true }
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @description 加数
|
|
109
|
-
* */
|
|
110
|
-
const add = () => {
|
|
111
|
-
const { modelValue } = props
|
|
112
|
-
if (modelValue > totalPageNum.value - 1) {
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
emit('change', { value: modelValue + 1 })
|
|
116
|
-
emit('update:modelValue', modelValue + 1)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const sub = () => {
|
|
120
|
-
const { modelValue } = props
|
|
121
|
-
if (modelValue < 2) {
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
emit('change', { value: modelValue - 1 })
|
|
125
|
-
emit('update:modelValue', modelValue - 1)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function updateTotalPage() {
|
|
129
|
-
const { total, pageSize } = props
|
|
130
|
-
totalPageNum.value = Math.ceil(total / pageSize)
|
|
131
|
-
}
|
|
132
|
-
</script>
|
|
133
|
-
|
|
134
|
-
<style lang="scss" scoped>
|
|
135
|
-
@import './index.scss';
|
|
136
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-pagination" :style="customStyle" v-if="!(hideIfOnePage && totalPageNum === 1)">
|
|
3
|
+
<view class="hy-pagination__content">
|
|
4
|
+
<hy-button
|
|
5
|
+
:plain="modelValue > 1"
|
|
6
|
+
type="info"
|
|
7
|
+
size="small"
|
|
8
|
+
:disabled="modelValue <= 1"
|
|
9
|
+
shape="circle"
|
|
10
|
+
class="hy-pagination__nav"
|
|
11
|
+
@click="sub"
|
|
12
|
+
>
|
|
13
|
+
<text v-if="!showIcon">{{ prevText }}</text>
|
|
14
|
+
<hy-icon
|
|
15
|
+
v-else
|
|
16
|
+
:class="`hy-pagination__left hy-pagination__icon ${
|
|
17
|
+
modelValue <= 1
|
|
18
|
+
? 'hy-pagination__nav--disabled'
|
|
19
|
+
: 'hy-pagination__nav--active'
|
|
20
|
+
}`"
|
|
21
|
+
:name="IconConfig.LEFT"
|
|
22
|
+
></hy-icon>
|
|
23
|
+
</hy-button>
|
|
24
|
+
<view class="hy-pagination__size">
|
|
25
|
+
<text class="hy-pagination__current">{{ modelValue }}</text>
|
|
26
|
+
<text class="hy-pagination__separator">/</text>
|
|
27
|
+
<text>{{ totalPageNum }}</text>
|
|
28
|
+
</view>
|
|
29
|
+
<hy-button
|
|
30
|
+
:plain="modelValue < totalPageNum"
|
|
31
|
+
type="info"
|
|
32
|
+
size="small"
|
|
33
|
+
:disabled="modelValue >= totalPageNum"
|
|
34
|
+
shape="circle"
|
|
35
|
+
@click="add"
|
|
36
|
+
>
|
|
37
|
+
<text v-if="!showIcon">{{ nextText }}</text>
|
|
38
|
+
<hy-icon
|
|
39
|
+
v-else
|
|
40
|
+
:custom-class="`hy-pagination__icon ${
|
|
41
|
+
modelValue >= totalPageNum
|
|
42
|
+
? 'hy-pagination__nav--disabled'
|
|
43
|
+
: 'hy-pagination__nav--active'
|
|
44
|
+
}`"
|
|
45
|
+
:name="IconConfig.RIGHT"
|
|
46
|
+
></hy-icon>
|
|
47
|
+
</hy-button>
|
|
48
|
+
</view>
|
|
49
|
+
<view class="hy-pagination__message" v-if="showMessage">
|
|
50
|
+
<text>{{ t('page', modelValue) }},</text>
|
|
51
|
+
<text v-if="total">{{ t('total', total) }},</text>
|
|
52
|
+
<text>{{ t('size', pageSize) }}</text>
|
|
53
|
+
</view>
|
|
54
|
+
</view>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script lang="ts">
|
|
58
|
+
export default {
|
|
59
|
+
name: 'hy-pagination',
|
|
60
|
+
options: {
|
|
61
|
+
virtualHost: true,
|
|
62
|
+
addGlobalClass: true,
|
|
63
|
+
styleIsolation: 'shared'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<script lang="ts" setup>
|
|
69
|
+
import { ref, watch } from 'vue'
|
|
70
|
+
import type { IPaginationEmits } from './typing'
|
|
71
|
+
import { IconConfig, useTranslate } from '../../libs'
|
|
72
|
+
import paginationProps from './props'
|
|
73
|
+
// 组件
|
|
74
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
75
|
+
import HyButton from '../hy-button/hy-button.vue'
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 当数据量过多时,使用分页分解数据。
|
|
79
|
+
* @displayName hy-pagination
|
|
80
|
+
*/
|
|
81
|
+
defineOptions({})
|
|
82
|
+
|
|
83
|
+
const props = defineProps(paginationProps)
|
|
84
|
+
const emit = defineEmits<IPaginationEmits>()
|
|
85
|
+
|
|
86
|
+
const { t } = useTranslate('pagination')
|
|
87
|
+
const totalPageNum = ref<number>(0) // 总页数
|
|
88
|
+
|
|
89
|
+
watch(
|
|
90
|
+
() => props.totalPage,
|
|
91
|
+
(newValue) => {
|
|
92
|
+
if (!totalPageNum.value && newValue) {
|
|
93
|
+
totalPageNum.value = totalPageNum.value
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{ immediate: true, deep: true }
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
watch(
|
|
100
|
+
() => props.total,
|
|
101
|
+
() => {
|
|
102
|
+
updateTotalPage()
|
|
103
|
+
},
|
|
104
|
+
{ immediate: true, deep: true }
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @description 加数
|
|
109
|
+
* */
|
|
110
|
+
const add = () => {
|
|
111
|
+
const { modelValue } = props
|
|
112
|
+
if (modelValue > totalPageNum.value - 1) {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
emit('change', { value: modelValue + 1 })
|
|
116
|
+
emit('update:modelValue', modelValue + 1)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const sub = () => {
|
|
120
|
+
const { modelValue } = props
|
|
121
|
+
if (modelValue < 2) {
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
emit('change', { value: modelValue - 1 })
|
|
125
|
+
emit('update:modelValue', modelValue - 1)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function updateTotalPage() {
|
|
129
|
+
const { total, pageSize } = props
|
|
130
|
+
totalPageNum.value = Math.ceil(total / pageSize)
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<style lang="scss" scoped>
|
|
135
|
+
@import './index.scss';
|
|
136
|
+
</style>
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
-
import { useTranslate } from '../../libs'
|
|
3
|
-
|
|
4
|
-
const { t } = useTranslate('pagination')
|
|
5
|
-
|
|
6
|
-
const paginationProps = {
|
|
7
|
-
/** 当前页 */
|
|
8
|
-
modelValue: {
|
|
9
|
-
type: Number,
|
|
10
|
-
default: 1
|
|
11
|
-
},
|
|
12
|
-
/** 总页数,如果有total,则优先使用total计算页数 */
|
|
13
|
-
totalPage: {
|
|
14
|
-
type: Number,
|
|
15
|
-
default: 1
|
|
16
|
-
},
|
|
17
|
-
/** 是否展示分页为Icon图标 */
|
|
18
|
-
showIcon: {
|
|
19
|
-
type: Boolean,
|
|
20
|
-
default: false
|
|
21
|
-
},
|
|
22
|
-
/** 是否展示总条数 */
|
|
23
|
-
showMessage: {
|
|
24
|
-
type: Boolean,
|
|
25
|
-
default: false
|
|
26
|
-
},
|
|
27
|
-
/** 总条数 */
|
|
28
|
-
total: {
|
|
29
|
-
type: Number,
|
|
30
|
-
default: 0
|
|
31
|
-
},
|
|
32
|
-
/** 每页条数 */
|
|
33
|
-
pageSize: {
|
|
34
|
-
type: Number,
|
|
35
|
-
default: 10
|
|
36
|
-
},
|
|
37
|
-
/** 上一页文本 */
|
|
38
|
-
prevText: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: () => t('prev')
|
|
41
|
-
},
|
|
42
|
-
/** 下一页文本 */
|
|
43
|
-
nextText: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: () => t('next')
|
|
46
|
-
},
|
|
47
|
-
/** 总页数只有一页时是否隐藏 */
|
|
48
|
-
hideIfOnePage: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: true
|
|
51
|
-
},
|
|
52
|
-
/** 定义需要用到的外部样式 */
|
|
53
|
-
customStyle: {
|
|
54
|
-
type: Object as PropType<CSSProperties>
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default paginationProps
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
import { useTranslate } from '../../libs'
|
|
3
|
+
|
|
4
|
+
const { t } = useTranslate('pagination')
|
|
5
|
+
|
|
6
|
+
const paginationProps = {
|
|
7
|
+
/** 当前页 */
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: Number,
|
|
10
|
+
default: 1
|
|
11
|
+
},
|
|
12
|
+
/** 总页数,如果有total,则优先使用total计算页数 */
|
|
13
|
+
totalPage: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 1
|
|
16
|
+
},
|
|
17
|
+
/** 是否展示分页为Icon图标 */
|
|
18
|
+
showIcon: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: false
|
|
21
|
+
},
|
|
22
|
+
/** 是否展示总条数 */
|
|
23
|
+
showMessage: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
/** 总条数 */
|
|
28
|
+
total: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 0
|
|
31
|
+
},
|
|
32
|
+
/** 每页条数 */
|
|
33
|
+
pageSize: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 10
|
|
36
|
+
},
|
|
37
|
+
/** 上一页文本 */
|
|
38
|
+
prevText: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: () => t('prev')
|
|
41
|
+
},
|
|
42
|
+
/** 下一页文本 */
|
|
43
|
+
nextText: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: () => t('next')
|
|
46
|
+
},
|
|
47
|
+
/** 总页数只有一页时是否隐藏 */
|
|
48
|
+
hideIfOnePage: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true
|
|
51
|
+
},
|
|
52
|
+
/** 定义需要用到的外部样式 */
|
|
53
|
+
customStyle: {
|
|
54
|
+
type: Object as PropType<CSSProperties>
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default paginationProps
|