<template>
  <view class="accessories_item" @tap.stop="toUrl">
    <view class="accessories_item_lay">
      <view class="accessories_item_title">
        {{ item.goodsName }}
      </view>
      <view class="accessories_item_number">
        {{ item.goodsId }}
      </view>
    </view>
    <view class="accessories_item_lay">
      <view class="accessories_item_inventory"> 库存{{ [item.oldQty, item.qty][type] }} </view>
      <view class="accessories_item_unit"> 单位：{{ item.goodsStockUnit }} </view>
    </view>
    <view class="accessories_item_lay">
      <view class="accessories_item_amount">
        新件售价<text>￥{{ item.marketPrice }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => ({})
    },
    type: {
      type: [Number, String],
      default: ''
    }
  },
  data() {
    return {}
  },
  methods: {
    toUrl() {
      if (this.type !== '') {
        if (this.type === 0) {
          this.$navToPage({
            url: `/packageAttachment/pages/returnOfOldParts/index?partsNumber=${this.item.goodsId || ''}`
          })
        } else if (this.type === 1) {
          this.$navToPage({
            url: `/packageAttachment/pages/returnOfNewParts/index?partsNumber=${
              this.item.partsNumber || ''
            }&state=SALES`
          })
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
@import './style/accessories_item.scss';
</style>
