el-plus-crud 0.0.41 → 0.0.44

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/el-plus-form/ElPlusForm.vue.d.ts +9 -9
  3. package/dist/components/el-plus-form/components/ElPlusFormArea.vue.d.ts +6 -0
  4. package/dist/components/el-plus-form/components/ElPlusFormBtn.vue.d.ts +6 -0
  5. package/dist/components/el-plus-form/components/ElPlusFormBtns.vue.d.ts +6 -0
  6. package/dist/components/el-plus-form/components/ElPlusFormCascader.vue.d.ts +6 -0
  7. package/dist/components/el-plus-form/components/ElPlusFormCascaderPanel.vue.d.ts +6 -0
  8. package/dist/components/el-plus-form/components/ElPlusFormCheckbox.vue.d.ts +6 -0
  9. package/dist/components/el-plus-form/components/ElPlusFormCheckboxButton.vue.d.ts +6 -0
  10. package/dist/components/el-plus-form/components/ElPlusFormColor.vue.d.ts +6 -0
  11. package/dist/components/el-plus-form/components/ElPlusFormDate.vue.d.ts +6 -0
  12. package/dist/components/el-plus-form/components/ElPlusFormDaterange.vue.d.ts +6 -0
  13. package/dist/components/el-plus-form/components/ElPlusFormDatetime.vue.d.ts +6 -0
  14. package/dist/components/el-plus-form/components/ElPlusFormDatetimerange.vue.d.ts +6 -0
  15. package/dist/components/el-plus-form/components/ElPlusFormInput.vue.d.ts +6 -0
  16. package/dist/components/el-plus-form/components/ElPlusFormLink.vue.d.ts +6 -0
  17. package/dist/components/el-plus-form/components/ElPlusFormLkuser.vue.d.ts +6 -0
  18. package/dist/components/el-plus-form/components/ElPlusFormNbinput.vue.d.ts +6 -0
  19. package/dist/components/el-plus-form/components/ElPlusFormNumber.vue.d.ts +6 -0
  20. package/dist/components/el-plus-form/components/ElPlusFormPassword.vue.d.ts +6 -0
  21. package/dist/components/el-plus-form/components/ElPlusFormQuickInput.vue.d.ts +6 -0
  22. package/dist/components/el-plus-form/components/ElPlusFormRadio.vue.d.ts +6 -0
  23. package/dist/components/el-plus-form/components/ElPlusFormRate.vue.d.ts +6 -0
  24. package/dist/components/el-plus-form/components/ElPlusFormSelect.vue.d.ts +6 -0
  25. package/dist/components/el-plus-form/components/ElPlusFormSlider.vue.d.ts +6 -0
  26. package/dist/components/el-plus-form/components/ElPlusFormSwitch.vue.d.ts +6 -0
  27. package/dist/components/el-plus-form/components/ElPlusFormTextarea.vue.d.ts +6 -0
  28. package/dist/components/el-plus-form/components/ElPlusFormTransfer.vue.d.ts +6 -0
  29. package/dist/components/el-plus-form/components/ElPlusFormTree.vue.d.ts +6 -0
  30. package/dist/components/el-plus-form/components/ElPlusFormTreeSelect.vue.d.ts +6 -0
  31. package/dist/components/el-plus-form/components/ElPlusFormUpload.vue.d.ts +6 -0
  32. package/dist/el-plus-crud.mjs +2110 -2052
  33. package/dist/el-plus-crud.umd.js +10 -10
  34. package/dist/style.css +1 -1
  35. package/lib/components/el-plus-form/ElPlusForm.vue +771 -771
  36. package/lib/components/el-plus-form/components/ElPlusFormArea.vue +62 -61
  37. package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +103 -102
  38. package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +134 -133
  39. package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +64 -63
  40. package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +54 -53
  41. package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +45 -44
  42. package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +45 -44
  43. package/lib/components/el-plus-form/components/ElPlusFormColor.vue +39 -38
  44. package/lib/components/el-plus-form/components/ElPlusFormDate.vue +40 -39
  45. package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +47 -46
  46. package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +41 -40
  47. package/lib/components/el-plus-form/components/ElPlusFormDatetimerange.vue +47 -46
  48. package/lib/components/el-plus-form/components/ElPlusFormInput.vue +62 -61
  49. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +282 -281
  50. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +490 -489
  51. package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +54 -53
  52. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +147 -146
  53. package/lib/components/el-plus-form/components/ElPlusFormPassword.vue +44 -43
  54. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +96 -94
  55. package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +43 -42
  56. package/lib/components/el-plus-form/components/ElPlusFormRate.vue +39 -38
  57. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +162 -161
  58. package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +39 -38
  59. package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +39 -38
  60. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +50 -49
  61. package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +45 -44
  62. package/lib/components/el-plus-form/components/ElPlusFormTree.vue +77 -76
  63. package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +60 -59
  64. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +369 -368
  65. package/lib/components/el-plus-table/components/header.vue +240 -240
  66. package/package.json +1 -1
  67. package/types/formList.d.ts +442 -440
