<template>
  <div class="warning-card" :style="{ 'border': `1px solid ${changeBG(item.yjjb)}` }">
    <div class="warning-image flex">
      <!-- -->
      <template v-if="!item.yjtp || item.yjtp.includes('baidu')">
        <img src="@/assets/images/car.png" width="65" height="70" v-if="item.yjlb == 2" />
        <img src="@/assets/images/default_male.png" width="65" height="70" v-else />
      </template>
      <el-image  preview-teleported v-else @click.stop style="width: 65px; height: 70px" :src="item.yjtp" :preview-src-list="[item.yjtp]" show-progress>
        <template #error>
          <div class="image-slot error">
            <img src="@/assets/images/car.png" width="65" height="70" v-if="item.yjlb == 2" />
            <img src="@/assets/images/default_male.png" width="65" height="70" v-else />
          </div>
        </template>
      </el-image>
      <div class="ml10 warning-info">
        <div class="flex just-between align-center">
          <div class="flex align-center mt4" v-if="item.yjlb == 2">
            <span>{{ item.cph }}</span>
          </div>
          <div class="flex align-center mt4" v-else>
            <span>{{ item.ryxm }}</span>
            <span class="gapline mr10 ml10"></span>
            <span>{{ IdCard(item.rysfzh, 2) }}</span>
            <span class="gapline mr10 ml10"></span>
            <span>{{ IdCard(item.rysfzh, 3) }}</span>
          </div>
          <span class="tag" v-if="item.yjbq" :style="{ 'background': `${changeBG(item.yjjb)}` }">{{ item.yjbq }}</span>
        </div>
        <div v-if="item.yjlb == 2" class="flex">车牌类型：
          <DictTag :tag="false" :value="item.hplx" color="#fff" :options="dict.D_BZ_HPZL" />
        </div>
        <div class="mt4" v-else>身份证：{{ item.rysfzh }}</div>
        <div class="mt4 two_text_detail">预警时间：{{ item.yjsj }}</div>
      </div>
    </div>
    <div class="warning-info warning-boder pb5" v-if="item.yjlx == '01'">
      <div class="mt4 two_text_detail">预警内容：{{ item.yjnr }}</div>
    </div>
    <div class="warning-info pt5 pb5 warning-boder" v-if="item.yjlx == '01'">
      <div class="mt4 two_text_detail">处置结果：{{ item.yjnr }}</div>
    </div>
    <div class="warning-info pt5 " v-if="item.yjlx == '01'">
      <div class="two_text_detail flex lh25"><img src="@/assets/images/ddtb.png" width="20" height="25" alt=""
          srcset="">{{
            item.yjnr }}</div>
    </div>
    <div class="mt4 two_text_detail" v-if="buttonBox">
            <el-button type="primary" @click="pushAssess(item)">全息档案</el-button>
      <el-button type="primary" @click="pushWarning(item)">预警指派</el-button>
      <el-button color="#ef7762" @click="showDetail(item)" style="color: #fff;">转合成</el-button>
      <!-- <el-button type="warning">转基管</el-button> -->
      <el-button type="danger">转会商</el-button>
      <el-button type="success" @click="showFeedback(item, '签收')" v-if="item.czzt == '01'">签收</el-button>
      <el-button type="success" @click="showFeedback(item, '反馈')" v-if="item.czzt == '02'">反馈</el-button>
      <el-button type="success" @click="showFeedback(item, '查看反馈')" v-if="item.czzt == '03'">查看反馈</el-button>
      <el-button type="success" @click="plotThetrajectory(item.rysfzh)">轨迹上图</el-button>
    </div>
    <!-- props.item.czzt == '03'" -->
  </div>
  <HolographicArchive v-model="assessShow" :dataList="dataList" />
  <WarningAssignment v-model="warningShow" :dataList="dataList"/>
</template>

<script setup>
import { IdCard } from '@/utils/validate.js'
import { reactive, ref, getCurrentInstance, watch } from "vue";
import { qcckGet, qcckPost } from "@/api/qcckApi.js";
import HolographicArchive from './holographicArchive.vue'
import WarningAssignment from './warningAssignment.vue'
const { proxy } = getCurrentInstance();

const props = defineProps({
  item: {
    type: Object,
    default: {}
  }, dict: {
    tupe: Object,
    default: {}
  }, buttonBox: {
    type: Boolean,
    default: false
  }
});
watch(() => props.item, (newVal, oldVal) => {
  emit('fkLxOptions', newVal);
},{deep:true,immediate:true})
const emit = defineEmits(["plotThetrajectory", "showDetail", 'showFeedback','fkLxOptions']);

const changeBG = (str) => {
  switch (str) {
    case "01":
      return "red";
    case "02":
      return "orange";
    case "03":
      return "#b5b522";
    default:
      return "blue";
  }
};
// 轨迹上图
const plotThetrajectory = (val) => {
  emit('plotThetrajectory', val);
}
// 查看反馈
const showFeedback = (val, type) => {
  switch (type) {
    case '签收':
      proxy.$confirm("是否确定要签收？", "警告", { type: "warning" }).then(() => {
        // switch (val.czzt) {
        //   case '01':
        //     val.czzt = '02'
        //     break;
        //   case '02':
        //     val.czzt = '03'
        //     break;
        //   default:
        //     break;
        // }
        qcckPost({ id: val.id }, "/mosty-gsxt/tbYjxx/yjqs").then(() => {
          val.czzt = '02'
          proxy.$message({ type: "success", message: "签收成功" });
        });
      })
      break;
    case '反馈':
    case '查看反馈':
      const data = {
        ...val,
        type: type,
      }
      emit('showFeedback', data);
      break;
  }
}
const showDetail = (item) => {
  emit('showDetail', item);
}
// 全息档案
const assessShow = ref(false)
const dataList = ref()
const pushAssess = (val) => {
  assessShow.value = true;
  dataList.value = val;
}
// 预警指派
const warningShow = ref(false)
const pushWarning = (val) => {
  warningShow.value = true;
  dataList.value = val;
}
</script>

<style lang="scss" scoped>
.warning-card {
  // background: url("~@/assets/images/xxxxxx.png") no-repeat center center;
  background-size: 100% 100%;

  gap: 12px;
  margin-bottom: 4px;
  padding: 10px;
  box-sizing: border-box;

  .warning-image {
    //
    // width: 80px;
    // height: 100px;

    // img {
    //   width: 100%;
    //   height: 100%;
    //   object-fit: cover;
    // }
  }

  .warning-info {
    flex: 1;

    .tag {
      padding: 1px 6px;
      background: #0072FF;
      border-radius: 2px 2px 2px 2px;
      font-size: 12px;
    }

    .gapline {
      width: 2px;
      height: 14px;
      background: #e9e9e9;
    }
  }

  // 图片错误状态样式
  .image-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
    border-radius: 4px;
  }

  // 主图错误和预览图错误的样式
  .image-slot.error,
  .image-slot.viewer-error {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
  }

  .warning-boder {
    border-bottom: 2px dashed #0958b2;
  }
}

.red {
  background: url("~@/assets/images/GroupRed.png") no-repeat center center;
  background-size: 100% 100%;
}

.orange {
  background: url("~@/assets/images/GroupOrange.png") no-repeat center center;
  background-size: 100% 100%;
}

.yellow {
  background: url("~@/assets/images/GroupYellow.png") no-repeat center center;
  background-size: 100% 100%;
}

.blue {
  background: url("~@/assets/images/GroupBlue.png") no-repeat center center;
  background-size: 100% 100%;
}
</style>
