<template>
	<view class="zd_container">
		<nav-bar title="点位管理"></nav-bar>
		<view class="zd_content">
			<view class="item-wrapper">
				<view class="item-wrap" v-for="(e, i) in dataList" :key="i">
					<view class="zd-row">
						<view class="zd-col-24">
							<view class="zd-row">
								<view class="zd-col-24 item-font-1">{{e.point_code}}</view>
							</view>
							<view class="zd-row">
								<view class="zd-col-24 item-font-4">{{e.material_name}}</view>
							</view>
							<view class="zd-row">
								<view class="zd-col-11">
									<input type="number" class="zd-col-24 item-font-3" v-model="e.material_qty">
								</view>
								<view class="zd-col-9">
									<button class="submit-button_new" :disabled="disabled" @tap="_changePointQty(e)">更改固化室库存</button>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import {getGhsPointList, changePointQty} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				dataList: [],
				disabled: false,
				pkId: '',
				pkObj: {}
			};
		},
		created () {
			this._getGhsPointList()
		},
		methods: {
			async _getGhsPointList () {
				let res = await getGhsPointList()
				this.dataList = [...res]
			},
			async _changePointQty (e) {
				this.disabled = true
				try {
					let res = await changePointQty(e.group_id, e.material_qty)
					this.disabled = false
					this.pkId = ''
					this._getGhsPointList()
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

<style lang="stylus" scoped>
.zd_content
	padding-bottom 20rpx
.item-font-1
	font-size 36rpx
	color #333
	font-weight 700
	padding 0
.item-font-4
	color #999
.item-font-3
	font-size 36rpx
	line-height 66rpx
	height 66rpx
	padding 0
	background-color transparent
	text-align left
	border-bottom 1px solid #dcdfe6
.submit-button_new
	line-height 60rpx
	font-size 28rpx
</style>
