<template>
	<view class="uni-flex u-col-center" style="padding-left: 10rpx;padding-right: 10rpx;
	 font-size:32rpx;">
		<view class="uni-flex uni-row u-col-center" @click="showLocation">
			<view class="flex uni-row" v-if="isShowEdit"  >
				<view >
					<text style="font-size: 35rpx;">{{title}}</text>	
					<text style="font-size: 45rpx;color:#3FBAFF; font-weight: bold;">&nbsp {{recommendLocationCode}}</text>
					<text v-if="locationCode" style="font-size: 45rpx;color:#3FBAFF;font-weight: bold;">&nbsp/&nbsp{{locationCode}}</text>
					<!-- <text style="font-size: 35rpx;color:#3FBAFF;" v-if="locationCode==''&&isShowEdit==true">&nbsp 请扫描</text> -->
				</view>
				<image style="width:45rpx;height: 45rpx; vertical-align:center" class="center" src="/static/icons/icons_edit.svg"></image>
			</view>
			<view class="" v-else>
				<view >
					<text style="font-size: 35rpx;">{{title}}</text>
					<text style="font-size: 45rpx;color:#3FBAFF;font-weight: bold;">&nbsp {{recommendLocationCode}}</text>
					<!-- <text style="font-size: 35rpx;color:#3FBAFF;" v-if="locationCode==''&&isShowEdit==true">&nbsp 请扫描</text> -->
				</view>
			</view>
			
			
			<view class="uni-flex uni-row center" style="vertical-align:center ;" v-if="isDevlement()">
				<text style="font-size: 30rpx;color: #2979ff; " @click="copy">复制</text>
			</view>
		</view>
		<win-scan-location ref="scanLocationCode" :title="title" @getLocation='getLocation'
			:locationAreaTypeList="locationAreaTypeList"></win-scan-location>
	</view>
</template>

<script>
	import winScanLocation from "@/mycomponents/scan/winScanLocation.vue"
	import config from '@/static/config.js'

	export default {
		components: {
			winScanLocation
		},
		data() {
			return {
				defaultlocationCode: ""
			}
		},
		props: {
			title: {
				type: String,
				default: "需求库位"
			},
			recommendLocationCode: {
				type: String,
				default: ""
			},
			locationCode: {
				type: String,
				default: ""
			},
			isShowEdit: {
				type: Boolean,
				default: true
			},
			locationAreaTypeList: {
				type: Array,
				default: null
			}
		},

		watch: {
			// locationCode: {
			// 	handler(newName, oldName) {
			// 		if (this.locationCode != "") {
			// 			this.defaultlocationCode = this.locationCode;
			// 		}
			// 	},
			// 	immediate: true,
			// 	deep: true
			// }
		},
		methods: {
			showLocation() {
				if (this.isShowEdit) {
					this.$refs.scanLocationCode.openScanPopup();
				}

			},
			//扫描源库位
			getLocation(location, code) {
				this.$emit("getLocation", location, code)
			},
			copy() {
				// HPQ;V1.0;ICE115F11161AG;PP20230427000026;B20230427002;Q100
				var content = this.recommendLocationCode;
				// #ifdef H5
				this.$copyText(content).then(
					res => {
						uni.showToast({
							title: '复制库位成功',
							icon: 'none'
						})
					}
				)
				// #endif
				// #ifndef H5
				uni.setClipboardData({
					data: content,
					success: () => {
						uni.showToast({
							title: '复制库位成功'
						})
					}
				})
				// #endif
			},
			isDevlement() {
				return config.isDevelopment;
			}
		}
	}
</script>

<style>
</style>