el-plus-crud 0.0.38 → 0.0.39

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 (76) hide show
  1. package/.eslintrc.js +78 -78
  2. package/.prettierrc.js +39 -39
  3. package/CHANGELOG.md +7 -5
  4. package/build.js +31 -31
  5. package/dist/el-plus-crud.mjs +2750 -2722
  6. package/dist/el-plus-crud.umd.js +14 -14
  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 +774 -772
  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 -51
  20. package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +44 -42
  21. package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +44 -42
  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 -44
  25. package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +40 -38
  26. package/lib/components/el-plus-form/components/ElPlusFormDatetimerange.vue +3 -1
  27. package/lib/components/el-plus-form/components/ElPlusFormFile.vue +47 -47
  28. package/lib/components/el-plus-form/components/ElPlusFormImage.vue +113 -113
  29. package/lib/components/el-plus-form/components/ElPlusFormInput.vue +3 -1
  30. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +281 -281
  31. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +489 -489
  32. package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +53 -51
  33. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +146 -144
  34. package/lib/components/el-plus-form/components/ElPlusFormPassword.vue +3 -1
  35. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +94 -92
  36. package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +42 -42
  37. package/lib/components/el-plus-form/components/ElPlusFormRate.vue +38 -38
  38. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +161 -161
  39. package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +38 -38
  40. package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +38 -38
  41. package/lib/components/el-plus-form/components/ElPlusFormTag.vue +78 -78
  42. package/lib/components/el-plus-form/components/ElPlusFormText.vue +99 -99
  43. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +49 -47
  44. package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +44 -44
  45. package/lib/components/el-plus-form/components/ElPlusFormTree.vue +76 -76
  46. package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +59 -59
  47. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +368 -368
  48. package/lib/components/el-plus-form/components/components/file-icons/FileIcons.vue +135 -135
  49. package/lib/components/el-plus-form/components/components/file-icons/data/index.ts +27 -27
  50. package/lib/components/el-plus-form/components/components/file-icons/images/doc.svg +12 -12
  51. package/lib/components/el-plus-form/components/components/file-icons/images/file.svg +18 -18
  52. package/lib/components/el-plus-form/components/components/file-icons/images/jpg.svg +13 -13
  53. package/lib/components/el-plus-form/components/components/file-icons/images/pdf.svg +12 -12
  54. package/lib/components/el-plus-form/components/components/file-icons/images/png.svg +12 -12
  55. package/lib/components/el-plus-form/components/components/file-icons/images/ppt.svg +12 -12
  56. package/lib/components/el-plus-form/components/components/file-icons/images/xls.svg +12 -12
  57. package/lib/components/el-plus-form/components/index.ts +17 -17
  58. package/lib/components/el-plus-form/data/file.ts +74 -74
  59. package/lib/components/el-plus-form/mixins/index.ts +113 -113
  60. package/lib/components/el-plus-form/util/index.ts +257 -257
  61. package/lib/components/el-plus-form/util/validate.ts +332 -332
  62. package/lib/components/el-plus-table/components/columnItem.vue +205 -205
  63. package/lib/components/el-plus-table/components/header.vue +240 -240
  64. package/lib/components/el-plus-table/components/statisticInfo.vue +47 -47
  65. package/lib/components/el-plus-table/util/index.ts +147 -147
  66. package/lib/config/index.ts +30 -30
  67. package/lib/index.d.ts +4 -4
  68. package/lib/index.ts +51 -51
  69. package/package.json +1 -1
  70. package/types/axios.d.ts +13 -13
  71. package/types/formList.d.ts +440 -440
  72. package/types/layout.d.ts +57 -57
  73. package/types/mitt.d.ts +38 -38
  74. package/types/pinia.d.ts +149 -149
  75. package/types/views.d.ts +329 -329
  76. package/vite.config.ts +78 -78
