el-plus-crud 0.0.49 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +20 -16
  2. package/dist/el-plus-crud.mjs +3801 -3606
  3. package/example/App.vue +1 -1
  4. package/lib/components/el-plus-form/ElPlusForm.vue +775 -771
  5. package/lib/components/el-plus-form/ElPlusFormDialog.vue +2 -4
  6. package/lib/components/el-plus-form/ElPlusFormGroup.vue +21 -1
  7. package/lib/components/el-plus-form/components/ElPlusFormArea.vue +62 -62
  8. package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +103 -103
  9. package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +140 -134
  10. package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +64 -64
  11. package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +71 -54
  12. package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +76 -45
  13. package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +45 -45
  14. package/lib/components/el-plus-form/components/ElPlusFormColor.vue +39 -39
  15. package/lib/components/el-plus-form/components/ElPlusFormDate.vue +40 -40
  16. package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +47 -47
  17. package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +41 -41
  18. package/lib/components/el-plus-form/components/ElPlusFormDatetimerange.vue +47 -47
  19. package/lib/components/el-plus-form/components/ElPlusFormImage.vue +4 -0
  20. package/lib/components/el-plus-form/components/ElPlusFormInput.vue +62 -62
  21. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +282 -282
  22. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +490 -490
  23. package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +54 -54
  24. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +147 -147
  25. package/lib/components/el-plus-form/components/ElPlusFormPassword.vue +44 -44
  26. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +96 -96
  27. package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +68 -68
  28. package/lib/components/el-plus-form/components/ElPlusFormRate.vue +54 -54
  29. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +162 -162
  30. package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +39 -39
  31. package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +69 -39
  32. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +50 -50
  33. package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +45 -45
  34. package/lib/components/el-plus-form/components/ElPlusFormTree.vue +77 -77
  35. package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +60 -60
  36. package/lib/components/el-plus-form/components/ElPlusFormUpbtn.vue +144 -0
  37. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +369 -369
  38. package/lib/components/el-plus-form/mixins/index.ts +2 -2
  39. package/lib/components/el-plus-table/components/columnItem.vue +7 -0
  40. package/lib/components/el-plus-table/components/header.vue +283 -260
  41. package/lib/components-list.ts +2 -0
  42. package/package.json +1 -1
  43. package/types/formList.d.ts +447 -446
