<template>
	<view class="zd_container">
		<nav-bar :title="title"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="zd-row border-bottom">
					<view class="zd-col-7">
						<span class="filter_label">{{$t('filter.point')}}</span>
					</view>
					<view class="zd-col-24 filter_select">
						<uni-data-select :placeholder="placeholder" v-model="index" :localdata="options" @change="selectChange"></uni-data-select>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-11 button-default" @click="cancle">{{$t('button.cancel')}}</button>
			<button class="zd-col-11 button-primary" :class="{'button-info': index === ''}" :disabled="disabled" @tap="_updateTask('1')">{{$t('take-and-place')}}</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import {updateTask} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				placeholder: this.$t('uni.dataSelect.placeholder'),
				title: '',
				options: [{text:'QFQ_2', value:'QFQ_2'},{text:'QFQ_4',value: 'QFQ_4'}],
				index: '',
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			selectChange (e) {
				this.index = e
				this.disabled = false
			},
			cancle () {
				this.index = ''
			},
			async _updateTask (type) {
				this.disabled = true
				if (!this.index) {
					this.disabled = false
					return
				}
				try {
					let res = await updateTask(this.index, type)
					this.cancle()
					uni.showToast({
						title: res.desc,
						icon: 'none'
					})
				} catch (err) {
					this.disabled = false
				}
			}
		}
	}
</script>

<style lang="stylus" scoped>
</style>
