<template>
	<view class="content">
		<nav-bar title="调拨维护"></nav-bar>
		<view class="search-confirm-wrap">
			<view class="zd-row">
				<view class="zd-col-24 zd-row">
					<view class="zd-col-8"><search-box v-model="val1" /></view>
					<view class="zd-col-8 select_wraper">
						<uni-data-select
						placeholder="请选择仓库名称"
						 v-model="value1"
						 :localdata="range1"
						></uni-data-select>
					</view>
					<view class="zd-col-7 select_wraper">
						<uni-data-select
						placeholder="请选择状态"
						 v-model="value"
						 :localdata="range"
						></uni-data-select>
					</view>
				</view>
				<button class="confirm-button mgr30" @tap="toSearch">查询</button>
				<button class="confirm-button" :class="{'confirm-button_disabled': checkArr1.length === 0}" @tap="toSure">直接调拨</button>
			</view>
		</view>
		<view class="zd-row jcflexstart table-title_wraper">调拨维护</view>
		<view class="grid-wrap">
			<view class="table-wrap">
				<view class="zd-row sticky zd-th-wraper">
					<view class="zd-col-1 zd-th"><text>序号</text></view>
					<view class="zd-col-1 zd-th"><text>选择</text></view>
					<view class="zd-col-2 zd-th"><text>物料编码</text></view>
					<view class="zd-col-2 zd-th"><text>物料名称</text></view>
					<view class="zd-col-2 zd-th"><text>规格型号</text></view>
					<view class="zd-col-2 zd-th"><text>辅助属性</text></view>
					<view class="zd-col-1 zd-th"><text>计里单位</text></view>
					<view class="zd-col-2 zd-th"><text>数量</text></view>
					<view class="zd-col-2 zd-th"><text>库存类型</text></view>
					<view class="zd-col-2 zd-th"><text>库存状态</text></view>
					<view class="zd-col-1 zd-th"><text>调出仓库</text></view>
					<view class="zd-col-1 zd-th"><text>调入仓库</text></view>
					<view class="zd-col-2 zd-th"><text>跟踪号</text></view>
					<view class="zd-col-2 zd-th"><text>计划调<br>入日期</text></view>
					<view class="zd-col-1 zd-th">更多</view>
				</view>
				<view class="zd-td-wraper" v-for="(e, i) in dataList1" :key="e.id">
					<view class="zd-row">
						<view class="zd-col-1 zd-td"><text>{{i+1}}</text></view>
						<view class="zd-col-1 zd-td" @tap.stop="toCheck1(e)">
							<view class="zd-checkbox" :class="{'zd-checkbox_active': e.checked}"></view>
						</view>
						<view class="zd-col-2 zd-td fontcol1"><text>{{e.djbh}}</text></view>
						<view class="zd-col-2 zd-td"><text>{{e.bmmc}}</text></view>
						<view class="zd-col-2 zd-td"><text>{{e.zzmc}}</text></view>
						<view class="zd-col-2 zd-td"><text>{{e.ckmc}}</text></view>
						<view class="zd-col-1 zd-td"><text class="fontbg1">{{e.djzt}}</text></view>
						<view class="zd-col-2 zd-td nowrap"><text>{{e.cjsj}}</text></view>
						<view class="zd-col-2 zd-td"><text>{{e.cjr}}</text></view>
						<view class="zd-col-2 zd-td nowrap"><text>{{e.ywrq}}</text></view>
						<view class="zd-col-1 zd-td nowrap"><text>{{e.update_time}}</text></view>
						<view class="zd-col-1 zd-td nowrap"><text>{{e.update_time}}</text></view>
						<view class="zd-col-2 zd-td"><text>{{e.update_name}}</text></view>
						<view class="zd-col-2 zd-td"><text>{{e.update_name}}</text></view>
						<view class="zd-col-1 zd-td" @tap.stop="getDetails(1,e)"><uni-icons type="more-filled" size="14" color="#fff"></uni-icons></view>
					</view>
				</view>
			</view>
			<pagination v-show="dataList1.length > 0" :total="totalCount1" :page-size="queryParams1.pageSize" :current-page="currentPage1" @page-change="handlePageChange1" />
		</view>
		<view class="footer"></view>
		<grid-detail :show="delShow" :data="detailObj" @closeDetail="delShow=false"></grid-detail>
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="关闭" confirmText="确定" title="提示" content="是否直接调拨？" @confirm="dialogConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import Pagination from '@/components/Pagination.vue'
	import GridDetail from '@/components/GridDetail.vue'
	import {easOutInBillPage, easOutInBillDetailPage, easOutInBillUpdate, easOutInBillDetailUpdate, queryInventoryInfo} from '@/utils/mork2.js'
	export default {
		components: {
			NavBar,
			SearchBox,
			Pagination,
			GridDetail
		},
		data() {
			return {
				val1: '',
				dataList1: [],
				checkArr1: [],
				disabled1: false,
				totalCount1: 0,
				queryParams1:{
					pageSize: 10,
					pageNum: 1
				},
				currentPage1: 1,
				delShow: false,
				detailObj: {},
				value: '',
				range:[{value: 1, text: '提交'}, {value: 2, text: '审核'}],
				value1: '',
				range1: [{value: '3.03.013', text: '三期原材料库'}]
			};
		},
		created () {
			this.toSearch()
		},
		methods: {
			// 查询一级表格
			toSearch () {
				this.queryParams1 = {
					pageSize: 10,
					pageNum: 1
				}
				this.currentPage1 = 1
				this._easOutInBillPage()
			},
			// 一级表格接口
			async _easOutInBillPage () {
				let res = await easOutInBillPage(this.val1, this.id, this.value, this.value1, this.queryParams1.pageNum + '', this.queryParams1.pageSize + '')
				if (res.code === 1) {
					this.checkArr1 = []
					res.result.map(el => {
						this.$set(el, 'checked', false)
					})
					this.dataList1 = [...res.result]
					this.totalCount1 = Number(res.totalElements)
					this.queryParams1.pageSize = Number(res.pageSize)
					this.queryParams1.pageNum = Number(res.pageNum)
				} else {
					uni.showToast({
						title: res.desc,
						icon: 'none'
					})
				}
			},
			// 一级表格切换分页
			handlePageChange1(page) {
				this.queryParams1.pageNum = page
				this.currentPage1 = page
				this._easOutInBillPage()
			},
			// 一级表格选中一行
			toCheck1 (e) {
				e.checked = !e.checked
				let arr = this.dataList1.filter(el => el.checked === true)
				this.checkArr1 = arr.map(el => {return el.djid})
			},
			// 点击直接调拨按钮
			async toSure () {
				if (this.checkArr1.length === 0) {
					return
				}
				this.$refs.alertDialog.open()
			},
			// 详情弹窗
			getDetails (type,e) {
				this.delShow = !this.delShow
				this.detailObj = {type: type, data:e}
			},
			dialogConfirm () {
				
			}
		}
	}
</script>

<style lang="stylus" scoped>
@import '../../common/style/mixin.styl';
.mgr30
	margin-right 30rpx
.select_wraper
	/deep/ .uni-select__selector
		z-index 11
	/deep/ .uni-select
		height: 30px;
		padding: 0 2px 0 12px;
		border: 1px solid #4980bd;
		background-color: rgba(45,88,184,0.1);
		border-radius: 6px;
	/deep/ .uni-select__input-placeholder, /deep/ .uni-select__input-text
		font-size 13px
		color #fff
	/deep/ .uni-select__selector
		background-color #071F3E
		border-color #0c3162
	/deep/ .uni-popper__arrow
		border-bottom-color #0c3162
		&:after
			border-bottom-color #071F3E
	/deep/ .uni-select__selector-item
		color #fff
.zd-th
	font-size: 12px;
	line-height: 13px;
	height: 36px;
</style>
