sh-view 2.8.0 → 2.8.2
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 +25 -20
- package/other.js +8 -8
- package/package.json +9 -6
- package/packages/components/index.js +91 -91
- package/packages/components/sh-alert/alert.ts +30 -0
- package/packages/components/sh-alert/index.vue +143 -168
- package/packages/components/sh-badge/index.vue +242 -242
- package/packages/components/sh-calendar/index.vue +650 -650
- package/packages/components/sh-card/index.vue +148 -148
- package/packages/components/sh-code-editor/index.vue +19 -19
- package/packages/components/sh-col/index.vue +92 -92
- package/packages/components/sh-corner/index.vue +230 -230
- package/packages/components/sh-count-to/index.vue +131 -131
- package/packages/components/sh-date/index.vue +301 -301
- package/packages/components/sh-drawer/index.vue +579 -579
- package/packages/components/sh-drawer/scrollbar.js +78 -78
- package/packages/components/sh-empty/index.vue +42 -42
- package/packages/components/sh-form/js/props.js +76 -76
- package/packages/components/sh-form/js/useForm.js +229 -229
- package/packages/components/sh-header/index.vue +261 -260
- package/packages/components/sh-icon/css/default/ionicons.svg +869 -869
- package/packages/components/sh-icon/css/font/iconfont.json +247 -247
- package/packages/components/sh-icon/index.vue +41 -41
- package/packages/components/sh-image/index.vue +133 -133
- package/packages/components/sh-list/index.vue +146 -146
- package/packages/components/sh-loading/index.vue +53 -53
- package/packages/components/sh-modal/index.vue +188 -188
- package/packages/components/sh-noticebar/index.vue +215 -215
- package/packages/components/sh-poptip/index.vue +597 -597
- package/packages/components/sh-progress/index.vue +276 -276
- package/packages/components/sh-pull-refresh/index.vue +289 -289
- package/packages/components/sh-result/index.vue +114 -114
- package/packages/components/sh-row/index.vue +66 -66
- package/packages/components/sh-split/components/trigger.vue +33 -33
- package/packages/components/sh-split/index.vue +342 -342
- package/packages/components/sh-table/components/importModal.vue +363 -363
- package/packages/components/sh-table/components/sh-column.vue +68 -68
- package/packages/components/sh-table/js/excel_to_json.js +313 -313
- package/packages/components/sh-table/js/props.js +305 -305
- package/packages/components/sh-table/js/tableMethods.js +167 -167
- package/packages/components/sh-table/js/useTable.js +636 -636
- package/packages/components/sh-table/table.vue +217 -217
- package/packages/components/sh-tabs/index.vue +426 -426
- package/packages/components/sh-tag/index.vue +168 -168
- package/packages/components/sh-toolbar/index.vue +182 -182
- package/packages/components/sh-tree/components/table-tree.vue +289 -289
- package/packages/components/sh-tree/mixin/treeProps.js +122 -122
- package/packages/components/sh-upload/index.vue +535 -535
- package/packages/components/sh-water-fall/index.vue +80 -80
- package/packages/components/sh-water-mark/index.vue +96 -96
- package/packages/css/index.js +4 -4
- package/packages/directive/index.js +19 -19
- package/packages/directive/module/click-out.js +14 -14
- package/packages/directive/module/draggable.js +42 -42
- package/packages/directive/module/line-clamp.js +22 -22
- package/packages/directive/module/prevent-click.js +18 -18
- package/packages/directive/module/resize.js +14 -14
- package/packages/directive/module/ripple.js +166 -166
- package/packages/index.js +39 -39
- package/packages/mixin/index.js +86 -86
- package/packages/other/sh-cron-modal/components/cron-content.vue +294 -294
- package/packages/other/sh-cron-modal/index.vue +81 -81
- package/packages/other/sh-cron-modal/mixin/cron-emits.js +1 -1
- package/packages/other/sh-cron-modal/mixin/cron-props.js +9 -9
- package/packages/other/sh-cron-modal/tabs/cron-week-box.vue +126 -126
- package/packages/other/sh-menu/index.vue +326 -326
- package/packages/other/sh-menu/menu-group-content.vue +136 -136
- package/packages/other/sh-menu/menu-item-content.vue +71 -71
- package/packages/other/sh-menu-card/index.vue +250 -250
- package/packages/other/sh-menu-card/menu-box.vue +87 -87
- package/packages/other/sh-preview/components/sh-excel.vue +163 -163
- package/packages/other/sh-preview/js/data-hook.js +41 -41
- package/packages/other/sh-preview/js/data-props.js +15 -15
- package/packages/other/sh-system-tip/index.vue +115 -115
- package/packages/utils/resize.js +69 -70
- package/packages/utils/transfer-queue.js +12 -12
- package/packages/vxeTable/index.js +193 -184
- package/packages/vxeTable/plugins/export.js +450 -450
- package/packages/vxeTable/render/cell/vxe-render-img.vue +27 -27
- package/packages/vxeTable/render/cell/vxe-render-table.vue +51 -51
- package/packages/vxeTable/render/cell/vxe-render-time.vue +44 -44
- package/packages/vxeTable/render/cell/vxe-render-tree.vue +70 -70
- package/packages/vxeTable/render/filters/vxe-filter-input.vue +26 -26
- package/packages/vxeTable/render/filters/vxe-filter-time.vue +26 -26
- package/packages/vxeTable/render/globalRenders.jsx +514 -514
- package/packages/vxeTable/render/mixin/cell-hooks.js +198 -198
- package/packages/vxeTable/render/mixin/cell-props.js +23 -23
- package/packages/vxeTable/render/mixin/filter-hooks.js +46 -46
- package/tsconfig.json +25 -0
- package/types/component.d.ts +1 -0
- package/types/index.ts +0 -0
|
@@ -1,301 +1,301 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="sh-date">
|
|
3
|
-
<template v-if="range">
|
|
4
|
-
<vxe-pulldown v-model="pulldownValue" v-bind="pulldownConfig" @hide-panel="onHidePanel">
|
|
5
|
-
<template #default>
|
|
6
|
-
<div class="sh-date-range-input" @click="onRangeFocus">
|
|
7
|
-
<input class="vxe-input vxe-input--inner" v-bind="startInputConfig" />
|
|
8
|
-
<span>{{ separator }}</span>
|
|
9
|
-
<input class="vxe-input vxe-input--inner" v-bind="endInputConfig" />
|
|
10
|
-
<span class="sh-date-range-suffix sh-date-clear" @click.stop="onRangeClear"><i class="vxe-icon-error-circle-fill"></i></span>
|
|
11
|
-
<span class="sh-date-range-suffix"><i class="vxe-icon-calendar"></i></span>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
<template #dropdown>
|
|
15
|
-
<div class="sh-date-content">
|
|
16
|
-
<sh-calendar v-model="rangeValue[0]" v-bind="startCalendarConfig" @change="onCalendarChange($event, 1)"></sh-calendar>
|
|
17
|
-
<div style="min-width: 10px"></div>
|
|
18
|
-
<sh-calendar v-model="rangeValue[1]" v-bind="endCalendarConfig" @change="onCalendarChange($event, 2)"></sh-calendar>
|
|
19
|
-
</div>
|
|
20
|
-
</template>
|
|
21
|
-
</vxe-pulldown>
|
|
22
|
-
</template>
|
|
23
|
-
<template v-else>
|
|
24
|
-
<vxe-input
|
|
25
|
-
v-model="inputValue"
|
|
26
|
-
v-bind="inputConfig"
|
|
27
|
-
@input="dispatch('input', $event)"
|
|
28
|
-
@change="dispatch('change', $event)"
|
|
29
|
-
@keydown="dispatch('keydown', $event)"
|
|
30
|
-
@keyup="dispatch('keyup', $event)"
|
|
31
|
-
@click="dispatch('click', $event)"
|
|
32
|
-
@focus="dispatch('focus', $event)"
|
|
33
|
-
@blur="dispatch('blur', $event)"
|
|
34
|
-
@clear="dispatch('clear', $event)"
|
|
35
|
-
@search-click="dispatch('search-click', $event)"
|
|
36
|
-
@toggle-visible="dispatch('toggle-visible', $event)"
|
|
37
|
-
@prefix-click="dispatch('prefix-click', $event)"
|
|
38
|
-
@suffix-click="dispatch('suffix-click', $event)"
|
|
39
|
-
@date-prev="dispatch('date-prev', $event)"
|
|
40
|
-
@date-today="dispatch('date-today', $event)"
|
|
41
|
-
@date-next="dispatch('date-next', $event)"></vxe-input>
|
|
42
|
-
</template>
|
|
43
|
-
</div>
|
|
44
|
-
</template>
|
|
45
|
-
|
|
46
|
-
<script>
|
|
47
|
-
// 记录自定义参数,传给vxe要过滤掉
|
|
48
|
-
let omitProps = ['range', 'separator', 'startPlaceholder', 'endPlaceholder', 'pulldown']
|
|
49
|
-
import { computed, defineComponent, getCurrentInstance, ref, reactive, onBeforeMount, watch } from 'vue'
|
|
50
|
-
export default defineComponent({
|
|
51
|
-
name: 'ShDate',
|
|
52
|
-
props: {
|
|
53
|
-
modelValue: [String, Number, Date, Array],
|
|
54
|
-
type: { type: String, default: 'date' },
|
|
55
|
-
clearable: { type: Boolean },
|
|
56
|
-
readonly: Boolean,
|
|
57
|
-
disabled: Boolean,
|
|
58
|
-
placeholder: String,
|
|
59
|
-
className: String,
|
|
60
|
-
size: String,
|
|
61
|
-
multiple: Boolean,
|
|
62
|
-
// date、week、month、quarter、year
|
|
63
|
-
startDate: { type: [String, Number, Date] },
|
|
64
|
-
endDate: { type: [String, Number, Date] },
|
|
65
|
-
minDate: [String, Number, Date],
|
|
66
|
-
maxDate: [String, Number, Date],
|
|
67
|
-
startDay: { type: [String, Number] },
|
|
68
|
-
labelFormat: { type: String, default: 'yyyy-MM-dd' },
|
|
69
|
-
valueFormat: { type: String, default: 'yyyy-MM-dd' },
|
|
70
|
-
editable: { type: Boolean, default: true },
|
|
71
|
-
festivalMethod: { type: Function },
|
|
72
|
-
disabledMethod: { type: Function },
|
|
73
|
-
// week
|
|
74
|
-
selectDay: { type: [String, Number] },
|
|
75
|
-
prefixIcon: String,
|
|
76
|
-
suffixIcon: String,
|
|
77
|
-
placement: String,
|
|
78
|
-
transfer: Boolean,
|
|
79
|
-
// 个性化参数
|
|
80
|
-
range: Boolean,
|
|
81
|
-
rangeFormat: String,
|
|
82
|
-
autoBlur: { type: Boolean, default: true },
|
|
83
|
-
separator: { type: String, default: '至' },
|
|
84
|
-
startPlaceholder: { type: String, default: '起始日期' },
|
|
85
|
-
endPlaceholder: { type: String, default: '截止日期' },
|
|
86
|
-
pulldown: Object
|
|
87
|
-
},
|
|
88
|
-
emits: [
|
|
89
|
-
'update:modelValue',
|
|
90
|
-
'focus',
|
|
91
|
-
'change',
|
|
92
|
-
'blur',
|
|
93
|
-
'input',
|
|
94
|
-
'keydown',
|
|
95
|
-
'keyup',
|
|
96
|
-
'click',
|
|
97
|
-
'clear',
|
|
98
|
-
'search-click',
|
|
99
|
-
'toggle-visible',
|
|
100
|
-
'prefix-click',
|
|
101
|
-
'suffix-click',
|
|
102
|
-
'date-prev',
|
|
103
|
-
'date-today',
|
|
104
|
-
'date-next'
|
|
105
|
-
],
|
|
106
|
-
setup(props, context) {
|
|
107
|
-
const { proxy } = getCurrentInstance()
|
|
108
|
-
const { $vUtils } = proxy
|
|
109
|
-
const { emit, slots } = context
|
|
110
|
-
|
|
111
|
-
const pulldownValue = ref(false)
|
|
112
|
-
const inputValue = ref(props.modelValue)
|
|
113
|
-
const rangeValue = ref(props.modelValue || [])
|
|
114
|
-
|
|
115
|
-
const inputConfig = computed(() => {
|
|
116
|
-
let defaultProps = {}
|
|
117
|
-
let vxeProps = $vUtils.omit(props, (val, key) => {
|
|
118
|
-
return omitProps.includes(key) || $vUtils.isNone(val)
|
|
119
|
-
})
|
|
120
|
-
let shProps = {}
|
|
121
|
-
return Object.assign(defaultProps, vxeProps, shProps)
|
|
122
|
-
})
|
|
123
|
-
const pulldownConfig = computed(() => {
|
|
124
|
-
return Object.assign({ transfer: true }, props.pulldown)
|
|
125
|
-
})
|
|
126
|
-
const calendarFormat = computed(() => {
|
|
127
|
-
if (props.rangeFormat) return props.rangeFormat
|
|
128
|
-
else if (props.type === 'month') return 'yyyy-MM'
|
|
129
|
-
else if (props.type === 'year') return 'yyyy'
|
|
130
|
-
return props.valueFormat
|
|
131
|
-
})
|
|
132
|
-
const rangeInputConfig = computed(() => ({ type: 'text', readonly: true }))
|
|
133
|
-
const startInputConfig = computed(() => {
|
|
134
|
-
let startValue = rangeValue.value[0] || ''
|
|
135
|
-
let startLabel = $vUtils.toDateString(startValue, calendarFormat.value)
|
|
136
|
-
return { ...rangeInputConfig.value, value: startLabel, placeholder: props.startPlaceholder }
|
|
137
|
-
})
|
|
138
|
-
const endInputConfig = computed(() => {
|
|
139
|
-
let endValue = rangeValue.value[1] || ''
|
|
140
|
-
let endLabel = $vUtils.toDateString(endValue, calendarFormat.value)
|
|
141
|
-
return { ...rangeInputConfig.value, value: endLabel, placeholder: props.endPlaceholder }
|
|
142
|
-
})
|
|
143
|
-
const calendarConfig = computed(() => {
|
|
144
|
-
return {
|
|
145
|
-
pulldown: true,
|
|
146
|
-
style: { height: '100%' },
|
|
147
|
-
align: 'center',
|
|
148
|
-
valueFormat: calendarFormat.value,
|
|
149
|
-
type: props.type
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
const startCalendarConfig = computed(() => {
|
|
153
|
-
let startValue = rangeValue.value[0] || ''
|
|
154
|
-
return {
|
|
155
|
-
...calendarConfig.value,
|
|
156
|
-
modelValue: startValue,
|
|
157
|
-
disabledMethod: ({ date, viewType }) => {
|
|
158
|
-
let endTime = rangeValue.value[1]
|
|
159
|
-
let { done, time } = $vUtils.getDateDiff(endTime, date)
|
|
160
|
-
return done
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
const endCalendarConfig = computed(() => {
|
|
165
|
-
let endValue = rangeValue.value[1] || ''
|
|
166
|
-
return {
|
|
167
|
-
...calendarConfig.value,
|
|
168
|
-
modelValue: endValue,
|
|
169
|
-
disabledMethod: ({ date, viewType }) => {
|
|
170
|
-
let startTime = rangeValue.value[0]
|
|
171
|
-
let { done, time } = $vUtils.getDateDiff(startTime, date)
|
|
172
|
-
return startTime ? !done : false
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
const onRangeFocus = async e => {
|
|
178
|
-
pulldownValue.value = !pulldownValue.value
|
|
179
|
-
if (pulldownValue.value) {
|
|
180
|
-
dispatch('focus', e)
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const onRangeClear = () => {
|
|
184
|
-
pulldownValue.value = false
|
|
185
|
-
rangeValue.value = []
|
|
186
|
-
onHidePanel()
|
|
187
|
-
}
|
|
188
|
-
const onHidePanel = () => {
|
|
189
|
-
dispatch('value')
|
|
190
|
-
dispatch('change')
|
|
191
|
-
dispatch('blur')
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const onCalendarChange = (date, type) => {
|
|
195
|
-
let valueList = rangeValue.value.filter(_ => _)
|
|
196
|
-
if (props.autoBlur && valueList.length === 2) {
|
|
197
|
-
pulldownValue.value = false
|
|
198
|
-
onHidePanel()
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 回调事件
|
|
203
|
-
const dispatch = (code, params) => {
|
|
204
|
-
if (props.range) {
|
|
205
|
-
let formarValue = rangeValue.value.map(item => $vUtils.toDateString(item, calendarFormat.value))
|
|
206
|
-
if (code === 'value') {
|
|
207
|
-
emit('update:modelValue', formarValue)
|
|
208
|
-
} else {
|
|
209
|
-
emit(code, { value: formarValue, params })
|
|
210
|
-
}
|
|
211
|
-
} else {
|
|
212
|
-
if (code === 'change') {
|
|
213
|
-
emit('update:modelValue', params.value)
|
|
214
|
-
}
|
|
215
|
-
emit(code, params)
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
watch(
|
|
220
|
-
() => props.modelValue,
|
|
221
|
-
(value, oldValue) => {
|
|
222
|
-
if (props.range) {
|
|
223
|
-
rangeValue.value = value
|
|
224
|
-
} else {
|
|
225
|
-
inputValue.value = value
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
return {
|
|
231
|
-
pulldownValue,
|
|
232
|
-
inputValue,
|
|
233
|
-
rangeValue,
|
|
234
|
-
inputConfig,
|
|
235
|
-
pulldownConfig,
|
|
236
|
-
startInputConfig,
|
|
237
|
-
endInputConfig,
|
|
238
|
-
startCalendarConfig,
|
|
239
|
-
endCalendarConfig,
|
|
240
|
-
onRangeFocus,
|
|
241
|
-
onHidePanel,
|
|
242
|
-
onRangeClear,
|
|
243
|
-
onCalendarChange,
|
|
244
|
-
dispatch
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
})
|
|
248
|
-
</script>
|
|
249
|
-
|
|
250
|
-
<style scoped lang="scss">
|
|
251
|
-
.sh-date {
|
|
252
|
-
display: inline-block;
|
|
253
|
-
position: relative;
|
|
254
|
-
}
|
|
255
|
-
.sh-date-range-input {
|
|
256
|
-
display: flex;
|
|
257
|
-
justify-content: space-between;
|
|
258
|
-
align-items: center;
|
|
259
|
-
border-radius: var(--vxe-border-radius);
|
|
260
|
-
color: var(--vxe-font-color);
|
|
261
|
-
border: 1px solid var(--vxe-input-border-color);
|
|
262
|
-
background-color: var(--vxe-input-background-color);
|
|
263
|
-
box-shadow: none;
|
|
264
|
-
&:hover {
|
|
265
|
-
.sh-date-clear {
|
|
266
|
-
display: flex;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
input {
|
|
270
|
-
width: 100%;
|
|
271
|
-
border: none;
|
|
272
|
-
color: inherit;
|
|
273
|
-
text-align: center;
|
|
274
|
-
}
|
|
275
|
-
.sh-date-range-suffix {
|
|
276
|
-
color: var(--vxe-table-column-icon-border-color);
|
|
277
|
-
height: 100%;
|
|
278
|
-
display: inline-flex;
|
|
279
|
-
margin-right: 8px;
|
|
280
|
-
}
|
|
281
|
-
.sh-date-clear {
|
|
282
|
-
cursor: pointer;
|
|
283
|
-
display: none;
|
|
284
|
-
position: absolute;
|
|
285
|
-
right: 0;
|
|
286
|
-
height: 100%;
|
|
287
|
-
justify-content: center;
|
|
288
|
-
align-items: center;
|
|
289
|
-
&:hover {
|
|
290
|
-
color: inherit;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
.sh-date-content {
|
|
295
|
-
display: flex;
|
|
296
|
-
justify-content: space-between;
|
|
297
|
-
padding: 12px;
|
|
298
|
-
width: 600px;
|
|
299
|
-
max-width: 100%;
|
|
300
|
-
}
|
|
301
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="sh-date">
|
|
3
|
+
<template v-if="range">
|
|
4
|
+
<vxe-pulldown v-model="pulldownValue" v-bind="pulldownConfig" @hide-panel="onHidePanel">
|
|
5
|
+
<template #default>
|
|
6
|
+
<div class="sh-date-range-input" @click="onRangeFocus">
|
|
7
|
+
<input class="vxe-input vxe-input--inner" v-bind="startInputConfig" />
|
|
8
|
+
<span>{{ separator }}</span>
|
|
9
|
+
<input class="vxe-input vxe-input--inner" v-bind="endInputConfig" />
|
|
10
|
+
<span class="sh-date-range-suffix sh-date-clear" @click.stop="onRangeClear"><i class="vxe-icon-error-circle-fill"></i></span>
|
|
11
|
+
<span class="sh-date-range-suffix"><i class="vxe-icon-calendar"></i></span>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
<template #dropdown>
|
|
15
|
+
<div class="sh-date-content">
|
|
16
|
+
<sh-calendar v-model="rangeValue[0]" v-bind="startCalendarConfig" @change="onCalendarChange($event, 1)"></sh-calendar>
|
|
17
|
+
<div style="min-width: 10px"></div>
|
|
18
|
+
<sh-calendar v-model="rangeValue[1]" v-bind="endCalendarConfig" @change="onCalendarChange($event, 2)"></sh-calendar>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
</vxe-pulldown>
|
|
22
|
+
</template>
|
|
23
|
+
<template v-else>
|
|
24
|
+
<vxe-input
|
|
25
|
+
v-model="inputValue"
|
|
26
|
+
v-bind="inputConfig"
|
|
27
|
+
@input="dispatch('input', $event)"
|
|
28
|
+
@change="dispatch('change', $event)"
|
|
29
|
+
@keydown="dispatch('keydown', $event)"
|
|
30
|
+
@keyup="dispatch('keyup', $event)"
|
|
31
|
+
@click="dispatch('click', $event)"
|
|
32
|
+
@focus="dispatch('focus', $event)"
|
|
33
|
+
@blur="dispatch('blur', $event)"
|
|
34
|
+
@clear="dispatch('clear', $event)"
|
|
35
|
+
@search-click="dispatch('search-click', $event)"
|
|
36
|
+
@toggle-visible="dispatch('toggle-visible', $event)"
|
|
37
|
+
@prefix-click="dispatch('prefix-click', $event)"
|
|
38
|
+
@suffix-click="dispatch('suffix-click', $event)"
|
|
39
|
+
@date-prev="dispatch('date-prev', $event)"
|
|
40
|
+
@date-today="dispatch('date-today', $event)"
|
|
41
|
+
@date-next="dispatch('date-next', $event)"></vxe-input>
|
|
42
|
+
</template>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
// 记录自定义参数,传给vxe要过滤掉
|
|
48
|
+
let omitProps = ['range', 'separator', 'startPlaceholder', 'endPlaceholder', 'pulldown']
|
|
49
|
+
import { computed, defineComponent, getCurrentInstance, ref, reactive, onBeforeMount, watch } from 'vue'
|
|
50
|
+
export default defineComponent({
|
|
51
|
+
name: 'ShDate',
|
|
52
|
+
props: {
|
|
53
|
+
modelValue: [String, Number, Date, Array],
|
|
54
|
+
type: { type: String, default: 'date' },
|
|
55
|
+
clearable: { type: Boolean },
|
|
56
|
+
readonly: Boolean,
|
|
57
|
+
disabled: Boolean,
|
|
58
|
+
placeholder: String,
|
|
59
|
+
className: String,
|
|
60
|
+
size: String,
|
|
61
|
+
multiple: Boolean,
|
|
62
|
+
// date、week、month、quarter、year
|
|
63
|
+
startDate: { type: [String, Number, Date] },
|
|
64
|
+
endDate: { type: [String, Number, Date] },
|
|
65
|
+
minDate: [String, Number, Date],
|
|
66
|
+
maxDate: [String, Number, Date],
|
|
67
|
+
startDay: { type: [String, Number] },
|
|
68
|
+
labelFormat: { type: String, default: 'yyyy-MM-dd' },
|
|
69
|
+
valueFormat: { type: String, default: 'yyyy-MM-dd' },
|
|
70
|
+
editable: { type: Boolean, default: true },
|
|
71
|
+
festivalMethod: { type: Function },
|
|
72
|
+
disabledMethod: { type: Function },
|
|
73
|
+
// week
|
|
74
|
+
selectDay: { type: [String, Number] },
|
|
75
|
+
prefixIcon: String,
|
|
76
|
+
suffixIcon: String,
|
|
77
|
+
placement: String,
|
|
78
|
+
transfer: Boolean,
|
|
79
|
+
// 个性化参数
|
|
80
|
+
range: Boolean,
|
|
81
|
+
rangeFormat: String,
|
|
82
|
+
autoBlur: { type: Boolean, default: true },
|
|
83
|
+
separator: { type: String, default: '至' },
|
|
84
|
+
startPlaceholder: { type: String, default: '起始日期' },
|
|
85
|
+
endPlaceholder: { type: String, default: '截止日期' },
|
|
86
|
+
pulldown: Object
|
|
87
|
+
},
|
|
88
|
+
emits: [
|
|
89
|
+
'update:modelValue',
|
|
90
|
+
'focus',
|
|
91
|
+
'change',
|
|
92
|
+
'blur',
|
|
93
|
+
'input',
|
|
94
|
+
'keydown',
|
|
95
|
+
'keyup',
|
|
96
|
+
'click',
|
|
97
|
+
'clear',
|
|
98
|
+
'search-click',
|
|
99
|
+
'toggle-visible',
|
|
100
|
+
'prefix-click',
|
|
101
|
+
'suffix-click',
|
|
102
|
+
'date-prev',
|
|
103
|
+
'date-today',
|
|
104
|
+
'date-next'
|
|
105
|
+
],
|
|
106
|
+
setup(props, context) {
|
|
107
|
+
const { proxy } = getCurrentInstance()
|
|
108
|
+
const { $vUtils } = proxy
|
|
109
|
+
const { emit, slots } = context
|
|
110
|
+
|
|
111
|
+
const pulldownValue = ref(false)
|
|
112
|
+
const inputValue = ref(props.modelValue)
|
|
113
|
+
const rangeValue = ref(props.modelValue || [])
|
|
114
|
+
|
|
115
|
+
const inputConfig = computed(() => {
|
|
116
|
+
let defaultProps = {}
|
|
117
|
+
let vxeProps = $vUtils.omit(props, (val, key) => {
|
|
118
|
+
return omitProps.includes(key) || $vUtils.isNone(val)
|
|
119
|
+
})
|
|
120
|
+
let shProps = {}
|
|
121
|
+
return Object.assign(defaultProps, vxeProps, shProps)
|
|
122
|
+
})
|
|
123
|
+
const pulldownConfig = computed(() => {
|
|
124
|
+
return Object.assign({ transfer: true }, props.pulldown)
|
|
125
|
+
})
|
|
126
|
+
const calendarFormat = computed(() => {
|
|
127
|
+
if (props.rangeFormat) return props.rangeFormat
|
|
128
|
+
else if (props.type === 'month') return 'yyyy-MM'
|
|
129
|
+
else if (props.type === 'year') return 'yyyy'
|
|
130
|
+
return props.valueFormat
|
|
131
|
+
})
|
|
132
|
+
const rangeInputConfig = computed(() => ({ type: 'text', readonly: true }))
|
|
133
|
+
const startInputConfig = computed(() => {
|
|
134
|
+
let startValue = rangeValue.value[0] || ''
|
|
135
|
+
let startLabel = $vUtils.toDateString(startValue, calendarFormat.value)
|
|
136
|
+
return { ...rangeInputConfig.value, value: startLabel, placeholder: props.startPlaceholder }
|
|
137
|
+
})
|
|
138
|
+
const endInputConfig = computed(() => {
|
|
139
|
+
let endValue = rangeValue.value[1] || ''
|
|
140
|
+
let endLabel = $vUtils.toDateString(endValue, calendarFormat.value)
|
|
141
|
+
return { ...rangeInputConfig.value, value: endLabel, placeholder: props.endPlaceholder }
|
|
142
|
+
})
|
|
143
|
+
const calendarConfig = computed(() => {
|
|
144
|
+
return {
|
|
145
|
+
pulldown: true,
|
|
146
|
+
style: { height: '100%' },
|
|
147
|
+
align: 'center',
|
|
148
|
+
valueFormat: calendarFormat.value,
|
|
149
|
+
type: props.type
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
const startCalendarConfig = computed(() => {
|
|
153
|
+
let startValue = rangeValue.value[0] || ''
|
|
154
|
+
return {
|
|
155
|
+
...calendarConfig.value,
|
|
156
|
+
modelValue: startValue,
|
|
157
|
+
disabledMethod: ({ date, viewType }) => {
|
|
158
|
+
let endTime = rangeValue.value[1]
|
|
159
|
+
let { done, time } = $vUtils.getDateDiff(endTime, date)
|
|
160
|
+
return done
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
const endCalendarConfig = computed(() => {
|
|
165
|
+
let endValue = rangeValue.value[1] || ''
|
|
166
|
+
return {
|
|
167
|
+
...calendarConfig.value,
|
|
168
|
+
modelValue: endValue,
|
|
169
|
+
disabledMethod: ({ date, viewType }) => {
|
|
170
|
+
let startTime = rangeValue.value[0]
|
|
171
|
+
let { done, time } = $vUtils.getDateDiff(startTime, date)
|
|
172
|
+
return startTime ? !done : false
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
const onRangeFocus = async e => {
|
|
178
|
+
pulldownValue.value = !pulldownValue.value
|
|
179
|
+
if (pulldownValue.value) {
|
|
180
|
+
dispatch('focus', e)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const onRangeClear = () => {
|
|
184
|
+
pulldownValue.value = false
|
|
185
|
+
rangeValue.value = []
|
|
186
|
+
onHidePanel()
|
|
187
|
+
}
|
|
188
|
+
const onHidePanel = () => {
|
|
189
|
+
dispatch('value')
|
|
190
|
+
dispatch('change')
|
|
191
|
+
dispatch('blur')
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const onCalendarChange = (date, type) => {
|
|
195
|
+
let valueList = rangeValue.value.filter(_ => _)
|
|
196
|
+
if (props.autoBlur && valueList.length === 2) {
|
|
197
|
+
pulldownValue.value = false
|
|
198
|
+
onHidePanel()
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 回调事件
|
|
203
|
+
const dispatch = (code, params) => {
|
|
204
|
+
if (props.range) {
|
|
205
|
+
let formarValue = rangeValue.value.map(item => $vUtils.toDateString(item, calendarFormat.value))
|
|
206
|
+
if (code === 'value') {
|
|
207
|
+
emit('update:modelValue', formarValue)
|
|
208
|
+
} else {
|
|
209
|
+
emit(code, { value: formarValue, params })
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
if (code === 'change') {
|
|
213
|
+
emit('update:modelValue', params.value)
|
|
214
|
+
}
|
|
215
|
+
emit(code, params)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
watch(
|
|
220
|
+
() => props.modelValue,
|
|
221
|
+
(value, oldValue) => {
|
|
222
|
+
if (props.range) {
|
|
223
|
+
rangeValue.value = value
|
|
224
|
+
} else {
|
|
225
|
+
inputValue.value = value
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
pulldownValue,
|
|
232
|
+
inputValue,
|
|
233
|
+
rangeValue,
|
|
234
|
+
inputConfig,
|
|
235
|
+
pulldownConfig,
|
|
236
|
+
startInputConfig,
|
|
237
|
+
endInputConfig,
|
|
238
|
+
startCalendarConfig,
|
|
239
|
+
endCalendarConfig,
|
|
240
|
+
onRangeFocus,
|
|
241
|
+
onHidePanel,
|
|
242
|
+
onRangeClear,
|
|
243
|
+
onCalendarChange,
|
|
244
|
+
dispatch
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
</script>
|
|
249
|
+
|
|
250
|
+
<style scoped lang="scss">
|
|
251
|
+
.sh-date {
|
|
252
|
+
display: inline-block;
|
|
253
|
+
position: relative;
|
|
254
|
+
}
|
|
255
|
+
.sh-date-range-input {
|
|
256
|
+
display: flex;
|
|
257
|
+
justify-content: space-between;
|
|
258
|
+
align-items: center;
|
|
259
|
+
border-radius: var(--vxe-border-radius);
|
|
260
|
+
color: var(--vxe-font-color);
|
|
261
|
+
border: 1px solid var(--vxe-input-border-color);
|
|
262
|
+
background-color: var(--vxe-input-background-color);
|
|
263
|
+
box-shadow: none;
|
|
264
|
+
&:hover {
|
|
265
|
+
.sh-date-clear {
|
|
266
|
+
display: flex;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
input {
|
|
270
|
+
width: 100%;
|
|
271
|
+
border: none;
|
|
272
|
+
color: inherit;
|
|
273
|
+
text-align: center;
|
|
274
|
+
}
|
|
275
|
+
.sh-date-range-suffix {
|
|
276
|
+
color: var(--vxe-table-column-icon-border-color);
|
|
277
|
+
height: 100%;
|
|
278
|
+
display: inline-flex;
|
|
279
|
+
margin-right: 8px;
|
|
280
|
+
}
|
|
281
|
+
.sh-date-clear {
|
|
282
|
+
cursor: pointer;
|
|
283
|
+
display: none;
|
|
284
|
+
position: absolute;
|
|
285
|
+
right: 0;
|
|
286
|
+
height: 100%;
|
|
287
|
+
justify-content: center;
|
|
288
|
+
align-items: center;
|
|
289
|
+
&:hover {
|
|
290
|
+
color: inherit;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
.sh-date-content {
|
|
295
|
+
display: flex;
|
|
296
|
+
justify-content: space-between;
|
|
297
|
+
padding: 12px;
|
|
298
|
+
width: 600px;
|
|
299
|
+
max-width: 100%;
|
|
300
|
+
}
|
|
301
|
+
</style>
|