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,53 +1,53 @@
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
+ <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,146 +1,146 @@
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
+ <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,94 +1,94 @@
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>
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>
@@ -1,42 +1,42 @@
1
- <template>
2
- <el-radio-group class="ElPlusFormRadio-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue">
3
- <el-radio v-for="option of attrs.options" :key="option.value" :label="option.value">
4
- {{ option.l || option.label }}
5
- </el-radio>
6
- </el-radio-group>
7
- </template>
8
- <script lang="ts">
9
- export default {
10
- name: 'ElPlusFormRadio',
11
- inheritAttrs: false,
12
- typeName: 'radio',
13
- customOptions: {}
14
- }
15
- </script>
16
- <script lang="ts" setup>
17
- import { ref, useAttrs, onBeforeMount } from 'vue'
18
- import { getAttrs, getEvents } from '../mixins'
19
-
20
- const props = defineProps<{
21
- modelValue?: string | number | '' | null
22
- field: string
23
- desc: { [key: string]: any }
24
- formData: { [key: string]: any }
25
- }>()
26
-
27
- const emits = defineEmits(['update:modelValue'])
28
- const currentValue = ref(props.modelValue)
29
- emits('update:modelValue', currentValue)
30
-
31
- const attrs = ref({} as any)
32
- const onEvents = ref(getEvents(props))
33
-
34
- onBeforeMount(async () => {
35
- attrs.value = await getAttrs(props, { ...useAttrs() })
36
- })
37
- </script>
38
- <style lang="scss" scoped>
39
- .ElPlusFormRadio-panel {
40
- display: flex;
41
- }
42
- </style>
1
+ <template>
2
+ <el-radio-group class="ElPlusFormRadio-panel" v-bind="attrs" v-on="onEvents" v-model="currentValue">
3
+ <el-radio v-for="option of attrs.options" :key="option.value" :label="option.value">
4
+ {{ option.l || option.label }}
5
+ </el-radio>
6
+ </el-radio-group>
7
+ </template>
8
+ <script lang="ts">
9
+ export default {
10
+ name: 'ElPlusFormRadio',
11
+ inheritAttrs: false,
12
+ typeName: 'radio',
13
+ customOptions: {}
14
+ }
15
+ </script>
16
+ <script lang="ts" setup>
17
+ import { ref, useAttrs, onBeforeMount } from 'vue'
18
+ import { getAttrs, getEvents } from '../mixins'
19
+
20
+ const props = defineProps<{
21
+ modelValue?: string | number | '' | null
22
+ field: string
23
+ desc: { [key: string]: any }
24
+ formData: { [key: string]: any }
25
+ }>()
26
+
27
+ const emits = defineEmits(['update:modelValue'])
28
+ const currentValue = ref(props.modelValue)
29
+ emits('update:modelValue', currentValue)
30
+
31
+ const attrs = ref({} as any)
32
+ const onEvents = ref(getEvents(props))
33
+
34
+ onBeforeMount(async () => {
35
+ attrs.value = await getAttrs(props, { ...useAttrs() })
36
+ })
37
+ </script>
38
+ <style lang="scss" scoped>
39
+ .ElPlusFormRadio-panel {
40
+ display: flex;
41
+ }
42
+ </style>