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,281 +1,281 @@
1
- <template>
2
- <div class="el-plus-form-link">
3
- <el-select ref="selectRef" style="width: 100%" :class="desc.class" :style="desc.style" v-bind="topAttrs" :teleported="false" :loading="loading" :modelValue="values" @visible-change="handelVisibleChange" @clear="handelClear" v-on="onEvents">
4
- <el-option v-for="option in options" :key="option.value" v-bind="option" />
5
- </el-select>
6
- <!-- 弹框 -->
7
- <el-dialog :width="desc.dialogWidth || '1000px'" :title="desc.title || desc.placeholder || '请选择' + desc.label" draggable :closeOnClickModal="false" showCancel v-model="isShowDialog" append-to-body destroy-on-close>
8
- <div style="width: 100%" class="form-link-dialog">
9
- <div class="panel-left">
10
- <!-- 左侧列表 -->
11
- <ElPlusTable v-if="tableConfig" ref="multipleTableRef" :tableConfig="tableConfig" :type="multiple ? 'selection' : 'index'" :isIndex="false" :rowKey="vkey" @selection="handelTableSelection" />
12
- </div>
13
- <div v-if="multiple" class="panel-right">
14
- <div class="right-title">已选中项:</div>
15
- <el-scrollbar height="480px" class="tag-list">
16
- <el-tag class="tag-item" style="margin-right: 10px; margin-bottom: 10px" v-for="tag in selectData" :key="tag.value" closable @close="() => handelTagRemove(tag)">
17
- {{ tag.label }}
18
- </el-tag>
19
- </el-scrollbar>
20
- <div class="btn-panel">
21
- <el-button @click="cancel">取消</el-button>
22
- <el-button type="primary" @click="submit">确定</el-button>
23
- </div>
24
- </div>
25
- </div>
26
- </el-dialog>
27
- </div>
28
- </template>
29
- <script lang="ts">
30
- export default {
31
- name: 'ElPlusFormLink',
32
- inheritAttrs: false,
33
- typeName: 'link',
34
- customOptions: {}
35
- }
36
- </script>
37
- <script lang="ts" setup>
38
- import { cloneDeep } from 'lodash'
39
- import { ref, reactive, watch, onMounted, computed } from 'vue'
40
- import { getEvents } from '../mixins'
41
-
42
- interface ILinkItem {
43
- label: string
44
- value: string
45
- dataItem: { [key: string]: any }
46
- }
47
-
48
- const props = defineProps<{
49
- modelValue?: []
50
- field: string
51
- loading?: boolean
52
- desc: { [key: string]: any }
53
- formData: { [key: string]: any }
54
- }>()
55
-
56
- const onEvents = ref(getEvents(props))
57
-
58
- const emits = defineEmits(['update:modelValue', 'change', 'input', 'validateThis'])
59
-
60
- const currentValue = ref(props.modelValue as any[])
61
- emits('update:modelValue', currentValue)
62
-
63
- // 顶部的select
64
- const selectRef = ref()
65
- const values = reactive([] as any[])
66
- const options = reactive([] as any[])
67
- const topAttrs = reactive({
68
- multiple: true,
69
- size: props.desc.size,
70
- collapseTags: true,
71
- collapseTagsTooltip: true,
72
- clearable: true,
73
- placeholder: props.desc.placeholder || '请选择' + props.desc.label
74
- })
75
-
76
- // 显示弹框
77
- const isShowDialog = ref(false)
78
- const tableConfig = ref({} as any)
79
- const vkey = computed(() => (props.desc.vkey as string) || 'id')
80
-
81
- const multiple = ref(false)
82
-
83
- const multipleTableRef = ref()
84
-
85
- // 存储的值
86
- const selectData = reactive([] as ILinkItem[])
87
-
88
- /**
89
- * 处理点击事件
90
- * @param val
91
- */
92
- function handelVisibleChange(val: any) {
93
- if (val) {
94
- selectRef.value.blur()
95
- isShowDialog.value = true
96
- }
97
- }
98
-
99
- /**
100
- * 处理清空选项
101
- */
102
- function handelClear() {
103
- selectData.splice(0, selectData.length)
104
- submit()
105
- }
106
-
107
- /**
108
- * 处理列表批量选中
109
- * @param selection
110
- */
111
- function handelTableSelection(selection: any[]) {
112
- // 这里全是新增
113
- selectData.splice(0, selectData.length)
114
- selection.map((row) => {
115
- selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
116
- })
117
- }
118
-
119
- /**
120
- * 处理表格操作列单个选中
121
- * @param btnBack
122
- */
123
- function handelSignleSelect({ row }: IBtnBack) {
124
- selectData.splice(0, selectData.length)
125
- selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
126
- // 直接关闭
127
- submit()
128
- }
129
-
130
- /**
131
- * 处理删除标签
132
- * @param item
133
- */
134
- function handelTagRemove(item: ILinkItem) {
135
- selectData.splice(
136
- selectData.findIndex((i) => i.value === item.value),
137
- 1
138
- )
139
- // 通知table刷新
140
- multipleTableRef.value.changeSelect([{ [vkey.value]: item.value }])
141
- }
142
-
143
- /**
144
- * 取消按钮
145
- */
146
- function cancel() {
147
- isShowDialog.value = false
148
- }
149
-
150
- /**
151
- * 确认按钮
152
- */
153
- function submit() {
154
- options.splice(0, options.length, ...selectData)
155
- const tempIds = [] as string[]
156
- const tempNames = [] as string[]
157
- values.splice(0, values.length)
158
-
159
- // 遍历数据
160
- selectData.map((item) => {
161
- values.push(item.value)
162
- tempIds.push(item.value)
163
- tempNames.push(item.label)
164
- })
165
- // 设置值
166
- currentValue.value = selectData.length > 0 ? [tempIds, tempNames] : []
167
-
168
- // 触发外部change事件
169
- if (onEvents.value.change) {
170
- onEvents.value.change(props.formData, null, currentValue.value)
171
- }
172
-
173
- isShowDialog.value = false
174
- emits('validateThis')
175
- }
176
-
177
- // 表格配置
178
- watch(
179
- () => props.desc.tableConfig,
180
- (val) => {
181
- let tempConfig = {} as ITableConfig
182
- if (val) {
183
- tempConfig = cloneDeep(val)
184
- if (typeof props.desc.multiple === 'function') {
185
- multiple.value = props.desc.multiple(props.formData)
186
- } else {
187
- multiple.value = props.desc.multiple
188
- }
189
- // 如果是多选
190
- if (multiple.value) {
191
- // TODO
192
- } else if (!multiple.value && tempConfig.column[tempConfig.column.length - 1].label !== '操作') {
193
- // 如果是单选
194
- tempConfig.column.push({ label: '操作', width: '120px', fixed: 'right', type: 'btns', btns: [{ label: '选中', on: { click: handelSignleSelect } }] })
195
- }
196
- tempConfig.maxHeight = 400
197
- }
198
- tableConfig.value = tempConfig
199
- },
200
- { deep: true, immediate: true }
201
- )
202
-
203
- onMounted(async () => {})
204
- </script>
205
- <style lang="scss" scoped>
206
- .el-plus-form-link {
207
- width: 100%;
208
-
209
- .items-panel {
210
- :deep(.el-input__inner) {
211
- cursor: pointer;
212
- }
213
- }
214
-
215
- :deep(.el-tag__close) {
216
- display: none !important;
217
- }
218
- }
219
- </style>
220
- <style lang="scss">
221
- .form-link-dialog {
222
- width: 100%;
223
- display: flex;
224
- box-sizing: border-box;
225
-
226
- .panel-left {
227
- // flex: 1;
228
- min-width: 60%;
229
- height: 500px;
230
- display: flex;
231
- flex-direction: column;
232
-
233
- .dept-breadcrumb {
234
- width: 100%;
235
- padding: 0 10px;
236
- margin-bottom: 20px;
237
- cursor: pointer;
238
- }
239
- }
240
-
241
- .panel-right {
242
- min-width: 40%;
243
- max-width: 40%;
244
- margin-left: 20px;
245
- border-left: 1px var(--el-border-color) var(--el-border-style);
246
- padding: 20px;
247
- display: flex;
248
- overflow: hidden;
249
- flex-direction: column;
250
-
251
- .right-title {
252
- width: 100%;
253
- font-size: 14px;
254
- color: #999999;
255
- margin-bottom: 20px;
256
- }
257
-
258
- .tag-list {
259
- width: 100%;
260
- height: 400px;
261
- overflow: hidden;
262
- .tag-item {
263
- .el-tag__content {
264
- max-width: 100px;
265
- text-overflow: ellipsis;
266
- overflow: hidden;
267
- white-space: nowrap;
268
- }
269
- }
270
- }
271
-
272
- .btn-panel {
273
- width: 100%;
274
- min-height: 50px;
275
- padding-top: 10px;
276
- display: flex;
277
- justify-content: center;
278
- }
279
- }
280
- }
281
- </style>
1
+ <template>
2
+ <div class="el-plus-form-link">
3
+ <el-select ref="selectRef" style="width: 100%" :class="desc.class" :style="desc.style" v-bind="topAttrs" :teleported="false" :loading="loading" :modelValue="values" @visible-change="handelVisibleChange" @clear="handelClear" v-on="onEvents">
4
+ <el-option v-for="option in options" :key="option.value" v-bind="option" />
5
+ </el-select>
6
+ <!-- 弹框 -->
7
+ <el-dialog :width="desc.dialogWidth || '1000px'" :title="desc.title || desc.placeholder || '请选择' + desc.label" draggable :closeOnClickModal="false" showCancel v-model="isShowDialog" append-to-body destroy-on-close>
8
+ <div style="width: 100%" class="form-link-dialog">
9
+ <div class="panel-left">
10
+ <!-- 左侧列表 -->
11
+ <ElPlusTable v-if="tableConfig" ref="multipleTableRef" :tableConfig="tableConfig" :type="multiple ? 'selection' : 'index'" :isIndex="false" :rowKey="vkey" @selection="handelTableSelection" />
12
+ </div>
13
+ <div v-if="multiple" class="panel-right">
14
+ <div class="right-title">已选中项:</div>
15
+ <el-scrollbar height="480px" class="tag-list">
16
+ <el-tag class="tag-item" style="margin-right: 10px; margin-bottom: 10px" v-for="tag in selectData" :key="tag.value" closable @close="() => handelTagRemove(tag)">
17
+ {{ tag.label }}
18
+ </el-tag>
19
+ </el-scrollbar>
20
+ <div class="btn-panel">
21
+ <el-button @click="cancel">取消</el-button>
22
+ <el-button type="primary" @click="submit">确定</el-button>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </el-dialog>
27
+ </div>
28
+ </template>
29
+ <script lang="ts">
30
+ export default {
31
+ name: 'ElPlusFormLink',
32
+ inheritAttrs: false,
33
+ typeName: 'link',
34
+ customOptions: {}
35
+ }
36
+ </script>
37
+ <script lang="ts" setup>
38
+ import { cloneDeep } from 'lodash'
39
+ import { ref, reactive, watch, onMounted, computed } from 'vue'
40
+ import { getEvents } from '../mixins'
41
+
42
+ interface ILinkItem {
43
+ label: string
44
+ value: string
45
+ dataItem: { [key: string]: any }
46
+ }
47
+
48
+ const props = defineProps<{
49
+ modelValue?: []
50
+ field: string
51
+ loading?: boolean
52
+ desc: { [key: string]: any }
53
+ formData: { [key: string]: any }
54
+ }>()
55
+
56
+ const onEvents = ref(getEvents(props))
57
+
58
+ const emits = defineEmits(['update:modelValue', 'change', 'input', 'validateThis'])
59
+
60
+ const currentValue = ref(props.modelValue as any[])
61
+ emits('update:modelValue', currentValue)
62
+
63
+ // 顶部的select
64
+ const selectRef = ref()
65
+ const values = reactive([] as any[])
66
+ const options = reactive([] as any[])
67
+ const topAttrs = reactive({
68
+ multiple: true,
69
+ size: props.desc.size,
70
+ collapseTags: true,
71
+ collapseTagsTooltip: true,
72
+ clearable: true,
73
+ placeholder: props.desc.placeholder || '请选择' + props.desc.label
74
+ })
75
+
76
+ // 显示弹框
77
+ const isShowDialog = ref(false)
78
+ const tableConfig = ref({} as any)
79
+ const vkey = computed(() => (props.desc.vkey as string) || 'id')
80
+
81
+ const multiple = ref(false)
82
+
83
+ const multipleTableRef = ref()
84
+
85
+ // 存储的值
86
+ const selectData = reactive([] as ILinkItem[])
87
+
88
+ /**
89
+ * 处理点击事件
90
+ * @param val
91
+ */
92
+ function handelVisibleChange(val: any) {
93
+ if (val) {
94
+ selectRef.value.blur()
95
+ isShowDialog.value = true
96
+ }
97
+ }
98
+
99
+ /**
100
+ * 处理清空选项
101
+ */
102
+ function handelClear() {
103
+ selectData.splice(0, selectData.length)
104
+ submit()
105
+ }
106
+
107
+ /**
108
+ * 处理列表批量选中
109
+ * @param selection
110
+ */
111
+ function handelTableSelection(selection: any[]) {
112
+ // 这里全是新增
113
+ selectData.splice(0, selectData.length)
114
+ selection.map((row) => {
115
+ selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
116
+ })
117
+ }
118
+
119
+ /**
120
+ * 处理表格操作列单个选中
121
+ * @param btnBack
122
+ */
123
+ function handelSignleSelect({ row }: IBtnBack) {
124
+ selectData.splice(0, selectData.length)
125
+ selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
126
+ // 直接关闭
127
+ submit()
128
+ }
129
+
130
+ /**
131
+ * 处理删除标签
132
+ * @param item
133
+ */
134
+ function handelTagRemove(item: ILinkItem) {
135
+ selectData.splice(
136
+ selectData.findIndex((i) => i.value === item.value),
137
+ 1
138
+ )
139
+ // 通知table刷新
140
+ multipleTableRef.value.changeSelect([{ [vkey.value]: item.value }])
141
+ }
142
+
143
+ /**
144
+ * 取消按钮
145
+ */
146
+ function cancel() {
147
+ isShowDialog.value = false
148
+ }
149
+
150
+ /**
151
+ * 确认按钮
152
+ */
153
+ function submit() {
154
+ options.splice(0, options.length, ...selectData)
155
+ const tempIds = [] as string[]
156
+ const tempNames = [] as string[]
157
+ values.splice(0, values.length)
158
+
159
+ // 遍历数据
160
+ selectData.map((item) => {
161
+ values.push(item.value)
162
+ tempIds.push(item.value)
163
+ tempNames.push(item.label)
164
+ })
165
+ // 设置值
166
+ currentValue.value = selectData.length > 0 ? [tempIds, tempNames] : []
167
+
168
+ // 触发外部change事件
169
+ if (onEvents.value.change) {
170
+ onEvents.value.change(props.formData, null, currentValue.value)
171
+ }
172
+
173
+ isShowDialog.value = false
174
+ emits('validateThis')
175
+ }
176
+
177
+ // 表格配置
178
+ watch(
179
+ () => props.desc.tableConfig,
180
+ (val) => {
181
+ let tempConfig = {} as ITableConfig
182
+ if (val) {
183
+ tempConfig = cloneDeep(val)
184
+ if (typeof props.desc.multiple === 'function') {
185
+ multiple.value = props.desc.multiple(props.formData)
186
+ } else {
187
+ multiple.value = props.desc.multiple
188
+ }
189
+ // 如果是多选
190
+ if (multiple.value) {
191
+ // TODO
192
+ } else if (!multiple.value && tempConfig.column[tempConfig.column.length - 1].label !== '操作') {
193
+ // 如果是单选
194
+ tempConfig.column.push({ label: '操作', width: '120px', fixed: 'right', type: 'btns', btns: [{ label: '选中', on: { click: handelSignleSelect } }] })
195
+ }
196
+ tempConfig.maxHeight = 400
197
+ }
198
+ tableConfig.value = tempConfig
199
+ },
200
+ { deep: true, immediate: true }
201
+ )
202
+
203
+ onMounted(async () => {})
204
+ </script>
205
+ <style lang="scss" scoped>
206
+ .el-plus-form-link {
207
+ width: 100%;
208
+
209
+ .items-panel {
210
+ :deep(.el-input__inner) {
211
+ cursor: pointer;
212
+ }
213
+ }
214
+
215
+ :deep(.el-tag__close) {
216
+ display: none !important;
217
+ }
218
+ }
219
+ </style>
220
+ <style lang="scss">
221
+ .form-link-dialog {
222
+ width: 100%;
223
+ display: flex;
224
+ box-sizing: border-box;
225
+
226
+ .panel-left {
227
+ // flex: 1;
228
+ min-width: 60%;
229
+ height: 500px;
230
+ display: flex;
231
+ flex-direction: column;
232
+
233
+ .dept-breadcrumb {
234
+ width: 100%;
235
+ padding: 0 10px;
236
+ margin-bottom: 20px;
237
+ cursor: pointer;
238
+ }
239
+ }
240
+
241
+ .panel-right {
242
+ min-width: 40%;
243
+ max-width: 40%;
244
+ margin-left: 20px;
245
+ border-left: 1px var(--el-border-color) var(--el-border-style);
246
+ padding: 20px;
247
+ display: flex;
248
+ overflow: hidden;
249
+ flex-direction: column;
250
+
251
+ .right-title {
252
+ width: 100%;
253
+ font-size: 14px;
254
+ color: #999999;
255
+ margin-bottom: 20px;
256
+ }
257
+
258
+ .tag-list {
259
+ width: 100%;
260
+ height: 400px;
261
+ overflow: hidden;
262
+ .tag-item {
263
+ .el-tag__content {
264
+ max-width: 100px;
265
+ text-overflow: ellipsis;
266
+ overflow: hidden;
267
+ white-space: nowrap;
268
+ }
269
+ }
270
+ }
271
+
272
+ .btn-panel {
273
+ width: 100%;
274
+ min-height: 50px;
275
+ padding-top: 10px;
276
+ display: flex;
277
+ justify-content: center;
278
+ }
279
+ }
280
+ }
281
+ </style>