<template>
	<view class="wrap">
		<page-nav :desc="desc" :title="title"></page-nav>
		<view class="container">
			<uni-list>
				<uni-list-item v-for="(item, index) in dictList" :key="index">
					<template v-slot:body>
						<image slot="icon" class="u-cell-icon" :src="getIcon('cell')" mode="widthFix"></image>
						<view @click="selectItem(item)">
							<text>{{item.dictValue}}</text>
						</view>
					</template>
				</uni-list-item>
			</uni-list>
		</view>

		<!-- 		<view class="list-wrap">
			<u-cell-group title-bg-color="rgb(243, 244, 246)" :title="item.groupName"
				v-for="(item, index) in dictList" :key="index">
				<u-cell-item :titleStyle="{fontWeight: 500}" @click="selectItem(item1)"
					:title="item1.dictValue" v-for="(item1, index1) in item.list" :key="index1">
					<image slot="icon" class="u-cell-icon" :src="getIcon('cell')" mode="widthFix"></image>
				</u-cell-item>
			</u-cell-group>
		</view> -->
		<u-gap height="70"></u-gap>
	</view>
</template>

<script>
	import pageNav from '@/components/page-nav/page-nav.vue';
	import http from '@/http/api.js'
	export default {
		components: {
			pageNav
		},
		onLoad(option) {

			let dictId = option.id;

			// let dictList = {};
			// dictList['groupName'] = '列表信息';
			var list = [];

			http.request({
				url: '/galaxy-system/dict-biz/list?parentId=' + dictId,
				//url: '/galaxy-system/dict-biz/child-list?parentId=' + dictId,
				method: 'GET'
			}).then(res => {
				console.log(res.data)
				if (res.data != null) {
					const dictLength = res.data['length'];
					for (var i = 0; i < dictLength; i++) {
						let dict = res.data['' + i];
						list.push(dict);
					}
				}

			}).catch(err => {
				console.log(err)
			})

			// dictList['list'] = list;
			this.dictList = list;


		},
		data() {
			return {
				dictList: [],
				title: '选择检查部位',
				desc: ''
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			},
		},
		onShow() {
			uni.setNavigationBarTitle({
				title: ""
			});
		},
		created() {

		},
		methods: {
			selectItem(dict) {
				uni.$emit("handClickItemLabelSelect", {
					id: dict['id'],
					dictKey: dict['dictKey'],
					dictValue: dict['dictValue']
				});
				uni.navigateBack();
			},
		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>
	.u-cell-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}
		.slot-box {
			/* #ifndef APP-NVUE */
			display: flex;
			/* #endif */
			flex-direction: row;
			align-items: center;
		}
	
		.slot-image {
			/* #ifndef APP-NVUE */
			display: block;
			/* #endif */
			margin-right: 10px;
			width: 30px;
			height: 30px;
		}
	
		.slot-text {
			flex: 1;
			font-size: 14px;
			color: #4cd964;
			margin-right: 10px;
		}
</style>
