<!--
  Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.

  https://www.mall4j.com/

  未经允许，不可做商业用途！

  版权所有，侵权必究！
-->

<template>
  <view class="Mall4j component-sku-selected-con">
    <!-- 已选规格 -->
    <view
      v-if="props.pageType"
      class="sku"
      @tap="showSku"
    >
      <view class="sku-tit">
        已选
      </view>
      <view class="sku-con">
        <block
          v-for="(skuItem,index) in selectedPropShowList"
          :key="index"
        >
          <text decode="true">
            {{ index < selectedPropShowList.length-1 ? skuItem +'，' : skuItem + '&nbsp; &nbsp;' }}
          </text>
        </block>
        <text>{{ props.prodNum }}件</text>
      </view>
      <view class="more">
        ...
      </view>
    </view>
    <!-- 已选规格end -->

    <!-- 规格弹窗 -->
    <view
      v-if="props.skuShow || (!props.skuShow && !props.pageType)"
      class="pup-sku"
    >
      <view
        class="pup-sku-main"
        @tap.stop
      >
        <view class="pup-sku-header">
          <view
            class="close"
            @tap="closePopup"
          />
          <view class="pup-sku-img">
            <img-show
              :src="setPicURL(defaultSku.pic, props.pic)"
              img-mode="aspectFit"
            />
          </view>
          <view class="pup-sku-prod">
            <!-- 秒杀商品价格 -->
            <view
              v-if="findSku && props.prodType === 2 && props.activityInfo.activityStatus === 2"
              class="pup-sku-price"
            >
              ￥
              <text class="pup-sku-price-int">
                {{ wxs.parsePrice(defaultSku.seckillPrice)[0] }}
              </text>
              .{{ wxs.parsePrice(defaultSku.seckillPrice)[1] }}
            </view>
            <!-- 商品价格 -->
            <view
              v-if="findSku && props.skuShowType === 0 && props.prodType === 0 || props.prodType === 3 || (props.prodType === 1 && props.skuShowType === 0 ) || (props.prodType === 2 && props.activityInfo.activityStatus === 1 || props.activityInfo.activityStatus === undefined)"
              class="pup-sku-price"
            >
              <text
                v-if="defaultSku.matchingPrice || defaultSku.price"
                class="pup-sku-price-int"
              >
                ￥{{ wxs.parsePrice(defaultSku.matchingPrice || defaultSku.price)[0] }}
              </text>
              <text v-if="defaultSku.matchingPrice || defaultSku.price">
                .{{ wxs.parsePrice(defaultSku.matchingPrice || defaultSku.price)[1] }}
              </text>
              <text v-if="(defaultSku.matchingPrice || defaultSku.price) && defaultSku.skuScore">
                +
              </text>
              <text
                v-if="defaultSku.skuScore && props.prodType===3"
                class="pup-sku-price-int"
              >
                {{ defaultSku.skuScore }}积分
              </text>
            </view>
            <!-- 拼团商品价格 -->
            <view
              v-if="props.prodType === 1 && findSku && props.skuShowType === 1"
              class="pup-sku-price"
            >
              ￥
              <text class="pup-sku-price-int">
                {{ wxs.parsePrice(defaultGroupSku.actPrice || defaultSku.actPrice)[0] }}
              </text>
              .{{ wxs.parsePrice(defaultGroupSku.actPrice || defaultSku.actPrice)[1] }}
            </view>
            <view
              v-if="!findSku"
              class="pup-sku-price"
            >
              无货
            </view>
            <view class="pup-sku-prop">
              <view>
                <text>已选</text>
                <text decode="true">
                  <text v-if="defaultSku.skuName">
                    {{ '&nbsp;' + defaultSku.skuName }}
                  </text>
                  <text v-else>
                    {{ '&nbsp;' + selectedPropShowList.join('，') }}
                  </text>
                  <text v-if="props.leastNum && props.comboId">
                    {{ '&nbsp;'+props.leastNum+'&nbsp;' }}件
                  </text>
                  <text v-else>
                    {{ '&nbsp;' + props.prodNum }}件
                  </text>
                </text>
              </view>
              <view v-if="findSku">
                <text>库存</text>
                <text decode="true">
                  {{ '&nbsp;'+ (props.prodType === 2 && (defaultSku.seckillStocks === 0 || defaultSku.seckillStocks) ? defaultSku.seckillStocks : defaultSku.stocks) }}
                </text>
                <text
                  v-if="(props.prodType === 2 || props.prodType === 1) && props.activityInfo.maxNum >= 1 && props.skuShowType === 1"
                  style="margin-left: 20rpx;"
                >
                  限购
                </text>
                <text
                  v-if="(props.prodType === 2 || props.prodType === 1) && props.activityInfo.maxNum >= 1 && props.skuShowType === 1"
                  decode="true"
                >
                  {{ '&nbsp;'+ props.activityInfo.maxNum }}
                </text>
              </view>
            </view>
          </view>
        </view>
        <view class="pup-sku-body">
          <view
            v-if="isInputing"
            class="input-mask"
            @tap="handleSetVirtualInputInfo"
          />
          <!-- 说明（虚拟商品） -->
          <view
            v-if="props.mold === 1 && (props.virtualInfo.writeOffNum !== 0 || (props.virtualInfo.writeOffNum === 0 && props.virtualInfo.isRefund === 0))"
            class="virtual-goods-tips"
          >
            <text class="vi-t">
              使用说明：
            </text>
            <!-- writeOffNum 0无需核销 1单次核销 -1多次核销 -->
            <block v-if="props.virtualInfo.writeOffNum !== 0">
              <!-- writeOffTime核销有效期 -1.长期有效 0.自定义 x.x天内有效 -->
              <text v-if="props.virtualInfo.writeOffTime === -1">
                购买后长期有效
              </text>
              <text v-else-if="props.virtualInfo.writeOffTime === 0">
                购买后 {{ props.virtualInfo.writeOffStart }} 至 {{ props.virtualInfo.writeOffEnd }} <text v-if="!isEn">
                  有效
                </text>
              </text>
              <text v-else-if="props.virtualInfo.writeOffTime === 1">
                购买后当天24点前有效
              </text>
              <text v-else>
                {购买后{{ props.virtualInfo.writeOffTime }}天内有效
              </text>
            </block>
            <!-- isRefund 0不支持退款 1支持退款 -->
            <text v-if="props.virtualInfo.isRefund === 0">
              <text v-if="props.virtualInfo.writeOffNum !== 0 ">
                ，
              </text>不支持申请退款
            </text>
          </view>

          <!-- 规格 -->
          <view class="pup-sku-area">
            <view
              v-if="props.skuList.length"
              class="sku-box"
            >
              <view
                v-for="(skuGroupItem, skuGroupItemIndex) in skuGroupList"
                :key="skuGroupItemIndex"
              >
                <view
                  v-for="(skuLine, key) in skuGroupItem"
                  :key="key"
                  class="items sku-text"
                >
                  <text class="sku-kind">
                    {{ key }}
                  </text>
                  <view class="con">
                    <text
                      v-for="skuLineItem in skuLine"
                      :key="skuLineItem"
                      class="sku-choose-item"
                      :class="['item-item',selectedPropList.indexOf(key + ':' + skuLineItem) !== -1?'active':'',
                               isSkuLineItemNotOptional(allProperties,selectedPropObj,key,skuLineItem,propKeys)? 'dashed' : '']"
                      @click="toChooseItem(skuGroupItemIndex, skuLineItem, key)"
                    >
                      {{ skuLineItem }}
                    </text>
                  </view>
                </view>
              </view>
            </view>
          </view>
          <!-- 数量 -->
          <view
            v-if="props.pageType || props.isJionGroup"
            class="pup-sku-count"
          >
            <view class="num-wrap">
              <view
                class="minus"
                @tap="onCountMinus"
              >
                <text class="row" />
              </view>
              <view class="text-wrap">
                <input
                  ref="prodNumSelfRef"
                  :key="prodNumSelfKey"
                  type="number"
                  :value="prodNumSelf"
                  @input="changeNUm"
                  @blur="prodNumInp()"
                >
              </view>
              <view
                class="plus"
                @tap="onCountPlus"
              >
                <text class="row" />
                <text class="col" />
              </view>
            </view>
            <view class="count-name">
              数量
            </view>
          </view>
        </view>
        <!-- 底部按钮: 普通/秒杀/拼团  -->
        <view
          v-if="(props.pageType || props.isJionGroup) && props.pageType != 3"
          :class="'pup-sku-footer ' + ( props.isJionGroup ? '' : findSku && !prodNumBiggerThanStock() ? '':'gray')"
        >
          <!-- 秒杀按钮 -->
          <view
            v-if="props.prodType===2 && props.activityInfo.activityStatus === 2"
            class="btn buy"
            @tap="handleBuyNow(2)"
          >
            立即抢购
          </view>
          <!-- 非秒杀、非预售商品 -->
          <block v-else-if="props.skuShowType==0 && props.preSellStatus != 1">
            <view
              v-if="props.skuShowType == 0 && props.mold !== 1"
              class="btn cart"
              @tap="handleAddToCart"
            >
              加入购物车
            </view>
            <view
              v-if="props.skuShowType==0"
              class="btn buy"
              @tap="handleBuyNow(0)"
            >
              立即购买
            </view>
          </block>
          <!-- 预售 -->
          <view
            v-if="props.preSellStatus == 1 && props.prodType !== 2"
            class="btn pre-sale-buy"
            @tap="handleBuyNow(0)"
          >
            立即购买
          </view>
          <!-- 开团按钮 -->
          <view
            v-if="props.skuShowType==1 && !props.isJionGroup && props.prodType === 1"
            :class="['btn', props.activityInfo.activityStatus === 1 ? 'gray-btn' : 'buy']"
            @tap="handleBuyNow(1)"
          >
            开团
          </view>
          <!-- 参团按钮 -->
          <view
            v-if="props.isJionGroup"
            class="btn buy"
            @tap="handleJionGroup"
          >
            立即参团
          </view>
        </view>
        <!-- 积分商品: 兑换按钮 -->
        <view
          v-if="props.prodType == 3"
          :class="'pup-sku-footer ' + (findSku && !prodNumBiggerThanStock() ? '':'gray')"
        >
          <view
            class="btn buy"
            @tap="handleBuyNow(3)"
          >
            立即兑换
          </view>
        </view>
        <!-- 活动商品: 仅作为套餐(附属商品)或赠品 不可单独购买 -->
        <view
          v-if="props.prodType == 5 && props.pageType"
          class="pup-sku-footer gray"
        >
          <view class="btn buy">
            活动商品不可购买
          </view>
        </view>
        <!-- 购物车: 切换sku弹窗 -->
        <view
          v-if="!props.pageType && !props.isJionGroup"
          class="pup-sku-footer"
          :class="{gray: !findSku}"
        >
          <view
            class="btn buy"
            @tap="submit"
          >
            确定
          </view>
        </view>
      </view>
    </view>
    <!-- 规格弹窗 end -->
  </view>
