|
|
@@ -5,11 +5,18 @@
|
|
5
|
5
|
<view class="tree-cover" :class="{'show':showDialog}" @tap="_cancel"></view>
|
|
6
|
6
|
<view class="tree-dialog" :class="{'show':showDialog}">
|
|
7
|
7
|
<view class="tree-bar">
|
|
8
|
|
- <view class="tree-bar-cancel" :style="{'color':cancelColor}" hover-class="hover-c" @tap="_cancel">取消
|
|
|
8
|
+ <view class="tree-bar-left">
|
|
|
9
|
+ <view class="tree-bar-cancel" :style="{'color':cancelColor}" hover-class="hover-c" @tap="_cancel">取消
|
|
|
10
|
+ </view>
|
|
9
|
11
|
</view>
|
|
10
|
12
|
<view class="tree-bar-title" :style="{'color':titleColor}">{{title}}</view>
|
|
11
|
|
- <view class="tree-bar-confirm" :style="{'color':confirmColor}" hover-class="hover-c" @tap="_confirm">
|
|
12
|
|
- {{multiple?'确定':''}}
|
|
|
13
|
+ <view class="tree-bar-right">
|
|
|
14
|
+ <view v-if="showClear" class="tree-bar-clear" :style="{'color':cancelColor}" hover-class="hover-c" @tap="_clear">
|
|
|
15
|
+ 清除
|
|
|
16
|
+ </view>
|
|
|
17
|
+ <view class="tree-bar-confirm" :style="{'color':confirmColor}" hover-class="hover-c" @tap="_confirm">
|
|
|
18
|
+ {{multiple?'确定':''}}
|
|
|
19
|
+ </view>
|
|
13
|
20
|
</view>
|
|
14
|
21
|
</view>
|
|
15
|
22
|
<view class="tree-view">
|
|
|
@@ -64,7 +71,7 @@
|
|
64
|
71
|
|
|
65
|
72
|
<script>
|
|
66
|
73
|
export default {
|
|
67
|
|
- emits: ['select-change'],
|
|
|
74
|
+ emits: ['select-change', 'clear'],
|
|
68
|
75
|
name: "ba-tree-picker",
|
|
69
|
76
|
props: {
|
|
70
|
77
|
personNames : {
|
|
|
@@ -129,6 +136,10 @@
|
|
129
|
136
|
type: Boolean,
|
|
130
|
137
|
default: false
|
|
131
|
138
|
},
|
|
|
139
|
+ showClear: { // 是否显示清除按钮
|
|
|
140
|
+ type: Boolean,
|
|
|
141
|
+ default: true
|
|
|
142
|
+ },
|
|
132
|
143
|
},
|
|
133
|
144
|
data() {
|
|
134
|
145
|
return {
|
|
|
@@ -167,6 +178,23 @@
|
|
167
|
178
|
this._hide()
|
|
168
|
179
|
this.$emit("cancel", '');
|
|
169
|
180
|
},
|
|
|
181
|
+ _clear() {
|
|
|
182
|
+ // 清除所有选中状态
|
|
|
183
|
+ this.treeList.forEach((item, index) => {
|
|
|
184
|
+ this.treeList[index].checkStatus = 0;
|
|
|
185
|
+ this.treeList[index].childCheckCount = 0;
|
|
|
186
|
+ this.treeList[index].childCheckPCount = 0;
|
|
|
187
|
+ });
|
|
|
188
|
+
|
|
|
189
|
+ // 关闭对话框
|
|
|
190
|
+ this._hide();
|
|
|
191
|
+
|
|
|
192
|
+ // 触发选择变更事件,返回空值
|
|
|
193
|
+ this.$emit("select-change", [], []);
|
|
|
194
|
+
|
|
|
195
|
+ // 触发清除事件
|
|
|
196
|
+ this.$emit("clear", '');
|
|
|
197
|
+ },
|
|
170
|
198
|
_confirm() { //多选
|
|
171
|
199
|
let selectedList = []; //如果子集全部选中,只返回父级 id
|
|
172
|
200
|
let selectedNames = [];
|
|
|
@@ -508,12 +536,31 @@
|
|
508
|
536
|
line-height: 1;
|
|
509
|
537
|
}
|
|
510
|
538
|
|
|
|
539
|
+ .tree-bar-left {
|
|
|
540
|
+ display: flex;
|
|
|
541
|
+ align-items: center;
|
|
|
542
|
+ }
|
|
|
543
|
+
|
|
|
544
|
+ .tree-bar-right {
|
|
|
545
|
+ display: flex;
|
|
|
546
|
+ align-items: center;
|
|
|
547
|
+ gap: 20rpx;
|
|
|
548
|
+ }
|
|
|
549
|
+
|
|
511
|
550
|
.tree-bar-confirm {
|
|
512
|
551
|
color: #0055ff;
|
|
513
|
552
|
padding: 15rpx;
|
|
514
|
553
|
}
|
|
515
|
554
|
|
|
516
|
|
- .tree-bar-title {}
|
|
|
555
|
+ .tree-bar-clear {
|
|
|
556
|
+ color: #757575;
|
|
|
557
|
+ padding: 15rpx;
|
|
|
558
|
+ }
|
|
|
559
|
+
|
|
|
560
|
+ .tree-bar-title {
|
|
|
561
|
+ flex: 1;
|
|
|
562
|
+ text-align: center;
|
|
|
563
|
+ }
|
|
517
|
564
|
|
|
518
|
565
|
.tree-bar-cancel {
|
|
519
|
566
|
color: #757575;
|