@@ -1,61 +1,62 @@
1
- <template>
2
- <el-cascader v-if="isInit" class="ElPlusFormArea-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" :options="areaList" />
3
- </template>
4
- <script lang="ts">
5
- export default {
6
- name: 'ElPlusFormArea',
7
- inheritAttrs: false,
8
- typeName: 'area',
9
- customOptions: {}
10
- }
11
- </script>
12
- <script lang="ts" setup>
13
- import { onMounted, ref, useAttrs, onBeforeMount, inject } from 'vue'
14
- import { getAttrs, getEvents } from '../mixins'
15
-
16
- const globalData = inject('globalData') as any
17
-
18
- const props = defineProps<{
19
- modelValue?: Array<any> | null
20
- field: string
21
- desc: { [key: string]: any }
22
- formData: { [key: string]: any }
23
- }>()
24
-
25
- const emits = defineEmits(['update:modelValue'])
26
- const areaList = ref([] as any)
27
- const attrs = ref({} as any)
28
- const isInit = ref(false)
29
- const onEvents = ref(getEvents(props))
30
- const currentValue = ref(props.modelValue)
31
-
32
- emits('update:modelValue', currentValue)
33
-
34
- /**
35
- * 远程加载数据
36
- * @param node
37
- * @param resolve
38
- */
39
- // async function lazyLoad(node: any, resolve: any) {
40
- // resolve(
41
- // ((await queryAreaByPId(node && node.value ? node.value : '0')) as Array<any>).map((item) => {
42
- // item.leaf = true
43
- // return item
44
- // })
45
- // )
46
- // }
47
-
48
- onBeforeMount(async () => {
49
- attrs.value = await getAttrs(props, { props: { value: 'id', label: 'name', children: 'childs', checkStrictly: !!props.desc.checkStrictly }, clearable: true, filterable: true, ...useAttrs() })
50
- isInit.value = true
51
- })
52
-
53
- onMounted(async () => {
54
- areaList.value = (globalData.areaList || []) as any[]
55
- })
56
- </script>
57
- <style lang="scss" scoped>
58
- .ElPlusFormArea-panel {
59
- display: flex;
60
- }
61
- </style>
1
+ <template>
2
+ <el-cascader v-if="isInit" class="ElPlusFormArea-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" :disabled="disabled" :options="areaList" />
3
+ </template>
4
+ <script lang="ts">
5
+ export default {
6
+ name: 'ElPlusFormArea',
7
+ inheritAttrs: false,
8
+ typeName: 'area',
9
+ customOptions: {}
10
+ }
11
+ </script>
12
+ <script lang="ts" setup>
13
+ import { onMounted, ref, useAttrs, onBeforeMount, inject } from 'vue'
14
+ import { getAttrs, getEvents } from '../mixins'
15
+
16
+ const globalData = inject('globalData') as any
17
+
18
+ const props = defineProps<{
19
+ modelValue?: Array<any> | null
20
+ field: string
21
+ desc: { [key: string]: any }
22
+ formData: { [key: string]: any }
23
+ disabled?: boolean
24
+ }>()
25
+
26
+ const emits = defineEmits(['update:modelValue'])
27
+ const areaList = ref([] as any)
28
+ const attrs = ref({} as any)
29
+ const isInit = ref(false)
30
+ const onEvents = ref(getEvents(props))
31
+ const currentValue = ref(props.modelValue)
32
+
33
+ emits('update:modelValue', currentValue)
34
+
35
+ /**
36
+ * 远程加载数据
37
+ * @param node
38
+ * @param resolve
39
+ */
40
+ // async function lazyLoad(node: any, resolve: any) {
41
+ // resolve(
42
+ // ((await queryAreaByPId(node && node.value ? node.value : '0')) as Array<any>).map((item) => {
43
+ // item.leaf = true
44
+ // return item
45
+ // })
46
+ // )
47
+ // }
48
+
49
+ onBeforeMount(async () => {
50
+ attrs.value = await getAttrs(props, { props: { value: 'id', label: 'name', children: 'childs', checkStrictly: !!props.desc.checkStrictly }, clearable: true, filterable: true, ...useAttrs() })
51
+ isInit.value = true
52
+ })
53
+
54
+ onMounted(async () => {
55
+ areaList.value = (globalData.areaList || []) as any[]
56
+ })
57
+ </script>
58
+ <style lang="scss" scoped>
59
+ .ElPlusFormArea-panel {
60
+ display: flex;
61
+ }
62
+ </style>
@@ -1,102 +1,103 @@
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" :disabled="disabled">
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" :disabled="disabled" :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
+ disabled?: boolean
39
+ }>()
40
+
41
+ const localLoading = ref(props.loading ?? false)
42
+
43
+ const attrs = computed(() => {
44
+ const attrs = Object.assign({}, useAttrs(), props.desc, props.desc?._attrs)
45
+ if (attrs.btnType) {
46
+ attrs.type = attrs.btnType
47
+ }
48
+ if (!attrs.plain) {
49
+ delete attrs.plain
50
+ }
51
+ return attrs
52
+ })
53
+
54
+ const onEvents = computed(() => {
55
+ const events = {} as any
56
+ if (props.desc && props.desc.on) {
57
+ for (const key in props.desc.on) {
58
+ if (key === 'click' && props.desc.mask) {
59
+ events[key] = function () {
60
+ localLoading.value = true
61
+ props.desc.on[key]({
62
+ row: props.formData,
63
+ callBack: () => {
64
+ setTimeout(() => (localLoading.value = false), 500)
65
+ },
66
+ field: props.field,
67
+ rowIndex: props.rowIndex
68
+ } as IBtnBack)
69
+ }
70
+ } else {
71
+ events[key] = function () {
72
+ props.desc.on[key]({ row: cloneDeep(props.formData || {}), field: props.field, rowIndex: props.rowIndex } as IBtnBack)
73
+ }
74
+ }
75
+ }
76
+ }
77
+ return events
78
+ })
79
+
80
+ const btnShowText = computed(() => {
81
+ if (props.desc.btnLabel) {
82
+ if (typeof props.desc.btnLabel === 'function') {
83
+ return props.desc.btnLabel(props.formData)
84
+ }
85
+ return props.desc.btnLabel
86
+ }
87
+ if (props.desc.label) {
88
+ if (typeof props.desc.label === 'function') {
89
+ return props.desc.label(props.formData)
90
+ }
91
+ return props.desc.label
92
+ }
93
+ return ''
94
+ })
95
+
96
+ watch(
97
+ () => props.loading,
98
+ (val) => {
99
+ localLoading.value = val
100
+ }
101
+ )
102
+ </script>
103
+ <style lang="scss" scoped></style>
@@ -1,133 +1,134 @@
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" :disabled="disabled" :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'" :disabled="disabled">
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
+ disabled?: boolean
39
+ }>()
40
+
41
+ const localBtnList = ref([] as any[])
42
+ const limitList = ref([] as any[])
43
+
44
+ const getAlignItems = computed(() => {
45
+ switch (props.desc.align) {
46
+ case 'right':
47
+ return 'flex-end'
48
+ case 'center':
49
+ return 'center'
50
+ case undefined:
51
+ case 'left':
52
+ return 'flex-start'
53
+ default:
54
+ return 'flex-start'
55
+ }
56
+ })
57
+
58
+ const handelEvelt = computed(() => {
59
+ return (item: any) => {
60
+ const events = {} as any
61
+ if (item && item.on) {
62
+ for (const key in item.on) {
63
+ if (key === 'click' && item.confirm) {
64
+ events[key] = function () {
65
+ ElMessageBox.confirm(item.confirm, '提示', {
66
+ type: 'warning'
67
+ }).then(() => {
68
+ item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
69
+ })
70
+ }
71
+ } else {
72
+ events[key] = function () {
73
+ item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
74
+ }
75
+ }
76
+ }
77
+ }
78
+ return events
79
+ }
80
+ })
81
+
82
+ // 初始化
83
+ const initBtnList = () => {
84
+ const tempList = [] as any[]
85
+ if (props.desc.btns.length > 0) {
86
+ props.desc.btns.map((item: any) => {
87
+ if (handelItemVIf(item)) {
88
+ tempList.push(item)
89
+ }
90
+ })
91
+ }
92
+ localBtnList.value = tempList
93
+ const limit = props.desc.limit || 3
94
+ if (localBtnList.value.length > limit) {
95
+ limitList.value = localBtnList.value.splice(limit - 1)
96
+ }
97
+ }
98
+ // 执行一次vif的处理
99
+ const handelItemVIf = (formItem: any): Boolean => {
100
+ if (typeof formItem.vif === 'function') {
101
+ return Boolean(runFnGetData(formItem.vif))
102
+ } else if (typeof formItem.vif === 'boolean') {
103
+ return formItem.vif
104
+ }
105
+ return true
106
+ }
107
+ // 执行函数,获取相关数据
108
+ const runFnGetData = (fn: Function) => {
109
+ return fn(props.formData)
110
+ }
111
+
112
+ watch(
113
+ () => props.desc,
114
+ () => initBtnList()
115
+ )
116
+ watch(
117
+ () => props.formData,
118
+ () => initBtnList()
119
+ )
120
+
121
+ onMounted(() => {
122
+ initBtnList()
123
+ })
124
+ </script>
125
+
126
+ <style lang="scss">
127
+ .el-plus-form-btn-group {
128
+ display: flex;
129
+
130
+ .group-menu-btn {
131
+ margin-left: 10px;
132
+ }
133
+ }
134
+ </style>