@ctzy-web-client/plugin-component-vue 1.0.0
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 +43 -0
- package/src/advance-select/advance-operation.vue +44 -0
- package/src/advance-select/advance-option.vue +115 -0
- package/src/advance-select/advance-select.vue +343 -0
- package/src/advance-select/events-helpers.js +40 -0
- package/src/advance-select/index.js +13 -0
- package/src/advance-select/use-advance-option.js +58 -0
- package/src/advance-select/use-advance-select.js +142 -0
- package/src/application-slot/application-slot.js +70 -0
- package/src/application-slot/breadcrumb-item.vue +12 -0
- package/src/application-slot/header-tools-item.vue +12 -0
- package/src/application-slot/index.js +17 -0
- package/src/breadcrumb-select/breadcrumb-select.vue +97 -0
- package/src/breadcrumb-select/index.js +6 -0
- package/src/components.js +39 -0
- package/src/contextmenu/contextmenu-item.vue +13 -0
- package/src/contextmenu/contextmenu.vue +56 -0
- package/src/contextmenu/index.js +11 -0
- package/src/contextmenu/use-contextmenu.js +117 -0
- package/src/data-form/data-form-item.vue +49 -0
- package/src/data-form/data-form.vue +212 -0
- package/src/data-form/dynamic-component.js +24 -0
- package/src/data-form/form-components/Blots/AtBlot.js +32 -0
- package/src/data-form/form-components/bwa-date-picker.vue +43 -0
- package/src/data-form/form-components/bwa-date-time-picker.vue +49 -0
- package/src/data-form/form-components/bwa-input-float.vue +41 -0
- package/src/data-form/form-components/bwa-input-integer.vue +58 -0
- package/src/data-form/form-components/bwa-input.vue +32 -0
- package/src/data-form/form-components/bwa-multi-select.vue +27 -0
- package/src/data-form/form-components/bwa-rich-text-tinymce.vue +561 -0
- package/src/data-form/form-components/bwa-rich-text.vue +395 -0
- package/src/data-form/form-components/bwa-select.vue +67 -0
- package/src/data-form/form-components/bwa-textarea.vue +28 -0
- package/src/data-form/form-components/bwa-upload.vue +145 -0
- package/src/data-form/form-components/bwa-user-multi-select.vue +25 -0
- package/src/data-form/form-components/bwa-user-select.vue +81 -0
- package/src/data-form/index.js +35 -0
- package/src/data-table/data-column-view.vue +131 -0
- package/src/data-table/data-table-card.vue +81 -0
- package/src/data-table/data-table-column.vue +52 -0
- package/src/data-table/data-table.vue +426 -0
- package/src/data-table/dynamic-component.js +58 -0
- package/src/data-table/index.js +13 -0
- package/src/data-table/use-datatable-drag.js +156 -0
- package/src/datatable-settings/datatable-settings.vue +323 -0
- package/src/datatable-settings/index.js +6 -0
- package/src/date-range/date-picker.vue +115 -0
- package/src/date-range/date-range.vue +202 -0
- package/src/date-range/index.js +6 -0
- package/src/drag-list/constants.js +1 -0
- package/src/drag-list/drag-item.vue +46 -0
- package/src/drag-list/drag-list.vue +50 -0
- package/src/drag-list/index.js +6 -0
- package/src/drag-list/use-drag-list.js +209 -0
- package/src/dragable/constants.js +3 -0
- package/src/dragable/dragable-item.vue +19 -0
- package/src/dragable/dragable-operation.vue +28 -0
- package/src/dragable/dragable.vue +26 -0
- package/src/dragable/index.js +14 -0
- package/src/dragable/use-dragable.js +227 -0
- package/src/filter-panel/conditions/condition.js +35 -0
- package/src/filter-panel/conditions/date-range-condition.vue +35 -0
- package/src/filter-panel/conditions/department-condition/data.json +29537 -0
- package/src/filter-panel/conditions/department-condition/department-condition.vue +92 -0
- package/src/filter-panel/conditions/department-condition/department-node.vue +52 -0
- package/src/filter-panel/conditions/index.js +22 -0
- package/src/filter-panel/conditions/input-condition.vue +63 -0
- package/src/filter-panel/conditions/multi-user-condition.vue +56 -0
- package/src/filter-panel/conditions/multiple-menu-condition.vue +45 -0
- package/src/filter-panel/conditions/single-menu-condition.vue +58 -0
- package/src/filter-panel/conditions/single-user-condition.vue +56 -0
- package/src/filter-panel/filter-panel-item.vue +46 -0
- package/src/filter-panel/filter-panel.vue +149 -0
- package/src/filter-panel/index.js +17 -0
- package/src/filter-panel/use-filter-panel-item.js +59 -0
- package/src/filter-panel/use-filter-panel.js +203 -0
- package/src/hooks/use-data/index.js +234 -0
- package/src/index.js +48 -0
- package/src/layout/index.js +6 -0
- package/src/layout/layout.vue +74 -0
- package/src/make-installer.js +36 -0
- package/src/math/Rectangle.js +28 -0
- package/src/menu/index.js +6 -0
- package/src/menu/menu-item.vue +41 -0
- package/src/menu/menu.vue +53 -0
- package/src/panel/index.js +6 -0
- package/src/panel/panel.vue +42 -0
- package/src/panel-tabs/index.js +6 -0
- package/src/panel-tabs/panel-tabs.js +92 -0
- package/src/pct-filter-panel/index.js +10 -0
- package/src/pct-filter-panel/pct-compents/index.js +10 -0
- package/src/pct-filter-panel/pct-compents/pct-Input-condition.vue +63 -0
- package/src/pct-filter-panel/pct-compents/pct-date-range-condition.vue +60 -0
- package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +177 -0
- package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue +142 -0
- package/src/pct-filter-panel/pct-filter-panel-item.vue +46 -0
- package/src/pct-filter-panel/pct-filter-panel.vue +201 -0
- package/src/pct-filter-panel/use-filter-panel-item.js +61 -0
- package/src/pct-filter-panel/use-filter-panel.js +206 -0
- package/src/plugins.js +3 -0
- package/src/progress/index.js +8 -0
- package/src/progress/progress-item.vue +81 -0
- package/src/progress/progress.vue +58 -0
- package/src/progress/use-progress.js +66 -0
- package/src/utils/db.js +8 -0
- package/src/utils.js +263 -0
- package/src/where-filter-panel/index.js +0 -0
- package/src/where-filter-panel/use-where-filter-panel.js +28 -0
- package/src/where-filter-panel/where-filter-panel.vue +9 -0
- package/style/advance-select.scss +316 -0
- package/style/breadcrumb-select.scss +80 -0
- package/style/common/var.scss +240 -0
- package/style/common.scss +48 -0
- package/style/contextmenu.scss +58 -0
- package/style/data-form.scss +35 -0
- package/style/data-table.scss +81 -0
- package/style/datatable-settings.scss +125 -0
- package/style/date-range.scss +136 -0
- package/style/department-condition.scss +39 -0
- package/style/drag-list.scss +68 -0
- package/style/dragable.scss +8 -0
- package/style/filter-panel.scss +199 -0
- package/style/index.scss +22 -0
- package/style/input-condition.scss +30 -0
- package/style/layout.scss +70 -0
- package/style/menu.scss +184 -0
- package/style/mixins/_var.scss +21 -0
- package/style/mixins/config.scss +4 -0
- package/style/mixins/function.scss +62 -0
- package/style/mixins/mixins.scss +88 -0
- package/style/panel-tabs.scss +60 -0
- package/style/panel.scss +110 -0
- package/style/pct-filter-panel.scss +306 -0
- package/style/progress.scss +122 -0
- package/style/rich-text.scss +30 -0
- package/style/theme/theme.scss +161 -0
- package/style/theme/var.scss +34 -0
- package/style/var.scss +21 -0
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ctzy-web-client/plugin-component-vue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "lib/index.js",
|
|
5
|
+
"module": "es/index.mjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"require": "./lib/index.js",
|
|
9
|
+
"import": "./es/index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"./src": "./src/index.js",
|
|
12
|
+
"./src/*": "./src/*",
|
|
13
|
+
"./es": "./es/index.mjs",
|
|
14
|
+
"./lib": "./lib/index.js",
|
|
15
|
+
"./es/*": "./es/*",
|
|
16
|
+
"./lib/*": "./lib/*",
|
|
17
|
+
"./style": "./style/index.css",
|
|
18
|
+
"./style/*": "./style/*",
|
|
19
|
+
"./style/src": "./style/src/index.scss",
|
|
20
|
+
"./style/src/*": "./style/src/*"
|
|
21
|
+
},
|
|
22
|
+
"style": "./style/index.css",
|
|
23
|
+
"author": "tommy",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"description": "web client 通用ui库",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@element-plus/icons": "^0.0.11",
|
|
28
|
+
"@tinymce/tinymce-vue": "^5",
|
|
29
|
+
"dayjs": "^1.11.6",
|
|
30
|
+
"dexie": "^3.2.3",
|
|
31
|
+
"element-plus": "^2.3.5",
|
|
32
|
+
"lodash": "^4.17.21",
|
|
33
|
+
"quill": "^1.3.7",
|
|
34
|
+
"rxjs": "^7.6.0",
|
|
35
|
+
"tinymce": "^6.4.2",
|
|
36
|
+
"web-base-client-vue": "^1.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@vueuse/core": "^9.6.0",
|
|
40
|
+
"vue": "^3.2.41",
|
|
41
|
+
"vue-router": "^4.1.6"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="[ns.be('select', 'operation'), ns.is('border', border)]"
|
|
4
|
+
@click="clickHandle"
|
|
5
|
+
>
|
|
6
|
+
<slot></slot>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup>
|
|
11
|
+
import { inject } from 'vue';
|
|
12
|
+
import { useNamespace, advanceSelectKey } from 'web-base-client-vue';
|
|
13
|
+
|
|
14
|
+
defineOptions({
|
|
15
|
+
name: 'BwaAdvanceOperation',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
border: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
type: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'button',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const emit = defineEmits(['click']);
|
|
30
|
+
|
|
31
|
+
const advanceSelect = inject(advanceSelectKey);
|
|
32
|
+
|
|
33
|
+
const clickHandle = () => {
|
|
34
|
+
if (props.type !== 'button') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
advanceSelect.hidePoppper();
|
|
39
|
+
|
|
40
|
+
emit('click');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const ns = useNamespace('advance');
|
|
44
|
+
</script>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="ns.b('option')" @click.stop="filterOptionClick">
|
|
3
|
+
<!-- @mouseenter="handleOptionMouseEnter" -->
|
|
4
|
+
<div :class="`${ns.be('option', 'content')} content-label-${value}`">
|
|
5
|
+
<slot>
|
|
6
|
+
<ElTooltip placement="top" append-to=".bwa-application" :disabled="currentLabel.length < 16">
|
|
7
|
+
<div :class="ns.be('option', 'content-label')" ref="contentText">
|
|
8
|
+
<ElCheckbox
|
|
9
|
+
v-if="source === 'pct' && !showSelectIcon"
|
|
10
|
+
@click.prevent
|
|
11
|
+
:class="ns.be('filter', 'checkbox')"
|
|
12
|
+
:modelValue="itemSelected"
|
|
13
|
+
style="height: 26px"
|
|
14
|
+
>
|
|
15
|
+
<div :class="ns.be('option', 'content-label')" style="width: 178px">{{ currentLabel }}</div>
|
|
16
|
+
</ElCheckbox>
|
|
17
|
+
<div v-else :class="[ns.be('option', 'content-label'), ns.is('selected',source === 'pct' && itemSelected && showSelectIcon)]">{{ currentLabel }}</div>
|
|
18
|
+
</div>
|
|
19
|
+
<template #content>
|
|
20
|
+
{{ currentLabel }}
|
|
21
|
+
</template>
|
|
22
|
+
</ElTooltip>
|
|
23
|
+
</slot>
|
|
24
|
+
</div>
|
|
25
|
+
<ElIcon
|
|
26
|
+
v-if="itemSelected && showSelectIcon"
|
|
27
|
+
:class="ns.be('option', 'selected')"
|
|
28
|
+
>
|
|
29
|
+
<Select />
|
|
30
|
+
</ElIcon>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import { ElTooltip } from 'element-plus';
|
|
36
|
+
import { getCurrentInstance, toRefs, ref, nextTick, onMounted, onUnmounted } from 'vue';
|
|
37
|
+
import { useNamespace } from 'web-base-client-vue';
|
|
38
|
+
import { useEvent } from './events-helpers';
|
|
39
|
+
import { useAdvanceOption } from './use-advance-option';
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
name: 'BwaAdvanceOption',
|
|
43
|
+
props: {
|
|
44
|
+
label: {
|
|
45
|
+
type: [String, Number, Boolean],
|
|
46
|
+
},
|
|
47
|
+
value: {
|
|
48
|
+
type: null,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
expose: ['currentLabel'],
|
|
52
|
+
setup(props, { expose }) {
|
|
53
|
+
const instance = getCurrentInstance();
|
|
54
|
+
|
|
55
|
+
const ns = useNamespace('advance');
|
|
56
|
+
|
|
57
|
+
const { handleOptionMouseEnter } = useEvent(ns);
|
|
58
|
+
|
|
59
|
+
const { advanceSelect, currentLabel, itemSelected, showSelectIcon, source } =
|
|
60
|
+
useAdvanceOption(props);
|
|
61
|
+
|
|
62
|
+
const show = ref(true)
|
|
63
|
+
const clickFlag = ref(true)
|
|
64
|
+
|
|
65
|
+
const contentText = ref()
|
|
66
|
+
|
|
67
|
+
expose({ currentLabel });
|
|
68
|
+
|
|
69
|
+
const filterOptionClick = () => {
|
|
70
|
+
advanceSelect.handleOptionSelect(instance.proxy);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 判断是否需要展示tooltip
|
|
74
|
+
const isShow = async () => {
|
|
75
|
+
const dom = document.querySelector(`.content-label-${props.value} .bwa-advance-option__content-label`);
|
|
76
|
+
if (dom) {
|
|
77
|
+
const scrollWidth = document.querySelector(`.content-label-${props.value} .bwa-advance-option__content-label`).scrollWidth;
|
|
78
|
+
const offsetWidth = document.querySelector(`.content-label-${props.value} .bwa-advance-option__content-label`).offsetWidth;
|
|
79
|
+
if (scrollWidth > offsetWidth) {
|
|
80
|
+
show.value = false
|
|
81
|
+
} else {
|
|
82
|
+
show.value = true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const listenerClickFunction = () => {
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
isShow();
|
|
90
|
+
}, 100)
|
|
91
|
+
}
|
|
92
|
+
// onMounted(async () => {
|
|
93
|
+
// if (clickFlag) {
|
|
94
|
+
// document.querySelector('.bwa-advance-select button')?.addEventListener('click', listenerClickFunction)
|
|
95
|
+
// clickFlag.value = false
|
|
96
|
+
// }
|
|
97
|
+
// })
|
|
98
|
+
|
|
99
|
+
// onUnmounted(() => {
|
|
100
|
+
// document.querySelector('.bwa-advance-select button').removeEventListener('click', listenerClickFunction)
|
|
101
|
+
// })
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
show,
|
|
105
|
+
ns,
|
|
106
|
+
currentLabel,
|
|
107
|
+
itemSelected,
|
|
108
|
+
showSelectIcon,
|
|
109
|
+
filterOptionClick,
|
|
110
|
+
handleOptionMouseEnter,
|
|
111
|
+
source
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
</script>
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="ns.b('select')" data-prefix="el" ref="selectWrapper">
|
|
3
|
+
<ElTooltip
|
|
4
|
+
:class="ns.be('select', 'tooltip')"
|
|
5
|
+
effect="light"
|
|
6
|
+
trigger="click"
|
|
7
|
+
placement="bottom-start"
|
|
8
|
+
:show-arrow="false"
|
|
9
|
+
append-to=".bwa-application"
|
|
10
|
+
:popper-style="popperStyle"
|
|
11
|
+
:popper-class="ns.be('select', 'popper')"
|
|
12
|
+
:persistent="true"
|
|
13
|
+
v-model:visible="isShowPopper"
|
|
14
|
+
:virtual-ref="virtualRef"
|
|
15
|
+
:virtual-triggering="virtualTriggering"
|
|
16
|
+
>
|
|
17
|
+
<template #default>
|
|
18
|
+
<slot name="reference" :label="selectedLabel" :column="column">
|
|
19
|
+
<div
|
|
20
|
+
:class="[
|
|
21
|
+
ns.be('select', 'pct-reference'),
|
|
22
|
+
ns.is('active', isShowPopper),
|
|
23
|
+
]"
|
|
24
|
+
v-if="source"
|
|
25
|
+
>
|
|
26
|
+
<slot
|
|
27
|
+
name="reference-content"
|
|
28
|
+
:label="selectedLabel"
|
|
29
|
+
:column="column"
|
|
30
|
+
:selected="selected"
|
|
31
|
+
>
|
|
32
|
+
<slot name="label">
|
|
33
|
+
<span v-if="column" :class="ns.be('select', 'label')">
|
|
34
|
+
{{ column.title }}
|
|
35
|
+
</span>
|
|
36
|
+
</slot>
|
|
37
|
+
<slot name="value" :selected="selected">
|
|
38
|
+
<span v-if="multiple" :class="ns.be('select', 'content')">
|
|
39
|
+
{{ selectedLabel.length ? selectedLabel.join(',') : '全部' }}
|
|
40
|
+
</span>
|
|
41
|
+
<span v-else :class="ns.be('select', 'content')">
|
|
42
|
+
{{ selectedLabel ? selectedLabel : '全部' }}
|
|
43
|
+
</span>
|
|
44
|
+
</slot>
|
|
45
|
+
<ElIcon :class="ns.be('select', 'caret')" v-if="showSelectIcon">
|
|
46
|
+
<slot name="icon">
|
|
47
|
+
<CaretBottom />
|
|
48
|
+
</slot>
|
|
49
|
+
</ElIcon>
|
|
50
|
+
</slot>
|
|
51
|
+
</div>
|
|
52
|
+
<div
|
|
53
|
+
:class="[
|
|
54
|
+
ns.be('select', 'reference'),
|
|
55
|
+
ns.is('active', isShowPopper),
|
|
56
|
+
]"
|
|
57
|
+
v-else
|
|
58
|
+
>
|
|
59
|
+
<slot
|
|
60
|
+
name="reference-content"
|
|
61
|
+
:label="selectedLabel"
|
|
62
|
+
:column="column"
|
|
63
|
+
:selected="selected"
|
|
64
|
+
>
|
|
65
|
+
<slot name="label">
|
|
66
|
+
<span v-if="column" :class="ns.be('select', 'label')">
|
|
67
|
+
{{ column.title }}
|
|
68
|
+
</span>
|
|
69
|
+
</slot>
|
|
70
|
+
<slot name="value" :selected="selected">
|
|
71
|
+
<span v-if="multiple" :class="ns.be('select', 'content')">
|
|
72
|
+
{{ selectedLabel.length ? selectedLabel.join(',') : '全部' }}
|
|
73
|
+
</span>
|
|
74
|
+
<span v-else :class="ns.be('select', 'content')">
|
|
75
|
+
{{ selectedLabel ? selectedLabel : '全部' }}
|
|
76
|
+
</span>
|
|
77
|
+
</slot>
|
|
78
|
+
</slot>
|
|
79
|
+
<ElIcon :class="ns.be('select', 'caret')" v-if="showSelectIcon">
|
|
80
|
+
<slot name="icon">
|
|
81
|
+
<CaretBottom />
|
|
82
|
+
</slot>
|
|
83
|
+
</ElIcon>
|
|
84
|
+
</div>
|
|
85
|
+
</slot>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<template #content>
|
|
89
|
+
<div :class="[ns.be('select', 'content'), ns.is('single', !multiple)]" :style="{'margin': '6px'}">
|
|
90
|
+
<slot name="contentTop"> </slot>
|
|
91
|
+
<div v-if="showSearch" :class="ns.be('select', 'input-wrapper')">
|
|
92
|
+
<ElInput
|
|
93
|
+
v-model="search"
|
|
94
|
+
:class="ns.be('select', 'input')"
|
|
95
|
+
:placeholder="searchPlaceholder"
|
|
96
|
+
type="text"
|
|
97
|
+
prefix-icon="Search"
|
|
98
|
+
clearable
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<div :class="ns.be('select', 'operation-wrapper')">
|
|
102
|
+
<template v-if="multiple || !required">
|
|
103
|
+
<template v-if="showSelection">
|
|
104
|
+
<AdvanceOperation
|
|
105
|
+
:class="ns.be('select', 'selection-wrapper')"
|
|
106
|
+
type="selection"
|
|
107
|
+
:border="true"
|
|
108
|
+
>
|
|
109
|
+
<span
|
|
110
|
+
v-if="multiple"
|
|
111
|
+
:class="[
|
|
112
|
+
ns.be('select', 'selection'),
|
|
113
|
+
ns.is('has-selected', !!selected.length),
|
|
114
|
+
]"
|
|
115
|
+
>
|
|
116
|
+
已选{{ selected.length }}项
|
|
117
|
+
</span>
|
|
118
|
+
<ElButton
|
|
119
|
+
v-if="!required"
|
|
120
|
+
link
|
|
121
|
+
type="primary"
|
|
122
|
+
:class="ns.be('select', 'clear')"
|
|
123
|
+
@click="handleClearClick"
|
|
124
|
+
>
|
|
125
|
+
清除选项
|
|
126
|
+
</ElButton>
|
|
127
|
+
</AdvanceOperation>
|
|
128
|
+
</template>
|
|
129
|
+
</template>
|
|
130
|
+
|
|
131
|
+
<slot name="operation"> </slot>
|
|
132
|
+
</div>
|
|
133
|
+
<div :class="ns.be('select', 'list')" v-loading="loading">
|
|
134
|
+
<ElScrollbar :max-height="listHeight">
|
|
135
|
+
<slot>
|
|
136
|
+
<AdvanceOption
|
|
137
|
+
v-for="item in data"
|
|
138
|
+
:key="item.value"
|
|
139
|
+
:value="item.value"
|
|
140
|
+
:label="item.label"
|
|
141
|
+
/>
|
|
142
|
+
</slot>
|
|
143
|
+
</ElScrollbar>
|
|
144
|
+
<template v-if="!optionsCount">
|
|
145
|
+
<slot name="empy">
|
|
146
|
+
<div :class="ns.be('select', 'empty')">未匹配到相关条目</div>
|
|
147
|
+
</slot>
|
|
148
|
+
</template>
|
|
149
|
+
</div>
|
|
150
|
+
<div v-if="slots.contentBottom"
|
|
151
|
+
:class="ns.be('select', 'bottom')"
|
|
152
|
+
:style="{'boxShadow': source ? 'none': '', 'padding': source ? '0': '4px 0px',}"
|
|
153
|
+
>
|
|
154
|
+
<slot name="contentBottom"> </slot>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
</template>
|
|
158
|
+
</ElTooltip>
|
|
159
|
+
</div>
|
|
160
|
+
</template>
|
|
161
|
+
|
|
162
|
+
<script setup>
|
|
163
|
+
import { debounceTime, Observable } from 'rxjs';
|
|
164
|
+
import {
|
|
165
|
+
reactive,
|
|
166
|
+
toRefs,
|
|
167
|
+
provide,
|
|
168
|
+
inject,
|
|
169
|
+
computed,
|
|
170
|
+
useSlots,
|
|
171
|
+
unref,
|
|
172
|
+
watch,
|
|
173
|
+
onBeforeUnmount,
|
|
174
|
+
getCurrentInstance,
|
|
175
|
+
} from 'vue';
|
|
176
|
+
import {
|
|
177
|
+
useNamespace,
|
|
178
|
+
advanceSelectKey,
|
|
179
|
+
filterPanelItemKey,
|
|
180
|
+
useGlobalConfig,
|
|
181
|
+
} from 'web-base-client-vue';
|
|
182
|
+
import { useData, dataProps } from '../hooks/use-data';
|
|
183
|
+
import AdvanceOperation from './advance-operation.vue';
|
|
184
|
+
import AdvanceOption from './advance-option.vue';
|
|
185
|
+
import { useAdvanceSelectStates, useAdvanceSelect } from './use-advance-select';
|
|
186
|
+
|
|
187
|
+
defineOptions({
|
|
188
|
+
name: 'BwaAdvanceSelect',
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const props = defineProps({
|
|
192
|
+
...dataProps,
|
|
193
|
+
options: {
|
|
194
|
+
type: Array,
|
|
195
|
+
},
|
|
196
|
+
modelValue: {
|
|
197
|
+
type: [Array, String, Number, Boolean],
|
|
198
|
+
},
|
|
199
|
+
listHeight: {
|
|
200
|
+
type: String,
|
|
201
|
+
default: '300px',
|
|
202
|
+
},
|
|
203
|
+
width: {
|
|
204
|
+
type: String,
|
|
205
|
+
default: '240px',
|
|
206
|
+
},
|
|
207
|
+
multiple: {
|
|
208
|
+
type: Boolean,
|
|
209
|
+
default: true,
|
|
210
|
+
},
|
|
211
|
+
multipleLimit: {
|
|
212
|
+
type: Number,
|
|
213
|
+
default: 0,
|
|
214
|
+
},
|
|
215
|
+
required: {
|
|
216
|
+
type: Boolean,
|
|
217
|
+
default: false,
|
|
218
|
+
},
|
|
219
|
+
showSearch: {
|
|
220
|
+
type: Boolean,
|
|
221
|
+
default: true,
|
|
222
|
+
},
|
|
223
|
+
searchPlaceholder: {
|
|
224
|
+
type: String,
|
|
225
|
+
default: '',
|
|
226
|
+
},
|
|
227
|
+
showSelection: {
|
|
228
|
+
type: Boolean,
|
|
229
|
+
default: true,
|
|
230
|
+
},
|
|
231
|
+
showSelectIcon: {
|
|
232
|
+
type: Boolean,
|
|
233
|
+
default: true,
|
|
234
|
+
},
|
|
235
|
+
closeAfterSelection: {
|
|
236
|
+
typoe: Boolean,
|
|
237
|
+
default: false,
|
|
238
|
+
},
|
|
239
|
+
loading: {
|
|
240
|
+
type: Boolean,
|
|
241
|
+
default: false,
|
|
242
|
+
},
|
|
243
|
+
virtualRef: null,
|
|
244
|
+
virtualTriggering: {
|
|
245
|
+
type: Boolean,
|
|
246
|
+
default: false,
|
|
247
|
+
},
|
|
248
|
+
source: '',
|
|
249
|
+
borderRadius: {
|
|
250
|
+
type: String,
|
|
251
|
+
default: '0px',
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const emit = defineEmits(['update:modelValue', 'search', 'visible-change']);
|
|
256
|
+
|
|
257
|
+
const debounceDelay = useGlobalConfig('debounceDelay', 500);
|
|
258
|
+
|
|
259
|
+
const filterPanelItem = inject(filterPanelItemKey, null);
|
|
260
|
+
|
|
261
|
+
const { listHeight, width, showSearch, showSelection, multiple, modelValue, borderRadius } =
|
|
262
|
+
toRefs(props);
|
|
263
|
+
|
|
264
|
+
const slots = useSlots();
|
|
265
|
+
|
|
266
|
+
const ns = useNamespace('advance');
|
|
267
|
+
|
|
268
|
+
const states = useAdvanceSelectStates(props);
|
|
269
|
+
|
|
270
|
+
const {
|
|
271
|
+
options: optionInstances,
|
|
272
|
+
optionsCount,
|
|
273
|
+
search,
|
|
274
|
+
isShowPopper,
|
|
275
|
+
selected,
|
|
276
|
+
} = toRefs(states);
|
|
277
|
+
|
|
278
|
+
const column = computed(() => filterPanelItem?.column ?? null);
|
|
279
|
+
|
|
280
|
+
const {
|
|
281
|
+
selectedLabel,
|
|
282
|
+
onOptionCreate,
|
|
283
|
+
onOptionDestroy,
|
|
284
|
+
handleClearClick,
|
|
285
|
+
handleOptionSelect,
|
|
286
|
+
hidePoppper,
|
|
287
|
+
} = useAdvanceSelect(props, states, {
|
|
288
|
+
emit,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const disabled = computed(() => !unref(isShowPopper));
|
|
292
|
+
// console.log(column,disabled,search)
|
|
293
|
+
const { data: itfData, loading: dataLoading } = useData(disabled, search);
|
|
294
|
+
|
|
295
|
+
const loading = computed(() => props.loading || unref(dataLoading));
|
|
296
|
+
|
|
297
|
+
const data = computed(() => props.options || unref(itfData));
|
|
298
|
+
|
|
299
|
+
if (multiple.value && !Array.isArray(modelValue.value)) {
|
|
300
|
+
emit('update:modelValue', []);
|
|
301
|
+
}
|
|
302
|
+
if (!multiple.value && Array.isArray(modelValue.value)) {
|
|
303
|
+
emit('update:modelValue', '');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
watch(isShowPopper, (isShowPopper) => {
|
|
307
|
+
emit('visible-change', isShowPopper);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const subscription = new Observable((observer) =>
|
|
311
|
+
watch(search, observer.next.bind(observer))
|
|
312
|
+
)
|
|
313
|
+
.pipe(debounceTime(unref(debounceDelay)))
|
|
314
|
+
.subscribe(emit.bind(null, 'search'));
|
|
315
|
+
|
|
316
|
+
onBeforeUnmount(subscription.unsubscribe.bind(subscription));
|
|
317
|
+
|
|
318
|
+
provide(
|
|
319
|
+
advanceSelectKey,
|
|
320
|
+
reactive({
|
|
321
|
+
props,
|
|
322
|
+
options: optionInstances,
|
|
323
|
+
selected,
|
|
324
|
+
onOptionCreate,
|
|
325
|
+
onOptionDestroy,
|
|
326
|
+
handleOptionSelect,
|
|
327
|
+
hidePoppper,
|
|
328
|
+
select: getCurrentInstance(),
|
|
329
|
+
})
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
const popperStyle = reactive({
|
|
333
|
+
padding: '0',
|
|
334
|
+
borderRadius,
|
|
335
|
+
width,
|
|
336
|
+
border: 'none',
|
|
337
|
+
boxShadow: `0 3px 12px 0 rgb(0 0 0 / 12%), 0 0.5px 1.5px 0 rgb(0 0 0 / 8%)`,
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
defineExpose({
|
|
341
|
+
handleClearClick
|
|
342
|
+
})
|
|
343
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { inject } from 'vue';
|
|
2
|
+
import { advanceSelectKey } from 'web-base-client-vue';
|
|
3
|
+
import { getStyle } from 'element-plus/es/utils/index';
|
|
4
|
+
import { createTablePopper } from 'element-plus/es/components/table/src/util';
|
|
5
|
+
|
|
6
|
+
export function useEvent(ns) {
|
|
7
|
+
const { select: advanceSelect } = inject(advanceSelectKey, {});
|
|
8
|
+
|
|
9
|
+
const handleOptionMouseEnter = (event, tooltipEffect) => {
|
|
10
|
+
const content = event.target.querySelector(
|
|
11
|
+
'.' + ns.be('option', 'content')
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const range = document.createRange();
|
|
15
|
+
range.setStart(content, 0);
|
|
16
|
+
range.setEnd(content, content.childNodes.length);
|
|
17
|
+
const rangeWidth = range.getBoundingClientRect().width;
|
|
18
|
+
const padding =
|
|
19
|
+
(Number.parseInt(getStyle(content, 'paddingLeft'), 10) || 0) +
|
|
20
|
+
Number.parseInt(getStyle(content, 'paddingRight'), 10) || 0;
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
rangeWidth + padding > content.offsetWidth ||
|
|
24
|
+
content.scrollWidth > content.offsetWidth
|
|
25
|
+
) {
|
|
26
|
+
createTablePopper(
|
|
27
|
+
advanceSelect?.refs.selectWrapper,
|
|
28
|
+
content,
|
|
29
|
+
content.innerText || content.textContent,
|
|
30
|
+
{
|
|
31
|
+
placement: 'top',
|
|
32
|
+
strategy: 'fixed',
|
|
33
|
+
},
|
|
34
|
+
'dark'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return { handleOptionMouseEnter };
|
|
40
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { withInstall } from 'element-plus/es/utils/vue/install';
|
|
2
|
+
import AdvanceSelect from './advance-select.vue';
|
|
3
|
+
import AdvanceOption from './advance-option.vue';
|
|
4
|
+
import AdvanceOperation from './advance-operation.vue';
|
|
5
|
+
|
|
6
|
+
export const BwaAdvanceSelect = withInstall(AdvanceSelect, {
|
|
7
|
+
AdvanceOption,
|
|
8
|
+
AdvanceOperation,
|
|
9
|
+
});
|
|
10
|
+
export const BwaAdvanceOption = withInstall(AdvanceOption);
|
|
11
|
+
export const BwaAdvanceOperation = withInstall(AdvanceOperation);
|
|
12
|
+
|
|
13
|
+
export default BwaAdvanceSelect;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
getCurrentInstance,
|
|
4
|
+
inject,
|
|
5
|
+
onMounted,
|
|
6
|
+
onUnmounted,
|
|
7
|
+
watch,
|
|
8
|
+
} from 'vue';
|
|
9
|
+
import { advanceSelectKey } from 'web-base-client-vue';
|
|
10
|
+
|
|
11
|
+
export const useAdvanceOption = (props) => {
|
|
12
|
+
const advanceSelect = inject(advanceSelectKey);
|
|
13
|
+
|
|
14
|
+
const instance = getCurrentInstance();
|
|
15
|
+
|
|
16
|
+
const currentLabel = computed(() => props.label || props.value);
|
|
17
|
+
|
|
18
|
+
const showSelectIcon = computed(
|
|
19
|
+
() => advanceSelect?.props?.showSelectIcon ?? true
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const itemSelected = computed(() => {
|
|
23
|
+
if (!advanceSelect.props.multiple) {
|
|
24
|
+
return advanceSelect.props.modelValue === props.value || advanceSelect.props.modelValue === props.value + '';
|
|
25
|
+
} else {
|
|
26
|
+
return (advanceSelect.props.modelValue || []).includes(props.value);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 获取来源
|
|
32
|
+
* @type {ComputedRef<*>}
|
|
33
|
+
*/
|
|
34
|
+
const source = computed(() => {
|
|
35
|
+
return advanceSelect.props.source
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
watch(
|
|
40
|
+
() => props.value,
|
|
41
|
+
(val, oldVal) => {
|
|
42
|
+
if (!Object.is(val, oldVal)) {
|
|
43
|
+
advanceSelect.onOptionDestroy(oldVal, instance.proxy);
|
|
44
|
+
advanceSelect.onOptionCreate(instance.proxy);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
onMounted(() => {
|
|
50
|
+
advanceSelect.onOptionCreate(instance.proxy);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
onUnmounted(() => {
|
|
54
|
+
advanceSelect.onOptionDestroy(props.value, instance.proxy);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return { advanceSelect, itemSelected, currentLabel, showSelectIcon, source };
|
|
58
|
+
};
|