|
|
@@ -8,6 +8,16 @@ const tranverse = (e, itemListKey) => {
|
|
|
e[i].selected = false;
|
|
|
}
|
|
|
}
|
|
|
+const tranverseTrue = (e, itemListKey) => {
|
|
|
+
|
|
|
+ for (let i in e) {
|
|
|
+ if (e[i][itemListKey]) {
|
|
|
+ e[i].open = true;
|
|
|
+ tranverseTrue(e[i][itemListKey], itemListKey)
|
|
|
+ }
|
|
|
+ e[i].selected = true;
|
|
|
+ }
|
|
|
+}
|
|
|
Component({
|
|
|
properties: {
|
|
|
treeList: Object,
|
|
|
@@ -27,7 +37,7 @@ Component({
|
|
|
type: String,
|
|
|
value: ""
|
|
|
},
|
|
|
- flgValidOnFlag:{ //默认显示启用
|
|
|
+ flgValidOnFlag: { //默认显示启用
|
|
|
type: Boolean,
|
|
|
value: true
|
|
|
},
|
|
|
@@ -61,7 +71,7 @@ Component({
|
|
|
isLastClickFlag: { //控制是否只可以点击末级
|
|
|
type: Boolean,
|
|
|
value: false
|
|
|
- },
|
|
|
+ },
|
|
|
},
|
|
|
data: {
|
|
|
},
|
|
|
@@ -91,13 +101,13 @@ Component({
|
|
|
|
|
|
onSwipeBind(e) {
|
|
|
console.log('onSwipeBind', e);
|
|
|
- this.triggerEvent('onSwipe',e);
|
|
|
+ this.triggerEvent('onSwipe', e);
|
|
|
},
|
|
|
- subonSwipeBind_(e){
|
|
|
+ subonSwipeBind_(e) {
|
|
|
console.log('subonSwipeBind_', e);
|
|
|
this.triggerEvent('onSwipe', e.detail);
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// onSwipeBind_(e) {
|
|
|
// console.log('onSwipeBind_', e)
|
|
|
// this.triggerEvent('onSwipe_', e);
|
|
|
@@ -124,6 +134,28 @@ Component({
|
|
|
})
|
|
|
|
|
|
},
|
|
|
+ //设置控件信息
|
|
|
+ setDataFromPageTrue(data) {
|
|
|
+ const { itemListKey } = this.data;
|
|
|
+ const { parentIdKey } = this.data;
|
|
|
+ let treeList = data
|
|
|
+ for (let i in treeList) {
|
|
|
+ if (treeList[i][itemListKey]) {
|
|
|
+ if (treeList[i][parentIdKey]) {
|
|
|
+ treeList[i].open = true;
|
|
|
+ } else {
|
|
|
+ treeList[i].open = true;
|
|
|
+ }
|
|
|
+ tranverseTrue(treeList[i][itemListKey], itemListKey);
|
|
|
+ }
|
|
|
+ treeList[i].selected = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ tree: treeList
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
//修改折叠状态
|
|
|
changeOpen(tree, id, itemListKey, idKey) {
|
|
|
for (let i = 0; i < tree.length; i += 1) {
|
|
|
@@ -163,20 +195,20 @@ Component({
|
|
|
clickName(e) {
|
|
|
const { idKey } = this.data;
|
|
|
const { nameKey } = this.data;
|
|
|
- const { itemListKey } = this.data;
|
|
|
+ const { itemListKey } = this.data;
|
|
|
|
|
|
- if(this.data.isLastClickFlag){ //开启只点击末级
|
|
|
- if(e.currentTarget.dataset.item[itemListKey]){ //还有子list 说明就不是末级
|
|
|
+ if (this.data.isLastClickFlag) { //开启只点击末级
|
|
|
+ if (e.currentTarget.dataset.item[itemListKey]) { //还有子list 说明就不是末级
|
|
|
return
|
|
|
}
|
|
|
- }
|
|
|
- this.triggerEvent('clickName', { id: e.currentTarget.dataset.item[idKey], name: e.currentTarget.dataset.item[nameKey] ,item:e.currentTarget.dataset.item});
|
|
|
+ }
|
|
|
+ this.triggerEvent('clickName', { id: e.currentTarget.dataset.item[idKey], name: e.currentTarget.dataset.item[nameKey], item: e.currentTarget.dataset.item });
|
|
|
|
|
|
},
|
|
|
//点击控件里的控件 回调
|
|
|
subclickName(e) {
|
|
|
|
|
|
- this.triggerEvent('clickName', { id: e.detail.id, name: e.detail.name,item:e.detail.item });
|
|
|
+ this.triggerEvent('clickName', { id: e.detail.id, name: e.detail.name, item: e.detail.item });
|
|
|
},
|
|
|
click(e) {
|
|
|
console.log("click")
|