xianniu-ui 0.1.2 → 0.1.4
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/lib/style/basic.css +1 -0
- package/lib/style/city.css +1 -0
- package/lib/style/date.css +1 -0
- package/lib/style/flex.css +1 -0
- package/lib/style/import.css +1 -0
- package/lib/style/index.css +1 -1
- package/{src → lib/style}/theme/element-variables.scss +2 -4
- package/{src → lib/style}/theme/index.scss +0 -0
- package/{src → lib/style}/theme/mixin.scss +0 -0
- package/{src → lib/style}/theme/sidebar.scss +0 -0
- package/lib/style/theme/theme.scss +4 -0
- package/{src → lib/style}/theme/transition.scss +0 -0
- package/{src → lib/style}/theme/variables.scss +0 -0
- package/lib/style/upload.css +1 -0
- package/lib/xianniu-ui.common.js +25504 -18072
- package/lib/xianniu-ui.css +1 -0
- package/lib/xianniu-ui.umd.js +25508 -18076
- package/lib/xianniu-ui.umd.min.js +1 -9
- package/package.json +63 -62
- package/packages/city/index.js +7 -0
- package/packages/city/main.vue +258 -0
- package/packages/date/index.js +7 -0
- package/packages/date/main.vue +348 -0
- package/packages/dialog/!main.vue +90 -0
- package/packages/dialog/main.vue +37 -57
- package/packages/drawer/index.js +7 -0
- package/packages/drawer/main.vue +65 -0
- package/packages/empty/index.js +7 -0
- package/packages/empty/main.vue +33 -0
- package/packages/export/index.js +7 -0
- package/packages/export/main.vue +99 -0
- package/packages/import/index.js +7 -0
- package/packages/import/main.vue +135 -0
- package/packages/inputRange/index.js +7 -0
- package/packages/inputRange/main.vue +15 -0
- package/packages/page/main.vue +5 -5
- package/packages/search/index.js +7 -0
- package/packages/search/main.vue +230 -0
- package/packages/style/lib/basic.css +1 -0
- package/packages/style/lib/city.css +1 -0
- package/packages/style/lib/date.css +1 -0
- package/packages/style/lib/flex.css +1 -0
- package/packages/style/lib/import.css +1 -0
- package/packages/style/lib/index.css +1 -1
- package/packages/style/lib/upload.css +1 -0
- package/packages/style/src/basic.scss +64 -0
- package/packages/style/src/city.scss +3 -0
- package/packages/style/src/date.scss +5 -0
- package/packages/style/src/flex.scss +74 -0
- package/packages/style/src/import.scss +37 -0
- package/packages/style/src/index.scss +9 -1
- package/packages/style/src/mixin/mixin.scss +270 -0
- package/packages/style/src/search.scss +17 -0
- package/packages/style/src/table.scss +36 -4
- package/packages/style/src/theme/element-variables.scss +26 -0
- package/packages/style/src/theme/index.scss +1 -0
- package/packages/style/src/theme/mixin.scss +270 -0
- package/packages/style/src/theme/sidebar.scss +271 -0
- package/packages/style/src/theme/theme.scss +4 -0
- package/packages/style/src/theme/transition.scss +52 -0
- package/packages/style/src/theme/variables.scss +36 -0
- package/packages/style/src/tip.scss +22 -0
- package/packages/style/src/tree.scss +87 -0
- package/packages/style/src/upload.scss +46 -0
- package/packages/table/column.vue +42 -23
- package/packages/table/main.vue +126 -35
- package/packages/tip/index.js +7 -0
- package/packages/tip/main.vue +22 -0
- package/packages/tree/index.js +7 -0
- package/packages/tree/main.vue +192 -0
- package/packages/upload/index.js +7 -0
- package/packages/upload/main.vue +346 -0
- package/packages/upload/upload-pop.vue +49 -0
- package/packages/upload/upload-slot.vue +0 -0
- package/src/index.js +23 -3
- package/src/plugins/index.js +1 -1
- package/src/utils/format.js +119 -106
- package/src/utils/index.js +0 -2
- package/src/utils/reg.js +7 -1
- package/src/utils/utils.js +76 -10
- package/src/utils/lodash.js +0 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.xn-tree {
|
|
2
|
+
width: 100%;
|
|
3
|
+
.el-tree > .el-tree-node:after {
|
|
4
|
+
border-top: none;
|
|
5
|
+
}
|
|
6
|
+
.el-tree-node {
|
|
7
|
+
position: relative;
|
|
8
|
+
z-index: 9;
|
|
9
|
+
padding-left: 16px;
|
|
10
|
+
}
|
|
11
|
+
//节点有间隙,隐藏掉展开按钮就好了,如果觉得空隙没事可以删掉
|
|
12
|
+
.el-tree-node__expand-icon.is-leaf {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
.el-tree-node__children {
|
|
16
|
+
padding-left: 16px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.el-tree-node :last-child::before {
|
|
20
|
+
height: 38px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.el-tree > .el-tree-node::before {
|
|
24
|
+
border-left: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.el-tree > .el-tree-node:after {
|
|
28
|
+
border-top: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.el-tree-node::before {
|
|
32
|
+
content: "";
|
|
33
|
+
left: -4px;
|
|
34
|
+
position: absolute;
|
|
35
|
+
right: auto;
|
|
36
|
+
border-width: 1px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.el-tree-node:after {
|
|
40
|
+
content: "";
|
|
41
|
+
left: -4px;
|
|
42
|
+
position: absolute;
|
|
43
|
+
right: auto;
|
|
44
|
+
border-width: 1px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.el-tree-node::before {
|
|
48
|
+
border-left: 1px dashed #dcdfe6;
|
|
49
|
+
bottom: 0px;
|
|
50
|
+
height: 100%;
|
|
51
|
+
top: -26px;
|
|
52
|
+
width: 1px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.el-tree-node:after {
|
|
56
|
+
border-top: 1px dashed #dcdfe6;
|
|
57
|
+
height: 20px;
|
|
58
|
+
top: 12px;
|
|
59
|
+
width: 18px;
|
|
60
|
+
}
|
|
61
|
+
.el-tree .el-tree-node__expand-icon.expanded {
|
|
62
|
+
-webkit-transform: rotate(0deg);
|
|
63
|
+
transform: rotate(0deg);
|
|
64
|
+
}
|
|
65
|
+
.el-tree .el-icon-caret-right::before {
|
|
66
|
+
content: "\e723";
|
|
67
|
+
font-size: 16px;
|
|
68
|
+
color: #ff745c;
|
|
69
|
+
position: absolute;
|
|
70
|
+
left: -4px;
|
|
71
|
+
top: -3px;
|
|
72
|
+
}
|
|
73
|
+
.el-tree .el-tree-node__expand-icon.expanded.el-icon-caret-right::before {
|
|
74
|
+
content: "\e722";
|
|
75
|
+
font-size: 16px;
|
|
76
|
+
color: #ff745c;
|
|
77
|
+
position: absolute;
|
|
78
|
+
left: -4px;
|
|
79
|
+
top: -3px;
|
|
80
|
+
}
|
|
81
|
+
.el-tree-node__content {
|
|
82
|
+
padding-left: 8px !important;
|
|
83
|
+
}
|
|
84
|
+
.el-tree-node__content:hover {
|
|
85
|
+
background-color: #fff;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.xn-upload {
|
|
2
|
+
border: 1px solid red;
|
|
3
|
+
.el-upload-list__item{
|
|
4
|
+
img{
|
|
5
|
+
object-fit: cover;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
// &.is-disabled {
|
|
9
|
+
// border: 1px solid red;
|
|
10
|
+
// .el-upload.el-upload--picture-card {
|
|
11
|
+
// cursor: not-allowed;
|
|
12
|
+
// background-color: #f4f4f5;
|
|
13
|
+
// &:hover {
|
|
14
|
+
// border-color: #c0ccda;
|
|
15
|
+
// color: #c0ccda;
|
|
16
|
+
// }
|
|
17
|
+
// .upload-limit {
|
|
18
|
+
// i,
|
|
19
|
+
// span {
|
|
20
|
+
// color: #bcbec2;
|
|
21
|
+
// }
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
// }
|
|
25
|
+
// &-main{
|
|
26
|
+
// border: 1px solid red;
|
|
27
|
+
// }
|
|
28
|
+
// &--slot{
|
|
29
|
+
// height: 100%;
|
|
30
|
+
|
|
31
|
+
// &__ext {
|
|
32
|
+
// position: absolute;
|
|
33
|
+
// bottom: 0;
|
|
34
|
+
// right: 0;
|
|
35
|
+
// z-index: 1000;
|
|
36
|
+
// background: rgba($color: #000000, $alpha: 0.4);
|
|
37
|
+
// height: 20px;
|
|
38
|
+
// line-height: 20px;
|
|
39
|
+
// color: #fff;
|
|
40
|
+
// font-size: 12px;
|
|
41
|
+
// padding: 0 5px;
|
|
42
|
+
// border-radius: 0 0 0 0;
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-table-column v-bind="$attrs" v-if="isShowColumn($attrs)">
|
|
2
|
+
<el-table-column v-bind="$attrs" v-on="$listeners" v-if="isShowColumn($attrs)">
|
|
3
|
+
|
|
3
4
|
<template v-if="$attrs.labelMsg">
|
|
4
5
|
<template slot="header">
|
|
5
6
|
<el-tooltip
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
<template slot-scope="{ row, $index }">
|
|
16
17
|
<expandDom
|
|
17
18
|
v-if="$attrs.render"
|
|
18
|
-
:column="
|
|
19
|
+
:column="row"
|
|
19
20
|
:row="row"
|
|
20
21
|
:render="$attrs.render"
|
|
21
22
|
:index="$index"
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
<template v-if="$attrs.more && $attrs.more.options.length">
|
|
28
29
|
<template v-for="(itemBtn, idxBtn) in $attrs.more.options">
|
|
29
30
|
<expand-dom
|
|
30
|
-
v-if="itemBtn.render"
|
|
31
|
+
v-if="itemBtn.render && itemBtn.show && itemBtn.show(row)"
|
|
31
32
|
:key="idxBtn"
|
|
32
33
|
:column="itemBtn"
|
|
33
34
|
:row="row"
|
|
@@ -35,21 +36,36 @@
|
|
|
35
36
|
:index="idxBtn"
|
|
36
37
|
/>
|
|
37
38
|
<template v-else>
|
|
38
|
-
<el-
|
|
39
|
-
v-if="itemBtn.
|
|
39
|
+
<el-popconfirm
|
|
40
|
+
v-if="itemBtn.isPopConfirm"
|
|
41
|
+
:title="itemBtn.options.title || `确定${label(itemBtn, row)}吗?`"
|
|
40
42
|
:key="idxBtn"
|
|
41
|
-
:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
:icon="itemBtn.icon"
|
|
45
|
-
:plain="itemBtn.plain"
|
|
46
|
-
@click="handleClick(itemBtn.method, row, $index)"
|
|
47
|
-
>{{
|
|
48
|
-
typeof itemBtn.label === "function"
|
|
49
|
-
? itemBtn.label(row)
|
|
50
|
-
: itemBtn.label
|
|
51
|
-
}}</el-button
|
|
43
|
+
:confirm-button-text="itemBtn.options.confirmButtonText"
|
|
44
|
+
class="ml-10"
|
|
45
|
+
@confirm="handleClick(itemBtn.method, row, $index)"
|
|
52
46
|
>
|
|
47
|
+
<el-button
|
|
48
|
+
:type="itemBtn.type || 'text'"
|
|
49
|
+
:size="itemBtn.size || 'mini'"
|
|
50
|
+
:icon="itemBtn.icon"
|
|
51
|
+
:plain="itemBtn.plain"
|
|
52
|
+
slot="reference"
|
|
53
|
+
>{{ label(itemBtn, row) }}</el-button
|
|
54
|
+
>
|
|
55
|
+
</el-popconfirm>
|
|
56
|
+
<template v-else>
|
|
57
|
+
<el-button
|
|
58
|
+
v-if="itemBtn.show ? itemBtn.show(row) : true"
|
|
59
|
+
:key="idxBtn"
|
|
60
|
+
:disabled="itemBtn.disabled ? itemBtn.disabled(row) : false"
|
|
61
|
+
:type="itemBtn.type || 'text'"
|
|
62
|
+
:size="itemBtn.size || 'mini'"
|
|
63
|
+
:icon="itemBtn.icon"
|
|
64
|
+
:plain="itemBtn.plain"
|
|
65
|
+
@click="handleClick(itemBtn.method, row, $index)"
|
|
66
|
+
>{{ label(itemBtn, row) }}</el-button
|
|
67
|
+
>
|
|
68
|
+
</template>
|
|
53
69
|
</template>
|
|
54
70
|
</template>
|
|
55
71
|
</template>
|
|
@@ -82,14 +98,17 @@ export default {
|
|
|
82
98
|
},
|
|
83
99
|
},
|
|
84
100
|
computed: {
|
|
101
|
+
label() {
|
|
102
|
+
return (itemBtn, row) => {
|
|
103
|
+
return typeof itemBtn.label === "function"
|
|
104
|
+
? itemBtn.label(row)
|
|
105
|
+
: itemBtn.label;
|
|
106
|
+
};
|
|
107
|
+
},
|
|
85
108
|
isShowColumn() {
|
|
86
109
|
return (row) => {
|
|
87
|
-
if (row.show
|
|
88
|
-
|
|
89
|
-
return row.show();
|
|
90
|
-
} else {
|
|
91
|
-
return row.show;
|
|
92
|
-
}
|
|
110
|
+
if (row.show != undefined) {
|
|
111
|
+
return typeof row.show === "function" ? row.show() : row.show;
|
|
93
112
|
}
|
|
94
113
|
return true;
|
|
95
114
|
};
|
|
@@ -99,7 +118,7 @@ export default {
|
|
|
99
118
|
watch: {},
|
|
100
119
|
methods: {
|
|
101
120
|
handleClick(method, row, index) {
|
|
102
|
-
if(this.$parent){
|
|
121
|
+
if (this.$parent) {
|
|
103
122
|
this.$parent.$emit("on-buttons", { method, row, index });
|
|
104
123
|
}
|
|
105
124
|
},
|
package/packages/table/main.vue
CHANGED
|
@@ -1,25 +1,79 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="xn-table-box">
|
|
3
|
-
<div
|
|
4
|
-
class="xn-table-box-tools"
|
|
5
|
-
v-if="isTools"
|
|
6
|
-
:class="{ 'is-border': !border }"
|
|
7
|
-
>
|
|
3
|
+
<div class="xn-table-box-tools" :class="{ 'is-border': !border }">
|
|
8
4
|
<slot name="tools">
|
|
9
|
-
<el-button
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
<el-button-group>
|
|
6
|
+
<el-tooltip
|
|
7
|
+
v-for="(item, idx) in tools"
|
|
8
|
+
:key="idx"
|
|
9
|
+
:content="item.label"
|
|
10
|
+
placement="bottom"
|
|
11
|
+
effect="dark"
|
|
12
|
+
>
|
|
13
|
+
<el-button
|
|
14
|
+
size="mini"
|
|
15
|
+
:icon="item.icon"
|
|
16
|
+
@click="handleToolsItem(item, idx)"
|
|
17
|
+
>
|
|
18
|
+
{{item.label}}
|
|
19
|
+
</el-button>
|
|
20
|
+
</el-tooltip>
|
|
21
|
+
<el-tooltip content="刷新列表" placement="bottom" effect="dark">
|
|
22
|
+
<el-button
|
|
23
|
+
size="mini"
|
|
24
|
+
@click="$emit('on-refresh')"
|
|
25
|
+
icon="el-icon-refresh"
|
|
26
|
+
></el-button>
|
|
27
|
+
</el-tooltip>
|
|
28
|
+
<el-popover
|
|
29
|
+
placement="bottom-end"
|
|
30
|
+
popper-class="xn-table-box-tools__pop"
|
|
31
|
+
class="ml-10"
|
|
32
|
+
trigger="hover"
|
|
33
|
+
>
|
|
34
|
+
<el-scrollbar
|
|
35
|
+
class="xn-table-box-tools__coll"
|
|
36
|
+
wrap-style="overflow-x:hidden;"
|
|
37
|
+
>
|
|
38
|
+
<div v-for="(item, idx) in columns" :key="idx" class="mb-5">
|
|
39
|
+
<el-checkbox
|
|
40
|
+
:value="item.checked"
|
|
41
|
+
:checked="item.checked"
|
|
42
|
+
@change="handleChangeToolshow(item)"
|
|
43
|
+
>{{ item.label }}</el-checkbox
|
|
44
|
+
>
|
|
45
|
+
</div>
|
|
46
|
+
</el-scrollbar>
|
|
47
|
+
<el-button
|
|
48
|
+
size="mini"
|
|
49
|
+
icon="el-icon-setting"
|
|
50
|
+
slot="reference"
|
|
51
|
+
></el-button>
|
|
52
|
+
</el-popover>
|
|
53
|
+
</el-button-group>
|
|
15
54
|
</slot>
|
|
16
55
|
</div>
|
|
56
|
+
<!-- <el-button
|
|
57
|
+
circle
|
|
58
|
+
size="mini"
|
|
59
|
+
@click="$emit('on-export')"
|
|
60
|
+
icon="el-icon-files"
|
|
61
|
+
></el-button>
|
|
62
|
+
<el-button
|
|
63
|
+
circle
|
|
64
|
+
size="mini"
|
|
65
|
+
@click="$emit('on-refresh')"
|
|
66
|
+
icon="el-icon-refresh"
|
|
67
|
+
></el-button> -->
|
|
68
|
+
|
|
17
69
|
<el-table
|
|
70
|
+
ref="table"
|
|
18
71
|
:data="data"
|
|
19
72
|
v-on="$listeners"
|
|
20
73
|
v-bind="$attrs"
|
|
21
74
|
:border="border"
|
|
22
75
|
:stripe="stripe"
|
|
76
|
+
@row-click="singleElection"
|
|
23
77
|
>
|
|
24
78
|
<el-table-column
|
|
25
79
|
v-if="selection && data.length"
|
|
@@ -28,28 +82,38 @@
|
|
|
28
82
|
width="50px"
|
|
29
83
|
align="center"
|
|
30
84
|
></el-table-column>
|
|
85
|
+
<el-table-column v-bind="$attrs" v-if="radio" width="50px" align="center">
|
|
86
|
+
<template slot-scope="{ row }">
|
|
87
|
+
<el-radio v-model="radioSelected" :label="row.id"> </el-radio>
|
|
88
|
+
</template>
|
|
89
|
+
</el-table-column>
|
|
31
90
|
<el-table-column
|
|
32
91
|
width="50px"
|
|
33
92
|
label="序号"
|
|
34
93
|
v-if="index && data.length"
|
|
35
94
|
type="index"
|
|
36
95
|
></el-table-column>
|
|
96
|
+
|
|
37
97
|
<slot name="column">
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
98
|
+
<template v-for="(item, idx) in columns">
|
|
99
|
+
<column
|
|
100
|
+
:key="idx"
|
|
101
|
+
v-if="item.checked === true"
|
|
102
|
+
v-bind="item"
|
|
103
|
+
></column>
|
|
104
|
+
</template>
|
|
43
105
|
</slot>
|
|
44
106
|
</el-table>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
107
|
+
|
|
108
|
+
<template v-if="!$utils.isEmpty(pageConfig)">
|
|
109
|
+
<xn-page
|
|
110
|
+
:total="pageConfig.total"
|
|
111
|
+
:page.sync="pageConfig.pageNum"
|
|
112
|
+
:limit.sync="pageConfig.pageSize"
|
|
113
|
+
@pagination="getList"
|
|
114
|
+
layout="total, prev, pager, next, jumper"
|
|
115
|
+
></xn-page>
|
|
116
|
+
</template>
|
|
53
117
|
</div>
|
|
54
118
|
</template>
|
|
55
119
|
|
|
@@ -59,9 +123,13 @@ export default {
|
|
|
59
123
|
name: "XnTable",
|
|
60
124
|
components: { column },
|
|
61
125
|
props: {
|
|
126
|
+
tools: {
|
|
127
|
+
type: Array,
|
|
128
|
+
default: () => [],
|
|
129
|
+
},
|
|
62
130
|
data: {
|
|
63
131
|
type: Array,
|
|
64
|
-
default: () =>
|
|
132
|
+
default: () => [],
|
|
65
133
|
},
|
|
66
134
|
border: {
|
|
67
135
|
type: Boolean,
|
|
@@ -73,29 +141,52 @@ export default {
|
|
|
73
141
|
},
|
|
74
142
|
stripe: Boolean,
|
|
75
143
|
selection: Boolean,
|
|
144
|
+
radio: Boolean,
|
|
145
|
+
|
|
76
146
|
showPage: Boolean,
|
|
147
|
+
pageLayout: {
|
|
148
|
+
type: String,
|
|
149
|
+
default: "total, prev, pager, next, jumper",
|
|
150
|
+
},
|
|
77
151
|
pageConfig: {
|
|
78
152
|
type: Object,
|
|
79
|
-
default: () => {
|
|
80
|
-
return {
|
|
81
|
-
pageSize: 15,
|
|
82
|
-
pageNum: 1,
|
|
83
|
-
};
|
|
84
|
-
},
|
|
153
|
+
default: () => {},
|
|
85
154
|
},
|
|
86
155
|
index: Boolean,
|
|
87
156
|
expand: Boolean,
|
|
88
157
|
isTools: Boolean,
|
|
89
158
|
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
159
|
+
data() {
|
|
160
|
+
return {
|
|
161
|
+
radioSelected: "",
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
computed: {},
|
|
165
|
+
created() {
|
|
166
|
+
this.columns.length &&
|
|
167
|
+
this.columns.forEach((item) => {
|
|
168
|
+
this.$set(item, "checked", true);
|
|
169
|
+
});
|
|
94
170
|
},
|
|
95
171
|
methods: {
|
|
96
172
|
getList(val) {
|
|
97
173
|
this.$emit("on-page", val);
|
|
98
174
|
},
|
|
175
|
+
|
|
176
|
+
singleElection(val) {
|
|
177
|
+
if (!this.radio) return;
|
|
178
|
+
this.radioSelected = val.id;
|
|
179
|
+
const res = this.data.filter((item) => item.id === val.id);
|
|
180
|
+
this.$emit("on-single", res);
|
|
181
|
+
},
|
|
182
|
+
handleToolsItem(row, idx) {
|
|
183
|
+
console.log(row, idx);
|
|
184
|
+
},
|
|
185
|
+
handleChangeToolshow(item) {
|
|
186
|
+
item.checked = item.checked === true ? false : true;
|
|
187
|
+
this.$refs.table.doLayout();
|
|
188
|
+
console.log(this.$root);
|
|
189
|
+
},
|
|
99
190
|
},
|
|
100
191
|
};
|
|
101
192
|
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="xn-tip" :class="[`xn-tip--${type}`]">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'XnTip',
|
|
10
|
+
props: {
|
|
11
|
+
type: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: 'primary',
|
|
14
|
+
validator: (val) => {
|
|
15
|
+
return ['primary', 'warning', 'success', 'danger', 'info'].includes(
|
|
16
|
+
val
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="xn-tree">
|
|
3
|
+
<el-tree
|
|
4
|
+
ref="tree"
|
|
5
|
+
class="xn-tree-main"
|
|
6
|
+
:data="data"
|
|
7
|
+
:indent="0"
|
|
8
|
+
default-expand-all
|
|
9
|
+
:check-strictly="true"
|
|
10
|
+
:props="defaultProps"
|
|
11
|
+
:node-key="nodeKey"
|
|
12
|
+
show-checkbox
|
|
13
|
+
:render-content="renderContent"
|
|
14
|
+
@check="clickDeal"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
name: 'XnTree',
|
|
22
|
+
props: {
|
|
23
|
+
data: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default: () => {}
|
|
26
|
+
},
|
|
27
|
+
nodeKey: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'menuId'
|
|
30
|
+
},
|
|
31
|
+
defaultProps: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default: () => {
|
|
34
|
+
return {
|
|
35
|
+
children: 'bossApplicationMenuVOS',
|
|
36
|
+
label: 'menuName'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
mounted() {
|
|
42
|
+
this.$nextTick(() => {
|
|
43
|
+
this.changeTreeClass()
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
methods: {
|
|
47
|
+
getCheckedKeys() {
|
|
48
|
+
return this.$refs.tree
|
|
49
|
+
.getCheckedKeys()
|
|
50
|
+
.concat(this.$refs.tree.getHalfCheckedKeys())
|
|
51
|
+
},
|
|
52
|
+
setCheckedKeys(data = []) {
|
|
53
|
+
this.$nextTick(() => {
|
|
54
|
+
this.$refs.tree.setCheckedKeys(data)
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
renderContent(h, { data }) {
|
|
58
|
+
let className = ''
|
|
59
|
+
// let className1 = ''
|
|
60
|
+
// perms这个是后台数据区分普通tree节点和横向tree节点的标志各位要根据实际情况做相对应的修改
|
|
61
|
+
if (
|
|
62
|
+
data.parentId &&
|
|
63
|
+
data.parentId !== 0 &&
|
|
64
|
+
!data[this.defaultProps.children].length
|
|
65
|
+
) {
|
|
66
|
+
className = 'especially'
|
|
67
|
+
}
|
|
68
|
+
// if (!node.isLeaf) {
|
|
69
|
+
// node.parent.className1 = 'pl-20'
|
|
70
|
+
// } else {
|
|
71
|
+
// className1 = 'pl-0'
|
|
72
|
+
// }
|
|
73
|
+
return (
|
|
74
|
+
// 在需要做横向排列的模块做标记
|
|
75
|
+
<div class={[className]}>{data[this.defaultProps.label]}</div>
|
|
76
|
+
)
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
// 改变tree节点样式
|
|
80
|
+
|
|
81
|
+
changeTreeClass() {
|
|
82
|
+
// 找到之前做标记的class
|
|
83
|
+
// var classDomList = document.getElementsByClassName('especially')
|
|
84
|
+
// // 改变这几个样式
|
|
85
|
+
// for (var i = 0; i < classDomList.length; i++) {
|
|
86
|
+
// // classDomList[i].parentNode.style.cssText = 'float: left'
|
|
87
|
+
// classDomList[i].parentNode.className =
|
|
88
|
+
// 'el-tree-node__content option-wrapper'
|
|
89
|
+
// classDomList[i].parentNode.style.marginLeft =
|
|
90
|
+
// '-25px'
|
|
91
|
+
// }
|
|
92
|
+
},
|
|
93
|
+
clickDeal(currentObj, treeStatus) {
|
|
94
|
+
this.clickCheck(currentObj, treeStatus, this.$refs.tree)
|
|
95
|
+
},
|
|
96
|
+
clickCheck(currentObj, treeStatus, ref) {
|
|
97
|
+
// 用于:父子节点严格互不关联时,父节点勾选变化时通知子节点同步变化,实现单向关联。
|
|
98
|
+
const selected = treeStatus.checkedKeys.indexOf(currentObj[this.nodeKey]) // -1未选中
|
|
99
|
+
// 选中
|
|
100
|
+
if (selected !== -1) {
|
|
101
|
+
// 子节点只要被选中父节点就被选中
|
|
102
|
+
this.selectedParent(currentObj, ref)
|
|
103
|
+
// 统一处理子节点为相同的勾选状态
|
|
104
|
+
this.uniteChildSame(currentObj, true, ref)
|
|
105
|
+
} else {
|
|
106
|
+
// 取消子节点的选中状态触发
|
|
107
|
+
if (currentObj.parentId !== -1) {
|
|
108
|
+
this.removeParent(currentObj, ref)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 未选中 处理子节点全部未选中
|
|
112
|
+
if (
|
|
113
|
+
currentObj[this.defaultProps.children] &&
|
|
114
|
+
currentObj[this.defaultProps.children].length !== 0
|
|
115
|
+
) {
|
|
116
|
+
this.uniteChildSame(currentObj, false, ref)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.$emit('on-check', this.getCheckedKeys())
|
|
120
|
+
},
|
|
121
|
+
/** 统一处理子节点为相同的勾选状态 **/
|
|
122
|
+
uniteChildSame(treeList, isSelected, ref) {
|
|
123
|
+
const treeListData = treeList[this.defaultProps.children] || []
|
|
124
|
+
const len = treeListData.length
|
|
125
|
+
|
|
126
|
+
ref.setChecked(treeList[this.nodeKey], isSelected)
|
|
127
|
+
|
|
128
|
+
for (let i = 0; i < len; i++) {
|
|
129
|
+
this.uniteChildSame(treeListData[i], isSelected, ref)
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/** 统一处理父节点为选中 **/
|
|
134
|
+
selectedParent(currentObj, ref) {
|
|
135
|
+
const currentNode = ref.getNode(currentObj)
|
|
136
|
+
if (currentNode.parent.key !== undefined) {
|
|
137
|
+
ref.setChecked(currentNode.parent, true)
|
|
138
|
+
return this.selectedParent(currentNode.parent, ref)
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
/** 子节点全没选中取消父级的选中状态 **/
|
|
143
|
+
removeParent(currentObj, ref) {
|
|
144
|
+
let a = 0
|
|
145
|
+
let b = 0
|
|
146
|
+
const currentNode = ref.getNode(currentObj)
|
|
147
|
+
if (currentNode.parent !== null) {
|
|
148
|
+
if (currentNode.parent.key !== undefined) {
|
|
149
|
+
ref.setChecked(currentNode.parent, true) // 根节点
|
|
150
|
+
this.removeParent(currentNode.parent, ref) // 递归判断子节点
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 不为0表示为父节点
|
|
155
|
+
if (currentNode.childNodes.length !== 0) {
|
|
156
|
+
// 循环判断父节点下的子节点
|
|
157
|
+
for (let i = 0; i < currentNode.childNodes.length; i++) {
|
|
158
|
+
// 判断父节点下的子节点是否全为false
|
|
159
|
+
if (currentNode.childNodes[i].checked === false) {
|
|
160
|
+
++a
|
|
161
|
+
|
|
162
|
+
// a === currentNode.childNodes.length 表明子节点全为false
|
|
163
|
+
if (a === currentNode.childNodes.length) {
|
|
164
|
+
// 等于 undefined 跳过,不等于继续执行
|
|
165
|
+
if (currentNode.childNodes[i].parent.key !== undefined) {
|
|
166
|
+
ref.setChecked(currentNode.childNodes[i].parent, false) // 父元素设置为false
|
|
167
|
+
// 循环上级父节点下的子节点
|
|
168
|
+
for (let i = 0; i < currentNode.parent.childNodes.length; i++) {
|
|
169
|
+
// 判断父节点下的子节点是否全为false
|
|
170
|
+
if (currentNode.parent.childNodes[i].checked === false) {
|
|
171
|
+
++b
|
|
172
|
+
|
|
173
|
+
// b === currentNode.parent.childNodes.length 表明子节点全为false
|
|
174
|
+
if (b === currentNode.parent.childNodes.length) {
|
|
175
|
+
ref.setChecked(currentNode.parent.key, false) // 父元素设置为false
|
|
176
|
+
return this.removeParent(currentNode.parent, ref) // 继续递归循环判断
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
</script>
|
|
189
|
+
|
|
190
|
+
<style lang="scss">
|
|
191
|
+
|
|
192
|
+
</style>
|