<template>
	<view class="msilde">
		<view class="search">
			<u-search placeholder="搜索科室" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/department/search')"></u-search>
		</view>
		<view class="left">
			<view :class="{ active: index == current }" v-for="(item, index) in list" :key="index" class="item" @click="current = index">{{ item.deptName }}</view>
		</view>
		<view class="right">
			<view class="list" v-if="list.length > 0">
				<view class="item" v-for="(item, index) in list[current].children" :key="item.deptId" @click="go('/pages/department/detail?id=' + item.deptId)">
					<view class="title omit">{{ item.deptName }}</view>
					<view class="icon">&#xe62b;</view>
				</view>
			</view>
			<u-empty v-else text="整理资料中..."></u-empty>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			title: '',
			current: 0,
			list: []
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/department/list',
				success: (res) => {
					this.list = res.data.data;
				}
			});
		},
		go(url) {
			uni.navigateTo({ url: url });
		}
	}
};
</script>

<style lang="scss"></style>
