<template>
  <view class="inspect-item" @click="toPage">
    <view
      class="content"
      :class="details.synchronization == 1 ? 'synchronization' : ''"
    >
      <view class="name">{{ getLabel(details.inspectionType) }}</view>
      <view class="info">
        <view class="info-row">
          <text class="title">{{ details.recordName }}</text>
          <text class="status">{{
            details.synchronization == 0 ? "待同步" : "已同步"
          }}</text>

          <view v-if="details.isException == 1" class="status alarm">
            <text class="iconfont icon-yichang1"></text>
            <text>有异常</text></view
          >
        </view>
        <view class="info-row info-row-code">
          <text>编号：</text>
          <text class="code-num">{{ details.inspectionCode }}</text>
        </view>
      </view>
      <view class="img">
        <image
          v-if="details.synchronization == 1"
          class="bg-img"
          src="../../static/img/add-img/default.png"
        ></image>
        <image
          v-else
          class="bg-img"
          src="../../static/img/add-img/active.png"
        ></image>
      </view>
    </view>
  </view>
</template>
<script>
import { pad_inspection_type } from "@/utils/dict.js";

export default {
  props: {
    details: {
      type: Object,
    },
    isDisable: {
      type: Boolean,
    },
  },
  methods: {
    getLabel(val) {
      const temp =
        (
          pad_inspection_type.rows.filter((item) => item.dictValue == val)[0] ||
          {}
        ).dictLabel || "";
      return temp.length ? temp.slice(0, 2) : "";
    },
    toPage() {
      const url =
        this.details.inspectionType == 1
          ? `/pages/inspectionContent/inspectionContent?isDisable=${
              this.isDisable ? 1 : 0
            }`
          : `/pages/shaftInspection/shaftInspection?isDisable=${
              this.isDisable ? 1 : 0
            }`;

      uni.navigateTo({
        url: `${url}&uid=${this.details.uid}`,
      });
    },
  },
};
</script>
<style scoped lang="less">
.inspect-item {
  width: 50%;
  padding-right: 16px;
  margin-bottom: 16px;
  .content {
    background: #fff;
    border: 0.4px solid rgba(224, 224, 224, 1);
    border-radius: 12px;
    padding: 18px 16px 14px 10px;
    display: flex;
    align-items: center;
    height: 84px;
    box-sizing: border-box;
    position: relative;
    background-image: linear-gradient(-67deg, #ffab2423, #ffab2411 50%);
    .name {
      background: #ffab2423;
      border-radius: 12px;
      width: 54px;
      height: 54px;
      margin-right: 10px;
      display: flex;
      justify-content: center;
      align-items: center;
      color: #f39800;
    }
    .info {
      .info-row {
        display: flex;
        align-items: center;
        margin-bottom: 8px;
        &:last-of-type {
          margin: 0;
        }
        .title {
          font-size: 12px;
          color: #000000;
          font-weight: bold;
          margin-right: 8px;
        }
        .status {
          padding: 2px 4px;
          font-size: 12px;
          color: #ffffff;
          text-align: center;
          line-height: 20px;
          font-weight: 400;
          background: #ffab24;
          border-radius: 3px;
        }
        .alarm {
          margin-left: 8px;
          background: rgba(255, 105, 82, 0.1);
          font-size: 12px;
          color: #ff6952;
          text-align: center;
          line-height: 20px;
          font-weight: 400;
        }
      }
      .info-row-code {
        font-size: 14px;
        color: #7c7c7c;
        font-weight: 400;
        .code-num {
          font-size: 14px;
          color: #000000;
          font-weight: 400;
        }
      }
    }

    .img {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      .bg-img {
        width: 80px;
        height: 80px;
      }
    }
  }

  .synchronization {
    background-image: linear-gradient(-67deg, #9c9c9c16, #9c9c9c09 50%);
    .name {
      background: #9c9c9c16;
      border-radius: 12px;
      color: #4a4a4a;
    }
    .status {
      background: #9c9c9c16 !important;
      color: #4a4a4a !important;
    }
  }
}
</style>