</template>

<script setup>

const props = defineProps({
  pic: {
    type: String,
    default: ''
  },
  isMain: {
    type: Boolean,
    default: false
  },
  leastNum: {
    type: Number,
    default: 0
  },
  skuName: {
    type: String,
    default: ''
  },
  skuList: {
    type: Array,
    default () {
      return []
    }
  },
  skuId: {
    type: Number,
    default: 0
  },
  comboId: {
    type: Number,
    default: 0
  },
  defaultPrice: {
    type: Number,
    default: 0
  },
  mold: {
    type: [Number, String],
    default: 0
  },
  virtualInfo: {
    type: Object,
    default: () => {}
  },
  // sku的显示类型 0普通sku 1拼团sku
  skuShowType: {
    type: Number,
    default: 0
  },
  prodType: {
    type: Number,
    default: 0
  },
  preSellStatus: {
    type: Number,
    default: 0
  },
  prodNum: {
    type: Number,
    default: 1
  },
  // 团购/秒杀  活动信息
  activityInfo: {
    type: Object,
    default: () => {}
  },
  // 页面类型: 0非商品详情页(套餐/购物车/团购详情:参团页面)  1普通商品(团购)  2秒杀商品  3积分商品  5活动商品
  pageType: {
    type: Number,
    default: 0
  },
  skuShow: {
    type: Boolean,
    default: false
  },
  // 参团页面
  isJionGroup: {
    type: Boolean,
    default: false
  }
})

