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,31 +1,31 @@
|
|
|
1
|
-
import type { ExtractPropTypes } from 'vue'
|
|
2
|
-
import skeletonProps from './props'
|
|
3
|
-
|
|
4
|
-
export type SkeletonTheme = 'text' | 'avatar' | 'paragraph' | 'image'
|
|
5
|
-
export type SkeletonAnimation = 'gradient' | 'flashed'
|
|
6
|
-
export type SkeletonRowColObj = {
|
|
7
|
-
[key: string]: any
|
|
8
|
-
type?: 'rect' | 'circle' | 'text'
|
|
9
|
-
size?: string | number
|
|
10
|
-
width?: string | number
|
|
11
|
-
height?: string | number
|
|
12
|
-
margin?: string | number
|
|
13
|
-
background?: string
|
|
14
|
-
marginLeft?: string | number
|
|
15
|
-
marginRight?: string | number
|
|
16
|
-
borderRadius?: string | number
|
|
17
|
-
backgroundColor?: string
|
|
18
|
-
}
|
|
19
|
-
export type SkeletonRowCol = number | SkeletonRowColObj | Array<SkeletonRowColObj>
|
|
20
|
-
export type SkeletonThemeVars = {
|
|
21
|
-
notifyPadding?: string
|
|
22
|
-
notifyFontSize?: string
|
|
23
|
-
notifyTextColor?: string
|
|
24
|
-
notifyLineHeight?: number | string
|
|
25
|
-
notifyDangerBackground?: string
|
|
26
|
-
notifyPrimaryBackground?: string
|
|
27
|
-
notifySuccessBackground?: string
|
|
28
|
-
notifyWarningBackground?: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type HySkeletonProps = ExtractPropTypes<typeof skeletonProps>
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import skeletonProps from './props'
|
|
3
|
+
|
|
4
|
+
export type SkeletonTheme = 'text' | 'avatar' | 'paragraph' | 'image'
|
|
5
|
+
export type SkeletonAnimation = 'gradient' | 'flashed'
|
|
6
|
+
export type SkeletonRowColObj = {
|
|
7
|
+
[key: string]: any
|
|
8
|
+
type?: 'rect' | 'circle' | 'text'
|
|
9
|
+
size?: string | number
|
|
10
|
+
width?: string | number
|
|
11
|
+
height?: string | number
|
|
12
|
+
margin?: string | number
|
|
13
|
+
background?: string
|
|
14
|
+
marginLeft?: string | number
|
|
15
|
+
marginRight?: string | number
|
|
16
|
+
borderRadius?: string | number
|
|
17
|
+
backgroundColor?: string
|
|
18
|
+
}
|
|
19
|
+
export type SkeletonRowCol = number | SkeletonRowColObj | Array<SkeletonRowColObj>
|
|
20
|
+
export type SkeletonThemeVars = {
|
|
21
|
+
notifyPadding?: string
|
|
22
|
+
notifyFontSize?: string
|
|
23
|
+
notifyTextColor?: string
|
|
24
|
+
notifyLineHeight?: number | string
|
|
25
|
+
notifyDangerBackground?: string
|
|
26
|
+
notifyPrimaryBackground?: string
|
|
27
|
+
notifySuccessBackground?: string
|
|
28
|
+
notifyWarningBackground?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type HySkeletonProps = ExtractPropTypes<typeof skeletonProps>
|
|
@@ -1,275 +1,275 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="[`hy-steps--${direction}`, 'hy-steps']">
|
|
3
|
-
<template v-for="(item, i) in list" :key="i">
|
|
4
|
-
<view ref="hy-steps-item" :class="[`hy-steps-item--${direction}`, 'hy-steps-item']">
|
|
5
|
-
<!-- 线条 -->
|
|
6
|
-
<view
|
|
7
|
-
v-if="i + 1 < list.length"
|
|
8
|
-
:class="[
|
|
9
|
-
`hy-steps-item__line--${direction}`,
|
|
10
|
-
'hy-steps-item__line',
|
|
11
|
-
statusClass(i + 1, list[i + 1].error)
|
|
12
|
-
]"
|
|
13
|
-
:style="lineStyle(item, i)"
|
|
14
|
-
></view>
|
|
15
|
-
<!-- 线条 -->
|
|
16
|
-
|
|
17
|
-
<!-- 步骤状态 -->
|
|
18
|
-
<view
|
|
19
|
-
:class="[
|
|
20
|
-
`hy-steps-item__wrapper--${direction}`,
|
|
21
|
-
dot ? `hy-steps-item__wrapper--dot` : statusClass(i, item.error),
|
|
22
|
-
'hy-steps-item__wrapper'
|
|
23
|
-
]"
|
|
24
|
-
:style="itemStyleInner"
|
|
25
|
-
>
|
|
26
|
-
<slot v-if="$slots.icon" name="icon" :error="item?.error" :index="i"></slot>
|
|
27
|
-
<template v-else>
|
|
28
|
-
<view
|
|
29
|
-
:class="[
|
|
30
|
-
'hy-steps-item__wrapper--dot__item',
|
|
31
|
-
`hy-steps-item__wrapper--dot__${statusClass(i, item.error)}`
|
|
32
|
-
]"
|
|
33
|
-
v-if="dot"
|
|
34
|
-
:style="{
|
|
35
|
-
backgroundColor: statusColor(i, item?.error)
|
|
36
|
-
}"
|
|
37
|
-
></view>
|
|
38
|
-
<view
|
|
39
|
-
class="hy-steps-item__wrapper__icon"
|
|
40
|
-
v-else-if="activeIcon || inactiveIcon"
|
|
41
|
-
>
|
|
42
|
-
<hy-icon
|
|
43
|
-
:name="i <= current ? activeIcon : inactiveIcon"
|
|
44
|
-
:size="iconSize"
|
|
45
|
-
:color="i <= current ? activeColor : inactiveColor"
|
|
46
|
-
></hy-icon>
|
|
47
|
-
</view>
|
|
48
|
-
<view
|
|
49
|
-
v-else
|
|
50
|
-
:style="{
|
|
51
|
-
backgroundColor:
|
|
52
|
-
statusClass(i, item.error) === 'process'
|
|
53
|
-
? activeColor
|
|
54
|
-
: 'transparent',
|
|
55
|
-
borderColor: statusColor(i, item?.error)
|
|
56
|
-
}"
|
|
57
|
-
class="hy-steps-item__wrapper__circle"
|
|
58
|
-
>
|
|
59
|
-
<text
|
|
60
|
-
v-if="
|
|
61
|
-
statusClass(i, item.error) === 'process' ||
|
|
62
|
-
statusClass(i, item.error) === 'wait'
|
|
63
|
-
"
|
|
64
|
-
class="hy-steps-item__wrapper__circle__text"
|
|
65
|
-
:style="{
|
|
66
|
-
color: textColor(i)
|
|
67
|
-
}"
|
|
68
|
-
>
|
|
69
|
-
{{ i + 1 }}
|
|
70
|
-
</text>
|
|
71
|
-
<hy-icon
|
|
72
|
-
v-else
|
|
73
|
-
:color="
|
|
74
|
-
statusClass(i, item.error) === 'error' ? 'error' : activeColor
|
|
75
|
-
"
|
|
76
|
-
:size="iconSize"
|
|
77
|
-
:name="
|
|
78
|
-
statusClass(i, item.error) === 'error'
|
|
79
|
-
? IconConfig.CLOSE
|
|
80
|
-
: IconConfig.CHECK_MASK
|
|
81
|
-
"
|
|
82
|
-
></hy-icon>
|
|
83
|
-
</view>
|
|
84
|
-
</template>
|
|
85
|
-
</view>
|
|
86
|
-
<!-- 步骤状态 -->
|
|
87
|
-
|
|
88
|
-
<!-- 内容区域 -->
|
|
89
|
-
<view
|
|
90
|
-
class="hy-steps-item__content"
|
|
91
|
-
:class="[`hy-steps-item__content--${direction}`]"
|
|
92
|
-
:style="[contentStyle]"
|
|
93
|
-
>
|
|
94
|
-
<slot v-if="$slots.content" name="content" :record="item" :index="i"></slot>
|
|
95
|
-
<template v-else>
|
|
96
|
-
<slot
|
|
97
|
-
v-if="$slots.title"
|
|
98
|
-
name="title"
|
|
99
|
-
:title="item.title"
|
|
100
|
-
:index="i"
|
|
101
|
-
></slot>
|
|
102
|
-
<text v-else :class="titleClass(i, item.error)">
|
|
103
|
-
{{ item.title }}
|
|
104
|
-
</text>
|
|
105
|
-
<slot v-if="$slots.docs" name="docs" :desc="item.docs" :index="i"></slot>
|
|
106
|
-
<text v-else :style="{ fontSize: '12px', color: '#999' }">{{
|
|
107
|
-
item.docs
|
|
108
|
-
}}</text>
|
|
109
|
-
<text class="hy-steps-item__content--date">{{ item.date }}</text>
|
|
110
|
-
</template>
|
|
111
|
-
</view>
|
|
112
|
-
<!-- 内容区域 -->
|
|
113
|
-
</view>
|
|
114
|
-
</template>
|
|
115
|
-
</view>
|
|
116
|
-
</template>
|
|
117
|
-
|
|
118
|
-
<script lang="ts">
|
|
119
|
-
export default {
|
|
120
|
-
name: 'hy-steps',
|
|
121
|
-
options: {
|
|
122
|
-
addGlobalClass: true,
|
|
123
|
-
virtualHost: true,
|
|
124
|
-
styleIsolation: 'shared'
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
</script>
|
|
128
|
-
|
|
129
|
-
<script setup lang="ts">
|
|
130
|
-
import { computed, ref, onMounted, getCurrentInstance, watch } from 'vue'
|
|
131
|
-
import type { CSSProperties } from 'vue'
|
|
132
|
-
import type { IStepsEmits } from './typing'
|
|
133
|
-
import type { StepListVo } from './typing'
|
|
134
|
-
import { addUnit, getRect, ColorConfig, IconConfig } from '../../libs'
|
|
135
|
-
import stepsProps from './props'
|
|
136
|
-
// 组件
|
|
137
|
-
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* 一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
|
|
141
|
-
* @displayName hy-steps
|
|
142
|
-
*/
|
|
143
|
-
defineOptions({})
|
|
144
|
-
|
|
145
|
-
const props = defineProps(stepsProps)
|
|
146
|
-
const emit = defineEmits<IStepsEmits>()
|
|
147
|
-
|
|
148
|
-
const itemRect = ref<UniApp.NodeInfo[]>([])
|
|
149
|
-
const stepsRects = ref<UniApp.NodeInfo[]>([])
|
|
150
|
-
const instance = getCurrentInstance()
|
|
151
|
-
|
|
152
|
-
watch(
|
|
153
|
-
() => props.current,
|
|
154
|
-
(newVal: number) => {
|
|
155
|
-
if (props.list[newVal - 1]?.error) {
|
|
156
|
-
const index = props.list.findIndex((item) => item.error)
|
|
157
|
-
emit('update:current', index)
|
|
158
|
-
emit('change', index)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
// 字体标题类名
|
|
164
|
-
const titleClass = computed(() => {
|
|
165
|
-
return (index: number, error: boolean) => {
|
|
166
|
-
const classes = ['hy-steps-item__content__title']
|
|
167
|
-
if (props.current === index) {
|
|
168
|
-
classes.push('hy-steps-item__content__title--active')
|
|
169
|
-
|
|
170
|
-
if (error) {
|
|
171
|
-
classes.push('hy-steps-item__content__title--error')
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return classes
|
|
176
|
-
}
|
|
177
|
-
})
|
|
178
|
-
// 字体颜色
|
|
179
|
-
const textColor = computed(() => {
|
|
180
|
-
return (index: number) => (index === props.current ? '#ffffff' : props.inactiveColor)
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* 线条样式
|
|
185
|
-
* */
|
|
186
|
-
const lineStyle = computed(() => {
|
|
187
|
-
return (temp: StepListVo, index: number): CSSProperties => {
|
|
188
|
-
const style: CSSProperties = {}
|
|
189
|
-
if (!stepsRects.value.length) return style
|
|
190
|
-
if (props.direction === 'row') {
|
|
191
|
-
style.width = addUnit(stepsRects.value[index].width! - itemRect.value[index].width!)
|
|
192
|
-
style.left = addUnit(
|
|
193
|
-
stepsRects.value[index].width! / 2 + itemRect.value[index].width! / 2
|
|
194
|
-
)
|
|
195
|
-
style.top = addUnit(itemRect.value[index].height! / 2)
|
|
196
|
-
} else {
|
|
197
|
-
style.height = addUnit(stepsRects.value[index].height! - itemRect.value[index].height!)
|
|
198
|
-
style.left = addUnit(itemRect.value[index].width! / 2)
|
|
199
|
-
style.top = addUnit(itemRect.value[index].height)
|
|
200
|
-
}
|
|
201
|
-
style.backgroundColor = temp.error ? '' : index < props.current ? '' : props.inactiveColor
|
|
202
|
-
return style
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
const itemStyleInner = computed(() => {
|
|
207
|
-
return {}
|
|
208
|
-
})
|
|
209
|
-
/**
|
|
210
|
-
* 状态类名
|
|
211
|
-
* */
|
|
212
|
-
const statusClass = computed(() => {
|
|
213
|
-
return (index: number, error: boolean = false) => {
|
|
214
|
-
if (props.current == index) {
|
|
215
|
-
return error ? 'error' : 'process'
|
|
216
|
-
} else if (props.current > index) {
|
|
217
|
-
return 'finish'
|
|
218
|
-
} else {
|
|
219
|
-
return 'wait'
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
const statusColor = computed(() => {
|
|
224
|
-
return (index: number, error?: boolean) => {
|
|
225
|
-
let colorTmp: string | number
|
|
226
|
-
switch (statusClass.value(index, error)) {
|
|
227
|
-
case 'finish':
|
|
228
|
-
colorTmp = props.activeColor
|
|
229
|
-
break
|
|
230
|
-
case 'error':
|
|
231
|
-
colorTmp = ColorConfig.error
|
|
232
|
-
break
|
|
233
|
-
case 'process':
|
|
234
|
-
colorTmp = props.dot ? props.current : 'transparent'
|
|
235
|
-
break
|
|
236
|
-
default:
|
|
237
|
-
colorTmp = props.inactiveColor
|
|
238
|
-
break
|
|
239
|
-
}
|
|
240
|
-
return colorTmp
|
|
241
|
-
}
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
const contentStyle = computed<CSSProperties>(() => {
|
|
245
|
-
const style: CSSProperties = {}
|
|
246
|
-
if (props.direction === 'column') {
|
|
247
|
-
style.marginLeft = props.dot ? '2px' : '6px'
|
|
248
|
-
style.marginTop = props.dot ? '0px' : '0px'
|
|
249
|
-
} else {
|
|
250
|
-
style.marginTop = props.dot ? '2px' : '6px'
|
|
251
|
-
style.marginLeft = props.dot ? '0px' : '0px'
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return style
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
onMounted(() => {
|
|
258
|
-
getStepsItemRect()
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
// 获取组件的尺寸,用于设置横线的位置
|
|
262
|
-
const getStepsItemRect = () => {
|
|
263
|
-
getRect('.hy-steps-item', true, instance).then((rect) => {
|
|
264
|
-
stepsRects.value = rect as UniApp.NodeInfo[]
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
getRect('.hy-steps-item__wrapper', true, instance).then((rect) => {
|
|
268
|
-
itemRect.value = rect as UniApp.NodeInfo[]
|
|
269
|
-
})
|
|
270
|
-
}
|
|
271
|
-
</script>
|
|
272
|
-
|
|
273
|
-
<style lang="scss" scoped>
|
|
274
|
-
@import './index.scss';
|
|
275
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="[`hy-steps--${direction}`, 'hy-steps']">
|
|
3
|
+
<template v-for="(item, i) in list" :key="i">
|
|
4
|
+
<view ref="hy-steps-item" :class="[`hy-steps-item--${direction}`, 'hy-steps-item']">
|
|
5
|
+
<!-- 线条 -->
|
|
6
|
+
<view
|
|
7
|
+
v-if="i + 1 < list.length"
|
|
8
|
+
:class="[
|
|
9
|
+
`hy-steps-item__line--${direction}`,
|
|
10
|
+
'hy-steps-item__line',
|
|
11
|
+
statusClass(i + 1, list[i + 1].error)
|
|
12
|
+
]"
|
|
13
|
+
:style="lineStyle(item, i)"
|
|
14
|
+
></view>
|
|
15
|
+
<!-- 线条 -->
|
|
16
|
+
|
|
17
|
+
<!-- 步骤状态 -->
|
|
18
|
+
<view
|
|
19
|
+
:class="[
|
|
20
|
+
`hy-steps-item__wrapper--${direction}`,
|
|
21
|
+
dot ? `hy-steps-item__wrapper--dot` : statusClass(i, item.error),
|
|
22
|
+
'hy-steps-item__wrapper'
|
|
23
|
+
]"
|
|
24
|
+
:style="itemStyleInner"
|
|
25
|
+
>
|
|
26
|
+
<slot v-if="$slots.icon" name="icon" :error="item?.error" :index="i"></slot>
|
|
27
|
+
<template v-else>
|
|
28
|
+
<view
|
|
29
|
+
:class="[
|
|
30
|
+
'hy-steps-item__wrapper--dot__item',
|
|
31
|
+
`hy-steps-item__wrapper--dot__${statusClass(i, item.error)}`
|
|
32
|
+
]"
|
|
33
|
+
v-if="dot"
|
|
34
|
+
:style="{
|
|
35
|
+
backgroundColor: statusColor(i, item?.error)
|
|
36
|
+
}"
|
|
37
|
+
></view>
|
|
38
|
+
<view
|
|
39
|
+
class="hy-steps-item__wrapper__icon"
|
|
40
|
+
v-else-if="activeIcon || inactiveIcon"
|
|
41
|
+
>
|
|
42
|
+
<hy-icon
|
|
43
|
+
:name="i <= current ? activeIcon : inactiveIcon"
|
|
44
|
+
:size="iconSize"
|
|
45
|
+
:color="i <= current ? activeColor : inactiveColor"
|
|
46
|
+
></hy-icon>
|
|
47
|
+
</view>
|
|
48
|
+
<view
|
|
49
|
+
v-else
|
|
50
|
+
:style="{
|
|
51
|
+
backgroundColor:
|
|
52
|
+
statusClass(i, item.error) === 'process'
|
|
53
|
+
? activeColor
|
|
54
|
+
: 'transparent',
|
|
55
|
+
borderColor: statusColor(i, item?.error)
|
|
56
|
+
}"
|
|
57
|
+
class="hy-steps-item__wrapper__circle"
|
|
58
|
+
>
|
|
59
|
+
<text
|
|
60
|
+
v-if="
|
|
61
|
+
statusClass(i, item.error) === 'process' ||
|
|
62
|
+
statusClass(i, item.error) === 'wait'
|
|
63
|
+
"
|
|
64
|
+
class="hy-steps-item__wrapper__circle__text"
|
|
65
|
+
:style="{
|
|
66
|
+
color: textColor(i)
|
|
67
|
+
}"
|
|
68
|
+
>
|
|
69
|
+
{{ i + 1 }}
|
|
70
|
+
</text>
|
|
71
|
+
<hy-icon
|
|
72
|
+
v-else
|
|
73
|
+
:color="
|
|
74
|
+
statusClass(i, item.error) === 'error' ? 'error' : activeColor
|
|
75
|
+
"
|
|
76
|
+
:size="iconSize"
|
|
77
|
+
:name="
|
|
78
|
+
statusClass(i, item.error) === 'error'
|
|
79
|
+
? IconConfig.CLOSE
|
|
80
|
+
: IconConfig.CHECK_MASK
|
|
81
|
+
"
|
|
82
|
+
></hy-icon>
|
|
83
|
+
</view>
|
|
84
|
+
</template>
|
|
85
|
+
</view>
|
|
86
|
+
<!-- 步骤状态 -->
|
|
87
|
+
|
|
88
|
+
<!-- 内容区域 -->
|
|
89
|
+
<view
|
|
90
|
+
class="hy-steps-item__content"
|
|
91
|
+
:class="[`hy-steps-item__content--${direction}`]"
|
|
92
|
+
:style="[contentStyle]"
|
|
93
|
+
>
|
|
94
|
+
<slot v-if="$slots.content" name="content" :record="item" :index="i"></slot>
|
|
95
|
+
<template v-else>
|
|
96
|
+
<slot
|
|
97
|
+
v-if="$slots.title"
|
|
98
|
+
name="title"
|
|
99
|
+
:title="item.title"
|
|
100
|
+
:index="i"
|
|
101
|
+
></slot>
|
|
102
|
+
<text v-else :class="titleClass(i, item.error)">
|
|
103
|
+
{{ item.title }}
|
|
104
|
+
</text>
|
|
105
|
+
<slot v-if="$slots.docs" name="docs" :desc="item.docs" :index="i"></slot>
|
|
106
|
+
<text v-else :style="{ fontSize: '12px', color: '#999' }">{{
|
|
107
|
+
item.docs
|
|
108
|
+
}}</text>
|
|
109
|
+
<text class="hy-steps-item__content--date">{{ item.date }}</text>
|
|
110
|
+
</template>
|
|
111
|
+
</view>
|
|
112
|
+
<!-- 内容区域 -->
|
|
113
|
+
</view>
|
|
114
|
+
</template>
|
|
115
|
+
</view>
|
|
116
|
+
</template>
|
|
117
|
+
|
|
118
|
+
<script lang="ts">
|
|
119
|
+
export default {
|
|
120
|
+
name: 'hy-steps',
|
|
121
|
+
options: {
|
|
122
|
+
addGlobalClass: true,
|
|
123
|
+
virtualHost: true,
|
|
124
|
+
styleIsolation: 'shared'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<script setup lang="ts">
|
|
130
|
+
import { computed, ref, onMounted, getCurrentInstance, watch } from 'vue'
|
|
131
|
+
import type { CSSProperties } from 'vue'
|
|
132
|
+
import type { IStepsEmits } from './typing'
|
|
133
|
+
import type { StepListVo } from './typing'
|
|
134
|
+
import { addUnit, getRect, ColorConfig, IconConfig } from '../../libs'
|
|
135
|
+
import stepsProps from './props'
|
|
136
|
+
// 组件
|
|
137
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
|
|
141
|
+
* @displayName hy-steps
|
|
142
|
+
*/
|
|
143
|
+
defineOptions({})
|
|
144
|
+
|
|
145
|
+
const props = defineProps(stepsProps)
|
|
146
|
+
const emit = defineEmits<IStepsEmits>()
|
|
147
|
+
|
|
148
|
+
const itemRect = ref<UniApp.NodeInfo[]>([])
|
|
149
|
+
const stepsRects = ref<UniApp.NodeInfo[]>([])
|
|
150
|
+
const instance = getCurrentInstance()
|
|
151
|
+
|
|
152
|
+
watch(
|
|
153
|
+
() => props.current,
|
|
154
|
+
(newVal: number) => {
|
|
155
|
+
if (props.list[newVal - 1]?.error) {
|
|
156
|
+
const index = props.list.findIndex((item) => item.error)
|
|
157
|
+
emit('update:current', index)
|
|
158
|
+
emit('change', index)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
// 字体标题类名
|
|
164
|
+
const titleClass = computed(() => {
|
|
165
|
+
return (index: number, error: boolean) => {
|
|
166
|
+
const classes = ['hy-steps-item__content__title']
|
|
167
|
+
if (props.current === index) {
|
|
168
|
+
classes.push('hy-steps-item__content__title--active')
|
|
169
|
+
|
|
170
|
+
if (error) {
|
|
171
|
+
classes.push('hy-steps-item__content__title--error')
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return classes
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
// 字体颜色
|
|
179
|
+
const textColor = computed(() => {
|
|
180
|
+
return (index: number) => (index === props.current ? '#ffffff' : props.inactiveColor)
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 线条样式
|
|
185
|
+
* */
|
|
186
|
+
const lineStyle = computed(() => {
|
|
187
|
+
return (temp: StepListVo, index: number): CSSProperties => {
|
|
188
|
+
const style: CSSProperties = {}
|
|
189
|
+
if (!stepsRects.value.length) return style
|
|
190
|
+
if (props.direction === 'row') {
|
|
191
|
+
style.width = addUnit(stepsRects.value[index].width! - itemRect.value[index].width!)
|
|
192
|
+
style.left = addUnit(
|
|
193
|
+
stepsRects.value[index].width! / 2 + itemRect.value[index].width! / 2
|
|
194
|
+
)
|
|
195
|
+
style.top = addUnit(itemRect.value[index].height! / 2)
|
|
196
|
+
} else {
|
|
197
|
+
style.height = addUnit(stepsRects.value[index].height! - itemRect.value[index].height!)
|
|
198
|
+
style.left = addUnit(itemRect.value[index].width! / 2)
|
|
199
|
+
style.top = addUnit(itemRect.value[index].height)
|
|
200
|
+
}
|
|
201
|
+
style.backgroundColor = temp.error ? '' : index < props.current ? '' : props.inactiveColor
|
|
202
|
+
return style
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
const itemStyleInner = computed(() => {
|
|
207
|
+
return {}
|
|
208
|
+
})
|
|
209
|
+
/**
|
|
210
|
+
* 状态类名
|
|
211
|
+
* */
|
|
212
|
+
const statusClass = computed(() => {
|
|
213
|
+
return (index: number, error: boolean = false) => {
|
|
214
|
+
if (props.current == index) {
|
|
215
|
+
return error ? 'error' : 'process'
|
|
216
|
+
} else if (props.current > index) {
|
|
217
|
+
return 'finish'
|
|
218
|
+
} else {
|
|
219
|
+
return 'wait'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
const statusColor = computed(() => {
|
|
224
|
+
return (index: number, error?: boolean) => {
|
|
225
|
+
let colorTmp: string | number
|
|
226
|
+
switch (statusClass.value(index, error)) {
|
|
227
|
+
case 'finish':
|
|
228
|
+
colorTmp = props.activeColor
|
|
229
|
+
break
|
|
230
|
+
case 'error':
|
|
231
|
+
colorTmp = ColorConfig.error
|
|
232
|
+
break
|
|
233
|
+
case 'process':
|
|
234
|
+
colorTmp = props.dot ? props.current : 'transparent'
|
|
235
|
+
break
|
|
236
|
+
default:
|
|
237
|
+
colorTmp = props.inactiveColor
|
|
238
|
+
break
|
|
239
|
+
}
|
|
240
|
+
return colorTmp
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
const contentStyle = computed<CSSProperties>(() => {
|
|
245
|
+
const style: CSSProperties = {}
|
|
246
|
+
if (props.direction === 'column') {
|
|
247
|
+
style.marginLeft = props.dot ? '2px' : '6px'
|
|
248
|
+
style.marginTop = props.dot ? '0px' : '0px'
|
|
249
|
+
} else {
|
|
250
|
+
style.marginTop = props.dot ? '2px' : '6px'
|
|
251
|
+
style.marginLeft = props.dot ? '0px' : '0px'
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return style
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
onMounted(() => {
|
|
258
|
+
getStepsItemRect()
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
// 获取组件的尺寸,用于设置横线的位置
|
|
262
|
+
const getStepsItemRect = () => {
|
|
263
|
+
getRect('.hy-steps-item', true, instance).then((rect) => {
|
|
264
|
+
stepsRects.value = rect as UniApp.NodeInfo[]
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
getRect('.hy-steps-item__wrapper', true, instance).then((rect) => {
|
|
268
|
+
itemRect.value = rect as UniApp.NodeInfo[]
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
</script>
|
|
272
|
+
|
|
273
|
+
<style lang="scss" scoped>
|
|
274
|
+
@import './index.scss';
|
|
275
|
+
</style>
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export interface StepListVo {
|
|
2
|
-
/**
|
|
3
|
-
* 标题
|
|
4
|
-
* */
|
|
5
|
-
title?: string
|
|
6
|
-
/**
|
|
7
|
-
* 描述
|
|
8
|
-
* */
|
|
9
|
-
docs?: string
|
|
10
|
-
/**
|
|
11
|
-
* 时间日期
|
|
12
|
-
* */
|
|
13
|
-
date?: string
|
|
14
|
-
/**
|
|
15
|
-
* 是否错误
|
|
16
|
-
* */
|
|
17
|
-
error?: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface IStepsEmits {
|
|
21
|
-
/** 值改成触发 */
|
|
22
|
-
(e: 'change', index: number): void
|
|
23
|
-
/** 值改成触发 */
|
|
24
|
-
(e: 'update:current', index: number): void
|
|
25
|
-
}
|
|
1
|
+
export interface StepListVo {
|
|
2
|
+
/**
|
|
3
|
+
* 标题
|
|
4
|
+
* */
|
|
5
|
+
title?: string
|
|
6
|
+
/**
|
|
7
|
+
* 描述
|
|
8
|
+
* */
|
|
9
|
+
docs?: string
|
|
10
|
+
/**
|
|
11
|
+
* 时间日期
|
|
12
|
+
* */
|
|
13
|
+
date?: string
|
|
14
|
+
/**
|
|
15
|
+
* 是否错误
|
|
16
|
+
* */
|
|
17
|
+
error?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IStepsEmits {
|
|
21
|
+
/** 值改成触发 */
|
|
22
|
+
(e: 'change', index: number): void
|
|
23
|
+
/** 值改成触发 */
|
|
24
|
+
(e: 'update:current', index: number): void
|
|
25
|
+
}
|