<template>
	<view class="msilde">
		<view class="left">
			<view :class="{ active: index == current }" v-for="(item, index) in list" :key="index" class="item" @click="selected(item, index)">{{ item.deptName }}</view>
		</view>
		<view class="right">
			<view class="contents">
				<u-parse :content="item.brief" v-if="item.brief"></u-parse>
				<u-empty v-else text="整理资料中..."></u-empty>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			current: 0,
			item: {},
			list: []
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/department/list',
				success: (res) => {
					this.list = res.data.data;
					this.selected(this.list[0], 0);
				}
			});
		},
		selected(item, index) {
			this.current = index;
			this.http.request({
				url: '/app/department/detail/' + item.deptId,
				success: (res) => {
					this.item = res.data.data;
					if (res.data.data.brief) {
						this.item.brief = res.data.data.brief.replace(new RegExp('/profile/upload/', 'g'), this.http.ip + '/profile/upload/');
					}
				}
			});
		}
	}
};
</script>

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