<template>
	<view>
		<uni-collapse>
			<uni-forms ref="form" :modelValue="formData" :rules="rules">
				<uni-forms-item label="日期范围" :labelWidth='90' name="updateTime">
					<uni-datetime-picker v-model="formData.updateTime" type="daterange" rangeSeparator="至" />
				</uni-forms-item>
				<uni-forms-item label="物料编码" :labelWidth='90' name="ptNoTar">
					<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarCode"
						v-model="formData.ptNoTar" type="text" />
				</uni-forms-item>
				<uni-forms-item label="物料名称" :labelWidth='90' name="ptTitleTar">
					<uni-easyinput v-model="formData.ptTitleTar" type="text" />
				</uni-forms-item>
				<uni-forms-item label="物料规格" :labelWidth='90' name="specification1">
					<uni-easyinput v-model="formData.specification1" type="text" />
				</uni-forms-item>
				<uni-forms-item label="仓库" :labelWidth='90' name="formData.whCode">
					<zxz-uni-data-select v-model="formData.whCode" :localdata="whOptions"
						:filterable="true"></zxz-uni-data-select>
					<!-- <uni-data-select v-model="formData.whCode" :localdata="whOptions"></uni-data-select> -->
				</uni-forms-item>
			</uni-forms>
			<u-button type="primary" @click="query">查询</u-button>
			<uni-collapse-item :open="true">
				<uni-card :is-shadow="false" is-full v-for="item,index in reportList" :key="item.id">
					<div><strong>合并标签号</strong>:{{item.singleReportSign}}</div>
					<div><strong>物料编码</strong>:{{item.ptNoTar}}</div>
					<div><strong>物料名称</strong>:{{item.ptTitleTar}}</div>
					<div><strong>物料规格</strong>:{{item.specification1}}</div>
					<div><strong>数量</strong>:{{item.reportNumber}}</div>
					<div><strong>仓库</strong>:{{item.whName?item.whName:item.whCode}}</div>
					<div><strong>状态</strong>:入库完成</div>
				</uni-card>
			</uni-collapse-item>
		</uni-collapse>
	</view>
</template>

<script>
	import {
		listMesJobSingleReportSign,
		advListMesJobSingleReportSign,
		getMesJobSingleReportSign,
		delMesJobSingleReportSign,
		addMesJobSingleReportSign,
		updateMesJobSingleReportSign,
		reportConfirm,
		qualityConfirm,
		whInConfirm
	} from "@/api/mes/mesJobSingleReportSign";
	import {
		listWarehouse
	} from "@/api/wms/pdcIn.js";
	export default {
		mounted() {
			listWarehouse().then(res => {
				this.whList = res.rows;
				this.whOptions = res.rows.map(item => {
					return {
						text: item.warehouseCode + ':' + item.warehouseName,
						value: item.warehouseCode,
						diasble: false
					}
				});
			})
		},
		data() {
			return {
				whOptions: [],
				whList: [],
				datetimerange: [],
				reportList: [],
				formData: {
					ptNoTar: null,
					ptTitleTar: null,
					updateTime: [],
					specification1: null,
					whCode: null
				},
				rules: {

				}
			}
		},
		methods: {
			//物料编码
			scanBar() {
				const _this = this;
				uni.scanCode({
					scanType: ['barCode', 'qrCode'],
					success: function(res) {
						_this.formData.ptNoTar = res.result;
					}
				});
			},
			query() {
				let obj = {
					['A.ptNoTar-0']: this.formData.ptNoTar,
					['A.ptNoTar-op']: 'ct',
					['A.ptTitleTar-0']: this.formData.ptTitleTar,
					['A.ptTitleTar-op']: 'ct',
					['A.specification1-0']: this.formData.specification1,
					['A.specification1-op']: 'ct',
					['A.updateTime-0']: this.formData.updateTime.length > 0 ? (this.formData.updateTime[0] +
						' 00:00:00') : null,
					['A.updateTime-1']: this.formData.updateTime.length > 0 ? (this.formData.updateTime[1] +
						' 00:00:00') : null,
					['A.updateTime-op']: 'bt',
					['A.whCode-0']: this.formData.whCode,
					['A.whCode-op']: 'eq',
					['A.status-op']: 'eq',
					['A.status-0']: 3,
					gexpr: 'A',
					pageNum: 0,
					pageSize: 100
				}
				console.log(obj)
				advListMesJobSingleReportSign(obj).then(res => {
					this.reportList = res.rows.map(item => {
						let obj = this.whList.find(i => i.warehouseCode == item.whCode)
						if (obj) {
							console.log(obj)
							item.whName = obj.warehouseName
						}
						return item
					})

				})
			}
		}
	}
</script>

<style>
</style>