<template>
	<view class="msilde">
		<view class="left">
			<u-collapse accordion @open="current = -1">
				<u-collapse-item :title="d.deptName" name="Docs guide" v-for="(d, index) in list" :key="d.deptName">
					<view :class="{ active: index == current }" v-for="(i, index) in d.children" :key="i.deptName" class="item" @click="selected(i, index)">{{ i.deptName }}</view>
				</u-collapse-item>
			</u-collapse>
		</view>
		<view class="right">
			<view class="list">
				<view v-for="(item, index) in doctor_list" :key="index" class="item">
					<image src="../../static/tx.jpg" mode="widthFix" class="head"></image>
					<view class="name">{{ item.name }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			doctor_list: {},
			current: -1,
			list: []
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/department/list',
				success: (res) => {
					this.list = res.data.data;
				}
			});
		},
		selected(item, index) {
			this.current = index;
			this.http.request({
				url: '/app/doctor/list',
				data: { deptId: item.deptId },
				success: (res) => {
					this.doctor_list = res.data.data;
				}
			});
		}
	}
};
</script>

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