<script>
import Selector from "@/components/Selector/index.vue";
import Template from "@/views/cms/template/index.vue";
import {DICT_TYPE} from "@/utils/dict";

export default {
  name: "ShowStepPriceItem",
  components: {Template, Selector},
  props: {
    index: Number,
    value: Object,
    priceName: String,
    fieldPrefix: String,
    unitMap: {
      type: Object,
      default(){
        return {}
      }
    },
    currencyMap: {
      type: Object,
      default(){
        return {}
      }
    }
  },
  computed:{
    showPackages(){
      return str => {
        let arr = str.split(",")
        return arr.map(item => {
          return this.getDictDataLabel(DICT_TYPE.ECW_PACKAGING_TYPE, item)
        }).join(",")
      }
    }
  }
}
</script>

<template>
  <div>
    <div class="mt-10">
      {{$t("第{no}阶段", {no: index + 1})}} {{priceName}}
      {{value.startNum}} - {{value.endNum}} {{unitMap[value.weightUnit]}}
    </div>
    <div>
      {{$t('默认') + priceName}}：
      {{value[`${fieldPrefix}Price`]}} {{currencyMap[value[`${fieldPrefix}PriceUnit`]]}} / {{unitMap[value[`${fieldPrefix}VolumeUnit`]]}}
    </div>
    <!--特需加价-->
    <div v-for="(special, specialIndex) in value.specialList">
      {{getDictDataLabel(DICT_TYPE.ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS, special.specialDictType) + priceName}}
        {{special[`${fieldPrefix}Price`]}}
        {{currencyMap[special[`${fieldPrefix}PriceUnit`]]}}
        {{unitMap[special[`${fieldPrefix}VolumeUnit`]]}}
    </div>
    <!--包装价-->
    <!--包装类型价格-->
    <template v-for="(item, i) in value.packagingList">
      {{$t('包装类型') + priceName + (i+1)}}
      {{showPackages(item.packagingTypes)}}
      {{item.packagingPrice}}
      {{currencyMap[item.packagingPriceUnit]}}
      {{unitMap[item.packagingVolumeUnit]}}
    </template>
  </div>
</template>

