<template>
	<view class="bg-white width-100 box-border">
		<!-- {{HOST_PRO}} -->
		<uni-grid :column="3" :highlight="true" @change="onSelectNav">
			<uni-grid-item v-for="(item, index) in gridList" :index="index" :key="index" >
				<view class="height-100 flex align-center justify-center">
					<view class="text-center d-inline-block">
						<image :src="'/static/images/'+item.authkey+'.png'" mode="scaleToFill" class="grid-item-image"></image>
						<view class="text">{{item.title}}</view>
					</view>
				</view>
			</uni-grid-item>
		</uni-grid>
	</view>
</template>

<script>
	import uniGrid from "@/components/uni-ui/uni-grid/uni-grid.vue"
	import uniGridItem from "@/components/uni-ui/uni-grid-item/uni-grid-item.vue"
	import {mapGetters} from "vuex"
	import {BARCODE_PROCESS,BARCODE_PROCESS_KEY,BARCODE_PRODUCE,BARCODE_PRODUCE_KEY,
	BARCODE_OUTSOURCE,BARCODE_OUTSOURCE_KEY} from "@/common/utils/barCode.js"
	// import $C from "@/api/config.js"
	
	let _gridList=[
		{title:"报工单",authkey:"work-order",url:"processcode-scan",nextUrl:"work-order-edit",barcodekey:BARCODE_PROCESS_KEY,barcodeType:BARCODE_PROCESS},
		{title:"生产入库",authkey:"warehousing",url:"processcode-scan",nextUrl:"warehousing-edit",barcodekey:BARCODE_PROCESS_KEY,barcodeType:BARCODE_PROCESS},
		{title:"清点单",authkey:"inventory",url:"inventory",},
		{title:"线边调拨",authkey:"transfer-lineEdge",url:"transfer-lineEdge",},
		{title:"调拨事务",authkey:"transfer-affair",url:"transfer-affair",},
		{title:"成本中心发料",authkey:"codeCenter-issue",url:"codeCenter-issue",},
		{title:"按单发料",authkey:"bill-order",url:"processcode-scan",nextUrl:"bill-order-edit",barcodekey:BARCODE_PRODUCE_KEY,barcodeType:BARCODE_PRODUCE},
		{title:"委外接收",authkey:"outsource-receive",url:"processcode-scan",nextUrl:"outsource-reveive-list",barcodekey:BARCODE_OUTSOURCE_KEY,barcodeType:BARCODE_OUTSOURCE},
		{title:"委外发料",authkey:"outsource-issue",url:"processcode-scan",nextUrl:"outsource-issue-list",barcodekey:BARCODE_OUTSOURCE_KEY,barcodeType:BARCODE_OUTSOURCE},
		{title:"移库事务",authkey:"move-warehouse",url:"move-warehouse"},
		{title:"开始生产",authkey:"begin-produce",url:"processcode-scan",nextUrl:"begin-produce-detail",barcodekey:BARCODE_PRODUCE_KEY,barcodeType:BARCODE_PRODUCE},
	]
// const BigNumber = require('bignumber.js');

	
	export default {
		components:{
			uniGrid,
			uniGridItem
		},
		data() {
			return {
				title:'工作台',
				// HOST_PRO:$C.HOST_PRO
			}
		},
		computed:{
			...mapGetters(['authList']),
			gridList () {
				let arr=[]
				this.authList.forEach((item,index)=>{
					_gridList.forEach((item2,index2)=>{
						if (item===item2.authkey) {
							arr.push(item2)
						}
					})
				})
				return arr
			}
		},
		onLoad() {
		},
		methods: {
		// nav 点击，params_barcodekey：条形码关键字
		onSelectNav (e) {
			 const index=e.detail.index
			 const item=this.gridList[index]
			 
			 const params_nextUrl=`nextUrl=${item.nextUrl ? item.nextUrl :null}`;
			 const params_barcodekey=`barcodekey=${item.barcodekey ? item.barcodekey :null}`;
       const params_barcodeType=`barcodeType=${item.barcodeType ? item.barcodeType :null}`;
			 
			 const url=`/pages/${item.url}/${item.url}?title=${item.title}&${params_nextUrl}&${params_barcodekey}&${params_barcodeType}`
		  uni.navigateTo({
		  	url:url
		  })
		 }
		},
		onNavigationBarButtonTap  (e) {
			if(e.index===0){
				uni.navigateTo({
					url:"/pages/user-center/user-center"
				})
			}
			if(e.index===1){
				uni.navigateTo({
					url:"/pages/label-print-type/label-print-type"
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}
	.grid-item-box{
		
	}
	.grid-item-image{
		width:100rpx;
		height: 100rpx;
	}
	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
	}
</style>
