<template>
	<!-- 选择门店 -->
	<view>
		<u-navbar title="选择门店" autoBack placeholder></u-navbar>
		<view class="card_search_head">
			<u-search v-model="cylinderNumber" shape="square" :showAction="false" placeholder="请输入门店名称"
				borderColor="#e4e7ed" bgColor="#fff" @change="quickSearch"></u-search>
		</view>
		<view v-if="treeData.length > 0">
			<tree-item v-for="item in treeData" :key="item.id" :item="item" @confirm="confirm"></tree-item>
		</view>
		<view style="margin-top: 30%;" v-else>
			<u-empty mode="list" text="暂无门店"></u-empty>
		</view>
	</view>
</template>

<script>
	import TreeItem from '@/components/TreeItem.vue';
	export default {
		components: {
			TreeItem
		},
		data() {
			return {
				cylinderNumber: '',
				flowId: '',
				treeData: [],
			}
		},
		onLoad(value) {
			this.flowId = value.flowId
			this.flowName = value.flowName
			this.getList()
		},
		methods: {
			getList() {
				this.$api.get('/api/store/all2', {
					name: this.cylinderNumber,
				}).then(res => {
					if (res.code == 200) {
						if (res.data) {
							this.treeData = res.data
						}
					}
				})
			},
			confirm(value) {
				uni.navigateTo({
					url: '/pages/information/recipient?shopID=' + value.id + '&shopName=' + value.name +
						'&flowId=' + this.flowId +
						'&flowName=' + this.flowName
				});
			},
			quickSearch() {
				this.treeData = []
				this.getList()
			},
		}
	}
</script>

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