el-plus-crud 0.0.39 → 0.0.41
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 +78 -78
- package/.prettierrc.js +39 -39
- package/CHANGELOG.md +5 -1
- package/build.js +31 -31
- package/dist/el-plus-crud.mjs +1803 -1801
- package/dist/el-plus-crud.umd.js +7 -7
- package/dist/style.css +1 -1
- package/example/App.vue +67 -67
- package/example/main.js +18 -18
- package/index.html +13 -13
- package/lib/components/el-plus-form/ElPlusForm.vue +771 -774
- package/lib/components/el-plus-form/ElPlusFormDialog.vue +90 -90
- package/lib/components/el-plus-form/ElPlusFormGroup.vue +116 -116
- package/lib/components/el-plus-form/components/ElPlusFormArea.vue +61 -61
- package/lib/components/el-plus-form/components/ElPlusFormAutocomplete.vue +49 -49
- package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +102 -102
- package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +133 -133
- package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +63 -63
- package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +53 -53
- package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +44 -44
- package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +44 -44
- package/lib/components/el-plus-form/components/ElPlusFormColor.vue +38 -38
- package/lib/components/el-plus-form/components/ElPlusFormDate.vue +39 -39
- package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +46 -46
- package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +40 -40
- package/lib/components/el-plus-form/components/ElPlusFormFile.vue +47 -47
- package/lib/components/el-plus-form/components/ElPlusFormImage.vue +113 -113
- package/lib/components/el-plus-form/components/ElPlusFormLink.vue +281 -281
- package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +489 -489
- package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +53 -53
- package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +146 -146
- package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +94 -94
- package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +42 -42
- package/lib/components/el-plus-form/components/ElPlusFormRate.vue +38 -38
- package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +161 -161
- package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +38 -38
- package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +38 -38
- package/lib/components/el-plus-form/components/ElPlusFormTag.vue +78 -78
- package/lib/components/el-plus-form/components/ElPlusFormText.vue +99 -99
- package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +49 -49
- package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +44 -44
- package/lib/components/el-plus-form/components/ElPlusFormTree.vue +76 -76
- package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +59 -59
- package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +368 -368
- package/lib/components/el-plus-form/components/components/file-icons/FileIcons.vue +135 -135
- package/lib/components/el-plus-form/components/components/file-icons/data/index.ts +27 -27
- package/lib/components/el-plus-form/components/components/file-icons/images/doc.svg +12 -12
- package/lib/components/el-plus-form/components/components/file-icons/images/file.svg +18 -18
- package/lib/components/el-plus-form/components/components/file-icons/images/jpg.svg +13 -13
- package/lib/components/el-plus-form/components/components/file-icons/images/pdf.svg +12 -12
- package/lib/components/el-plus-form/components/components/file-icons/images/png.svg +12 -12
- package/lib/components/el-plus-form/components/components/file-icons/images/ppt.svg +12 -12
- package/lib/components/el-plus-form/components/components/file-icons/images/xls.svg +12 -12
- package/lib/components/el-plus-form/components/index.ts +17 -17
- package/lib/components/el-plus-form/data/file.ts +74 -74
- package/lib/components/el-plus-form/mixins/index.ts +115 -113
- package/lib/components/el-plus-form/util/index.ts +257 -257
- package/lib/components/el-plus-form/util/validate.ts +332 -332
- package/lib/components/el-plus-table/components/columnItem.vue +205 -205
- package/lib/components/el-plus-table/components/header.vue +240 -240
- package/lib/components/el-plus-table/components/statisticInfo.vue +47 -47
- package/lib/components/el-plus-table/util/index.ts +147 -147
- package/lib/config/index.ts +30 -30
- package/lib/index.d.ts +4 -4
- package/lib/index.ts +51 -51
- package/package.json +1 -1
- package/types/axios.d.ts +13 -13
- package/types/formList.d.ts +440 -440
- package/types/layout.d.ts +57 -57
- package/types/mitt.d.ts +38 -38
- package/types/pinia.d.ts +149 -149
- package/types/views.d.ts +329 -329
- package/vite.config.ts +78 -78
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<template v-if="props.desc.confirm">
|
|
3
|
-
<el-popconfirm @confirm="onEvents.click" :title="props.desc.confirm">
|
|
4
|
-
<template #reference>
|
|
5
|
-
<el-button :loading="localLoading" :size="props.desc.size || 'small'" v-bind="attrs">
|
|
6
|
-
<template #default v-if="!!desc.label">
|
|
7
|
-
{{ btnShowText }}
|
|
8
|
-
</template>
|
|
9
|
-
</el-button>
|
|
10
|
-
</template>
|
|
11
|
-
</el-popconfirm>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<el-button v-else :loading="localLoading" :size="props.desc.size || 'small'" v-bind="attrs" v-on="onEvents" :style="{ pointerEvents: desc.isTag ? 'none' : 'all' }">
|
|
15
|
-
<template #default v-if="!!props.desc.label">
|
|
16
|
-
{{ btnShowText }}
|
|
17
|
-
</template>
|
|
18
|
-
</el-button>
|
|
19
|
-
</template>
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
export default {
|
|
22
|
-
name: 'ElPlusFormBtn',
|
|
23
|
-
inheritAttrs: false,
|
|
24
|
-
typeName: 'btn',
|
|
25
|
-
customOptions: {}
|
|
26
|
-
}
|
|
27
|
-
</script>
|
|
28
|
-
<script lang="ts" setup>
|
|
29
|
-
import { cloneDeep } from 'lodash'
|
|
30
|
-
import { ref, computed, useAttrs, watch } from 'vue'
|
|
31
|
-
|
|
32
|
-
const props = defineProps<{
|
|
33
|
-
field?: string
|
|
34
|
-
rowIndex?: number
|
|
35
|
-
loading?: boolean
|
|
36
|
-
desc: { [key: string]: any }
|
|
37
|
-
formData?: { [key: string]: any }
|
|
38
|
-
}>()
|
|
39
|
-
|
|
40
|
-
const localLoading = ref(props.loading ?? false)
|
|
41
|
-
|
|
42
|
-
const attrs = computed(() => {
|
|
43
|
-
const attrs = Object.assign({}, useAttrs(), props.desc, props.desc?._attrs)
|
|
44
|
-
if (attrs.btnType) {
|
|
45
|
-
attrs.type = attrs.btnType
|
|
46
|
-
}
|
|
47
|
-
if (!attrs.plain) {
|
|
48
|
-
delete attrs.plain
|
|
49
|
-
}
|
|
50
|
-
return attrs
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const onEvents = computed(() => {
|
|
54
|
-
const events = {} as any
|
|
55
|
-
if (props.desc && props.desc.on) {
|
|
56
|
-
for (const key in props.desc.on) {
|
|
57
|
-
if (key === 'click' && props.desc.mask) {
|
|
58
|
-
events[key] = function () {
|
|
59
|
-
localLoading.value = true
|
|
60
|
-
props.desc.on[key]({
|
|
61
|
-
row: props.formData,
|
|
62
|
-
callBack: () => {
|
|
63
|
-
setTimeout(() => (localLoading.value = false), 500)
|
|
64
|
-
},
|
|
65
|
-
field: props.field,
|
|
66
|
-
rowIndex: props.rowIndex
|
|
67
|
-
} as IBtnBack)
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
events[key] = function () {
|
|
71
|
-
props.desc.on[key]({ row: cloneDeep(props.formData || {}), field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return events
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const btnShowText = computed(() => {
|
|
80
|
-
if (props.desc.btnLabel) {
|
|
81
|
-
if (typeof props.desc.btnLabel === 'function') {
|
|
82
|
-
return props.desc.btnLabel(props.formData)
|
|
83
|
-
}
|
|
84
|
-
return props.desc.btnLabel
|
|
85
|
-
}
|
|
86
|
-
if (props.desc.label) {
|
|
87
|
-
if (typeof props.desc.label === 'function') {
|
|
88
|
-
return props.desc.label(props.formData)
|
|
89
|
-
}
|
|
90
|
-
return props.desc.label
|
|
91
|
-
}
|
|
92
|
-
return ''
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
watch(
|
|
96
|
-
() => props.loading,
|
|
97
|
-
(val) => {
|
|
98
|
-
localLoading.value = val
|
|
99
|
-
}
|
|
100
|
-
)
|
|
101
|
-
</script>
|
|
102
|
-
<style lang="scss" scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<template v-if="props.desc.confirm">
|
|
3
|
+
<el-popconfirm @confirm="onEvents.click" :title="props.desc.confirm">
|
|
4
|
+
<template #reference>
|
|
5
|
+
<el-button :loading="localLoading" :size="props.desc.size || 'small'" v-bind="attrs">
|
|
6
|
+
<template #default v-if="!!desc.label">
|
|
7
|
+
{{ btnShowText }}
|
|
8
|
+
</template>
|
|
9
|
+
</el-button>
|
|
10
|
+
</template>
|
|
11
|
+
</el-popconfirm>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<el-button v-else :loading="localLoading" :size="props.desc.size || 'small'" v-bind="attrs" v-on="onEvents" :style="{ pointerEvents: desc.isTag ? 'none' : 'all' }">
|
|
15
|
+
<template #default v-if="!!props.desc.label">
|
|
16
|
+
{{ btnShowText }}
|
|
17
|
+
</template>
|
|
18
|
+
</el-button>
|
|
19
|
+
</template>
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
export default {
|
|
22
|
+
name: 'ElPlusFormBtn',
|
|
23
|
+
inheritAttrs: false,
|
|
24
|
+
typeName: 'btn',
|
|
25
|
+
customOptions: {}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { cloneDeep } from 'lodash'
|
|
30
|
+
import { ref, computed, useAttrs, watch } from 'vue'
|
|
31
|
+
|
|
32
|
+
const props = defineProps<{
|
|
33
|
+
field?: string
|
|
34
|
+
rowIndex?: number
|
|
35
|
+
loading?: boolean
|
|
36
|
+
desc: { [key: string]: any }
|
|
37
|
+
formData?: { [key: string]: any }
|
|
38
|
+
}>()
|
|
39
|
+
|
|
40
|
+
const localLoading = ref(props.loading ?? false)
|
|
41
|
+
|
|
42
|
+
const attrs = computed(() => {
|
|
43
|
+
const attrs = Object.assign({}, useAttrs(), props.desc, props.desc?._attrs)
|
|
44
|
+
if (attrs.btnType) {
|
|
45
|
+
attrs.type = attrs.btnType
|
|
46
|
+
}
|
|
47
|
+
if (!attrs.plain) {
|
|
48
|
+
delete attrs.plain
|
|
49
|
+
}
|
|
50
|
+
return attrs
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const onEvents = computed(() => {
|
|
54
|
+
const events = {} as any
|
|
55
|
+
if (props.desc && props.desc.on) {
|
|
56
|
+
for (const key in props.desc.on) {
|
|
57
|
+
if (key === 'click' && props.desc.mask) {
|
|
58
|
+
events[key] = function () {
|
|
59
|
+
localLoading.value = true
|
|
60
|
+
props.desc.on[key]({
|
|
61
|
+
row: props.formData,
|
|
62
|
+
callBack: () => {
|
|
63
|
+
setTimeout(() => (localLoading.value = false), 500)
|
|
64
|
+
},
|
|
65
|
+
field: props.field,
|
|
66
|
+
rowIndex: props.rowIndex
|
|
67
|
+
} as IBtnBack)
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
events[key] = function () {
|
|
71
|
+
props.desc.on[key]({ row: cloneDeep(props.formData || {}), field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return events
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const btnShowText = computed(() => {
|
|
80
|
+
if (props.desc.btnLabel) {
|
|
81
|
+
if (typeof props.desc.btnLabel === 'function') {
|
|
82
|
+
return props.desc.btnLabel(props.formData)
|
|
83
|
+
}
|
|
84
|
+
return props.desc.btnLabel
|
|
85
|
+
}
|
|
86
|
+
if (props.desc.label) {
|
|
87
|
+
if (typeof props.desc.label === 'function') {
|
|
88
|
+
return props.desc.label(props.formData)
|
|
89
|
+
}
|
|
90
|
+
return props.desc.label
|
|
91
|
+
}
|
|
92
|
+
return ''
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
watch(
|
|
96
|
+
() => props.loading,
|
|
97
|
+
(val) => {
|
|
98
|
+
localLoading.value = val
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
</script>
|
|
102
|
+
<style lang="scss" scoped></style>
|
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="el-plus-form-btn-group" :style="{ 'justify-content': getAlignItems }">
|
|
3
|
-
<template v-for="(item, i) in localBtnList" :key="i + (item.label || item.title || '')">
|
|
4
|
-
<ElPlusFormBtn type="primary" :field="field" :desc="item || {}" :formData="formData" :plain="(item && item.plain) ?? desc.plain ?? true" :text="desc.text" :rowIndex="rowIndex" />
|
|
5
|
-
</template>
|
|
6
|
-
<template v-if="limitList && limitList.length > 0">
|
|
7
|
-
<el-dropdown class="group-menu-btn" :size="desc.size || 'small'">
|
|
8
|
-
<el-button type="primary" :size="desc.size || 'small'" :plain="desc.plain ?? true"> 更多<i class="ele-ArrowDown el-icon--right" /> </el-button>
|
|
9
|
-
<template #dropdown>
|
|
10
|
-
<el-dropdown-menu>
|
|
11
|
-
<el-dropdown-item v-for="(item, i) in limitList" :key="i + (item.label || item.title)" v-on="handelEvelt(item)">
|
|
12
|
-
{{ item.label || item.title }}
|
|
13
|
-
</el-dropdown-item>
|
|
14
|
-
</el-dropdown-menu>
|
|
15
|
-
</template>
|
|
16
|
-
</el-dropdown>
|
|
17
|
-
</template>
|
|
18
|
-
</div>
|
|
19
|
-
</template>
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
export default {
|
|
22
|
-
name: 'ElPlusFormBtns',
|
|
23
|
-
inheritAttrs: false,
|
|
24
|
-
typeName: 'btns',
|
|
25
|
-
customOptions: {}
|
|
26
|
-
}
|
|
27
|
-
</script>
|
|
28
|
-
<script lang="ts" setup>
|
|
29
|
-
import { ref, computed, watch, onMounted } from 'vue'
|
|
30
|
-
import ElPlusFormBtn from './ElPlusFormBtn.vue'
|
|
31
|
-
import { ElMessageBox } from 'element-plus'
|
|
32
|
-
|
|
33
|
-
const props = defineProps<{
|
|
34
|
-
field: string
|
|
35
|
-
rowIndex?: number
|
|
36
|
-
desc: { [key: string]: any }
|
|
37
|
-
formData: { [key: string]: any }
|
|
38
|
-
}>()
|
|
39
|
-
|
|
40
|
-
const localBtnList = ref([] as any[])
|
|
41
|
-
const limitList = ref([] as any[])
|
|
42
|
-
|
|
43
|
-
const getAlignItems = computed(() => {
|
|
44
|
-
switch (props.desc.align) {
|
|
45
|
-
case 'right':
|
|
46
|
-
return 'flex-end'
|
|
47
|
-
case 'center':
|
|
48
|
-
return 'center'
|
|
49
|
-
case undefined:
|
|
50
|
-
case 'left':
|
|
51
|
-
return 'flex-start'
|
|
52
|
-
default:
|
|
53
|
-
return 'flex-start'
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
const handelEvelt = computed(() => {
|
|
58
|
-
return (item: any) => {
|
|
59
|
-
const events = {} as any
|
|
60
|
-
if (item && item.on) {
|
|
61
|
-
for (const key in item.on) {
|
|
62
|
-
if (key === 'click' && item.confirm) {
|
|
63
|
-
events[key] = function () {
|
|
64
|
-
ElMessageBox.confirm(item.confirm, '提示', {
|
|
65
|
-
type: 'warning'
|
|
66
|
-
}).then(() => {
|
|
67
|
-
item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
events[key] = function () {
|
|
72
|
-
item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return events
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
// 初始化
|
|
82
|
-
const initBtnList = () => {
|
|
83
|
-
const tempList = [] as any[]
|
|
84
|
-
if (props.desc.btns.length > 0) {
|
|
85
|
-
props.desc.btns.map((item: any) => {
|
|
86
|
-
if (handelItemVIf(item)) {
|
|
87
|
-
tempList.push(item)
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
localBtnList.value = tempList
|
|
92
|
-
const limit = props.desc.limit || 3
|
|
93
|
-
if (localBtnList.value.length > limit) {
|
|
94
|
-
limitList.value = localBtnList.value.splice(limit - 1)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// 执行一次vif的处理
|
|
98
|
-
const handelItemVIf = (formItem: any): Boolean => {
|
|
99
|
-
if (typeof formItem.vif === 'function') {
|
|
100
|
-
return Boolean(runFnGetData(formItem.vif))
|
|
101
|
-
} else if (typeof formItem.vif === 'boolean') {
|
|
102
|
-
return formItem.vif
|
|
103
|
-
}
|
|
104
|
-
return true
|
|
105
|
-
}
|
|
106
|
-
// 执行函数,获取相关数据
|
|
107
|
-
const runFnGetData = (fn: Function) => {
|
|
108
|
-
return fn(props.formData)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
watch(
|
|
112
|
-
() => props.desc,
|
|
113
|
-
() => initBtnList()
|
|
114
|
-
)
|
|
115
|
-
watch(
|
|
116
|
-
() => props.formData,
|
|
117
|
-
() => initBtnList()
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
onMounted(() => {
|
|
121
|
-
initBtnList()
|
|
122
|
-
})
|
|
123
|
-
</script>
|
|
124
|
-
|
|
125
|
-
<style lang="scss">
|
|
126
|
-
.el-plus-form-btn-group {
|
|
127
|
-
display: flex;
|
|
128
|
-
|
|
129
|
-
.group-menu-btn {
|
|
130
|
-
margin-left: 10px;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="el-plus-form-btn-group" :style="{ 'justify-content': getAlignItems }">
|
|
3
|
+
<template v-for="(item, i) in localBtnList" :key="i + (item.label || item.title || '')">
|
|
4
|
+
<ElPlusFormBtn type="primary" :field="field" :desc="item || {}" :formData="formData" :plain="(item && item.plain) ?? desc.plain ?? true" :text="desc.text" :rowIndex="rowIndex" />
|
|
5
|
+
</template>
|
|
6
|
+
<template v-if="limitList && limitList.length > 0">
|
|
7
|
+
<el-dropdown class="group-menu-btn" :size="desc.size || 'small'">
|
|
8
|
+
<el-button type="primary" :size="desc.size || 'small'" :plain="desc.plain ?? true"> 更多<i class="ele-ArrowDown el-icon--right" /> </el-button>
|
|
9
|
+
<template #dropdown>
|
|
10
|
+
<el-dropdown-menu>
|
|
11
|
+
<el-dropdown-item v-for="(item, i) in limitList" :key="i + (item.label || item.title)" v-on="handelEvelt(item)">
|
|
12
|
+
{{ item.label || item.title }}
|
|
13
|
+
</el-dropdown-item>
|
|
14
|
+
</el-dropdown-menu>
|
|
15
|
+
</template>
|
|
16
|
+
</el-dropdown>
|
|
17
|
+
</template>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
export default {
|
|
22
|
+
name: 'ElPlusFormBtns',
|
|
23
|
+
inheritAttrs: false,
|
|
24
|
+
typeName: 'btns',
|
|
25
|
+
customOptions: {}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { ref, computed, watch, onMounted } from 'vue'
|
|
30
|
+
import ElPlusFormBtn from './ElPlusFormBtn.vue'
|
|
31
|
+
import { ElMessageBox } from 'element-plus'
|
|
32
|
+
|
|
33
|
+
const props = defineProps<{
|
|
34
|
+
field: string
|
|
35
|
+
rowIndex?: number
|
|
36
|
+
desc: { [key: string]: any }
|
|
37
|
+
formData: { [key: string]: any }
|
|
38
|
+
}>()
|
|
39
|
+
|
|
40
|
+
const localBtnList = ref([] as any[])
|
|
41
|
+
const limitList = ref([] as any[])
|
|
42
|
+
|
|
43
|
+
const getAlignItems = computed(() => {
|
|
44
|
+
switch (props.desc.align) {
|
|
45
|
+
case 'right':
|
|
46
|
+
return 'flex-end'
|
|
47
|
+
case 'center':
|
|
48
|
+
return 'center'
|
|
49
|
+
case undefined:
|
|
50
|
+
case 'left':
|
|
51
|
+
return 'flex-start'
|
|
52
|
+
default:
|
|
53
|
+
return 'flex-start'
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const handelEvelt = computed(() => {
|
|
58
|
+
return (item: any) => {
|
|
59
|
+
const events = {} as any
|
|
60
|
+
if (item && item.on) {
|
|
61
|
+
for (const key in item.on) {
|
|
62
|
+
if (key === 'click' && item.confirm) {
|
|
63
|
+
events[key] = function () {
|
|
64
|
+
ElMessageBox.confirm(item.confirm, '提示', {
|
|
65
|
+
type: 'warning'
|
|
66
|
+
}).then(() => {
|
|
67
|
+
item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
events[key] = function () {
|
|
72
|
+
item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return events
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// 初始化
|
|
82
|
+
const initBtnList = () => {
|
|
83
|
+
const tempList = [] as any[]
|
|
84
|
+
if (props.desc.btns.length > 0) {
|
|
85
|
+
props.desc.btns.map((item: any) => {
|
|
86
|
+
if (handelItemVIf(item)) {
|
|
87
|
+
tempList.push(item)
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
localBtnList.value = tempList
|
|
92
|
+
const limit = props.desc.limit || 3
|
|
93
|
+
if (localBtnList.value.length > limit) {
|
|
94
|
+
limitList.value = localBtnList.value.splice(limit - 1)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// 执行一次vif的处理
|
|
98
|
+
const handelItemVIf = (formItem: any): Boolean => {
|
|
99
|
+
if (typeof formItem.vif === 'function') {
|
|
100
|
+
return Boolean(runFnGetData(formItem.vif))
|
|
101
|
+
} else if (typeof formItem.vif === 'boolean') {
|
|
102
|
+
return formItem.vif
|
|
103
|
+
}
|
|
104
|
+
return true
|
|
105
|
+
}
|
|
106
|
+
// 执行函数,获取相关数据
|
|
107
|
+
const runFnGetData = (fn: Function) => {
|
|
108
|
+
return fn(props.formData)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
watch(
|
|
112
|
+
() => props.desc,
|
|
113
|
+
() => initBtnList()
|
|
114
|
+
)
|
|
115
|
+
watch(
|
|
116
|
+
() => props.formData,
|
|
117
|
+
() => initBtnList()
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
onMounted(() => {
|
|
121
|
+
initBtnList()
|
|
122
|
+
})
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<style lang="scss">
|
|
126
|
+
.el-plus-form-btn-group {
|
|
127
|
+
display: flex;
|
|
128
|
+
|
|
129
|
+
.group-menu-btn {
|
|
130
|
+
margin-left: 10px;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-cascader v-if="isInit" class="ElPlusFormCascader-panel" v-bind="attrs" v-on="onEvents" :options="options" v-model="currentValue" />
|
|
3
|
-
</template>
|
|
4
|
-
<script lang="ts">
|
|
5
|
-
export default {
|
|
6
|
-
name: 'ElPlusFormCascader',
|
|
7
|
-
inheritAttrs: false,
|
|
8
|
-
typeName: 'cascader',
|
|
9
|
-
customOptions: {}
|
|
10
|
-
}
|
|
11
|
-
</script>
|
|
12
|
-
<script lang="ts" setup>
|
|
13
|
-
import { ref, useAttrs, onBeforeMount, inject, reactive, watch } from 'vue'
|
|
14
|
-
import { getAttrs, getEvents } from '../mixins'
|
|
15
|
-
import { isEqual } from 'lodash'
|
|
16
|
-
|
|
17
|
-
const globalData = inject('globalData') as any
|
|
18
|
-
|
|
19
|
-
const props = defineProps<{
|
|
20
|
-
modelValue?: Array<string> | string | null
|
|
21
|
-
field: string
|
|
22
|
-
desc: { [key: string]: any }
|
|
23
|
-
formData: { [key: string]: any }
|
|
24
|
-
}>()
|
|
25
|
-
|
|
26
|
-
const emits = defineEmits(['update:modelValue'])
|
|
27
|
-
const currentValue = ref(props.modelValue)
|
|
28
|
-
emits('update:modelValue', currentValue)
|
|
29
|
-
|
|
30
|
-
const isInit = ref(false)
|
|
31
|
-
const attrs = ref({} as any)
|
|
32
|
-
const onEvents = ref(getEvents(props))
|
|
33
|
-
const options = reactive([] as any[])
|
|
34
|
-
|
|
35
|
-
onBeforeMount(async () => {
|
|
36
|
-
attrs.value = await getAttrs(props, { clearable: true, props: { value: 'value', label: 'label', children: 'children', checkStrictly: !!props.desc.checkStrictly }, ...useAttrs() })
|
|
37
|
-
isInit.value = true
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
//监听options数据
|
|
41
|
-
watch(
|
|
42
|
-
() => props.desc.options,
|
|
43
|
-
async (data) => {
|
|
44
|
-
if (typeof data === 'string') {
|
|
45
|
-
options.splice(0, options.length, ...(globalData[data] || []))
|
|
46
|
-
} else if (typeof data === 'function') {
|
|
47
|
-
options.splice(0, options.length, ...(await data(props.formData)))
|
|
48
|
-
} else if (Array.isArray(data)) {
|
|
49
|
-
if (data && options && !isEqual(data, options)) {
|
|
50
|
-
options.splice(0, options.length, ...data)
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
options.splice(0, options.length)
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{ immediate: true }
|
|
57
|
-
)
|
|
58
|
-
</script>
|
|
59
|
-
<style lang="scss" scoped>
|
|
60
|
-
.ElPlusFormCascader-panel {
|
|
61
|
-
display: flex;
|
|
62
|
-
}
|
|
63
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<el-cascader v-if="isInit" class="ElPlusFormCascader-panel" v-bind="attrs" v-on="onEvents" :options="options" v-model="currentValue" />
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
export default {
|
|
6
|
+
name: 'ElPlusFormCascader',
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
typeName: 'cascader',
|
|
9
|
+
customOptions: {}
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { ref, useAttrs, onBeforeMount, inject, reactive, watch } from 'vue'
|
|
14
|
+
import { getAttrs, getEvents } from '../mixins'
|
|
15
|
+
import { isEqual } from 'lodash'
|
|
16
|
+
|
|
17
|
+
const globalData = inject('globalData') as any
|
|
18
|
+
|
|
19
|
+
const props = defineProps<{
|
|
20
|
+
modelValue?: Array<string> | string | null
|
|
21
|
+
field: string
|
|
22
|
+
desc: { [key: string]: any }
|
|
23
|
+
formData: { [key: string]: any }
|
|
24
|
+
}>()
|
|
25
|
+
|
|
26
|
+
const emits = defineEmits(['update:modelValue'])
|
|
27
|
+
const currentValue = ref(props.modelValue)
|
|
28
|
+
emits('update:modelValue', currentValue)
|
|
29
|
+
|
|
30
|
+
const isInit = ref(false)
|
|
31
|
+
const attrs = ref({} as any)
|
|
32
|
+
const onEvents = ref(getEvents(props))
|
|
33
|
+
const options = reactive([] as any[])
|
|
34
|
+
|
|
35
|
+
onBeforeMount(async () => {
|
|
36
|
+
attrs.value = await getAttrs(props, { clearable: true, props: { value: 'value', label: 'label', children: 'children', checkStrictly: !!props.desc.checkStrictly }, ...useAttrs() })
|
|
37
|
+
isInit.value = true
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
//监听options数据
|
|
41
|
+
watch(
|
|
42
|
+
() => props.desc.options,
|
|
43
|
+
async (data) => {
|
|
44
|
+
if (typeof data === 'string') {
|
|
45
|
+
options.splice(0, options.length, ...(globalData[data] || []))
|
|
46
|
+
} else if (typeof data === 'function') {
|
|
47
|
+
options.splice(0, options.length, ...(await data(props.formData)))
|
|
48
|
+
} else if (Array.isArray(data)) {
|
|
49
|
+
if (data && options && !isEqual(data, options)) {
|
|
50
|
+
options.splice(0, options.length, ...data)
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
options.splice(0, options.length)
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{ immediate: true }
|
|
57
|
+
)
|
|
58
|
+
</script>
|
|
59
|
+
<style lang="scss" scoped>
|
|
60
|
+
.ElPlusFormCascader-panel {
|
|
61
|
+
display: flex;
|
|
62
|
+
}
|
|
63
|
+
</style>
|