@kyfe/hroa-ui 1.0.5 → 1.0.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/dist/hroa-ui.common.js +3104 -279
- package/dist/hroa-ui.css +1 -1
- package/dist/hroa-ui.umd.js +3104 -279
- package/dist/hroa-ui.umd.min.js +2 -2
- package/dist/img/header.7e31b1d5.png +0 -0
- package/lib/getJsModule/index.css +1 -1
- package/lib/getJsModule/index.js +2 -2
- package/lib/hr-add-list/index.js +1 -1
- package/lib/hr-bottom-button/index.js +1 -1
- package/lib/hr-breadcrumb/index.js +1 -1
- package/lib/hr-button/index.js +1 -1
- package/lib/hr-checkbox/index.css +1 -0
- package/lib/hr-checkbox/index.js +1 -0
- package/lib/hr-checkbox-group/index.css +1 -0
- package/lib/hr-checkbox-group/index.js +1 -0
- package/lib/hr-clipboard/index.js +1 -1
- package/lib/hr-collapse-card/index.js +1 -1
- package/lib/hr-condition-filtrate/index.js +1 -1
- package/lib/hr-condition-filtrate-popup/index.js +1 -1
- package/lib/hr-date-filter/index.css +1 -0
- package/lib/hr-date-filter/index.js +1 -0
- package/lib/hr-dropdown-date/index.js +1 -1
- package/lib/hr-elasticity-box/index.js +1 -1
- package/lib/hr-elasticity-box-item/index.js +1 -1
- package/lib/hr-emotional-picture/index.js +1 -1
- package/lib/hr-employee-choose/index.js +1 -1
- package/lib/hr-file-list/index.css +1 -1
- package/lib/hr-file-list/index.js +1 -1
- package/lib/hr-full-screen/index.js +1 -1
- package/lib/hr-img-list/index.js +1 -1
- package/lib/hr-info-card/index.js +1 -1
- package/lib/hr-information/index.js +1 -1
- package/lib/hr-license-plate-number/index.js +1 -1
- package/lib/hr-module-card/index.js +1 -1
- package/lib/hr-multiterm-choose/index.css +1 -1
- package/lib/hr-multiterm-choose/index.js +1 -1
- package/lib/hr-no-data/index.js +1 -1
- package/lib/hr-notice-bar/index.js +1 -1
- package/lib/hr-notification-dialog/index.css +1 -0
- package/lib/hr-notification-dialog/index.js +1 -0
- package/lib/hr-open-ks/index.js +1 -1
- package/lib/hr-pager/index.css +1 -1
- package/lib/hr-pager/index.js +1 -1
- package/lib/hr-popup/index.js +1 -1
- package/lib/hr-preview-file/index.js +1 -1
- package/lib/hr-radiobox/index.css +1 -0
- package/lib/hr-radiobox/index.js +1 -0
- package/lib/hr-radiobox-group/index.css +1 -0
- package/lib/hr-radiobox-group/index.js +1 -0
- package/lib/hr-rate/index.js +1 -1
- package/lib/hr-reason-textarea/index.js +1 -1
- package/lib/hr-search-input/index.js +1 -1
- package/lib/hr-search-tips/index.css +1 -0
- package/lib/hr-search-tips/index.js +9 -0
- package/lib/hr-select/index.js +1 -1
- package/lib/hr-select-list/index.js +1 -1
- package/lib/hr-single-choose/index.css +1 -1
- package/lib/hr-single-choose/index.js +1 -1
- package/lib/hr-slide-pager/index.css +1 -1
- package/lib/hr-slide-pager/index.js +1 -1
- package/lib/hr-sort/index.js +1 -1
- package/lib/hr-stack-image/index.js +1 -1
- package/lib/hr-tab-nav/index.js +1 -1
- package/lib/hr-time-picker/index.css +1 -0
- package/lib/hr-time-picker/index.js +1 -0
- package/lib/hr-view-item/index.js +1 -1
- package/lib/hr-virtual-list/index.css +1 -0
- package/lib/hr-virtual-list/index.js +1 -0
- package/lib/img/header.7e31b1d5.png +0 -0
- package/lib/index/index.css +1 -1
- package/lib/index/index.js +2 -2
- package/lib/utils/index.js +1 -1
- package/package.json +6 -2
- package/packages/hr-checkbox/index.js +8 -0
- package/packages/hr-checkbox/src/active-icon.png +0 -0
- package/packages/hr-checkbox/src/checkbox-group.vue +74 -0
- package/packages/hr-checkbox/src/checkbox.vue +226 -0
- package/packages/hr-checkbox/src/data.js +46 -0
- package/packages/hr-checkbox//345/244/215/351/200/211/346/241/206-/345/215/225/351/200/211/346/241/206.md +0 -0
- package/packages/hr-checkbox-group/index.js +8 -0
- package/packages/hr-date-filter/index.js +7 -0
- package/packages/hr-date-filter/src/date-select.vue +153 -0
- package/packages/hr-date-filter/src/index.vue +243 -0
- package/packages/hr-date-filter/src/style.less +130 -0
- package/packages/hr-date-filter/src/utils.js +109 -0
- package/packages/hr-file-list/src/index.vue +2 -2
- package/packages/hr-multiterm-choose/src/index.vue +4 -5
- package/packages/hr-notification-dialog/images/header.png +0 -0
- package/packages/hr-notification-dialog/index.js +7 -0
- package/packages/hr-notification-dialog/src/index.vue +293 -0
- package/packages/hr-notification-dialog//345/274/271/347/252/227/346/217/220/347/244/272/347/273/204/344/273/266.md +0 -0
- package/packages/hr-pager/src/index.vue +28 -4
- package/packages/hr-radiobox/index.js +8 -0
- package/packages/hr-radiobox/src/data.js +46 -0
- package/packages/hr-radiobox/src/radiobox-group.vue +64 -0
- package/packages/hr-radiobox/src/radiobox.vue +191 -0
- package/packages/hr-radiobox-group/index.js +8 -0
- package/packages/hr-search-tips/index.js +3 -0
- package/packages/hr-search-tips/src/index.vue +213 -0
- package/packages/hr-search-tips//350/277/234/347/250/213/346/250/241/347/263/212/346/220/234/347/264/242.md +0 -0
- package/packages/hr-single-choose/src/index.vue +4 -5
- package/packages/hr-slide-pager/src/index.vue +3 -10
- package/packages/hr-time-picker/index.js +3 -0
- package/packages/hr-time-picker/src/index.vue +85 -0
- package/packages/hr-time-picker//346/227/266/351/227/264/351/200/211/346/213/251/345/231/250.md +0 -0
- package/packages/hr-virtual-list/index.js +7 -0
- package/packages/hr-virtual-list/src/cc-item.vue +105 -0
- package/packages/hr-virtual-list/src/index.vue +227 -0
- package/packages/hr-virtual-list//350/231/232/346/213/237/345/210/227/350/241/250.md +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ks-popup v-model="popupShow"
|
|
3
|
+
@click-overlay="onMaskClose"
|
|
4
|
+
:close-on-click-overlay="this.confirmCountDown > 0 ? false : closeOnClickOverlay"
|
|
5
|
+
:get-container="getContainer"
|
|
6
|
+
:overlay="overlay"
|
|
7
|
+
class="popup">
|
|
8
|
+
<transition name="van-fade">
|
|
9
|
+
<div v-show="show"
|
|
10
|
+
class="notification-popup"
|
|
11
|
+
@click.stop>
|
|
12
|
+
<!-- 顶部图片 -->
|
|
13
|
+
<div class="notification-popup-header"
|
|
14
|
+
v-if="showHeader">
|
|
15
|
+
<!-- 插槽内容 -->
|
|
16
|
+
<template v-if="$slots.top">
|
|
17
|
+
<slot name="top"></slot>
|
|
18
|
+
</template>
|
|
19
|
+
<img v-else
|
|
20
|
+
:src="headerImg"
|
|
21
|
+
alt="img">
|
|
22
|
+
</div>
|
|
23
|
+
<!-- 中间内容 -->
|
|
24
|
+
<div :class="['notification-popup-content', {'showRadio': !showConfirmBtn && !showCancelBtn && !$slots.btn && showHeader, 'showRadio-t': !showHeader, 'showBorder': !$slots.default}]">
|
|
25
|
+
<!-- 插槽内容 -->
|
|
26
|
+
<template v-if="$slots.default">
|
|
27
|
+
<slot></slot>
|
|
28
|
+
</template>
|
|
29
|
+
<!-- 默认样式内容 -->
|
|
30
|
+
<template v-else>
|
|
31
|
+
<div v-if="contentHeader"
|
|
32
|
+
class="notification-popup-content-header">{{contentHeader}}</div>
|
|
33
|
+
<div v-if="contentText"
|
|
34
|
+
class="notification-popup-content-content"
|
|
35
|
+
:style="{textIndent: textIndent}">{{contentText}}</div>
|
|
36
|
+
</template>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="notification-popup-bottom"
|
|
39
|
+
v-if="showConfirmBtn || showCancelBtn || $slots.btn">
|
|
40
|
+
<!-- 按钮插槽内容 -->
|
|
41
|
+
<template v-if="$slots.btn">
|
|
42
|
+
<slot name="btn"></slot>
|
|
43
|
+
</template>
|
|
44
|
+
<!-- 按钮默认样式 -->
|
|
45
|
+
<template v-else>
|
|
46
|
+
<ks-button v-if="showCancelBtn"
|
|
47
|
+
type="default"
|
|
48
|
+
size="large"
|
|
49
|
+
@click="onCancel"
|
|
50
|
+
:disabled="cancelCountDown > 0"
|
|
51
|
+
block>{{cancelText}}</ks-button>
|
|
52
|
+
<ks-button v-if="showConfirmBtn"
|
|
53
|
+
:class="{'margin-left': showCancelBtn}"
|
|
54
|
+
type="primary"
|
|
55
|
+
size="large"
|
|
56
|
+
@click="onConfirm"
|
|
57
|
+
:disabled="confirmCountDown > 0"
|
|
58
|
+
block>{{confirmText}}</ks-button>
|
|
59
|
+
</template>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</transition>
|
|
63
|
+
</ks-popup>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<script>
|
|
67
|
+
export default {
|
|
68
|
+
name: 'HrNotificationDialog',
|
|
69
|
+
model: {
|
|
70
|
+
prop: 'show',
|
|
71
|
+
event: 'onUpdate'
|
|
72
|
+
},
|
|
73
|
+
props: {
|
|
74
|
+
// 判断是否显示
|
|
75
|
+
show: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
// 判断是否显示顶部区域
|
|
80
|
+
showHeader: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true
|
|
83
|
+
},
|
|
84
|
+
// 顶部图片
|
|
85
|
+
headerImg: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: require('../images/header.png')
|
|
88
|
+
},
|
|
89
|
+
// 内容标题
|
|
90
|
+
contentHeader: {
|
|
91
|
+
type: String
|
|
92
|
+
},
|
|
93
|
+
// 内容
|
|
94
|
+
contentText: {
|
|
95
|
+
type: String
|
|
96
|
+
},
|
|
97
|
+
// 判断是否显示确认弹窗
|
|
98
|
+
showConfirmBtn: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true
|
|
101
|
+
},
|
|
102
|
+
// 判断是否显示取消弹窗
|
|
103
|
+
showCancelBtn: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: true
|
|
106
|
+
},
|
|
107
|
+
// 确定按钮默认文案
|
|
108
|
+
confirmBtnText: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: '确认'
|
|
111
|
+
},
|
|
112
|
+
// 取消按钮默认文案
|
|
113
|
+
cancelBtnText: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: '取消'
|
|
116
|
+
},
|
|
117
|
+
// 判断是否显示确认按钮的倒计时
|
|
118
|
+
showConfirmCountDown: {
|
|
119
|
+
type: Number,
|
|
120
|
+
default: 0
|
|
121
|
+
},
|
|
122
|
+
// 判断是否显示取消按钮的倒计时
|
|
123
|
+
showCancelCountDown: {
|
|
124
|
+
type: Number,
|
|
125
|
+
default: 0
|
|
126
|
+
},
|
|
127
|
+
// 内容首行缩进
|
|
128
|
+
textIndent: {
|
|
129
|
+
type: String,
|
|
130
|
+
default: '1em'
|
|
131
|
+
},
|
|
132
|
+
// 点击遮罩层关闭
|
|
133
|
+
closeOnClickOverlay: {
|
|
134
|
+
type: Boolean,
|
|
135
|
+
default: true
|
|
136
|
+
},
|
|
137
|
+
// 挂载元素位置
|
|
138
|
+
getContainer: {
|
|
139
|
+
type: [String, Function],
|
|
140
|
+
},
|
|
141
|
+
// 判断是否显示遮罩层
|
|
142
|
+
overlay: {
|
|
143
|
+
type: Boolean,
|
|
144
|
+
default: true
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
data () {
|
|
148
|
+
return {
|
|
149
|
+
popupShow: false, // 弹窗是否显示
|
|
150
|
+
confirmCountDown: 0, // 确认按钮倒计时
|
|
151
|
+
cancelCountDown: 0, // 取消按钮倒计时
|
|
152
|
+
timer: null, // 定时器
|
|
153
|
+
boxWidth: '' // 容器宽度
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
computed: {
|
|
157
|
+
// 确认按钮
|
|
158
|
+
confirmText () {
|
|
159
|
+
return this.confirmCountDown > 0 ? `${this.confirmBtnText}(${this.confirmCountDown})` : this.confirmBtnText
|
|
160
|
+
},
|
|
161
|
+
// 取消按钮
|
|
162
|
+
cancelText () {
|
|
163
|
+
return this.cancelCountDown > 0 ? `${this.cancelBtnText}(${this.cancelCountDown})` : this.cancelBtnText
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
watch: {
|
|
167
|
+
show: {
|
|
168
|
+
handler (val) {
|
|
169
|
+
if (val) {
|
|
170
|
+
if (this.showCancelCountDown && this.showCancelCountDown > 0) {
|
|
171
|
+
this.cancelCountDown = this.showCancelCountDown
|
|
172
|
+
// 启动定时器
|
|
173
|
+
this.startCountDown('cancelCountDown')
|
|
174
|
+
}
|
|
175
|
+
if (this.showConfirmCountDown && this.showConfirmCountDown > 0) {
|
|
176
|
+
this.confirmCountDown = this.showConfirmCountDown
|
|
177
|
+
// 启动定时器
|
|
178
|
+
this.startCountDown('confirmCountDown')
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
if (this.timer) {
|
|
182
|
+
this.clearTimer()
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
this.popupShow = val;
|
|
186
|
+
},
|
|
187
|
+
immediate: true
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
methods: {
|
|
191
|
+
/**
|
|
192
|
+
* 清除定时器
|
|
193
|
+
*/
|
|
194
|
+
clearTimer () {
|
|
195
|
+
clearInterval(this.timer)
|
|
196
|
+
this.timer = null
|
|
197
|
+
},
|
|
198
|
+
/**
|
|
199
|
+
* 启动定时器
|
|
200
|
+
*/
|
|
201
|
+
startCountDown (name) {
|
|
202
|
+
this.timer = setInterval(() => {
|
|
203
|
+
this[name]--
|
|
204
|
+
if (this[name] <= 0) {
|
|
205
|
+
this.clearTimer()
|
|
206
|
+
}
|
|
207
|
+
}, 1000)
|
|
208
|
+
},
|
|
209
|
+
/**
|
|
210
|
+
* 确认
|
|
211
|
+
*/
|
|
212
|
+
onConfirm () {
|
|
213
|
+
this.$emit('onConfirm')
|
|
214
|
+
},
|
|
215
|
+
/**
|
|
216
|
+
* 取消
|
|
217
|
+
*/
|
|
218
|
+
onCancel () {
|
|
219
|
+
this.$emit('onCancel')
|
|
220
|
+
},
|
|
221
|
+
/**
|
|
222
|
+
* 点击幕布取消
|
|
223
|
+
*/
|
|
224
|
+
onMaskClose () {
|
|
225
|
+
// 如果还在倒计时 则不关闭
|
|
226
|
+
if (this.confirmCountDown > 0) return
|
|
227
|
+
this.$emit('onMask')
|
|
228
|
+
if (this.closeOnClickOverlay) {
|
|
229
|
+
this.$emit('onUpdate', false)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
</script>
|
|
235
|
+
|
|
236
|
+
<style lang="less" scoped>
|
|
237
|
+
@radiusSize: 12px;
|
|
238
|
+
@radius: 0 0 @radiusSize @radiusSize;
|
|
239
|
+
.popup {
|
|
240
|
+
background-color: transparent;
|
|
241
|
+
top: 45%;
|
|
242
|
+
width: calc(100% - 80px);
|
|
243
|
+
}
|
|
244
|
+
.notification-popup {
|
|
245
|
+
box-sizing: border-box;
|
|
246
|
+
&-header {
|
|
247
|
+
height: 88px;
|
|
248
|
+
img {
|
|
249
|
+
width: 100%;
|
|
250
|
+
height: 100%;
|
|
251
|
+
// vertical-align: middle;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
&-content {
|
|
255
|
+
padding: 20px;
|
|
256
|
+
background: #ffffff;
|
|
257
|
+
line-height: 22px;
|
|
258
|
+
&.showRadio {
|
|
259
|
+
border-radius: @radius;
|
|
260
|
+
}
|
|
261
|
+
&.showRadio-t {
|
|
262
|
+
border-radius: @radiusSize @radiusSize 0 0;
|
|
263
|
+
}
|
|
264
|
+
// 不加这个内容content区域上下会有未知的横线
|
|
265
|
+
&.showBorder {
|
|
266
|
+
border-top: 1px solid transparent;
|
|
267
|
+
}
|
|
268
|
+
&-header {
|
|
269
|
+
text-align: center;
|
|
270
|
+
font-size: 18px;
|
|
271
|
+
color: #1b2240;
|
|
272
|
+
margin-bottom: 12px;
|
|
273
|
+
font-weight: 500;
|
|
274
|
+
}
|
|
275
|
+
&-content {
|
|
276
|
+
font-size: 16px;
|
|
277
|
+
color: #1a2242;
|
|
278
|
+
font-size: 16px;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
&-bottom {
|
|
282
|
+
// 不加这个内容content区域上下会有未知的横线
|
|
283
|
+
border-top: 1px solid transparent;
|
|
284
|
+
padding: 0 20px 20px;
|
|
285
|
+
border-radius: @radius;
|
|
286
|
+
background: #ffffff;
|
|
287
|
+
display: flex;
|
|
288
|
+
.margin-left {
|
|
289
|
+
margin-left: 15px;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
</style>
|
|
File without changes
|
|
@@ -28,6 +28,13 @@
|
|
|
28
28
|
isFreeze: {
|
|
29
29
|
default: false
|
|
30
30
|
},
|
|
31
|
+
// 是否可以切换分页的钩子,为true可切换,为false不可切换
|
|
32
|
+
canTurnPageFn: {
|
|
33
|
+
type: Function,
|
|
34
|
+
default () {
|
|
35
|
+
return () => true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
31
38
|
},
|
|
32
39
|
data () {
|
|
33
40
|
return {
|
|
@@ -54,15 +61,32 @@
|
|
|
54
61
|
}
|
|
55
62
|
},
|
|
56
63
|
methods: {
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
/**
|
|
65
|
+
* @description 校验是否可切换分页钩子
|
|
66
|
+
* @returns {Boolean} true-禁止切换 false-可切换
|
|
67
|
+
*/
|
|
68
|
+
async isLimitSwitchPage () {
|
|
69
|
+
// 钩子存在,并且不可切换分页
|
|
70
|
+
if (this.canTurnPageFn && typeof this.canTurnPageFn === 'function') {
|
|
71
|
+
let canSwitchPage = await this.canTurnPageFn()
|
|
72
|
+
if (!canSwitchPage) {
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
async nextPage () {
|
|
78
|
+
// 校验切分页钩子,判断是否可切换分页
|
|
79
|
+
let isLimitSwitch = await this.isLimitSwitchPage()
|
|
80
|
+
if (isLimitSwitch || this.nextDisabled) {
|
|
59
81
|
return
|
|
60
82
|
}
|
|
61
83
|
this.currentIndex++
|
|
62
84
|
this.$emit('turnPage', this.ids[this.currentIndex])
|
|
63
85
|
},
|
|
64
|
-
prevPage () {
|
|
65
|
-
|
|
86
|
+
async prevPage () {
|
|
87
|
+
// 校验切分页钩子,判断是否可切换分页
|
|
88
|
+
let isLimitSwitch = await this.isLimitSwitchPage()
|
|
89
|
+
if (isLimitSwitch || this.prevDisabled) {
|
|
66
90
|
return
|
|
67
91
|
}
|
|
68
92
|
this.currentIndex--
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default class RadioboxItem {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.value = ''
|
|
4
|
+
this.label = ''
|
|
5
|
+
this.selfAdaption = ''
|
|
6
|
+
this.divideeQually = ''
|
|
7
|
+
this.margin = ''
|
|
8
|
+
this.bottom = ''
|
|
9
|
+
this.index = ''
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
init (params = {}) {
|
|
13
|
+
this.initState(params)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
initState (params) {
|
|
17
|
+
const { value, label, selfAdaption, divideeQually, margin, marginBottom, index } = params
|
|
18
|
+
this.value = value
|
|
19
|
+
this.label = label
|
|
20
|
+
this.selfAdaption = selfAdaption
|
|
21
|
+
this.divideeQually = divideeQually
|
|
22
|
+
this.margin = margin
|
|
23
|
+
this.bottom = marginBottom
|
|
24
|
+
this.index = index
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getIndex () { }
|
|
28
|
+
|
|
29
|
+
get width () {
|
|
30
|
+
return this.selfAdaption ? null : `calc((100% - ${this.margin * (this.divideeQually - 1)}px) / ${this.divideeQually})`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get marginRight () {
|
|
34
|
+
return this.selfAdaption ? `${this.margin}px` : `${(this.index + 1) % this.divideeQually === 0 ? 0 : this.margin}px`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get marginBottom () {
|
|
38
|
+
return `${this.bottom}px`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const CHOOSE_TYPE = {
|
|
44
|
+
SINGLE: 'single', // 单选
|
|
45
|
+
MULTIPLE: 'multiple' // 多选
|
|
46
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export default {
|
|
3
|
+
name: 'HrRadioboxGroup',
|
|
4
|
+
provide () {
|
|
5
|
+
return {
|
|
6
|
+
divideeQually: this.divideeQually,
|
|
7
|
+
margin: this.margin,
|
|
8
|
+
marginBottom: this.marginBottom,
|
|
9
|
+
selfAdaption: this.selfAdaption,
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
props: {
|
|
13
|
+
divideeQually: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default () {
|
|
16
|
+
return 3
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
margin: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default () {
|
|
22
|
+
return 12
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
selfAdaption: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default () {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
value: {
|
|
32
|
+
type: String || Number,
|
|
33
|
+
default () {
|
|
34
|
+
return []
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
marginBottom: {
|
|
38
|
+
type: Number,
|
|
39
|
+
default () {
|
|
40
|
+
return this.margin
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
data () {
|
|
45
|
+
return {}
|
|
46
|
+
},
|
|
47
|
+
methods: {},
|
|
48
|
+
render () {
|
|
49
|
+
return <div class="hr-radiobox-group">
|
|
50
|
+
{
|
|
51
|
+
this.$slots.default
|
|
52
|
+
}
|
|
53
|
+
</div>
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<style scoped lang="less">
|
|
59
|
+
.hr-radiobox-group {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-wrap: wrap;
|
|
62
|
+
justify-content: flex-start;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import RadioboxItem from './data'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
name: 'HrRadiobox',
|
|
6
|
+
inject: {
|
|
7
|
+
selfAdaption: {
|
|
8
|
+
from: 'selfAdaption',
|
|
9
|
+
default () {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
divideeQually: {
|
|
14
|
+
from: 'divideeQually',
|
|
15
|
+
default () {
|
|
16
|
+
return 3
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
margin: {
|
|
20
|
+
from: 'margin',
|
|
21
|
+
default () {
|
|
22
|
+
return 12
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
marginBottom: {
|
|
26
|
+
from: 'marginBottom',
|
|
27
|
+
default () {
|
|
28
|
+
return this.margin
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
props: {
|
|
33
|
+
index: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default () {
|
|
36
|
+
return 0
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
value: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default () {
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
label: {
|
|
46
|
+
type: String,
|
|
47
|
+
default () {
|
|
48
|
+
return '暂无'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
disabled: { // 禁用
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default () {
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
data () {
|
|
59
|
+
return {
|
|
60
|
+
radioboxItem: new RadioboxItem(),
|
|
61
|
+
selfModel: false
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
computed: {
|
|
65
|
+
// 中间层
|
|
66
|
+
model: {
|
|
67
|
+
get () {
|
|
68
|
+
return this.isGroup ? this._radioboxGroup.value : this.value
|
|
69
|
+
},
|
|
70
|
+
set (val) {
|
|
71
|
+
if (this.isGroup) {
|
|
72
|
+
this.dispatch('HrRadioboxGroup', 'input', [val])
|
|
73
|
+
} else {
|
|
74
|
+
this.$emit('input', val)
|
|
75
|
+
this.selfModel = val
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
//是否有group
|
|
80
|
+
isGroup () {
|
|
81
|
+
let parent = this.$parent
|
|
82
|
+
while (parent) {
|
|
83
|
+
if (parent.$options.name !== 'HrRadioboxGroup') {
|
|
84
|
+
parent = parent.$parent
|
|
85
|
+
} else {
|
|
86
|
+
this._radioboxGroup = parent
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false
|
|
91
|
+
},
|
|
92
|
+
isChecked () {
|
|
93
|
+
return this.model === this.label
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
methods: {
|
|
97
|
+
// 修改父组件数组
|
|
98
|
+
dispatch (componentName, eventName, params) {
|
|
99
|
+
let parent = this.$parent || this.$root
|
|
100
|
+
let name = parent.$options.name
|
|
101
|
+
|
|
102
|
+
while (parent && (!name || name !== componentName)) {
|
|
103
|
+
(parent = parent.$parent) && (name = parent.$options.name)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
parent && parent.$emit.apply(parent, [eventName].concat(params))
|
|
107
|
+
},
|
|
108
|
+
handleChange () {
|
|
109
|
+
this.setModel()
|
|
110
|
+
this.$emit('change', this.model)
|
|
111
|
+
this.$nextTick(() => {
|
|
112
|
+
this.dispatch('HrRadioboxGroup', 'change', this._radioboxGroup.value)
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
setModel () {
|
|
116
|
+
this.model = this.isChecked ? null : this.label
|
|
117
|
+
},
|
|
118
|
+
getIndex () {
|
|
119
|
+
return this.$parent.$children.indexOf(this)
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
render () {
|
|
123
|
+
const { value, label, selfAdaption, divideeQually, margin, marginBottom } = this
|
|
124
|
+
const index = this.getIndex()
|
|
125
|
+
this.radioboxItem.init({
|
|
126
|
+
value,
|
|
127
|
+
label,
|
|
128
|
+
selfAdaption,
|
|
129
|
+
divideeQually,
|
|
130
|
+
margin,
|
|
131
|
+
marginBottom,
|
|
132
|
+
index,
|
|
133
|
+
vm: this,
|
|
134
|
+
})
|
|
135
|
+
return <div
|
|
136
|
+
onClick={this.handleChange}
|
|
137
|
+
index={index}
|
|
138
|
+
style={{
|
|
139
|
+
width: this.radioboxItem.width,
|
|
140
|
+
marginRight: this.radioboxItem.marginRight,
|
|
141
|
+
marginBottom: this.radioboxItem.marginBottom,
|
|
142
|
+
}}
|
|
143
|
+
class={[
|
|
144
|
+
'hr-radiobox',
|
|
145
|
+
'ellipsis',
|
|
146
|
+
this.isChecked && 'checked',
|
|
147
|
+
]}>
|
|
148
|
+
{label}
|
|
149
|
+
</div>
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
</script>
|
|
153
|
+
|
|
154
|
+
<style scoped lang="less">
|
|
155
|
+
.ellipsis {
|
|
156
|
+
overflow: hidden;
|
|
157
|
+
white-space: nowrap;
|
|
158
|
+
text-overflow: ellipsis;
|
|
159
|
+
}
|
|
160
|
+
.hr-radiobox {
|
|
161
|
+
height: 28px;
|
|
162
|
+
border-radius: 8px;
|
|
163
|
+
box-sizing: border-box;
|
|
164
|
+
background: #f7f8fa;
|
|
165
|
+
text-align: center;
|
|
166
|
+
line-height: 27px;
|
|
167
|
+
color: #03050d;
|
|
168
|
+
font-size: 12px;
|
|
169
|
+
padding: 0 8px;
|
|
170
|
+
position: relative;
|
|
171
|
+
&.checked {
|
|
172
|
+
background: rgba(121, 114, 254, 0.08);
|
|
173
|
+
color: #7972fe;
|
|
174
|
+
&::after {
|
|
175
|
+
content: " ";
|
|
176
|
+
position: absolute;
|
|
177
|
+
left: 0;
|
|
178
|
+
top: 0;
|
|
179
|
+
width: calc(200% - 2px);
|
|
180
|
+
height: calc(200% - 2px);
|
|
181
|
+
border: 1px solid #7972fe;
|
|
182
|
+
border-radius: 16px;
|
|
183
|
+
box-sizing: border-box;
|
|
184
|
+
-webkit-transform-origin: 0 0;
|
|
185
|
+
transform-origin: 0 0;
|
|
186
|
+
-webkit-transform: scale(0.5);
|
|
187
|
+
transform: scale(0.5);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
</style>
|