vue2-client 1.18.32 → 1.18.34
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/.eslintrc.js +90 -90
- package/Components.md +60 -60
- package/docs/index.md +30 -30
- package/index.js +31 -31
- package/jest-transform-stub.js +8 -8
- package/jest.setup.js +7 -7
- package/package.json +1 -1
- package/src/assets/img/querySlotDemo.svg +15 -15
- package/src/assets/svg/female.svg +1 -1
- package/src/assets/svg/male.svg +1 -1
- package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
- package/src/base-client/components/common/CitySelect/index.js +3 -3
- package/src/base-client/components/common/CitySelect/index.md +109 -109
- package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
- package/src/base-client/components/common/CreateQuery/index.js +3 -3
- package/src/base-client/components/common/CreateQuery/index.md +42 -42
- package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
- package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
- package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
- package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
- package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
- package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
- package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
- package/src/base-client/components/common/HIS/HFormGroup/index.js +3 -3
- package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
- package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
- package/src/base-client/components/common/PersonSetting/index.js +3 -3
- package/src/base-client/components/common/Tree/Tree.vue +149 -149
- package/src/base-client/components/common/Tree/index.js +2 -2
- package/src/base-client/components/common/Upload/index.js +3 -3
- package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
- package/src/base-client/components/common/XCard/XCard.vue +64 -64
- package/src/base-client/components/common/XCollapse/XCollapse.vue +830 -830
- package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
- package/src/base-client/components/common/XDataDrawer/index.js +3 -3
- package/src/base-client/components/common/XDataDrawer/index.md +41 -41
- package/src/base-client/components/common/XDescriptions/index.js +3 -3
- package/src/base-client/components/common/XDescriptions/index.md +322 -322
- package/src/base-client/components/common/XForm/index.md +178 -178
- package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +6 -3
- package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
- package/src/base-client/components/common/XStepView/index.js +3 -3
- package/src/base-client/components/common/XStepView/index.md +31 -31
- package/src/base-client/components/common/XTable/XTable.vue +1715 -1715
- package/src/base-client/components/common/XTable/index.md +255 -255
- package/src/base-client/components/common/XTimeline/XTimeline.vue +477 -477
- package/src/base-client/components/his/XHisEditor/XHisEditor.vue +705 -705
- package/src/base-client/components/his/XList/XList.vue +938 -938
- package/src/base-client/components/his/XSimpleTable/XSimpleTable.vue +504 -45
- package/src/base-client/components/his/XTimeSelect/XTimeSelect.vue +354 -354
- package/src/base-client/components/his/XTitle/XTitle.vue +314 -314
- package/src/base-client/components/his/XTreeRows/XTreeRows.vue +341 -341
- package/src/base-client/components/his/threeTestOrders/editor.vue +113 -113
- package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
- package/src/base-client/plugins/Config.js +19 -19
- package/src/base-client/plugins/tabs-page-plugin.js +39 -39
- package/src/components/Charts/Bar.vue +62 -62
- package/src/components/Charts/ChartCard.vue +134 -134
- package/src/components/Charts/Liquid.vue +67 -67
- package/src/components/Charts/MiniArea.vue +39 -39
- package/src/components/Charts/MiniBar.vue +39 -39
- package/src/components/Charts/MiniProgress.vue +75 -75
- package/src/components/Charts/MiniSmoothArea.vue +40 -40
- package/src/components/Charts/Radar.vue +68 -68
- package/src/components/Charts/RankList.vue +77 -77
- package/src/components/Charts/TagCloud.vue +113 -113
- package/src/components/Charts/TransferBar.vue +64 -64
- package/src/components/Charts/Trend.vue +82 -82
- package/src/components/Charts/chart.less +12 -12
- package/src/components/Charts/smooth.area.less +13 -13
- package/src/components/NumberInfo/NumberInfo.vue +54 -54
- package/src/components/NumberInfo/index.js +3 -3
- package/src/components/NumberInfo/index.less +54 -54
- package/src/components/NumberInfo/index.md +43 -43
- package/src/components/card/ChartCard.vue +79 -79
- package/src/components/chart/Bar.vue +60 -60
- package/src/components/chart/MiniArea.vue +67 -67
- package/src/components/chart/MiniBar.vue +59 -59
- package/src/components/chart/MiniProgress.vue +57 -57
- package/src/components/chart/Radar.vue +80 -80
- package/src/components/chart/RankingList.vue +60 -60
- package/src/components/chart/Trend.vue +79 -79
- package/src/components/chart/index.less +9 -9
- package/src/components/checkbox/ColorCheckbox.vue +157 -157
- package/src/components/input/IInput.vue +66 -66
- package/src/components/menu/SideMenu.vue +75 -75
- package/src/components/menu/menu.js +273 -273
- package/src/components/tool/AStepItem.vue +60 -60
- package/src/layouts/CommonLayout.vue +56 -56
- package/src/layouts/header/HeaderNotice.vue +177 -177
- package/src/lib.js +1 -1
- package/src/mock/extend/index.js +84 -84
- package/src/mock/goods/index.js +108 -108
- package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
- package/src/pages/system/dictionary/index.vue +44 -44
- package/src/pages/system/monitor/loginInfor/index.vue +37 -37
- package/src/pages/system/monitor/operLog/index.vue +37 -37
- package/src/pages/userInfoDetailManage/ExceptionRecordQuery/index.vue +45 -45
- package/src/services/api/cas.js +79 -79
- package/src/store/modules/setting.js +119 -119
- package/src/utils/authority-utils.js +85 -85
- package/src/utils/errorCode.js +6 -6
- package/src-base-client/components/common/HIS/HForm/HForm.vue +347 -0
- package/src-base-client/components/common/XCollapse/XCollapse.vue +0 -0
- package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
|
@@ -1,354 +1,354 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="x-time-select" :class="[{ 'has-nav-arrows': navArrows }, wrapperClassObject]">
|
|
3
|
-
<div class="time-select-container">
|
|
4
|
-
<div v-if="type === 'range'" class="picker-wrapper">
|
|
5
|
-
<span v-if="showCalendarIcon" class="left-calendar-icon"><a-icon type="calendar" /></span>
|
|
6
|
-
<a-range-picker
|
|
7
|
-
:value="dateRange"
|
|
8
|
-
:placeholder="['开始日期', '结束日期']"
|
|
9
|
-
:separator="rangeSeparator"
|
|
10
|
-
:disabled="disabled"
|
|
11
|
-
:allowClear="allowClear"
|
|
12
|
-
:format="format"
|
|
13
|
-
:showTime="showTime"
|
|
14
|
-
@change="handleDateChange"
|
|
15
|
-
/>
|
|
16
|
-
</div>
|
|
17
|
-
<div v-if="type === 'date' && !navArrows" class="picker-wrapper">
|
|
18
|
-
<span v-if="showCalendarIcon" class="left-calendar-icon"><a-icon type="calendar" /></span>
|
|
19
|
-
<a-date-picker
|
|
20
|
-
:value="dateRange[0]"
|
|
21
|
-
:format="format"
|
|
22
|
-
:disabled="disabled"
|
|
23
|
-
:allowClear="allowClear"
|
|
24
|
-
:showTime="showTime"
|
|
25
|
-
@change="handleDateChange"
|
|
26
|
-
/>
|
|
27
|
-
</div>
|
|
28
|
-
<div v-if="type === 'date' && navArrows" class="picker-wrapper nav-arrows-wrapper">
|
|
29
|
-
<span
|
|
30
|
-
v-if="!disabled"
|
|
31
|
-
class="nav-arrow nav-arrow-left"
|
|
32
|
-
@mousedown.prevent.stop
|
|
33
|
-
@click.stop="handleShiftDay(-1)"
|
|
34
|
-
><a-icon type="left" /></span>
|
|
35
|
-
<a-date-picker
|
|
36
|
-
:value="dateRange[0]"
|
|
37
|
-
:format="format"
|
|
38
|
-
:disabled="disabled"
|
|
39
|
-
:allowClear="allowClear"
|
|
40
|
-
:showTime="showTime"
|
|
41
|
-
:suffixIcon="null"
|
|
42
|
-
@change="handleDateChange"
|
|
43
|
-
/>
|
|
44
|
-
<span
|
|
45
|
-
v-if="!disabled"
|
|
46
|
-
class="nav-arrow nav-arrow-right"
|
|
47
|
-
@mousedown.prevent.stop
|
|
48
|
-
@click.stop="handleShiftDay(1)"
|
|
49
|
-
><a-icon type="right" /></span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
<script>
|
|
57
|
-
import moment from 'moment'
|
|
58
|
-
import { getConfigByName } from '@vue2-client/services/api/common'
|
|
59
|
-
|
|
60
|
-
export default {
|
|
61
|
-
name: 'XTimeSelect',
|
|
62
|
-
inject: ['getComponentByName'],
|
|
63
|
-
props: {
|
|
64
|
-
queryParamsName: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: null
|
|
67
|
-
},
|
|
68
|
-
value: {
|
|
69
|
-
type: Array,
|
|
70
|
-
default: () => []
|
|
71
|
-
},
|
|
72
|
-
defaultTime: {
|
|
73
|
-
type: Array,
|
|
74
|
-
default: () => []
|
|
75
|
-
},
|
|
76
|
-
disabled: {
|
|
77
|
-
type: Boolean,
|
|
78
|
-
default: false
|
|
79
|
-
},
|
|
80
|
-
allowClear: {
|
|
81
|
-
type: Boolean,
|
|
82
|
-
default: true
|
|
83
|
-
},
|
|
84
|
-
format: {
|
|
85
|
-
type: String,
|
|
86
|
-
default: 'YYYY-MM-DD'
|
|
87
|
-
},
|
|
88
|
-
navArrows: {
|
|
89
|
-
type: Boolean,
|
|
90
|
-
default: false
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
data () {
|
|
94
|
-
return {
|
|
95
|
-
dateRange: [],
|
|
96
|
-
type: 'range',
|
|
97
|
-
showCalendarIcon: false
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
computed: {
|
|
101
|
-
// 与 XHDescriptions 一致的样式配置模式:通过 $attrs 映射布尔/尺寸类
|
|
102
|
-
wrapperClassObject () {
|
|
103
|
-
const attrs = this.$attrs || {}
|
|
104
|
-
const classes = {}
|
|
105
|
-
const booleanStyleKeys = [
|
|
106
|
-
'yizhu-date'
|
|
107
|
-
]
|
|
108
|
-
booleanStyleKeys.forEach(key => {
|
|
109
|
-
const val = attrs[key]
|
|
110
|
-
const truthy = val === true || val === '' || val === 'true'
|
|
111
|
-
if (truthy) classes[`xtime-${key}`] = true
|
|
112
|
-
})
|
|
113
|
-
const size = attrs.size
|
|
114
|
-
if (size && typeof size === 'string') classes[`xtime-size-${size}`] = true
|
|
115
|
-
return classes
|
|
116
|
-
},
|
|
117
|
-
showTime () {
|
|
118
|
-
// 根据format判断是否需要显示时间选择器
|
|
119
|
-
return this.format && (this.format.includes('HH:mm') || this.format.includes('hh:mm'))
|
|
120
|
-
},
|
|
121
|
-
rangeSeparator () {
|
|
122
|
-
return this.type === 'range' ? '-' : '至'
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
watch: {
|
|
126
|
-
value: {
|
|
127
|
-
handler (newVal) {
|
|
128
|
-
this.convertValueToMoment(newVal)
|
|
129
|
-
},
|
|
130
|
-
immediate: true,
|
|
131
|
-
deep: true
|
|
132
|
-
},
|
|
133
|
-
defaultTime: {
|
|
134
|
-
handler (newVal) {
|
|
135
|
-
// 只有在没有传入value时才使用defaultTime
|
|
136
|
-
if (!this.value || this.value.length === 0) {
|
|
137
|
-
this.convertValueToMoment(newVal)
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
immediate: true,
|
|
141
|
-
deep: true
|
|
142
|
-
},
|
|
143
|
-
type () {
|
|
144
|
-
this.convertValueToMoment(this.value)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
},
|
|
148
|
-
created () {
|
|
149
|
-
this.getData(this.queryParamsName)
|
|
150
|
-
},
|
|
151
|
-
methods: {
|
|
152
|
-
convertValueToMoment (value) {
|
|
153
|
-
// 如果没有传入value或value为空,则使用defaultTime
|
|
154
|
-
const timeToUse = (value && value.length > 0) ? value : this.defaultTime
|
|
155
|
-
if (this.type === 'range' && timeToUse?.length === 2) {
|
|
156
|
-
this.dateRange = [
|
|
157
|
-
timeToUse[0] ? moment(timeToUse[0]) : null,
|
|
158
|
-
timeToUse[1] ? moment(timeToUse[1]) : null
|
|
159
|
-
]
|
|
160
|
-
} else if (this.type === 'date' && timeToUse?.length === 1) {
|
|
161
|
-
this.dateRange = [timeToUse[0] ? moment(timeToUse[0]) : null]
|
|
162
|
-
} else {
|
|
163
|
-
this.dateRange = []
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
handleDateChange (dates, dateStrings) {
|
|
167
|
-
if (this.type === 'date') {
|
|
168
|
-
// 单个日期选择器,dates是一个moment对象或null
|
|
169
|
-
this.dateRange = [dates]
|
|
170
|
-
} else {
|
|
171
|
-
// 范围选择器,dates是一个数组
|
|
172
|
-
this.dateRange = dates
|
|
173
|
-
}
|
|
174
|
-
this.$emit('change', dateStrings)
|
|
175
|
-
},
|
|
176
|
-
async getData (data) {
|
|
177
|
-
if (data) {
|
|
178
|
-
getConfigByName(data, 'af-his', res => {
|
|
179
|
-
if (['date', 'range'].includes(res.type)) {
|
|
180
|
-
this.type = res.type
|
|
181
|
-
}
|
|
182
|
-
// 处理format配置
|
|
183
|
-
if (res.format !== undefined) {
|
|
184
|
-
this.format = res.format
|
|
185
|
-
}
|
|
186
|
-
// 处理图标开关配置(默认关闭)
|
|
187
|
-
this.showCalendarIcon = res && res.showCalendarIcon === true
|
|
188
|
-
// 处理左右箭头开关配置(默认关闭)
|
|
189
|
-
this.navArrows = !!(res && (res.navArrows === true || res.showNavArrows === true))
|
|
190
|
-
// 处理defaultTime配置
|
|
191
|
-
if (res.defaultTime !== undefined) {
|
|
192
|
-
if (res.defaultTime === 'now') {
|
|
193
|
-
// 如果配置为'now',设置当前时间
|
|
194
|
-
const now = moment().format(this.format)
|
|
195
|
-
if (this.type === 'range') {
|
|
196
|
-
this.defaultTime = [now, now]
|
|
197
|
-
} else if (this.type === 'date') {
|
|
198
|
-
this.defaultTime = [now]
|
|
199
|
-
}
|
|
200
|
-
} else if (Array.isArray(res.defaultTime)) {
|
|
201
|
-
// 如果配置为数组,直接使用
|
|
202
|
-
this.defaultTime = res.defaultTime
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
this.convertValueToMoment(this.value)
|
|
206
|
-
})
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
handleShiftDay (delta) {
|
|
210
|
-
if (this.type !== 'date') return
|
|
211
|
-
const current = this.dateRange && this.dateRange[0] ? this.dateRange[0].clone() : moment()
|
|
212
|
-
const unit = this.showTime ? 'day' : 'day'
|
|
213
|
-
const next = current.add(delta, unit)
|
|
214
|
-
this.dateRange = [next]
|
|
215
|
-
this.$emit('change', next ? next.format(this.format) : '')
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
</script>
|
|
220
|
-
|
|
221
|
-
<style scoped lang="less">
|
|
222
|
-
.x-time-select {
|
|
223
|
-
position: relative;
|
|
224
|
-
width: 100%;
|
|
225
|
-
box-sizing: border-box;
|
|
226
|
-
display: block;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.time-select-container {
|
|
230
|
-
display: flex;
|
|
231
|
-
align-items: center;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.picker-wrapper {
|
|
235
|
-
flex: 1;
|
|
236
|
-
position: relative;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.nav-arrows-wrapper {
|
|
240
|
-
position: relative;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.nav-arrow {
|
|
244
|
-
position: absolute;
|
|
245
|
-
top: 50%;
|
|
246
|
-
transform: translateY(-50%);
|
|
247
|
-
display: inline-flex;
|
|
248
|
-
align-items: center;
|
|
249
|
-
justify-content: center;
|
|
250
|
-
width: 24px;
|
|
251
|
-
height: 24px;
|
|
252
|
-
color: #848484;
|
|
253
|
-
cursor: pointer;
|
|
254
|
-
user-select: none;
|
|
255
|
-
z-index: 3;
|
|
256
|
-
}
|
|
257
|
-
.nav-arrow:hover {
|
|
258
|
-
color: #515151;
|
|
259
|
-
}
|
|
260
|
-
.nav-arrow-left {
|
|
261
|
-
left: 6px;
|
|
262
|
-
}
|
|
263
|
-
.nav-arrow-right {
|
|
264
|
-
right: 6px;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.x-time-select :deep(.ant-picker-range),
|
|
268
|
-
.x-time-select :deep(.ant-picker) {
|
|
269
|
-
width: 100%;
|
|
270
|
-
height: 32px;
|
|
271
|
-
border-radius: 7px;
|
|
272
|
-
background: #FFFFFF;
|
|
273
|
-
border: 1px solid #E5E9F0;
|
|
274
|
-
box-sizing: border-box;
|
|
275
|
-
opacity: 1;
|
|
276
|
-
}
|
|
277
|
-
.x-time-select.has-nav-arrows :deep(.ant-picker-suffix) {
|
|
278
|
-
display: none; /* 仅箭头模式隐藏后缀图标容器 */
|
|
279
|
-
}
|
|
280
|
-
.x-time-select :deep(.ant-calendar-picker) {
|
|
281
|
-
width: 100%;
|
|
282
|
-
display: block;
|
|
283
|
-
}
|
|
284
|
-
.x-time-select :deep(.ant-calendar-picker-input) {
|
|
285
|
-
width: 100%;
|
|
286
|
-
height: 32px;
|
|
287
|
-
border-radius: 7px;
|
|
288
|
-
background: #FFFFFF;
|
|
289
|
-
border: 1px solid #E5E9F0;
|
|
290
|
-
box-sizing: border-box;
|
|
291
|
-
opacity: 1;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.x-time-select :deep(.ant-input) {
|
|
295
|
-
width: 100%;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/* 左侧日历图标 */
|
|
299
|
-
.left-calendar-icon {
|
|
300
|
-
position: absolute;
|
|
301
|
-
left: 10px;
|
|
302
|
-
top: 1.8px;
|
|
303
|
-
width: 18.2px;
|
|
304
|
-
height: 91%;
|
|
305
|
-
opacity: 1;
|
|
306
|
-
color: #848484;
|
|
307
|
-
z-index: 2;
|
|
308
|
-
pointer-events: none;
|
|
309
|
-
display: inline-flex;
|
|
310
|
-
align-items: center;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/* 为日期输入增加左内边距,避免与图标重叠(兼容 ant 不同版本) */
|
|
314
|
-
.x-time-select :deep(.ant-picker-input > input) {
|
|
315
|
-
padding-left: 19px;
|
|
316
|
-
padding-right: 19px;
|
|
317
|
-
font-family: 'Source Han Sans';
|
|
318
|
-
font-weight: normal;
|
|
319
|
-
line-height: normal;
|
|
320
|
-
text-align: center;
|
|
321
|
-
color: #313131;
|
|
322
|
-
}
|
|
323
|
-
.x-time-select :deep(.ant-calendar-picker-input) {
|
|
324
|
-
padding-left: 19px;
|
|
325
|
-
padding-right: 19px;
|
|
326
|
-
font-family: 'Source Han Sans';
|
|
327
|
-
font-size: 16px;
|
|
328
|
-
font-weight: normal;
|
|
329
|
-
line-height: normal;
|
|
330
|
-
text-align: center;
|
|
331
|
-
color: #313131;
|
|
332
|
-
}
|
|
333
|
-
.x-time-select.has-nav-arrows :deep(.ant-calendar-picker-icon),
|
|
334
|
-
.x-time-select.has-nav-arrows :deep(.ant-calendar-picker-clear),
|
|
335
|
-
.x-time-select.has-nav-arrows :deep(.anticon-calendar) {
|
|
336
|
-
display: none; /* 仅箭头模式隐藏旧版图标节点 */
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
.x-time-select.xtime-yizhu-date {
|
|
340
|
-
margin: 2px 11px 2px 24px;
|
|
341
|
-
width: 234px;
|
|
342
|
-
height: 32px;
|
|
343
|
-
border-radius: 7px;
|
|
344
|
-
opacity: 1;
|
|
345
|
-
background: #FFFFFF;
|
|
346
|
-
box-sizing: border-box;
|
|
347
|
-
border: 1px solid #E5E9F0;
|
|
348
|
-
}
|
|
349
|
-
/* 箭头模式下,让输入有左右内边距以避让箭头 */
|
|
350
|
-
.x-time-select.has-nav-arrows :deep(.ant-picker-input > input) {
|
|
351
|
-
padding-left: 30px;
|
|
352
|
-
padding-right: 30px;
|
|
353
|
-
}
|
|
354
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="x-time-select" :class="[{ 'has-nav-arrows': navArrows }, wrapperClassObject]">
|
|
3
|
+
<div class="time-select-container">
|
|
4
|
+
<div v-if="type === 'range'" class="picker-wrapper">
|
|
5
|
+
<span v-if="showCalendarIcon" class="left-calendar-icon"><a-icon type="calendar" /></span>
|
|
6
|
+
<a-range-picker
|
|
7
|
+
:value="dateRange"
|
|
8
|
+
:placeholder="['开始日期', '结束日期']"
|
|
9
|
+
:separator="rangeSeparator"
|
|
10
|
+
:disabled="disabled"
|
|
11
|
+
:allowClear="allowClear"
|
|
12
|
+
:format="format"
|
|
13
|
+
:showTime="showTime"
|
|
14
|
+
@change="handleDateChange"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
<div v-if="type === 'date' && !navArrows" class="picker-wrapper">
|
|
18
|
+
<span v-if="showCalendarIcon" class="left-calendar-icon"><a-icon type="calendar" /></span>
|
|
19
|
+
<a-date-picker
|
|
20
|
+
:value="dateRange[0]"
|
|
21
|
+
:format="format"
|
|
22
|
+
:disabled="disabled"
|
|
23
|
+
:allowClear="allowClear"
|
|
24
|
+
:showTime="showTime"
|
|
25
|
+
@change="handleDateChange"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
<div v-if="type === 'date' && navArrows" class="picker-wrapper nav-arrows-wrapper">
|
|
29
|
+
<span
|
|
30
|
+
v-if="!disabled"
|
|
31
|
+
class="nav-arrow nav-arrow-left"
|
|
32
|
+
@mousedown.prevent.stop
|
|
33
|
+
@click.stop="handleShiftDay(-1)"
|
|
34
|
+
><a-icon type="left" /></span>
|
|
35
|
+
<a-date-picker
|
|
36
|
+
:value="dateRange[0]"
|
|
37
|
+
:format="format"
|
|
38
|
+
:disabled="disabled"
|
|
39
|
+
:allowClear="allowClear"
|
|
40
|
+
:showTime="showTime"
|
|
41
|
+
:suffixIcon="null"
|
|
42
|
+
@change="handleDateChange"
|
|
43
|
+
/>
|
|
44
|
+
<span
|
|
45
|
+
v-if="!disabled"
|
|
46
|
+
class="nav-arrow nav-arrow-right"
|
|
47
|
+
@mousedown.prevent.stop
|
|
48
|
+
@click.stop="handleShiftDay(1)"
|
|
49
|
+
><a-icon type="right" /></span>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
import moment from 'moment'
|
|
58
|
+
import { getConfigByName } from '@vue2-client/services/api/common'
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
name: 'XTimeSelect',
|
|
62
|
+
inject: ['getComponentByName'],
|
|
63
|
+
props: {
|
|
64
|
+
queryParamsName: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: null
|
|
67
|
+
},
|
|
68
|
+
value: {
|
|
69
|
+
type: Array,
|
|
70
|
+
default: () => []
|
|
71
|
+
},
|
|
72
|
+
defaultTime: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: () => []
|
|
75
|
+
},
|
|
76
|
+
disabled: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
allowClear: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true
|
|
83
|
+
},
|
|
84
|
+
format: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: 'YYYY-MM-DD'
|
|
87
|
+
},
|
|
88
|
+
navArrows: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: false
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
data () {
|
|
94
|
+
return {
|
|
95
|
+
dateRange: [],
|
|
96
|
+
type: 'range',
|
|
97
|
+
showCalendarIcon: false
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
computed: {
|
|
101
|
+
// 与 XHDescriptions 一致的样式配置模式:通过 $attrs 映射布尔/尺寸类
|
|
102
|
+
wrapperClassObject () {
|
|
103
|
+
const attrs = this.$attrs || {}
|
|
104
|
+
const classes = {}
|
|
105
|
+
const booleanStyleKeys = [
|
|
106
|
+
'yizhu-date'
|
|
107
|
+
]
|
|
108
|
+
booleanStyleKeys.forEach(key => {
|
|
109
|
+
const val = attrs[key]
|
|
110
|
+
const truthy = val === true || val === '' || val === 'true'
|
|
111
|
+
if (truthy) classes[`xtime-${key}`] = true
|
|
112
|
+
})
|
|
113
|
+
const size = attrs.size
|
|
114
|
+
if (size && typeof size === 'string') classes[`xtime-size-${size}`] = true
|
|
115
|
+
return classes
|
|
116
|
+
},
|
|
117
|
+
showTime () {
|
|
118
|
+
// 根据format判断是否需要显示时间选择器
|
|
119
|
+
return this.format && (this.format.includes('HH:mm') || this.format.includes('hh:mm'))
|
|
120
|
+
},
|
|
121
|
+
rangeSeparator () {
|
|
122
|
+
return this.type === 'range' ? '-' : '至'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
watch: {
|
|
126
|
+
value: {
|
|
127
|
+
handler (newVal) {
|
|
128
|
+
this.convertValueToMoment(newVal)
|
|
129
|
+
},
|
|
130
|
+
immediate: true,
|
|
131
|
+
deep: true
|
|
132
|
+
},
|
|
133
|
+
defaultTime: {
|
|
134
|
+
handler (newVal) {
|
|
135
|
+
// 只有在没有传入value时才使用defaultTime
|
|
136
|
+
if (!this.value || this.value.length === 0) {
|
|
137
|
+
this.convertValueToMoment(newVal)
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
immediate: true,
|
|
141
|
+
deep: true
|
|
142
|
+
},
|
|
143
|
+
type () {
|
|
144
|
+
this.convertValueToMoment(this.value)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
},
|
|
148
|
+
created () {
|
|
149
|
+
this.getData(this.queryParamsName)
|
|
150
|
+
},
|
|
151
|
+
methods: {
|
|
152
|
+
convertValueToMoment (value) {
|
|
153
|
+
// 如果没有传入value或value为空,则使用defaultTime
|
|
154
|
+
const timeToUse = (value && value.length > 0) ? value : this.defaultTime
|
|
155
|
+
if (this.type === 'range' && timeToUse?.length === 2) {
|
|
156
|
+
this.dateRange = [
|
|
157
|
+
timeToUse[0] ? moment(timeToUse[0]) : null,
|
|
158
|
+
timeToUse[1] ? moment(timeToUse[1]) : null
|
|
159
|
+
]
|
|
160
|
+
} else if (this.type === 'date' && timeToUse?.length === 1) {
|
|
161
|
+
this.dateRange = [timeToUse[0] ? moment(timeToUse[0]) : null]
|
|
162
|
+
} else {
|
|
163
|
+
this.dateRange = []
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
handleDateChange (dates, dateStrings) {
|
|
167
|
+
if (this.type === 'date') {
|
|
168
|
+
// 单个日期选择器,dates是一个moment对象或null
|
|
169
|
+
this.dateRange = [dates]
|
|
170
|
+
} else {
|
|
171
|
+
// 范围选择器,dates是一个数组
|
|
172
|
+
this.dateRange = dates
|
|
173
|
+
}
|
|
174
|
+
this.$emit('change', dateStrings)
|
|
175
|
+
},
|
|
176
|
+
async getData (data) {
|
|
177
|
+
if (data) {
|
|
178
|
+
getConfigByName(data, 'af-his', res => {
|
|
179
|
+
if (['date', 'range'].includes(res.type)) {
|
|
180
|
+
this.type = res.type
|
|
181
|
+
}
|
|
182
|
+
// 处理format配置
|
|
183
|
+
if (res.format !== undefined) {
|
|
184
|
+
this.format = res.format
|
|
185
|
+
}
|
|
186
|
+
// 处理图标开关配置(默认关闭)
|
|
187
|
+
this.showCalendarIcon = res && res.showCalendarIcon === true
|
|
188
|
+
// 处理左右箭头开关配置(默认关闭)
|
|
189
|
+
this.navArrows = !!(res && (res.navArrows === true || res.showNavArrows === true))
|
|
190
|
+
// 处理defaultTime配置
|
|
191
|
+
if (res.defaultTime !== undefined) {
|
|
192
|
+
if (res.defaultTime === 'now') {
|
|
193
|
+
// 如果配置为'now',设置当前时间
|
|
194
|
+
const now = moment().format(this.format)
|
|
195
|
+
if (this.type === 'range') {
|
|
196
|
+
this.defaultTime = [now, now]
|
|
197
|
+
} else if (this.type === 'date') {
|
|
198
|
+
this.defaultTime = [now]
|
|
199
|
+
}
|
|
200
|
+
} else if (Array.isArray(res.defaultTime)) {
|
|
201
|
+
// 如果配置为数组,直接使用
|
|
202
|
+
this.defaultTime = res.defaultTime
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
this.convertValueToMoment(this.value)
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
handleShiftDay (delta) {
|
|
210
|
+
if (this.type !== 'date') return
|
|
211
|
+
const current = this.dateRange && this.dateRange[0] ? this.dateRange[0].clone() : moment()
|
|
212
|
+
const unit = this.showTime ? 'day' : 'day'
|
|
213
|
+
const next = current.add(delta, unit)
|
|
214
|
+
this.dateRange = [next]
|
|
215
|
+
this.$emit('change', next ? next.format(this.format) : '')
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
</script>
|
|
220
|
+
|
|
221
|
+
<style scoped lang="less">
|
|
222
|
+
.x-time-select {
|
|
223
|
+
position: relative;
|
|
224
|
+
width: 100%;
|
|
225
|
+
box-sizing: border-box;
|
|
226
|
+
display: block;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.time-select-container {
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.picker-wrapper {
|
|
235
|
+
flex: 1;
|
|
236
|
+
position: relative;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.nav-arrows-wrapper {
|
|
240
|
+
position: relative;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.nav-arrow {
|
|
244
|
+
position: absolute;
|
|
245
|
+
top: 50%;
|
|
246
|
+
transform: translateY(-50%);
|
|
247
|
+
display: inline-flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
justify-content: center;
|
|
250
|
+
width: 24px;
|
|
251
|
+
height: 24px;
|
|
252
|
+
color: #848484;
|
|
253
|
+
cursor: pointer;
|
|
254
|
+
user-select: none;
|
|
255
|
+
z-index: 3;
|
|
256
|
+
}
|
|
257
|
+
.nav-arrow:hover {
|
|
258
|
+
color: #515151;
|
|
259
|
+
}
|
|
260
|
+
.nav-arrow-left {
|
|
261
|
+
left: 6px;
|
|
262
|
+
}
|
|
263
|
+
.nav-arrow-right {
|
|
264
|
+
right: 6px;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.x-time-select :deep(.ant-picker-range),
|
|
268
|
+
.x-time-select :deep(.ant-picker) {
|
|
269
|
+
width: 100%;
|
|
270
|
+
height: 32px;
|
|
271
|
+
border-radius: 7px;
|
|
272
|
+
background: #FFFFFF;
|
|
273
|
+
border: 1px solid #E5E9F0;
|
|
274
|
+
box-sizing: border-box;
|
|
275
|
+
opacity: 1;
|
|
276
|
+
}
|
|
277
|
+
.x-time-select.has-nav-arrows :deep(.ant-picker-suffix) {
|
|
278
|
+
display: none; /* 仅箭头模式隐藏后缀图标容器 */
|
|
279
|
+
}
|
|
280
|
+
.x-time-select :deep(.ant-calendar-picker) {
|
|
281
|
+
width: 100%;
|
|
282
|
+
display: block;
|
|
283
|
+
}
|
|
284
|
+
.x-time-select :deep(.ant-calendar-picker-input) {
|
|
285
|
+
width: 100%;
|
|
286
|
+
height: 32px;
|
|
287
|
+
border-radius: 7px;
|
|
288
|
+
background: #FFFFFF;
|
|
289
|
+
border: 1px solid #E5E9F0;
|
|
290
|
+
box-sizing: border-box;
|
|
291
|
+
opacity: 1;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.x-time-select :deep(.ant-input) {
|
|
295
|
+
width: 100%;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* 左侧日历图标 */
|
|
299
|
+
.left-calendar-icon {
|
|
300
|
+
position: absolute;
|
|
301
|
+
left: 10px;
|
|
302
|
+
top: 1.8px;
|
|
303
|
+
width: 18.2px;
|
|
304
|
+
height: 91%;
|
|
305
|
+
opacity: 1;
|
|
306
|
+
color: #848484;
|
|
307
|
+
z-index: 2;
|
|
308
|
+
pointer-events: none;
|
|
309
|
+
display: inline-flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* 为日期输入增加左内边距,避免与图标重叠(兼容 ant 不同版本) */
|
|
314
|
+
.x-time-select :deep(.ant-picker-input > input) {
|
|
315
|
+
padding-left: 19px;
|
|
316
|
+
padding-right: 19px;
|
|
317
|
+
font-family: 'Source Han Sans';
|
|
318
|
+
font-weight: normal;
|
|
319
|
+
line-height: normal;
|
|
320
|
+
text-align: center;
|
|
321
|
+
color: #313131;
|
|
322
|
+
}
|
|
323
|
+
.x-time-select :deep(.ant-calendar-picker-input) {
|
|
324
|
+
padding-left: 19px;
|
|
325
|
+
padding-right: 19px;
|
|
326
|
+
font-family: 'Source Han Sans';
|
|
327
|
+
font-size: 16px;
|
|
328
|
+
font-weight: normal;
|
|
329
|
+
line-height: normal;
|
|
330
|
+
text-align: center;
|
|
331
|
+
color: #313131;
|
|
332
|
+
}
|
|
333
|
+
.x-time-select.has-nav-arrows :deep(.ant-calendar-picker-icon),
|
|
334
|
+
.x-time-select.has-nav-arrows :deep(.ant-calendar-picker-clear),
|
|
335
|
+
.x-time-select.has-nav-arrows :deep(.anticon-calendar) {
|
|
336
|
+
display: none; /* 仅箭头模式隐藏旧版图标节点 */
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.x-time-select.xtime-yizhu-date {
|
|
340
|
+
margin: 2px 11px 2px 24px;
|
|
341
|
+
width: 234px;
|
|
342
|
+
height: 32px;
|
|
343
|
+
border-radius: 7px;
|
|
344
|
+
opacity: 1;
|
|
345
|
+
background: #FFFFFF;
|
|
346
|
+
box-sizing: border-box;
|
|
347
|
+
border: 1px solid #E5E9F0;
|
|
348
|
+
}
|
|
349
|
+
/* 箭头模式下,让输入有左右内边距以避让箭头 */
|
|
350
|
+
.x-time-select.has-nav-arrows :deep(.ant-picker-input > input) {
|
|
351
|
+
padding-left: 30px;
|
|
352
|
+
padding-right: 30px;
|
|
353
|
+
}
|
|
354
|
+
</style>
|