@kyfe/hroa-ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/demo.html +8 -0
- package/dist/hrui.common.js +3892 -0
- package/dist/hrui.common.js.map +1 -0
- package/dist/hrui.umd.js +3902 -0
- package/dist/hrui.umd.js.map +1 -0
- package/dist/hrui.umd.min.js +2 -0
- package/dist/hrui.umd.min.js.map +1 -0
- package/lib/hr-bottom-button/index.css +1 -0
- package/lib/hr-bottom-button/index.js +1 -0
- package/lib/hr-button/index.css +1 -0
- package/lib/hr-button/index.js +1 -0
- package/lib/hr-clipboard/index.css +1 -0
- package/lib/hr-clipboard/index.js +1 -0
- package/lib/hr-condition-filtrate/index.css +1 -0
- package/lib/hr-condition-filtrate/index.js +1 -0
- package/lib/hr-emotional-picture/index.css +1 -0
- package/lib/hr-emotional-picture/index.js +1 -0
- package/lib/hr-module-card/index.css +1 -0
- package/lib/hr-module-card/index.js +1 -0
- package/lib/hr-notice-bar/index.js +1 -0
- package/lib/hr-open-ks/index.css +1 -0
- package/lib/hr-open-ks/index.js +1 -0
- package/lib/hr-pager/index.css +1 -0
- package/lib/hr-pager/index.js +1 -0
- package/lib/hr-search-input/index.css +1 -0
- package/lib/hr-search-input/index.js +1 -0
- package/lib/hr-select/index.js +1 -0
- package/lib/hr-slide-pager/index.css +1 -0
- package/lib/hr-slide-pager/index.js +1 -0
- package/lib/hr-stack-image/index.css +1 -0
- package/lib/hr-stack-image/index.js +1 -0
- package/lib/hr-tab-nav/index.css +1 -0
- package/lib/hr-tab-nav/index.js +1 -0
- package/lib/hr-view-item/index.css +1 -0
- package/lib/hr-view-item/index.js +1 -0
- package/lib/index/index.css +1 -0
- package/lib/index/index.js +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +66 -0
- package/packages/hr-bottom-button/index.js +7 -0
- package/packages/hr-bottom-button/src/index.vue +85 -0
- package/packages/hr-button/index.js +13 -0
- package/packages/hr-button/src/hr-button.vue +39 -0
- package/packages/hr-clipboard/index.js +3 -0
- package/packages/hr-clipboard/src/icon.png +0 -0
- package/packages/hr-clipboard/src/main.vue +64 -0
- package/packages/hr-clipboard/src/util.js +9 -0
- package/packages/hr-condition-filtrate/enum/index.js +11 -0
- package/packages/hr-condition-filtrate/image/arrow-right.png +0 -0
- package/packages/hr-condition-filtrate/index.js +7 -0
- package/packages/hr-condition-filtrate/src/employee-choose/index.vue +101 -0
- package/packages/hr-condition-filtrate/src/index.vue +246 -0
- package/packages/hr-condition-filtrate/src/multiterm-choose/index.vue +167 -0
- package/packages/hr-condition-filtrate/src/org-tree-choose/index.vue +102 -0
- package/packages/hr-condition-filtrate/src/single-choose/index.vue +144 -0
- package/packages/hr-condition-filtrate/src/text-input/index.vue +60 -0
- package/packages/hr-condition-filtrate/src/time-selector/date-range-select.vue +154 -0
- package/packages/hr-condition-filtrate/src/time-selector/images/date-icon.png +0 -0
- package/packages/hr-condition-filtrate/src/time-selector/index.vue +380 -0
- package/packages/hr-condition-filtrate/src/time-selector/utils/constant.js +30 -0
- package/packages/hr-condition-filtrate/src/time-selector/utils/tools.js +213 -0
- package/packages/hr-emotional-picture/index.js +7 -0
- package/packages/hr-emotional-picture/src/index.vue +66 -0
- package/packages/hr-emotional-picture//346/203/205/346/204/237/345/233/276/347/273/204/344/273/266.md +0 -0
- package/packages/hr-module-card/index.js +13 -0
- package/packages/hr-module-card/src/index.vue +132 -0
- package/packages/hr-module-card//346/250/241/345/235/227/345/215/241/347/211/207/347/273/204/344/273/266.md +29 -0
- package/packages/hr-notice-bar/index.js +7 -0
- package/packages/hr-notice-bar/src/bem.js +38 -0
- package/packages/hr-notice-bar/src/index.js +52 -0
- package/packages/hr-notice-bar//351/200/232/347/237/245/346/240/217/347/273/204/344/273/266.md +3 -0
- package/packages/hr-open-ks/index.js +3 -0
- package/packages/hr-open-ks/src/icon.png +0 -0
- package/packages/hr-open-ks/src/main.vue +85 -0
- package/packages/hr-open-ks/src/util.js +31 -0
- package/packages/hr-pager/images/next-page.png +0 -0
- package/packages/hr-pager/images/prev-page.png +0 -0
- package/packages/hr-pager/index.js +7 -0
- package/packages/hr-pager/src/index.vue +95 -0
- package/packages/hr-pager//346/214/211/351/222/256/347/277/273/351/241/265/347/273/204/344/273/266.md +0 -0
- package/packages/hr-search-input/image/input-close-icon.png +0 -0
- package/packages/hr-search-input/image/search-icon.png +0 -0
- package/packages/hr-search-input/index.js +8 -0
- package/packages/hr-search-input/src/index.vue +144 -0
- package/packages/hr-select/index.js +3 -0
- package/packages/hr-select/src/main.vue +62 -0
- package/packages/hr-slide-pager/guide/image/turn-left.png +0 -0
- package/packages/hr-slide-pager/guide/image/turn-right.png +0 -0
- package/packages/hr-slide-pager/guide/index.vue +59 -0
- package/packages/hr-slide-pager/guide//346/226/260/346/211/213/346/214/207/345/274/225.md +0 -0
- package/packages/hr-slide-pager/index.js +7 -0
- package/packages/hr-slide-pager/src/index.vue +371 -0
- package/packages/hr-slide-pager//346/273/221/345/212/250/347/277/273/351/241/265/347/273/204/344/273/266.md +0 -0
- package/packages/hr-stack-image/index.js +3 -0
- package/packages/hr-stack-image/src/main.vue +77 -0
- package/packages/hr-stack-image//345/261/202/345/217/240/345/233/276/347/211/207/347/273/204/344/273/266.md +0 -0
- package/packages/hr-tab-nav/index.js +8 -0
- package/packages/hr-tab-nav/src/index.vue +96 -0
- package/packages/hr-view-item/index.js +13 -0
- package/packages/hr-view-item/src/index.vue +89 -0
- package/packages/hr-view-item//350/241/250/345/215/225/351/241/271item/345/261/225/347/244/272.md +0 -0
- package/packages/index.js +53 -0
- package/packages/utils/directive.js +58 -0
- package/packages/utils/index.js +73 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import DateRangeSelect from './date-range-select.vue'
|
|
3
|
+
import { hrDayJs } from './utils/tools'
|
|
4
|
+
import { DATE_SHORTCUT_PARAMS } from '../../enum/index.js'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
name: 'TimeSelector',
|
|
9
|
+
components: {
|
|
10
|
+
DateRangeSelect,
|
|
11
|
+
},
|
|
12
|
+
props: {
|
|
13
|
+
comItem: {
|
|
14
|
+
type: Object,
|
|
15
|
+
default: () => ({})
|
|
16
|
+
},
|
|
17
|
+
type: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: 'daterange'
|
|
20
|
+
},
|
|
21
|
+
min: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: '2020/01/01'
|
|
24
|
+
},
|
|
25
|
+
isTab: { // 是否显示快捷按钮
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true
|
|
28
|
+
},
|
|
29
|
+
defaultValue: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 1
|
|
32
|
+
},
|
|
33
|
+
defaultType: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: 'month'
|
|
36
|
+
},
|
|
37
|
+
title: {
|
|
38
|
+
type: String,
|
|
39
|
+
default () {
|
|
40
|
+
return '请选择'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
data () {
|
|
45
|
+
return {
|
|
46
|
+
startDate: '',
|
|
47
|
+
endDate: '',
|
|
48
|
+
show: false,
|
|
49
|
+
defaultDate: [],
|
|
50
|
+
active: '',
|
|
51
|
+
maxDate: hrDayJs(new Date())
|
|
52
|
+
.subtract(-1, 'month')
|
|
53
|
+
.format('YYYY/MM/DD'),
|
|
54
|
+
selectValue: [],
|
|
55
|
+
dateKey: 1
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
mounted () {
|
|
59
|
+
this.initDate();
|
|
60
|
+
},
|
|
61
|
+
methods: {
|
|
62
|
+
handleChoose (active) {
|
|
63
|
+
const param = DATE_SHORTCUT_PARAMS[active]
|
|
64
|
+
const { count, type } = param
|
|
65
|
+
this.startDate = hrDayJs().subtract(count, type).format('YYYY/MM/DD')
|
|
66
|
+
this.endDate = hrDayJs().format('YYYY/MM/DD')
|
|
67
|
+
this.active = active
|
|
68
|
+
this.defaultDate = [this.startDate + ' 00:00:00', this.endDate + ' 23:59:59']
|
|
69
|
+
this.$emit('input', this.defaultDate)
|
|
70
|
+
},
|
|
71
|
+
initDate () {
|
|
72
|
+
let startDate = hrDayJs(new Date()).subtract(this.defaultValue, this.defaultType).format('YYYY/MM')
|
|
73
|
+
let endDate = hrDayJs(new Date()).format('YYYY/MM/DD')
|
|
74
|
+
this.defaultDate = [startDate + '/01 00:00:00', endDate + ' 23:59:59']
|
|
75
|
+
this.selectValue = { str: [startDate, endDate] }
|
|
76
|
+
this.startDate = null
|
|
77
|
+
this.endDate = null
|
|
78
|
+
this.active = ''
|
|
79
|
+
// this.comItem.value = []
|
|
80
|
+
},
|
|
81
|
+
closePop () {
|
|
82
|
+
this.show = false
|
|
83
|
+
},
|
|
84
|
+
showPop () {
|
|
85
|
+
this.show = true
|
|
86
|
+
},
|
|
87
|
+
// 校验时间差
|
|
88
|
+
timeDifference (date1, date2) {
|
|
89
|
+
date1 = new Date(date1)
|
|
90
|
+
date2 = new Date(date2)
|
|
91
|
+
var newYear = date1.getFullYear()
|
|
92
|
+
var newMonth = date1.getMonth() + 2
|
|
93
|
+
if (newMonth >= 11) {
|
|
94
|
+
newYear += 1
|
|
95
|
+
newMonth -= 11
|
|
96
|
+
date1.setFullYear(newYear)
|
|
97
|
+
date1.setMonth(newMonth - 1)
|
|
98
|
+
} else {
|
|
99
|
+
date1.setFullYear(newYear)
|
|
100
|
+
date1.setMonth(newMonth)
|
|
101
|
+
}
|
|
102
|
+
if (date1.getTime() >= date2.getTime()) {
|
|
103
|
+
return true
|
|
104
|
+
} else {
|
|
105
|
+
return false
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
// 时间选择器确认事件
|
|
109
|
+
onSelect (value) {
|
|
110
|
+
this.selectValue = value
|
|
111
|
+
},
|
|
112
|
+
submit () {
|
|
113
|
+
console.log('submit', this.selectValue)
|
|
114
|
+
let value = this.selectValue
|
|
115
|
+
if (value.str && value.str.length && value.str[1]) {
|
|
116
|
+
let res = this.timeDifference(value.str[0] + ' 00:00:00', value.str[1] + ' 00:00:00')
|
|
117
|
+
if (res) {
|
|
118
|
+
this.startDate = value.str[0]
|
|
119
|
+
this.endDate = value.str[1]
|
|
120
|
+
let val = [value.str[0] + ' 00:00:00', value.str[1] + ' 23:59:59']
|
|
121
|
+
this.defaultDate = val
|
|
122
|
+
this.$emit('input', val)
|
|
123
|
+
this.active = ''
|
|
124
|
+
this.show = false
|
|
125
|
+
} else {
|
|
126
|
+
this.$toast('选择时间不能超过2个月')
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
} else {
|
|
130
|
+
this.$toast('请选择结束时间')
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
reset () {
|
|
134
|
+
this.initDate()
|
|
135
|
+
this.dateKey++
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
render () {
|
|
139
|
+
{/* 渲染时间范围选择框 */ }
|
|
140
|
+
const renderRangeInputBox = () => {
|
|
141
|
+
return <div class="input-box">
|
|
142
|
+
<span>{this.startDate}</span>
|
|
143
|
+
<span class="mid-key"> - </span>
|
|
144
|
+
<span>{this.endDate}</span>
|
|
145
|
+
</div>
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
{/* 渲染单个时间选择框 */ }
|
|
149
|
+
const renderInputBox = () => {
|
|
150
|
+
return <div class="input-box">
|
|
151
|
+
<span>{this.defaultDate}</span>
|
|
152
|
+
</div>
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
{/* 快捷选项 */ }
|
|
156
|
+
const renderSelectorShortcutBox = () => {
|
|
157
|
+
return <div class="selector-shortcut">
|
|
158
|
+
{
|
|
159
|
+
Object.keys(DATE_SHORTCUT_PARAMS).map((key) => {
|
|
160
|
+
return <div class={["shortcut-item", key == this.active ? 'active' : '']}
|
|
161
|
+
onClick={this.handleChoose.bind(this, key)}
|
|
162
|
+
key={key}>{DATE_SHORTCUT_PARAMS[key].text}</div>
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
</div>
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return <div class="time-selector">
|
|
169
|
+
{/* 头部 */}
|
|
170
|
+
<div class="selector-title">{this.title}</div>
|
|
171
|
+
{/* 选择框 */}
|
|
172
|
+
<div class="selector-input" onClick={this.showPop}>
|
|
173
|
+
{this.type == 'daterange' && renderRangeInputBox()}
|
|
174
|
+
{this.type == 'date' && renderInputBox()}
|
|
175
|
+
<span class="input-icon"></span>
|
|
176
|
+
</div>
|
|
177
|
+
{/* 是否显示快捷按钮 */}
|
|
178
|
+
{this.isTab && renderSelectorShortcutBox()}
|
|
179
|
+
{/* 时间选择框 */}
|
|
180
|
+
<div class="selector-popup">
|
|
181
|
+
<van-popup
|
|
182
|
+
value={this.show}
|
|
183
|
+
onInput={(value) => { this.show = value }}
|
|
184
|
+
style="height: 100%"
|
|
185
|
+
get-container="body"
|
|
186
|
+
position="right">
|
|
187
|
+
<div class="popup-date">
|
|
188
|
+
<header class="ksui-header">
|
|
189
|
+
<div class="back-icon" onClick={() => { this.show = false }}>
|
|
190
|
+
<van-icon size={15} name="arrow-left" />
|
|
191
|
+
<span>选择时间段</span>
|
|
192
|
+
</div>
|
|
193
|
+
</header>
|
|
194
|
+
<div class="date-content">
|
|
195
|
+
<DateRangeSelect defaultValue={this.defaultDate}
|
|
196
|
+
v-show={this.show}
|
|
197
|
+
key={this.dateKey}
|
|
198
|
+
min={this.min}
|
|
199
|
+
max={this.maxDate}
|
|
200
|
+
ref="dateRangeSelect"
|
|
201
|
+
onSelect={this.onSelect} />
|
|
202
|
+
</div>
|
|
203
|
+
<div class="date-footer">
|
|
204
|
+
<van-button type="default" onClick={this.reset} class="footer-btn left-btn">重置</van-button>
|
|
205
|
+
<van-button type="primary" onClick={this.submit} class="footer-btn">确定</van-button>
|
|
206
|
+
</div>
|
|
207
|
+
</div >
|
|
208
|
+
</van-popup>
|
|
209
|
+
</div>
|
|
210
|
+
</div >
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
</script>
|
|
214
|
+
|
|
215
|
+
<style lang="less" scoped>
|
|
216
|
+
/deep/.van-calendar__body {
|
|
217
|
+
.van-calendar__day--disabled {
|
|
218
|
+
color: #ccc;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/deep/.ksui-header {
|
|
222
|
+
.back-icon {
|
|
223
|
+
font-weight: 600 !important;
|
|
224
|
+
font-size: 16px !important;
|
|
225
|
+
.van-icon {
|
|
226
|
+
font-weight: 600 !important;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
.time-selector {
|
|
231
|
+
width: 100%;
|
|
232
|
+
text-align: center;
|
|
233
|
+
line-height: 38px;
|
|
234
|
+
.selector-title {
|
|
235
|
+
line-height: 20px;
|
|
236
|
+
margin-bottom: 12px;
|
|
237
|
+
text-align: left;
|
|
238
|
+
font-size: 14px;
|
|
239
|
+
font-weight: 600;
|
|
240
|
+
color: #03050d;
|
|
241
|
+
.title-black {
|
|
242
|
+
font-size: 14px;
|
|
243
|
+
font-weight: normal;
|
|
244
|
+
color: #6e6d72;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
.selector-input {
|
|
248
|
+
background: #f3f4f6;
|
|
249
|
+
border-radius: 8px;
|
|
250
|
+
color: #232323;
|
|
251
|
+
display: flex;
|
|
252
|
+
justify-content: space-between;
|
|
253
|
+
padding: 0 20px;
|
|
254
|
+
align-items: center;
|
|
255
|
+
line-height: 32px;
|
|
256
|
+
.input-box {
|
|
257
|
+
font-size: 14px;
|
|
258
|
+
color: #333333;
|
|
259
|
+
display: flex;
|
|
260
|
+
justify-content: space-between;
|
|
261
|
+
width: 100%;
|
|
262
|
+
span {
|
|
263
|
+
flex: 3;
|
|
264
|
+
}
|
|
265
|
+
.mid-key {
|
|
266
|
+
flex: 1;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
.input-icon {
|
|
270
|
+
display: inline-block;
|
|
271
|
+
width: 14px;
|
|
272
|
+
height: 14px;
|
|
273
|
+
background: url("./images/date-icon.png") no-repeat;
|
|
274
|
+
background-size: 100%;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
.selector-shortcut {
|
|
278
|
+
display: flex;
|
|
279
|
+
flex-wrap: wrap;
|
|
280
|
+
// justify-content: space-between;
|
|
281
|
+
justify-content: flex-start;
|
|
282
|
+
|
|
283
|
+
margin-top: 12px;
|
|
284
|
+
.shortcut-item {
|
|
285
|
+
width: calc((100% - 16px) / 3);
|
|
286
|
+
text-align: center;
|
|
287
|
+
background: #f3f4f6;
|
|
288
|
+
border-radius: 8px;
|
|
289
|
+
margin-bottom: 11px;
|
|
290
|
+
margin-right: 8px;
|
|
291
|
+
line-height: 28px;
|
|
292
|
+
font-size: 12px;
|
|
293
|
+
color: #03050d;
|
|
294
|
+
|
|
295
|
+
&.active {
|
|
296
|
+
// border: 1px solid #7972fe;
|
|
297
|
+
background: rgba(121, 114, 254, 0.08);
|
|
298
|
+
color: #7972fe;
|
|
299
|
+
position: relative;
|
|
300
|
+
&::after {
|
|
301
|
+
content: " ";
|
|
302
|
+
position: absolute;
|
|
303
|
+
left: 0;
|
|
304
|
+
top: 0;
|
|
305
|
+
width: 200%;
|
|
306
|
+
height: 200%;
|
|
307
|
+
border: 1px solid #7972fe;
|
|
308
|
+
border-radius: 16px;
|
|
309
|
+
-webkit-transform-origin: 0 0;
|
|
310
|
+
transform-origin: 0 0;
|
|
311
|
+
-webkit-transform: scale(0.5);
|
|
312
|
+
transform: scale(0.5);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
.shortcut-item:nth-child(3n) {
|
|
317
|
+
margin-right: 0;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
.popup-date {
|
|
322
|
+
.back-icon {
|
|
323
|
+
font-size: 14px;
|
|
324
|
+
color: #03050d;
|
|
325
|
+
font-weight: 500;
|
|
326
|
+
display: inline-block;
|
|
327
|
+
padding: 12px;
|
|
328
|
+
i {
|
|
329
|
+
position: relative;
|
|
330
|
+
top: -1px;
|
|
331
|
+
}
|
|
332
|
+
span {
|
|
333
|
+
margin-left: 2px;
|
|
334
|
+
position: relative;
|
|
335
|
+
top: -3px;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/deep/ .van-calendar__bottom-info {
|
|
339
|
+
bottom: 1px !important;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
.date-footer {
|
|
343
|
+
width: 100%;
|
|
344
|
+
padding: 14px 20px;
|
|
345
|
+
// height: 64px;
|
|
346
|
+
flex-shrink: 0;
|
|
347
|
+
display: flex;
|
|
348
|
+
justify-content: space-around;
|
|
349
|
+
align-items: center;
|
|
350
|
+
overflow: hidden;
|
|
351
|
+
box-sizing: border-box;
|
|
352
|
+
.footer-btn {
|
|
353
|
+
height: 36px;
|
|
354
|
+
width: 44%;
|
|
355
|
+
border-radius: 8px;
|
|
356
|
+
height: 40px;
|
|
357
|
+
}
|
|
358
|
+
.left-btn {
|
|
359
|
+
color: #8b83fc;
|
|
360
|
+
position: relative;
|
|
361
|
+
border: none;
|
|
362
|
+
font-size: 16px;
|
|
363
|
+
height: 40px;
|
|
364
|
+
&::after {
|
|
365
|
+
content: " ";
|
|
366
|
+
position: absolute;
|
|
367
|
+
left: 0;
|
|
368
|
+
top: 0;
|
|
369
|
+
width: 200%;
|
|
370
|
+
height: 200%;
|
|
371
|
+
border: 1px solid #7972fe;
|
|
372
|
+
border-radius: 16px;
|
|
373
|
+
-webkit-transform-origin: 0 0;
|
|
374
|
+
transform-origin: 0 0;
|
|
375
|
+
-webkit-transform: scale(0.5);
|
|
376
|
+
transform: scale(0.5);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const SECONDS_A_MINUTE = 60
|
|
2
|
+
export const SECONDS_A_HOUR = SECONDS_A_MINUTE * 60
|
|
3
|
+
export const SECONDS_A_DAY = SECONDS_A_HOUR * 24
|
|
4
|
+
export const SECONDS_A_WEEK = SECONDS_A_DAY * 7
|
|
5
|
+
|
|
6
|
+
export const MILLISECONDS_A_SECOND = 1e3
|
|
7
|
+
export const MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND
|
|
8
|
+
export const MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND
|
|
9
|
+
export const MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND
|
|
10
|
+
export const MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND
|
|
11
|
+
|
|
12
|
+
// English locales
|
|
13
|
+
export const MS = 'millisecond'
|
|
14
|
+
export const S = 'second'
|
|
15
|
+
export const MIN = 'minute'
|
|
16
|
+
export const H = 'hour'
|
|
17
|
+
export const D = 'day'
|
|
18
|
+
export const W = 'week'
|
|
19
|
+
export const M = 'month'
|
|
20
|
+
export const Q = 'quarter'
|
|
21
|
+
export const Y = 'year'
|
|
22
|
+
export const DATE = 'date'
|
|
23
|
+
|
|
24
|
+
export const FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ssZ'
|
|
25
|
+
|
|
26
|
+
export const INVALID_DATE_STRING = 'Invalid Date'
|
|
27
|
+
|
|
28
|
+
// regex
|
|
29
|
+
export const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/
|
|
30
|
+
export const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import * as C from './constant'
|
|
2
|
+
|
|
3
|
+
// const IS_DAYJS = '$isDayjsObject'
|
|
4
|
+
// const isDayjs = d => d instanceof HrDayJs || !!(d && d[IS_DAYJS])
|
|
5
|
+
|
|
6
|
+
// 时间对象格式为文本格式
|
|
7
|
+
export const formatToString = (date, type) => {
|
|
8
|
+
if (!date) { return null }
|
|
9
|
+
|
|
10
|
+
let _date = new Date(date)
|
|
11
|
+
let y = _date.getFullYear()
|
|
12
|
+
let m = _date.getMonth() + 1
|
|
13
|
+
m = m < 10 ? '0' + m : m
|
|
14
|
+
let d = _date.getDate()
|
|
15
|
+
d = d < 10 ? '0' + d : d
|
|
16
|
+
return type === 'month' ? `${y}/${m}` : `${y}/${m}/${d}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 字符串转换为时间
|
|
20
|
+
export const formatToDate = (date) => {
|
|
21
|
+
if (!date) { return null }
|
|
22
|
+
return new Date(typeof date === 'string' ? date.replace(/-/g, "/") : date)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 暴露出去的主函数
|
|
26
|
+
export const hrDayJs = (date) => {
|
|
27
|
+
return new HrDayJs(date)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 克隆
|
|
31
|
+
const wrapper = (date) => {
|
|
32
|
+
return hrDayJs(date)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class HrDayJs {
|
|
36
|
+
constructor(date) {
|
|
37
|
+
this.$d = formatToDate(date || new Date())
|
|
38
|
+
this.init()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
init () {
|
|
42
|
+
const { $d } = this
|
|
43
|
+
this.$y = $d.getFullYear()
|
|
44
|
+
this.$M = $d.getMonth()
|
|
45
|
+
this.$D = $d.getDate()
|
|
46
|
+
this.$W = $d.getDay()
|
|
47
|
+
this.$H = $d.getHours()
|
|
48
|
+
this.$m = $d.getMinutes()
|
|
49
|
+
this.$s = $d.getSeconds()
|
|
50
|
+
this.$ms = $d.getMilliseconds()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toString () {
|
|
54
|
+
return formatToString(this.$d)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
subtract (number, string) {
|
|
58
|
+
return this.add(number * -1, string)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
add (number, unit) {
|
|
62
|
+
number = Number(number) // eslint-disable-line no-param-reassign
|
|
63
|
+
const instanceFactorySet = (n) => {
|
|
64
|
+
const d = hrDayJs(this)
|
|
65
|
+
return wrapper(d.date(d.date() + Math.round(n * number)), this)
|
|
66
|
+
}
|
|
67
|
+
if (unit === C.M) {
|
|
68
|
+
return this.set(C.M, this.$M + number)
|
|
69
|
+
}
|
|
70
|
+
if (unit === C.Y) {
|
|
71
|
+
return this.set(C.Y, this.$y + number)
|
|
72
|
+
}
|
|
73
|
+
if (unit === C.D) {
|
|
74
|
+
return instanceFactorySet(1)
|
|
75
|
+
}
|
|
76
|
+
if (unit === C.W) {
|
|
77
|
+
return instanceFactorySet(7)
|
|
78
|
+
}
|
|
79
|
+
const step = {
|
|
80
|
+
[C.MIN]: C.MILLISECONDS_A_MINUTE,
|
|
81
|
+
[C.H]: C.MILLISECONDS_A_HOUR,
|
|
82
|
+
[C.S]: C.MILLISECONDS_A_SECOND
|
|
83
|
+
}[unit] || 1 // ms
|
|
84
|
+
|
|
85
|
+
const nextTimeStamp = this.$d.getTime() + (number * step)
|
|
86
|
+
return wrapper(nextTimeStamp)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
format (formatStr) {
|
|
90
|
+
let str = '-'
|
|
91
|
+
switch (formatStr) {
|
|
92
|
+
case 'YYYY/MM/DD': str = '/'; break;
|
|
93
|
+
}
|
|
94
|
+
return `${this.$y}${str}${this.formatNumber(this.$M + 1)}${str}${this.formatNumber(this.$D)}`
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
formatNumber (number) {
|
|
98
|
+
return number < 10 ? '0' + number : number
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
valueOf () {
|
|
102
|
+
return this.$d.getTime()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
clone () {
|
|
106
|
+
return wrapper(this.$d)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
set (string, int) {
|
|
110
|
+
return this.clone().$set(string, int)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
$set (unit, int) { // private set
|
|
114
|
+
const utcPad = `set${this.$u ? 'UTC' : ''}`
|
|
115
|
+
const name = {
|
|
116
|
+
[C.D]: `${utcPad}Date`,
|
|
117
|
+
[C.DATE]: `${utcPad}Date`,
|
|
118
|
+
[C.M]: `${utcPad}Month`,
|
|
119
|
+
[C.Y]: `${utcPad}FullYear`,
|
|
120
|
+
[C.H]: `${utcPad}Hours`,
|
|
121
|
+
[C.MIN]: `${utcPad}Minutes`,
|
|
122
|
+
[C.S]: `${utcPad}Seconds`,
|
|
123
|
+
[C.MS]: `${utcPad}Milliseconds`
|
|
124
|
+
}[unit]
|
|
125
|
+
const arg = unit === C.D ? this.$D + (int - this.$W) : int
|
|
126
|
+
if (unit === C.M || unit === C.Y) {
|
|
127
|
+
const date = this.clone().set(C.DATE, 1)
|
|
128
|
+
date.$d[name](arg)
|
|
129
|
+
date.init()
|
|
130
|
+
this.$d = date.set(C.DATE, Math.min(this.$D, date.daysInMonth())).$d
|
|
131
|
+
} else if (name) this.$d[name](arg)
|
|
132
|
+
|
|
133
|
+
this.init()
|
|
134
|
+
return this
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
startOf (unit, startOf) { // startOf -> endOf
|
|
138
|
+
const isStartOf = !(startOf === undefined) ? startOf : true
|
|
139
|
+
const instanceFactory = (d, m) => {
|
|
140
|
+
const ins = wrapper(this.$u ?
|
|
141
|
+
Date.UTC(this.$y, m, d) : new Date(this.$y, m, d), this)
|
|
142
|
+
return isStartOf ? ins : ins.endOf(C.D)
|
|
143
|
+
}
|
|
144
|
+
const instanceFactorySet = (method, slice) => {
|
|
145
|
+
const argumentStart = [0, 0, 0, 0]
|
|
146
|
+
const argumentEnd = [23, 59, 59, 999]
|
|
147
|
+
return wrapper(this.toDate()[method].apply( // eslint-disable-line prefer-spread
|
|
148
|
+
this.toDate('s'),
|
|
149
|
+
(isStartOf ? argumentStart : argumentEnd).slice(slice)
|
|
150
|
+
), this)
|
|
151
|
+
}
|
|
152
|
+
const { $W, $M, $D } = this
|
|
153
|
+
const utcPad = `set${this.$u ? 'UTC' : ''}`
|
|
154
|
+
switch (unit) {
|
|
155
|
+
case C.Y:
|
|
156
|
+
return isStartOf ? instanceFactory(1, 0) :
|
|
157
|
+
instanceFactory(31, 11)
|
|
158
|
+
case C.M:
|
|
159
|
+
return isStartOf ? instanceFactory(1, $M) :
|
|
160
|
+
instanceFactory(0, $M + 1)
|
|
161
|
+
case C.W: {
|
|
162
|
+
const weekStart = this.$locale().weekStart || 0
|
|
163
|
+
const gap = ($W < weekStart ? $W + 7 : $W) - weekStart
|
|
164
|
+
return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M)
|
|
165
|
+
}
|
|
166
|
+
case C.D:
|
|
167
|
+
case C.DATE:
|
|
168
|
+
return instanceFactorySet(`${utcPad}Hours`, 0)
|
|
169
|
+
case C.H:
|
|
170
|
+
return instanceFactorySet(`${utcPad}Minutes`, 1)
|
|
171
|
+
case C.MIN:
|
|
172
|
+
return instanceFactorySet(`${utcPad}Seconds`, 2)
|
|
173
|
+
case C.S:
|
|
174
|
+
return instanceFactorySet(`${utcPad}Milliseconds`, 3)
|
|
175
|
+
default:
|
|
176
|
+
return this.clone()
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
endOf (arg) {
|
|
181
|
+
return this.startOf(arg, false)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
toDate () {
|
|
185
|
+
return new Date(this.valueOf())
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
daysInMonth () {
|
|
189
|
+
return this.endOf(C.M).$D
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
$g (input, get, set) {
|
|
193
|
+
if (input === undefined) return this[get]
|
|
194
|
+
return this.set(set, input)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const proto = HrDayJs.prototype
|
|
199
|
+
hrDayJs.prototype = proto;
|
|
200
|
+
[
|
|
201
|
+
['$ms', C.MS],
|
|
202
|
+
['$s', C.S],
|
|
203
|
+
['$m', C.MIN],
|
|
204
|
+
['$H', C.H],
|
|
205
|
+
['$W', C.D],
|
|
206
|
+
['$M', C.M],
|
|
207
|
+
['$y', C.Y],
|
|
208
|
+
['$D', C.DATE]
|
|
209
|
+
].forEach((g) => {
|
|
210
|
+
proto[g[1]] = function (input) {
|
|
211
|
+
return this.$g(input, g[0], g[1])
|
|
212
|
+
}
|
|
213
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
const baseUrl = 'https://erphostjs.kye-erp.com/hr-oa-kts/ks-app/common/emotion/'
|
|
3
|
+
export default {
|
|
4
|
+
name: 'HrEmotionalPicture',
|
|
5
|
+
props: {
|
|
6
|
+
type: {
|
|
7
|
+
type: String,
|
|
8
|
+
default () {
|
|
9
|
+
return 'evaluate'
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
text: {
|
|
13
|
+
type: String,
|
|
14
|
+
default () {
|
|
15
|
+
return '暂无数据'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
data () {
|
|
20
|
+
return {
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
render () {
|
|
24
|
+
const { text, type } = this
|
|
25
|
+
|
|
26
|
+
return <div class="hr-emotional-picture">
|
|
27
|
+
<div class="picture-content">
|
|
28
|
+
<img class="content-icon" src={`${baseUrl}${type}.png`} />
|
|
29
|
+
<div class="content-text">{text}</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<style scoped lang="less">
|
|
37
|
+
.hr-emotional-picture {
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
.picture-content {
|
|
41
|
+
position: absolute;
|
|
42
|
+
left: 50%;
|
|
43
|
+
top: 50%;
|
|
44
|
+
width: 100%;
|
|
45
|
+
transform: translate(-50%, -50%);
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
.content-icon {
|
|
49
|
+
width: 140px;
|
|
50
|
+
height: 140px;
|
|
51
|
+
text-align: center;
|
|
52
|
+
margin-left: 50%;
|
|
53
|
+
transform: translateX(-50%);
|
|
54
|
+
}
|
|
55
|
+
.content-text {
|
|
56
|
+
font-size: 16px;
|
|
57
|
+
font-weight: 700;
|
|
58
|
+
line-height: 22px;
|
|
59
|
+
text-align: center;
|
|
60
|
+
color: #03050d;
|
|
61
|
+
margin-top: 12px;
|
|
62
|
+
display: block;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : HR-OA-KTS 黄强 670604@ky-tech.com.cn
|
|
3
|
+
* @Date : 2024-02-28 19:08:32
|
|
4
|
+
* @Description :
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import hrModuleCard from './src/index.vue'
|
|
8
|
+
|
|
9
|
+
hrModuleCard.install = function (Vue) {
|
|
10
|
+
Vue.component(hrModuleCard.name, hrModuleCard);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default hrModuleCard;
|