<template>
  <view class="accessories_nfo_card" @tap.stop="toUrl">
    <view class="accessories_nfo_ac">
      <view class="accessories_nfo_title"> 申请单号: </view>
      <view class="accessories_nfo_info">
        <view>
          {{ item.salesId }}
        </view>
      </view>
      <view class="accessories_nfo_title colorts">
        {{ item.stateName }}
      </view>
    </view>
    <view class="accessories_nfo_ac">
      <view class="accessories_nfo_title"> 申请时间: </view>
      <view class="accessories_nfo_info">
        <view>
          {{ item.createTime }}
        </view>
      </view>
    </view>
    <view class="accessories_nfo_ac">
      <view class="accessories_nfo_title"> 总金额: </view>
      <view class="accessories_nfo_info">
        <view>
          {{
            [...(item.itemList || []).map(a => Math.round(a.salesPrice * a.quantity * 100) / 100), 0].reduce((a, b) => {
              return a + b
            })
          }}
        </view>
      </view>
    </view>
    <view class="accessories_nfo_ac">
      <view class="accessories_nfo_title"> 网点: </view>
      <view class="accessories_nfo_info">
        <view> {{ item.websitName }}({{ item.websitNumber }}) </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    type: {
      type: String,
      default: ''
    },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {}
  },
  methods: {
    toUrl() {
      var { id, pushFlag, identity } = this.item
      if (this.type === 'entryStock') {
        this.$navToPage({
          url: `/packageAttachment/pages/applyReturnOfNewPiece/index?salesId=${id}&pushFlag=${
            pushFlag || ''
          }&identity=${identity}`
        })
      } else {
        this.$navToPage({
          url: `/packageAttachment/pages/orderOfSales/details?salesId=${id}&pushFlag=${
            pushFlag || ''
          }&identity=${identity}`
        })
      }
    }
  }
}
</script>

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