GoodsInfo.vue 12.4 KB
<template>
  <div class="goods-components gl-form-page">
    <div class="title">商品信息</div>
      <div class="detail_pannel" v-for="(item, index) in goodsInfo" :key="index">
        <div class="item_label">上架商品:</div>
        <div class="item_value">
          <div class="incid_box">
            <div class="item" v-for="(subItem, subIndex) in detailInfo" :key="subIndex">
              <div class="label">{{ subItem.unit ? (membraneTypeList.includes(item['goodsType']) ? subItem.label +
            `(元)/${subItem.value == 'purchasePrice' ? '卷' : '车'}` : (subItem.label + '(元)/件')) : subItem.label }}:</div>
              <div class="value">{{ subItem.unit ? (priceFilter(item[subItem.value]) || '-') : (item[subItem.value] || '-') }}</div>
            </div>
            <!-- 商品分类 延保类 -->
            <div class="item" v-if="item['goodsType'] == 1 || (extendedPosiType.includes(item['goodsType']) && !supplierCode.includes(item['supplierCode'] + ''))">
              <div class="label">部位:</div>
              <div class="value">{{ item['positionNames'] || '-' }}</div>
            </div>
            <!-- 质保年限 膜类展示-->
            <div class="item" v-if="membraneTypeList.includes(item['goodsType'])">
              <div class="label">质保年限/年:</div>
              <div class="value">{{ item['warrantyPeriod'] || '-' }}</div>
            </div>
            <!-- 商品分类 权益升级 -->
            <div class="item" v-if="equitySceneType.includes(item['goodsType']) && !supplierCode.includes(item['supplierCode'] + '')">
              <div class="label">服务时间/年:</div>
              <div class="value">{{ item['serviceYears'] || '-' }}</div>
            </div>
            <!-- 商品分类 权益升级 -->
            <div class="item" v-if="equitySceneType.includes(item['goodsType'])">
              <div class="label">实体卡:</div>
              <div class="value">{{ item['entityCardFlag'] == 'Y' ? '是' : '否' }}</div>
            </div>
            <div class="item" v-if="equitySceneType.includes(item['goodsType']) || extendedPosiType.includes(item['goodsType'])">
              <div class="label">适用车价:</div>
              <div v-if="!filterEmpty(item['minSuitCarPrice']) && !filterEmpty(item['maxSuitCarPrice'])">{{ item['minSuitCarPrice'] }} - {{ item['maxSuitCarPrice'] }}万</div>
              <div v-else>-</div>
            </div>
            <!-- 商品分类 权益升级 -->
            <div class="item flex_1" v-if="equitySceneType.includes(item['goodsType']) && !supplierCode.includes(item['supplierCode'] + '')">
              <div class="label">服务项目:</div>
              <div class="value">{{ item['serviceItemNames'] || '-' }}</div>
            </div>
          </div>
          <div class="grounding_box">
            <!-- 太阳膜/延保类(第三方供应方)时展示 -->
            <div class="grounding_item" v-if="(extendedPosiType.includes(item['goodsType']) && !supplierCode.includes(item['supplierCode'] + '')) || item['goodsType'] == 1">
              <div class="label">上架部位:</div>
              <div class="value">{{ item['positionStr'] || '-' }}</div>
            </div>
            <div class="grounding_item">
              <div class="label">商品别名:</div>
              <div class="value">{{ item['goodsAlias'] || '-' }}</div>
            </div>
            <!-- 太阳膜时展示 -->
            <div class="grounding_item" v-if="item['goodsType'] == 1">
              <div class="label">质保卡类型:</div>
              <div class="value">{{ item['warrantyTypeStr'] || '-' }}</div>
            </div>
            <!-- 太阳膜/售后众筹场景时展示 -->
            <div class="grounding_item" v-if="item['goodsType'] == 1 || item['sceneType'] == 3">
              <div class="label">升级产品供货模式:</div>
              <div class="value">{{ item['upgradeSupplyModeStr'] || '-' }}</div>
            </div>
            <div class="grounding_item">
              <div class="label">{{ membraneTypeList.includes(item['goodsType']) ? '售价(元)/车:' : '售价(元)/件:' }}</div>
              <div class="value">{{ priceFilter(item['sellPrice']) || '-' }}</div>
            </div>
            <div class="grounding_item">
              <div class="label">{{ membraneTypeList.includes(item['goodsType']) ? '最低售价(元)/车:' : '最低售价(元)/件:' }}</div>
              <div class="value">{{ priceFilter(item['minSellPrice']) || '-' }}</div>
            </div>
            <!-- 非权益/延保类或售后众筹场景时展示 -->
            <div class="grounding_item" v-if="!equitySceneType.includes(item['goodsType']) && !extendedPosiType.includes(item['goodsType']) || item['sceneType'] == 3">
              <div class="label">{{ membraneTypeList.includes(item['goodsType']) ? '产品、升级成本(元)/车:' : '产品、升级成本(元)/件:' }}</div>
              <div class="value">{{ priceFilter(item['upgradeProductCost']) || '-' }}</div>
            </div>
            <!-- 产品供货模式选择“门店回收原厂+嘀加”时展示 -->
            <div class="grounding_item" v-if="item['upgradeSupplyMode'] == 4">
              <div class="label">{{ membraneTypeList.includes(item['goodsType']) ? '回收成本(元)/车:' : '回收成本(元)/件:' }}</div>
              <div class="value">{{ priceFilter(item['recoveryCost']) || '-' }}</div>
            </div>
            <!-- 产品供货模式选择“门店套码+嘀加”“ 服务商自采+嘀加”时展示 -->
            <div class="grounding_item" v-if="item['upgradeSupplyMode'] == 3 || item['upgradeSupplyMode'] == 5">
              <div class="label">{{ membraneTypeList.includes(item['goodsType']) ? '虚拟对账成本(元)/车:' : '虚拟对账成本(元)/件:' }}</div>
              <div class="value">{{ priceFilter(item['virtualAccountCost']) || '-' }}</div>
            </div>
            <!-- 权益类目/延保类目 -->
            <div class="grounding_item" v-if="equitySceneType.includes(item['goodsType']) || extendedPosiType.includes(item['goodsType'])">
              <div class="label">{{ membraneTypeList.includes(item['goodsType']) ? '嘀加成本(元)/车:' : '嘀加成本(元)/件:' }}</div>
              <div class="value">{{ priceFilter(item['djCost']) || '-' }}</div>
            </div>
            <!-- 权益类目/延保类目 -->
            <div class="grounding_item" v-if="equitySceneType.includes(item['goodsType']) || extendedPosiType.includes(item['goodsType'])">
              <div class="label">{{ membraneTypeList.includes(item['goodsType']) ? '第三方成本(元)/车:' : '第三方成本(元)/件:' }}</div>
              <div class="value">{{ priceFilter(item['thirdPartyCost']) || '-' }}</div>
            </div>
          </div>
        </div>
      </div>
  </div>
