@lx-frontend/wrap-element-ui 1.0.28 → 2.0.0-beta.2

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 (33) hide show
  1. package/package.json +21 -12
  2. package/src/components/AddMembers/index.vue +100 -89
  3. package/src/components/AuditSteps/index.vue +107 -74
  4. package/src/components/DemoComponent/index.vue +8 -5
  5. package/src/components/EditableTable/bizHooks/useCellHover.ts +47 -2
  6. package/src/components/EditableTable/bizHooks/useColumnHeaderOperation.ts +5 -4
  7. package/src/components/EditableTable/bizHooks/useDefaultOperation.ts +12 -4
  8. package/src/components/EditableTable/bizHooks/useDragSort.ts +36 -3
  9. package/src/components/EditableTable/bizHooks/useRowBgColor.ts +6 -2
  10. package/src/components/EditableTable/bizHooks/useViewSetting.ts +2 -1
  11. package/src/components/EditableTable/features/bizColorSelect.vue +4 -3
  12. package/src/components/EditableTable/features/bizEditCell.vue +6 -6
  13. package/src/components/EditableTable/features/bizTableHeaderPopover/BizCheckboxFilter.vue +3 -3
  14. package/src/components/EditableTable/features/bizTableHeaderPopover/BizColorRadioFilter.vue +3 -4
  15. package/src/components/EditableTable/features/bizTableHeaderPopover/BizDoubleDatePickerFilter.vue +8 -8
  16. package/src/components/EditableTable/features/bizTableHeaderPopover/BizInputFilter.vue +2 -2
  17. package/src/components/EditableTable/features/bizTableHeaderPopover/BizMonthDayPicker.vue +2 -2
  18. package/src/components/EditableTable/features/bizTableHeaderPopover/BizRadioFilter.vue +3 -4
  19. package/src/components/EditableTable/features/bizTableHeaderPopover/index.vue +28 -19
  20. package/src/components/EditableTable/features/bizTableOperatePopover.vue +11 -9
  21. package/src/components/EditableTable/features/bizViewSettingDialog.vue +10 -6
  22. package/src/components/EditableTable/index.less +189 -186
  23. package/src/components/EditableTable/index.vue +34 -16
  24. package/src/components/EditableTable/types/index.ts +4 -4
  25. package/src/components/Ellipsis/MultilineEllipsis.vue +96 -109
  26. package/src/components/Ellipsis/index.vue +114 -89
  27. package/src/components/LxTable/index.vue +98 -143
  28. package/src/components/PopoverForm/index.vue +52 -47
  29. package/src/components/SearchForm/index.vue +128 -138
  30. package/src/components/SearchForm/types/index.ts +4 -4
  31. package/src/components/SearchSelect/index.vue +83 -67
  32. package/src/components/index.ts +1 -1
  33. package/src/components/singleMessage/index.ts +15 -44
@@ -20,31 +20,31 @@
20
20
  <el-input
21
21
  v-if="type === 'input'"
22
22
  :placeholder="placeholder ? placeholder : showLabel ? '请输入' : label"
23
- :value="formData[prop]"
23
+ :model-value="formData[prop]"
24
24
  :maxlength="maxlength"
25
- @input="val => handleInput(val, prop, inputLimitCallback)"
25
+ @update:modelValue="val => handleInput(val, prop, inputLimitCallback)"
26
26
  />
27
27
  <div
28
28
  v-if="type === 'doubleInput'"
29
29
  :class="doubleIsInline ? 'form-double-inline': ''"
30
30
  >
31
31
  <el-input
32
- @input="val => handleInput(val, prop[0], inputLimitCallback)"
33
- :value="formData[prop[0]]"
32
+ @update:modelValue="val => handleInput(val, prop[0], inputLimitCallback)"
33
+ :model-value="formData[prop[0]]"
34
34
  :placeholder="(placeholder || [])[0] || '请输入'"
35
35
  />
36
36
  <el-input
37
37
  :placeholder="(placeholder || [])[1] || '请输入'"
38
- :value="formData[prop[1]]"
39
- @input="val => handleInput(val, prop[1], inputLimitCallback)"
38
+ :model-value="formData[prop[1]]"
39
+ @update:modelValue="val => handleInput(val, prop[1], inputLimitCallback)"
40
40
  />
