el-plus-crud 0.0.74 → 0.0.76

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