<template>
  <view class="orderCard">
    <view class="order-top">
      <view class="orderNo">
        采购单号：{{ order.soNo }}
      </view>
      <!--      <view :style="{ color: getFlagColor(order.flag) }" class="flag">-->
      <!--        {{ order.flagStr }}-->
      <!--      </view>-->
    </view>
    <view class="order-body">
      <view class="baseInfo">
        <view>
          数量：{{ order.itemCount }}
        </view>
        <view v-if="order.totalPrice">
          金额：{{ order.totalPrice }}
        </view>
        <view>
          状态：{{ soStatusText }}
        </view>
        <view>
          采购员：{{ order.userName }}
        </view>
      </view>
      <view class="footer">
        <view @click="gotoInWare" class="btn pg" style="margin-right: 40rpx">
          <!--          在什么都不能操作的情况下，可以查看详情-->
          查看入库单
        </view>
        <view @click="gotoDetail" class="btn pg">
          <!--          在什么都不能操作的情况下，可以查看详情-->
          入库
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import {
  getUserInfo,
  getStrData
} from '@/utils/auth';
import request from '@/utils/request';
import {getDictTextByCodeAndValue} from "@/utils/utils";

export default {
  name: "repairSoCard",
  props: {
    order: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  computed: {
    // projectName() {
    //   if (this.order && this.order.projectList && this.order.projectList.length > 0) {
    //     return this.order.projectList.map(m => m.name).join(',')
    //   }
    //   return ''
    // }
  },
  data() {
    return {
      soStatusText:''
    }
  },
  mounted() {
    this.getDictTextByCodeAndValue(this.order.soStatus); // 组件加载时调用方法
  },
  onLoad() {

  },
  methods: {
    getDictTextByCodeAndValue(soStatus) {
      getDictTextByCodeAndValue('repair_so_status', soStatus)
          .then(value => {
            this.soStatusText = value; // 存储到 data 中
          })
          .catch(error => {
            this.soStatusText = "未知";
            console.error(error);
          });
    },
    /**
     * 查看详情
     */
    gotoDetail() {
      uni.navigateTo({
        url: '/pages-warehouse/inOutWarehouse/part?soId=' + this.order.id
      })
    },
    gotoInWare(){
      uni.navigateTo({
        url: '/pages-order/inWare/inWare?soId=' + this.order.id
      })
    },
    /**
     * 项目派工
     */
    projectDis() {
      uni.navigateTo({
        url: '/pages-order/choosePeople/choosePeople?id=' + this.order.id
      })
    }
  },
  getStatus() {

  }
}
</script>

<style lang="less" scoped>
.orderCard {
  background: #FFFFFF;
  border-radius: 8rpx 8rpx 8rpx 8rpx;
  border-left: 4rpx solid #FFB323;
  padding: 0 30rpx;
  margin: 15rpx 0;
}

.order-top {
  padding: 20rpx 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #F3F5F7;

  .orderNo {
    font-weight: 500;
    font-size: 24rpx;
    color: #858BA0;
  }

  .flag {
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    font-size: 24rpx;
  }
}

.order-body {
  .carNum {
    margin: 20rpx 0;
  }

  .carModel {
    margin: 20rpx 0;
    font-weight: 500;
    font-size: 28rpx;
    color: #858BA0;
  }

  .project {
    padding: 20rpx 10rpx;
    background: #F2F2F7;
    border-radius: 4rpx 4rpx 4rpx 4rpx;

    display: flex;
    align-items: center;

    .project-left {
      flex: 1;
      width: 0;
    }

    .project-right {
      padding: 0 16rpx;
      display: flex;
      flex-direction: column;
      align-items: center;

      border-left: 1rpx solid #DDDDDD;

      .rightIcon {
        width: 40rpx;
        height: 40rpx;
      }

      .rightText {
        font-weight: 500;
        font-size: 24rpx;
        color: #17DBB1;
      }
    }

    .title {
      font-weight: 500;
      font-size: 24rpx;
      color: #0174F6;
      display: flex;
      align-items: center;
      column-gap: 8rpx;
    }

    .titleIcon {
      width: 24rpx;
      height: 24rpx;
    }

    .desc {
      font-weight: 500;
      font-size: 24rpx;
      color: #333333;
      margin-top: 10rpx;
    }
  }

  .baseInfo {
    font-weight: 500;
    font-size: 28rpx;
    color: #858BA0;
    //padding-bottom: 10rpx;

    & > view {
      margin: 30rpx 0;
    }
  }

  .footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    column-gap: 10rpx;
    padding-bottom: 30rpx;

    .btn {
      width: 172rpx;
      height: 60rpx;
      border-radius: 30rpx 30rpx 30rpx 30rpx;
      border: 2rpx solid #0174F6;

      display: flex;
      align-items: center;
      justify-content: center;

      font-weight: 500;
      font-size: 28rpx;
      color: #0174F6;

      &.qc {
        background: #0174F6;
        color: #fff;
      }

    }
  }
}
</style>
