<template>
  <view class="uni-flex u-col-center" style="padding-top: 15rpx; padding-bottom: 15rpx; padding-left: 10rpx; padding-right: 10rpx; font-size: 32rpx">
    <text style="font-size: 35rpx">{{ title }} </text>
    <view class="uni-flex u-col-center" @click="showLocation">
      <text style="color: #3fbaff; font-size: 35rpx" v-if="containerCode == '' && isShowEdit == true">&nbsp 请扫描</text>
      <text style="color: #3fbaff; font-size: 35rpx">&nbsp {{ containerCode }}</text>
      <image v-if="isShowEdit" style="width: 45rpx; height: 45rpx" src="/static/icons/icons_edit.svg"></image>
    </view>
    <winScanContainer ref="scanContainer" :title="title" @getContainer="getContainer"></winScanContainer>
  </view>
</template>

<script setup lang="ts">
import { ref, getCurrentInstance, onMounted, nextTick, watch } from 'vue'
import winScanContainer from '@/mycomponents/scan/winScanContainer.vue'

const defaultContainerCode = ref('')
const props = defineProps({
  title: {
    type: String,
    default: '需求库位'
  },
  containerCode: {
    type: String,
    default: ''
  },
  isShowEdit: {
    type: Boolean,
    default: true
  }
})
watch(
  () => props.containerCode,
  (val) => {
    if (val != '') {
      defaultContainerCode.value = val
    }
  },
  {
    immediate: true,
    deep: true
  }
)

const showLocation = () => {
  scanContainer.value.openScanPopup()
}
// 扫描源库位
const getContainer = (containerInfo) => {
  emit('getContainer', containerInfo)
}

// 传递给父类
const emit = defineEmits(['getContainer'])
</script>

<style></style>