const emit = defineEmits([
  'closeSkuPop',
  'setSku',
  'showSku',
  'setProdNum',
  'addToCart',
  'buyNow',
  'groupConfirmOrder',
  'setVirtualInputInfo'
])

const wxs = number()
// 是否为英文
const isEn = ref(uni.getStorageSync('cloudLang') == 'en')

const { proxy } = getCurrentInstance()
const prodNumSelfKey = ref(1)
const prodNumSelf = computed({
  get () {
    return props.prodNum
  },
  set () {
    prodNumSelfKey.value = Math.random() * 1000000
    proxy.$forceUpdate()
  }
})

onMounted(() => {
  groupSku()
})

/**
 * 图片路径处理
 */
const setPicURL = (pic, pic1) => {
  const url = pic || pic1
  if (url) {
    return url.indexOf('http') === -1 ? import.meta.env.VITE_APP_RESOURCES_URL + url : url
  }
  return false
}
const closePopup = () => {
  emit('closeSkuPop')
}

const defaultSku = ref('')
const propKeys = ref([])
const selectedPropObj = ref({})
const skuGroup = ref({})
const allProperties = ref([])
const findSku = ref(false)
const skuGroupList = ref([])
const selectedPropObjList = ref([])
const groupSku = () => {
  const skuList = props.activityInfo.activityStatus == 2 && props.activityInfo.seckillId ? props.activityInfo.seckillSkuList : props.skuList
  if (skuList.length == 1 && !skuList[0].properties) {
    defaultSku.value = skuList[0]
    findSku.value = true
    if (props.pageType || props.isJionGroup) {
      emit('setSku', defaultSku.value, findSku.value)
    }
    if (props.activityInfo && props.prodType === 1) {
      setDefaultGroupSku()
    }
    return
  }
  const skuGroupListVal = []
  const skuGroupVal = {}
  const allPropertiesVal = []
  const propKeysVal = []
  const selectedPropObjVal = {}
  const selectedPropObjListVal = []

  let defaultSkuVal = null
  const arr = JSON.parse(JSON.stringify(props.skuList))
  arr.sort((a, b) => {
    return a.seckillPrice - b.seckillPrice
  })
  for (let i = 0; i < skuList.length; i++) {
    let isDefault = false
    if ((!defaultSkuVal && skuList[i].skuId == props.skuId) ||
        (!defaultSkuVal && skuList[i].price == props.defaultPrice) ||
        (!defaultSkuVal && skuList[i].seckillPrice === props.activityInfo?.seckillPrice && skuList[i].price === props.activityInfo?.price) ||
        (!defaultSkuVal && skuList[i].actPrice === props.activityInfo?.actPrice && props.prodType === 1)) {
      defaultSkuVal = skuList[i]
      isDefault = true
    }
    if (defaultSkuVal === null && (i === skuList.length - 1)) {
      defaultSkuVal = arr[0]
      isDefault = true
    }
    const properties = skuList[i].properties // 版本:公开版;颜色:金色;内存:64GB
    allPropertiesVal.push(properties)
    const propList = properties.split(';') // ["版本:公开版","颜色:金色","内存:64GB"]

    for (let j = 0; j < propList.length; j++) {
      const index = propList[j].indexOf(':')
      const propval = [propList[j].slice(0, index), propList[j].substring(index + 1)] // ["版本","公开版"]
      let propvals = skuGroupVal[propval[0]] // 先取出 版本对应的值数组

      // 如果当前是默认选中的sku，把对应的属性值 组装到selectedProp
      if (isDefault) {
        propKeysVal.push(propval[0])
        selectedPropObjVal[propval[0]] = propval[1]
        const selectedPropObjItem = {}
        selectedPropObjItem[propval[0]] = propval[1]
        selectedPropObjListVal.push(selectedPropObjItem)
      }

      if (propvals == undefined) {
        propvals = [] // 假设还没有版本，新建个新的空数组
        propvals.push(propval[1]) // 把 "公开版" 放进空数组
      } else {
        if (propvals.indexOf(propval[1]) === -1) { // 如果数组里面没有"公开版"
          propvals.push(propval[1]) // 把 "公开版" 放进数组
        }
      }
      skuGroupVal[propval[0]] = propvals // 最后把数据 放回版本对应的值
      const propListItem = {}
      propListItem[propval[0]] = propvals
      skuGroupListVal.push(propListItem)
    }
  }
  defaultSku.value = defaultSkuVal || {}
  propKeys.value = propKeysVal
  selectedPropObj.value = selectedPropObjVal
  skuGroup.value = skuGroupVal
  selectedPropObjList.value = selectedPropObjListVal
  skuGroupList.value = unique(skuGroupListVal)
  allProperties.value = allPropertiesVal
  parseSelectedObjToVals(skuList)
  proxy.$forceUpdate()
  if (props.activityInfo && props.prodType === 1) {
    setDefaultGroupSku()
  }
}

