<!--  -->
<template>
  <div class="explorate" :class="{ downMode }" v-if="data">
    <div>
      <h2 class="title">道路交通事故现场勘查笔录(续页)</h2>

      <div class="container">
        <div class="table-header">
          <p style="margin-bottom: 5px">二、现场监控设备情况</p>
          <div class="table-header-info">
            <div class="item" v-for="(i, index) in headerList.options" @click="checkOptions(headerList, index)">
              <ui-icon :type="data.cameraInfo.check == i.id ? 'rb_y' : 'rb_n'"></ui-icon>
              <span>{{ i.title }}</span>
              <div v-if="i.id == 2" style="flex: 1">
                <input type="text" v-model="data.cameraInfo.value" />
                <div class="content-box left" style="height: 24px; border-bottom: 1px solid #000">{{ data.cameraInfo.value }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="table-body">
          <p style="margin-bottom: 20px; margin-top: 10px">三、现场伤亡人员基本情况及救援</p>
          <p style="margin-bottom: 10px">（一）伤亡人员基本情况；</p>
          <div class="item">
            <span>当场死亡：（</span>
            <div style="min-width: 10px">
              <input style="width: 30px" type="text" v-model="data.dieNum" />
              <div class="content-box">{{ data.dieNum }}</div>
            </div>
            <span>）人；急救、医疗人员签名确认：</span>
            <div style="flex: 1">
              <input class="under-line" type="text" v-model="data.doctorSign" />
              <div class="content-box left" style="border-bottom: 1px solid #000">{{ data.doctorSign }}</div>
            </div>
          </div>
          <div class="item">
            <span>受伤：（</span>
            <div style="min-width: 10px">
              <input style="width: 30px" type="text" v-model="data.hurtNum" />
              <div class="content-box">{{ data.hurtNum }}</div>
            </div>
            <span>）人。</span>
          </div>
          <div class="item column">
            <span>伤亡人员去向：</span>
            <div style="min-height: 60px; width: 100%">
              <textarea style="height: 60px" v-model="data.hurtDieGo" name="" id="" cols="30" rows="10"></textarea>
              <div class="content-box top-left">{{ data.hurtDieGo }}</div>
            </div>
          </div>
          <div class="item column">
            <span>其他需求说明的情况：</span>
            <div style="min-height: 60px; width: 100%">
              <textarea style="height: 60px" v-model="data.desc" name="" id="" cols="30" rows="10"></textarea>
              <div class="content-box top-left">{{ data.desc }}</div>
            </div>
          </div>
          <p>（二）救援简要情况：</p>

          <div class="item" style="margin-top: 10px">
            <span> 是否涉及危险物品：</span>
            <div style="margin-right: 40px" v-for="(i, index) in isnotList.options" @click="checkOptions(isnotList, index)">
              <ui-icon :type="data.dangerousInfo.check == i.id ? 'rb_y' : 'rb_n'"></ui-icon>
              <span>{{ i.title }}</span>
            </div>
            <!-- <div style="margin-right: 40px">
              <ui-icon type="rb_n"></ui-icon>
              <span>是</span>
            </div> -->
            <div>名称：</div>
            <div style="flex: 1">
              <input class="under-line" type="text" v-model="data.dangerousInfo.value" />
              <div class="content-box left" style="border-bottom: 1px solid #000">{{ data.dangerousInfo.value }}</div>
            </div>
          </div>
          <p style="margin-bottom: 5px">相关部门和人员到达情况：</p>
          <div class="item half">
            <template v-for="(i, index) in reachList.options">
              <div v-if="index < 2" @click="checkOptions(reachList, index)">
                <div style="display: inline-block">
                  <ui-icon :type="reachList.check == i.id ? 'rb_y' : 'rb_n'"></ui-icon>
                  <span>{{ i.title }}</span>
                </div>
              </div>
            </template>
          </div>
          <div class="item half">
            <template v-for="(i, index) in reachList.options">
              <div v-if="index >= 2" @click="checkOptions(reachList, index)">
                <div style="display: inline-block">
                  <ui-icon :type="reachList.check == i.id ? 'rb_y' : 'rb_n'"></ui-icon>
                  <span>{{ i.title }}</span>
                </div>
              </div>
            </template>
          </div>
        </div>
        <div class="table-excel">
          <p style="margin-bottom: 10px">四、现场事故车辆车型、牌号及车辆挡位 转向、灯光、仪表指针位置，汽车行驶记录仪、车载 事件数据记录仪、卫星定位装置等安装及使用情况</p>
          <table>
            <tr>
              <td rowspan="2">编号</td>
              <td rowspan="2">牌号</td>
              <td rowspan="2">车辆类型</td>
              <td rowspan="2">车辆档位</td>
              <td rowspan="2">灯光开启情况</td>
              <td rowspan="2">车速仪表指针位置</td>
              <td colspan="3">车载设备安装使用情况（有，无）</td>
            </tr>
            <tr>
              <td>汽车行驶记录仪</td>
              <td>车载事件数据记录仪</td>
              <td>卫星定位装置</td>
            </tr>
            <tr v-for="(i, index) in data.list">
              <td v-for="(j, j_index) in i">
                <div class="content-box">{{ data.list[index][j_index] }}</div>
                <input type="text" v-model="data.list[index][j_index]" />
              </td>
            </tr>
          </table>
        </div>
        <div class="sign-box">
          <div>
            <span>现场勘查人员签名：</span>
            <div>
              <input type="text" v-model="data.explorateSign" />
              <div class="content-box left">{{ data.explorateSign }}</div>
            </div>
          </div>
          <div>
            <span>记录人签名：</span>
            <div>
              <input type="text" v-model="data.reportSign" />
              <div class="content-box left">{{ data.reportSign }}</div>
            </div>
          </div>
        </div>
        <div class="sign-box">
          <div>
            <span>当事人签名：</span>
            <div>
              <input type="text" v-model="data.clientSign" />
              <div class="content-box left">{{ data.clientSign }}</div>
            </div>
          </div>
          <div>
            <span>见证人签名：</span>
            <div>
              <input type="text" v-model="data.witnessSign" />
              <div class="content-box left">{{ data.witnessSign }}</div>
            </div>
          </div>
        </div>
      </div>
      <div class="footer">
        <span>共<span>肆</span>页</span>
        <span>第<span>贰</span>页</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref, toRefs, onBeforeMount, onMounted, nextTick, defineProps } from "vue";