41
41
  </div>
42
42
  <el-select
43
43
  v-if="type === 'select'"
44
- :value="formData[prop]"
45
- :placeholder="placeholder ? placeholder : showLabel ? '请输入' : label"
44
+ :model-value="formData[prop]"
45
+ :placeholder="withoutAll ? (placeholder ? placeholder : showLabel ? '请输入' : label) : (showLabel ? '全部' : label)"
46
46
  :clearable="clearable"
47
- @input="val => handleInput(val, prop)"
47
+ @update:modelValue="val => handleInput(val, prop)"
48
48
  @change="(...args) => changeCb && changeCb(...args)"
49
49
  :filterable="filterable"
50
50
  :multiple="multiple"
@@ -65,46 +65,46 @@
65
65
  </el-select>
66
66
  <el-date-picker
67
67
  v-if="type === 'datePicker'"
68
- @input="val => handleInput(val, prop)"
68
+ @update:modelValue="val => handleInput(val, prop)"
69
69
  @change="(...args) => changeCb && changeCb(...args)"
70
- :value="formData[prop]"
71
- format="yyyy-MM-dd"
72
- value-format="yyyy-MM-dd"
70
+ :model-value="formData[prop]"
71
+ format="YYYY-MM-DD"
72
+ value-format="YYYY-MM-DD"
73
73
  :type="dateType"
74
74
  :range-separator="rangeSeparator || '到'"
75
75
  :placeholder="dateType == 'date' ? placeholder || '选择日期' : '选择日期范围'"
76
76
  start-placeholder="开始日期"
77
77
  end-placeholder="结束日期"
78
- :picker-options="pickerOptions"
78
+ :disabled-date="pickerOptions?.disabledDate"
79
79
  />
80
80
  <div
81
81
  v-if="type === 'doubleDatePicker'"
82
82
  :class="doubleIsInline ? 'form-double-inline': ''"
83
83
  >
84
84
  <el-date-picker
85
- @input="val => handleInput(val, prop[0], '', key)"
85
+ @update:modelValue="val => handleInput(val, prop[0], '', key)"
86
86
  @change="(...args) => changeCb && changeCb(...args)"
87
- :value="formData[prop[0]]"
88
- value-format="yyyy-MM-dd"
89
- format="yyyy-MM-dd"
87
+ :model-value="formData[prop[0]]"
88
+ value-format="YYYY-MM-DD"
89
+ format="YYYY-MM-DD"
90
90
  type="date"
91
91
  :editable="false"
92
92
  :placeholder="(placeholder || [])[0] || '开始日期'"
93
- :picker-options="pickerOptions?.start || genStartDateDisabledOptions(formData[prop[1]], limit)"
93
+ :disabled-date="pickerOptions?.start?.disabledDate || genStartDateDisabledOptions(formData[prop[1]], limit)?.disabledDate"
94
94
  />
95
95
  <el-date-picker
96
- @input="val => handleInput(val, prop[1], '', key)"
96
+ @update:modelValue="val => handleInput(val, prop[1], '', key)"
97
97
  @change="(...args) => changeCb && changeCb(...args)"
98
- :value="formData[prop[1]]"
99
- value-format="yyyy-MM-dd"
100
- format="yyyy-MM-dd"
98
+ :model-value="formData[prop[1]]"
99
+ value-format="YYYY-MM-DD"
100
+ format="YYYY-MM-DD"
101
101
  type="date"
102
102
  :editable="false"
103
103
  :placeholder="(placeholder || [])[1] || '结束日期'"
104
- :picker-options="pickerOptions?.end || genEndDateDisabledOptions(formData[prop[0]], limit)"
104
+ :disabled-date="pickerOptions?.end?.disabledDate || genEndDateDisabledOptions(formData[prop[0]], limit)?.disabledDate"
105
105
  />
106
106
  <el-checkbox
107
- :value="checkedIds[key]"
107
+ :model-value="checkedIds[key]"
108
108
  v-if="isEmpty"
109
109
  @change="(value) => handelIsEmpty(prop, value, key)"
110
110
  class="is-empty"