/**
 * 将已选的 {key:val,key2:val2}转换成 [val,val2]
 */
const selectedPropShowList = ref([])
const selectedPropList = ref([])
const selectedProperties = ref('')
const parseSelectedObjToVals = (skuList) => {
  const selectedPropObjListVal = selectedPropObjList.value
  let selectedPropertiesVal = ''
  const selectedPropListVal = []
  const selectedPropShowListVal = []
  for (let i = 0; i < selectedPropObjListVal.length; i++) {
    const selectedPropObjItem = selectedPropObjListVal[i]
    for (const key in selectedPropObjItem) {
      if (Object.hasOwnProperty.call(selectedPropObjItem, key)) {
        selectedPropListVal.push(key + ':' + selectedPropObjItem[key])
        selectedPropShowListVal.push(selectedPropObjItem[key])
        selectedPropertiesVal += key + ':' + selectedPropObjItem[key] + ';'
      }
    }
  }
  selectedPropertiesVal = selectedPropertiesVal.substring(0, selectedPropertiesVal.length - 1)
  selectedPropList.value = selectedPropListVal
  selectedPropShowList.value = selectedPropShowListVal
  selectedProperties.value = selectedPropertiesVal
  selectedPropObjList.value = selectedPropObjListVal
  let findSkuVal = false
  for (let i = 0; i < skuList.length; i++) {
    if (skuList[i].properties == selectedPropertiesVal) {
      findSkuVal = true
      defaultSku.value = skuList[i]
      break
    }
  }
  findSku.value = findSkuVal
  if (props.pageType || props.isJionGroup) {
    emit('setSku', defaultSku.value, findSku.value)
  }
  if (props.activityInfo && props.prodType === 1) {
    setDefaultGroupSku()
  }
}