import { tables } from "@/store/tables";
import { tablesInfo, setData } from "./data";
const props = defineProps({
  downMode: { type: Boolean, default: false },
  isDownloadShow: { type: Boolean, default: false },
});
const data = ref(null);

const checkOptions = (item, index) => {
  item.check = item.options[index].id;
  data.value[item.type].check = item.check;
};
const headerList = ref({
  check: 0,
  type: "cameraInfo",
  options: [
    {
      id: 1,
      title: "未发现",
    },
    {
      id: 2,
      title: "发现",
    },
  ],
});
const isnotList = ref({
  check: 0,
  type: "dangerousInfo",
  options: [
    {
      id: 1,
      title: "否",
    },
    {
      id: 2,
      title: "是",
    },
  ],
});
const reachList = ref({
  check: 0,
  type: "reachs",
  options: [
    {
      id: 1,
      title: "医疗",
    },
    {
      id: 2,
      title: "消防",
    },
    {
      id: 3,
      title: "清障",
    },
    {
      id: 4,
      title: "其他",
    },
  ],
});
const saveHandler = () => {
  return { type: "explorateTwo", data: data.value };
};
const saveStore = () => {
  // return new Promise((res, rej) => {
  // origin["legacy"] = JSON.parse(JSON.stringify(data.value));
  // });
};
defineExpose({ saveHandler, data });

onMounted(() => {
  if (props.isDownloadShow) {
  } else {
    setData("explorateTwo");
  }
  if (tablesInfo.explorateTwo) {
    data.value = tablesInfo.explorateTwo;
  }
});
</script>
<style lang="scss" scoped>
div[contenteditable] {
  outline: none;
}
.content-box {
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  &.left {
    justify-content: flex-start;
  }
  &.top-left {
    align-items: flex-start;
    justify-content: flex-start;
  }
}
.explorate {
  color: #000;
  width: 100%;
  height: 100%;
  // display: grid;

  font-family: sr, st;
  &.downMode {
    input,
    textarea {
      display: none;
    }
    .content-box {
      display: flex;
    }
  }
  // padding: 80px 0 0 0;
  > div {
    // padding: 20px 50px 30px;
  }

  &.downMode {
    input {
      display: none;
    }
    .content-box {
      display: flex;
    }
  }
  .title {
    text-align: center;
    margin-bottom: 10px;
  }
  .container {
    border: 1px solid #000;
    font-size: 20px;
    .table-excel {
      padding: 10px;
      table {
        width: 100%;
        border-collapse: collapse;
        border: 1px solid #000;
        tr {
          // border-bottom: 1px solid #000;
          &:last-of-type {
            td {
              border-bottom: none;
            }
          }
        }
        td {
          padding: 0 2px;
          box-sizing: border-box;
          text-align: center;
          max-width: 11%;
          height: 40px;
          border-right: 1px solid #000;
          border-bottom: 1px solid #000;
          &:last-of-type {
            border-right: none;
          }
          input {
            width: 100%;
            height: 100%;
            text-align: center;
          }
          > div {
            outline: none;
          }
        }
      }
    }
    .sign-box {
      padding: 0 10px;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      border-top: 1px solid #000;
      min-height: 40px;
      > div {
        width: 50%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        > div {
          flex: 1;
          height: 100%;
          outline: none;
          display: flex;
          align-items: center;
          justify-content: flex-start;
          line-height: 40px;
        }
      }
    }
    .table-body {
      border-top: 1px solid #000;
      margin-top: 10px;
      padding: 0 10px 10px;
      border-bottom: 1px solid #000;
      .item {
        display: flex;
        margin-bottom: 10px;
        &.half {
          align-items: center;
          justify-content: space-between;
          > div {
            width: 50%;
            flex-flow: row wrap;
          }
        }
        &.column {
          flex-direction: column;

          > div {
            outline: none;
            height: 100%;
            textarea {
              height: 100%;
              width: 100%;
              resize: none;
            }
          }
        }
        > div {
          input {
            &.under-line {
              width: 100%;

              border-bottom: 1px solid #000;
            }
            // border-bottom: 1px solid #000;
          }
        }
      }
    }
    .table-header {
      padding: 0 10px;
      .table-header-info {
        padding-left: 50px;
        .item {
          display: flex;
          align-items: center;
          justify-content: flex-start;
          width: 100%;
          > div {
            input {
              width: 100%;
              border-bottom: 1px solid #000;
            }
          }
        }
      }
    }
  }
  .footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 60px;
    margin-top: 10px;
    > span {
      > span {
        margin: 0 24px;
      }
    }
  }
}
</style>