@@ -117,146 +117,136 @@
117
117
  :name="slotName"
118
118
  />
119
119
  </el-form-item>
120
- <span v-if="isShowSearchBtn">
120
+ <el-form-item
121
+ v-if="isShowSearchBtn"
122
+ label-width="0"
123
+ class="search-form__buttons"
124
+ >
121
125
  <el-button
122
126
  class="search"
123
127
  @click="handleSearch"
124
128
  type="primary"
125
- >{{ searchText }}</el-button>
129
+ >
130
+ {{ searchText }}
131
+ </el-button>
126
132
  <el-button
127
133
  v-if="showClear"
128
134
  @click="handleClearParams"
129
- >{{ clearText }}</el-button>
130
- </span>
135
+ >
136
+ {{ clearText }}
137
+ </el-button>
138
+ </el-form-item>
131
139
  </el-form>
132
140
  </template>
133
141
 
134
- <script>
135
- import { genStartDateDisabledOptions, genEndDateDisabledOptions } from '../helper';
142
+ <script setup lang="ts">
143
+ import { ref, watch, onMounted } from 'vue'
144
+ import { genStartDateDisabledOptions, genEndDateDisabledOptions } from '../helper'
136
145
 
137
- export default {
138
- name: 'SearchForm',
139
- props: {
140
- labelPosition: {
141
- default: 'right',
142
- type: String
143
- },
144
- isShowSearchBtn: {
145
- default: true,
146
- type: Boolean
147
- },
148
- isInline: {
149
- default: false,
150
- type: Boolean
151
- },
152
- config: {
153
- required: true,
154
- type: Array
155
- },
156
- width: {
157
- default: '100px',
158
- type: String
159
- },
160
- formData: {
161
- required: true
162
- },
163
- showClear: {
164
- default: true,
165
- type: Boolean
166
- },
167
- showLabel: {
168
- default: true,
169
- type: Boolean
170
- },
171
- ownerClear: {
172
- type: Function
173
- },
174
- resetCheckedIds: {
175
- type: Boolean
176
- },
177
- searchText: {
178
- default: '搜索',
179
- type: String
180
- },
181
- clearText: {
182
- default: '清除',
183
- type: String
184
- }
185
- },
186
- data () {
187
- return {
188
- visible: true,
189
- initialData: {},
190
- checkedIds: {}
191
- }
192
- },
193
- watch: {
194
- resetCheckedIds () {
195
- this.config.filter(c => c.type === 'doubleDatePicker').map(t => t.key).forEach(k => {
196
- this.$set(this.checkedIds, k, false)
197
- })
198
- }
199
- },
200
- mounted () {
201
- this.initialData = Object.freeze({ ...this.formData })
202
- },
203
- methods: {
204
- genStartDateDisabledOptions,
205
- genEndDateDisabledOptions,
206
- handleInput (val, prop, inputLimitCallback, key) {
207
- if (inputLimitCallback && !inputLimitCallback(val)) return false
208
- if (val) {
209
- this.$set(this.checkedIds, key, false)
210
- }
211
- this.$emit('update:formData', { ...this.formData, [prop]: val })
212
- this.$emit('isPickerEmpty', this.checkedIds)
213
- },
146
+ defineOptions({ name: 'SearchForm' })
147
+
148
+ interface IProps {
149
+ labelPosition?: string
150
+ isShowSearchBtn?: boolean
151
+ isInline?: boolean
152
+ config: Record<string, any>[]
153
+ width?: string
154
+ formData: Record<string, any>
155
+ showClear?: boolean
156
+ showLabel?: boolean
157
+ ownerClear?: () => void
158
+ resetCheckedIds?: boolean
159
+ searchText?: string
160
+ clearText?: string
161
+ }
162
+
163
+ interface IEmits {
164
+ (e: 'update:formData', val: Record<string, any>): void
165
+ (e: 'isPickerEmpty', val: Record<string, boolean>): void
166
+ (e: 'search', formData: Record<string, any>): void
167
+ (e: 'clear'): void
168
+ }
169
+
170
+ const props = withDefaults(defineProps<IProps>(), {
171
+ labelPosition: 'right',
172
+ isShowSearchBtn: true,
173
+ isInline: false,
174
+ width: '100px',
175
+ showClear: true,
176
+ showLabel: true,
177
+ searchText: '搜索',
178
+ clearText: '清除',
179
+ })
214
180
 
215
- handleSearch () {
216
- this.$emit('search', this.formData)
217
- },
181
+ const emit = defineEmits<IEmits>()
218
182
 
219
- handelIsEmpty (prop, value, key) {
220
- if (value) {
221
- // eslint-disable-next-line
222
- this.formData[prop[0]] = '';
223
- // eslint-disable-next-line
224
- this.formData[prop[1]] = '';
225
- }
226
- this.$set(this.checkedIds, key, value)
227
- this.$emit('isPickerEmpty', this.checkedIds)
228
- },
183
+ const initialData = ref<Record<string, any>>({})
184
+ const checkedIds = ref<Record<string, boolean>>({})
229
185
 
230
- handleClearParams () { // 父组件可以通过调用 `this.$refs[xx].handleClearParams()` 来清空表单数据
231
- if (this.ownerClear && typeof this.ownerClear === 'function') {
232
- this.ownerClear()
233
- return
234
- }
235
- Object.keys(this.checkedIds).forEach((k) => {
236
- this.checkedIds[k] = false
237
- })
238
- this.$emit('update:formData', { ...this.formData, ...this.initialData })
239
- this.$emit('clear')
240
- },
186
+ watch(() => props.resetCheckedIds, () => {
187
+ props.config.filter(c => c.type === 'doubleDatePicker').map(t => t.key).forEach((k: string) => {
188
+ checkedIds.value[k] = false
189
+ })
190
+ })
241
191
 
242
- handleFormClose () {
243
- this.visible = false;
244
- },
192
+ onMounted(() => {
193
+ initialData.value = Object.freeze({ ...props.formData })
194
+ })
195
+
196
+ const handleInput = (val: any, prop: string | number, inputLimitCallback?: any, key?: string) => {
197
+ if (inputLimitCallback && !inputLimitCallback(val)) return false
198
+ if (val && key) {
199
+ checkedIds.value[key] = false
245
200
  }
201
+ emit('update:formData', { ...props.formData, [prop]: val })
202
+ emit('isPickerEmpty', checkedIds.value)
203
+ }
204
+
205
+ const handleSearch = () => {
206
+ emit('search', props.formData)
207
+ }
208
+
209
+ const handelIsEmpty = (prop: string[], value: boolean, key: string) => {
210
+ if (value) {
211
+ emit('update:formData', { ...props.formData, [prop[0]]: '', [prop[1]]: '' })
212
+ }
213
+ checkedIds.value[key] = value
214
+ emit('isPickerEmpty', checkedIds.value)
215
+ }
216
+
217
+ const handleClearParams = () => {
218
+ if (props.ownerClear && typeof props.ownerClear === 'function') {
219
+ props.ownerClear()
220
+ return
221
+ }
222
+ Object.keys(checkedIds.value).forEach((k) => {
223
+ checkedIds.value[k] = false
224
+ })
225
+ emit('update:formData', { ...props.formData, ...initialData.value })
226
+ emit('clear')
246
227
  }
247
228
  </script>
248
229
  <style scoped lang="less">
249
230
  .form-double-inline {
250
231
  display: flex;
251
- & .el-input {
232
+ :deep(.el-input) {
252
233
  &:not(:first-child) {
253
234
  margin-left: 4px;
254
235
  }
255
236
  }
256
- & .el-date-editor{
257
- &:not(:first-child){
237
+ :deep(.el-date-editor) {
238
+ &:not(:first-child) {
258
239
  margin-left: 4px;
259
240
  }
260
241
  }
242
+ :deep(.is-empty) {
243
+ margin-left: 4px;
244
+ }
245
+ }
246
+ :deep(.el-select) {
247
+ min-width: 180px;
248
+ }
249
+ :deep(.el-form-item__label) {
250
+ height: auto;
261
251
  }
262
252
  </style>
@@ -1,4 +1,4 @@
1
- import { DatePicker } from "element-ui/types/element-ui"
1
+ import type { DatePickerProps } from 'element-plus'
2
2
 
3
3
  type BaseOption = {
4
4
  label: string
@@ -41,7 +41,7 @@ type DatePickerOption = BaseOption & {
41
41
  type: 'datePicker'
42
42
  dateType?: string
43
43
  rangeSeparator?: string
44
- datePickerOptions?: DatePicker['pickerOptions']
44
+ datePickerOptions?: DatePickerProps['disabledDate']
45
45
  }
46
46
 
47
47
  type BaseDoubleOption = Omit<BaseOption, 'prop'> & {
@@ -62,8 +62,8 @@ type DoubleDatePickerOptionBase = BaseDoubleOption & {
62
62
 
63
63
  type DoubleDatePickerOption = DoubleDatePickerOptionBase & {
64
64
  pickerOptions?: {
65
- start?: DatePicker['pickerOptions']
66
- end?: DatePicker['pickerOptions']
65
+ start?: DatePickerProps['disabledDate']
66
+ end?: DatePickerProps['disabledDate']
67
67
  }
68
68
  }
69
69
 
@@ -10,7 +10,7 @@
10
10
  v-model="content"
11
11
  class="search-select__input"
12
12
  :placeholder="placeholder"
13
- @input="handleInputChange"
13
+ @update:modelValue="handleInputChange"
14
14
  @focus="handleFocus"
15
15
  @blur="handleBlur"
16
16
  />
@@ -38,72 +38,88 @@
38
38
  </div>
39
39
  </template>
40
40
 
41
- <script>
42
- export default {
43
- name: 'SearchSelect',
44
- props: {
45
- value: {
46
- default: '',
47
- type: String,
48
- },
49
- placeholder: {
50
- default: '请输入',
51
- type: String,
52
- },
53
- list: {
54
- default: () => [],
55
- type: Array,
56
- },
57
- showList: {
58
- default: () => [],
59
- type: Array,
60
- }
61
- },
62
- data() {
63
- return {
64
- content: '',
65
- visible: false,
66
- currentId: 0
67
- }
68
- },
69
- watch: {
70
- value(val) {
71
- this.content = val
72
- }
73
- },
74
- methods: {
75
- handleFocus() {
76
- this.visible = true
77
- this.$emit('input', this.content)
78
- },
79
- handleInputChange(params) {
80
- this.$emit('update:value', params)
81
- this.$emit('input', params)
82
- },
83
- navigateOptions(e, params) {
84
- e.target.selectionStart = this.content.length
85
- if (params === 'next') this.currentId = this.currentId === this.list.length - 1 ? 0 : this.currentId + 1
86
- if (params === 'prev') this.currentId = this.currentId === 0 ? this.list.length - 1 : this.currentId - 1
87
- },
88
- selectOption() {
89
- this.visible = false
90
- this.$refs.input.blur()
91
- this.$emit('select', this.list[this.currentId])
92
- },
93
- handleBlur() {
94
- const timer = setTimeout(() => {
95
- this.visible = false
96
- clearTimeout(timer)
97
- }, 300)
98
- },
99
- handleSelect(item) {
100
- this.$emit('select', item)
101
- },
102
- getKey (item, index) {
103
- return btoa(escape(`${item}_${index}`))
104
- }
105
- },
106
- };
41
+ <script setup lang="ts">
42
+ import { ref, watch } from 'vue'
43
+
44
+ defineOptions({ name: 'SearchSelect' })
45
+
46
+ interface IProps {
47
+ value?: string
48
+ modelValue?: string
49
+ placeholder?: string
50
+ list?: any[]
51
+ showList?: any[]
52
+ }
53
+
54
+ interface IEmits {
55
+ (e: 'input', val: string): void
56
+ (e: 'update:modelValue', val: string): void
57
+ (e: 'update:value', val: string): void
58
+ (e: 'select', item: any): void
59
+ }
60
+
61
+ const props = withDefaults(defineProps<IProps>(), {
62
+ value: '',
63
+ modelValue: '',
64
+ placeholder: '请输入',
65
+ list: () => [],
66
+ showList: () => [],
67
+ })
68
+
69
+ const emit = defineEmits<IEmits>()
70
+
71
+ const content = ref('')
72
+ const visible = ref(false)
73
+ const currentId = ref(0)
74
+ const input = ref<{ blur: () => void }>()
75
+
76
+ watch(() => props.value, (val) => {
77
+ content.value = val
78
+ })
79
+
80
+ watch(() => props.modelValue, (val) => {
81
+ content.value = val
82
+ })
83
+
84
+ const handleFocus = () => {
85
+ visible.value = true
86
+ emit('input', content.value)
87
+ emit('update:modelValue', content.value)
88
+ }
89
+
90
+ const handleInputChange = (params: string) => {
91
+ emit('update:value', params)
92
+ emit('input', params)
93
+ emit('update:modelValue', params)
94
+ }
95
+
96
+ const navigateOptions = (e: KeyboardEvent, params: string) => {
97
+ const target = e.target as HTMLInputElement
98
+ target.selectionStart = content.value.length
99
+ if (params === 'next') currentId.value = currentId.value === props.list.length - 1 ? 0 : currentId.value + 1
100
+ if (params === 'prev') currentId.value = currentId.value === 0 ? props.list.length - 1 : currentId.value - 1
101
+ }
102
+
103
+ const selectOption = () => {
104
+ visible.value = false
105
+ input.value?.blur()
106
+ emit('select', props.list[currentId.value])
107
+ }
108
+
109
+ const handleBlur = () => {
110
+ const timer = setTimeout(() => {
111
+ visible.value = false
112
+ clearTimeout(timer)
113
+ }, 300)
114
+ }
115
+
116
+ const handleSelect = (item: any) => {
117
+ emit('select', item)
118
+ }
119
+
120
+ const getKey = (item: any, index: number) => {
121
+ return btoa(escape(`${item}_${index}`))
122
+ }
107
123
  </script>
108
124
 
109
125
  <style lang="less">
@@ -8,7 +8,7 @@ import SearchSelect from './SearchSelect/index.vue'
8
8
  import AddMembers from './AddMembers/index.vue'
9
9
  import PopoverForm from './PopoverForm/index.vue'
10
10
  import EditableTable from './EditableTable/index.vue'
11
- import SingleMessage from './singleMessage/index'
11
+ import { SingleMessage } from './singleMessage/index'
12
12
 
13
13
  export {
14
14
  DemoComponent,
@@ -1,44 +1,15 @@
1
- import { Message } from 'element-ui';
2
- import MessageType from 'element-ui/packages/message';
3
-
4
-
5
- let messageInstance: MessageType = null;
6
-
7
- const closeMsg = (message: MessageType) => {
8
- message.singleTimer = setTimeout(() => {
9
- message.singleTimer && clearTimeout(message.singleTimer);
10
- message.close();
11
- messageInstance = null;
12
- }, 3000);
13
- };
14
-
15
- const singleMessage: MessageType = (options: any) => {
16
- if (
17
- messageInstance
18
- && (messageInstance.message !== options.message || messageInstance.type !== options.type)
19
- ) {
20
- messageInstance.close();
21
- messageInstance = Message({ ...options, duration: 0 });
22
- return closeMsg(messageInstance);
23
- }
24
- if (messageInstance) {
25
- messageInstance.singleTimer && clearTimeout(messageInstance.singleTimer);
26
- return closeMsg(messageInstance);
27
- }
28
- messageInstance = Message({ ...options, duration: 0 });
29
- closeMsg(messageInstance);
30
- };
31
-
32
- ['error', 'success', 'info', 'warning'].forEach(type => {
33
- singleMessage[type] = options => {
34
- if (typeof options === 'string') {
35
- options = {
36
- message: options,
37
- };
38
- }
39
- options.type = type;
40
- return singleMessage(options);
41
- };
42
- });
43
-
44
- export default singleMessage;
1
+ import { ElMessage } from 'element-plus';
2
+
3
+ export interface ISingleMessageOption {
4
+ message: string;
5
+ type?: 'success' | 'warning' | 'info' | 'error';
6
+ duration?: number;
7
+ }
8
+
9
+ export function SingleMessage(option: ISingleMessageOption) {
10
+ ElMessage({
11
+ message: option.message,
12
+ type: option.type || 'success',
13
+ duration: option.duration || 3000,
14
+ });
15
+ }