const showSku = () => {
  emit('showSku')
}

/**
 * 判断当前的规格值 是否可以选
 */
const isSkuLineItemNotOptional = (allPropertiesVal, propObj, key, item, propKeys) => {
  const selectedPropObjVal = Object.assign({}, propObj)
  let properties = ''
  selectedPropObjVal[key] = item
  for (let j = 0; j < propKeys.length; j++) {
    properties += propKeys[j] + ':' + selectedPropObjVal[propKeys[j]] + ';'
  }
  properties = properties.substring(0, properties.length - 1)
  for (let i = 0; i < allPropertiesVal.length; i++) {
    if (properties == allPropertiesVal[i]) {
      return false
    }
  }
  for (let i = 0; i < allPropertiesVal.length; i++) {
    if (allPropertiesVal[i].indexOf(item) >= 0) {
      return true
    }
  }
  return false
}

/**
 * 规格点击事件
 */
const toChooseItem = (skuGroupItemIndex, skuLineItem, key) => {
  selectedPropObjList.value[skuGroupItemIndex] = selectedPropObjList.value[skuGroupItemIndex] || {}

  selectedPropObjList.value[skuGroupItemIndex][key] = skuLineItem
  selectedPropObj.value[key] = skuLineItem
  const skuList = props.activityInfo?.activityStatus == 2 && props.activityInfo.seckillId ? props.activityInfo.seckillSkuList : props.skuList
  parseSelectedObjToVals(skuList)
  if (props.pageType || props.isJionGroup) {
    emit('setSku', defaultSku.value, findSku.value)
  }
  if (props.activityInfo && props.prodType === 1) {
    setDefaultGroupSku()
  }
}

/**
 * 设置选中的拼团sku
 */
// 团购sku
const defaultGroupSku = ref({})
const setDefaultGroupSku = () => {
  const groupSkuList = props.activityInfo.groupSkuList || props.activityInfo.seckillSkuList
  if (groupSkuList) {
    if (groupSkuList.length === 1 && !groupSkuList[0].properties) {
      defaultGroupSku.value = groupSkuList[0]
      emit('setSku', defaultGroupSku.value, findSku.value)
      return
    }
    for (let i = 0; i < groupSkuList.length; i++) {
      if (groupSkuList[i].properties == selectedProperties.value) {
        defaultGroupSku.value = groupSkuList[i]
        emit('setSku', defaultGroupSku.value, findSku.value)
        break
      }
    }
  }
}

