yj-kikimore 0.1.0
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/LICENSE +21 -0
- package/README.md +489 -0
- package/package.json +99 -0
- package/src/FormDialog/elementIsVisible.ts +7 -0
- package/src/FormDialog/highlightError.scss +85 -0
- package/src/FormDialog/highlightError.ts +84 -0
- package/src/FormDialog/index.vue +932 -0
- package/src/PopButton/index.vue +168 -0
- package/src/PopSwitch/index.vue +271 -0
- package/src/PopSwitch/utils.ts +9 -0
- package/src/Select/index.vue +480 -0
- package/src/index.ts +6 -0
- package/src/src/FormDialog/elementIsVisible.d.ts +2 -0
- package/src/src/FormDialog/highlightError.d.ts +2 -0
- package/src/src/PopSwitch/utils.d.ts +1 -0
- package/src/src/index.d.ts +5 -0
- package/src/src/utils.d.ts +8 -0
- package/src/utils.ts +80 -0
|
@@ -0,0 +1,932 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 为什么要套一个 div? -->
|
|
3
|
+
<!-- https://github.com/element-plus/element-plus/issues/10515 -->
|
|
4
|
+
<div>
|
|
5
|
+
<el-dialog
|
|
6
|
+
v-bind="ElDialogProps"
|
|
7
|
+
ref="elDialogRef"
|
|
8
|
+
:key="key"
|
|
9
|
+
v-model="show"
|
|
10
|
+
:visible="show"
|
|
11
|
+
:title="Title"
|
|
12
|
+
:destroyOnClose="false"
|
|
13
|
+
:appendToBody="false"
|
|
14
|
+
:fullscreen="fullscreen"
|
|
15
|
+
v-on="Listeners"
|
|
16
|
+
@closed="onClosed"
|
|
17
|
+
>
|
|
18
|
+
<!-- 向 el-dialog 传递 slot -->
|
|
19
|
+
<template #[headerSlotName]>
|
|
20
|
+
<!-- 接收 slot -->
|
|
21
|
+
<component v-if="isGlobalSlot(Slots[headerSlotName])" :is="Slots[headerSlotName]()" />
|
|
22
|
+
<slot v-else :name="headerSlotName">
|
|
23
|
+
<span>{{ Title }}</span>
|
|
24
|
+
</slot>
|
|
25
|
+
<div style="display: flex; align-items: center">
|
|
26
|
+
<template v-if="isVue3">
|
|
27
|
+
<el-icon
|
|
28
|
+
v-if="ShowFullscreenToggle"
|
|
29
|
+
:class="fullscreen ? 'el-icon-copy-document' : 'el-icon-full-screen'"
|
|
30
|
+
@click="toggleFullscreen()"
|
|
31
|
+
>
|
|
32
|
+
<Component :is="fullscreen ? 'CopyDocument' : 'FullScreen'" />
|
|
33
|
+
</el-icon>
|
|
34
|
+
<el-icon
|
|
35
|
+
v-if="ElDialogProps.showClose !== false"
|
|
36
|
+
class="el-icon-close"
|
|
37
|
+
@click="onCancel"
|
|
38
|
+
>
|
|
39
|
+
<Close />
|
|
40
|
+
</el-icon>
|
|
41
|
+
</template>
|
|
42
|
+
<template v-else>
|
|
43
|
+
<i
|
|
44
|
+
v-if="ShowFullscreenToggle"
|
|
45
|
+
:class="fullscreen ? 'el-icon-copy-document' : 'el-icon-full-screen'"
|
|
46
|
+
@click="toggleFullscreen()"
|
|
47
|
+
/>
|
|
48
|
+
<i v-if="ElDialogProps.showClose !== false" class="el-icon-close" @click="onCancel" />
|
|
49
|
+
</template>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
<div v-loading="Loading" style="display: flex; flex-direction: column; overflow-y: hidden">
|
|
53
|
+
<div
|
|
54
|
+
ref="overlayScrollbar"
|
|
55
|
+
style="overflow-y: auto; padding: 25px 40px 85px 40px; max-height: calc(100vh - 45px)"
|
|
56
|
+
>
|
|
57
|
+
<el-form
|
|
58
|
+
v-if="ValueIsPlainObject"
|
|
59
|
+
:class="Readonly && 'readonly'"
|
|
60
|
+
v-bind="ElFormProps"
|
|
61
|
+
v-on="Listeners"
|
|
62
|
+
>
|
|
63
|
+
<component v-if="isGlobalSlot(Slots['default'])" :is="Slots['default']()" />
|
|
64
|
+
<slot v-else />
|
|
65
|
+
</el-form>
|
|
66
|
+
<template v-else>
|
|
67
|
+
<component v-if="isGlobalSlot(Slots['default'])" :is="Slots['default']()" />
|
|
68
|
+
<slot v-else />
|
|
69
|
+
</template>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<template #footer>
|
|
74
|
+
<component v-if="isGlobalSlot(Slots['footer'])" :is="Slots['footer']()" />
|
|
75
|
+
<slot v-else name="footer">
|
|
76
|
+
<template v-if="ReverseButtons">
|
|
77
|
+
<el-button
|
|
78
|
+
v-if="ShowConfirmButton"
|
|
79
|
+
type="primary"
|
|
80
|
+
:disabled="closing || denying"
|
|
81
|
+
:class="closing && 'closing'"
|
|
82
|
+
:loading="confirming"
|
|
83
|
+
@click="onConfirm"
|
|
84
|
+
>
|
|
85
|
+
{{ ConfirmButtonText }}
|
|
86
|
+
</el-button>
|
|
87
|
+
<el-button
|
|
88
|
+
v-if="ShowDenyButton"
|
|
89
|
+
type="danger"
|
|
90
|
+
:disabled="closing || confirming"
|
|
91
|
+
:class="closing && 'closing'"
|
|
92
|
+
:loading="denying"
|
|
93
|
+
@click="onDeny"
|
|
94
|
+
>
|
|
95
|
+
{{ DenyButtonText }}
|
|
96
|
+
</el-button>
|
|
97
|
+
<el-button
|
|
98
|
+
v-if="ShowResetButton && $refs[ElFormProps.ref]"
|
|
99
|
+
type="info"
|
|
100
|
+
:disabled="closing || confirming || denying"
|
|
101
|
+
@click="onReset"
|
|
102
|
+
>
|
|
103
|
+
{{ ResetButtonText }}
|
|
104
|
+
</el-button>
|
|
105
|
+
<el-button
|
|
106
|
+
v-if="ShowCancelButton"
|
|
107
|
+
:disabled="closing"
|
|
108
|
+
:class="closing && 'closing'"
|
|
109
|
+
@click="onCancel"
|
|
110
|
+
>
|
|
111
|
+
{{ CancelButtonText }}
|
|
112
|
+
</el-button>
|
|
113
|
+
</template>
|
|
114
|
+
|
|
115
|
+
<template v-else>
|
|
116
|
+
<el-button
|
|
117
|
+
v-if="ShowCancelButton"
|
|
118
|
+
:disabled="closing"
|
|
119
|
+
:class="closing && 'closing'"
|
|
120
|
+
@click="onCancel"
|
|
121
|
+
>
|
|
122
|
+
{{ CancelButtonText }}
|
|
123
|
+
</el-button>
|
|
124
|
+
<el-button
|
|
125
|
+
v-if="ShowResetButton && $refs[ElFormProps.ref]"
|
|
126
|
+
type="info"
|
|
127
|
+
:disabled="closing || confirming || denying"
|
|
128
|
+
@click="onReset"
|
|
129
|
+
>
|
|
130
|
+
{{ ResetButtonText }}
|
|
131
|
+
</el-button>
|
|
132
|
+
<el-button
|
|
133
|
+
v-if="ShowDenyButton"
|
|
134
|
+
type="danger"
|
|
135
|
+
:disabled="closing || confirming"
|
|
136
|
+
:class="closing && 'closing'"
|
|
137
|
+
:loading="denying"
|
|
138
|
+
@click="onDeny"
|
|
139
|
+
>
|
|
140
|
+
{{ DenyButtonText }}
|
|
141
|
+
</el-button>
|
|
142
|
+
<el-button
|
|
143
|
+
v-if="ShowConfirmButton"
|
|
144
|
+
type="primary"
|
|
145
|
+
:disabled="closing || denying"
|
|
146
|
+
:class="closing && 'closing'"
|
|
147
|
+
:loading="confirming"
|
|
148
|
+
@click="onConfirm"
|
|
149
|
+
>
|
|
150
|
+
{{ ConfirmButtonText }}
|
|
151
|
+
</el-button>
|
|
152
|
+
</template>
|
|
153
|
+
</slot>
|
|
154
|
+
</template>
|
|
155
|
+
</el-dialog>
|
|
156
|
+
</div>
|
|
157
|
+
</template>
|
|
158
|
+
|
|
159
|
+
<script>
|
|
160
|
+
import { isVue3 } from 'vue-demi'
|
|
161
|
+
import { conclude, resolveConfig } from 'vue-global-config'
|
|
162
|
+
import { cloneDeep, isPlainObject } from 'lodash-es'
|
|
163
|
+
import { getListeners, isGlobalSlot } from '../utils'
|
|
164
|
+
import highlightError from './highlightError'
|
|
165
|
+
|
|
166
|
+
const globalProps = {}
|
|
167
|
+
const globalAttrs = {}
|
|
168
|
+
const globalListeners = {}
|
|
169
|
+
const globalSlots = {}
|
|
170
|
+
|
|
171
|
+
const model = {
|
|
172
|
+
prop: isVue3 ? 'modelValue' : 'value',
|
|
173
|
+
event: isVue3 ? 'update:modelValue' : 'input'
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const boolProps = [
|
|
177
|
+
'show',
|
|
178
|
+
'readonly',
|
|
179
|
+
'loading',
|
|
180
|
+
'showFullscreenToggle',
|
|
181
|
+
'showConfirmButton',
|
|
182
|
+
'showDenyButton',
|
|
183
|
+
'showResetButton',
|
|
184
|
+
'showCancelButton',
|
|
185
|
+
'reverseButtons'
|
|
186
|
+
]
|
|
187
|
+
|
|
188
|
+
export default {
|
|
189
|
+
name: 'KiFormDialog',
|
|
190
|
+
install(app, options = {}) {
|
|
191
|
+
const { props, attrs, listeners, slots } = resolveConfig(options, this.props)
|
|
192
|
+
Object.assign(globalProps, props)
|
|
193
|
+
Object.assign(globalAttrs, attrs)
|
|
194
|
+
Object.assign(globalListeners, listeners)
|
|
195
|
+
Object.assign(globalSlots, slots)
|
|
196
|
+
app.component(this.name, this)
|
|
197
|
+
},
|
|
198
|
+
props: {
|
|
199
|
+
[model.prop]: {},
|
|
200
|
+
title: {},
|
|
201
|
+
elFormProps: {},
|
|
202
|
+
retrieve: {},
|
|
203
|
+
confirm: {},
|
|
204
|
+
deny: {},
|
|
205
|
+
getContainer: {},
|
|
206
|
+
confirmButtonText: {},
|
|
207
|
+
resetButtonText: {},
|
|
208
|
+
denyButtonText: {},
|
|
209
|
+
cancelButtonText: {},
|
|
210
|
+
...Object.fromEntries(
|
|
211
|
+
Array.from(boolProps, (boolProp) => [
|
|
212
|
+
boolProp,
|
|
213
|
+
{
|
|
214
|
+
type: Boolean,
|
|
215
|
+
default: undefined
|
|
216
|
+
}
|
|
217
|
+
])
|
|
218
|
+
)
|
|
219
|
+
},
|
|
220
|
+
emits: [model.event, 'update:show', 'fullscreen-change'],
|
|
221
|
+
data() {
|
|
222
|
+
return {
|
|
223
|
+
initialValue: undefined,
|
|
224
|
+
initiated: false,
|
|
225
|
+
retrieving: true,
|
|
226
|
+
confirming: false,
|
|
227
|
+
denying: false,
|
|
228
|
+
closing: false,
|
|
229
|
+
scrollbar: null,
|
|
230
|
+
beforeCloseIsPassed: false,
|
|
231
|
+
fullscreen: false,
|
|
232
|
+
labelWidth: undefined,
|
|
233
|
+
key: 0,
|
|
234
|
+
isVue3
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
computed: {
|
|
238
|
+
Listeners() {
|
|
239
|
+
return getListeners.call(this, globalListeners)
|
|
240
|
+
},
|
|
241
|
+
Slots() {
|
|
242
|
+
return conclude([isVue3 ? this.$slots : this.$scopedSlots, globalSlots])
|
|
243
|
+
},
|
|
244
|
+
headerSlotName() {
|
|
245
|
+
return isVue3 ? 'header' : 'title'
|
|
246
|
+
},
|
|
247
|
+
ConfirmButtonText() {
|
|
248
|
+
return conclude([this.confirmButtonText, globalProps.confirmButtonText, 'OK'], {
|
|
249
|
+
type: String
|
|
250
|
+
})
|
|
251
|
+
},
|
|
252
|
+
DenyButtonText() {
|
|
253
|
+
return conclude([this.denyButtonText, globalProps.denyButtonText, 'No'], {
|
|
254
|
+
type: String
|
|
255
|
+
})
|
|
256
|
+
},
|
|
257
|
+
ResetButtonText() {
|
|
258
|
+
return conclude([this.resetButtonText, globalProps.resetButtonText, 'Reset'], {
|
|
259
|
+
type: String
|
|
260
|
+
})
|
|
261
|
+
},
|
|
262
|
+
CancelButtonText() {
|
|
263
|
+
return conclude([this.cancelButtonText, globalProps.cancelButtonText, 'Cancel'], {
|
|
264
|
+
type: String
|
|
265
|
+
})
|
|
266
|
+
},
|
|
267
|
+
ShowFullscreenToggle() {
|
|
268
|
+
return conclude([this.showFullscreenToggle, globalProps.showFullscreenToggle, true], {
|
|
269
|
+
type: Boolean
|
|
270
|
+
})
|
|
271
|
+
},
|
|
272
|
+
ShowConfirmButton() {
|
|
273
|
+
return conclude([this.showConfirmButton, globalProps.showConfirmButton, !this.Readonly], {
|
|
274
|
+
type: Boolean
|
|
275
|
+
})
|
|
276
|
+
},
|
|
277
|
+
ShowDenyButton() {
|
|
278
|
+
return conclude([this.showDenyButton, globalProps.showDenyButton, false], {
|
|
279
|
+
type: Boolean
|
|
280
|
+
})
|
|
281
|
+
},
|
|
282
|
+
ShowResetButton() {
|
|
283
|
+
return conclude([this.showResetButton, globalProps.showResetButton, false], {
|
|
284
|
+
type: Boolean
|
|
285
|
+
})
|
|
286
|
+
},
|
|
287
|
+
ShowCancelButton() {
|
|
288
|
+
return conclude([this.showCancelButton, globalProps.showCancelButton, !this.Readonly], {
|
|
289
|
+
type: Boolean
|
|
290
|
+
})
|
|
291
|
+
},
|
|
292
|
+
ReverseButtons() {
|
|
293
|
+
return conclude([this.reverseButtons, globalProps.reverseButtons, false], {
|
|
294
|
+
type: Boolean
|
|
295
|
+
})
|
|
296
|
+
},
|
|
297
|
+
ValueIsPlainObject() {
|
|
298
|
+
return isPlainObject(this[model.prop])
|
|
299
|
+
},
|
|
300
|
+
Title() {
|
|
301
|
+
return conclude([this.title, globalProps.title], {
|
|
302
|
+
type: String
|
|
303
|
+
})
|
|
304
|
+
},
|
|
305
|
+
Loading() {
|
|
306
|
+
return conclude([this.loading, globalProps.loading, this.retrieving], {
|
|
307
|
+
type: Boolean
|
|
308
|
+
})
|
|
309
|
+
},
|
|
310
|
+
Retrieve() {
|
|
311
|
+
return conclude([this.retrieve, globalProps.retrieve], {
|
|
312
|
+
type: Function
|
|
313
|
+
})
|
|
314
|
+
},
|
|
315
|
+
Confirm() {
|
|
316
|
+
return conclude([this.confirm, globalProps.confirm], {
|
|
317
|
+
type: Function
|
|
318
|
+
})
|
|
319
|
+
},
|
|
320
|
+
Deny() {
|
|
321
|
+
return conclude([this.deny, globalProps.deny], {
|
|
322
|
+
type: Function
|
|
323
|
+
})
|
|
324
|
+
},
|
|
325
|
+
Readonly() {
|
|
326
|
+
return conclude([this.readonly, globalProps.readonly, false], {
|
|
327
|
+
type: Boolean
|
|
328
|
+
})
|
|
329
|
+
},
|
|
330
|
+
// 必须放在 ElDialogProps 下面
|
|
331
|
+
GetContainer() {
|
|
332
|
+
return conclude(
|
|
333
|
+
[
|
|
334
|
+
this.getContainer,
|
|
335
|
+
globalProps.getContainer,
|
|
336
|
+
[true, ''].includes(this.ElDialogProps.appendToBody) ? 'body' : undefined
|
|
337
|
+
],
|
|
338
|
+
{
|
|
339
|
+
type: [String, Function]
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
},
|
|
343
|
+
ElDialogProps() {
|
|
344
|
+
return conclude([this.$attrs, globalAttrs], {
|
|
345
|
+
type: Object,
|
|
346
|
+
camelizeObjectKeys: true,
|
|
347
|
+
default: (userProp) => {
|
|
348
|
+
this.beforeCloseIsPassed = Boolean(userProp.beforeClose)
|
|
349
|
+
if (userProp.fullscreen !== undefined && this.show) {
|
|
350
|
+
this.toggleFullscreen([true, ''].includes(userProp.fullscreen))
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
closeOnClickModal: false,
|
|
354
|
+
...(!this.beforeCloseIsPassed && {
|
|
355
|
+
beforeClose: () => {
|
|
356
|
+
this.$emit('update:show', false)
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
defaultIsDynamic: true
|
|
362
|
+
})
|
|
363
|
+
},
|
|
364
|
+
ElFormProps() {
|
|
365
|
+
return {
|
|
366
|
+
model: this[model.prop],
|
|
367
|
+
...conclude(
|
|
368
|
+
[
|
|
369
|
+
this.elFormProps,
|
|
370
|
+
globalProps.elFormProps,
|
|
371
|
+
{
|
|
372
|
+
disabled: this.readonly || this.confirming,
|
|
373
|
+
ref: 'elFormRef',
|
|
374
|
+
labelWidth: this.labelWidth
|
|
375
|
+
// model 不能写在这里因为会被深拷贝,将导致无法重置
|
|
376
|
+
// model: this[model.prop],
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
{
|
|
380
|
+
type: Object,
|
|
381
|
+
camelizeObjectKeys: true
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
watch: {
|
|
388
|
+
show: {
|
|
389
|
+
// 针对默认打开的情况 默认打开时 依然执行retrieve
|
|
390
|
+
immediate: true,
|
|
391
|
+
handler(newShow) {
|
|
392
|
+
if (newShow) {
|
|
393
|
+
/* if (!this.labelWidthSettled) {
|
|
394
|
+
this.labelWidth = await this.getLabelWidth()
|
|
395
|
+
this.labelWidthSettled = true
|
|
396
|
+
} */
|
|
397
|
+
this.retrieving = true
|
|
398
|
+
const result = this.Retrieve?.()
|
|
399
|
+
if (result instanceof Promise) {
|
|
400
|
+
result
|
|
401
|
+
.catch((e) => {
|
|
402
|
+
console.error(e)
|
|
403
|
+
this.onCancel()
|
|
404
|
+
})
|
|
405
|
+
.finally((e) => {
|
|
406
|
+
this.retrieving = false
|
|
407
|
+
})
|
|
408
|
+
} else {
|
|
409
|
+
this.retrieving = false
|
|
410
|
+
}
|
|
411
|
+
this.computeLabelWidth()
|
|
412
|
+
// 不兼容 tinymce
|
|
413
|
+
/* this.$nextTick(() => {
|
|
414
|
+
this.osInstance = OverlayScrollbars(this.$refs.overlayScrollbar, {})
|
|
415
|
+
}) */
|
|
416
|
+
}
|
|
417
|
+
// 首次不执行
|
|
418
|
+
else if (this.initiated) {
|
|
419
|
+
this.closing = true
|
|
420
|
+
}
|
|
421
|
+
if (this.GetContainer) {
|
|
422
|
+
this.$nextTick(() => {
|
|
423
|
+
;(typeof this.GetContainer === 'function'
|
|
424
|
+
? this.GetContainer()
|
|
425
|
+
: document.querySelector(this.GetContainer)
|
|
426
|
+
).appendChild(this.$el)
|
|
427
|
+
})
|
|
428
|
+
}
|
|
429
|
+
this.initiated = true
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
mounted() {
|
|
434
|
+
this.initialValue = cloneDeep(this[model.prop])
|
|
435
|
+
},
|
|
436
|
+
updated() {
|
|
437
|
+
this.computeLabelWidth()
|
|
438
|
+
},
|
|
439
|
+
unmounted() {
|
|
440
|
+
if (this.GetContainer && this.$el?.parentNode) {
|
|
441
|
+
this.$el.parentNode.removeChild(this.$el)
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
methods: {
|
|
445
|
+
isGlobalSlot,
|
|
446
|
+
toggleFullscreen(newValue = !this.fullscreen) {
|
|
447
|
+
if (typeof newValue !== 'boolean') {
|
|
448
|
+
return
|
|
449
|
+
}
|
|
450
|
+
this.fullscreen = newValue
|
|
451
|
+
this.$nextTick(() => {
|
|
452
|
+
window.dispatchEvent(new Event('resize'))
|
|
453
|
+
this.$emit('fullscreen-change', this.fullscreen)
|
|
454
|
+
})
|
|
455
|
+
},
|
|
456
|
+
// fix: https://github.com/ElemeFE/element/issues?q=label+width+auto
|
|
457
|
+
computeLabelWidth() {
|
|
458
|
+
const { labelWidth, labelPosition } = this.ElFormProps
|
|
459
|
+
// 如果 label 位置不为顶部 且 用户没有指定 label 宽度,则计算 label 宽度
|
|
460
|
+
if (labelPosition !== 'top' && [undefined, 'auto'].includes(labelWidth)) {
|
|
461
|
+
this.$nextTick(() => {
|
|
462
|
+
// fix: show 的初始值为 true 时 this.$refs.elFormRef 为空
|
|
463
|
+
setTimeout(() => {
|
|
464
|
+
let max = 0
|
|
465
|
+
this.$refs[this.ElFormProps.ref]?.$el
|
|
466
|
+
.querySelectorAll('.el-form-item__label')
|
|
467
|
+
.forEach((item) => {
|
|
468
|
+
// updated 时,避免受之前设置的宽度影响
|
|
469
|
+
const prevWidth = item.style.width
|
|
470
|
+
item.style.width = 'revert'
|
|
471
|
+
const computedWidth = Math.ceil(parseFloat(window.getComputedStyle(item).width))
|
|
472
|
+
if (computedWidth > max) {
|
|
473
|
+
max = computedWidth
|
|
474
|
+
}
|
|
475
|
+
// 不还原会导致文案变成居左的(默认是居右)
|
|
476
|
+
item.style.width = prevWidth
|
|
477
|
+
})
|
|
478
|
+
if (max) {
|
|
479
|
+
this.labelWidth = `${max}px`
|
|
480
|
+
}
|
|
481
|
+
}, 0)
|
|
482
|
+
})
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
onReset() {
|
|
486
|
+
this.$refs[this.ElFormProps.ref].resetFields()
|
|
487
|
+
},
|
|
488
|
+
onClosed() {
|
|
489
|
+
this.$emit(model.event, cloneDeep(this.initialValue))
|
|
490
|
+
this.$refs[this.ElFormProps.ref]?.clearValidate()
|
|
491
|
+
this.confirming = false
|
|
492
|
+
this.denying = false
|
|
493
|
+
this.closing = false
|
|
494
|
+
// el-dialog 内部的 key 是在 onCancel 时改变
|
|
495
|
+
// 改为 closed 时改变,提升性能,在 DOM 较多时感受明显
|
|
496
|
+
if (['', true].includes(this.ElDialogProps.destroyOnClose)) {
|
|
497
|
+
this.key++
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
onCancel() {
|
|
501
|
+
if (this.beforeCloseIsPassed) {
|
|
502
|
+
this.$refs.elDialogRef.beforeClose()
|
|
503
|
+
} else {
|
|
504
|
+
this.$emit('update:show', false)
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
onConfirm() {
|
|
508
|
+
const exec = () => {
|
|
509
|
+
if (typeof this.Confirm === 'function') {
|
|
510
|
+
const result = this.Confirm()
|
|
511
|
+
if (result instanceof Promise) {
|
|
512
|
+
this.confirming = true
|
|
513
|
+
result
|
|
514
|
+
.then((data) => {
|
|
515
|
+
if (data?.show === true) {
|
|
516
|
+
this.confirming = false
|
|
517
|
+
} else {
|
|
518
|
+
this.onCancel()
|
|
519
|
+
}
|
|
520
|
+
})
|
|
521
|
+
.catch((e) => {
|
|
522
|
+
console.error(e)
|
|
523
|
+
this.confirming = false
|
|
524
|
+
})
|
|
525
|
+
} else if (result?.show !== true) {
|
|
526
|
+
this.onCancel()
|
|
527
|
+
}
|
|
528
|
+
} else {
|
|
529
|
+
this.onCancel()
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (this.$refs[this.ElFormProps.ref]) {
|
|
534
|
+
this.$refs[this.ElFormProps.ref]
|
|
535
|
+
.validate()
|
|
536
|
+
.then(() => {
|
|
537
|
+
exec()
|
|
538
|
+
})
|
|
539
|
+
.catch((e) => {
|
|
540
|
+
this.$emit('validateCatch', e)
|
|
541
|
+
this.highlightError(undefined, this.$refs.overlayScrollbar)
|
|
542
|
+
})
|
|
543
|
+
} else {
|
|
544
|
+
exec()
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
onDeny() {
|
|
548
|
+
const exec = () => {
|
|
549
|
+
if (typeof this.Deny === 'function') {
|
|
550
|
+
const result = this.Deny()
|
|
551
|
+
if (result instanceof Promise) {
|
|
552
|
+
this.denying = true
|
|
553
|
+
result
|
|
554
|
+
.then((data) => {
|
|
555
|
+
if (data?.show === true) {
|
|
556
|
+
this.denying = false
|
|
557
|
+
} else {
|
|
558
|
+
this.onCancel()
|
|
559
|
+
}
|
|
560
|
+
})
|
|
561
|
+
.catch((e) => {
|
|
562
|
+
console.error(e)
|
|
563
|
+
this.denying = false
|
|
564
|
+
})
|
|
565
|
+
} else if (result?.show !== true) {
|
|
566
|
+
this.onCancel()
|
|
567
|
+
}
|
|
568
|
+
} else {
|
|
569
|
+
this.onCancel()
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (this.$refs[this.ElFormProps.ref]) {
|
|
574
|
+
this.$refs[this.ElFormProps.ref].validate().then(() => {
|
|
575
|
+
exec()
|
|
576
|
+
this.highlightError(undefined, this.$refs.overlayScrollbar)
|
|
577
|
+
}).catch((e) => {
|
|
578
|
+
this.$emit('validateCatch', e)
|
|
579
|
+
})
|
|
580
|
+
} else {
|
|
581
|
+
exec()
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
highlightError
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
</script>
|
|
588
|
+
|
|
589
|
+
<style lang="scss" scoped>
|
|
590
|
+
// 动画
|
|
591
|
+
/* @keyframes open {
|
|
592
|
+
0% {
|
|
593
|
+
opacity: 0;
|
|
594
|
+
transform: scale3d(0, 0, 1);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
100% {
|
|
598
|
+
opacity: 1;
|
|
599
|
+
transform: scale3d(1, 1, 1);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
@keyframes close {
|
|
604
|
+
0% {
|
|
605
|
+
opacity: 1;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
100% {
|
|
609
|
+
opacity: 0;
|
|
610
|
+
transform: scale3d(0.5, 0.5, 1);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.el-dialog__wrapper {
|
|
615
|
+
transition-duration: 0.3s;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.dialog-fade-enter-active {
|
|
619
|
+
animation: none !important;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
.dialog-fade-leave-active {
|
|
623
|
+
transition-duration: 0.15s !important;
|
|
624
|
+
animation: none !important;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.dialog-fade-enter-active :deep(.el-dialog),
|
|
628
|
+
.dialog-fade-leave-active :deep(.el-dialog) {
|
|
629
|
+
animation-fill-mode: forwards;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.dialog-fade-enter-active :deep(.el-dialog) {
|
|
633
|
+
animation-duration: 0.3s;
|
|
634
|
+
animation-name: open;
|
|
635
|
+
animation-timing-function: cubic-bezier(0.6, 0, 0.4, 1);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.dialog-fade-leave-active :deep(.el-dialog) {
|
|
639
|
+
animation-duration: 0.3s;
|
|
640
|
+
animation-name: close;
|
|
641
|
+
} */
|
|
642
|
+
</style>
|
|
643
|
+
|
|
644
|
+
<style lang="scss" scoped>
|
|
645
|
+
// 兼容 Vue 2.6
|
|
646
|
+
// TODO: Vue 3 中报警告
|
|
647
|
+
::v-deep .el-dialog__wrapper {
|
|
648
|
+
display: flex;
|
|
649
|
+
|
|
650
|
+
.el-dialog {
|
|
651
|
+
min-width: 800px;
|
|
652
|
+
|
|
653
|
+
&:not(.is-fullscreen) {
|
|
654
|
+
margin: auto !important;
|
|
655
|
+
|
|
656
|
+
.el-dialog__body {
|
|
657
|
+
max-height: calc(100vh - 100px);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.el-dialog__header {
|
|
662
|
+
display: flex;
|
|
663
|
+
justify-content: space-between;
|
|
664
|
+
align-items: center;
|
|
665
|
+
|
|
666
|
+
& > .el-dialog__headerbtn {
|
|
667
|
+
display: none;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.el-icon-copy-document,
|
|
671
|
+
.el-icon-full-screen {
|
|
672
|
+
cursor: pointer;
|
|
673
|
+
|
|
674
|
+
&:hover {
|
|
675
|
+
color: #409eff;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
.el-icon-close {
|
|
680
|
+
cursor: pointer;
|
|
681
|
+
font-size: 20px;
|
|
682
|
+
margin-left: 15px;
|
|
683
|
+
|
|
684
|
+
&:hover {
|
|
685
|
+
color: #ff7575;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
.el-dialog__body {
|
|
691
|
+
max-height: calc(100vh - 45px);
|
|
692
|
+
overflow-y: auto;
|
|
693
|
+
padding: 0;
|
|
694
|
+
display: flex;
|
|
695
|
+
flex-direction: column;
|
|
696
|
+
|
|
697
|
+
.el-form-item__content {
|
|
698
|
+
.el-input,
|
|
699
|
+
.el-input-number,
|
|
700
|
+
.el-select,
|
|
701
|
+
.el-time-select,
|
|
702
|
+
.el-time-picker,
|
|
703
|
+
.el-date-picker,
|
|
704
|
+
.el-date-editor,
|
|
705
|
+
.el-cascader {
|
|
706
|
+
width: 100%;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.el-form-item:last-child {
|
|
711
|
+
margin-bottom: 0;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
::-webkit-scrollbar {
|
|
715
|
+
width: 6px; // 纵向滚动条
|
|
716
|
+
height: 6px; // 横向滚动条
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
::-webkit-scrollbar-thumb {
|
|
720
|
+
border-radius: 10px;
|
|
721
|
+
background-color: #c0c0c0;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.el-form.readonly {
|
|
725
|
+
[disabled='disabled'],
|
|
726
|
+
.is-disabled,
|
|
727
|
+
.is-disabled *,
|
|
728
|
+
.disabled {
|
|
729
|
+
color: revert !important;
|
|
730
|
+
cursor: revert !important;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner,
|
|
734
|
+
.el-checkbox__input.is-disabled.is-indeterminate .el-checkbox__inner {
|
|
735
|
+
background-color: #409eff;
|
|
736
|
+
border-color: #409eff;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
|
|
740
|
+
border-color: #fff;
|
|
741
|
+
cursor: revert;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.el-radio__input.is-disabled.is-checked {
|
|
745
|
+
.el-radio__inner {
|
|
746
|
+
border-color: #409eff;
|
|
747
|
+
background: #409eff;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.el-radio__inner::after {
|
|
751
|
+
cursor: revert;
|
|
752
|
+
background-color: #fff;
|
|
753
|
+
border-color: revert;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
.el-slider__runway.disabled > .el-slider__button-wrapper {
|
|
758
|
+
cursor: revert;
|
|
759
|
+
|
|
760
|
+
& > .el-slider__button {
|
|
761
|
+
cursor: revert;
|
|
762
|
+
border-color: #409eff;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.el-color-picker.is-disabled > .el-color-picker__mask {
|
|
767
|
+
display: none;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.el-upload {
|
|
771
|
+
cursor: revert;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
.el-dialog__footer {
|
|
777
|
+
position: absolute;
|
|
778
|
+
bottom: 0;
|
|
779
|
+
right: 0;
|
|
780
|
+
backdrop-filter: blur(1px);
|
|
781
|
+
z-index: 1;
|
|
782
|
+
|
|
783
|
+
.el-button.is-disabled.closing {
|
|
784
|
+
cursor: revert;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
:deep(.el-overlay-dialog) {
|
|
791
|
+
display: flex;
|
|
792
|
+
|
|
793
|
+
.el-dialog {
|
|
794
|
+
min-width: 800px;
|
|
795
|
+
|
|
796
|
+
&:not(.is-fullscreen) {
|
|
797
|
+
margin: auto !important;
|
|
798
|
+
|
|
799
|
+
.el-dialog__body {
|
|
800
|
+
max-height: calc(100vh - 100px);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
.el-dialog__header {
|
|
805
|
+
display: flex;
|
|
806
|
+
justify-content: space-between;
|
|
807
|
+
align-items: center;
|
|
808
|
+
|
|
809
|
+
& > .el-dialog__headerbtn {
|
|
810
|
+
display: none;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.el-icon-copy-document,
|
|
814
|
+
.el-icon-full-screen {
|
|
815
|
+
cursor: pointer;
|
|
816
|
+
|
|
817
|
+
&:hover {
|
|
818
|
+
color: #409eff;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
.el-icon-close {
|
|
823
|
+
cursor: pointer;
|
|
824
|
+
font-size: 20px;
|
|
825
|
+
margin-left: 15px;
|
|
826
|
+
|
|
827
|
+
&:hover {
|
|
828
|
+
color: #ff7575;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
.el-dialog__body {
|
|
834
|
+
max-height: calc(100vh - 45px);
|
|
835
|
+
overflow-y: auto;
|
|
836
|
+
padding: 0;
|
|
837
|
+
display: flex;
|
|
838
|
+
flex-direction: column;
|
|
839
|
+
|
|
840
|
+
.el-form-item__content {
|
|
841
|
+
.el-input,
|
|
842
|
+
.el-input-number,
|
|
843
|
+
.el-select,
|
|
844
|
+
.el-time-select,
|
|
845
|
+
.el-time-picker,
|
|
846
|
+
.el-date-picker,
|
|
847
|
+
.el-date-editor,
|
|
848
|
+
.el-cascader {
|
|
849
|
+
width: 100%;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
.el-form-item:last-child {
|
|
854
|
+
margin-bottom: 0;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
::-webkit-scrollbar {
|
|
858
|
+
width: 6px; // 纵向滚动条
|
|
859
|
+
height: 6px; // 横向滚动条
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
::-webkit-scrollbar-thumb {
|
|
863
|
+
border-radius: 10px;
|
|
864
|
+
background-color: #c0c0c0;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.el-form.readonly {
|
|
868
|
+
[disabled='disabled'],
|
|
869
|
+
.is-disabled,
|
|
870
|
+
.is-disabled *,
|
|
871
|
+
.disabled {
|
|
872
|
+
color: revert !important;
|
|
873
|
+
cursor: revert !important;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner,
|
|
877
|
+
.el-checkbox__input.is-disabled.is-indeterminate .el-checkbox__inner {
|
|
878
|
+
background-color: #409eff;
|
|
879
|
+
border-color: #409eff;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
|
|
883
|
+
border-color: #fff;
|
|
884
|
+
cursor: revert;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
.el-radio__input.is-disabled.is-checked {
|
|
888
|
+
.el-radio__inner {
|
|
889
|
+
border-color: #409eff;
|
|
890
|
+
background: #409eff;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
.el-radio__inner::after {
|
|
894
|
+
cursor: revert;
|
|
895
|
+
background-color: #fff;
|
|
896
|
+
border-color: revert;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
.el-slider__runway.disabled > .el-slider__button-wrapper {
|
|
901
|
+
cursor: revert;
|
|
902
|
+
|
|
903
|
+
& > .el-slider__button {
|
|
904
|
+
cursor: revert;
|
|
905
|
+
border-color: #409eff;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
.el-color-picker.is-disabled > .el-color-picker__mask {
|
|
910
|
+
display: none;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
.el-upload {
|
|
914
|
+
cursor: revert;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.el-dialog__footer {
|
|
920
|
+
position: absolute;
|
|
921
|
+
bottom: 0;
|
|
922
|
+
right: 0;
|
|
923
|
+
backdrop-filter: blur(1px);
|
|
924
|
+
z-index: 1;
|
|
925
|
+
|
|
926
|
+
.el-button.is-disabled.closing {
|
|
927
|
+
cursor: revert;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
</style>
|