<template>
  <view class="task-item">
    <view @click="detailClick">
      <view class="task-head">
        <view class="sn-box">单据编号：{{ item.number }}</view>
        <view>
          <view class="tips tips-red" v-if="item.status == 1">待审核</view>
          <view class="tips tips-greed" v-if="item.status == 2">已入库</view>
          <view class="tips tips-yellow" v-if="item.status == 4">入库中</view>
        </view>
      </view>
      <view class="task-line">
        <view>客户名称：</view>
        <view>{{ item.supplierName }}</view>
      </view>
      <view class="task-line">
        <view>单据日期：</view>
        <view>{{ item.createTime }}</view>
      </view>
      <view class="task-line">
        <view class="task-line2">
          <view>类别：</view>
          <view>采购入库</view>
        </view>
        <view class="task-line2">
          <view>入库人：</view>
          <view>张三</view>
        </view>
        <!-- <view class="task-line2">
          <view>出库人：</view>
          <view class="task-num">{{ item.goodsTypeCount || 0 }}种</view>
        </view> -->
      </view>
      <view class="task-line">
        <view class="task-line2">
          <view>货物总数：</view>
          <view class="task-num">{{ item.goodsQuantity }}件</view>
        </view>
        <view class="task-line2">
          <view>货物种类：</view>
          <view class="task-num">{{ item.goodsTypeCount || 0 }}种</view>
        </view>
      </view>
    </view>
    <view class="action-box">
      <view class="task-line" style="font-size: 24rpx; margin: 0">
        <view>入库时间：</view>
        <view>2021-11-21 00:00:03</view>
      </view>
      <view class="task-bottom">
        <view
          class="btn btn-1"
          v-if="item.status == 1 || item.status == 4"
          @click="toAudit"
          >去审核</view
        >
        <view class="btn btn-2" v-else @click="toDetail">详情</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => {},
    },
    type: {
      type: String,
      default: "",
    },
  },
  data() {
    return {};
  },
  methods: {
    toAudit() {
      this.$emit("toAudit", this.item);
    },
    toDetail() {
      this.$emit("toDetail", this.item);
    },
    detailClick() {
      if (this.item.status == 1 || this.item.status == 4) {
        this.toAudit();
      } else {
        this.toDetail();
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.task-item {
  width: 100%;
  background-color: #fff;
  border-radius: 16rpx;
  padding: 24rpx 24rpx 0;
  margin-bottom: 24rpx;
  .task-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .sn-box {
      color: #333;
      font-family: "PingFang SC";
      font-size: 28rpx;
      font-weight: 500;
    }
    .tips {
      font-family: "PingFang SC";
      font-size: 22rpx;
      font-weight: 400;
      width: 120rpx;
      height: 44rpx;
      border-radius: 8rpx;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .tips-red {
      color: #ff3b1d;
      background: rgba(255, 59, 29, 0.2);
    }
    .tips-greed {
      color: #00b97b;
      background: rgba(0, 185, 123, 0.2);
    }
    .tips-yellow {
      color: #f57701;
      background: rgba(245, 151, 1, 0.2);
    }
  }

  .task-line {
    display: flex;
    align-items: center;
    color: #666;
    font-family: "PingFang SC";
    font-size: 28rpx;
    font-weight: 400;
    margin-top: 16rpx;
  }
  .task-line2 {
    width: 50%;
    display: flex;
    align-items: center;
    .task-num {
      color: #0256ff;
    }
  }

  .action-box {
    margin-top: 32rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .task-bottom {
    border-top: 1px solid #f0f0f0;
    height: 104rpx;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    .btn {
      width: 144rpx;
      height: 56rpx;
      border-radius: 8rpx;
      font-size: 28rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: "PingFang SC";
    }
    .btn-1 {
      background: #0256ff;
      color: #fff;
    }
    .btn-2 {
      border: 1px solid #0256ff;
      background: rgba(2, 86, 255, 0.2);
      color: #0256ff;
    }
  }
}
</style>
