el-plus-crud 0.0.49 → 0.0.51

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 (43) hide show
  1. package/CHANGELOG.md +20 -16
  2. package/dist/el-plus-crud.mjs +3801 -3606
  3. package/example/App.vue +1 -1
  4. package/lib/components/el-plus-form/ElPlusForm.vue +775 -771
  5. package/lib/components/el-plus-form/ElPlusFormDialog.vue +2 -4
  6. package/lib/components/el-plus-form/ElPlusFormGroup.vue +21 -1
  7. package/lib/components/el-plus-form/components/ElPlusFormArea.vue +62 -62
  8. package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +103 -103
  9. package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +140 -134
  10. package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +64 -64
  11. package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +71 -54
  12. package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +76 -45
  13. package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +45 -45
  14. package/lib/components/el-plus-form/components/ElPlusFormColor.vue +39 -39
  15. package/lib/components/el-plus-form/components/ElPlusFormDate.vue +40 -40
  16. package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +47 -47
  17. package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +41 -41
  18. package/lib/components/el-plus-form/components/ElPlusFormDatetimerange.vue +47 -47
  19. package/lib/components/el-plus-form/components/ElPlusFormImage.vue +4 -0
  20. package/lib/components/el-plus-form/components/ElPlusFormInput.vue +62 -62
  21. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +282 -282
  22. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +490 -490
  23. package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +54 -54
  24. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +147 -147
  25. package/lib/components/el-plus-form/components/ElPlusFormPassword.vue +44 -44
  26. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +96 -96
  27. package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +68 -68
  28. package/lib/components/el-plus-form/components/ElPlusFormRate.vue +54 -54
  29. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +162 -162
  30. package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +39 -39
  31. package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +69 -39
  32. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +50 -50
  33. package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +45 -45
  34. package/lib/components/el-plus-form/components/ElPlusFormTree.vue +77 -77
  35. package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +60 -60
  36. package/lib/components/el-plus-form/components/ElPlusFormUpbtn.vue +144 -0
  37. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +369 -369
  38. package/lib/components/el-plus-form/mixins/index.ts +2 -2
  39. package/lib/components/el-plus-table/components/columnItem.vue +7 -0
  40. package/lib/components/el-plus-table/components/header.vue +283 -260
  41. package/lib/components-list.ts +2 -0
  42. package/package.json +1 -1
  43. package/types/formList.d.ts +447 -446
@@ -71,9 +71,9 @@ function dialogSuccess(formBack: IFormBack) {
71
71
  if (props.tableRef) {
72
72
  ElMessage.success(props.successTip)
73
73
  props.tableRef.reload()
74
- close()
74
+ currentShow.value = false
75
75
  setTimeout(() => {
76
- formBack.callback()
76
+ formBack.callBack()
77
77
  }, 200)
78
78
  }
79
79
  }