@@ -1,51 +1,53 @@
1
- <template>
2
- <el-input :class="desc.class" :style="desc.style" :clearable="attrs.clearable ?? true" type="number" v-bind="attrs" v-on="onEvents" v-model="currentValue">
3
- <template v-for="(item, key, index) of slots" #[key] :key="index">
4
- <slot :name="key" />
5
- </template>
6
- <template v-if="desc.rtext" #append>{{ desc.rtext.text }}</template>
7
- </el-input>
8
- </template>
9
- <script lang="ts">
10
- export default {
11
- name: 'ElPlusFormNbinput',
12
- inheritAttrs: false,
13
- typeName: 'nbinput',
14
- customOptions: {}
15
- }
16
- </script>
17
- <script lang="ts" setup>
18
- import { ref, useAttrs, useSlots, onBeforeMount } from 'vue'
19
- import { getAttrs, getEvents } from '../mixins'
20
-
21
- const props = defineProps<{
22
- modelValue?: string | number | '' | null
23
- field: string
24
- loading?: boolean
25
- desc: { [key: string]: any }
26
- formData: { [key: string]: any }
27
- rowIndex?: number
28
- }>()
29
- const emits = defineEmits(['update:modelValue'])
30
- const currentValue = ref(props.modelValue)
31
- emits('update:modelValue', currentValue)
32
-
33
- const slots = ref(Object.assign({}, useSlots(), props.desc.slots))
34
- const attrs = ref({} as any)
35
- const onEvents = ref(getEvents(props))
36
-
37
- onBeforeMount(async () => {
38
- attrs.value = await getAttrs(props, { ...useAttrs() })
39
- })
40
- </script>
41
- <style lang="scss">
42
- /*input输入框屏蔽浏览器出现上下箭头*/
43
- input::-webkit-outer-spin-button,
44
- input::-webkit-inner-spin-button {
45
- -webkit-appearance: none;
46
- }
47
-
48
- input[type='number'] {
49
- -moz-appearance: textfield;
50
- }
51
- </style>
1
+ <template>
2
+ <el-input v-if="isInit" :class="desc.class" :style="desc.style" :clearable="attrs.clearable ?? true" type="number" v-bind="attrs" v-on="onEvents" v-model="currentValue">
3
+ <template v-for="(item, key, index) of slots" #[key] :key="index">
4
+ <slot :name="key" />
5
+ </template>
6
+ <template v-if="desc.rtext" #append>{{ desc.rtext.text }}</template>
7
+ </el-input>
8
+ </template>
9
+ <script lang="ts">
10
+ export default {
11
+ name: 'ElPlusFormNbinput',
12
+ inheritAttrs: false,
13
+ typeName: 'nbinput',
14
+ customOptions: {}
15
+ }
16
+ </script>
17
+ <script lang="ts" setup>
18
+ import { ref, useAttrs, useSlots, onBeforeMount } from 'vue'
19
+ import { getAttrs, getEvents } from '../mixins'
20
+
21
+ const props = defineProps<{
22
+ modelValue?: string | number | '' | null
23
+ field: string
24
+ loading?: boolean
25
+ desc: { [key: string]: any }
26
+ formData: { [key: string]: any }
27
+ rowIndex?: number
28
+ }>()
29
+ const emits = defineEmits(['update:modelValue'])
30
+ const currentValue = ref(props.modelValue)
31
+ emits('update:modelValue', currentValue)
32
+
33
+ const slots = ref(Object.assign({}, useSlots(), props.desc.slots))
34
+ const attrs = ref({} as any)
35
+ const isInit = ref(false)
36
+ const onEvents = ref(getEvents(props))
37
+
38
+ onBeforeMount(async () => {
39
+ attrs.value = await getAttrs(props, { ...useAttrs() })
40
+ isInit.value = true
41
+ })
42
+ </script>
43
+ <style lang="scss">
44
+ /*input输入框屏蔽浏览器出现上下箭头*/
45
+ input::-webkit-outer-spin-button,
46
+ input::-webkit-inner-spin-button {
47
+ -webkit-appearance: none;
48
+ }
49
+
50
+ input[type='number'] {
51
+ -moz-appearance: textfield;
52
+ }
53
+ </style>
@@ -1,144 +1,146 @@
1
- <template>
2
- <el-input-number class="ElPlusFormNumber-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" @focus="handelFocus" @blur="handelBlur" onkeypress="return( /[\d\.]/.test(String.fromCharCode(event.keyCode)))" />
3
- </template>
4
- <script lang="ts">
5
- export default {
6
- name: 'ElPlusFormNumber',
7
- inheritAttrs: false,
8
- typeName: 'number',
9
- customOptions: {}
10
- }
11
- </script>
12
- <script lang="ts" setup>
13
- import { ref, computed, useAttrs, onBeforeMount, nextTick, inject } from 'vue'
14
- import { getAttrs, getEvents } from '../mixins'
15
- import { ElMessage } from 'element-plus'
16
-
17
- const defaultConf = inject('defaultConf') as ICRUDConfig
18
-
19
- const props = defineProps<{
20
- modelValue?: number | null
21
- field: string
22
- loading?: boolean
23
- desc: { [key: string]: any }
24
- formData: { [key: string]: any }
25
- rowIndex?: number
26
- }>()
27
-
28
- const emits = defineEmits(['update:modelValue', 'validateThis'])
29
- const currentValue = ref(props.modelValue)
30
- emits('update:modelValue', currentValue)
31
- const attrs = ref({} as any)
32
- const onEvents = ref(getEvents(props))
33
-
34
- const isDoChange = ref(false)
35
-
36
- onBeforeMount(async () => {
37
- attrs.value = await getAttrs(props, { ...defaultConf.form?.leng.nbinput, ...useAttrs() })
38
- delete attrs.value.min
39
- delete attrs.value.max
40
- })
41
-
42
- /**
43
- * 获取焦点
44
- */
45
- function handelFocus() {
46
- isDoChange.value = false
47
- }
48
-
49
- /**
50
- * 处理失去焦点
51
- * @param event
52
- */
53
- function handelBlur() {
54
- if (!isDoChange.value) {
55
- if (!currentValue.value) {
56
- nextTick(() => {
57
- currentValue.value = props.desc?.required ? numBindAttr.value.min : 0
58
- if (!props.desc?.required) {
59
- // 查看了源码,这里需要二次赋不一样的值,这里才会真正重新渲染
60
- nextTick(() => {
61
- currentValue.value = null
62
- })
63
- }
64
- })
65
- } else {
66
- handelValChange(currentValue.value, 0)
67
- }
68
- }
69
- nextTick(() => {
70
- emits('validateThis')
71
- })
72
- }
73
-
74
- /**
75
- * 绑定属性
76
- */
77
- const numBindAttr = computed(() => {
78
- let numAttrs = props.desc.attrs || defaultConf.form?.leng.nbinput
79
- if (typeof props.desc.attrs === 'function') {
80
- numAttrs = props.desc.attrs(props.formData)
81
- }
82
- // 这里判断一下,最小和最大值的大小
83
- if (numAttrs.min > numAttrs.max) {
84
- numAttrs.min = numAttrs.max
85
- } else if (numAttrs.max < numAttrs.min) {
86
- numAttrs.max = numAttrs.min
87
- }
88
- return numAttrs
89
- })
90
-
91
- // 判断一下初始值
92
- if (currentValue.value !== undefined && currentValue.value !== null) {
93
- if (currentValue.value < numBindAttr.value.min) {
94
- currentValue.value = numBindAttr.value.min
95
- } else if (currentValue.value > numBindAttr.value.max) {
96
- currentValue.value = numBindAttr.value.max
97
- }
98
- }
99
-
100
- const change = onEvents.value.change
101
- if (change) {
102
- onEvents.value.change = (val: any, oldVal: any) => {
103
- handelValChange(val, oldVal)
104
- }
105
- } else {
106
- onEvents.value.change = handelValChange
107
- }
108
-
109
- /**
110
- * 监听值改变
111
- * @param val
112
- */
113
- function handelValChange(val: any, oldVal: any) {
114
- isDoChange.value = true
115
- if (val !== oldVal) {
116
- if (val < numBindAttr.value.min) {
117
- ElMessage.warning(`${props.desc?.label || ''}最少不能低于${numBindAttr.value.min}`)
118
- nextTick(() => {
119
- currentValue.value = numBindAttr.value.min
120
- })
121
- } else if (val > numBindAttr.value.max) {
122
- ElMessage.warning(`${props.desc?.label || ''}最多不能大于${numBindAttr.value.max}`)
123
- nextTick(() => {
124
- currentValue.value = numBindAttr.value.max
125
- change && change()
126
- })
127
- } else {
128
- change && change()
129
- }
130
- }
131
- }
132
- </script>
133
- <style lang="scss" scoped>
134
- .ElPlusFormNumber-panel {
135
- width: 100% !important;
136
- max-width: 100%;
137
- :deep(.el-input__wrapper) {
138
- // padding-left: 11px !important;
139
- input {
140
- text-align: left !important;
141
- }
142
- }
143
- }
144
- </style>
1
+ <template>
2
+ <el-input-number v-if="isInit" class="ElPlusFormNumber-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue" @focus="handelFocus" @blur="handelBlur" onkeypress="return( /[\d\.]/.test(String.fromCharCode(event.keyCode)))" />
3
+ </template>
4
+ <script lang="ts">
5
+ export default {
6
+ name: 'ElPlusFormNumber',
7
+ inheritAttrs: false,
8
+ typeName: 'number',
9
+ customOptions: {}
10
+ }
11
+ </script>
12
+ <script lang="ts" setup>
13
+ import { ref, computed, useAttrs, onBeforeMount, nextTick, inject } from 'vue'
14
+ import { getAttrs, getEvents } from '../mixins'
15
+ import { ElMessage } from 'element-plus'
16
+
17
+ const defaultConf = inject('defaultConf') as ICRUDConfig
18
+
19
+ const props = defineProps<{
20
+ modelValue?: number | null
21
+ field: string
22
+ loading?: boolean
23
+ desc: { [key: string]: any }
24
+ formData: { [key: string]: any }
25
+ rowIndex?: number
26
+ }>()
27
+
28
+ const emits = defineEmits(['update:modelValue', 'validateThis'])
29
+ const currentValue = ref(props.modelValue)
30
+ emits('update:modelValue', currentValue)
31
+ const attrs = ref({} as any)
32
+ const isInit = ref(false)
33
+ const onEvents = ref(getEvents(props))
34
+
35
+ const isDoChange = ref(false)
36
+
37
+ onBeforeMount(async () => {
38
+ attrs.value = await getAttrs(props, { ...defaultConf.form?.leng.nbinput, ...useAttrs() })
39
+ delete attrs.value.min
40
+ delete attrs.value.max
41
+ isInit.value = true
42
+ })
43
+
44
+ /**
45
+ * 获取焦点
46
+ */
47
+ function handelFocus() {
48
+ isDoChange.value = false
49
+ }
50
+
51
+ /**
52
+ * 处理失去焦点
53
+ * @param event
54
+ */
55
+ function handelBlur() {
56
+ if (!isDoChange.value) {
57
+ if (!currentValue.value) {
58
+ nextTick(() => {
59
+ currentValue.value = props.desc?.required ? numBindAttr.value.min : 0
60
+ if (!props.desc?.required) {
61
+ // 查看了源码,这里需要二次赋不一样的值,这里才会真正重新渲染
62
+ nextTick(() => {
63
+ currentValue.value = null
64
+ })
65
+ }
66
+ })
67
+ } else {
68
+ handelValChange(currentValue.value, 0)
69
+ }
70
+ }
71
+ nextTick(() => {
72
+ emits('validateThis')
73
+ })
74
+ }
75
+
76
+ /**
77
+ * 绑定属性
78
+ */
79
+ const numBindAttr = computed(() => {
80
+ let numAttrs = props.desc.attrs || defaultConf.form?.leng.nbinput
81
+ if (typeof props.desc.attrs === 'function') {
82
+ numAttrs = props.desc.attrs(props.formData)
83
+ }
84
+ // 这里判断一下,最小和最大值的大小
85
+ if (numAttrs.min > numAttrs.max) {
86
+ numAttrs.min = numAttrs.max
87
+ } else if (numAttrs.max < numAttrs.min) {
88
+ numAttrs.max = numAttrs.min
89
+ }
90
+ return numAttrs
91
+ })
92
+
93
+ // 判断一下初始值
94
+ if (currentValue.value !== undefined && currentValue.value !== null) {
95
+ if (currentValue.value < numBindAttr.value.min) {
96
+ currentValue.value = numBindAttr.value.min
97
+ } else if (currentValue.value > numBindAttr.value.max) {
98
+ currentValue.value = numBindAttr.value.max
99
+ }
100
+ }
101
+
102
+ const change = onEvents.value.change
103
+ if (change) {
104
+ onEvents.value.change = (val: any, oldVal: any) => {
105
+ handelValChange(val, oldVal)
106
+ }
107
+ } else {
108
+ onEvents.value.change = handelValChange
109
+ }
110
+
111
+ /**
112
+ * 监听值改变
113
+ * @param val
114
+ */
115
+ function handelValChange(val: any, oldVal: any) {
116
+ isDoChange.value = true
117
+ if (val !== oldVal) {
118
+ if (val < numBindAttr.value.min) {
119
+ ElMessage.warning(`${props.desc?.label || ''}最少不能低于${numBindAttr.value.min}`)
120
+ nextTick(() => {
121
+ currentValue.value = numBindAttr.value.min
122
+ })
123
+ } else if (val > numBindAttr.value.max) {
124
+ ElMessage.warning(`${props.desc?.label || ''}最多不能大于${numBindAttr.value.max}`)
125
+ nextTick(() => {
126
+ currentValue.value = numBindAttr.value.max
127
+ change && change()
128
+ })
129
+ } else {
130
+ change && change()
131
+ }
132
+ }
133
+ }
134
+ </script>
135
+ <style lang="scss" scoped>
136
+ .ElPlusFormNumber-panel {
137
+ width: 100% !important;
138
+ max-width: 100%;
139
+ :deep(.el-input__wrapper) {
140
+ // padding-left: 11px !important;
141
+ input {
142
+ text-align: left !important;
143
+ }
144
+ }
145
+ }
146
+ </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <el-input :class="desc.class" :show-password="true" v-bind="attrs" v-on="onEvents" v-model="currentValue">
2
+ <el-input v-if="isInit" :class="desc.class" :show-password="true" v-bind="attrs" v-on="onEvents" v-model="currentValue">
3
3
  <!-- 组件内部插槽 -->
