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.
Files changed (73) hide show
  1. package/.eslintrc.js +78 -78
  2. package/.prettierrc.js +39 -39
  3. package/CHANGELOG.md +5 -1
  4. package/build.js +31 -31
  5. package/dist/el-plus-crud.mjs +1803 -1801
  6. package/dist/el-plus-crud.umd.js +7 -7
  7. package/dist/style.css +1 -1
  8. package/example/App.vue +67 -67
  9. package/example/main.js +18 -18
  10. package/index.html +13 -13
  11. package/lib/components/el-plus-form/ElPlusForm.vue +771 -774
  12. package/lib/components/el-plus-form/ElPlusFormDialog.vue +90 -90
  13. package/lib/components/el-plus-form/ElPlusFormGroup.vue +116 -116
  14. package/lib/components/el-plus-form/components/ElPlusFormArea.vue +61 -61
  15. package/lib/components/el-plus-form/components/ElPlusFormAutocomplete.vue +49 -49
  16. package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +102 -102
  17. package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +133 -133
  18. package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +63 -63
  19. package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +53 -53
  20. package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +44 -44
  21. package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +44 -44
  22. package/lib/components/el-plus-form/components/ElPlusFormColor.vue +38 -38
  23. package/lib/components/el-plus-form/components/ElPlusFormDate.vue +39 -39
  24. package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +46 -46
  25. package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +40 -40
  26. package/lib/components/el-plus-form/components/ElPlusFormFile.vue +47 -47
  27. package/lib/components/el-plus-form/components/ElPlusFormImage.vue +113 -113
  28. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +281 -281
  29. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +489 -489
  30. package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +53 -53
  31. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +146 -146
  32. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +94 -94
  33. package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +42 -42
  34. package/lib/components/el-plus-form/components/ElPlusFormRate.vue +38 -38
  35. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +161 -161
  36. package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +38 -38
  37. package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +38 -38
  38. package/lib/components/el-plus-form/components/ElPlusFormTag.vue +78 -78
  39. package/lib/components/el-plus-form/components/ElPlusFormText.vue +99 -99
  40. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +49 -49
  41. package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +44 -44
  42. package/lib/components/el-plus-form/components/ElPlusFormTree.vue +76 -76
  43. package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +59 -59
  44. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +368 -368
  45. package/lib/components/el-plus-form/components/components/file-icons/FileIcons.vue +135 -135
  46. package/lib/components/el-plus-form/components/components/file-icons/data/index.ts +27 -27
  47. package/lib/components/el-plus-form/components/components/file-icons/images/doc.svg +12 -12
  48. package/lib/components/el-plus-form/components/components/file-icons/images/file.svg +18 -18
  49. package/lib/components/el-plus-form/components/components/file-icons/images/jpg.svg +13 -13
  50. package/lib/components/el-plus-form/components/components/file-icons/images/pdf.svg +12 -12
  51. package/lib/components/el-plus-form/components/components/file-icons/images/png.svg +12 -12
  52. package/lib/components/el-plus-form/components/components/file-icons/images/ppt.svg +12 -12
  53. package/lib/components/el-plus-form/components/components/file-icons/images/xls.svg +12 -12
  54. package/lib/components/el-plus-form/components/index.ts +17 -17
  55. package/lib/components/el-plus-form/data/file.ts +74 -74
  56. package/lib/components/el-plus-form/mixins/index.ts +115 -113
  57. package/lib/components/el-plus-form/util/index.ts +257 -257
  58. package/lib/components/el-plus-form/util/validate.ts +332 -332
  59. package/lib/components/el-plus-table/components/columnItem.vue +205 -205
  60. package/lib/components/el-plus-table/components/header.vue +240 -240
  61. package/lib/components/el-plus-table/components/statisticInfo.vue +47 -47
  62. package/lib/components/el-plus-table/util/index.ts +147 -147
  63. package/lib/config/index.ts +30 -30
  64. package/lib/index.d.ts +4 -4
  65. package/lib/index.ts +51 -51
  66. package/package.json +1 -1
  67. package/types/axios.d.ts +13 -13
  68. package/types/formList.d.ts +440 -440
  69. package/types/layout.d.ts +57 -57
  70. package/types/mitt.d.ts +38 -38
  71. package/types/pinia.d.ts +149 -149
  72. package/types/views.d.ts +329 -329
  73. package/vite.config.ts +78 -78
