organization.vue 1.45 KB
<template>
	<view class="org-content">
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<view>
			<luyj-tree @sendValue="confirm" :is-check="isCheck" :search-placeholder="$t('common.pleaseEnterContent')" :search-if="true" v-slot:default="{ item }" :max="max" :trees="tree">
				<view>
					<view class="content-item">
						<view class="word">{{ item.name }}</view>
					</view>
				</view>
			</luyj-tree>
			<mescroll-empty v-if="!tree.length" />
		</view>
	</view>
</template>

<script>
import { transOrgFunc } from '@/config/common.js';
import api from '@/api/index.js'

export default {
	data() {
		return {
			isCheck: true, // 是否可选
			tree: [],
			max: 5,
			id: ''
		};
	},
	onShow(){
		uni.setNavigationBarTitle({
			title:this.$t('menu.organizationScreening')
		})
	},
	onLoad(e) {
		// 隐藏原生的tabbar
		uni.hideTabBar();
		this.loadData();
	},
	methods: {
		async loadData() {
			const res = await api.homeApi.getMeOrgListApi()
			if (res) {
				const list = transOrgFunc(res);
				this.tree = list;
			}
		},
		confirm(val) {
			this.id = val[0].id;
			let pages = getCurrentPages(); //获取所有页面栈实例列表
			let nowPage = pages[pages.length - 1]; //当前页页面实例
			let prevPage = pages[pages.length - 2]; //上一页页面实例
			prevPage.$vm.ordId = this.id;
			uni.navigateBack({
				delta: 1
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.org-content {
	padding: 0 10rpx;
}
</style>