4
4
  <template v-for="(item, key, index) in slots" #[key]="data" :key="index">
5
5
  <slot :name="key" :data="data" />
@@ -33,9 +33,11 @@ emits('update:modelValue', currentValue)
33
33
 
34
34
  const slots = ref(Object.assign({}, useSlots(), props.desc.slots))
35
35
  const attrs = ref({} as any)
36
+ const isInit = ref(false)
36
37
  const onEvents = ref(getEvents(props))
37
38
 
38
39
  onBeforeMount(async () => {
39
40
  attrs.value = await getAttrs(props, { autocomplete: 'new-password', maxlength: defaultConf.form?.leng?.input || 0, ...useAttrs() })
41
+ isInit.value = true
40
42
  })
41
43
  </script>
@@ -1,92 +1,94 @@
1
- <template>
2
- <el-input :class="desc.class" :style="desc.style" type="textarea" v-bind="attrs" v-model="currentValue" v-on="onEvents"> </el-input>
3
- <div class="el-plus-form-quick-input">
4
- <el-tag v-for="(option, index) in options" :key="index" type="info" @click="changeTip(option.label)">{{ option.label }}</el-tag>
5
- </div>
6
- </template>
7
- <script lang="ts">
8
- export default {
9
- name: 'ElPlusFormQuickinput',
10
- inheritAttrs: false,
11
- typeName: 'quickinput',
12
- customOptions: {}
13
- }
14
- </script>
15
- <script lang="ts" setup>
16
- import { ref, useAttrs, watch, onBeforeMount, inject, reactive } from 'vue'
17
- import { getAttrs, getEvents } from '../mixins'
18
- import { isEqual } from 'lodash'
19
-
20
- const globalData = inject('globalData') as any
21
- const defaultConf = inject('defaultConf') as ICRUDConfig
22
-
23
- const props = defineProps<{
24
- modelValue?: string | null
25
- field: string
26
- loading?: boolean
27
- desc: { [key: string]: any }
28
- formData: { [key: string]: any }
29
- }>()
30
-
31
- const emits = defineEmits(['update:modelValue', 'validateThis'])
32
- const attrs = ref({} as any)
33
- const onEvents = ref(getEvents(props))
34
- const options = reactive([] as any[])
35
- const currentValue = ref(props.modelValue)
36
- emits('update:modelValue', currentValue)
37
-
38
- onBeforeMount(async () => {
39
- attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng.textare, showWordLimit: true, rows: 3, ...useAttrs() })
40
- })
41
-
42
- /**
43
- *
44
- * @param text
45
- * 选中
46
- */
47
- function changeTip(text: any) {
48
- currentValue.value = text
49
- emits('validateThis')
50
- }
51
-
52
- watch(
53
- () => props.modelValue,
54
- (data: string | null | undefined) => {
55
- // 这里要截取一下字符串长度
56
- if (data && data.length > attrs.value.maxlength) {
57
- data = data.substring(0, attrs.value.maxlength)
58
- }
59
- currentValue.value = data
60
- },
61
- { immediate: true }
62
- )
63
- watch(
64
- () => props.desc.options,
65
- async (data) => {
66
- if (typeof data === 'string') {
67
- // // 从全局数据中获取options
68
- options.splice(0, options.length, ...(globalData[data] || []))
69
- } else if (typeof data === 'function') {
70
- options.splice(0, options.length, ...(await data(props.formData)))
71
- } else if (Array.isArray(data)) {
72
- if (data && options && !isEqual(data, options)) {
73
- options.splice(0, options.length, ...data)
74
- }
75
- } else {
76
- options.splice(0, options.length)
77
- }
78
- },
79
- { immediate: true }
80
- )
81
- </script>
82
- <style lang="scss">
83
- .el-plus-form-quick-input {
84
- width: 100%;
85
- display: flex;
86
- align-items: center;
87
- margin-top: 10px;
88
- .el-tag {
89
- margin-right: 10px;
90
- }
91
- }
92
- </style>
1
+ <template>
2
+ <el-input v-if="isInit" :class="desc.class" :style="desc.style" type="textarea" v-bind="attrs" v-model="currentValue" v-on="onEvents"> </el-input>
3
+ <div class="el-plus-form-quick-input">
4
+ <el-tag v-for="(option, index) in options" :key="index" type="info" @click="changeTip(option.label)">{{ option.label }}</el-tag>
5
+ </div>
6
+ </template>
7
+ <script lang="ts">
8
+ export default {
9
+ name: 'ElPlusFormQuickinput',
10
+ inheritAttrs: false,
11
+ typeName: 'quickinput',
12
+ customOptions: {}
13
+ }
14
+ </script>
15
+ <script lang="ts" setup>
16
+ import { ref, useAttrs, watch, onBeforeMount, inject, reactive } from 'vue'
17
+ import { getAttrs, getEvents } from '../mixins'
18
+ import { isEqual } from 'lodash'
19
+
20
+ const globalData = inject('globalData') as any
21
+ const defaultConf = inject('defaultConf') as ICRUDConfig
22
+
23
+ const props = defineProps<{
24
+ modelValue?: string | null
25
+ field: string
26
+ loading?: boolean
27
+ desc: { [key: string]: any }
28
+ formData: { [key: string]: any }
29
+ }>()
30
+
31
+ const emits = defineEmits(['update:modelValue', 'validateThis'])
32
+ const attrs = ref({} as any)
33
+ const isInit = ref(false)
34
+ const onEvents = ref(getEvents(props))
35
+ const options = reactive([] as any[])
36
+ const currentValue = ref(props.modelValue)
37
+ emits('update:modelValue', currentValue)
38
+
39
+ onBeforeMount(async () => {
40
+ attrs.value = await getAttrs(props, { maxlength: defaultConf.form?.leng.textare, showWordLimit: true, rows: 3, ...useAttrs() })
41
+ isInit.value = true
42
+ })
43
+
44
+ /**
45
+ *
46
+ * @param text
47
+ * 选中
48
+ */
49
+ function changeTip(text: any) {
50
+ currentValue.value = text
51
+ emits('validateThis')
52
+ }
53
+
54
+ watch(
55
+ () => props.modelValue,
56
+ (data: string | null | undefined) => {
57
+ // 这里要截取一下字符串长度
58
+ if (data && data.length > attrs.value.maxlength) {
59
+ data = data.substring(0, attrs.value.maxlength)
60
+ }
61
+ currentValue.value = data
62
+ },
63
+ { immediate: true }
64
+ )
65
+ watch(
66
+ () => props.desc.options,
67
+ async (data) => {
68
+ if (typeof data === 'string') {
69
+ // // 从全局数据中获取options
70
+ options.splice(0, options.length, ...(globalData[data] || []))
71
+ } else if (typeof data === 'function') {
72
+ options.splice(0, options.length, ...(await data(props.formData)))
73
+ } else if (Array.isArray(data)) {
74
+ if (data && options && !isEqual(data, options)) {
75
+ options.splice(0, options.length, ...data)
76
+ }
77
+ } else {
78
+ options.splice(0, options.length)
79
+ }
80
+ },
81
+ { immediate: true }
82
+ )
83
+ </script>
84
+ <style lang="scss">
85
+ .el-plus-form-quick-input {
86
+ width: 100%;
87
+ display: flex;
88
+ align-items: center;
89
+ margin-top: 10px;
90
+ .el-tag {
91
+ margin-right: 10px;
92
+ }
93
+ }
94
+ </style>