<template>
	<view>
		<button v-for='item in types' @click="handleScan(item.dictValue)">
			{{ item.dictLabel }}
		</button>
		
		<button @click='handleLogout'>
			退出登录
		</button>
	</view>
</template>

<script>
	import { getDicts } from '@/api/system/dict/data.js'
	import { getGenerateRecord } from '@/api/wms/code.js'
	
	export default {
		data() {
			return {
				types: []
			}
		},
		methods: {
			handleLogout() {
				this.$modal.confirm('确定注销并退出系统吗？').then(() => {
					this.$store.dispatch('LogOut').then(() => {}).finally(() => {
						this.$tab.reLaunch('/pages/login')
					})
				})
			},
			handleScan(type) {
				// 1. 扫码
				uni.scanCode({
					success(res) {
						const result = res.result;
						// 2. 解析二维码的content，获取enter_coil_no、current_coil_no和coil_id
						const qrcodeRecord = qrcodeRes.data;
						const content = JSON.parse(qrcodeRecord.content);
						const enterCoilNo = content.enter_coil_no;
						const currentCoilNo = content.current_coil_no;
						const coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null;
						
						// 3. 调用创建待操作记录的API
					}
				})
			}
		},
		mounted() {
			// 获取字典
			getDicts('easycode_type').then(res => {
				console.log(res)
				this.types = res.data
			})
		}
	}
</script>

<style>

</style>