@@ -1,282 +1,282 @@
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" :disabled="disabled" :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
- disabled?: boolean
55
- }>()
56
-
57
- const onEvents = ref(getEvents(props))
58
-
59
- const emits = defineEmits(['update:modelValue', 'change', 'input', 'validateThis'])
60
-
61
- const currentValue = ref(props.modelValue as any[])
62
- emits('update:modelValue', currentValue)
63
-
64
- // 顶部的select
65
- const selectRef = ref()
66
- const values = reactive([] as any[])
67
- const options = reactive([] as any[])
68
- const topAttrs = reactive({
69
- multiple: true,
70
- size: props.desc.size,
71
- collapseTags: true,
72
- collapseTagsTooltip: true,
73
- clearable: true,
74
- placeholder: props.desc.placeholder || '请选择' + props.desc.label
75
- })
76
-
77
- // 显示弹框
78
- const isShowDialog = ref(false)
79
- const tableConfig = ref({} as any)
80
- const vkey = computed(() => (props.desc.vkey as string) || 'id')
81
-
82
- const multiple = ref(false)
83
-
84
- const multipleTableRef = ref()
85
-
86
- // 存储的值
87
- const selectData = reactive([] as ILinkItem[])
88
-
89
- /**
90
- * 处理点击事件
91
- * @param val
92
- */
93
- function handelVisibleChange(val: any) {
94
- if (val) {
95
- selectRef.value.blur()
96
- isShowDialog.value = true
97
- }
98
- }
99
-
100
- /**
101
- * 处理清空选项
102
- */
103
- function handelClear() {
104
- selectData.splice(0, selectData.length)
105
- submit()
106
- }
107
-
108
- /**
109
- * 处理列表批量选中
110
- * @param selection
111
- */
112
- function handelTableSelection(selection: any[]) {
113
- // 这里全是新增
114
- selectData.splice(0, selectData.length)
115
- selection.map((row) => {
116
- selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
117
- })
118
- }
119
-
120
- /**
121
- * 处理表格操作列单个选中
122
- * @param btnBack
123
- */
124
- function handelSignleSelect({ row }: IBtnBack) {
125
- selectData.splice(0, selectData.length)
126
- selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
127
- // 直接关闭
128
- submit()
129
- }
130
-
131
- /**
132
- * 处理删除标签
133
- * @param item
134
- */
135
- function handelTagRemove(item: ILinkItem) {
136
- selectData.splice(
137
- selectData.findIndex((i) => i.value === item.value),
138
- 1
139
- )
140
- // 通知table刷新
141
- multipleTableRef.value.changeSelect([{ [vkey.value]: item.value }])
142
- }
143
-
144
- /**
145
- * 取消按钮
146
- */
147
- function cancel() {
148
- isShowDialog.value = false
149
- }
150
-
151
- /**
152
- * 确认按钮
153
- */
154
- function submit() {
155
- options.splice(0, options.length, ...selectData)
156
- const tempIds = [] as string[]
157
- const tempNames = [] as string[]
158
- values.splice(0, values.length)
159
-
160
- // 遍历数据
161
- selectData.map((item) => {
162
- values.push(item.value)
163
- tempIds.push(item.value)
164
- tempNames.push(item.label)
165
- })
166
- // 设置值
167
- currentValue.value = selectData.length > 0 ? [tempIds, tempNames] : []
168
-
169
- // 触发外部change事件
170
- if (onEvents.value.change) {
171
- onEvents.value.change(props.formData, null, currentValue.value)
172
- }
173
-
174
- isShowDialog.value = false
175
- emits('validateThis')
176
- }
177
-
178
- // 表格配置
179
- watch(
180
- () => props.desc.tableConfig,
181
- (val) => {
182
- let tempConfig = {} as ITableConfig
183
- if (val) {
184
- tempConfig = cloneDeep(val)
185
- if (typeof props.desc.multiple === 'function') {
186
- multiple.value = props.desc.multiple(props.formData)
187
- } else {
188
- multiple.value = props.desc.multiple
189
- }
190
- // 如果是多选
191
- if (multiple.value) {
192
- // TODO
193
- } else if (!multiple.value && tempConfig.column[tempConfig.column.length - 1].label !== '操作') {
194
- // 如果是单选
195
- tempConfig.column.push({ label: '操作', width: '120px', fixed: 'right', type: 'btns', btns: [{ label: '选中', on: { click: handelSignleSelect } }] })
196
- }
197
- tempConfig.maxHeight = 400
198
- }
199
- tableConfig.value = tempConfig
200
- },
201
- { deep: true, immediate: true }
202
- )
203
-
204
- onMounted(async () => {})
205
- </script>
206
- <style lang="scss" scoped>
207
- .el-plus-form-link {
208
- width: 100%;
209
-
210
- .items-panel {
211
- :deep(.el-input__inner) {
212
- cursor: pointer;
213
- }
214
- }
215
-
216
- :deep(.el-tag__close) {
217
- display: none !important;
218
- }
219
- }
220
- </style>
221
- <style lang="scss">
222
- .form-link-dialog {
223
- width: 100%;
224
- display: flex;
225
- box-sizing: border-box;
226
-
227
- .panel-left {
228
- // flex: 1;
229
- min-width: 60%;
230
- height: 500px;
231
- display: flex;
232
- flex-direction: column;
233
-
234
- .dept-breadcrumb {
235
- width: 100%;
236
- padding: 0 10px;
237
- margin-bottom: 20px;
238
- cursor: pointer;
239
- }
240
- }
241
-
242
- .panel-right {
243
- min-width: 40%;
244
- max-width: 40%;
245
- margin-left: 20px;
246
- border-left: 1px var(--el-border-color) var(--el-border-style);
247
- padding: 20px;
248
- display: flex;
249
- overflow: hidden;
250
- flex-direction: column;
251
-
252
- .right-title {
253
- width: 100%;
254
- font-size: 14px;
255
- color: #999999;
256
- margin-bottom: 20px;
257
- }
258
-
259
- .tag-list {
260
- width: 100%;
261
- height: 400px;
262
- overflow: hidden;
263
- .tag-item {
264
- .el-tag__content {
265
- max-width: 100px;
266
- text-overflow: ellipsis;
267
- overflow: hidden;
268
- white-space: nowrap;
269
- }
270
- }
271
- }
272
-
273
- .btn-panel {
274
- width: 100%;
275
- min-height: 50px;
276
- padding-top: 10px;
277
- display: flex;
278
- justify-content: center;
279
- }
280
- }
281
- }
282
- </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" :disabled="disabled" :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
+ disabled?: boolean
55
+ }>()
56
+
57
+ const onEvents = ref(getEvents(props))
58
+
59
+ const emits = defineEmits(['update:modelValue', 'change', 'input', 'validateThis'])
60
+
61
+ const currentValue = ref(props.modelValue as any[])
62
+ emits('update:modelValue', currentValue)
63
+
64
+ // 顶部的select
65
+ const selectRef = ref()
66
+ const values = reactive([] as any[])
67
+ const options = reactive([] as any[])
68
+ const topAttrs = reactive({
69
+ multiple: true,
70
+ size: props.desc.size,
71
+ collapseTags: true,
72
+ collapseTagsTooltip: true,
73
+ clearable: true,
74
+ placeholder: props.desc.placeholder || '请选择' + props.desc.label
75
+ })
76
+
77
+ // 显示弹框
78
+ const isShowDialog = ref(false)
79
+ const tableConfig = ref({} as any)
80
+ const vkey = computed(() => (props.desc.vkey as string) || 'id')
81
+
82
+ const multiple = ref(false)
83
+
84
+ const multipleTableRef = ref()
85
+
86
+ // 存储的值
87
+ const selectData = reactive([] as ILinkItem[])
88
+
89
+ /**
90
+ * 处理点击事件
91
+ * @param val
92
+ */
93
+ function handelVisibleChange(val: any) {
94
+ if (val) {
95
+ selectRef.value.blur()
96
+ isShowDialog.value = true
97
+ }
98
+ }
99
+
100
+ /**
101
+ * 处理清空选项
102
+ */
103
+ function handelClear() {
104
+ selectData.splice(0, selectData.length)
105
+ submit()
106
+ }
107
+
108
+ /**
109
+ * 处理列表批量选中
110
+ * @param selection
111
+ */
112
+ function handelTableSelection(selection: any[]) {
113
+ // 这里全是新增
114
+ selectData.splice(0, selectData.length)
115
+ selection.map((row) => {
116
+ selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
117
+ })
118
+ }
119
+
120
+ /**
121
+ * 处理表格操作列单个选中
122
+ * @param btnBack
123
+ */
124
+ function handelSignleSelect({ row }: IBtnBack) {
125
+ selectData.splice(0, selectData.length)
126
+ selectData.push({ label: row[props.desc.lkey || 'name'], value: row[vkey.value], dataItem: row })
127
+ // 直接关闭
128
+ submit()
129
+ }
130
+
131
+ /**
132
+ * 处理删除标签
133
+ * @param item
134
+ */
135
+ function handelTagRemove(item: ILinkItem) {
136
+ selectData.splice(
137
+ selectData.findIndex((i) => i.value === item.value),
138
+ 1
139
+ )
140
+ // 通知table刷新
141
+ multipleTableRef.value.changeSelect([{ [vkey.value]: item.value }])
142
+ }
143
+
144
+ /**
145
+ * 取消按钮
146
+ */
147
+ function cancel() {
148
+ isShowDialog.value = false
149
+ }
150
+
151
+ /**
152
+ * 确认按钮
153
+ */
154
+ function submit() {
155
+ options.splice(0, options.length, ...selectData)
156
+ const tempIds = [] as string[]
157
+ const tempNames = [] as string[]
158
+ values.splice(0, values.length)
159
+
160
+ // 遍历数据
161
+ selectData.map((item) => {
162
+ values.push(item.value)
163
+ tempIds.push(item.value)
164
+ tempNames.push(item.label)
165
+ })
166
+ // 设置值
167
+ currentValue.value = selectData.length > 0 ? [tempIds, tempNames] : []
168
+
169
+ // 触发外部change事件
170
+ if (onEvents.value.change) {
171
+ onEvents.value.change(props.formData, null, currentValue.value)
172
+ }
173
+
174
+ isShowDialog.value = false
175
+ emits('validateThis')
176
+ }
177
+
178
+ // 表格配置
179
+ watch(
180
+ () => props.desc.tableConfig,
181
+ (val) => {
182
+ let tempConfig = {} as ITableConfig
183
+ if (val) {
184
+ tempConfig = cloneDeep(val)
185
+ if (typeof props.desc.multiple === 'function') {
186
+ multiple.value = props.desc.multiple(props.formData)
187
+ } else {
188
+ multiple.value = props.desc.multiple
189
+ }
190
+ // 如果是多选
191
+ if (multiple.value) {
192
+ // TODO
193
+ } else if (!multiple.value && tempConfig.column[tempConfig.column.length - 1].label !== '操作') {
194
+ // 如果是单选
195
+ tempConfig.column.push({ label: '操作', width: '120px', fixed: 'right', type: 'btns', btns: [{ label: '选中', on: { click: handelSignleSelect } }] })
196
+ }
197
+ tempConfig.maxHeight = 400
198
+ }
199
+ tableConfig.value = tempConfig
200
+ },
201
+ { deep: true, immediate: true }
202
+ )
203
+
204
+ onMounted(async () => {})
205
+ </script>
206
+ <style lang="scss" scoped>
207
+ .el-plus-form-link {
208
+ width: 100%;
209
+
210
+ .items-panel {
211
+ :deep(.el-input__inner) {
212
+ cursor: pointer;
213
+ }
214
+ }
215
+
216
+ :deep(.el-tag__close) {
217
+ display: none !important;
218
+ }
219
+ }
220
+ </style>
221
+ <style lang="scss">
222
+ .form-link-dialog {
223
+ width: 100%;
224
+ display: flex;
225
+ box-sizing: border-box;
226
+
227
+ .panel-left {
228
+ // flex: 1;
229
+ min-width: 60%;
230
+ height: 500px;
231
+ display: flex;
232
+ flex-direction: column;
233
+
234
+ .dept-breadcrumb {
235
+ width: 100%;
236
+ padding: 0 10px;
237
+ margin-bottom: 20px;
238
+ cursor: pointer;
239
+ }
240
+ }
241
+
242
+ .panel-right {
243
+ min-width: 40%;
244
+ max-width: 40%;
245
+ margin-left: 20px;
246
+ border-left: 1px var(--el-border-color) var(--el-border-style);
247
+ padding: 20px;
248
+ display: flex;
249
+ overflow: hidden;
250
+ flex-direction: column;
251
+
252
+ .right-title {
253
+ width: 100%;
254
+ font-size: 14px;
255
+ color: #999999;
256
+ margin-bottom: 20px;
257
+ }
258
+
259
+ .tag-list {
260
+ width: 100%;
261
+ height: 400px;
262
+ overflow: hidden;
263
+ .tag-item {
264
+ .el-tag__content {
265
+ max-width: 100px;
266
+ text-overflow: ellipsis;
267
+ overflow: hidden;
268
+ white-space: nowrap;
269
+ }
270
+ }
271
+ }
272
+
273
+ .btn-panel {
274
+ width: 100%;
275
+ min-height: 50px;
276
+ padding-top: 10px;
277
+ display: flex;
278
+ justify-content: center;
279
+ }
280
+ }
281
+ }
282
+ </style>