@smallwei/avue 3.8.1 → 3.8.3
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/README.md +206 -86
- package/dist/avue.js +37301 -0
- package/dist/avue.js.map +1 -0
- package/dist/avue.min.js +6 -0
- package/dist/avue.min.mjs +2 -0
- package/dist/avue.mjs +2 -0
- package/dist/index.css +1 -0
- package/es/avue.min.mjs +2 -0
- package/es/avue.min.ts +2 -0
- package/es/avue.mjs +2 -0
- package/es/avue.ts +2 -0
- package/es/core/create.mjs +8 -0
- package/es/core/create.ts +16 -0
- package/es/core/dataformat.mjs +184 -0
- package/es/core/dataformat.ts +190 -0
- package/es/core/detail.mjs +74 -0
- package/es/core/detail.ts +81 -0
- package/es/core/dic.mjs +213 -0
- package/es/core/dic.ts +235 -0
- package/es/core/locale.mjs +8 -0
- package/es/core/locale.ts +9 -0
- package/es/core/packages.mjs +61 -0
- package/es/core/packages.ts +62 -0
- package/es/core/slot.mjs +32 -0
- package/es/core/slot.ts +30 -0
- package/es/global/variable.mjs +80 -0
- package/es/global/variable.ts +84 -0
- package/es/icon.mjs +9 -0
- package/es/icon.ts +11 -0
- package/es/index.mjs +127 -0
- package/es/index.ts +177 -0
- package/es/locale/browser/en.mjs +288 -0
- package/es/locale/browser/zh-cn.mjs +288 -0
- package/es/locale/browser/zh.mjs +288 -0
- package/es/locale/index.mjs +141 -0
- package/es/locale/index.ts +196 -0
- package/es/locale/lang/en.mjs +282 -0
- package/es/locale/lang/en.ts +282 -0
- package/es/locale/lang/zh-cn.mjs +282 -0
- package/es/locale/lang/zh-cn.ts +282 -0
- package/es/locale/lang/zh.mjs +282 -0
- package/es/locale/lang/zh.ts +282 -0
- package/es/packages/core/common/event.mjs +58 -0
- package/es/packages/core/common/event.ts +56 -0
- package/es/packages/core/common/init.mjs +134 -0
- package/es/packages/core/common/init.ts +133 -0
- package/es/packages/core/common/props.mjs +239 -0
- package/es/packages/core/common/props.ts +240 -0
- package/es/packages/core/components/dialog-form/index.mjs +29 -0
- package/es/packages/core/components/dialog-form/index.ts +29 -0
- package/es/packages/core/components/dialog-form/index.vue +108 -0
- package/es/packages/core/components/form/custom.mjs +41 -0
- package/es/packages/core/components/form/custom.ts +41 -0
- package/es/packages/core/components/form/index.vue +176 -0
- package/es/packages/core/components/icon/index.vue +37 -0
- package/es/packages/core/components/image-preview/index.mjs +34 -0
- package/es/packages/core/components/image-preview/index.ts +37 -0
- package/es/packages/core/components/image-preview/index.vue +215 -0
- package/es/packages/core/directive/contextmenu.mjs +92 -0
- package/es/packages/core/directive/contextmenu.ts +103 -0
- package/es/packages/core/directive/permission.mjs +19 -0
- package/es/packages/core/directive/permission.ts +18 -0
- package/es/packages/data/box/index.vue +66 -0
- package/es/packages/data/card/index.vue +62 -0
- package/es/packages/data/cardText/index.vue +56 -0
- package/es/packages/data/countdown/index.vue +81 -0
- package/es/packages/data/dashboard/index.vue +72 -0
- package/es/packages/data/display/index.vue +63 -0
- package/es/packages/data/icons/index.vue +68 -0
- package/es/packages/data/imgText/index.vue +72 -0
- package/es/packages/data/list/index.vue +69 -0
- package/es/packages/data/notice/index.vue +63 -0
- package/es/packages/data/operaText/index.vue +62 -0
- package/es/packages/data/panel/index.vue +62 -0
- package/es/packages/data/pay/index.vue +92 -0
- package/es/packages/data/price/index.vue +55 -0
- package/es/packages/data/product/index.vue +106 -0
- package/es/packages/data/profile/index.vue +91 -0
- package/es/packages/data/progress/index.vue +64 -0
- package/es/packages/data/rank/index.vue +92 -0
- package/es/packages/data/rotate/index.vue +69 -0
- package/es/packages/data/statistic/index.vue +71 -0
- package/es/packages/data/tabs/index.vue +64 -0
- package/es/packages/data/task/index.vue +82 -0
- package/es/packages/data/weather/index.vue +103 -0
- package/es/packages/element-plus/array/index.vue +115 -0
- package/es/packages/element-plus/article/index.vue +73 -0
- package/es/packages/element-plus/card/index.vue +103 -0
- package/es/packages/element-plus/cascader/index.vue +132 -0
- package/es/packages/element-plus/chat/index.vue +513 -0
- package/es/packages/element-plus/checkbox/index.vue +84 -0
- package/es/packages/element-plus/comment/index.vue +76 -0
- package/es/packages/element-plus/count-up/index.vue +107 -0
- package/es/packages/element-plus/crud/column/column-default.vue +128 -0
- package/es/packages/element-plus/crud/column/column-dynamic.vue +86 -0
- package/es/packages/element-plus/crud/column/column-menu.vue +267 -0
- package/es/packages/element-plus/crud/column/column-slot.vue +348 -0
- package/es/packages/element-plus/crud/column/column.vue +119 -0
- package/es/packages/element-plus/crud/column/menu.vue +78 -0
- package/es/packages/element-plus/crud/config.mjs +74 -0
- package/es/packages/element-plus/crud/config.ts +74 -0
- package/es/packages/element-plus/crud/dialog/dialog-column.vue +102 -0
- package/es/packages/element-plus/crud/dialog/dialog-excel.vue +204 -0
- package/es/packages/element-plus/crud/dialog/dialog-filter.vue +159 -0
- package/es/packages/element-plus/crud/dialog/dialog-form.vue +352 -0
- package/es/packages/element-plus/crud/grid/index.vue +271 -0
- package/es/packages/element-plus/crud/grid/item.vue +39 -0
- package/es/packages/element-plus/crud/index.vue +1018 -0
- package/es/packages/element-plus/crud/menu/header-menu.vue +175 -0
- package/es/packages/element-plus/crud/menu/header-search.vue +228 -0
- package/es/packages/element-plus/crud/menu/table-page.vue +108 -0
- package/es/packages/element-plus/date/index.vue +81 -0
- package/es/packages/element-plus/draggable/index.vue +444 -0
- package/es/packages/element-plus/dynamic/index.vue +353 -0
- package/es/packages/element-plus/flow/index.vue +339 -0
- package/es/packages/element-plus/flow/node.vue +84 -0
- package/es/packages/element-plus/form/config.mjs +6 -0
- package/es/packages/element-plus/form/config.ts +6 -0
- package/es/packages/element-plus/form/index.vue +954 -0
- package/es/packages/element-plus/form/menu.vue +63 -0
- package/es/packages/element-plus/group/index.vue +90 -0
- package/es/packages/element-plus/input/index.vue +1264 -0
- package/es/packages/element-plus/input-color/index.vue +70 -0
- package/es/packages/element-plus/input-cron/index.vue +363 -0
- package/es/packages/element-plus/input-icon/index.vue +143 -0
- package/es/packages/element-plus/input-map/index.vue +311 -0
- package/es/packages/element-plus/input-number/index.vue +91 -0
- package/es/packages/element-plus/input-table/index.vue +279 -0
- package/es/packages/element-plus/input-tag/index.vue +79 -0
- package/es/packages/element-plus/input-tree/index.vue +194 -0
- package/es/packages/element-plus/license/index.vue +155 -0
- package/es/packages/element-plus/login/index.vue +203 -0
- package/es/packages/element-plus/mention/index.vue +117 -0
- package/es/packages/element-plus/radio/index.vue +38 -0
- package/es/packages/element-plus/rate/index.vue +51 -0
- package/es/packages/element-plus/search/index.vue +129 -0
- package/es/packages/element-plus/select/index.vue +292 -0
- package/es/packages/element-plus/sign/index.vue +230 -0
- package/es/packages/element-plus/slider/index.vue +66 -0
- package/es/packages/element-plus/switch/index.vue +72 -0
- package/es/packages/element-plus/tabs/index.vue +62 -0
- package/es/packages/element-plus/text-ellipsis/index.vue +104 -0
- package/es/packages/element-plus/time/index.vue +81 -0
- package/es/packages/element-plus/title/index.vue +30 -0
- package/es/packages/element-plus/tree/index.vue +460 -0
- package/es/packages/element-plus/upload/index.vue +728 -0
- package/es/packages/element-plus/verify/index.vue +62 -0
- package/es/packages/element-plus/video/index.vue +90 -0
- package/es/plugin/ali/index.mjs +4 -0
- package/es/plugin/ali/index.ts +6 -0
- package/es/plugin/clipboard/index.mjs +61 -0
- package/es/plugin/clipboard/index.ts +67 -0
- package/es/plugin/export/_blob.mjs +151 -0
- package/es/plugin/export/_blob.ts +176 -0
- package/es/plugin/export/_export2Excel.mjs +141 -0
- package/es/plugin/export/_export2Excel.ts +166 -0
- package/es/plugin/export/index.mjs +263 -0
- package/es/plugin/export/index.ts +274 -0
- package/es/plugin/logs/index.mjs +46 -0
- package/es/plugin/logs/index.ts +66 -0
- package/es/plugin/print/index.mjs +145 -0
- package/es/plugin/print/index.ts +155 -0
- package/es/plugin/qiniu/index.mjs +78 -0
- package/es/plugin/qiniu/index.ts +88 -0
- package/es/plugin/screenshot/index.mjs +8 -0
- package/es/plugin/screenshot/index.ts +9 -0
- package/es/plugin/video/index.mjs +52 -0
- package/es/plugin/video/index.ts +60 -0
- package/es/plugin/watermark/index.mjs +114 -0
- package/es/plugin/watermark/index.ts +127 -0
- package/es/plugin/watermark/watermark.mjs +109 -0
- package/es/plugin/watermark/watermark.ts +121 -0
- package/es/ui/data/index.mjs +49 -0
- package/es/ui/data/index.ts +51 -0
- package/es/ui/element-plus/index.mjs +87 -0
- package/es/ui/element-plus/index.ts +89 -0
- package/es/ui/index.mjs +4 -0
- package/es/ui/index.ts +6 -0
- package/es/utils/bem.mjs +29 -0
- package/es/utils/bem.ts +36 -0
- package/es/utils/mock.mjs +137 -0
- package/es/utils/mock.ts +151 -0
- package/es/utils/util.mjs +370 -0
- package/es/utils/util.ts +392 -0
- package/es/utils/validate.mjs +18 -0
- package/es/utils/validate.ts +23 -0
- package/es/version.mjs +1 -0
- package/es/version.ts +1 -0
- package/lib/avue.js +11 -31398
- package/lib/avue.min.js +11 -6
- package/lib/avue.min.ts +2 -0
- package/lib/avue.ts +2 -0
- package/lib/core/create.js +14 -0
- package/lib/core/create.ts +16 -0
- package/lib/core/dataformat.js +194 -0
- package/lib/core/dataformat.ts +190 -0
- package/lib/core/detail.js +81 -0
- package/lib/core/detail.ts +81 -0
- package/lib/core/dic.js +220 -0
- package/lib/core/dic.ts +235 -0
- package/lib/core/locale.js +10 -0
- package/lib/core/locale.ts +9 -0
- package/lib/core/packages.js +66 -0
- package/lib/core/packages.ts +62 -0
- package/lib/core/slot.js +34 -0
- package/lib/core/slot.ts +30 -0
- package/lib/global/variable.js +83 -0
- package/lib/global/variable.ts +84 -0
- package/lib/icon.js +44 -0
- package/lib/icon.ts +11 -0
- package/lib/index.css +1 -1
- package/lib/index.js +134 -0
- package/lib/index.ts +177 -0
- package/lib/locale/browser/en.js +288 -0
- package/lib/locale/browser/zh-cn.js +288 -0
- package/lib/locale/browser/zh.js +288 -0
- package/lib/locale/index.js +153 -47
- package/lib/locale/index.ts +196 -0
- package/lib/locale/lang/en.js +284 -100
- package/lib/locale/lang/en.ts +282 -0
- package/lib/locale/lang/zh-cn.js +284 -0
- package/lib/locale/lang/zh-cn.ts +282 -0
- package/lib/locale/lang/zh.js +284 -100
- package/lib/locale/lang/zh.ts +282 -0
- package/lib/packages/core/common/event.js +61 -0
- package/lib/packages/core/common/event.ts +56 -0
- package/lib/packages/core/common/init.js +140 -0
- package/lib/packages/core/common/init.ts +133 -0
- package/lib/packages/core/common/props.js +245 -0
- package/lib/packages/core/common/props.ts +240 -0
- package/lib/packages/core/components/dialog-form/index.js +35 -0
- package/lib/packages/core/components/dialog-form/index.ts +29 -0
- package/lib/packages/core/components/dialog-form/index.vue +108 -0
- package/lib/packages/core/components/form/custom.js +43 -0
- package/lib/packages/core/components/form/custom.ts +41 -0
- package/lib/packages/core/components/form/index.vue +176 -0
- package/lib/packages/core/components/icon/index.vue +37 -0
- package/lib/packages/core/components/image-preview/index.js +40 -0
- package/lib/packages/core/components/image-preview/index.ts +37 -0
- package/lib/packages/core/components/image-preview/index.vue +215 -0
- package/lib/packages/core/directive/contextmenu.js +94 -0
- package/lib/packages/core/directive/contextmenu.ts +103 -0
- package/lib/packages/core/directive/permission.js +21 -0
- package/lib/packages/core/directive/permission.ts +18 -0
- package/lib/packages/data/box/index.vue +66 -0
- package/lib/packages/data/card/index.vue +62 -0
- package/lib/packages/data/cardText/index.vue +56 -0
- package/lib/packages/data/countdown/index.vue +81 -0
- package/lib/packages/data/dashboard/index.vue +72 -0
- package/lib/packages/data/display/index.vue +63 -0
- package/lib/packages/data/icons/index.vue +68 -0
- package/lib/packages/data/imgText/index.vue +72 -0
- package/lib/packages/data/list/index.vue +69 -0
- package/lib/packages/data/notice/index.vue +63 -0
- package/lib/packages/data/operaText/index.vue +62 -0
- package/lib/packages/data/panel/index.vue +62 -0
- package/lib/packages/data/pay/index.vue +92 -0
- package/lib/packages/data/price/index.vue +55 -0
- package/lib/packages/data/product/index.vue +106 -0
- package/lib/packages/data/profile/index.vue +91 -0
- package/lib/packages/data/progress/index.vue +64 -0
- package/lib/packages/data/rank/index.vue +92 -0
- package/lib/packages/data/rotate/index.vue +69 -0
- package/lib/packages/data/statistic/index.vue +71 -0
- package/lib/packages/data/tabs/index.vue +64 -0
- package/lib/packages/data/task/index.vue +82 -0
- package/lib/packages/data/weather/index.vue +103 -0
- package/lib/packages/element-plus/array/index.vue +115 -0
- package/lib/packages/element-plus/article/index.vue +73 -0
- package/lib/packages/element-plus/card/index.vue +103 -0
- package/lib/packages/element-plus/cascader/index.vue +132 -0
- package/lib/packages/element-plus/chat/index.vue +513 -0
- package/lib/packages/element-plus/checkbox/index.vue +84 -0
- package/lib/packages/element-plus/comment/index.vue +76 -0
- package/lib/packages/element-plus/count-up/index.vue +107 -0
- package/lib/packages/element-plus/crud/column/column-default.vue +128 -0
- package/lib/packages/element-plus/crud/column/column-dynamic.vue +86 -0
- package/lib/packages/element-plus/crud/column/column-menu.vue +267 -0
- package/lib/packages/element-plus/crud/column/column-slot.vue +348 -0
- package/lib/packages/element-plus/crud/column/column.vue +119 -0
- package/lib/packages/element-plus/crud/column/menu.vue +78 -0
- package/lib/packages/element-plus/crud/config.js +76 -0
- package/lib/packages/element-plus/crud/config.ts +74 -0
- package/lib/packages/element-plus/crud/dialog/dialog-column.vue +102 -0
- package/lib/packages/element-plus/crud/dialog/dialog-excel.vue +204 -0
- package/lib/packages/element-plus/crud/dialog/dialog-filter.vue +159 -0
- package/lib/packages/element-plus/crud/dialog/dialog-form.vue +352 -0
- package/lib/packages/element-plus/crud/grid/index.vue +271 -0
- package/lib/packages/element-plus/crud/grid/item.vue +39 -0
- package/lib/packages/element-plus/crud/index.vue +1018 -0
- package/lib/packages/element-plus/crud/menu/header-menu.vue +175 -0
- package/lib/packages/element-plus/crud/menu/header-search.vue +228 -0
- package/lib/packages/element-plus/crud/menu/table-page.vue +108 -0
- package/lib/packages/element-plus/date/index.vue +81 -0
- package/lib/packages/element-plus/draggable/index.vue +444 -0
- package/lib/packages/element-plus/dynamic/index.vue +353 -0
- package/lib/packages/element-plus/flow/index.vue +339 -0
- package/lib/packages/element-plus/flow/node.vue +84 -0
- package/lib/packages/element-plus/form/config.js +8 -0
- package/lib/packages/element-plus/form/config.ts +6 -0
- package/lib/packages/element-plus/form/index.vue +954 -0
- package/lib/packages/element-plus/form/menu.vue +63 -0
- package/lib/packages/element-plus/group/index.vue +90 -0
- package/lib/packages/element-plus/input/index.vue +1264 -0
- package/lib/packages/element-plus/input-color/index.vue +70 -0
- package/lib/packages/element-plus/input-cron/index.vue +363 -0
- package/lib/packages/element-plus/input-icon/index.vue +143 -0
- package/lib/packages/element-plus/input-map/index.vue +311 -0
- package/lib/packages/element-plus/input-number/index.vue +91 -0
- package/lib/packages/element-plus/input-table/index.vue +279 -0
- package/lib/packages/element-plus/input-tag/index.vue +79 -0
- package/lib/packages/element-plus/input-tree/index.vue +194 -0
- package/lib/packages/element-plus/license/index.vue +155 -0
- package/lib/packages/element-plus/login/index.vue +203 -0
- package/lib/packages/element-plus/mention/index.vue +117 -0
- package/lib/packages/element-plus/radio/index.vue +38 -0
- package/lib/packages/element-plus/rate/index.vue +51 -0
- package/lib/packages/element-plus/search/index.vue +129 -0
- package/lib/packages/element-plus/select/index.vue +292 -0
- package/lib/packages/element-plus/sign/index.vue +230 -0
- package/lib/packages/element-plus/slider/index.vue +66 -0
- package/lib/packages/element-plus/switch/index.vue +72 -0
- package/lib/packages/element-plus/tabs/index.vue +62 -0
- package/lib/packages/element-plus/text-ellipsis/index.vue +104 -0
- package/lib/packages/element-plus/time/index.vue +81 -0
- package/lib/packages/element-plus/title/index.vue +30 -0
- package/lib/packages/element-plus/tree/index.vue +460 -0
- package/lib/packages/element-plus/upload/index.vue +728 -0
- package/lib/packages/element-plus/verify/index.vue +62 -0
- package/lib/packages/element-plus/video/index.vue +90 -0
- package/lib/plugin/ali/index.js +8 -0
- package/lib/plugin/ali/index.ts +6 -0
- package/lib/plugin/clipboard/index.js +64 -0
- package/lib/plugin/clipboard/index.ts +67 -0
- package/lib/plugin/export/_blob.js +151 -0
- package/lib/plugin/export/_blob.ts +176 -0
- package/lib/plugin/export/_export2Excel.js +145 -0
- package/lib/plugin/export/_export2Excel.ts +166 -0
- package/lib/plugin/export/index.js +268 -0
- package/lib/plugin/export/index.ts +274 -0
- package/lib/plugin/logs/index.js +48 -0
- package/lib/plugin/logs/index.ts +66 -0
- package/lib/plugin/print/index.js +147 -0
- package/lib/plugin/print/index.ts +155 -0
- package/lib/plugin/qiniu/index.js +82 -0
- package/lib/plugin/qiniu/index.ts +88 -0
- package/lib/plugin/screenshot/index.js +14 -0
- package/lib/plugin/screenshot/index.ts +9 -0
- package/lib/plugin/video/index.js +55 -0
- package/lib/plugin/video/index.ts +60 -0
- package/lib/plugin/watermark/index.js +121 -0
- package/lib/plugin/watermark/index.ts +127 -0
- package/lib/plugin/watermark/watermark.js +111 -0
- package/lib/plugin/watermark/watermark.ts +121 -0
- package/lib/ui/data/index.js +54 -0
- package/lib/ui/data/index.ts +51 -0
- package/lib/ui/element-plus/index.js +92 -0
- package/lib/ui/element-plus/index.ts +89 -0
- package/lib/ui/index.js +9 -0
- package/lib/ui/index.ts +6 -0
- package/lib/utils/bem.js +31 -0
- package/lib/utils/bem.ts +36 -0
- package/lib/utils/mock.js +142 -0
- package/lib/utils/mock.ts +151 -0
- package/lib/utils/util.js +403 -0
- package/lib/utils/util.ts +392 -0
- package/lib/utils/validate.js +21 -0
- package/lib/utils/validate.ts +23 -0
- package/lib/version.js +4 -0
- package/lib/version.ts +1 -0
- package/package.json +24 -11
- package/types/index.d.ts +141 -0
- package/types/shims-aliases.d.ts +4 -0
- package/types/shims-vue.d.ts +6 -0
- package/lib/avue.js.map +0 -1
- package/lib/locale/format.js +0 -44
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="b()">
|
|
3
|
+
<div :class="b('filter')"
|
|
4
|
+
v-if="validData(option.filter,true)">
|
|
5
|
+
<el-input :placeholder="validData(option.filterText, t('tree.filterPlaceholder'))"
|
|
6
|
+
:size="size"
|
|
7
|
+
v-model="filterValue">
|
|
8
|
+
<template #append
|
|
9
|
+
v-if="validData(option.addBtn,true)">
|
|
10
|
+
<slot v-if="$slots['add-btn']"
|
|
11
|
+
name="add-btn"></slot>
|
|
12
|
+
<el-button v-else
|
|
13
|
+
:size="size"
|
|
14
|
+
@click="parentAdd"
|
|
15
|
+
v-permission="getPermission('addBtn')"
|
|
16
|
+
icon="el-icon-plus"></el-button>
|
|
17
|
+
</template>
|
|
18
|
+
</el-input>
|
|
19
|
+
</div>
|
|
20
|
+
<el-scrollbar :class="b('content')">
|
|
21
|
+
<component :is="componentName"
|
|
22
|
+
ref="tree"
|
|
23
|
+
:data="data"
|
|
24
|
+
:lazy="lazy"
|
|
25
|
+
:load="treeLoad"
|
|
26
|
+
:draggable="option.draggable"
|
|
27
|
+
:height="option.height"
|
|
28
|
+
:props="treeProps"
|
|
29
|
+
:icon-class="iconClass"
|
|
30
|
+
:indent="indent"
|
|
31
|
+
:highlight-current="!multiple"
|
|
32
|
+
:show-checkbox="multiple"
|
|
33
|
+
:accordion="accordion"
|
|
34
|
+
:node-key="valueKey"
|
|
35
|
+
:check-strictly="checkStrictly"
|
|
36
|
+
:check-on-click-node="checkOnClickNode"
|
|
37
|
+
:filter-node-method="filterNode"
|
|
38
|
+
:check-on-click-leaf="checkOnClickLeaf"
|
|
39
|
+
v-loading="loading"
|
|
40
|
+
:expand-on-click-node="expandOnClickNode"
|
|
41
|
+
@check-change="handleCheckChange"
|
|
42
|
+
@node-click="nodeClick"
|
|
43
|
+
@node-expand="nodeExpand"
|
|
44
|
+
@node-drag-start="handleDragStart"
|
|
45
|
+
@node-drag-enter="handleDragEnter"
|
|
46
|
+
@node-drag-leave="handleDragLeave"
|
|
47
|
+
@node-drag-over="handleDragOver"
|
|
48
|
+
@node-drag-end="handleDragEnd"
|
|
49
|
+
@node-drop="handleDrop"
|
|
50
|
+
:allow-drop="option.allowDrop"
|
|
51
|
+
:allow-drag="option.allowDrag"
|
|
52
|
+
@node-contextmenu="nodeContextmenu"
|
|
53
|
+
:default-expand-all="defaultExpandAll"
|
|
54
|
+
:default-expanded-keys="defaultExpandedKeys">
|
|
55
|
+
<template #="{ node, data }"
|
|
56
|
+
v-if="$slots.default">
|
|
57
|
+
<slot :node="node"
|
|
58
|
+
:data="data"></slot>
|
|
59
|
+
</template>
|
|
60
|
+
<template #="{ node }"
|
|
61
|
+
v-else>
|
|
62
|
+
<slot :node="node"
|
|
63
|
+
:data="data"></slot>
|
|
64
|
+
<span class="el-tree-node__label">{{node.label}}</span>
|
|
65
|
+
</template>
|
|
66
|
+
</component>
|
|
67
|
+
</el-scrollbar>
|
|
68
|
+
|
|
69
|
+
<div class="el-cascader-panel is-bordered"
|
|
70
|
+
v-if="client.show&&menu"
|
|
71
|
+
@click="client.show=false"
|
|
72
|
+
:style="styleName"
|
|
73
|
+
:class="b('menu')">
|
|
74
|
+
<div :class="b('item')"
|
|
75
|
+
v-if="validData(option.addBtn,true)"
|
|
76
|
+
v-permission="getPermission('addBtn')"
|
|
77
|
+
@click="rowAdd">{{menuIcon('addBtn')}}</div>
|
|
78
|
+
<div :class="b('item')"
|
|
79
|
+
v-if="validData(option.editBtn,true)"
|
|
80
|
+
v-permission="getPermission('editBtn')"
|
|
81
|
+
@click="rowEdit">{{menuIcon('editBtn')}}</div>
|
|
82
|
+
<div :class="b('item')"
|
|
83
|
+
v-if="validData(option.delBtn,true)"
|
|
84
|
+
v-permission="getPermission('delBtn')"
|
|
85
|
+
@click="rowRemove">{{menuIcon('delBtn')}}</div>
|
|
86
|
+
<slot name="menu"
|
|
87
|
+
:node="node"></slot>
|
|
88
|
+
</div>
|
|
89
|
+
<el-dialog :title="node[labelKey] || title"
|
|
90
|
+
v-model="box"
|
|
91
|
+
class="avue-dialog avue-dialog--none"
|
|
92
|
+
:append-to-body="$AVUE.appendToBody"
|
|
93
|
+
lock-scroll
|
|
94
|
+
:before-close="hide"
|
|
95
|
+
:width="validData(option.dialogWidth,'50%')">
|
|
96
|
+
<avue-form v-model="form"
|
|
97
|
+
:option="formOption"
|
|
98
|
+
ref="form"
|
|
99
|
+
v-if="box"
|
|
100
|
+
@submit="handleSubmit"></avue-form>
|
|
101
|
+
</el-dialog>
|
|
102
|
+
|
|
103
|
+
</div>
|
|
104
|
+
</template>
|
|
105
|
+
|
|
106
|
+
<script>
|
|
107
|
+
import { DIC_PROPS } from '../../../global/variable.mjs';
|
|
108
|
+
import locale from "../../../core/locale.mjs";
|
|
109
|
+
import create from "../../../core/create.mjs";
|
|
110
|
+
import permission from '../../core/directive/permission.mjs';
|
|
111
|
+
export default create({
|
|
112
|
+
name: "tree",
|
|
113
|
+
mixins: [locale],
|
|
114
|
+
directives: {
|
|
115
|
+
permission
|
|
116
|
+
},
|
|
117
|
+
props: {
|
|
118
|
+
indent: Number,
|
|
119
|
+
filterNodeMethod: Function,
|
|
120
|
+
checkOnClickNode: Boolean,
|
|
121
|
+
beforeClose: Function,
|
|
122
|
+
beforeOpen: Function,
|
|
123
|
+
permission: {
|
|
124
|
+
type: [Function, Object],
|
|
125
|
+
default: () => {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
iconClass: {
|
|
130
|
+
type: String,
|
|
131
|
+
},
|
|
132
|
+
checkOnClickLeaf: Boolean,
|
|
133
|
+
loading: {
|
|
134
|
+
type: Boolean,
|
|
135
|
+
default: false
|
|
136
|
+
},
|
|
137
|
+
expandOnClickNode: {
|
|
138
|
+
type: Boolean,
|
|
139
|
+
default: false
|
|
140
|
+
},
|
|
141
|
+
option: {
|
|
142
|
+
type: Object,
|
|
143
|
+
default: () => {
|
|
144
|
+
return {};
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
data: {
|
|
148
|
+
type: Array,
|
|
149
|
+
default: () => {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
modelValue: {
|
|
154
|
+
type: Object,
|
|
155
|
+
default: () => {
|
|
156
|
+
return {};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
data () {
|
|
161
|
+
return {
|
|
162
|
+
filterValue: "",
|
|
163
|
+
client: {
|
|
164
|
+
x: 0,
|
|
165
|
+
y: 0,
|
|
166
|
+
show: false
|
|
167
|
+
},
|
|
168
|
+
box: false,
|
|
169
|
+
type: "",
|
|
170
|
+
node: {},
|
|
171
|
+
obj: {},
|
|
172
|
+
form: {},
|
|
173
|
+
// 存储事件监听器引用,用于销毁时清理
|
|
174
|
+
clickListener: null,
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
computed: {
|
|
178
|
+
virtualize () {
|
|
179
|
+
return this.option.virtualize
|
|
180
|
+
},
|
|
181
|
+
componentName () {
|
|
182
|
+
return 'elTree' + (this.virtualize ? 'V2' : '')
|
|
183
|
+
},
|
|
184
|
+
styleName () {
|
|
185
|
+
return {
|
|
186
|
+
top: this.setPx(this.client.y - 10),
|
|
187
|
+
left: this.setPx(this.client.x - 10),
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
treeProps () {
|
|
191
|
+
return Object.assign(this.deepClone(DIC_PROPS), this.props, {
|
|
192
|
+
isLeaf: this.leafKey
|
|
193
|
+
})
|
|
194
|
+
},
|
|
195
|
+
menu () {
|
|
196
|
+
return this.validData(this.option.menu, true)
|
|
197
|
+
},
|
|
198
|
+
title () {
|
|
199
|
+
return this.option.title || this.t('crud.addTitle')
|
|
200
|
+
},
|
|
201
|
+
treeLoad () {
|
|
202
|
+
return this.option.treeLoad
|
|
203
|
+
},
|
|
204
|
+
checkStrictly () {
|
|
205
|
+
return this.option.checkStrictly
|
|
206
|
+
},
|
|
207
|
+
accordion () {
|
|
208
|
+
return this.option.accordion
|
|
209
|
+
},
|
|
210
|
+
multiple () {
|
|
211
|
+
return this.option.multiple
|
|
212
|
+
},
|
|
213
|
+
lazy () {
|
|
214
|
+
return this.option.lazy
|
|
215
|
+
},
|
|
216
|
+
addText () {
|
|
217
|
+
return this.addFlag ? this.menuIcon('addBtn') : this.menuIcon('updateBtn');
|
|
218
|
+
},
|
|
219
|
+
addFlag () {
|
|
220
|
+
return ["add", "parentAdd"].includes(this.type);
|
|
221
|
+
},
|
|
222
|
+
size () {
|
|
223
|
+
return this.option.size
|
|
224
|
+
},
|
|
225
|
+
props () {
|
|
226
|
+
return this.option.props || {};
|
|
227
|
+
},
|
|
228
|
+
leafKey () {
|
|
229
|
+
return this.props.leaf || DIC_PROPS.leaf
|
|
230
|
+
},
|
|
231
|
+
valueKey () {
|
|
232
|
+
return this.props.value || DIC_PROPS.value;
|
|
233
|
+
},
|
|
234
|
+
labelKey () {
|
|
235
|
+
return this.props.label || DIC_PROPS.label;
|
|
236
|
+
},
|
|
237
|
+
childrenKey () {
|
|
238
|
+
return this.props.children || DIC_PROPS.children;
|
|
239
|
+
},
|
|
240
|
+
nodeKey () {
|
|
241
|
+
return this.option.nodeKey || DIC_PROPS.nodeKey;
|
|
242
|
+
},
|
|
243
|
+
defaultExpandAll () {
|
|
244
|
+
return this.option.defaultExpandAll;
|
|
245
|
+
},
|
|
246
|
+
defaultExpandedKeys () {
|
|
247
|
+
return this.option.defaultExpandedKeys;
|
|
248
|
+
},
|
|
249
|
+
formOption () {
|
|
250
|
+
return Object.assign(
|
|
251
|
+
this.option.formOption || {},
|
|
252
|
+
{
|
|
253
|
+
boxType: this.type,
|
|
254
|
+
submitText: this.addText,
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
mounted () {
|
|
260
|
+
// 创建事件监听器函数并存储引用,用于后续清理
|
|
261
|
+
this.clickListener = (e) => {
|
|
262
|
+
// 检查点击事件是否发生在组件外部,如果是则隐藏右键菜单
|
|
263
|
+
if (!this.$el.contains(e.target)) {
|
|
264
|
+
this.client.show = false;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// 注册全局点击事件监听器
|
|
269
|
+
document.addEventListener('click', this.clickListener);
|
|
270
|
+
|
|
271
|
+
// 初始化树组件的方法
|
|
272
|
+
this.initFun();
|
|
273
|
+
},
|
|
274
|
+
beforeUnmount () {
|
|
275
|
+
// 组件销毁前清理全局事件监听器,防止内存泄漏
|
|
276
|
+
if (this.clickListener) {
|
|
277
|
+
document.removeEventListener('click', this.clickListener);
|
|
278
|
+
this.clickListener = null;
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
watch: {
|
|
282
|
+
filterValue (val) {
|
|
283
|
+
this.$refs.tree.filter(val);
|
|
284
|
+
},
|
|
285
|
+
modelValue (val) {
|
|
286
|
+
this.form = val;
|
|
287
|
+
},
|
|
288
|
+
form (val) {
|
|
289
|
+
this.$emit('update:modelValue', val);
|
|
290
|
+
this.$emit("change", val);
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
methods: {
|
|
294
|
+
handleDragStart (node, ev) {
|
|
295
|
+
this.$emit('node-drag-start', node, ev)
|
|
296
|
+
},
|
|
297
|
+
handleDragEnter (draggingNode, dropNode, ev) {
|
|
298
|
+
this.$emit('node-drag-enter', draggingNode, dropNode, ev)
|
|
299
|
+
},
|
|
300
|
+
handleDragLeave (draggingNode, dropNode, ev) {
|
|
301
|
+
this.$emit('node-drag-leave', draggingNode, dropNode, ev)
|
|
302
|
+
},
|
|
303
|
+
handleDragOver (draggingNode, dropNode, ev) {
|
|
304
|
+
this.$emit('node-drag-over', draggingNode, dropNode, ev)
|
|
305
|
+
},
|
|
306
|
+
handleDragEnd (draggingNode, dropNode, dropType, ev) {
|
|
307
|
+
this.$emit('node-drag-end', draggingNode, dropNode, dropType, ev)
|
|
308
|
+
},
|
|
309
|
+
handleDrop (draggingNode, dropNode, dropType, ev) {
|
|
310
|
+
this.$emit('node-drop', draggingNode, dropNode, dropType, ev)
|
|
311
|
+
},
|
|
312
|
+
menuIcon (value) {
|
|
313
|
+
return this.validData(this.option[value + 'Text'], this.t("crud." + value))
|
|
314
|
+
},
|
|
315
|
+
getPermission (key) {
|
|
316
|
+
if (typeof this.permission === "function") {
|
|
317
|
+
return this.permission(key, this.node.data || {})
|
|
318
|
+
} else if (!this.validatenull(this.permission[key])) {
|
|
319
|
+
return this.permission[key]
|
|
320
|
+
} else {
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
/**
|
|
325
|
+
* 初始化树组件的方法代理
|
|
326
|
+
* 将element-plus tree组件的方法代理到当前组件实例上,
|
|
327
|
+
* 使父组件可以直接调用这些方法
|
|
328
|
+
*/
|
|
329
|
+
initFun () {
|
|
330
|
+
[
|
|
331
|
+
'filter', 'updateKeyChildren', 'getCheckedNodes', 'setCheckedNodes', 'getCheckedKeys',
|
|
332
|
+
'setCheckedKeys', 'setChecked', 'getHalfCheckedNodes', 'getHalfCheckedKeys', 'getCurrentKey', 'getCurrentNode',
|
|
333
|
+
'setCurrentKey', 'setCurrentNode', 'getNode', 'remove', 'append', 'insertBefore', 'insertAfter'
|
|
334
|
+
].forEach(ele => {
|
|
335
|
+
this[ele] = this.$refs.tree[ele];
|
|
336
|
+
})
|
|
337
|
+
},
|
|
338
|
+
nodeContextmenu (e, data, node, obj) {
|
|
339
|
+
this.node = node;
|
|
340
|
+
this.client.x = e.clientX;
|
|
341
|
+
this.client.y = e.clientY;
|
|
342
|
+
this.client.show = true;
|
|
343
|
+
this.$emit('node-contextmenu', data, node, obj)
|
|
344
|
+
},
|
|
345
|
+
handleCheckChange (data, checked, indeterminate) {
|
|
346
|
+
this.$emit('check-change', data, checked, indeterminate)
|
|
347
|
+
},
|
|
348
|
+
handleSubmit (form, done) {
|
|
349
|
+
this.addFlag ? this.save(form, done) : this.update(form, done)
|
|
350
|
+
},
|
|
351
|
+
nodeClick (data, node, nodeComp) {
|
|
352
|
+
this.client.show = false
|
|
353
|
+
this.$emit("node-click", data, node, nodeComp);
|
|
354
|
+
},
|
|
355
|
+
nodeExpand (data, node, nodeComp) {
|
|
356
|
+
this.$emit("node-expand", data, node, nodeComp);
|
|
357
|
+
},
|
|
358
|
+
filterNode (value, data) {
|
|
359
|
+
if (typeof this.filterNodeMethod === 'function') {
|
|
360
|
+
return this.filterNodeMethod(value, data);
|
|
361
|
+
}
|
|
362
|
+
if (!value) return true;
|
|
363
|
+
return data[this.labelKey].indexOf(value) !== -1;
|
|
364
|
+
},
|
|
365
|
+
hide (done) {
|
|
366
|
+
const callback = () => {
|
|
367
|
+
done && done()
|
|
368
|
+
this.node = {};
|
|
369
|
+
this.form = {}
|
|
370
|
+
this.box = false;
|
|
371
|
+
}
|
|
372
|
+
if (typeof this.beforeClose === "function") {
|
|
373
|
+
this.beforeClose(callback, this.type);
|
|
374
|
+
} else {
|
|
375
|
+
callback();
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
save (data, done) {
|
|
379
|
+
const callback = (form) => {
|
|
380
|
+
form = this.deepClone(form || this.form);
|
|
381
|
+
if (this.type === "add") {
|
|
382
|
+
this.$refs.tree.append(form, this.node.data[this.valueKey])
|
|
383
|
+
} else if (this.type === "parentAdd") {
|
|
384
|
+
this.$refs.tree.append(form)
|
|
385
|
+
}
|
|
386
|
+
done()
|
|
387
|
+
this.$nextTick(() => this.hide())
|
|
388
|
+
};
|
|
389
|
+
this.$emit("save", this.node, data, callback, done);
|
|
390
|
+
},
|
|
391
|
+
update (data, done) {
|
|
392
|
+
const callback = (form) => {
|
|
393
|
+
form = this.deepClone(form || this.form);
|
|
394
|
+
const rowKey = form[this.valueKey]
|
|
395
|
+
this.node.data = form
|
|
396
|
+
let { parentList, index } = this.findData(rowKey)
|
|
397
|
+
if (parentList) {
|
|
398
|
+
const oldRow = parentList.splice(index, 1)[0];
|
|
399
|
+
form[this.childrenKey] = oldRow[this.childrenKey]
|
|
400
|
+
parentList.splice(index, 0, this.deepClone(form))
|
|
401
|
+
}
|
|
402
|
+
this.hide();
|
|
403
|
+
done()
|
|
404
|
+
};
|
|
405
|
+
this.$emit("update", this.node, data, callback, done);
|
|
406
|
+
},
|
|
407
|
+
rowEdit (a) {
|
|
408
|
+
this.type = "edit";
|
|
409
|
+
this.form = this.deepClone(this.node.data);
|
|
410
|
+
this.show();
|
|
411
|
+
},
|
|
412
|
+
parentAdd () {
|
|
413
|
+
this.type = "parentAdd";
|
|
414
|
+
this.show();
|
|
415
|
+
},
|
|
416
|
+
rowAdd () {
|
|
417
|
+
this.type = "add";
|
|
418
|
+
this.show();
|
|
419
|
+
},
|
|
420
|
+
show () {
|
|
421
|
+
const callback = () => {
|
|
422
|
+
this.client.show = false;
|
|
423
|
+
this.box = true;
|
|
424
|
+
}
|
|
425
|
+
if (typeof this.beforeOpen === "function") {
|
|
426
|
+
this.beforeOpen(callback, this.type);
|
|
427
|
+
} else {
|
|
428
|
+
callback();
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
rowRemove () {
|
|
432
|
+
this.client.show = false;
|
|
433
|
+
const callback = () => {
|
|
434
|
+
this.$refs.tree.remove(this.node)
|
|
435
|
+
}
|
|
436
|
+
this.$emit("del", this.node, callback);
|
|
437
|
+
},
|
|
438
|
+
findData (id) {
|
|
439
|
+
let result = {}
|
|
440
|
+
const callback = (parentList, parent) => {
|
|
441
|
+
parentList.forEach((ele, index) => {
|
|
442
|
+
if (ele[this.valueKey] == id) {
|
|
443
|
+
result = {
|
|
444
|
+
item: ele,
|
|
445
|
+
index: index,
|
|
446
|
+
parentList: parentList,
|
|
447
|
+
parent: parent
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (ele[this.childrenKey]) {
|
|
451
|
+
callback(ele[this.childrenKey], ele)
|
|
452
|
+
}
|
|
453
|
+
})
|
|
454
|
+
}
|
|
455
|
+
callback(this.data)
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
</script>
|