<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">大/小卷</span>
					</view>
					<view class="zd-col-17 filter_picker">
						<picker @change="pickerChange" :value="index1" :range="options1" range-key="text">
							<view class="uni-input">{{index1 !== '' ? options1[index1].text : ''}}</view>
						</picker>
					</view>
					<uni-icons type="right" size="14" color="#999"></uni-icons>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-7">
						<span class="filter_label">缓存架</span>
					</view>
					<view class="zd-col-17 filter_select">
						<zxz-uni-data-select v-model="index" :localdata="options"></zxz-uni-data-select>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-8 button-default" @tap="clearUp">清空</button>
			<button class="zd-col-15 button-primary" :class="{'button-info': !index || index1 === ''}" :disabled="disabled" @tap="_temporaryStorage">确认暂存</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {queryOrderInfo, temporaryStorage} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				options1: [{value: '1', text: '大卷'}, {value: '2', text: '小卷'}],
				index1: '',
				index: '',
				options: [],
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
			this._queryOrderInfo()
		},
		methods: {
			pickerChange (e) {
				this.index1 = e.detail.value
			},
			async _queryOrderInfo () {
				let res = await queryOrderInfo('1')
				this.options = [...res.data]
				this.options.map(el => {
					this.$set(el, 'text', el.zc_point)
					this.$set(el, 'value', el.zc_point)
				})
			},
			clearUp () {
				this.index = ''
				this.index1 = ''
				this.disabled = false
			},
			async _temporaryStorage () {
				this.disabled = true
				if (!this.index || this.index1 === '') {
					this.disabled = false
					return
				}
				try {
					let res = await temporaryStorage(this.options1[this.index1].value, this.index)
					this.clearUp()
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

<style lang="stylus" scoped>
.zd_content
	height: calc(100% - var(--status-bar-height) - 212rpx);
	padding: 20rpx 14rpx 0 14rpx;
.grid-wraper
	height: 100%;
	overflow: auto;
.slide_new table td, .slide_new table th
	overflow: visible;
</style>
