<template>
	<view class="zd_container">
		<nav-bar title="物料库存"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="filter_item">
					<view class="filter_label">物料</view>
					<view class="filter_input_wraper">
						<uni-data-select v-model="index1" :localdata="options1" @change="selectChange1"></uni-data-select>
					</view>
				</view>
			</view>
			<view class="item-wrapper">
				<view class="item-wrap" v-for="(e, i) in dataList" :key="i">
					<view class="zd-row jcflexstart mgb10">
						<view class="item-font-1 item-font-5">{{e.material_code}}</view>
						<view class="item-line-2"></view>
						<view class="item-font-1 item-font-6">{{e.material_name}}</view>
					</view>
					<view class="zd-row jcflexstart">
						<view class="item-font-1 item-font-6">点位:</view>
						<view class="item-font-1">{{e.point_code}}{{e.point_name}}</view>
					</view>
					<view class="zd-row">
						<view class="zd-col-20 zd-row jcflexstart">
							<view class="item-font-4">设备:</view>
							<view class="item-font-4">{{e.vehicle_code}}</view>
						</view>
						<view class="zd-col-4 item-status" :class="'item-status-' + e.vehicle_type">{{textState(e.vehicle_type)}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar_new">
			<button class="zd-col-7 submit-button_c" @tap="toClear">清空</button>
			<button class="zd-col-15 submit-button_new" @tap="_getInventoryMaterialInfo">查询</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import {materialList, getInventoryMaterialInfo} from '@/utils/mork2.js'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				dataList: [],
				disabled: false,
				options1: [],
				index1: '',
				pkId: ''
			};
		},
		created () {
			this._materialList()
		},
		methods: {
			textState (e) {
				switch (e) {
					case '1':
						return '普涂'
						break
					case '2':
						return '连涂'
						break
					default:
						return ''
						break
				}
			},
			selectChange1 (e) {
				this.index1 = e
			},
			/** 下拉框查询 */
			async _materialList () {
				let res = await materialList()
				this.options1 = [...res]
			},
			async _getInventoryMaterialInfo () {
				let res = await getInventoryMaterialInfo(this.index1)
				this.dataList = [...res]
			},
			toClear () {
				this.index1 = ''
				this.dataList = []
			}
		}
	}
</script>

<style lang="stylus">
.item-font-5
	color #2b87ff
	font-weight bold
.item-font-6
	color #000
.item-font-4
	color #323232
.item-status
	border-top-left-radius: 15rpx
	border-bottom-left-radius: 0
	border-top-right-radius: 0
	border-bottom-right-radius: 15rpx
.item-status-1
	background-color: #f3ccb5;
	color: #ff5e00;
.item-status-2
	background-color: #96f3b8;
	color: #36744c;
</style>
