<template>
	
	<view class="page-wraper">
		
		<view class="page-header">
			<view class="" style="margin: 10rpx;">
				<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
					activeColor="#007AFF"></uni-segmented-control>
			</view>
			
		</view>
	
		<view class="page-main">
			<scroll-view scroll-y="true" class="page-main-scroll">
				<view class="uni-flex uni-row" style="flex-wrap: wrap;">
					<view class="uni-flex" style=" width: 50%; justify-content: center; margin-top: 40rpx; "
						v-for="(item, index) in dataList" :key="index">
						<uni-tag :inverted="!item.checked" :circle="false" :text="item.itemCode" type="primary"
							@click="setContainerModel(item)"
							 />
					</view>
				
				</view>
			</scroll-view>
		</view>
	
		<view class="page-footer">
			<view class="uni-flex u-col-center space-between padding_10"
				style="background-color:ghostwhite; width: 100%; ">
				<view class="">
				</view>
				<view class="new_btn_bot count_shadow">
					<button type="primary" class="new_save_btn" @click="submit()">提交</button>
				</view>
			</view>
		</view>
	
	
		<com-message ref="comMessage"></com-message>
	</view>
</template>
<script>
	import {
		injectIssueRequest
	} from '@/api/index.js';
	import {
		goHome,
		dateFormat,
		getContainerTypeName,
		showConfirmMsg
	} from '@/common/basic.js';
	import winEmptyView from '@/mycomponents/wincom/winEmptyView.vue'
	import comJobTopInfo from '@/mycomponents/comjob/comJobTopInfo.vue'
	import comMessage from '@/mycomponents/common/comMessage.vue'
	export default {
		components: {
			winEmptyView,
			comJobTopInfo,
			comMessage
		},
		data() {
			return {
				items: ['保险杠', '轮眉','车门装饰板'],
				current: 0,
				pageSize: this.modelConfig,
				pageIndex: 1,
				loadingType: "nomore",
				dataList: [{itemCode:"THILDD0A542AG5",checked:false},
				{itemCode:"THILDD0A542AG5",checked:false},
				{itemCode:"THILDD0A542AG5",checked:false},
				{itemCode:"THILDD0A542AG4",checked:false},
				{itemCode:"THILDD0A542AG4",checked:false},
				{itemCode:"THILDD0A542AG4",checked:false},
				{itemCode:"123456",checked:false},
				{itemCode:"1234888",checked:false},
				{itemCode:"12349528",checked:false}
					
				],
				isFinished:false
			};
		},
		filters: {
			formatDate: function(val) {
				return dateFormat(val)
			},
		},

		onShow() {
		},
		onReachBottom() {
		},
		onPullDownRefresh() {
		},
		//后退按钮
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false;
			}
			goHome();
			return true;
		},
		//返回首页
		onNavigationBarButtonTap(e) {
			if (e.index === 0) {
				goHome();
			} else if (e.index === 1) {
				window.location.reload();
			}
		},
		methods: {
			setContainerModel(item) {
				this.dataList.forEach(res => {
					res.checked = false
				})
				item.checked = true;
			},
			onClickItem(item) {
				this.current = item.currentIndex;
				console.log("点击", this.current)
				if(this.current==0){
					this.isFinished =false;
				}else {
					this.isFinished =true;
				}
			},

			//查询发货任务
			showMessage(message) {
				this.$refs.comMessage.showMessage(message);
			},
			showCommitSuccessMessage() {
				this.$refs.comMessage.showCommitSuccess();
			},
			submit(item) {
				uni.showLoading({
					title: "提交中...",
					mask:true
				});
				
				console.log("测试",JSON.stringify(params));
				injectIssueRequest(item.id, params)
					.then(res => {
						uni.hideLoading();
						if (res != null) {
							this.showCommitSuccessMessage();
							this.getList("refresh")
						}
					})
					.catch(err => {
						this.showMessage(err.message);
						uni.hideLoading();
					});
			},
		}
	};
</script>