@@ -85,6 +85,4 @@ function dialogSuccess(formBack: IFormBack) {
85
85
  function handelClosed() {
86
86
  refElPlusDialogForm.value?.clear()
87
87
  }
88
-
89
- defineExpose({ open, close })
90
88
  </script>
@@ -84,11 +84,31 @@ function setComponentRef(el: any, key: string) {
84
84
  }
85
85
 
86
86
  //重置
87
- const handleReset = () => {
87
+ function handleReset() {
88
88
  formRefs.value.map((item, index, arr) => {
89
89
  index === arr.length - 1 ? '' : item.clearValid()
90
90
  })
91
91
  }
92
+
93
+ /**
94
+ * 校验
95
+ */
96
+ async function validate() {
97
+ return await Promise.all(formRefs.value.map((tempRef) => tempRef.validate()))
98
+ }
99
+
100
+ /**
101
+ * 获取数据
102
+ */
103
+ function getData() {
104
+ const tempData = {} as any
105
+ formRefs.value.map((tempRef) => {
106
+ Object.assign(tempData, tempRef.getData())
107
+ })
108
+ return tempData
109
+ }
110
+
111
+ defineExpose({ validate, getData })
92
112
  </script>
93
113
  <style lang="scss">
94
114
  .el-plus-form-group {
@@ -1,62 +1,62 @@
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
+ <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,103 +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" :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
+ <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,134 +1,140 @@
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>
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
+ <template v-if="item.elType === 'upload'">
5
+ <ElPlusFormUpbtn type="primary" :field="field" :desc="item || {}" :formData="formData" :plain="(item && item.plain) ?? desc.plain ?? true" :disabled="disabled" :text="desc.text" :rowIndex="rowIndex" />
6
+ </template>
7
+ <template v-else>
8
+ <ElPlusFormBtn type="primary" :field="field" :desc="item || {}" :formData="formData" :plain="(item && item.plain) ?? desc.plain ?? true" :disabled="disabled" :text="desc.text" :rowIndex="rowIndex" />
9
+ </template>
10
+ </template>
11
+ <template v-if="limitList && limitList.length > 0">
12
+ <el-dropdown class="group-menu-btn" :size="desc.size || 'small'" :disabled="disabled">
13
+ <el-button type="primary" :size="desc.size || 'small'" :plain="desc.plain ?? true"> 更多<i class="ele-ArrowDown el-icon--right" /> </el-button>
14
+ <template #dropdown>
15
+ <el-dropdown-menu>
16
+ <el-dropdown-item v-for="(item, i) in limitList" :key="i + (item.label || item.title)" v-on="handelEvelt(item)">
17
+ {{ item.label || item.title }}
18
+ </el-dropdown-item>
19
+ </el-dropdown-menu>
20
+ </template>
21
+ </el-dropdown>
22
+ </template>
23
+ </div>
24
+ </template>
25
+ <script lang="ts">
26
+ export default {
27
+ name: 'ElPlusFormBtns',
28
+ inheritAttrs: false,
29
+ typeName: 'btns',
30
+ customOptions: {}
31
+ }
32
+ </script>
33
+ <script lang="ts" setup>
34
+ import { ref, computed, watch, onMounted } from 'vue'
35
+ import ElPlusFormBtn from './ElPlusFormBtn.vue'
36
+ import ElPlusFormUpbtn from './ElPlusFormUpbtn.vue'
37
+ import { ElMessageBox } from 'element-plus'
38
+
39
+ const props = defineProps<{
40
+ field: string
41
+ rowIndex?: number
42
+ desc: { [key: string]: any }
43
+ formData: { [key: string]: any }
44
+ disabled?: boolean
45
+ }>()
46
+
47
+ const localBtnList = ref([] as any[])
48
+ const limitList = ref([] as any[])
49
+
50
+ const getAlignItems = computed(() => {
51
+ switch (props.desc.align) {
52
+ case 'right':
53
+ return 'flex-end'
54
+ case 'center':
55
+ return 'center'
56
+ case undefined:
57
+ case 'left':
58
+ return 'flex-start'
59
+ default:
60
+ return 'flex-start'
61
+ }
62
+ })
63
+
64
+ const handelEvelt = computed(() => {
65
+ return (item: any) => {
66
+ const events = {} as any
67
+ if (item && item.on) {
68
+ for (const key in item.on) {
69
+ if (key === 'click' && item.confirm) {
70
+ events[key] = function () {
71
+ ElMessageBox.confirm(item.confirm, '提示', {
72
+ type: 'warning'
73
+ }).then(() => {
74
+ item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
75
+ })
76
+ }
77
+ } else {
78
+ events[key] = function () {
79
+ item.on[key]({ row: props.formData, field: props.field, rowIndex: props.rowIndex } as IBtnBack)
80
+ }
81
+ }
82
+ }
83
+ }
84
+ return events
85
+ }
86
+ })
87
+
88
+ // 初始化
89
+ const initBtnList = () => {
90
+ const tempList = [] as any[]
91
+ if (props.desc.btns.length > 0) {
92
+ props.desc.btns.map((item: any) => {
93
+ if (handelItemVIf(item)) {
94
+ tempList.push(item)
95
+ }
96
+ })
97
+ }
98
+ localBtnList.value = tempList
99
+ const limit = props.desc.limit || 3
100
+ if (localBtnList.value.length > limit) {
101
+ limitList.value = localBtnList.value.splice(limit - 1)
102
+ }
103
+ }
104
+ // 执行一次vif的处理
105
+ const handelItemVIf = (formItem: any): Boolean => {
106
+ if (typeof formItem.vif === 'function') {
107
+ return Boolean(runFnGetData(formItem.vif))
108
+ } else if (typeof formItem.vif === 'boolean') {
109
+ return formItem.vif
110
+ }
111
+ return true
112
+ }
113
+ // 执行函数,获取相关数据
114
+ const runFnGetData = (fn: Function) => {
115
+ return fn(props.formData)
116
+ }
117
+
118
+ watch(
119
+ () => props.desc,
120
+ () => initBtnList()
121
+ )
122
+ watch(
123
+ () => props.formData,
124
+ () => initBtnList()
125
+ )
126
+
127
+ onMounted(() => {
128
+ initBtnList()
129
+ })
130
+ </script>
131
+
132
+ <style lang="scss">
133
+ .el-plus-form-btn-group {
134
+ display: flex;
135
+
136
+ .group-menu-btn {
137
+ margin-left: 10px;
138
+ }
139
+ }
140
+ </style>