@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.
- package/package.json +21 -12
- package/src/components/AddMembers/index.vue +100 -89
- package/src/components/AuditSteps/index.vue +107 -74
- package/src/components/DemoComponent/index.vue +8 -5
- package/src/components/EditableTable/bizHooks/useCellHover.ts +47 -2
- package/src/components/EditableTable/bizHooks/useColumnHeaderOperation.ts +5 -4
- package/src/components/EditableTable/bizHooks/useDefaultOperation.ts +12 -4
- package/src/components/EditableTable/bizHooks/useDragSort.ts +36 -3
- package/src/components/EditableTable/bizHooks/useRowBgColor.ts +6 -2
- package/src/components/EditableTable/bizHooks/useViewSetting.ts +2 -1
- package/src/components/EditableTable/features/bizColorSelect.vue +4 -3
- package/src/components/EditableTable/features/bizEditCell.vue +6 -6
- package/src/components/EditableTable/features/bizTableHeaderPopover/BizCheckboxFilter.vue +3 -3
- package/src/components/EditableTable/features/bizTableHeaderPopover/BizColorRadioFilter.vue +3 -4
- package/src/components/EditableTable/features/bizTableHeaderPopover/BizDoubleDatePickerFilter.vue +8 -8
- package/src/components/EditableTable/features/bizTableHeaderPopover/BizInputFilter.vue +2 -2
- package/src/components/EditableTable/features/bizTableHeaderPopover/BizMonthDayPicker.vue +2 -2
- package/src/components/EditableTable/features/bizTableHeaderPopover/BizRadioFilter.vue +3 -4
- package/src/components/EditableTable/features/bizTableHeaderPopover/index.vue +28 -19
- package/src/components/EditableTable/features/bizTableOperatePopover.vue +11 -9
- package/src/components/EditableTable/features/bizViewSettingDialog.vue +10 -6
- package/src/components/EditableTable/index.less +189 -186
- package/src/components/EditableTable/index.vue +34 -16
- package/src/components/EditableTable/types/index.ts +4 -4
- package/src/components/Ellipsis/MultilineEllipsis.vue +96 -109
- package/src/components/Ellipsis/index.vue +114 -89
- package/src/components/LxTable/index.vue +98 -143
- package/src/components/PopoverForm/index.vue +52 -47
- package/src/components/SearchForm/index.vue +128 -138
- package/src/components/SearchForm/types/index.ts +4 -4
- package/src/components/SearchSelect/index.vue +83 -67
- package/src/components/index.ts +1 -1
- package/src/components/singleMessage/index.ts +15 -44
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lx-frontend/wrap-element-ui",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "wrap-element-ui",
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
|
+
"description": "wrap-element-ui Vue 3 + Element Plus 组件库",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "src/components/index.ts",
|
|
7
7
|
"private": false,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build:sb": "cross-env MODE=production rimraf storybook-static && pnpm build:lib && storybook build",
|
|
14
14
|
"preview": "serve ./storybook-static",
|
|
15
15
|
"publish:dev": "npm publish --access public --tag beta",
|
|
16
|
-
"publish:prod": "npm publish --access public",
|
|
16
|
+
"publish:prod": "npm publish --access public --tag latest",
|
|
17
17
|
"cdn": "gulp oss",
|
|
18
18
|
"lint": "eslint src"
|
|
19
19
|
},
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
],
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"dayjs": "^1.11.13",
|
|
27
|
-
"element-
|
|
27
|
+
"element-plus": "^2.5.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
|
-
"vue": "
|
|
29
|
+
"vue": "^3.4.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@element-plus/icons-vue": "^2.3.2",
|
|
32
33
|
"@faker-js/faker": "^8.4.1",
|
|
33
34
|
"@storybook/addon-docs": "7.6.19",
|
|
34
35
|
"@storybook/addon-essentials": "7.6.19",
|
|
@@ -39,19 +40,23 @@
|
|
|
39
40
|
"@storybook/react": "7.6.19",
|
|
40
41
|
"@storybook/react-vite": "7.6.19",
|
|
41
42
|
"@storybook/test": "7.6.19",
|
|
42
|
-
"@storybook/
|
|
43
|
-
"@storybook/
|
|
43
|
+
"@storybook/vue3": "7.6.19",
|
|
44
|
+
"@storybook/vue3-vite": "7.6.19",
|
|
44
45
|
"@types/jest": "^24.0.11",
|
|
45
46
|
"@types/lodash": "^4.17.5",
|
|
46
47
|
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
47
48
|
"@typescript-eslint/parser": "^7.16.0",
|
|
48
49
|
"@vitejs/plugin-legacy": "^4.1.1",
|
|
49
|
-
"@vitejs/plugin-
|
|
50
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
51
|
+
"@vue/compiler-core": "^3.5.38",
|
|
52
|
+
"@vue/compiler-dom": "^3.5.38",
|
|
50
53
|
"@vue/eslint-config-typescript": "^13.0.0",
|
|
51
|
-
"@vue/
|
|
54
|
+
"@vue/shared": "^3.5.38",
|
|
55
|
+
"@vue/test-utils": "^2.4.0",
|
|
52
56
|
"ali-oss": "^6.20.0",
|
|
53
57
|
"autoprefixer": "^10.4.19",
|
|
54
58
|
"cross-env": "^7.0.3",
|
|
59
|
+
"element-plus": "^2.5.0",
|
|
55
60
|
"eslint": "^8.57.0",
|
|
56
61
|
"eslint-plugin-vue": "^9.27.0",
|
|
57
62
|
"gulp": "^4.0.2",
|
|
@@ -63,11 +68,15 @@
|
|
|
63
68
|
"serve": "^14.2.3",
|
|
64
69
|
"storybook": "7.6.19",
|
|
65
70
|
"through2": "^4.0.2",
|
|
66
|
-
"typescript": "^
|
|
67
|
-
"vite": "^
|
|
71
|
+
"typescript": "^5.3.0",
|
|
72
|
+
"vite": "^5.0.0",
|
|
68
73
|
"vite-plugin-dts": "^3.9.1",
|
|
69
74
|
"vite-plugin-lib-inject-css": "^2.1.1",
|
|
70
75
|
"vite-tsconfig-paths": "^4.3.2",
|
|
71
|
-
"vue
|
|
76
|
+
"vue": "^3.4.0"
|
|
77
|
+
},
|
|
78
|
+
"volta": {
|
|
79
|
+
"node": "20.20.2",
|
|
80
|
+
"pnpm": "8.15.9"
|
|
72
81
|
}
|
|
73
82
|
}
|
|
@@ -6,103 +6,113 @@
|
|
|
6
6
|
:width="360"
|
|
7
7
|
@on-change="handleCloseTechniciansSelectPopup"
|
|
8
8
|
>
|
|
9
|
-
<
|
|
10
|
-
slot="form"
|
|
11
|
-
class="team-setting__technicians-popover"
|
|
12
|
-
>
|
|
13
|
-
<div class="team-setting__technicians-select">
|
|
14
|
-
<el-input
|
|
15
|
-
v-model="techniciansSearchQuery"
|
|
16
|
-
placeholder="请输入姓名"
|
|
17
|
-
@input="handleInputTechniciansSearch"
|
|
18
|
-
/>
|
|
19
|
-
</div>
|
|
9
|
+
<template #form>
|
|
20
10
|
<div
|
|
21
|
-
|
|
22
|
-
class="team-setting__empty-technicians-options"
|
|
23
|
-
>
|
|
24
|
-
{{ $attrs.empty || '系统未登记该员工,请先添加员工账号' }}
|
|
25
|
-
</div>
|
|
26
|
-
<ul
|
|
27
|
-
v-else
|
|
28
|
-
class="team-setting__technicians-options"
|
|
11
|
+
class="team-setting__technicians-popover"
|
|
29
12
|
>
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
<div class="team-setting__technicians-select">
|
|
14
|
+
<el-input
|
|
15
|
+
v-model="techniciansSearchQuery"
|
|
16
|
+
placeholder="请输入姓名"
|
|
17
|
+
@input="handleInputTechniciansSearch"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
<div
|
|
21
|
+
v-if="techniciansSearchQuery && !technicianOptions.length && !fetchTechniciansLoading"
|
|
22
|
+
class="team-setting__empty-technicians-options"
|
|
34
23
|
>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<el-button
|
|
46
|
-
v-else
|
|
47
|
-
type="text"
|
|
48
|
-
@click="handleAddTechnician($attrs.keyId, item)"
|
|
24
|
+
{{ attrs.empty || '系统未登记该员工,请先添加员工账号' }}
|
|
25
|
+
</div>
|
|
26
|
+
<ul
|
|
27
|
+
v-else
|
|
28
|
+
class="team-setting__technicians-options"
|
|
29
|
+
>
|
|
30
|
+
<li
|
|
31
|
+
class="team-setting__technicians-option"
|
|
32
|
+
v-for="item in technicianOptions"
|
|
33
|
+
:key="item[attrs.showConfig!.id]"
|
|
49
34
|
>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
<div class="team-setting__technicians-option-left">
|
|
36
|
+
{{ `${item[attrs.showConfig!.name]} | ${item.roles}` }}
|
|
37
|
+
</div>
|
|
38
|
+
<el-button
|
|
39
|
+
v-if="item.is_selected"
|
|
40
|
+
type="text"
|
|
41
|
+
disabled
|
|
42
|
+
>
|
|
43
|
+
已添加
|
|
44
|
+
</el-button>
|
|
45
|
+
<el-button
|
|
46
|
+
v-else
|
|
47
|
+
type="text"
|
|
48
|
+
@click="handleAddTechnician(attrs.keyId, item)"
|
|
49
|
+
>
|
|
50
|
+
添加
|
|
51
|
+
</el-button>
|
|
52
|
+
</li>
|
|
53
|
+
</ul>
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
56
|
+
<template #reference>
|
|
57
|
+
<el-button
|
|
58
|
+
type="text"
|
|
59
|
+
:icon="Plus"
|
|
60
|
+
>
|
|
61
|
+
{{ title }}
|
|
62
|
+
</el-button>
|
|
63
|
+
</template>
|
|
62
64
|
</PopoverForm>
|
|
63
65
|
</div>
|
|
64
66
|
</template>
|
|
65
67
|
|
|
66
|
-
<script>
|
|
67
|
-
import
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
68
|
+
<script setup lang="ts">
|
|
69
|
+
import { ref, useAttrs } from 'vue'
|
|
70
|
+
import { Plus } from '@element-plus/icons-vue'
|
|
71
|
+
import PopoverForm from '../PopoverForm/index.vue'
|
|
72
|
+
|
|
73
|
+
defineOptions({ name: 'AddMembers' })
|
|
74
|
+
|
|
75
|
+
interface IProps {
|
|
76
|
+
technicianOptions?: any[]
|
|
77
|
+
fetchTechniciansLoading?: boolean
|
|
78
|
+
title?: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface IEmits {
|
|
82
|
+
(e: 'update:technicianOptions', val: any[]): void
|
|
83
|
+
(e: 'fetchTechniciansMethods', query: string): void
|
|
84
|
+
(e: 'handleAddTechnician', query: { id: any; item: any }): void
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
withDefaults(defineProps<IProps>(), {
|
|
88
|
+
technicianOptions: () => [],
|
|
89
|
+
fetchTechniciansLoading: false,
|
|
90
|
+
title: '添加成员',
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const emit = defineEmits<IEmits>()
|
|
94
|
+
const attrs = useAttrs() as {
|
|
95
|
+
empty?: string
|
|
96
|
+
showConfig?: { id: string; name: string }
|
|
97
|
+
keyId?: any
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const techniciansSearchQuery = ref('')
|
|
101
|
+
|
|
102
|
+
const handleCloseTechniciansSelectPopup = (show: boolean) => {
|
|
103
|
+
if (show) return
|
|
104
|
+
techniciansSearchQuery.value = ''
|
|
105
|
+
emit('update:technicianOptions', [])
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const handleInputTechniciansSearch = (query: string) => {
|
|
109
|
+
emit('fetchTechniciansMethods', query)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const handleAddTechnician = (id: any, item: any) => {
|
|
113
|
+
const query = { id, item }
|
|
114
|
+
emit('handleAddTechnician', query)
|
|
115
|
+
}
|
|
106
116
|
</script>
|
|
107
117
|
|
|
108
118
|
<style lang="less">
|
|
@@ -111,6 +121,7 @@ export default {
|
|
|
111
121
|
padding: 20px;
|
|
112
122
|
height: 350px;
|
|
113
123
|
overflow-y: auto;
|
|
124
|
+
overflow-x: hidden;
|
|
114
125
|
}
|
|
115
126
|
&__technicians-select {
|
|
116
127
|
width: 320px;
|
|
@@ -1,86 +1,118 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="audit-steps">
|
|
3
3
|
<ElSteps direction="vertical">
|
|
4
|
-
<ElStep
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
<ElStep
|
|
5
|
+
class="audit-steps__step-item"
|
|
6
|
+
v-for="(item, index) in modelValue"
|
|
7
|
+
:key="index"
|
|
8
|
+
>
|
|
9
|
+
<template #icon>
|
|
10
|
+
{{ index + 1 }}
|
|
11
|
+
</template>
|
|
12
|
+
<template #description>
|
|
13
|
+
<div :class="{'el-name-box': item.id}">
|
|
14
|
+
<span :class="[ 'audit-steps__step-order', {first: index===0} ]">{{ index + 1 }}</span>
|
|
15
|
+
<ElSelect
|
|
16
|
+
:model-value="item.employees"
|
|
17
|
+
@update:model-value="val => handleEditCandidate(val, index)"
|
|
18
|
+
multiple
|
|
19
|
+
:multiple-limit="maxSelect"
|
|
20
|
+
placeholder="请选择"
|
|
21
|
+
>
|
|
22
|
+
<ElOption
|
|
23
|
+
v-for="v in candidates"
|
|
24
|
+
:key="v.id"
|
|
25
|
+
:label="v.name"
|
|
26
|
+
:value="v.id"
|
|
27
|
+
/>
|
|
28
|
+
</ElSelect>
|
|
29
|
+
<i
|
|
30
|
+
class="el-name"
|
|
31
|
+
v-if="item.id"
|
|
32
|
+
>{{ item.miniName }}</i>
|
|
33
|
+
<el-icon
|
|
34
|
+
v-if="index"
|
|
35
|
+
class="el-icon-delete"
|
|
36
|
+
@click="handleDeleteStep(index)"
|
|
37
|
+
>
|
|
38
|
+
<Delete />
|
|
39
|
+
</el-icon>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
23
42
|
</ElStep>
|
|
24
43
|
</ElSteps>
|
|
25
|
-
<ElButton
|
|
44
|
+
<ElButton
|
|
45
|
+
v-if="isAdd"
|
|
46
|
+
type="text"
|
|
47
|
+
class="audit-steps__add"
|
|
48
|
+
icon="circle-plus"
|
|
49
|
+
@click="handleAddStep"
|
|
50
|
+
>
|
|
51
|
+
添加审核环节
|
|
52
|
+
</ElButton>
|
|
26
53
|
</div>
|
|
27
54
|
</template>
|
|
28
55
|
|
|
29
|
-
<script>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.syncSteps(_steps => {
|
|
75
|
-
return _steps.concat([{ employees: [] }])
|
|
76
|
-
})
|
|
77
|
-
},
|
|
78
|
-
// 判断是不是每一个步骤都选有审核人
|
|
79
|
-
isValidateSteps () {
|
|
80
|
-
return !this.value.some(_steps => _steps.employees.length <= 0)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
56
|
+
<script setup lang="ts">
|
|
57
|
+
import { computed } from 'vue'
|
|
58
|
+
import { Delete } from '@element-plus/icons-vue'
|
|
59
|
+
import { ElSteps, ElStep, ElSelect, ElOption, ElButton } from 'element-plus'
|
|
60
|
+
|
|
61
|
+
defineOptions({ name: 'AuditSteps' })
|
|
62
|
+
|
|
63
|
+
interface StepItem {
|
|
64
|
+
employees: any[]
|
|
65
|
+
id?: any
|
|
66
|
+
miniName?: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface IProps {
|
|
70
|
+
candidates?: any[]
|
|
71
|
+
modelValue?: StepItem[]
|
|
72
|
+
maxSelect?: number
|
|
73
|
+
stepNum?: number
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface IEmits {
|
|
77
|
+
(e: 'update:modelValue', val: StepItem[]): void
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const props = withDefaults(defineProps<IProps>(), {
|
|
81
|
+
candidates: () => [],
|
|
82
|
+
modelValue: () => [],
|
|
83
|
+
maxSelect: 3,
|
|
84
|
+
stepNum: 2,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const emit = defineEmits<IEmits>()
|
|
88
|
+
|
|
89
|
+
const isAdd = computed(() => props.modelValue.length < props.stepNum)
|
|
90
|
+
|
|
91
|
+
const syncSteps = (modification: (_steps: StepItem[]) => StepItem[]) => {
|
|
92
|
+
const _steps = [...props.modelValue]
|
|
93
|
+
emit('update:modelValue', modification(_steps))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const handleEditCandidate = (val: any[], index: number) => {
|
|
97
|
+
syncSteps(_steps => {
|
|
98
|
+
_steps[index].employees = val
|
|
99
|
+
return _steps
|
|
100
|
+
})
|
|
83
101
|
}
|
|
102
|
+
|
|
103
|
+
const handleDeleteStep = (i: number) => {
|
|
104
|
+
syncSteps(_steps => {
|
|
105
|
+
_steps.splice(i, 1)
|
|
106
|
+
return _steps
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const handleAddStep = () => {
|
|
111
|
+
syncSteps(_steps => {
|
|
112
|
+
return _steps.concat([{ employees: [] }])
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
84
116
|
</script>
|
|
85
117
|
|
|
86
118
|
<style lang="less">
|
|
@@ -104,6 +136,7 @@ export default {
|
|
|
104
136
|
margin-left: 10px;
|
|
105
137
|
font-size: 16px;
|
|
106
138
|
cursor: pointer;
|
|
139
|
+
vertical-align: middle;
|
|
107
140
|
}
|
|
108
141
|
}
|
|
109
142
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="demo-component__input">
|
|
3
|
-
<ElInput
|
|
3
|
+
<ElInput
|
|
4
|
+
title="DemoComponent"
|
|
5
|
+
lable="DemoComponent"
|
|
6
|
+
/>
|
|
4
7
|
</div>
|
|
5
8
|
</template>
|
|
6
|
-
<script>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { ElInput } from 'element-plus'
|
|
11
|
+
|
|
12
|
+
defineOptions({ name: 'DemoComponent' })
|
|
10
13
|
</script>
|
|
11
14
|
|
|
12
15
|
<style lang="less">
|
|
@@ -1,7 +1,52 @@
|
|
|
1
|
-
import debounce from 'lodash/debounce';
|
|
2
|
-
import throttle from 'lodash/throttle';
|
|
3
1
|
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
|
4
2
|
|
|
3
|
+
/** 简单实现 debounce */
|
|
4
|
+
function debounce<T extends (...args: any[]) => any>(fn: T, delay: number) {
|
|
5
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
6
|
+
const debounced = (...args: any[]) => {
|
|
7
|
+
if (timer !== null) clearTimeout(timer);
|
|
8
|
+
timer = setTimeout(() => {
|
|
9
|
+
fn(...args);
|
|
10
|
+
timer = null;
|
|
11
|
+
}, delay);
|
|
12
|
+
};
|
|
13
|
+
debounced.cancel = () => {
|
|
14
|
+
if (timer !== null) clearTimeout(timer);
|
|
15
|
+
timer = null;
|
|
16
|
+
};
|
|
17
|
+
return debounced as T & { cancel: () => void };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** 简单实现 throttle */
|
|
21
|
+
function throttle<T extends (...args: any[]) => any>(fn: T, delay: number) {
|
|
22
|
+
let lastTime = 0;
|
|
23
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
24
|
+
const throttled = (...args: any[]) => {
|
|
25
|
+
const now = Date.now();
|
|
26
|
+
const remaining = delay - (now - lastTime);
|
|
27
|
+
if (remaining <= 0) {
|
|
28
|
+
if (timer !== null) {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
timer = null;
|
|
31
|
+
}
|
|
32
|
+
lastTime = now;
|
|
33
|
+
fn(...args);
|
|
34
|
+
} else if (timer === null) {
|
|
35
|
+
timer = setTimeout(() => {
|
|
36
|
+
lastTime = Date.now();
|
|
37
|
+
timer = null;
|
|
38
|
+
fn(...args);
|
|
39
|
+
}, remaining);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
throttled.cancel = () => {
|
|
43
|
+
if (timer !== null) clearTimeout(timer);
|
|
44
|
+
timer = null;
|
|
45
|
+
lastTime = 0;
|
|
46
|
+
};
|
|
47
|
+
return throttled as T & { cancel: () => void };
|
|
48
|
+
}
|
|
49
|
+
|
|
5
50
|
export function useCellHover(tableDomRef) {
|
|
6
51
|
|
|
7
52
|
// 鼠标悬浮的行
|
|
@@ -120,10 +120,11 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
const closeSortAndFilterPopover = (exceptProp?: string) => {
|
|
123
|
-
document.querySelectorAll('
|
|
124
|
-
|
|
125
|
-
item?.__vue__
|
|
126
|
-
|
|
123
|
+
document.querySelectorAll('.editable-table-sort-filter').forEach((item: any) => {
|
|
124
|
+
try {
|
|
125
|
+
const vm = item.__vueParentComponent?.proxy || item.__vue__;
|
|
126
|
+
vm?.doClose?.() || vm?.hide?.();
|
|
127
|
+
} catch {}
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
130
|
|
|
@@ -25,12 +25,16 @@ export function useDefaultOperation({ emit, pageSize, props, tableDomRef, hasExp
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const closeOperationPopover = () => {
|
|
28
|
-
operationPopoverRef.value
|
|
28
|
+
const refs = operationPopoverRef.value;
|
|
29
|
+
if (!refs) return;
|
|
30
|
+
const list = Array.isArray(refs) ? refs : [refs];
|
|
31
|
+
list.forEach((item) => item?.doClose?.());
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
const closeAllExpandedRows = () => {
|
|
32
35
|
if (!hasExpandRow) return
|
|
33
|
-
tableDomRef.value?.data
|
|
36
|
+
const data = tableDomRef.value?.data ?? tableDomRef.value?.store?.states?.data?.value;
|
|
37
|
+
data?.forEach((item) => {
|
|
34
38
|
tableDomRef.value?.toggleRowExpansion(item, false)
|
|
35
39
|
})
|
|
36
40
|
}
|
|
@@ -47,13 +51,17 @@ export function useDefaultOperation({ emit, pageSize, props, tableDomRef, hasExp
|
|
|
47
51
|
|
|
48
52
|
const handleRowPinToTop = (scope) => {
|
|
49
53
|
const { row, $index: index, store } = scope;
|
|
50
|
-
const dataList = store.states.data;
|
|
54
|
+
const dataList = store.states.data.value ?? store.states.data;
|
|
51
55
|
const newList = [
|
|
52
56
|
...dataList.slice(0, index),
|
|
53
57
|
...dataList.slice(index + 1)
|
|
54
58
|
];
|
|
55
59
|
newList.unshift({ ...row, isPinned: true });
|
|
56
|
-
store.states.data
|
|
60
|
+
if (typeof store.states.data.value !== 'undefined') {
|
|
61
|
+
store.states.data.value = newList;
|
|
62
|
+
} else {
|
|
63
|
+
store.states.data = newList;
|
|
64
|
+
}
|
|
57
65
|
emit('row-pin-to-top', { row, rawIndex: index, page: props.currentPage, size: pageSize.value });
|
|
58
66
|
closeOperationPopover();
|
|
59
67
|
}
|