<template>
	<view class="page">
		<uni-section :title='sectionTitle' type="line" :strong="true"  class="bg-white"/>
		<template v-for="(item,index) in list">
			<list-item :key="index" @delete="onDelete(index)">
				<item-row title="物品号">{{item.itemno}}</item-row>
				<item-row title="数量">{{item.itemnum}}</item-row>
			</list-item>
		</template>
			<btn-scan :type='barCodeType'  @scan="onScan($event,{uniqueItemid:true})" @submit="onSubmit(urlkey,urlparams)" ></btn-scan>
	</view>
</template>

<script>
	import uniSection from "@/components/uni-ui/uni-section/uni-section.vue"
	import listItem from "@/components/warehousing-item/list-item.vue"
	import btnScan from "@/components/common/btn-scan.vue"
	import itemRow from "@/components/common/item-row.vue"
	import {onErrorBarCodeType,formateScanData} from "@/common/utils/common.js"
	import {BARCODE_CAIGOU_KEY,BARCODE_FINISHEDGOOD_KEY} from "@/common/utils/barCode.js"
	import {scanProductMixin} from "@/common/utils/mixins.js"
	import {queryDirectDetailInventoryorder,queryExamineDetailInventoryorder,querySaleDetailInventoryorder} from "@/api/api.js"


	
	export default {
		mixins:[scanProductMixin],
		components:{
			uniSection,
			listItem,
			btnScan,
			itemRow
		},
		data () {
			return {
				list:[],  // 物品列表 (当前页面展示)
				QRDH:null,  // 销售单号
				SWH:null,  // 事务号
				typekey:null,  // 类型关键字
				type:null,   // 清点类型
			}
		},
		computed:{
			urlkey () {
				return this.type === '入库' ?  'inventory-warehousing-edit' : 'inventory-outsource-edit'
			},
			urlparams () {
				let str=`&typekey=${this.typekey}`
				switch (this.type) {
					case "入库":
					  str+=`&SWH=${this.SWH}`
					break;
					case "出库":
					  str+=`&QRDH=${this.QRDH}`
					break;
				}
				return str
			},
			// 页面标题
			sectionTitle () {
				let title=''
				switch (this.type) {
					case "入库":
					 title='入库物品条形码'
					break;
					case "出库":
					title='出库物品条形码'
					break;
				}
				return title
			},
			// 条形码类型
			barCodeType () {
				let type=''
				switch (this.type) {
					case "入库":
					 type=BARCODE_CAIGOU_KEY
					break;
					case "出库":
					 type=BARCODE_FINISHEDGOOD_KEY
					break;
				}
				return type
			}
		},
		onReady () {
			uni.setNavigationBarTitle({
				title:`请扫描${this.type}物品`
			})
		},
		onLoad (e) {
			/*
			  SWH：事务号
			  type:清点类型（入库，出库）
				typekey:关键字（入库：直接入库，检验入库，出库：出库）
			*/
		  this.QRDH=e.QRDH
		  this.SWH=e.SWH
			this.type=e.type
			this.typekey=e.typekey
		},
		methods:{
		}
	}
	
</script>

<style lang="scss">
	
</style>
