<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="contents">
				<u-divider :text="item.deptName + '介绍'" v-if="item.deptName"></u-divider>
				<image src="https://omo-oss-image.thefastimg.com/portal-saas/new2022102818501904409/cms/image/29a676ec-abc2-48fe-8657-ce8f05f8ceb2.jpg" mode="widthFix" style="width: 100%;height: 150px;" v-else></image>
				<u-parse :content="item.brief"></u-parse>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {},
			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/department/detail/' + item.deptId,
				success: (res) => {
					this.item = res.data.data;
					this.item.brief = res.data.data.brief.replace(new RegExp('/profile/upload/', 'g'), this.http.ip + '/profile/upload/');
				}
			});
		}
	}
};
</script>

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