@@ -1,90 +1,90 @@
1
- <template>
2
- <el-dialog class="el-plus-form-dialog" v-model="currentShow" :title="props.title" v-bind="dialogAttrs" @closed="handelClosed">
3
- <!-- title 插槽 -->
4
- <template #header>
5
- <slot name="header" />
6
- </template>
7
- <ElPlusForm ref="refElPlusDialogForm" style="padding: 20px" :isDialog="true" v-model="currentValue" v-bind="attrs" :success="dialogSuccess" @cancel="currentShow = false">
8
- <template #top>
9
- <slot name="top" />
10
- </template>
11
- <template #default>
12
- <slot name="default" />
13
- </template>
14
- </ElPlusForm>
15
- </el-dialog>
16
- </template>
17
- <script lang="ts">
18
- export default {
19
- name: 'ElPlusFormDialog',
20
- inheritAttrs: false,
21
- customOptions: {}
22
- }
23
- </script>
24
- <script lang="ts" setup>
25
- import { ref, computed, useAttrs } from 'vue'
26
- import ElPlusForm from './ElPlusForm.vue'
27
- import { ElMessage } from 'element-plus'
28
-
29
- const emits = defineEmits(['update:show', 'update:modelValue'])
30
- const props = withDefaults(defineProps<{ modelValue?: { [key: string]: any } | {}; show?: boolean; title?: string; tableRef?: any; success?: Function; successTip?: string }>(), {
31
- title: '',
32
- modelValue: () => {
33
- return {}
34
- },
35
- show: false,
36
- successTip: '操作成功!'
37
- })
38
-
39
- // 重新定义当前值
40
- const currentValue = computed({
41
- get: () => props.modelValue,
42
- set(val: any) {
43
- emits('update:modelValue', val)
44
- }
45
- })
46
-
47
- // 是否显示弹框
48
- const currentShow = computed({
49
- get() {
50
- return props.show
51
- },
52
- set(val: boolean) {
53
- emits('update:show', val)
54
- }
55
- })
56
- const refElPlusDialogForm = ref(null as any)
57
-
58
- // 合并属性
59
- const { width, top, modal, appendToBody, showClose, draggable, closeOnClickModal, ...attrs } = Object.assign({ width: '700px', draggable: true, top: '15vh', closeOnClickModal: false, showCancel: true }, useAttrs())
60
- // 弹框属性
61
- const dialogAttrs = { width, top, modal, appendToBody, showClose, draggable, closeOnClickModal }
62
-
63
- /**
64
- * 这里重新定义一下成功事件
65
- * @param formBack
66
- */
67
- function dialogSuccess(formBack: IFormBack) {
68
- if (props.success) {
69
- props.success(formBack)
70
- } else {
71
- if (props.tableRef) {
72
- ElMessage.success(props.successTip)
73
- props.tableRef.reload()
74
- close()
75
- setTimeout(() => {
76
- formBack.callback()
77
- }, 200)
78
- }
79
- }
80
- }
81
-
82
- /**
83
- * 处理弹框关闭
84
- */
85
- function handelClosed() {
86
- refElPlusDialogForm.value?.clear()
87
- }
88
-
89
- defineExpose({ open, close })
90
- </script>
1
+ <template>
2
+ <el-dialog class="el-plus-form-dialog" v-model="currentShow" :title="props.title" v-bind="dialogAttrs" @closed="handelClosed">
3
+ <!-- title 插槽 -->
4
+ <template #header>
5
+ <slot name="header" />
6
+ </template>
7
+ <ElPlusForm ref="refElPlusDialogForm" style="padding: 20px" :isDialog="true" v-model="currentValue" v-bind="attrs" :success="dialogSuccess" @cancel="currentShow = false">
8
+ <template #top>
9
+ <slot name="top" />
10
+ </template>
11
+ <template #default>
12
+ <slot name="default" />
13
+ </template>
14
+ </ElPlusForm>
15
+ </el-dialog>
16
+ </template>
17
+ <script lang="ts">
18
+ export default {
19
+ name: 'ElPlusFormDialog',
20
+ inheritAttrs: false,
21
+ customOptions: {}
22
+ }
23
+ </script>
24
+ <script lang="ts" setup>
25
+ import { ref, computed, useAttrs } from 'vue'
26
+ import ElPlusForm from './ElPlusForm.vue'
27
+ import { ElMessage } from 'element-plus'
28
+
29
+ const emits = defineEmits(['update:show', 'update:modelValue'])
30
+ const props = withDefaults(defineProps<{ modelValue?: { [key: string]: any } | {}; show?: boolean; title?: string; tableRef?: any; success?: Function; successTip?: string }>(), {
31
+ title: '',
32
+ modelValue: () => {
33
+ return {}
34
+ },
35
+ show: false,
36
+ successTip: '操作成功!'
37
+ })
38
+
39
+ // 重新定义当前值
40
+ const currentValue = computed({
41
+ get: () => props.modelValue,
42
+ set(val: any) {
43
+ emits('update:modelValue', val)
44
+ }
45
+ })
46
+
47
+ // 是否显示弹框
48
+ const currentShow = computed({
49
+ get() {
50
+ return props.show
51
+ },
52
+ set(val: boolean) {
53
+ emits('update:show', val)
54
+ }
55
+ })
56
+ const refElPlusDialogForm = ref(null as any)
57
+
58
+ // 合并属性
59
+ const { width, top, modal, appendToBody, showClose, draggable, closeOnClickModal, ...attrs } = Object.assign({ width: '700px', draggable: true, top: '15vh', closeOnClickModal: false, showCancel: true }, useAttrs())
60
+ // 弹框属性
61
+ const dialogAttrs = { width, top, modal, appendToBody, showClose, draggable, closeOnClickModal }
62
+
63
+ /**
64
+ * 这里重新定义一下成功事件
65
+ * @param formBack
66
+ */
67
+ function dialogSuccess(formBack: IFormBack) {
68
+ if (props.success) {
69
+ props.success(formBack)
70
+ } else {
71
+ if (props.tableRef) {
72
+ ElMessage.success(props.successTip)
73
+ props.tableRef.reload()
74
+ close()
75
+ setTimeout(() => {
76
+ formBack.callback()
77
+ }, 200)
78
+ }
79
+ }
80
+ }
81
+
82
+ /**
83
+ * 处理弹框关闭
84
+ */
85
+ function handelClosed() {
86
+ refElPlusDialogForm.value?.clear()
87
+ }
88
+
89
+ defineExpose({ open, close })
90
+ </script>
@@ -1,116 +1,116 @@
1
- <template>
2
- <div class="el-plus-form-group">
3
- <template v-for="(group, i) in getGroupFowmLayout" :key="i">
4
- <div class="title-line" v-if="group.title">{{ group.title }}</div>
5
- <ElPlusForm v-model="currentValue" v-bind="group.formProps" :ref="(el) => setComponentRef(el, 'form' + i)" @reset="handleReset">
6
- <template v-if="useSlots()['default' + i]">
7
- <slot :name="'default' + i"> </slot>
8
- </template>
9
- </ElPlusForm>
10
- </template>
11
- </div>
12
- </template>
13
- <script lang="ts">
14
- export default {
15
- name: 'ElPlusFormGroup',
16
- inheritAttrs: false,
17
- customOptions: {}
18
- }
19
- </script>
20
- <script lang="ts" setup>
21
- import { cloneDeep } from 'lodash'
22
- import { computed, ref, useSlots } from 'vue'
23
- import ElPlusForm, { IFormProps } from './ElPlusForm.vue'
24
-
25
- const emits = defineEmits(['update:show', 'update:modelValue', 'before-validate', 'before-request', 'request-success', 'request-error', 'request-end', 'request'])
26
- const props = defineProps<{
27
- modelValue: { [key: string]: any } | {}
28
- // 表单Group项
29
- formGroup: IFormGroupConfig
30
- // 提交状态
31
- isLoading?: boolean
32
- }>()
33
-
34
- const formRefs = ref([] as any[])
35
- const formRefsKeys = [] as string[]
36
-
37
- // 重新定义当前值
38
- const currentValue = computed({
39
- get: () => props.modelValue,
40
- set(val: any) {
41
- emits('update:modelValue', val)
42
- }
43
- })
44
-
45
- /**
46
- * 获取布局,且初始化
47
- * @param groupItem
48
- */
49
- const getGroupFowmLayout = computed(() => {
50
- const formConfigList = [] as Array<{
51
- title?: string
52
- column?: number
53
- formProps?: IFormProps
54
- }>
55
- const tempFormConfig = cloneDeep(props.formGroup) as any
56
- const column = props.formGroup.column || 1
57
- // 移除无用
58
- delete tempFormConfig.group
59
- delete tempFormConfig.column
60
-
61
- // 表单校验
62
- tempFormConfig.beforeValidate = async (formData: any) => {
63
- return await Promise.all(formRefs.value.map((tempRef) => tempRef.validate()))
64
- }
65
- // 遍历
66
- props.formGroup.group.map((groupItem, i) => {
67
- formConfigList.push({
68
- title: groupItem.title,
69
- formProps: Object.assign({ column: groupItem.column || column }, i === props.formGroup.group.length - 1 ? tempFormConfig : { showBtns: false }, groupItem || {}) as IFormProps
70
- })
71
- })
72
- return formConfigList
73
- })
74
-
75
- // 设置子组件的ref-重置form的时候需要用到
76
- function setComponentRef(el: any, key: string) {
77
- if (!el) return
78
- if (formRefsKeys.indexOf(key) < 0) {
79
- formRefsKeys.push(key)
80
- formRefs.value.push(el)
81
- }
82
- }
83
-
84
- //重置
85
- const handleReset = () => {
86
- formRefs.value.map((item, index, arr) => {
87
- index === arr.length - 1 ? '' : item.clearValid()
88
- })
89
- }
90
- </script>
91
- <style lang="scss">
92
- .el-plus-form-group {
93
- // Todo
94
- /* 通用的标题-短线线 */
95
- .title-line {
96
- width: 100%;
97
- height: 22px;
98
- font-size: 16px;
99
- font-weight: 500;
100
- color: #222222;
101
- line-height: 22px;
102
- position: relative;
103
- padding-left: 10px;
104
- margin-bottom: 20px;
105
- &::before {
106
- position: absolute;
107
- content: '';
108
- width: 3px;
109
- height: 16px;
110
- left: 0;
111
- top: 1px;
112
- background-color: var(--el-color-primary);
113
- }
114
- }
115
- }
116
- </style>
1
+ <template>
2
+ <div class="el-plus-form-group">
3
+ <template v-for="(group, i) in getGroupFowmLayout" :key="i">
4
+ <div class="title-line" v-if="group.title">{{ group.title }}</div>
5
+ <ElPlusForm v-model="currentValue" v-bind="group.formProps" :ref="(el) => setComponentRef(el, 'form' + i)" @reset="handleReset">
6
+ <template v-if="useSlots()['default' + i]">
7
+ <slot :name="'default' + i"> </slot>
8
+ </template>
9
+ </ElPlusForm>
10
+ </template>
11
+ </div>
12
+ </template>
13
+ <script lang="ts">
14
+ export default {
15
+ name: 'ElPlusFormGroup',
16
+ inheritAttrs: false,
17
+ customOptions: {}
18
+ }
19
+ </script>
20
+ <script lang="ts" setup>
21
+ import { cloneDeep } from 'lodash'
22
+ import { computed, ref, useSlots } from 'vue'
23
+ import ElPlusForm, { IFormProps } from './ElPlusForm.vue'
24
+
25
+ const emits = defineEmits(['update:show', 'update:modelValue', 'before-validate', 'before-request', 'request-success', 'request-error', 'request-end', 'request'])
26
+ const props = defineProps<{
27
+ modelValue: { [key: string]: any } | {}
28
+ // 表单Group项
29
+ formGroup: IFormGroupConfig
30
+ // 提交状态
31
+ isLoading?: boolean
32
+ }>()
33
+
34
+ const formRefs = ref([] as any[])
35
+ const formRefsKeys = [] as string[]
36
+
37
+ // 重新定义当前值
38
+ const currentValue = computed({
39
+ get: () => props.modelValue,
40
+ set(val: any) {
41
+ emits('update:modelValue', val)
42
+ }
43
+ })
44
+
45
+ /**
46
+ * 获取布局,且初始化
47
+ * @param groupItem
48
+ */
49
+ const getGroupFowmLayout = computed(() => {
50
+ const formConfigList = [] as Array<{
51
+ title?: string
52
+ column?: number
53
+ formProps?: IFormProps
54
+ }>
55
+ const tempFormConfig = cloneDeep(props.formGroup) as any
56
+ const column = props.formGroup.column || 1
57
+ // 移除无用
58
+ delete tempFormConfig.group
59
+ delete tempFormConfig.column
60
+
61
+ // 表单校验
62
+ tempFormConfig.beforeValidate = async (formData: any) => {
63
+ return await Promise.all(formRefs.value.map((tempRef) => tempRef.validate()))
64
+ }
65
+ // 遍历
66
+ props.formGroup.group.map((groupItem, i) => {
67
+ formConfigList.push({
68
+ title: groupItem.title,
69
+ formProps: Object.assign({ column: groupItem.column || column }, i === props.formGroup.group.length - 1 ? tempFormConfig : { showBtns: false }, groupItem || {}) as IFormProps
70
+ })
71
+ })
72
+ return formConfigList
73
+ })
74
+
75
+ // 设置子组件的ref-重置form的时候需要用到
76
+ function setComponentRef(el: any, key: string) {
77
+ if (!el) return
78
+ if (formRefsKeys.indexOf(key) < 0) {
79
+ formRefsKeys.push(key)
80
+ formRefs.value.push(el)
81
+ }
82
+ }
83
+
84
+ //重置
85
+ const handleReset = () => {
86
+ formRefs.value.map((item, index, arr) => {
87
+ index === arr.length - 1 ? '' : item.clearValid()
88
+ })
89
+ }
90
+ </script>
91
+ <style lang="scss">
92
+ .el-plus-form-group {
93
+ // Todo
94
+ /* 通用的标题-短线线 */
95
+ .title-line {
96
+ width: 100%;
97
+ height: 22px;
98
+ font-size: 16px;
99
+ font-weight: 500;
100
+ color: #222222;
101
+ line-height: 22px;
102
+ position: relative;
103
+ padding-left: 10px;
104
+ margin-bottom: 20px;
105
+ &::before {
106
+ position: absolute;
107
+ content: '';
108
+ width: 3px;
109
+ height: 16px;
110
+ left: 0;
111
+ top: 1px;
112
+ background-color: var(--el-color-primary);
113
+ }
114
+ }
115
+ }
116
+ </style>
@@ -1,61 +1,61 @@
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" :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,49 +1,49 @@
1
- <template>
2
- <el-autocomplete class="ElPlusFormAutocomplete-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue">
3
- <!-- 作用域插槽 -->
4
- <template #default="data">
5
- <slot :data="data" />
6
- </template>
7
-
8
- <!-- 非作用域插槽 -->
9
- <template v-for="(item, key, index) in slots" #[key]="data" :key="index">
10
- <slot :name="key" :data="data" />
11
- </template>
12
- </el-autocomplete>
13
- </template>
14
- <script lang="ts">
15
- export default {
16
- name: 'ElPlusFormAutocomplete',
17
- inheritAttrs: false,
18
- typeName: 'autocomplete',
19
- customOptions: {}
20
- }
21
- </script>
22
- <script lang="ts" setup>
23
- import { ref, useAttrs, useSlots, onBeforeMount } from 'vue'
24
- import { getAttrs, getEvents } from '../mixins'
25
-
26
- const props = defineProps<{
27
- modelValue?: string | number | '' | null
28
- field: string
29
- desc: { [key: string]: any }
30
- formData: { [key: string]: any }
31
- }>()
32
-
33
- const emits = defineEmits(['update:modelValue'])
34
- const currentValue = ref(props.modelValue)
35
- emits('update:modelValue', currentValue)
36
-
37
- const slots = ref(Object.assign({}, useSlots(), props.desc.slots))
38
- const attrs = ref({} as any)
39
- const onEvents = ref(getEvents(props))
40
-
41
- onBeforeMount(async () => {
42
- attrs.value = await getAttrs(props, { autocomplete: 'new-password', ...useAttrs() })
43
- })
44
- </script>
45
- <style lang="scss" scoped>
46
- .ElPlusFormAutocomplete-panel {
47
- display: flex;
48
- }
49
- </style>
1
+ <template>
2
+ <el-autocomplete class="ElPlusFormAutocomplete-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue">
3
+ <!-- 作用域插槽 -->
4
+ <template #default="data">
5
+ <slot :data="data" />
6
+ </template>
7
+
8
+ <!-- 非作用域插槽 -->
9
+ <template v-for="(item, key, index) in slots" #[key]="data" :key="index">
10
+ <slot :name="key" :data="data" />
11
+ </template>
12
+ </el-autocomplete>
13
+ </template>
14
+ <script lang="ts">
15
+ export default {
16
+ name: 'ElPlusFormAutocomplete',
17
+ inheritAttrs: false,
18
+ typeName: 'autocomplete',
19
+ customOptions: {}
20
+ }
21
+ </script>
22
+ <script lang="ts" setup>
23
+ import { ref, useAttrs, useSlots, onBeforeMount } from 'vue'
24
+ import { getAttrs, getEvents } from '../mixins'
25
+
26
+ const props = defineProps<{
27
+ modelValue?: string | number | '' | null
28
+ field: string
29
+ desc: { [key: string]: any }
30
+ formData: { [key: string]: any }
31
+ }>()
32
+
33
+ const emits = defineEmits(['update:modelValue'])
34
+ const currentValue = ref(props.modelValue)
35
+ emits('update:modelValue', currentValue)
36
+
37
+ const slots = ref(Object.assign({}, useSlots(), props.desc.slots))
38
+ const attrs = ref({} as any)
39
+ const onEvents = ref(getEvents(props))
40
+
41
+ onBeforeMount(async () => {
42
+ attrs.value = await getAttrs(props, { autocomplete: 'new-password', ...useAttrs() })
43
+ })
44
+ </script>
45
+ <style lang="scss" scoped>
46
+ .ElPlusFormAutocomplete-panel {
47
+ display: flex;
48
+ }
49
+ </style>