<template>
	<view>
		<view class="search">
			<view class="box" @click="go_search()">
				<view class="icon">
					<uni-icons type="search" size="16" color="#BBBBBB"></uni-icons>
				</view>
				<view class="text">搜索</view>
			</view>
		</view>

		<view class="content">
			<!-- <view class="title">

				<view class="tab" @click="change_tab_active(1)">
					<view class="text" :class="tab_active == 1?'active':''">最近常用</view>
					<view class="line" v-if="tab_active == 1"></view>
				</view>
				<view class="tab" @click="change_tab_active(2)">
					<view class="text" :class="tab_active == 2?'active':''">全部流程</view>
					<view class="line" v-if="tab_active == 2"></view>
				</view>

			</view> -->

			<!-- 暂时一个分类 -->
			<view class="title">
				<view class="tab">
					<view class="text" :class="tab_active == 1?'active':''">全部流程</view>
					<view class="line" v-if="tab_active == 1"></view>
				</view>
			</view>

			<view class="section" v-for="(item,index) in list" :key="index">
				<view class="box">
					<view class="item">
						<view class="left">
							<view class="icon" v-if="active == index" @click.stop="change_active(index)">
								<image src="./icon/close.png" mode=""></image>
							</view>
							<view class="icon" v-if="active != index" @click.stop="change_active(index)">
								<image src="./icon/open.png" mode=""></image>
							</view>
							<view class="text">{{item.type}} （{{item.count}}）</view>
						</view>
					</view>
					<view class="list" v-if="active == index">
						<view class="item" v-for="(item_2,index_2) in item.list" :key="index_2"
							@click="go_detail_apply(item_2.name,item_2.flow_set_id)">
							<view class="left">
								<view class="text">{{item_2.name}}</view>
							</view>
							<view class="right">
								<uni-icons type="compose"></uni-icons>
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		set_base_url
	} from '@/common/set_base_url.js'

	export default {
		data() {
			return {
				// 切换
				tab_active: 1,

				list: [],
				// 当前展开
				active: 99999999,

			};
		},
		onLoad() {
			this.get_list()
		},
		methods: {
			// 搜索
			go_search() {
				uni.navigateTo({
					url: "./search/search",
					animationType: "fade-in",
					animationDuration: 200
				})
			},

			change_tab_active(item) {
				this.tab_active = item
			},

			change_active(index) {
				if (this.active == index) {
					this.active = 99999999
				} else {
					this.active = index
				}
			},

			get_list() {
				this.$api.workflow_get_all_list({

				}).then((res) => {
					console.log(res)
					this.list = res.data.content.data
				})

			},
			go_detail_apply(name, flow_set_id) {
				uni.navigateTo({
					url: "./detail_apply/detail_apply?title=" + name + "&flow_set_id=" + flow_set_id
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F3F8F7;
	}

	.search {
		margin-bottom: 20rpx;
		background-color: #FFFFFF;
		box-sizing: border-box;
		padding: 25rpx 30rpx;

		.box {
			height: 80rpx;
			background-color: #F4F4F4;
			border-radius: 50rpx;

			display: flex;
			align-items: center;

			box-sizing: border-box;
			padding: 0 25rpx;

			.icon {
				margin-right: 10rpx;
			}

			.text {
				font-size: 30rpx;
				color: #BBBBBB;
			}
		}
	}

	.content {
		background-color: #FFFFFF;

		.title {
			height: 110rpx;
			display: flex;
			align-items: center;

			box-sizing: border-box;
			padding: 0 25rpx;
			border-bottom: 1rpx solid #F3F8F7;

			.tab {
				width: 350rpx;
				line-height: 110rpx;
				position: relative;

				.text {
					text-align: center;
				}

				.line {
					position: absolute;
					left: 50%;
					bottom: 0;

					transform: translateX(-40rpx);

					width: 80rpx;
					height: 4rpx;
					background-color: #00A0E8;
				}

				.active {
					color: #00A0E8;
					font-weight: 700;
				}
			}
		}

		.section {
			box-sizing: border-box;
			padding: 0 20rpx;

			.box {

				.item {
					height: 110rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;

					margin-left: 20rpx;
					border-bottom: 1rpx solid #F3F8F7;

					.left {
						display: flex;
						align-items: center;

						.icon {
							line-height: 110rpx;
							width: 90rpx;
							text-align: center;

							image {
								width: 24rpx;
								height: 24rpx;
							}
						}

						.text {
							font-size: 32rpx;
						}
					}

				}

				.list {
					.item {
						height: 110rpx;

						display: flex;
						justify-content: space-between;
						align-items: center;

						margin-left: 108rpx;
						border-bottom: 1rpx solid #F3F8F7;

						.left {
							.text {
								margin-left: 18rpx;
								font-size: 30rpx;

							}
						}

						.right {
							line-height: 110rpx;
							width: 90rpx;
							text-align: center;
						}

					}
				}

			}

		}

	}
</style>