/**
 * 去重
 */
const unique = (arr) => {
  const map = {}
  arr.forEach(item => {
    const obj = {}
    Object.keys(item).sort().map(key => {
      obj[key] = item[key]
      return key
    })
    map[JSON.stringify(obj)] = item
  })
  return Object.keys(map).map(key => JSON.parse(key))
}

/**
 * 减数量
 */
const onCountMinus = () => {
  let prodNum = prodNumSelf
  if (prodNum > 1) {
    prodNum = prodNum - 1
  }
  emit('setProdNum', prodNum)
}

/**
 * 加数量
 */
const onCountPlus = () => {
  // 商品数量
  let prodNum = parseInt(prodNumSelf)
  // 默认库存数量
  const defaultSkuStock = parseInt(props.prodType === 2 && (defaultSku.value.seckillStocks === 0 || defaultSku.value.seckillStocks) ? defaultSku.value.seckillStocks : defaultSku.value.stocks)
  // 是否限购
  const isRestriction = props.activityInfo.maxNum && props.activityInfo.maxNum !== -1 && props.skuShowType === 1 && props.activityInfo.maxNum <= defaultSkuStock
  // limit 最大可购买数量: 活动商品不限购则为当前sku库存；活动商品限购时，当库存大于限购数量则为限购数量，否则为库存数量
  const limit = !isRestriction ? defaultSkuStock : defaultSkuStock > props.activityInfo.maxNum ? props.activityInfo.maxNum : defaultSkuStock
  if (isRestriction) {
    if (prodNum >= limit) {
      uni.showToast({
        title: isRestriction && limit ? `限购 ${props.activityInfo.maxNum} ${$t('piece')}` : '库存不足',
        icon: 'none'
      })
    }
    prodNum = (prodNum >= limit ? limit : prodNum + 1) || 1
  } else {
    if (prodNum >= defaultSkuStock) {
      uni.showToast({
        title: '库存不足',
        icon: 'none'
      })
      prodNum = defaultSkuStock || 1
    } else {
      prodNum += 1
    }
  }
  emit('setProdNum', prodNum)
}

/**
 * 加购
 */
const handleAddToCart = () => {
  if (!findSku.value || prodNumBiggerThanStock()) {
    return
  }
  emit('addToCart')
}

/**
 * 立即购买
 * @param {Number} orderType 订单类型  0普通 1团购 2秒杀 3积分
 */
const handleBuyNow = (orderType) => {
  if (!findSku.value || prodNumBiggerThanStock()) {
    return
  }
  emit('buyNow', orderType)
}

/**
 * 参团
 */
const handleJionGroup = () => {
  if (!findSku.value || prodNumBiggerThanStock()) {
    return
  }
  emit('groupConfirmOrder')
}

/**
 * 库存校验
 * @return {Boolean} 购买数量大于库存
 */
const prodNumBiggerThanStock = () => {
  const defaultSkuStock = props.pageType == 2 ? defaultSku.value.seckillStocks : defaultSku.value.stocks
  return prodNumSelf > defaultSkuStock
}

/**
 * 设置虚拟商品留言
 */
const isInputing = ref(false)
const handleSetVirtualInputInfo = () => {
  isInputing.value = false
  emit('setVirtualInputInfo', props.virtualInfo.virtualRemarks)
}

/**
 * 输入商品数量
 */
const num = ref('')
const prodNumInp = () => {
  let numVal = Number(num.value.replace(/[^\d]/g, ''))
  const max = props.prodType === 2 && (defaultSku.value.seckillStocks === 0 || defaultSku.value.seckillStocks) ? defaultSku.value.seckillStocks : defaultSku.value.stocks
  if (numVal > max) {
    numVal = max
  } else if (numVal < 1) {
    numVal = 1
  }
  emit('setProdNum', numVal)
}
const changeNUm = (e) => {
  num.value = e.detail.value
}

const submit = () => {
  if (findSku.value) {
    emit('setSku', defaultSku.value, props.isMain, findSku.value)
  }
}

</script>

<style lang="scss" scoped>
@use './prod-sku-select.scss';
</style>
