jsy-app/components/custom-select-land/custom-select-land.vue

141 lines
2.9 KiB
Vue
Raw Normal View History

2024-09-18 10:30:10 +08:00
<template>
<u-popup mode="left" :show="show" @close="close">
<u-collapse ref="refCollapse" :value="showValue" @change="changeItem" @open="openItem" @close="closeItem"
accordion>
<u-collapse-item v-for="(item,i) in list" :name="i">
<template v-slot:icon>
<view class="iconfont icon-qiye icon"></view>
</template>
<template v-slot:title>
2024-09-25 18:47:15 +08:00
{{item.label}}
2024-09-18 10:30:10 +08:00
</template>
<template v-slot:right-icon>
2024-09-25 18:47:15 +08:00
<u-badge numberType="overflow" type="primary" max="999" :showZero="true"
:value="item.children.length" />
2024-09-18 10:30:10 +08:00
</template>
2024-09-25 18:47:15 +08:00
<view class="u-collapse-content" v-if="item.id == selectCId">
2024-09-18 10:30:10 +08:00
<u-list>
<u-list-item v-for="item2 in item.children">
<u-cell @click="select(item2)">
<template v-slot:icon>
<view class="iconfont icon-ditu icon"></view>
</template>
<template v-slot:title>
2024-09-25 18:47:15 +08:00
{{item2.name}}
2024-09-18 10:30:10 +08:00
</template>
<template v-slot:right-icon>
2024-09-25 18:47:15 +08:00
<u-badge numberType="overflow" type="success" max="999" :showZero="true"
:value="item2.valueNum" />
2024-09-18 10:30:10 +08:00
</template>
</u-cell>
</u-list-item>
</u-list>
</view>
</u-collapse-item>
</u-collapse>
</u-popup>
</template>
<script>
2024-09-25 18:47:15 +08:00
import store from "@/store"
import {
deptTreeSelectByRole,
getManagerGroundList,
} from "@/api/index.js"
2024-09-18 10:30:10 +08:00
export default {
name: 'custom-select-land',
emits: ["select"],
2024-09-25 18:47:15 +08:00
props: {},
2024-09-18 10:30:10 +08:00
watch: {},
data() {
return {
2024-09-25 18:47:15 +08:00
user: store.state.user.user,
2024-09-18 10:30:10 +08:00
show: false,
showValue: null,
2024-09-25 18:47:15 +08:00
list: getApp().land.list,
selectCId: getApp().land.selectCId,
selectItem: getApp().land.selectItem,
2024-09-18 10:30:10 +08:00
}
},
created() {
2024-09-25 18:47:15 +08:00
const that = this;
getApp().land.getList(that.user.userId);
that.list = getApp().land.list;
that.selectCId = getApp().land.selectCId;
that.selectItem = getApp().land.selectItem;
2024-09-18 10:30:10 +08:00
},
methods: {
open() {
2024-09-25 18:47:15 +08:00
console.log("open:", this.list);
2024-09-18 10:30:10 +08:00
if (this.list.length > 0) {
this.show = true;
} else {
2024-09-25 18:47:15 +08:00
this.$toast("无数据");
2024-09-18 10:30:10 +08:00
}
},
close() {
2024-09-25 18:47:15 +08:00
this.show = false;
2024-09-18 10:30:10 +08:00
},
select(item) {
2024-09-25 18:47:15 +08:00
this.selectItem = item;
getApp().land.setStorage(2, item);
2024-09-18 10:30:10 +08:00
this.$emit("select", item);
this.close();
},
changeItem(e) {
console.log("changeItem:", e);
},
openItem(e) {
this.showValue = e;
2024-09-25 18:47:15 +08:00
this.selectCId = this.list[e].id;
2024-09-18 10:30:10 +08:00
this.$nextTick(() => {
this.$refs.refCollapse.init();
})
},
closeItem(e) {
this.showValue = null;
}
}
}
</script>
<style lang="scss" scoped>
$list-height: 100px;
::v-deep.u-popup__content {
min-width: 240px;
.u-collapse {
height: 100vh;
overflow-y: auto;
}
.u-cell__right-icon-wrap--down,
.u-cell__right-icon-wrap--up {
transform: none;
}
.u-collapse-item__content__text {
padding: 0;
}
.u-cell__body__content {
.icon {
color: #3c9cff;
font-size: 44rpx;
}
}
.u-collapse-content {
font-size: 28rpx;
.icon {
color: #39ac4f;
}
}
}
</style>