</template>

<script>
import { fetchConfig } from '@/config'
import { upgradeSupplyModeList, crowdUpgradeSupplyModeList } from '@/common/constant'
export default {
  name: 'GoodsInfo',
  props: {
    goodsInfo: Array
  },
  data() {
    return {
      equitySceneType: [], // 权益类目
      extendedPosiType: [], // 延保类
      membraneTypeList: [], // 膜类
      supplierCode: [], // 第三方供应商编码
      detailInfo: [
        {
          label: '商品名称',
          value: 'upgradeGoodsName'
        },
        {
          label: '商品编码',
          value: 'type'
        },
        {
          label: '第三方编码',
          value: 'thirdPartyCode'
        },
        {
          label: '采购价',
          value: 'purchasePrice',
          unit: true
        },
        {
          label: '参考售价',
          value: 'upgradePrice',
          unit: true
        },
        {
          label: '所属系列',
          value: 'goodsName'
        },
        {
          label: '所属分类',
          value: 'goodsTypeName'
        },
        {
          label: '商品ID',
          value: 'upgradeCommodityCode'
        }
      ],
      warrantyTypeShow: {
        0: '质保卡',
        1: '质保权益卡'
      }
    }
  },
  mounted() {
    this.getBaseConfig()
  },
  methods: {
    // 获取配置服务上面配置的类目
    async getBaseConfig() {
      try {
        const { equitySceneType, extendedPosiType, membraneTypeList, supplierCode } = await fetchConfig()
        this.equitySceneType = equitySceneType
        this.extendedPosiType = extendedPosiType
        this.membraneTypeList = membraneTypeList
        this.supplierCode = supplierCode
        // 获取商品部位数据
        const positionTypeList = await this.$apis.contractManager.getProdPartListApi({goodsType: 1}) // 太阳膜
        const extendedPosiTypeList = await this.$apis.contractManager.getProdPartListApi({ goodsType: extendedPosiType && extendedPosiType[0] }) // 延保
        this.goodsInfo?.forEach(val => {
          const { upgradeGoods, goodsInfo, warrantyType, upgradeSupplyMode } = val
          const positionNamesArr = this.$common.utils.deepClone(positionTypeList.concat(extendedPosiTypeList)).filter(subVal => (upgradeGoods?.position?.split(','))?.includes(subVal.position + '')) || []
          const arr = val.goodsType == 1 ? upgradeSupplyModeList : crowdUpgradeSupplyModeList
          val.positionStr = this.$common.utils.deepClone(positionTypeList.concat(extendedPosiTypeList)).filter(subVal => val?.position == subVal.position)[0]?.confName || '' // 上架部位
          val.positionNames = positionNamesArr.length ? positionNamesArr.map(subItem => subItem?.confName).join('/') : '' // 部位名称
          val.purchasePrice = upgradeGoods?.purchasePrice // 采购价
          val.serviceYears = upgradeGoods?.serviceYears // 服务时间
          val.serviceItemNames = upgradeGoods?.upgradeGoodsServiceItemsList?.map(v => `${v.serviceName}-${v.serviceGrade}/${v.servicePeriod}`).join(',') // 服务项目
          val.type = upgradeGoods?.type // 编码
          val.thirdPartyCode = upgradeGoods?.thirdPartyCode // 第三方编码
          val.entityCardFlag = upgradeGoods?.entityCardFlag // 是否实体卡
          val.minSuitCarPrice = upgradeGoods?.minSuitCarPrice // 适用车价最低价
          val.maxSuitCarPrice = upgradeGoods?.maxSuitCarPrice // 适用车价最高价
          val.supplierCode = goodsInfo?.supplierCode // 供应方
          val.warrantyTypeStr = this.warrantyTypeShow[warrantyType] || '-' // 质保卡类型
          val.warrantyPeriod = upgradeGoods?.warrantyPeriod // 质保年限
          val.upgradePrice = upgradeGoods?.upgradePrice // 参考售价
          val.upgradeSupplyModeStr = arr?.filter(v => v.confId == upgradeSupplyMode)[0]?.confName || '' // 升级产品供货模式
        })
      } catch (error) {
        console.log(error)
      }
    },
    // 处理金额补零
    priceFilter(num) {
      var pow = Math.pow(10, 2)
      if (this.filterEmpty(num)) return '-'
      return (Math.round(num * pow) / pow).toFixed(2)
    },
    filterEmpty(data) {
      return (data ?? '') === ''
    }
  }
}
</script>
<style lang="scss" scoped>
.goods-components {
  margin-top: 10px;
  background: white;
  .title {
    padding: 0 20px;
    font-size: 16px;
    font-weight: bold;
    height: 58px;
    line-height: 58px;
    border-bottom: 1px solid #d8d8d8;
    margin: 0 0;
    color: #333;
  }
  .edit-form-container {
    padding: 32px 0 12px;
  }
  .detail_pannel {
    display: flex;
    padding: 32px 20px 12px;
    border-bottom: 1px solid #e8e8ea;
    font-size: 14px;
    &:last-child {
      border: none;
    }
    .item_label {
      width: 160px;
      text-align: right;
      color: #666666;
    }
    .item_value {
      width: 100%;
      .incid_box {
        background: #f9f9f9;
        display: flex;
        flex-wrap: wrap;
        padding: 10px 0;
        .item{
          flex: 0 0 33%;
          margin: 10px 0;
          display: flex;
          .label{
            width: 160px;
            text-align: right;
            color: #333333;
          }
        }
        .flex_1{
          flex: 0 0 100%;
          .value{
            line-height: 30px;
            margin-top: -8px;
          }
        }
      }
      .grounding_box {
        display: flex;
        flex-wrap: wrap;
        padding: 10px 0;
        .grounding_item{
          flex: 0 0 33%;
          margin: 10px 0;
          display: flex;
          .label{
            width: 160px;
            text-align: right;
            color: #333333;
          }
        }
      }
    }
  }
}
</style>